@atlaskit/inline-edit 12.2.6 → 12.2.8

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/inline-edit
2
2
 
3
+ ## 12.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 12.2.7
10
+
11
+ ### Patch Changes
12
+
13
+ - [`18aeca8c199`](https://bitbucket.org/atlassian/atlassian-frontend/commits/18aeca8c199) - Internal change to update token references. There is no expected behaviour or visual change.
14
+
3
15
  ## 12.2.6
4
16
 
5
17
  ### Patch Changes
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -11,5 +10,4 @@ Object.defineProperty(exports, "default", {
11
10
  return _inlineEdit.default;
12
11
  }
13
12
  });
14
-
15
13
  var _inlineEdit = _interopRequireDefault(require("../inline-edit"));
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -11,5 +10,4 @@ Object.defineProperty(exports, "default", {
11
10
  return _inlineEditableTextfield.default;
12
11
  }
13
12
  });
14
-
15
13
  var _inlineEditableTextfield = _interopRequireDefault(require("../inline-editable-textfield"));
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -17,7 +16,5 @@ Object.defineProperty(exports, "default", {
17
16
  return _inlineEdit.default;
18
17
  }
19
18
  });
20
-
21
19
  var _inlineEdit = _interopRequireDefault(require("./inline-edit"));
22
-
23
20
  var _inlineEditableTextfield = _interopRequireDefault(require("./inline-editable-textfield"));
@@ -1,46 +1,27 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.default = void 0;
11
-
12
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
-
14
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
-
16
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
-
18
12
  var _react = _interopRequireWildcard(require("react"));
19
-
20
13
  var _react2 = require("@emotion/react");
21
-
22
14
  var _analyticsNext = require("@atlaskit/analytics-next");
23
-
24
15
  var _Field = _interopRequireDefault(require("@atlaskit/form/Field"));
25
-
26
16
  var _Form = _interopRequireDefault(require("@atlaskit/form/Form"));
27
-
28
17
  var _components = _interopRequireDefault(require("@atlaskit/theme/components"));
29
-
30
18
  var _buttons = _interopRequireDefault(require("./internal/buttons"));
31
-
32
19
  var _useButtonFocusHook2 = _interopRequireDefault(require("./internal/hooks/use-button-focus-hook"));
33
-
34
20
  var _readView = _interopRequireDefault(require("./internal/read-view"));
35
-
36
21
  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); }
37
-
38
22
  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; }
