@atlaskit/task-decision 19.1.3 → 19.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,27 @@
1
1
  # @atlaskit/task-decision
2
2
 
3
+ ## 19.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#146310](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/146310)
8
+ [`fb230587c00e2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fb230587c00e2) -
9
+ [ux] [A11Y-9616] Add internationalisation to tasks and descisions plugin, wrap tasks item lists in
10
+ a fieldset to group them and give them an accessible name
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
16
+ ## 19.1.4
17
+
18
+ ### Patch Changes
19
+
20
+ - [#139777](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/139777)
21
+ [`cfdfe0077993d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cfdfe0077993d) -
22
+ Fix bug where a refs were passed incorrectly, preventing task item focus from being set
23
+ - Updated dependencies
24
+
3
25
  ## 19.1.3
4
26
 
5
27
  ### Patch Changes
@@ -26,6 +26,12 @@
26
26
  {
27
27
  "path": "../../../design-system/icon/afm-cc/tsconfig.json"
28
28
  },
29
+ {
30
+ "path": "../../../platform/feature-flags/afm-cc/tsconfig.json"
31
+ },
32
+ {
33
+ "path": "../../../platform/feature-flags-react/afm-cc/tsconfig.json"
34
+ },
29
35
  {
30
36
  "path": "../../../design-system/tokens/afm-cc/tsconfig.json"
31
37
  },
@@ -26,6 +26,9 @@
26
26
  {
27
27
  "path": "../../../design-system/icon/afm-jira/tsconfig.json"
28
28
  },
29
+ {
30
+ "path": "../../../platform/feature-flags-react/afm-jira/tsconfig.json"
31
+ },
29
32
  {
30
33
  "path": "../../../design-system/tokens/afm-jira/tsconfig.json"
31
34
  },
@@ -26,6 +26,9 @@
26
26
  {
27
27
  "path": "../../../design-system/icon/afm-post-office/tsconfig.json"
28
28
  },
29
+ {
30
+ "path": "../../../platform/feature-flags-react/afm-post-office/tsconfig.json"
31
+ },
29
32
  {
30
33
  "path": "../../../design-system/tokens/afm-post-office/tsconfig.json"
31
34
  },
@@ -16,6 +16,8 @@ var _checkboxChecked = _interopRequireDefault(require("@atlaskit/icon/core/check
16
16
  var _Item = _interopRequireDefault(require("./Item"));
17
17
  var _analyticsNext = require("@atlaskit/analytics-next");
18
18
  var _analytics = require("../analytics");
19
+ var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
20
+ var _useCallbackRef = require("use-callback-ref");
19
21
  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); }
20
22
  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 && {}.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; }
21
23
  // eslint-disable-next-line @atlassian/tangerine/import/entry-points
@@ -37,7 +39,7 @@ var taskCount = 0;
37
39
  var getCheckBoxId = function getCheckBoxId(localId) {
38
40
  return "".concat(localId, "-").concat(taskCount++);
39
41
  };
