@atlaskit/inline-edit 15.6.4 → 15.6.6

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,20 @@
1
1
  # @atlaskit/inline-edit
2
2
 
3
+ ## 15.6.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b8934c531e413`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b8934c531e413) -
8
+ Internal refactoring
9
+
10
+ ## 15.6.5
11
+
12
+ ### Patch Changes
13
+
14
+ - [`1dc3b51d1f95e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1dc3b51d1f95e) -
15
+ Fix accessible edit button label rendering as [object Object] when a ReactNode is provided for the
16
+ label prop
17
+
3
18
  ## 15.6.4
4
19
 
5
20
  ### Patch Changes
@@ -19,6 +19,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
19
19
  var _compiled = require("@atlaskit/primitives/compiled");
20
20
  var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
21
21
  var _buttons = _interopRequireDefault(require("./internal/buttons"));
22
+ var _getTextFromReactNode = _interopRequireDefault(require("./internal/get-text-from-react-node"));
22
23
  var _useButtonFocusHook2 = _interopRequireDefault(require("./internal/hooks/use-button-focus-hook"));
23
24
  var _readView = _interopRequireDefault(require("./internal/read-view"));
24
25
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -28,7 +29,7 @@ var fieldStyles = null;
28
29
  var analyticsAttributes = {
29
30
  componentName: 'inlineEdit',
30
31
  packageName: "@atlaskit/inline-edit",
31
- packageVersion: "0.0.0-development"
32
+ packageVersion: "15.6.5"
32
33
  };
33
34
  var InnerInlineEdit = function InnerInlineEdit(props) {
34
35
  var _props$startWithEditV = props.startWithEditViewOpen,
@@ -153,7 +154,8 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
153
154
  }, []);
154
155
  var concatenatedEditButtonLabel = function concatenatedEditButtonLabel() {
155
156
  if (label) {
156
- return "".concat(editButtonLabel, ", ").concat(label, ", ").concat(editLabel);
157
+ var labelText = typeof label === 'string' ? label : (0, _getTextFromReactNode.default)(label);
158
+ return "".concat(editButtonLabel, ", ").concat(labelText, ", ").concat(editLabel);
157
159
  }
158
160
  return "".concat(editButtonLabel, ", ").concat(editLabel);
159
161
  };
@@ -55,7 +55,9 @@ var InlineEditableTextfield = function InlineEditableTextfield(props) {
55
55
  }
56
56
  providedOnCancel === null || providedOnCancel === void 0 || providedOnCancel();
57
57
  }, [defaultValue, providedOnCancel]);
58
- return /*#__PURE__*/_react.default.createElement(_inlineEdit.default, (0, _extends2.default)({}, props, {
58
+ return /*#__PURE__*/_react.default.createElement(_inlineEdit.default
59
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
60
+ , (0, _extends2.default)({}, props, {
59
61
  onCancel: onCancel,
60
62
  defaultValue: defaultValue,
61
63
  editView: function editView(_ref) {
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ /**
10
+ * Recursively extracts plain text content from a ReactNode.
11
+ *
12
+ * This is useful when a ReactNode needs to be represented as a string,
13
+ * e.g. for use in an `aria-label` attribute.
14
+ */
15
+ var _getTextFromReactNode = function getTextFromReactNode(node) {
16
+ if (node == null || typeof node === 'boolean') {
17
+ return '';
18
+ }
19
+ if (typeof node === 'string') {
20
+ return node;
21
+ }
22
+ if (typeof node === 'number') {
23
+ return String(node);
24
+ }
25
+ if (Array.isArray(node)) {
26
+ return node.map(_getTextFromReactNode).join('');
27
+ }
28
+ if ( /*#__PURE__*/_react.default.isValidElement(node)) {
29
+ return _getTextFromReactNode(node.props.children);
30
+ }
31
+ return '';
32
+ };
33
+ var _default = exports.default = _getTextFromReactNode;
@@ -9,13 +9,14 @@ import { fg } from '@atlaskit/platform-feature-flags';
9
9
  import { Pressable } from '@atlaskit/primitives/compiled';
10
10
  import VisuallyHidden from '@atlaskit/visually-hidden';
11
11
  import Buttons from './internal/buttons';
12
+ import getTextFromReactNode from './internal/get-text-from-react-node';
12
13
  import useButtonFocusHook from './internal/hooks/use-button-focus-hook';
13
14
  import ReadView from './internal/read-view';
14
15
  const fieldStyles = null;
15
16
  const analyticsAttributes = {
16
17
  componentName: 'inlineEdit',
17
18
  packageName: "@atlaskit/inline-edit",
18
- packageVersion: "0.0.0-development"
19
+ packageVersion: "15.6.5"
19
20
  };
20
21
  const InnerInlineEdit = props => {
21
22
  const {
@@ -130,7 +131,8 @@ const InnerInlineEdit = props => {
130
131
  }, []);
131
132
  const concatenatedEditButtonLabel = () => {
132
133
  if (label) {
133
- return `${editButtonLabel}, ${label}, ${editLabel}`;
134
+ const labelText = typeof label === 'string' ? label : getTextFromReactNode(label);
135
+ return `${editButtonLabel}, ${labelText}, ${editLabel}`;
134
136
  }
135
137
  return `${editButtonLabel}, ${editLabel}`;
136
138
  };
@@ -45,7 +45,9 @@ const InlineEditableTextfield = props => {
45
45
  }
46
46
  providedOnCancel === null || providedOnCancel === void 0 ? void 0 : providedOnCancel();
47
47
  }, [defaultValue, providedOnCancel]);
48
- return /*#__PURE__*/React.createElement(InlineEdit, _extends({}, props, {
48
+ return /*#__PURE__*/React.createElement(InlineEdit
49
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
50
+ , _extends({}, props, {
49
51
  onCancel: onCancel,
50
52
  defaultValue: defaultValue,
51
53
  editView: ({
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * Recursively extracts plain text content from a ReactNode.
5
+ *
6
+ * This is useful when a ReactNode needs to be represented as a string,
7
+ * e.g. for use in an `aria-label` attribute.
8
+ */
9
+ const getTextFromReactNode = node => {
10
+ if (node == null || typeof node === 'boolean') {
11
+ return '';
12
+ }
13
+ if (typeof node === 'string') {
14
+ return node;
15
+ }
16
+ if (typeof node === 'number') {
17
+ return String(node);
18
+ }
19
+ if (Array.isArray(node)) {
20
+ return node.map(getTextFromReactNode).join('');
21
+ }
22
+ if ( /*#__PURE__*/React.isValidElement(node)) {
23
+ return getTextFromReactNode(node.props.children);
24
+ }
25
+ return '';
26
+ };
27
+ export default getTextFromReactNode;
@@ -13,13 +13,14 @@ import { fg } from '@atlaskit/platform-feature-flags';
13
13
  import { Pressable } from '@atlaskit/primitives/compiled';
14
14
  import VisuallyHidden from '@atlaskit/visually-hidden';
15
15
  import Buttons from './internal/buttons';
16
+ import getTextFromReactNode from './internal/get-text-from-react-node';
16
17
  import useButtonFocusHook from './internal/hooks/use-button-focus-hook';
17
18
  import ReadView from './internal/read-view';
18
19
  var fieldStyles = null;
19
20
  var analyticsAttributes = {
20
21
  componentName: 'inlineEdit',
21
22
  packageName: "@atlaskit/inline-edit",
22
- packageVersion: "0.0.0-development"
23
+ packageVersion: "15.6.5"
23
24
  };
24
25
  var InnerInlineEdit = function InnerInlineEdit(props) {
25
26
  var _props$startWithEditV = props.startWithEditViewOpen,
@@ -144,7 +145,8 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
144
145
  }, []);
145
146
  var concatenatedEditButtonLabel = function concatenatedEditButtonLabel() {
146
147
  if (label) {
147
- return "".concat(editButtonLabel, ", ").concat(label, ", ").concat(editLabel);
148
+ var labelText = typeof label === 'string' ? label : getTextFromReactNode(label);
149
+ return "".concat(editButtonLabel, ", ").concat(labelText, ", ").concat(editLabel);
148
150
  }
149
151
  return "".concat(editButtonLabel, ", ").concat(editLabel);
150
152
  };
@@ -46,7 +46,9 @@ var InlineEditableTextfield = function InlineEditableTextfield(props) {
46
46
  }
47
47
  providedOnCancel === null || providedOnCancel === void 0 || providedOnCancel();
48
48
  }, [defaultValue, providedOnCancel]);
49
- return /*#__PURE__*/React.createElement(InlineEdit, _extends({}, props, {
49
+ return /*#__PURE__*/React.createElement(InlineEdit
50
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
51
+ , _extends({}, props, {
50
52
  onCancel: onCancel,
51
53
  defaultValue: defaultValue,
52
54
  editView: function editView(_ref) {
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * Recursively extracts plain text content from a ReactNode.
5
+ *
6
+ * This is useful when a ReactNode needs to be represented as a string,
7
+ * e.g. for use in an `aria-label` attribute.
8
+ */
9
+ var _getTextFromReactNode = function getTextFromReactNode(node) {
10
+ if (node == null || typeof node === 'boolean') {
11
+ return '';
12
+ }
13
+ if (typeof node === 'string') {
14
+ return node;
15
+ }
16
+ if (typeof node === 'number') {
17
+ return String(node);
18
+ }
19
+ if (Array.isArray(node)) {
20
+ return node.map(_getTextFromReactNode).join('');
21
+ }
22
+ if ( /*#__PURE__*/React.isValidElement(node)) {
23
+ return _getTextFromReactNode(node.props.children);
24
+ }
25
+ return '';
26
+ };
27
+ export default _getTextFromReactNode;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ /**
3
+ * Recursively extracts plain text content from a ReactNode.
4
+ *
5
+ * This is useful when a ReactNode needs to be represented as a string,
6
+ * e.g. for use in an `aria-label` attribute.
7
+ */
8
+ declare const getTextFromReactNode: (node: React.ReactNode) => string;
9
+ export default getTextFromReactNode;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ /**
3
+ * Recursively extracts plain text content from a ReactNode.
4
+ *
5
+ * This is useful when a ReactNode needs to be represented as a string,
6
+ * e.g. for use in an `aria-label` attribute.
7
+ */
8
+ declare const getTextFromReactNode: (node: React.ReactNode) => string;
9
+ export default getTextFromReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/inline-edit",
3
- "version": "15.6.4",
3
+ "version": "15.6.6",
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/"
@@ -23,7 +23,7 @@
23
23
  "sideEffects": [
24
24
  "**/*.compiled.css"
25
25
  ],
26
- "atlaskit:src": "src/index.ts",
26
+ "atlaskit:src": "src/index.tsx",
27
27
  "homepage": "https://atlassian.design/components/inline-edit/",
28
28
  "atlassian": {
29
29
  "team": "Design System Team",