39
-
40
23
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
41
-
42
24
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
43
-
44
25
  var fieldStyles = (0, _react2.css)({
45
26
  maxWidth: '100%',
46
27
  position: 'relative'
@@ -51,71 +32,62 @@ var buttonStyles = (0, _react2.css)({
51
32
  var analyticsAttributes = {
52
33
  componentName: 'inlineEdit',
53
34
  packageName: "@atlaskit/inline-edit",
54
- packageVersion: "12.2.6"
35
+ packageVersion: "12.2.8"
55
36
  };
56
-
57
37
  var noop = function noop() {};
58
-
59
38
  var InnerInlineEdit = function InnerInlineEdit(props) {
60
39
  var _props$startWithEditV = props.startWithEditViewOpen,
61
- startWithEditViewOpen = _props$startWithEditV === void 0 ? false : _props$startWithEditV,
62
- _props$keepEditViewOp = props.keepEditViewOpenOnBlur,
63
- keepEditViewOpenOnBlur = _props$keepEditViewOp === void 0 ? false : _props$keepEditViewOp,
64
- _props$hideActionButt = props.hideActionButtons,
65
- hideActionButtons = _props$hideActionButt === void 0 ? false : _props$hideActionButt,
66
- _props$isRequired = props.isRequired,
67
- isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
68
- _props$readViewFitCon = props.readViewFitContainerWidth,
69
- readViewFitContainerWidth = _props$readViewFitCon === void 0 ? false : _props$readViewFitCon,
70
- _props$editButtonLabe = props.editButtonLabel,
71
- editButtonLabel = _props$editButtonLabe === void 0 ? 'Edit' : _props$editButtonLabe,
72
- _props$confirmButtonL = props.confirmButtonLabel,
73
- confirmButtonLabel = _props$confirmButtonL === void 0 ? 'Confirm' : _props$confirmButtonL,
74
- _props$cancelButtonLa = props.cancelButtonLabel,
75
- cancelButtonLabel = _props$cancelButtonLa === void 0 ? 'Cancel' : _props$cancelButtonLa,
76
- defaultValue = props.defaultValue,
77
- isEditing = props.isEditing,
78
- label = props.label,
79
- validate = props.validate,
80
- readView = props.readView,
81
- editView = props.editView,
82
- analyticsContext = props.analyticsContext,
83
- providedOnConfirm = props.onConfirm,
84
- _props$onCancel = props.onCancel,
85
- providedOnCancel = _props$onCancel === void 0 ? noop : _props$onCancel,
86
- _props$onEdit = props.onEdit,
87
- providedOnEdit = _props$onEdit === void 0 ? noop : _props$onEdit,
88
- mode = props.mode;
40
+ startWithEditViewOpen = _props$startWithEditV === void 0 ? false : _props$startWithEditV,
41
+ _props$keepEditViewOp = props.keepEditViewOpenOnBlur,
42
+ keepEditViewOpenOnBlur = _props$keepEditViewOp === void 0 ? false : _props$keepEditViewOp,
43
+ _props$hideActionButt = props.hideActionButtons,
44
+ hideActionButtons = _props$hideActionButt === void 0 ? false : _props$hideActionButt,
45
+ _props$isRequired = props.isRequired,
46
+ isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
47
+ _props$readViewFitCon = props.readViewFitContainerWidth,
48
+ readViewFitContainerWidth = _props$readViewFitCon === void 0 ? false : _props$readViewFitCon,
49
+ _props$editButtonLabe = props.editButtonLabel,
50
+ editButtonLabel = _props$editButtonLabe === void 0 ? 'Edit' : _props$editButtonLabe,
51
+ _props$confirmButtonL = props.confirmButtonLabel,
52
+ confirmButtonLabel = _props$confirmButtonL === void 0 ? 'Confirm' : _props$confirmButtonL,
53
+ _props$cancelButtonLa = props.cancelButtonLabel,
54
+ cancelButtonLabel = _props$cancelButtonLa === void 0 ? 'Cancel' : _props$cancelButtonLa,
55
+ defaultValue = props.defaultValue,
56
+ isEditing = props.isEditing,
57
+ label = props.label,
58
+ validate = props.validate,
59
+ readView = props.readView,
60
+ editView = props.editView,
61
+ analyticsContext = props.analyticsContext,
62
+ providedOnConfirm = props.onConfirm,
63
+ _props$onCancel = props.onCancel,
64
+ providedOnCancel = _props$onCancel === void 0 ? noop : _props$onCancel,
65
+ _props$onEdit = props.onEdit,
66
+ providedOnEdit = _props$onEdit === void 0 ? noop : _props$onEdit,
67
+ mode = props.mode;
89
68
  var wasFocusReceivedSinceLastBlurRef = (0, _react.useRef)(false);
90
69
  var isControlled = typeof isEditing === 'undefined';
91
-
92
70
  var _useState = (0, _react.useState)(startWithEditViewOpen),
93
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
94
- isEditingState = _useState2[0],
95
- setEditingState = _useState2[1];
96
-
71
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
72
+ isEditingState = _useState2[0],
73
+ setEditingState = _useState2[1];
97
74
  var timerRef = (0, _react.useRef)();
98
-
99
75
  var _useButtonFocusHook = (0, _useButtonFocusHook2.default)(isEditing, isEditingState),
100
- editButtonRef = _useButtonFocusHook.editButtonRef,
101
- editViewRef = _useButtonFocusHook.editViewRef,
102
- shouldBeEditing = _useButtonFocusHook.shouldBeEditing,
103
- doNotFocusOnEditButton = _useButtonFocusHook.doNotFocusOnEditButton;
104
-
76
+ editButtonRef = _useButtonFocusHook.editButtonRef,
77
+ editViewRef = _useButtonFocusHook.editViewRef,
78
+ shouldBeEditing = _useButtonFocusHook.shouldBeEditing,
79
+ doNotFocusOnEditButton = _useButtonFocusHook.doNotFocusOnEditButton;
105
80
  var onCancel = (0, _react.useCallback)(function () {
106
81
  if (isControlled) {
107
82
  setEditingState(false);
108
83
  }
109
-
110
84
  providedOnCancel();
111
85
  }, [isControlled, providedOnCancel]);
112
86
  var onEditRequested = (0, _react.useCallback)(function () {
113
87
  if (isControlled) {
114
88
  setEditingState(true);
115
89
  }
116
-
117
90
  providedOnEdit();
118
-
119
91
  if (shouldBeEditing && editViewRef.current) {
120
92
  editViewRef.current.focus();
121
93
  }
@@ -125,7 +97,6 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
125
97
  if (isControlled) {
126
98
  setEditingState(false);
127
99
  }
128
-
129
100
  providedOnConfirm(value, analyticsEvent);
130
101
  },
131
102
  action: 'confirmed',
@@ -138,12 +109,12 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
138
109
  var tryAutoSubmitWhenBlur = (0, _react.useCallback)(function (isFieldInvalid, onSubmit, formRef) {
139
110
  if (!isFieldInvalid && !wasFocusReceivedSinceLastBlurRef.current && formRef.current) {
140
111
  doNotFocusOnEditButton();
141
-
142
112
  if (formRef.current.checkValidity()) {
143
113
  onSubmit();
144
114
  }
145
115
  }
146
116
  }, [doNotFocusOnEditButton]);
117
+
147
118
  /** If keepEditViewOpenOnBlur prop is set to false, will call confirmIfUnfocused() which
148
119
  * confirms the value, if the focus is not transferred to the action buttons
149
120
  *
@@ -157,7 +128,6 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
157
128
  * - focus on input first, and then use keyboard to `submit`
158
129
  * - focus on input first, and then click anywhere else on the page (outside of edit view wrapper) to `submit` (auto save)
159
130
  */
160
-
161
131
  var onEditViewWrapperBlur = (0, _react.useCallback)(function (isFieldInvalid, onSubmit, formRef) {
162
132
  if (!keepEditViewOpenOnBlur) {
163
133
  wasFocusReceivedSinceLastBlurRef.current = false;
@@ -166,6 +136,7 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
166
136
  }, 0);
167
137
  }
168
138
  }, [keepEditViewOpenOnBlur, tryAutoSubmitWhenBlur]);
139
+
169
140
  /** Gets called when focus is transferred to the editView, or action buttons
170
141
  *
171
142
  * There are three paths here the function can be called:
@@ -174,11 +145,9 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
174
145
  * - when a user use keyboard to tab into `editView`
175
146
  * - when a user use keyboard to tab into `submit` when they were on input field
176
147
  */
177
-
178
148
  var onEditViewWrapperFocus = (0, _react.useCallback)(function () {
179
149
  wasFocusReceivedSinceLastBlurRef.current = true;
180
150
  }, []);
181
-
182
151
  var renderReadView = function renderReadView() {
183
152
  return (0, _react2.jsx)(_readView.default, {
184
153
  editButtonLabel: editButtonLabel,
@@ -189,22 +158,20 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
189
158
  readView: readView
190
159
  });
191
160
  };
192
- /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
193
-
194
161
 
162
+ /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
195
163
  return (0, _react2.jsx)(_Form.default, {
196
164
  onSubmit: function onSubmit(data) {
197
165
  return onConfirm(data.inlineEdit);
198
166
  }
199
167
  }, function (_ref) {
200
168
  var _ref$formProps = _ref.formProps,
201
- _onKeyDown = _ref$formProps.onKeyDown,
202
- onSubmit = _ref$formProps.onSubmit,
203
- formRef = _ref$formProps.ref;
169
+ _onKeyDown = _ref$formProps.onKeyDown,
170
+ onSubmit = _ref$formProps.onSubmit,
171
+ formRef = _ref$formProps.ref;
204
172
  return (0, _react2.jsx)("form", {
205
173
  onKeyDown: function onKeyDown(e) {
206
174
  _onKeyDown(e);
207
-
208
175
  if (e.key === 'Esc' || e.key === 'Escape') {
209
176
  onCancel();
210
177
  }
@@ -218,10 +185,9 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
218
185
  validate: validate,
219
186
  isRequired: isRequired,
220
187
  key: "edit-view" // used for reset to default value
221
-
222
188
  }, function (_ref2) {
223
189
  var fieldProps = _ref2.fieldProps,
224
- error = _ref2.error;
190
+ error = _ref2.error;
225
191
  return (0, _react2.jsx)("div", {
226
192
  css: fieldStyles,
227
193
  onBlur: function onBlur() {
@@ -239,21 +205,18 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
239
205
  },
240
206
  mode: mode,
241
207
  onCancelClick: onCancelClick
242
- }) :
243
- /** This is to allow Ctrl + Enter to submit without action buttons */
208
+ }) : /** This is to allow Ctrl + Enter to submit without action buttons */
244
209
  (0, _react2.jsx)("button", {
245
210
  css: buttonStyles,
246
211
  type: "submit"
247
212
  }));
248
- }) :
249
- /** Field is used here only for the label */
213
+ }) : /** Field is used here only for the label */
250
214
  (0, _react2.jsx)(_Field.default, {
251
215
  name: "inlineEdit",
252
216
  label: label,
253
217
  defaultValue: "",
254
218
  isRequired: isRequired,
255
219
  key: "read-view" // used for reset to default value
256
-
257
220
  }, renderReadView));
258
221
  });
259
222
  /* eslint-enable jsx-a11y/no-noninteractive-element-interactions */