40
- var TaskItem = function TaskItem(props) {
42
+ var TaskItemWithoutRefFix = function TaskItemWithoutRefFix(props) {
41
43
  var appearance = props.appearance,
42
44
  isDone = props.isDone,
43
45
  isFocused = props.isFocused,
@@ -50,8 +52,8 @@ var TaskItem = function TaskItem(props) {
50
52
  taskId = props.taskId,
51
53
  onChange = props.onChange,
52
54
  onClick = props.onClick,
53
- createAnalyticsEvent = props.createAnalyticsEvent,
54
- inputRefFromProps = props.inputRef;
55
+ createAnalyticsEvent = props.createAnalyticsEvent;
56
+ var inputRefFromProps = props.inputRef;
55
57
  var checkBoxId = (0, _react.useMemo)(function () {
56
58
  return getCheckBoxId(taskId);
57
59
  }, [taskId]);
@@ -128,7 +130,98 @@ var TaskItem = function TaskItem(props) {
128
130
  checkBoxId: checkBoxId
129
131
  }, children);
130
132
  };
133
+ var TaskItemWithRefFix = function TaskItemWithRefFix(props) {
134
+ var appearance = props.appearance,
135
+ isDone = props.isDone,
136
+ isFocused = props.isFocused,
137
+ contentRef = props.contentRef,
138
+ children = props.children,
139
+ placeholder = props.placeholder,
140
+ showPlaceholder = props.showPlaceholder,
141
+ disabled = props.disabled,
142
+ dataAttributes = props.dataAttributes,
143
+ taskId = props.taskId,
144
+ onChange = props.onChange,
145
+ onClick = props.onClick,
146
+ createAnalyticsEvent = props.createAnalyticsEvent,
147
+ inputRefFromProps = props.inputRef;
148
+ var checkBoxId = (0, _react.useMemo)(function () {
149
+ return getCheckBoxId(taskId);
150
+ }, [taskId]);
151
+ var handleOnChange = (0, _react.useMemo)(function () {
152
+ return function (_evt) {
153
+ var newIsDone = !isDone;
154
+ if (onChange) {
155
+ onChange(taskId, newIsDone);
156
+ }
157
+ var action = newIsDone ? 'checked' : 'unchecked';
158
+ if (createAnalyticsEvent) {
159
+ (0, _analytics.createAndFireEventInElementsChannel)({
160
+ action: action,
161
+ actionSubject: 'action',
162
+ eventType: 'ui',
163
+ attributes: {
164
+ localId: taskId
165
+ }
166
+ })(createAnalyticsEvent);
167
+ }
168
+ };
169
+ }, [onChange, taskId, isDone, createAnalyticsEvent]);
170
+ var handleOnKeyPress = (0, _react.useMemo)(function () {
171
+ return function (event) {
172
+ if (event.key === 'Enter') {
173
+ handleOnChange(event);
174
+ }
175
+ };
176
+ }, [handleOnChange]);
177
+ var localInputRef = (0, _react.useRef)(null);
178
+ var inputRef = (0, _useCallbackRef.useMergeRefs)(inputRefFromProps === undefined ? [localInputRef] : [inputRefFromProps, localInputRef]);
179
+ var icon = /*#__PURE__*/_react.default.createElement("span", {
180
+ contentEditable: false,
181
+ className: (0, _runtime.ax)(["_16jlidpf _1o9zidpf _i0dl1tcg _1bsb1tcg _4t3i1tcg _kqswh2mm _1wpzv2br _1snx1r31 _1746glyw _dx3f1o36 _1h5xidpf _sqizidpf _fs2cidpf _1smcidpf _oezm15vq _1l0615vq _1abj1mn3 _18a711so _16np1elr _a27kkb7n _q3p7usvi _qhqx1nu9 _10cr1ssb _zfav1ssb _m7eu1ooe _l9o0n7od _1efjn7od _1u2istnw _32ro1j9a _1wn015vq _den512j9 _zh8l1b66 _g5w3stnw _whhepxbi _1stbpxbi _18tob3bt _1awt1ule _haf81ssb _ra781ssb _cr751ooe _1q8r7vkz _9l2s7vkz _1mh7kb7n _s3uktlke _1davidpf _8bo8stnw _psnc1ssb _4k421ssb _1rvv1ooe _13vl73ad _1t711tcg _1nuz1tcg _cs4qstnw _9j2j1ssb _1mwj1ssb _19l51ooe _12yy1d5g _1miy1elr _1umo18hz _tpz25w2r _k6dg18hz _1qduewfl _q8ft1fvw _1y9t5w2r _ut031fvw _gi9hr01l _1qp6muej _wxkgr01l _wo245w2r _c8dpmuej _d2dcsyzs _1eulsyzs _1bc7syzs _16fmsyzs _bhkusyzs _czfesyzs _1gxgsyzs _19w0syzs _1x1y1lg7"]),
182
+ style: {
183
+ "--_toyvsf": (0, _runtime.ix)("2px solid ".concat("var(--ds-border-focused, #388BFF)"))
184
+ }
185
+ }, /*#__PURE__*/_react.default.createElement("input", {
186
+ id: checkBoxId,
187
+ "aria-labelledby": "".concat(checkBoxId, "-wrapper"),
188
+ name: checkBoxId,
189
+ type: "checkbox",
190
+ onChange: handleOnChange,
191
+ onClick: onClick,
192
+ checked: !!isDone,
193
+ disabled: !!disabled,
194
+ suppressHydrationWarning: true,
195
+ onKeyPress: handleOnKeyPress,
196
+ ref: inputRef
197
+ }), isDone ? /*#__PURE__*/_react.default.createElement(_checkboxChecked.default, {
198
+ label: ""
199
+ }) : /*#__PURE__*/_react.default.createElement(CheckboxUncheckedIcon, {
200
+ label: ""
201
+ }));
202
+ _react.default.useEffect(function () {
203
+ if (isFocused && inputRef.current) {
204
+ var _inputRef$current4, _inputRef$current5;
205
+ (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 || _inputRef$current4.focus();
206
+ (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 || _inputRef$current5.blur();
207
+ setTimeout(function () {
208
+ var _inputRef$current6;
209
+ (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 || _inputRef$current6.focus();
210
+ }, 100);
211
+ }
212
+ }, [isFocused, inputRef]);
213
+ return /*#__PURE__*/_react.default.createElement(_Item.default, {
214
+ appearance: appearance,
215
+ contentRef: contentRef,
216
+ icon: icon,
217
+ placeholder: placeholder,
218
+ showPlaceholder: showPlaceholder,
219
+ itemType: "TASK",
220
+ dataAttributes: dataAttributes,
221
+ checkBoxId: checkBoxId
222
+ }, children);
223
+ };
131
224
 
132
225
  // This is to ensure that the "type" is exported, as it gets lost and not exported along with TaskItem after
133
226
  // going through the high order component.
134
- var _default = exports.default = (0, _analyticsNext.withAnalyticsEvents)()(TaskItem);
227
+ var _default = exports.default = (0, _platformFeatureFlagsReact.componentWithFG)('platform_editor_task_item_ref_fix', (0, _analyticsNext.withAnalyticsEvents)()(TaskItemWithRefFix), (0, _analyticsNext.withAnalyticsEvents)()(TaskItemWithoutRefFix));
@@ -16,19 +16,52 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
16
16
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
17
  var _react = _interopRequireWildcard(require("react"));
18
18
  var _analyticsNamespacedContext = require("@atlaskit/analytics-namespaced-context");
19
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
+ var _i18n = require("./i18n");
21
+ var _reactIntlNext = require("react-intl-next");
19
22
  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); }
20
23
  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 && {}.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; }
21
24
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
22
25
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
23
26
  var listStyles = null;
24
27
  var taskListStyles = null;
25
- var TaskList = exports.default = /*#__PURE__*/function (_PureComponent) {
26
- function TaskList() {
27
- (0, _classCallCheck2.default)(this, TaskList);
28
- return _callSuper(this, TaskList, arguments);
28
+ var TaskListNew = function TaskListNew(_ref) {
29
+ var listId = _ref.listId,
30
+ children = _ref.children;
31
+ var listSize = _react.default.Children.count(children);
32
+ var _useIntl = (0, _reactIntlNext.useIntl)(),
33
+ formatMessage = _useIntl.formatMessage;
34
+ if (!children) {
35
+ return null;
29
36
  }
30
- (0, _inherits2.default)(TaskList, _PureComponent);
31
- return (0, _createClass2.default)(TaskList, [{
37
+ return /*#__PURE__*/_react.default.createElement("div", {
38
+ role: "group",
39
+ "data-task-list-local-id": "",
40
+ "aria-label": formatMessage(_i18n.messages.fieldsetLabel),
41
+ className: (0, _runtime.ax)(["_2mzuglyw _19bvidpf"])
42
+ }, _react.default.Children.map(children, function (child, idx) {
43
+ var _ref2 = child.props,
44
+ localId = _ref2.localId;
45
+ return /*#__PURE__*/_react.default.createElement(_analyticsNamespacedContext.FabricElementsAnalyticsContext, {
46
+ data: {
47
+ listLocalId: listId,
48
+ listSize: listSize,
49
+ position: idx
50
+ }
51
+ }, /*#__PURE__*/_react.default.createElement("div", {
52
+ key: idx,
53
+ "data-task-local-id": localId || '',
54
+ className: (0, _runtime.ax)(["_19pk1b66"])
55
+ }, child));
56
+ }));
57
+ };
58
+ var TaskListOld = /*#__PURE__*/function (_PureComponent) {
59
+ function TaskListOld() {
60
+ (0, _classCallCheck2.default)(this, TaskListOld);
61
+ return _callSuper(this, TaskListOld, arguments);
62
+ }
63
+ (0, _inherits2.default)(TaskListOld, _PureComponent);
64
+ return (0, _createClass2.default)(TaskListOld, [{
32
65
  key: "render",
33
66
  value: function render() {
34
67
  var _this$props = this.props,
@@ -49,8 +82,8 @@ var TaskList = exports.default = /*#__PURE__*/function (_PureComponent) {
49
82
  "data-task-list-local-id": "",
50
83
  className: (0, _runtime.ax)(["_2mzuglyw _19bvidpf"])
51
84
  }, _react.default.Children.map(children, function (child, idx) {
52
- var _ref = child.props,
53
- localId = _ref.localId;
85
+ var _ref3 = child.props,
86
+ localId = _ref3.localId;
54
87
  return /*#__PURE__*/_react.default.createElement(_analyticsNamespacedContext.FabricElementsAnalyticsContext, {
55
88
  data: {
56
89
  listLocalId: listId,
@@ -65,4 +98,11 @@ var TaskList = exports.default = /*#__PURE__*/function (_PureComponent) {
65
98
  }));
66
99
  }
67
100
  }]);
68
- }(_react.PureComponent);
101
+ }(_react.PureComponent);
102
+ var TaskListNext = function TaskListNext(props) {
103
+ if ((0, _platformFeatureFlags.fg)('editor_a11y_group_around_action_items')) {
104
+ return /*#__PURE__*/_react.default.createElement(TaskListNew, props);
105
+ }
106
+ return /*#__PURE__*/_react.default.createElement(TaskListOld, props);
107
+ };
108
+ var _default = exports.default = TaskListNext;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.messages = void 0;
7
+ var _reactIntlNext = require("react-intl-next");
8
+ var messages = exports.messages = (0, _reactIntlNext.defineMessages)({
9
+ fieldsetLabel: {
10
+ id: 'fabric.editor.fieldsetLabel',
11
+ defaultMessage: 'Action Item List',
12
+ description: 'Label for a list of tasks/ action items'
13
+ }
14
+ });
@@ -11,6 +11,8 @@ import CheckboxCheckedIcon from '@atlaskit/icon/core/checkbox-checked';
11
11
  import Item from './Item';
12
12
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
13
13
  import { createAndFireEventInElementsChannel } from '../analytics';
14
+ import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
15
+ import { useMergeRefs } from 'use-callback-ref';
14
16
  const CheckboxUncheckedIcon = props => /*#__PURE__*/React.createElement(Icon, _extends({
15
17
  dangerouslySetGlyph: `<rect width="12.5" height="12.5" x="1.75" y="1.75" stroke="currentcolor" stroke-width="1.5" rx="1.25"/>`,
16
18
  type: 'core'
@@ -24,7 +26,7 @@ const CheckboxUncheckedIcon = props => /*#__PURE__*/React.createElement(Icon, _e
24
26
  const checkboxStyles = null;
25
27
  let taskCount = 0;
26
28
  const getCheckBoxId = localId => `${localId}-${taskCount++}`;
27
- const TaskItem = props => {
29
+ const TaskItemWithoutRefFix = props => {
28
30
  const {
29
31
  appearance,
30
32
  isDone,
@@ -38,9 +40,9 @@ const TaskItem = props => {
38
40
  taskId,
39
41
  onChange,
40
42
  onClick,
41
- createAnalyticsEvent,
42
- inputRef: inputRefFromProps
43
+ createAnalyticsEvent
43
44
  } = props;
45
+ const inputRefFromProps = props.inputRef;
44
46
  const checkBoxId = useMemo(() => getCheckBoxId(taskId), [taskId]);
45
47
  const handleOnChange = useMemo(() => {
46
48
  return _evt => {
@@ -110,8 +112,94 @@ const TaskItem = props => {
110
112
  checkBoxId: checkBoxId
111
113
  }, children);
112
114
  };
115
+ const TaskItemWithRefFix = props => {
116
+ const {
117
+ appearance,
118
+ isDone,
119
+ isFocused,
120
+ contentRef,
121
+ children,
122
+ placeholder,
123
+ showPlaceholder,
124
+ disabled,
125
+ dataAttributes,
126
+ taskId,
127
+ onChange,
128
+ onClick,
129
+ createAnalyticsEvent,
130
+ inputRef: inputRefFromProps
131
+ } = props;
132
+ const checkBoxId = useMemo(() => getCheckBoxId(taskId), [taskId]);
133
+ const handleOnChange = useMemo(() => {
134
+ return _evt => {
135
+ const newIsDone = !isDone;
136
+ if (onChange) {
137
+ onChange(taskId, newIsDone);
138
+ }
139
+ const action = newIsDone ? 'checked' : 'unchecked';
140
+ if (createAnalyticsEvent) {
141
+ createAndFireEventInElementsChannel({
142
+ action,
143
+ actionSubject: 'action',
144
+ eventType: 'ui',
145
+ attributes: {
146
+ localId: taskId
147
+ }
148
+ })(createAnalyticsEvent);
149
+ }
150
+ };
151
+ }, [onChange, taskId, isDone, createAnalyticsEvent]);
152
+ const handleOnKeyPress = useMemo(() => event => {
153
+ if (event.key === 'Enter') {
154
+ handleOnChange(event);
155
+ }
156
+ }, [handleOnChange]);
157
+ const localInputRef = useRef(null);
158
+ const inputRef = useMergeRefs(inputRefFromProps === undefined ? [localInputRef] : [inputRefFromProps, localInputRef]);
159
+ const icon = /*#__PURE__*/React.createElement("span", {
160
+ contentEditable: false,
161
+ className: ax(["_16jlidpf _1o9zidpf _i0dl1tcg _1bsb1tcg _4t3i1tcg _kqswh2mm _1wpzv2br _1snx1r31 _1746glyw _dx3f1o36 _1h5xidpf _sqizidpf _fs2cidpf _1smcidpf _oezm15vq _1l0615vq _1abj1mn3 _18a711so _16np1elr _a27kkb7n _q3p7usvi _qhqx1nu9 _10cr1ssb _zfav1ssb _m7eu1ooe _l9o0n7od _1efjn7od _1u2istnw _32ro1j9a _1wn015vq _den5ugt7 _zh8l1b66 _g5w3stnw _whhepxbi _1stbpxbi _18tob3bt _1awt1ule _haf81ssb _ra781ssb _cr751ooe _1q8r7vkz _9l2s7vkz _1mh7kb7n _s3uktlke _1davidpf _8bo8stnw _psnc1ssb _4k421ssb _1rvv1ooe _13vl73ad _1t711tcg _1nuz1tcg _cs4qstnw _9j2j1ssb _1mwj1ssb _19l51ooe _12yy1d5g _1miy1elr _1umo18hz _tpz25w2r _k6dg18hz _1qduewfl _q8ft1fvw _1y9t5w2r _ut031fvw _gi9hr01l _1qp6muej _wxkgr01l _wo245w2r _c8dpmuej _d2dcsyzs _1eulsyzs _1bc7syzs _16fmsyzs _bhkusyzs _czfesyzs _1gxgsyzs _19w0syzs _1x1y1lg7"])
162
+ }, /*#__PURE__*/React.createElement("input", {
163
+ id: checkBoxId,
164
+ "aria-labelledby": `${checkBoxId}-wrapper`,
165
+ name: checkBoxId,
166
+ type: "checkbox",
167
+ onChange: handleOnChange,
168
+ onClick: onClick,
169
+ checked: !!isDone,
170
+ disabled: !!disabled,
171
+ suppressHydrationWarning: true,
172
+ onKeyPress: handleOnKeyPress,
173
+ ref: inputRef
174
+ }), isDone ? /*#__PURE__*/React.createElement(CheckboxCheckedIcon, {
175
+ label: ""
176
+ }) : /*#__PURE__*/React.createElement(CheckboxUncheckedIcon, {
177
+ label: ""
178
+ }));
179
+ React.useEffect(() => {
180
+ if (isFocused && inputRef.current) {
181
+ var _inputRef$current4, _inputRef$current5;
182
+ (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.focus();
183
+ (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.blur();
184
+ setTimeout(() => {
185
+ var _inputRef$current6;
186
+ (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 ? void 0 : _inputRef$current6.focus();
187
+ }, 100);
188
+ }
189
+ }, [isFocused, inputRef]);
190
+ return /*#__PURE__*/React.createElement(Item, {
191
+ appearance: appearance,
192
+ contentRef: contentRef,
193
+ icon: icon,
194
+ placeholder: placeholder,
195
+ showPlaceholder: showPlaceholder,
196
+ itemType: "TASK",
197
+ dataAttributes: dataAttributes,
198
+ checkBoxId: checkBoxId
199
+ }, children);
200
+ };
113
201
 
114
202
  // This is to ensure that the "type" is exported, as it gets lost and not exported along with TaskItem after
115
203
  // going through the high order component.
116
204
 
117
- export default withAnalyticsEvents()(TaskItem);
205
+ export default componentWithFG('platform_editor_task_item_ref_fix', withAnalyticsEvents()(TaskItemWithRefFix), withAnalyticsEvents()(TaskItemWithoutRefFix));
@@ -1,12 +1,47 @@
1
1
  /* TaskList.tsx generated by @compiled/babel-plugin v0.36.1 */
2
2
  import "./TaskList.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
- import React from 'react';
5
- import { PureComponent } from 'react';
4
+ import React, { PureComponent } from 'react';
6
5
  import { FabricElementsAnalyticsContext } from '@atlaskit/analytics-namespaced-context';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
7
+ import { messages } from './i18n';
8
+ import { useIntl } from 'react-intl-next';
7
9
  const listStyles = null;
8
10
  const taskListStyles = null;
9
- export default class TaskList extends PureComponent {
11
+ const TaskListNew = ({
12
+ listId,
13
+ children
14
+ }) => {
15
+ const listSize = React.Children.count(children);
16
+ const {
17
+ formatMessage
18
+ } = useIntl();
19
+ if (!children) {
20
+ return null;
21
+ }
22
+ return /*#__PURE__*/React.createElement("div", {
23
+ role: "group",
24
+ "data-task-list-local-id": "",
25
+ "aria-label": formatMessage(messages.fieldsetLabel),
26
+ className: ax(["_2mzuglyw _19bvidpf"])
27
+ }, React.Children.map(children, (child, idx) => {
28
+ const {
29
+ localId
30
+ } = child.props;
31
+ return /*#__PURE__*/React.createElement(FabricElementsAnalyticsContext, {
32
+ data: {
33
+ listLocalId: listId,
34
+ listSize,
35
+ position: idx
36
+ }
37
+ }, /*#__PURE__*/React.createElement("div", {
38
+ key: idx,
39
+ "data-task-local-id": localId || '',
40
+ className: ax(["_19pk1b66"])
41
+ }, child));
42
+ }));
43
+ };
44
+ class TaskListOld extends PureComponent {
10
45
  render() {
11
46
  const {
12
47
  listId,
@@ -43,4 +78,11 @@ export default class TaskList extends PureComponent {
43
78
  }, child));
44
79
  }));
45
80
  }
46
- }
81
+ }
82
+ const TaskListNext = props => {
83
+ if (fg('editor_a11y_group_around_action_items')) {
84
+ return /*#__PURE__*/React.createElement(TaskListNew, props);
85
+ }
86
+ return /*#__PURE__*/React.createElement(TaskListOld, props);
87
+ };
88
+ export default TaskListNext;
@@ -0,0 +1,8 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export const messages = defineMessages({
3
+ fieldsetLabel: {
4
+ id: 'fabric.editor.fieldsetLabel',
5
+ defaultMessage: 'Action Item List',
6
+ description: 'Label for a list of tasks/ action items'
7
+ }
8
+ });
@@ -11,6 +11,8 @@ import CheckboxCheckedIcon from '@atlaskit/icon/core/checkbox-checked';
11
11
  import Item from './Item';
12
12
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
13
13
  import { createAndFireEventInElementsChannel } from '../analytics';
14
+ import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
15
+ import { useMergeRefs } from 'use-callback-ref';
14
16
  var CheckboxUncheckedIcon = function CheckboxUncheckedIcon(props) {
15
17
  return /*#__PURE__*/React.createElement(Icon, _extends({
16
18
  dangerouslySetGlyph: "<rect width=\"12.5\" height=\"12.5\" x=\"1.75\" y=\"1.75\" stroke=\"currentcolor\" stroke-width=\"1.5\" rx=\"1.25\"/>",
@@ -28,7 +30,7 @@ var taskCount = 0;
28
30
  var getCheckBoxId = function getCheckBoxId(localId) {
29
31
  return "".concat(localId, "-").concat(taskCount++);
30
32
  };
31
- var TaskItem = function TaskItem(props) {
33
+ var TaskItemWithoutRefFix = function TaskItemWithoutRefFix(props) {
32
34
  var appearance = props.appearance,
33
35
  isDone = props.isDone,
34
36
  isFocused = props.isFocused,
@@ -41,8 +43,8 @@ var TaskItem = function TaskItem(props) {
41
43
  taskId = props.taskId,
42
44
  onChange = props.onChange,
43
45
  onClick = props.onClick,
44
- createAnalyticsEvent = props.createAnalyticsEvent,
45
- inputRefFromProps = props.inputRef;
46
+ createAnalyticsEvent = props.createAnalyticsEvent;
47
+ var inputRefFromProps = props.inputRef;
46
48
  var checkBoxId = useMemo(function () {
47
49
  return getCheckBoxId(taskId);
48
50
  }, [taskId]);
@@ -119,8 +121,99 @@ var TaskItem = function TaskItem(props) {
119
121
  checkBoxId: checkBoxId
120
122
  }, children);
121
123
  };
124
+ var TaskItemWithRefFix = function TaskItemWithRefFix(props) {
125
+ var appearance = props.appearance,
126
+ isDone = props.isDone,
127
+ isFocused = props.isFocused,
128
+ contentRef = props.contentRef,
129
+ children = props.children,
130
+ placeholder = props.placeholder,
131
+ showPlaceholder = props.showPlaceholder,
132
+ disabled = props.disabled,
133
+ dataAttributes = props.dataAttributes,
134
+ taskId = props.taskId,
135
+ onChange = props.onChange,
136
+ onClick = props.onClick,
137
+ createAnalyticsEvent = props.createAnalyticsEvent,
138
+ inputRefFromProps = props.inputRef;
139
+ var checkBoxId = useMemo(function () {
140
+ return getCheckBoxId(taskId);
141
+ }, [taskId]);
142
+ var handleOnChange = useMemo(function () {
143
+ return function (_evt) {
144
+ var newIsDone = !isDone;
145
+ if (onChange) {
146
+ onChange(taskId, newIsDone);
147
+ }
148
+ var action = newIsDone ? 'checked' : 'unchecked';
149
+ if (createAnalyticsEvent) {
150
+ createAndFireEventInElementsChannel({
151
+ action: action,
152
+ actionSubject: 'action',
153
+ eventType: 'ui',
154
+ attributes: {
155
+ localId: taskId
156
+ }
157
+ })(createAnalyticsEvent);
158
+ }
159
+ };
160
+ }, [onChange, taskId, isDone, createAnalyticsEvent]);
161
+ var handleOnKeyPress = useMemo(function () {
162
+ return function (event) {
163
+ if (event.key === 'Enter') {
164
+ handleOnChange(event);
165
+ }
166
+ };
167
+ }, [handleOnChange]);
168
+ var localInputRef = useRef(null);
169
+ var inputRef = useMergeRefs(inputRefFromProps === undefined ? [localInputRef] : [inputRefFromProps, localInputRef]);
170
+ var icon = /*#__PURE__*/React.createElement("span", {
171
+ contentEditable: false,
172
+ className: ax(["_16jlidpf _1o9zidpf _i0dl1tcg _1bsb1tcg _4t3i1tcg _kqswh2mm _1wpzv2br _1snx1r31 _1746glyw _dx3f1o36 _1h5xidpf _sqizidpf _fs2cidpf _1smcidpf _oezm15vq _1l0615vq _1abj1mn3 _18a711so _16np1elr _a27kkb7n _q3p7usvi _qhqx1nu9 _10cr1ssb _zfav1ssb _m7eu1ooe _l9o0n7od _1efjn7od _1u2istnw _32ro1j9a _1wn015vq _den512j9 _zh8l1b66 _g5w3stnw _whhepxbi _1stbpxbi _18tob3bt _1awt1ule _haf81ssb _ra781ssb _cr751ooe _1q8r7vkz _9l2s7vkz _1mh7kb7n _s3uktlke _1davidpf _8bo8stnw _psnc1ssb _4k421ssb _1rvv1ooe _13vl73ad _1t711tcg _1nuz1tcg _cs4qstnw _9j2j1ssb _1mwj1ssb _19l51ooe _12yy1d5g _1miy1elr _1umo18hz _tpz25w2r _k6dg18hz _1qduewfl _q8ft1fvw _1y9t5w2r _ut031fvw _gi9hr01l _1qp6muej _wxkgr01l _wo245w2r _c8dpmuej _d2dcsyzs _1eulsyzs _1bc7syzs _16fmsyzs _bhkusyzs _czfesyzs _1gxgsyzs _19w0syzs _1x1y1lg7"]),
173
+ style: {
174
+ "--_toyvsf": ix("2px solid ".concat("var(--ds-border-focused, #388BFF)"))
175
+ }
176
+ }, /*#__PURE__*/React.createElement("input", {
177
+ id: checkBoxId,
178
+ "aria-labelledby": "".concat(checkBoxId, "-wrapper"),
179
+ name: checkBoxId,
180
+ type: "checkbox",
181
+ onChange: handleOnChange,
182
+ onClick: onClick,
183
+ checked: !!isDone,
184
+ disabled: !!disabled,
185
+ suppressHydrationWarning: true,
186
+ onKeyPress: handleOnKeyPress,
187
+ ref: inputRef
188
+ }), isDone ? /*#__PURE__*/React.createElement(CheckboxCheckedIcon, {
189
+ label: ""
190
+ }) : /*#__PURE__*/React.createElement(CheckboxUncheckedIcon, {
191
+ label: ""
192
+ }));
193
+ React.useEffect(function () {
194
+ if (isFocused && inputRef.current) {
195
+ var _inputRef$current4, _inputRef$current5;
196
+ (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 || _inputRef$current4.focus();
197
+ (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 || _inputRef$current5.blur();
198
+ setTimeout(function () {
199
+ var _inputRef$current6;
200
+ (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 || _inputRef$current6.focus();
201
+ }, 100);
202
+ }
203
+ }, [isFocused, inputRef]);
204
+ return /*#__PURE__*/React.createElement(Item, {
205
+ appearance: appearance,
206
+ contentRef: contentRef,
207
+ icon: icon,
208
+ placeholder: placeholder,
209
+ showPlaceholder: showPlaceholder,
210
+ itemType: "TASK",
211
+ dataAttributes: dataAttributes,
212
+ checkBoxId: checkBoxId
213
+ }, children);
214
+ };
122
215
 
123
216
  // This is to ensure that the "type" is exported, as it gets lost and not exported along with TaskItem after
124
217
  // going through the high order component.
125
218
 
126
- export default withAnalyticsEvents()(TaskItem);
219
+ export default componentWithFG('platform_editor_task_item_ref_fix', withAnalyticsEvents()(TaskItemWithRefFix), withAnalyticsEvents()(TaskItemWithoutRefFix));
@@ -8,18 +8,50 @@ import "./TaskList.compiled.css";
8
8
  import { ax, ix } from "@compiled/react/runtime";
9
9
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
10
10
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
- import React from 'react';
12
- import { PureComponent } from 'react';
11
+ import React, { PureComponent } from 'react';
13
12
  import { FabricElementsAnalyticsContext } from '@atlaskit/analytics-namespaced-context';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
14
+ import { messages } from './i18n';
15
+ import { useIntl } from 'react-intl-next';
14
16
  var listStyles = null;
15
17
  var taskListStyles = null;
16
- var TaskList = /*#__PURE__*/function (_PureComponent) {
17
- function TaskList() {
18
- _classCallCheck(this, TaskList);
19
- return _callSuper(this, TaskList, arguments);
18
+ var TaskListNew = function TaskListNew(_ref) {
19
+ var listId = _ref.listId,
20
+ children = _ref.children;
21
+ var listSize = React.Children.count(children);
22
+ var _useIntl = useIntl(),
23
+ formatMessage = _useIntl.formatMessage;
24
+ if (!children) {
25
+ return null;
20
26
  }
21
- _inherits(TaskList, _PureComponent);
22
- return _createClass(TaskList, [{
27
+ return /*#__PURE__*/React.createElement("div", {
28
+ role: "group",
29
+ "data-task-list-local-id": "",
30
+ "aria-label": formatMessage(messages.fieldsetLabel),
31
+ className: ax(["_2mzuglyw _19bvidpf"])
32
+ }, React.Children.map(children, function (child, idx) {
33
+ var _ref2 = child.props,
34
+ localId = _ref2.localId;
35
+ return /*#__PURE__*/React.createElement(FabricElementsAnalyticsContext, {
36
+ data: {
37
+ listLocalId: listId,
38
+ listSize: listSize,
39
+ position: idx
40
+ }
41
+ }, /*#__PURE__*/React.createElement("div", {
42
+ key: idx,
43
+ "data-task-local-id": localId || '',
44
+ className: ax(["_19pk1b66"])
45
+ }, child));
46
+ }));
47
+ };
48
+ var TaskListOld = /*#__PURE__*/function (_PureComponent) {
49
+ function TaskListOld() {
50
+ _classCallCheck(this, TaskListOld);
51
+ return _callSuper(this, TaskListOld, arguments);
52
+ }
53
+ _inherits(TaskListOld, _PureComponent);
54
+ return _createClass(TaskListOld, [{
23
55
  key: "render",
24
56
  value: function render() {
25
57
  var _this$props = this.props,
@@ -40,8 +72,8 @@ var TaskList = /*#__PURE__*/function (_PureComponent) {
40
72
  "data-task-list-local-id": "",
41
73
  className: ax(["_2mzuglyw _19bvidpf"])
42
74
  }, React.Children.map(children, function (child, idx) {
43
- var _ref = child.props,
44
- localId = _ref.localId;
75
+ var _ref3 = child.props,
76
+ localId = _ref3.localId;
45
77
  return /*#__PURE__*/React.createElement(FabricElementsAnalyticsContext, {
46
78
  data: {
47
79
  listLocalId: listId,
@@ -57,4 +89,10 @@ var TaskList = /*#__PURE__*/function (_PureComponent) {
57
89
  }
58
90
  }]);
59
91
  }(PureComponent);
60
- export { TaskList as default };
92
+ var TaskListNext = function TaskListNext(props) {
93
+ if (fg('editor_a11y_group_around_action_items')) {
94
+ return /*#__PURE__*/React.createElement(TaskListNew, props);
95
+ }
96
+ return /*#__PURE__*/React.createElement(TaskListOld, props);
97
+ };
98
+ export default TaskListNext;
@@ -0,0 +1,8 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export var messages = defineMessages({
3
+ fieldsetLabel: {
4
+ id: 'fabric.editor.fieldsetLabel',
5
+ defaultMessage: 'Action Item List',
6
+ description: 'Label for a list of tasks/ action items'
7
+ }
8
+ });
@@ -1,4 +1,4 @@
1
- import React, { type RefObject } from 'react';
1
+ import React, { type Ref } from 'react';
2
2
  import { PureComponent } from 'react';
3
3
  import { type Appearance, type ContentRef, type TaskDecisionProvider } from '../types';
4
4
  export interface Props {
@@ -19,7 +19,7 @@ export interface Props {
19
19
  dataAttributes?: {
20
20
  [key: string]: string | number;
21
21
  };
22
- inputRef?: RefObject<HTMLInputElement>;
22
+ inputRef?: Ref<HTMLInputElement>;
23
23
  disableOnChange?: boolean;
24
24
  }
25
25
  export interface State {
@@ -2,7 +2,7 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import React, { type RefObject } from 'react';
5
+ import React, { Ref } from 'react';
6
6
  import { type Appearance, type ContentRef } from '../types';
7
7
  import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
8
8
  export interface Props {
@@ -21,7 +21,7 @@ export interface Props {
21
21
  dataAttributes?: {
22
22
  [key: string]: string | number;
23
23
  };
24
- inputRef?: RefObject<HTMLInputElement>;
24
+ inputRef?: Ref<HTMLInputElement>;
25
25
  }
26
- declare const _default: React.ForwardRefExoticComponent<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any>>;
26
+ declare const _default: React.FC<Omit<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any>, "ref"> & React.RefAttributes<any>>;
27
27
  export default _default;
@@ -1,8 +1,11 @@
1
- import { PureComponent, type ReactNode } from 'react';
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { ReactNode } from 'react';
2
6
  export interface Props {
3
7
  listId?: string;
4
8
  children?: ReactNode;
5
9
  }
6
- export default class TaskList extends PureComponent<Props, {}> {
7
- render(): JSX.Element | null;
8
- }
10
+ declare const TaskListNext: (props: Props) => JSX.Element;
11
+ export default TaskListNext;
@@ -0,0 +1,7 @@
1
+ export declare const messages: {
2
+ fieldsetLabel: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ };
@@ -1,4 +1,4 @@
1
- import React, { type RefObject } from 'react';
1
+ import React, { type Ref } from 'react';
2
2
  import { PureComponent } from 'react';
3
3
  import { type Appearance, type ContentRef, type TaskDecisionProvider } from '../types';
4
4
  export interface Props {
@@ -19,7 +19,7 @@ export interface Props {
19
19
  dataAttributes?: {
20
20
  [key: string]: string | number;
21
21
  };
22
- inputRef?: RefObject<HTMLInputElement>;
22
+ inputRef?: Ref<HTMLInputElement>;
23
23
  disableOnChange?: boolean;
24
24
  }
25
25
  export interface State {
@@ -2,7 +2,7 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import React, { type RefObject } from 'react';
5
+ import React, { Ref } from 'react';
6
6
  import { type Appearance, type ContentRef } from '../types';
7
7
  import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
8
8
  export interface Props {
@@ -21,7 +21,7 @@ export interface Props {
21
21
  dataAttributes?: {
22
22
  [key: string]: string | number;
23
23
  };
24
- inputRef?: RefObject<HTMLInputElement>;
24
+ inputRef?: Ref<HTMLInputElement>;
25
25
  }
26
- declare const _default: React.ForwardRefExoticComponent<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any>>;
26
+ declare const _default: React.FC<Omit<Omit<Props, keyof WithAnalyticsEventsProps> & React.RefAttributes<any>, "ref"> & React.RefAttributes<any>>;
27
27
  export default _default;
@@ -1,8 +1,11 @@
1
- import { PureComponent, type ReactNode } from 'react';
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { ReactNode } from 'react';
2
6
  export interface Props {
3
7
  listId?: string;
4
8
  children?: ReactNode;
5
9
  }
6
- export default class TaskList extends PureComponent<Props, {}> {
7
- render(): JSX.Element | null;
8
- }
10
+ declare const TaskListNext: (props: Props) => JSX.Element;
11
+ export default TaskListNext;
@@ -0,0 +1,7 @@
1
+ export declare const messages: {
2
+ fieldsetLabel: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/task-decision",
3
- "version": "19.1.3",
3
+ "version": "19.2.0",
4
4
  "description": "Tasks and decisions react components",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -43,11 +43,15 @@
43
43
  "dependencies": {
44
44
  "@atlaskit/analytics-namespaced-context": "^7.0.0",
45
45
  "@atlaskit/analytics-next": "^11.0.0",
46
- "@atlaskit/icon": "^25.3.0",
47
- "@atlaskit/tokens": "^4.5.0",
46
+ "@atlaskit/icon": "^25.6.0",
47
+ "@atlaskit/platform-feature-flags": "^1.1.0",
48
+ "@atlaskit/platform-feature-flags-react": "^0.1.0",
49
+ "@atlaskit/tokens": "^4.8.0",
48
50
  "@atlaskit/util-service-support": "^6.3.0",
49
51
  "@babel/runtime": "^7.0.0",
50
52
  "@compiled/react": "^0.18.3",
53
+ "react-intl-next": "npm:react-intl@^5.18.1",
54
+ "use-callback-ref": "^1.2.3",
51
55
  "uuid": "^3.1.0"
52
56
  },
53
57
  "peerDependencies": {
@@ -56,10 +60,10 @@
56
60
  "url-search-params": "^0.10.0"
57
61
  },
58
62
  "devDependencies": {
59
- "@af/visual-regression": "^1.3.0",
63
+ "@af/visual-regression": "workspace:^",
60
64
  "@atlaskit/analytics-listeners": "^9.0.0",
61
- "@atlaskit/elements-test-helpers": "^0.9.0",
62
- "@atlaskit/ssr": "^0.4.0",
65
+ "@atlaskit/elements-test-helpers": "workspace:^",
66
+ "@atlaskit/ssr": "workspace:^",
63
67
  "@atlaskit/util-data-test": "^18.0.0",
64
68
  "@testing-library/react": "^13.4.0",
65
69
  "@testing-library/user-event": "^14.4.3",
@@ -84,5 +88,10 @@
84
88
  "compiled"
85
89
  ]
86
90
  }
91
+ },
92
+ "platform-feature-flags": {
93
+ "editor_a11y_group_around_action_items": {
94
+ "type": "boolean"
95
+ }
87
96
  }
88
97
  }