@@ -267,6 +230,5 @@ var InlineEdit = function InlineEdit(props) {
267
230
  }));
268
231
  });
269
232
  };
270
-
271
233
  var _default = InlineEdit;
272
234
  exports.default = _default;
@@ -1,30 +1,19 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
-
14
10
  var _react = require("@emotion/react");
15
-
16
11
  var _error = _interopRequireDefault(require("@atlaskit/icon/glyph/error"));
17
-
18
12
  var _inlineDialog = _interopRequireDefault(require("@atlaskit/inline-dialog"));
19
-
20
13
  var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
21
-
22
14
  var _colors = require("@atlaskit/theme/colors");
23
-
24
15
  var _inlineEdit = _interopRequireDefault(require("./inline-edit"));
25
-
26
16
  var _constants = require("./internal/constants");
27
-
28
17
  var _excluded = ["errorMessage", "isInvalid"];
29
18
  var errorIconContainerStyles = (0, _react.css)({
30
19
  paddingRight: _constants.gridSize - 2,
@@ -42,19 +31,18 @@ var readViewForTextFieldStyles = (0, _react.css)({
42
31
  var compactStyles = (0, _react.css)({
43
32
  padding: "".concat(_constants.gridSize / 2, "px ").concat(_constants.gridSize - 2, "px")
44
33
  });
45
-
46
34
  var InlineEditableTextfield = function InlineEditableTextfield(props) {
47
35
  var _props$isCompact = props.isCompact,
48
- isCompact = _props$isCompact === void 0 ? false : _props$isCompact,
49
- defaultValue = props.defaultValue,
50
- placeholder = props.placeholder,
51
- testId = props.testId;
36
+ isCompact = _props$isCompact === void 0 ? false : _props$isCompact,
37
+ defaultValue = props.defaultValue,
38
+ placeholder = props.placeholder,
39
+ testId = props.testId;
52
40
  return (0, _react.jsx)(_inlineEdit.default, (0, _extends2.default)({}, props, {
53
41
  defaultValue: defaultValue,
54
42
  editView: function editView(_ref) {
55
43
  var errorMessage = _ref.errorMessage,
56
- isInvalid = _ref.isInvalid,
57
- props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
44
+ isInvalid = _ref.isInvalid,
45
+ props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
58
46
  return (0, _react.jsx)(_inlineDialog.default, {
59
47
  isOpen: isInvalid,
60
48
  content: (0, _react.jsx)("div", {
@@ -82,6 +70,5 @@ var InlineEditableTextfield = function InlineEditableTextfield(props) {
82
70
  }
83
71
  }));
84
72
  };
85
-
86
73
  var _default = InlineEditableTextfield;
87
74
  exports.default = _default;
@@ -1,25 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _react = require("@emotion/react");
11
-
12
9
  var _standardButton = _interopRequireDefault(require("@atlaskit/button/standard-button"));
13
-
14
10
  var _check = _interopRequireDefault(require("@atlaskit/icon/glyph/check"));
15
-
16
11
  var _cross = _interopRequireDefault(require("@atlaskit/icon/glyph/cross"));
17
-
18
12
  var _colors = require("@atlaskit/theme/colors");
19
-
20
13
  var _constants = require("./constants");
21
-
22
14
  /** @jsx jsx */
15
+
23
16
  var buttonsContainerStyles = (0, _react.css)({
24
17
  display: 'flex',
25
18
  marginTop: _constants.gridSize - 2,
@@ -73,13 +66,12 @@ var buttonWrapperBaseStyles = (0, _react.css)({
73
66
  marginLeft: _constants.gridSize / 2
74
67
  }
75
68
  });
76
-
77
69
  var Buttons = function Buttons(_ref) {
78
70
  var mode = _ref.mode,
79
- confirmButtonLabel = _ref.confirmButtonLabel,
80
- cancelButtonLabel = _ref.cancelButtonLabel,
81
- onMouseDown = _ref.onMouseDown,
82
- onCancelClick = _ref.onCancelClick;
71
+ confirmButtonLabel = _ref.confirmButtonLabel,
72
+ cancelButtonLabel = _ref.cancelButtonLabel,
73
+ onMouseDown = _ref.onMouseDown,
74
+ onCancelClick = _ref.onCancelClick;
83
75
  return (0, _react.jsx)("div", {
84
76
  css: buttonsContainerStyles
85
77
  }, (0, _react.jsx)("div", {
@@ -106,6 +98,5 @@ var Buttons = function Buttons(_ref) {
106
98
  onMouseDown: onMouseDown
107
99
  })));
108
100
  };
109
-
110
101
  var _default = Buttons;
111
102
  exports.default = _default;
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.gridSize = exports.fontSize = exports.borderRadius = void 0;
7
-
8
7
  var _constants = require("@atlaskit/theme/constants");
9
-
10
8
  var gridSize = (0, _constants.gridSize)();
11
9
  exports.gridSize = gridSize;
12
10
  var fontSize = (0, _constants.fontSize)();
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = require("react");
9
-
10
8
  var usePrevious = function usePrevious(value) {
11
9
  var ref = (0, _react.useRef)();
12
10
  (0, _react.useEffect)(function () {
@@ -14,7 +12,6 @@ var usePrevious = function usePrevious(value) {
14
12
  }, [value]);
15
13
  return ref.current;
16
14
  };
17
-
18
15
  var useButtonFocusHook = function useButtonFocusHook(isEditing, isEditingState) {
19
16
  var editButtonRef = (0, _react.useRef)(null);
20
17
  var editViewRef = (0, _react.useRef)();
@@ -42,11 +39,9 @@ var useButtonFocusHook = function useButtonFocusHook(isEditing, isEditingState)
42
39
  }
43
40
  }
44
41
  }, [prevIsEditing, shouldBeEditing]);
45
-
46
42
  var doNotFocusOnEditButton = function doNotFocusOnEditButton() {
47
43
  return preventFocusOnEditButtonRef.current = true;
48
44
  };
49
-
50
45
  return {
51
46
  editButtonRef: editButtonRef,
52
47
  editViewRef: editViewRef,
@@ -54,6 +49,5 @@ var useButtonFocusHook = function useButtonFocusHook(isEditing, isEditingState)
54
49
  doNotFocusOnEditButton: doNotFocusOnEditButton
55
50
  };
56
51
  };
57
-
58
52
  var _default = useButtonFocusHook;
59
53
  exports.default = _default;
@@ -1,34 +1,25 @@
1
1
  "use strict";
2
2
 
3
3
  var _typeof = require("@babel/runtime/helpers/typeof");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _react = _interopRequireWildcard(require("react"));
11
-
12
9
  var _react2 = require("@emotion/react");
13
-
14
10
  var _colors = require("@atlaskit/theme/colors");
15
-
16
11
  var _constants = require("./constants");
17
-
18
12
  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); }
19
-
20
13
  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; }
21
-
22
14
  /** @jsx jsx */
15
+
23
16
  var readViewContainerStyles = (0, _react2.css)({
24
17
  lineHeight: 1
25
18
  });
26
19
  var editButtonStyles = (0, _react2.css)({
27
20
  display: 'block',
28
- // TODO Delete this comment after verifying spacing token -> previous value `'0'`
29
- margin: "var(--ds-scale-0, 0px)",
30
- // TODO Delete this comment after verifying spacing token -> previous value `'0'`
31
- padding: "var(--ds-scale-0, 0px)",
21
+ margin: "var(--ds-space-0, 0px)",
22
+ padding: "var(--ds-space-0, 0px)",
32
23
  appearance: 'none',
33
24
  background: 'transparent',
34
25
  border: 0,
@@ -54,34 +45,29 @@ var readViewFitContainerWidthStyles = (0, _react2.css)({
54
45
  width: '100%'
55
46
  });
56
47
  var DRAG_THRESHOLD = 5;
57
-
58
48
  var ReadView = function ReadView(_ref) {
59
49
  var editButtonLabel = _ref.editButtonLabel,
60
- onEditRequested = _ref.onEditRequested,
61
- postReadViewClick = _ref.postReadViewClick,
62
- editButtonRef = _ref.editButtonRef,
63
- readViewFitContainerWidth = _ref.readViewFitContainerWidth,
64
- readView = _ref.readView;
50
+ onEditRequested = _ref.onEditRequested,
51
+ postReadViewClick = _ref.postReadViewClick,
52
+ editButtonRef = _ref.editButtonRef,
53
+ readViewFitContainerWidth = _ref.readViewFitContainerWidth,
54
+ readView = _ref.readView;
65
55
  var startX = (0, _react.useRef)(0);
66
56
  var startY = (0, _react.useRef)(0);
67
-
68
57
  var mouseHasMovedAfterMouseDown = function mouseHasMovedAfterMouseDown(event) {
69
58
  return Math.abs(startX.current - event.clientX) >= DRAG_THRESHOLD || Math.abs(startY.current - event.clientY) >= DRAG_THRESHOLD;
70
59
  };
71
-
72
60
  var onReadViewClick = function onReadViewClick(event) {
73
61
  var element = event.target;
74
62
  /** If a link is clicked in the read view, default action should be taken */
75
-
76
63
  if (element.tagName.toLowerCase() !== 'a' && !mouseHasMovedAfterMouseDown(event)) {
77
64
  event.preventDefault();
78
65
  onEditRequested();
79
66
  postReadViewClick();
80
67
  }
81
68
  };
82
- /* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions,jsx-a11y/no-noninteractive-element-interactions */
83
-
84
69
 
70
+ /* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions,jsx-a11y/no-noninteractive-element-interactions */
85
71
  return (0, _react2.jsx)("div", {
86
72
  css: readViewContainerStyles
87
73
  }, (0, _react2.jsx)("button", {
@@ -101,6 +87,5 @@ var ReadView = function ReadView(_ref) {
101
87
  }, readView()));
102
88
  /* eslint-enable jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions,jsx-a11y/no-noninteractive-element-interactions */
103
89
  };
104
-
105
90
  var _default = ReadView;
106
91
  exports.default = _default;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/inline-edit",
3
- "version": "12.2.6",
3
+ "version": "12.2.8",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
4
3
  import React, { useCallback, useRef, useState } from 'react';
5
4
  import { css, jsx } from '@emotion/react';
@@ -20,11 +19,9 @@ const buttonStyles = css({
20
19
  const analyticsAttributes = {
21
20
  componentName: 'inlineEdit',
22
21
  packageName: "@atlaskit/inline-edit",
23
- packageVersion: "12.2.6"
22
+ packageVersion: "12.2.8"
24
23
  };
25
-
26
24
  const noop = () => {};
27
-
28
25
  const InnerInlineEdit = props => {
29
26
  const {
30
27
  startWithEditViewOpen = false,
@@ -61,16 +58,13 @@ const InnerInlineEdit = props => {
61
58
  if (isControlled) {
62
59
  setEditingState(false);
63
60
  }
64
-
65
61
  providedOnCancel();
66
62
  }, [isControlled, providedOnCancel]);
67
63
  const onEditRequested = useCallback(() => {
68
64
  if (isControlled) {
69
65
  setEditingState(true);
70
66
  }
71
-
72
67
  providedOnEdit();
73
-
74
68
  if (shouldBeEditing && editViewRef.current) {
75
69
  editViewRef.current.focus();
76
70
  }
@@ -80,7 +74,6 @@ const InnerInlineEdit = props => {
80
74
  if (isControlled) {
81
75
  setEditingState(false);
82
76
  }
83
-
84
77
  providedOnConfirm(value, analyticsEvent);
85
78
  },
86
79
  action: 'confirmed',
@@ -94,12 +87,12 @@ const InnerInlineEdit = props => {
94
87
  const tryAutoSubmitWhenBlur = useCallback((isFieldInvalid, onSubmit, formRef) => {
95
88
  if (!isFieldInvalid && !wasFocusReceivedSinceLastBlurRef.current && formRef.current) {
96
89
  doNotFocusOnEditButton();
97
-
98
90
  if (formRef.current.checkValidity()) {
99
91
  onSubmit();
100
92
  }
101
93
  }
102
94
  }, [doNotFocusOnEditButton]);
95
+
103
96
  /** If keepEditViewOpenOnBlur prop is set to false, will call confirmIfUnfocused() which
104
97
  * confirms the value, if the focus is not transferred to the action buttons
105
98
  *
@@ -113,13 +106,13 @@ const InnerInlineEdit = props => {
113
106
  * - focus on input first, and then use keyboard to `submit`
114
107
  * - focus on input first, and then click anywhere else on the page (outside of edit view wrapper) to `submit` (auto save)
115
108
  */
116
-
117
109
  const onEditViewWrapperBlur = useCallback((isFieldInvalid, onSubmit, formRef) => {
118
110
  if (!keepEditViewOpenOnBlur) {
119
111
  wasFocusReceivedSinceLastBlurRef.current = false;
120
112
  timerRef.current = setTimeout(() => tryAutoSubmitWhenBlur(isFieldInvalid, onSubmit, formRef), 0);
121
113
  }
122
114
  }, [keepEditViewOpenOnBlur, tryAutoSubmitWhenBlur]);
115
+
123
116
  /** Gets called when focus is transferred to the editView, or action buttons
124
117
  *
125
118
  * There are three paths here the function can be called:
@@ -128,11 +121,9 @@ const InnerInlineEdit = props => {
128
121
  * - when a user use keyboard to tab into `editView`
129
122
  * - when a user use keyboard to tab into `submit` when they were on input field
130
123
  */
131
-
132
124
  const onEditViewWrapperFocus = useCallback(() => {
133
125
  wasFocusReceivedSinceLastBlurRef.current = true;
134
126
  }, []);
135
-
136
127
  const renderReadView = () => {
137
128
  return jsx(ReadView, {
138
129
  editButtonLabel: editButtonLabel,
@@ -143,9 +134,8 @@ const InnerInlineEdit = props => {
143
134
  readView: readView
144
135
  });
145
136
  };
146
- /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
147
-
148
137
 
138
+ /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
149
139
  return jsx(Form, {
150
140
  onSubmit: data => onConfirm(data.inlineEdit)
151
141
  }, ({
@@ -157,7 +147,6 @@ const InnerInlineEdit = props => {
157
147
  }) => jsx("form", {
158
148
  onKeyDown: e => {
159
149
  onKeyDown(e);
160
-
161
150
  if (e.key === 'Esc' || e.key === 'Escape') {
162
151
  onCancel();
163
152
  }
@@ -171,7 +160,6 @@ const InnerInlineEdit = props => {
171
160
  validate: validate,
172
161
  isRequired: isRequired,
173
162
  key: "edit-view" // used for reset to default value
174
-
175
163
  }, ({
176
164
  fieldProps,
177
165
  error
@@ -181,7 +169,8 @@ const InnerInlineEdit = props => {
181
169
  onEditViewWrapperBlur(fieldProps.isInvalid, onSubmit, formRef);
182
170
  },
183
171
  onFocus: onEditViewWrapperFocus
184
- }, editView({ ...fieldProps,
172
+ }, editView({
173
+ ...fieldProps,
185
174
  errorMessage: error
186
175
  }, editViewRef), !hideActionButtons ? jsx(Buttons, {
187
176
  cancelButtonLabel: cancelButtonLabel,
@@ -192,20 +181,17 @@ const InnerInlineEdit = props => {
192
181
  },
193
182
  mode: mode,
194
183
  onCancelClick: onCancelClick
195
- }) :
196
- /** This is to allow Ctrl + Enter to submit without action buttons */
184
+ }) : /** This is to allow Ctrl + Enter to submit without action buttons */
197
185
  jsx("button", {
198
186
  css: buttonStyles,
199
187
  type: "submit"
200
- }))) :
201
- /** Field is used here only for the label */
188
+ }))) : /** Field is used here only for the label */
202
189
  jsx(Field, {
203
190
  name: "inlineEdit",
204
191
  label: label,
205
192
  defaultValue: "",
206
193
  isRequired: isRequired,
207
194
  key: "read-view" // used for reset to default value
208
-
209
195
  }, renderReadView)));
210
196
  /* eslint-enable jsx-a11y/no-noninteractive-element-interactions */
211
197
  };
@@ -218,5 +204,4 @@ const InlineEdit = props => {
218
204
  }));
219
205
  });
220
206
  };
221
-
222
207
  export default InlineEdit;
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
4
3
  import { css, jsx } from '@emotion/react';
5
4
  import ErrorIcon from '@atlaskit/icon/glyph/error';
@@ -24,7 +23,6 @@ const readViewForTextFieldStyles = css({
24
23
  const compactStyles = css({
25
24
  padding: `${gridSize / 2}px ${gridSize - 2}px`
26
25
  });
27
-
28
26
  const InlineEditableTextfield = props => {
29
27
  const {
30
28
  isCompact = false,
@@ -62,5 +60,4 @@ const InlineEditableTextfield = props => {
62
60
  }, defaultValue || placeholder)
63
61
  }));
64
62
  };
65
-
66
63
  export default InlineEditableTextfield;
@@ -1,4 +1,5 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import { css, jsx } from '@emotion/react';
3
4
  import Button from '@atlaskit/button/standard-button';
4
5
  import ConfirmIcon from '@atlaskit/icon/glyph/check';
@@ -58,7 +59,6 @@ const buttonWrapperBaseStyles = css({
58
59
  marginLeft: gridSize / 2
59
60
  }
60
61
  });
61
-
62
62
  const Buttons = ({
63
63
  mode,
64
64
  confirmButtonLabel,
@@ -92,5 +92,4 @@ const Buttons = ({
92
92
  onMouseDown: onMouseDown
93
93
  })));
94
94
  };
95
-
96
95
  export default Buttons;
@@ -1,5 +1,4 @@
1
1
  import { useEffect, useRef } from 'react';
2
-
3
2
  const usePrevious = value => {
4
3
  const ref = useRef();
5
4
  useEffect(() => {
@@ -7,7 +6,6 @@ const usePrevious = value => {
7
6
  }, [value]);
8
7
  return ref.current;
9
8
  };
10
-
11
9
  const useButtonFocusHook = (isEditing, isEditingState) => {
12
10
  const editButtonRef = useRef(null);
13
11
  const editViewRef = useRef();
@@ -35,9 +33,7 @@ const useButtonFocusHook = (isEditing, isEditingState) => {
35
33
  }
36
34
  }
37
35
  }, [prevIsEditing, shouldBeEditing]);
38
-
39
36
  const doNotFocusOnEditButton = () => preventFocusOnEditButtonRef.current = true;
40
-
41
37
  return {
42
38
  editButtonRef,
43
39
  editViewRef,
@@ -45,5 +41,4 @@ const useButtonFocusHook = (isEditing, isEditingState) => {
45
41
  doNotFocusOnEditButton
46
42
  };
47
43
  };
48
-
49
44
  export default useButtonFocusHook;
@@ -8,10 +8,8 @@ const readViewContainerStyles = css({
8
8
  });
9
9
  const editButtonStyles = css({
10
10
  display: 'block',
11
- // TODO Delete this comment after verifying spacing token -> previous value `'0'`
12
- margin: "var(--ds-scale-0, 0px)",
13
- // TODO Delete this comment after verifying spacing token -> previous value `'0'`
14
- padding: "var(--ds-scale-0, 0px)",
11
+ margin: "var(--ds-space-0, 0px)",
12
+ padding: "var(--ds-space-0, 0px)",
15
13
  appearance: 'none',
16
14
  background: 'transparent',
17
15
  border: 0,
@@ -37,7 +35,6 @@ const readViewFitContainerWidthStyles = css({
37
35
  width: '100%'
38
36
  });
39
37
  const DRAG_THRESHOLD = 5;
40
-
41
38
  const ReadView = ({
42
39
  editButtonLabel,
43
40
  onEditRequested,
@@ -48,24 +45,20 @@ const ReadView = ({
48
45
  }) => {
49
46
  const startX = useRef(0);
50
47
  const startY = useRef(0);
51
-
52
48
  const mouseHasMovedAfterMouseDown = event => {
53
49
  return Math.abs(startX.current - event.clientX) >= DRAG_THRESHOLD || Math.abs(startY.current - event.clientY) >= DRAG_THRESHOLD;
54
50
  };
55
-
56
51
  const onReadViewClick = event => {
57
52
  const element = event.target;
58
53
  /** If a link is clicked in the read view, default action should be taken */
59
-
60
54
  if (element.tagName.toLowerCase() !== 'a' && !mouseHasMovedAfterMouseDown(event)) {
61
55
  event.preventDefault();
62
56
  onEditRequested();
63
57
  postReadViewClick();
64
58
  }
65
59
  };
66
- /* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions,jsx-a11y/no-noninteractive-element-interactions */
67
-
68
60
 
61
+ /* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions,jsx-a11y/no-noninteractive-element-interactions */
69
62
  return jsx("div", {
70
63
  css: readViewContainerStyles
71
64
  }, jsx("button", {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/inline-edit",
3
- "version": "12.2.6",
3
+ "version": "12.2.8",
4
4
  "sideEffects": false
5
5
  }
@@ -1,11 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
-
5
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
-
7
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
-
9
6
  /** @jsx jsx */
10
7
  import React, { useCallback, useRef, useState } from 'react';
11
8
  import { css, jsx } from '@emotion/react';
@@ -26,71 +23,62 @@ var buttonStyles = css({
26
23
  var analyticsAttributes = {
27
24
  componentName: 'inlineEdit',
28
25
  packageName: "@atlaskit/inline-edit",
29
- packageVersion: "12.2.6"
26
+ packageVersion: "12.2.8"
30
27
  };
31
-
32
28
  var noop = function noop() {};
33
-
34
29
  var InnerInlineEdit = function InnerInlineEdit(props) {
35
30
  var _props$startWithEditV = props.startWithEditViewOpen,
36
- startWithEditViewOpen = _props$startWithEditV === void 0 ? false : _props$startWithEditV,
37
- _props$keepEditViewOp = props.keepEditViewOpenOnBlur,
38
- keepEditViewOpenOnBlur = _props$keepEditViewOp === void 0 ? false : _props$keepEditViewOp,
39
- _props$hideActionButt = props.hideActionButtons,
40
- hideActionButtons = _props$hideActionButt === void 0 ? false : _props$hideActionButt,
41
- _props$isRequired = props.isRequired,
42
- isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
43
- _props$readViewFitCon = props.readViewFitContainerWidth,
44
- readViewFitContainerWidth = _props$readViewFitCon === void 0 ? false : _props$readViewFitCon,
45
- _props$editButtonLabe = props.editButtonLabel,
46
- editButtonLabel = _props$editButtonLabe === void 0 ? 'Edit' : _props$editButtonLabe,
47
- _props$confirmButtonL = props.confirmButtonLabel,
48
- confirmButtonLabel = _props$confirmButtonL === void 0 ? 'Confirm' : _props$confirmButtonL,
49
- _props$cancelButtonLa = props.cancelButtonLabel,
50
- cancelButtonLabel = _props$cancelButtonLa === void 0 ? 'Cancel' : _props$cancelButtonLa,
51
- defaultValue = props.defaultValue,
52
- isEditing = props.isEditing,
53
- label = props.label,
54
- validate = props.validate,
55
- readView = props.readView,
56
- editView = props.editView,
57
- analyticsContext = props.analyticsContext,
58
- providedOnConfirm = props.onConfirm,
59
- _props$onCancel = props.onCancel,
60
- providedOnCancel = _props$onCancel === void 0 ? noop : _props$onCancel,
61
- _props$onEdit = props.onEdit,
62
- providedOnEdit = _props$onEdit === void 0 ? noop : _props$onEdit,
63
- mode = props.mode;
31
+ startWithEditViewOpen = _props$startWithEditV === void 0 ? false : _props$startWithEditV,
32
+ _props$keepEditViewOp = props.keepEditViewOpenOnBlur,
33
+ keepEditViewOpenOnBlur = _props$keepEditViewOp === void 0 ? false : _props$keepEditViewOp,
34
+ _props$hideActionButt = props.hideActionButtons,
35
+ hideActionButtons = _props$hideActionButt === void 0 ? false : _props$hideActionButt,
36
+ _props$isRequired = props.isRequired,
37
+ isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
38
+ _props$readViewFitCon = props.readViewFitContainerWidth,
39
+ readViewFitContainerWidth = _props$readViewFitCon === void 0 ? false : _props$readViewFitCon,
40
+ _props$editButtonLabe = props.editButtonLabel,
41
+ editButtonLabel = _props$editButtonLabe === void 0 ? 'Edit' : _props$editButtonLabe,
42
+ _props$confirmButtonL = props.confirmButtonLabel,
43
+ confirmButtonLabel = _props$confirmButtonL === void 0 ? 'Confirm' : _props$confirmButtonL,
44
+ _props$cancelButtonLa = props.cancelButtonLabel,
45
+ cancelButtonLabel = _props$cancelButtonLa === void 0 ? 'Cancel' : _props$cancelButtonLa,
46
+ defaultValue = props.defaultValue,
47
+ isEditing = props.isEditing,
48
+ label = props.label,
49
+ validate = props.validate,
50
+ readView = props.readView,
51
+ editView = props.editView,
52
+ analyticsContext = props.analyticsContext,
53
+ providedOnConfirm = props.onConfirm,
54
+ _props$onCancel = props.onCancel,
55
+ providedOnCancel = _props$onCancel === void 0 ? noop : _props$onCancel,
56
+ _props$onEdit = props.onEdit,
57
+ providedOnEdit = _props$onEdit === void 0 ? noop : _props$onEdit,
58
+ mode = props.mode;
64
59
  var wasFocusReceivedSinceLastBlurRef = useRef(false);
65
60
  var isControlled = typeof isEditing === 'undefined';
66
-
67
61
  var _useState = useState(startWithEditViewOpen),
68
- _useState2 = _slicedToArray(_useState, 2),
69
- isEditingState = _useState2[0],
70
- setEditingState = _useState2[1];
71
-
62
+ _useState2 = _slicedToArray(_useState, 2),
63
+ isEditingState = _useState2[0],
64
+ setEditingState = _useState2[1];
72
65
  var timerRef = useRef();
73
-
74
66
  var _useButtonFocusHook = useButtonFocusHook(isEditing, isEditingState),
75
- editButtonRef = _useButtonFocusHook.editButtonRef,
76
- editViewRef = _useButtonFocusHook.editViewRef,
77
- shouldBeEditing = _useButtonFocusHook.shouldBeEditing,
78
- doNotFocusOnEditButton = _useButtonFocusHook.doNotFocusOnEditButton;
79
-
67
+ editButtonRef = _useButtonFocusHook.editButtonRef,
68
+ editViewRef = _useButtonFocusHook.editViewRef,
69
+ shouldBeEditing = _useButtonFocusHook.shouldBeEditing,
70
+ doNotFocusOnEditButton = _useButtonFocusHook.doNotFocusOnEditButton;
80
71
  var onCancel = useCallback(function () {
81
72
  if (isControlled) {
82
73
  setEditingState(false);
83
74
  }
84
-
85
75
  providedOnCancel();
86
76
  }, [isControlled, providedOnCancel]);
87
77
  var onEditRequested = useCallback(function () {
88
78
  if (isControlled) {
89
79
  setEditingState(true);
90
80
  }
91
-
92
81
  providedOnEdit();
93
-
94
82
  if (shouldBeEditing && editViewRef.current) {
95
83
  editViewRef.current.focus();
96
84
  }
@@ -100,7 +88,6 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
100
88
  if (isControlled) {
101
89
  setEditingState(false);
102
90
  }
103
-
104
91
  providedOnConfirm(value, analyticsEvent);
105
92
  },
106
93
  action: 'confirmed',
@@ -113,12 +100,12 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
113
100
  var tryAutoSubmitWhenBlur = useCallback(function (isFieldInvalid, onSubmit, formRef) {
114
101
  if (!isFieldInvalid && !wasFocusReceivedSinceLastBlurRef.current && formRef.current) {
115
102
  doNotFocusOnEditButton();
116
-
117
103
  if (formRef.current.checkValidity()) {
118
104
  onSubmit();
119
105
  }
120
106
  }
121
107
  }, [doNotFocusOnEditButton]);
108
+
122
109
  /** If keepEditViewOpenOnBlur prop is set to false, will call confirmIfUnfocused() which
123
110
  * confirms the value, if the focus is not transferred to the action buttons
124
111
  *
@@ -132,7 +119,6 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
132
119
  * - focus on input first, and then use keyboard to `submit`
133
120
  * - focus on input first, and then click anywhere else on the page (outside of edit view wrapper) to `submit` (auto save)
134
121
  */
135
-
136
122
  var onEditViewWrapperBlur = useCallback(function (isFieldInvalid, onSubmit, formRef) {
137
123
  if (!keepEditViewOpenOnBlur) {
138
124
  wasFocusReceivedSinceLastBlurRef.current = false;
@@ -141,6 +127,7 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
141
127
  }, 0);
142
128
  }
143
129
  }, [keepEditViewOpenOnBlur, tryAutoSubmitWhenBlur]);
130
+
144
131
  /** Gets called when focus is transferred to the editView, or action buttons
145
132
  *
146
133
  * There are three paths here the function can be called:
@@ -149,11 +136,9 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
149
136
  * - when a user use keyboard to tab into `editView`
150
137
  * - when a user use keyboard to tab into `submit` when they were on input field
151
138
  */
152
-
153
139
  var onEditViewWrapperFocus = useCallback(function () {
154
140
  wasFocusReceivedSinceLastBlurRef.current = true;
155
141
  }, []);
156
-
157
142
  var renderReadView = function renderReadView() {
158
143
  return jsx(ReadView, {
159
144
  editButtonLabel: editButtonLabel,
@@ -164,22 +149,20 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
164
149
  readView: readView
165
150
  });
166
151
  };
167
- /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
168
-
169
152
 
153
+ /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
170
154
  return jsx(Form, {
171
155
  onSubmit: function onSubmit(data) {
172
156
  return onConfirm(data.inlineEdit);
173
157
  }
174
158
  }, function (_ref) {
175
159
  var _ref$formProps = _ref.formProps,
176
- _onKeyDown = _ref$formProps.onKeyDown,
177
- onSubmit = _ref$formProps.onSubmit,
178
- formRef = _ref$formProps.ref;
160
+ _onKeyDown = _ref$formProps.onKeyDown,
161
+ onSubmit = _ref$formProps.onSubmit,
162
+ formRef = _ref$formProps.ref;
179
163
  return jsx("form", {
180
164
  onKeyDown: function onKeyDown(e) {
181
165
  _onKeyDown(e);
182
-
183
166
  if (e.key === 'Esc' || e.key === 'Escape') {
184
167
  onCancel();
185
168
  }
@@ -193,10 +176,9 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
193
176
  validate: validate,
194
177
  isRequired: isRequired,
195
178
  key: "edit-view" // used for reset to default value
196
-
197
179
  }, function (_ref2) {
198
180
  var fieldProps = _ref2.fieldProps,
199
- error = _ref2.error;
181
+ error = _ref2.error;
200
182
  return jsx("div", {
201
183
  css: fieldStyles,
202
184
  onBlur: function onBlur() {
@@ -214,21 +196,18 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
214
196
  },
215
197
  mode: mode,
216
198
  onCancelClick: onCancelClick
217
- }) :
218
- /** This is to allow Ctrl + Enter to submit without action buttons */
199
+ }) : /** This is to allow Ctrl + Enter to submit without action buttons */
219
200
  jsx("button", {
220
201
  css: buttonStyles,
221
202
  type: "submit"
222
203
  }));
223
- }) :
224
- /** Field is used here only for the label */
204
+ }) : /** Field is used here only for the label */
225
205
  jsx(Field, {
226
206
  name: "inlineEdit",
227
207
  label: label,
228
208
  defaultValue: "",
229
209
  isRequired: isRequired,
230
210
  key: "read-view" // used for reset to default value
231
-
232
211
  }, renderReadView));
233
212
  });
234
213
  /* eslint-enable jsx-a11y/no-noninteractive-element-interactions */
@@ -242,5 +221,4 @@ var InlineEdit = function InlineEdit(props) {
242
221
  }));
243
222
  });
244
223
  };
245
-
246
224
  export default InlineEdit;
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["errorMessage", "isInvalid"];
4
-
5
4
  /** @jsx jsx */
6
5
  import { css, jsx } from '@emotion/react';
7
6
  import ErrorIcon from '@atlaskit/icon/glyph/error';
@@ -26,20 +25,18 @@ var readViewForTextFieldStyles = css({
26
25
  var compactStyles = css({
27
26
  padding: "".concat(gridSize / 2, "px ").concat(gridSize - 2, "px")
28
27
  });
29
-
30
28
  var InlineEditableTextfield = function InlineEditableTextfield(props) {
31
29
  var _props$isCompact = props.isCompact,
32
- isCompact = _props$isCompact === void 0 ? false : _props$isCompact,
33
- defaultValue = props.defaultValue,
34
- placeholder = props.placeholder,
35
- testId = props.testId;
30
+ isCompact = _props$isCompact === void 0 ? false : _props$isCompact,
31
+ defaultValue = props.defaultValue,
32
+ placeholder = props.placeholder,
33
+ testId = props.testId;
36
34
  return jsx(InlineEdit, _extends({}, props, {
37
35
  defaultValue: defaultValue,
38
36
  editView: function editView(_ref) {
39
37
  var errorMessage = _ref.errorMessage,
40
- isInvalid = _ref.isInvalid,
41
- props = _objectWithoutProperties(_ref, _excluded);
42
-
38
+ isInvalid = _ref.isInvalid,
39
+ props = _objectWithoutProperties(_ref, _excluded);
43
40
  return jsx(InlineDialog, {
44
41
  isOpen: isInvalid,
45
42
  content: jsx("div", {
@@ -67,5 +64,4 @@ var InlineEditableTextfield = function InlineEditableTextfield(props) {
67
64
  }
68
65
  }));
69
66
  };
70
-
71
67
  export default InlineEditableTextfield;
@@ -1,4 +1,5 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import { css, jsx } from '@emotion/react';
3
4
  import Button from '@atlaskit/button/standard-button';
4
5
  import ConfirmIcon from '@atlaskit/icon/glyph/check';
@@ -58,13 +59,12 @@ var buttonWrapperBaseStyles = css({
58
59
  marginLeft: gridSize / 2
59
60
  }
60
61
  });
61
-
62
62
  var Buttons = function Buttons(_ref) {
63
63
  var mode = _ref.mode,
64
- confirmButtonLabel = _ref.confirmButtonLabel,
65
- cancelButtonLabel = _ref.cancelButtonLabel,
66
- onMouseDown = _ref.onMouseDown,
67
- onCancelClick = _ref.onCancelClick;
64
+ confirmButtonLabel = _ref.confirmButtonLabel,
65
+ cancelButtonLabel = _ref.cancelButtonLabel,
66
+ onMouseDown = _ref.onMouseDown,
67
+ onCancelClick = _ref.onCancelClick;
68
68
  return jsx("div", {
69
69
  css: buttonsContainerStyles
70
70
  }, jsx("div", {
@@ -91,5 +91,4 @@ var Buttons = function Buttons(_ref) {
91
91
  onMouseDown: onMouseDown
92
92
  })));
93
93
  };
94
-
95
94
  export default Buttons;
@@ -1,5 +1,4 @@
1
1
  import { useEffect, useRef } from 'react';
2
-
3
2
  var usePrevious = function usePrevious(value) {
4
3
  var ref = useRef();
5
4
  useEffect(function () {
@@ -7,7 +6,6 @@ var usePrevious = function usePrevious(value) {
7
6
  }, [value]);
8
7
  return ref.current;
9
8
  };
10
-
11
9
  var useButtonFocusHook = function useButtonFocusHook(isEditing, isEditingState) {
12
10
  var editButtonRef = useRef(null);
13
11
  var editViewRef = useRef();
@@ -35,11 +33,9 @@ var useButtonFocusHook = function useButtonFocusHook(isEditing, isEditingState)
35
33
  }
36
34
  }
37
35
  }, [prevIsEditing, shouldBeEditing]);
38
-
39
36
  var doNotFocusOnEditButton = function doNotFocusOnEditButton() {
40
37
  return preventFocusOnEditButtonRef.current = true;
41
38
  };
42
-
43
39
  return {
44
40
  editButtonRef: editButtonRef,
45
41
  editViewRef: editViewRef,
@@ -47,5 +43,4 @@ var useButtonFocusHook = function useButtonFocusHook(isEditing, isEditingState)
47
43
  doNotFocusOnEditButton: doNotFocusOnEditButton
48
44
  };
49
45
  };
50
-
51
46
  export default useButtonFocusHook;
@@ -8,10 +8,8 @@ var readViewContainerStyles = css({
8
8
  });
9
9
  var editButtonStyles = css({
10
10
  display: 'block',
11
- // TODO Delete this comment after verifying spacing token -> previous value `'0'`
12
- margin: "var(--ds-scale-0, 0px)",
13
- // TODO Delete this comment after verifying spacing token -> previous value `'0'`
14
- padding: "var(--ds-scale-0, 0px)",
11
+ margin: "var(--ds-space-0, 0px)",
12
+ padding: "var(--ds-space-0, 0px)",
15
13
  appearance: 'none',
16
14
  background: 'transparent',
17
15
  border: 0,
@@ -37,34 +35,29 @@ var readViewFitContainerWidthStyles = css({
37
35
  width: '100%'
38
36
  });
39
37
  var DRAG_THRESHOLD = 5;
40
-
41
38
  var ReadView = function ReadView(_ref) {
42
39
  var editButtonLabel = _ref.editButtonLabel,
43
- onEditRequested = _ref.onEditRequested,
44
- postReadViewClick = _ref.postReadViewClick,
45
- editButtonRef = _ref.editButtonRef,
46
- readViewFitContainerWidth = _ref.readViewFitContainerWidth,
47
- readView = _ref.readView;
40
+ onEditRequested = _ref.onEditRequested,
41
+ postReadViewClick = _ref.postReadViewClick,
42
+ editButtonRef = _ref.editButtonRef,
43
+ readViewFitContainerWidth = _ref.readViewFitContainerWidth,
44
+ readView = _ref.readView;
48
45
  var startX = useRef(0);
49
46
  var startY = useRef(0);
50
-
51
47
  var mouseHasMovedAfterMouseDown = function mouseHasMovedAfterMouseDown(event) {
52
48
  return Math.abs(startX.current - event.clientX) >= DRAG_THRESHOLD || Math.abs(startY.current - event.clientY) >= DRAG_THRESHOLD;
53
49
  };
54
-
55
50
  var onReadViewClick = function onReadViewClick(event) {
56
51
  var element = event.target;
57
52
  /** If a link is clicked in the read view, default action should be taken */
58
-
59
53
  if (element.tagName.toLowerCase() !== 'a' && !mouseHasMovedAfterMouseDown(event)) {
60
54
  event.preventDefault();
61
55
  onEditRequested();
62
56
  postReadViewClick();
63
57
  }
64
58
  };
65
- /* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions,jsx-a11y/no-noninteractive-element-interactions */
66
-
67
59
 
60
+ /* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions,jsx-a11y/no-noninteractive-element-interactions */
68
61
  return jsx("div", {
69
62
  css: readViewContainerStyles
70
63
  }, jsx("button", {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/inline-edit",
3
- "version": "12.2.6",
3
+ "version": "12.2.8",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/inline-edit",
3
- "version": "12.2.6",
3
+ "version": "12.2.8",
4
4
  "description": "An inline edit displays a custom input component that switches between reading and editing on the same page.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,7 +33,7 @@
33
33
  "@atlaskit/inline-dialog": "^13.4.0",
34
34
  "@atlaskit/textfield": "^5.3.0",
35
35
  "@atlaskit/theme": "^12.2.0",
36
- "@atlaskit/tokens": "^0.13.0",
36
+ "@atlaskit/tokens": "^1.0.0",
37
37
  "@babel/runtime": "^7.0.0",
38
38
  "@emotion/react": "^11.7.1"
39
39
  },
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/datetime-picker": "^12.3.0",
45
45
  "@atlaskit/docs": "*",
46
46
  "@atlaskit/section-message": "^6.3.0",
47
- "@atlaskit/select": "^16.0.0",
47
+ "@atlaskit/select": "^16.1.0",
48
48
  "@atlaskit/ssr": "*",
49
49
  "@atlaskit/tag": "^11.4.0",
50
50
  "@atlaskit/tag-group": "^10.1.0",
package/report.api.md CHANGED
@@ -1,4 +1,4 @@
1
- <!-- API Report Version: 2.2 -->
1
+ <!-- API Report Version: 2.3 -->
2
2
 
3
3
  ## API Report File for "@atlaskit/inline-edit"
4
4