@atlaskit/form 10.5.1 → 10.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/form
2
2
 
3
+ ## 10.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`34d8c0a75098e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/34d8c0a75098e) -
8
+ [ux] accessibility improvements to the error validation
9
+
10
+ ## 10.5.2
11
+
12
+ ### Patch Changes
13
+
14
+ - [#129726](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/129726)
15
+ [`778c15c1d279a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/778c15c1d279a) -
16
+ [ux] Removed feature flag `platform.design-system-team.form-header-typography-updates_4f1g6` and
17
+ `platform.design-system-team.form-label-typography-updates` feature flags resulting in minor
18
+ visual changes to typography.
19
+
3
20
  ## 10.5.1
4
21
 
5
22
  ### Patch Changes
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "HelperMessage", {
15
15
  return _messages.HelperMessage;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "MessageWrapper", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _messages.MessageWrapper;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "ValidMessage", {
19
25
  enumerable: true,
20
26
  get: function get() {
@@ -4,12 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = exports.FormHeaderTitle = exports.FormHeaderDescription = exports.FormHeaderContent = void 0;
7
+ exports.default = void 0;
8
8
  var _react = require("@emotion/react");
9
9
  var _heading = _interopRequireDefault(require("@atlaskit/heading"));
10
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
10
  var _primitives = require("@atlaskit/primitives");
12
- var _typography = require("@atlaskit/theme/typography");
13
11
  /**
14
12
  * @jsxRuntime classic
15
13
  * @jsx jsx
@@ -24,48 +22,6 @@ var formHeaderContentStyles = (0, _primitives.xcss)({
24
22
  var formHeaderDescriptionStyles = (0, _primitives.xcss)({
25
23
  marginBlockStart: 'space.100'
26
24
  });
27
- var formHeaderTitleStyles = (0, _react.css)({
28
- lineHeight: "var(--ds-font-lineHeight-500, 32px)",
29
- marginBlockStart: 0,
30
- marginInlineEnd: "var(--ds-space-400, 32px)",
31
- overflow: 'hidden',
32
- textOverflow: 'ellipsis',
33
- whiteSpace: 'nowrap'
34
- });
35
- var formHeaderWrapperStyles = (0, _react.css)({
36
- fontFamily: "var(--ds-font-family-body, ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
37
- });
38
-
39
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
40
- var lightH700Styles = (0, _react.css)((0, _typography.h700)({
41
- theme: {
42
- mode: 'light'
43
- }
44
- }));
45
- var FormHeaderContent = exports.FormHeaderContent = function FormHeaderContent(_ref) {
46
- var children = _ref.children;
47
- return (0, _react.jsx)(_primitives.Box, {
48
- xcss: formHeaderContentStyles
49
- }, children);
50
- };
51
- var FormHeaderDescription = exports.FormHeaderDescription = function FormHeaderDescription(_ref2) {
52
- var children = _ref2.children;
53
- return (0, _react.jsx)(_primitives.Box, {
54
- xcss: formHeaderDescriptionStyles
55
- }, children);
56
- };
57
- var FormHeaderTitle = exports.FormHeaderTitle = function FormHeaderTitle(_ref3) {
58
- var children = _ref3.children;
59
- return (0, _react.jsx)("h2", {
60
- css: [lightH700Styles, formHeaderTitleStyles]
61
- }, children);
62
- };
63
- var FormHeaderWrapper = function FormHeaderWrapper(_ref4) {
64
- var children = _ref4.children;
65
- return (0, _react.jsx)("div", {
66
- css: formHeaderWrapperStyles
67
- }, children);
68
- };
69
25
 
70
26
  /**
71
27
  * __Form header__.
@@ -77,12 +33,16 @@ var FormHeaderWrapper = function FormHeaderWrapper(_ref4) {
77
33
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
78
34
  * - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout).
79
35
  */
80
- var FormHeader = function FormHeader(_ref5) {
81
- var children = _ref5.children,
82
- description = _ref5.description,
83
- title = _ref5.title;
84
- return (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.form-header-typography-updates_4f1g6') ? (0, _react.jsx)(_primitives.Box, null, title && (0, _react.jsx)(_heading.default, {
36
+ var FormHeader = function FormHeader(_ref) {
37
+ var children = _ref.children,
38
+ description = _ref.description,
39
+ title = _ref.title;
40
+ return (0, _react.jsx)(_primitives.Box, null, title && (0, _react.jsx)(_heading.default, {
85
41
  size: "large"
86
- }, title), description && (0, _react.jsx)(FormHeaderDescription, null, description), children && (0, _react.jsx)(FormHeaderContent, null, children)) : (0, _react.jsx)(FormHeaderWrapper, null, title && (0, _react.jsx)(FormHeaderTitle, null, title), description && (0, _react.jsx)(FormHeaderDescription, null, description), children && (0, _react.jsx)(FormHeaderContent, null, children));
42
+ }, title), description && (0, _react.jsx)(_primitives.Box, {
43
+ xcss: formHeaderDescriptionStyles
44
+ }, description), children && (0, _react.jsx)(_primitives.Box, {
45
+ xcss: formHeaderContentStyles
46
+ }, children));
87
47
  };
88
48
  var _default = exports.default = FormHeader;
package/dist/cjs/index.js CHANGED
@@ -64,6 +64,12 @@ Object.defineProperty(exports, "Legend", {
64
64
  return _label.Legend;
65
65
  }
66
66
  });
67
+ Object.defineProperty(exports, "MessageWrapper", {
68
+ enumerable: true,
69
+ get: function get() {
70
+ return _messages.MessageWrapper;
71
+ }
72
+ });
67
73
  Object.defineProperty(exports, "RangeField", {
68
74
  enumerable: true,
69
75
  get: function get() {
package/dist/cjs/label.js CHANGED
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = exports.Legend = exports.Label = void 0;
7
7
  var _react = require("@emotion/react");
8
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
- var _colors = require("@atlaskit/theme/colors");
10
8
  /**
11
9
  * @jsxRuntime classic
12
10
  * @jsx jsx
@@ -16,18 +14,12 @@ var _colors = require("@atlaskit/theme/colors");
16
14
 
17
15
  var fieldsetLabelStyles = (0, _react.css)({
18
16
  display: 'inline-block',
17
+ color: "var(--ds-text-subtle, #44546F)",
19
18
  font: "var(--ds-font-body-UNSAFE_small, normal 400 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
19
+ fontWeight: "var(--ds-font-weight-bold, 700)",
20
20
  marginBlockEnd: "var(--ds-space-050, 4px)",
21
21
  marginBlockStart: "var(--ds-space-0, 0px)"
22
22
  });
23
- var oldFieldsetLabelStyles = (0, _react.css)({
24
- color: "var(--ds-text-subtle, ".concat(_colors.N200, ")"),
25
- fontWeight: "var(--ds-font-weight-semibold, 600)"
26
- });
27
- var newFieldsetLabelStyles = (0, _react.css)({
28
- color: "var(--ds-text-subtle, #44546F)",
29
- fontWeight: "var(--ds-font-weight-bold, 700)"
30
- });
31
23
 
32
24
  /**
33
25
  * __Label__
@@ -43,9 +35,7 @@ var Label = exports.Label = function Label(_ref) {
43
35
  id = _ref.id,
44
36
  testId = _ref.testId;
45
37
  return (0, _react.jsx)("label", {
46
- css: [fieldsetLabelStyles,
47
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
48
- (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.form-label-typography-updates') ? newFieldsetLabelStyles : oldFieldsetLabelStyles],
38
+ css: fieldsetLabelStyles,
49
39
  id: id,
50
40
  htmlFor: htmlFor,
51
41
  "data-testid": testId
@@ -60,9 +50,7 @@ var Label = exports.Label = function Label(_ref) {
60
50
  var Legend = exports.Legend = function Legend(_ref2) {
61
51
  var children = _ref2.children;
62
52
  return (0, _react.jsx)("legend", {
63
- css: [fieldsetLabelStyles,
64
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
65
- (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.form-label-typography-updates') ? newFieldsetLabelStyles : oldFieldsetLabelStyles]
53
+ css: fieldsetLabelStyles
66
54
  }, children);
67
55
  };
68
56
  var _default = exports.default = Label;
@@ -4,8 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.ValidMessage = exports.HelperMessage = exports.ErrorMessage = void 0;
8
- var _react = require("@emotion/react");
7
+ exports.ValidMessage = exports.MessageWrapperContext = exports.MessageWrapper = exports.HelperMessage = exports.ErrorMessage = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _react = require("react");
10
+ var _react2 = require("@emotion/react");
9
11
  var _success = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/success"));
10
12
  var _error = _interopRequireDefault(require("@atlaskit/icon/glyph/error"));
11
13
  var _colors = require("@atlaskit/theme/colors");
@@ -25,7 +27,7 @@ var _fieldIdContext = require("./field-id-context");
25
27
  * Public API of the various message components.
26
28
  */
27
29
 
28
- var messageStyles = (0, _react.css)({
30
+ var messageStyles = (0, _react2.css)({
29
31
  display: 'flex',
30
32
  justifyContent: 'baseline',
31
33
  gap: "var(--ds-space-050, 4px)",
@@ -33,31 +35,31 @@ var messageStyles = (0, _react.css)({
33
35
  marginBlockStart: "var(--ds-space-050, 4px)"
34
36
  });
35
37
  var messageAppearanceStyles = {
36
- default: (0, _react.css)({
38
+ default: (0, _react2.css)({
37
39
  color: "var(--ds-text-subtlest, ".concat(_colors.N200, ")")
38
40
  }),
39
- error: (0, _react.css)({
41
+ error: (0, _react2.css)({
40
42
  color: "var(--ds-text-danger, #AE2A19)"
41
43
  }),
42
- valid: (0, _react.css)({
44
+ valid: (0, _react2.css)({
43
45
  color: "var(--ds-text-success, #216E4E)"
44
46
  })
45
47
  };
46
- var iconWrapperStyles = (0, _react.css)({
48
+ var iconWrapperStyles = (0, _react2.css)({
47
49
  display: 'flex'
48
50
  });
49
51
  var IconWrapper = function IconWrapper(_ref) {
50
52
  var children = _ref.children;
51
- return (0, _react.jsx)("span", {
53
+ return (0, _react2.jsx)("span", {
52
54
  css: iconWrapperStyles
53
55
  }, children);
54
56
  };
55
57
  var messageIcons = {
56
- error: (0, _react.jsx)(_error.default, {
58
+ error: (0, _react2.jsx)(_error.default, {
57
59
  size: "small",
58
60
  label: "error"
59
61
  }),
60
- valid: (0, _react.jsx)(_success.default, {
62
+ valid: (0, _react2.jsx)(_success.default, {
61
63
  size: "small",
62
64
  label: "success"
63
65
  })
@@ -69,6 +71,18 @@ var Message = function Message(_ref2) {
69
71
  fieldId = _ref2.fieldId,
70
72
  testId = _ref2.testId;
71
73
  var icon = messageIcons[appearance];
74
+ var messageRef = (0, _react.useRef)(null);
75
+ var _useState = (0, _react.useState)(false),
76
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
77
+ hasMessageWrapper = _useState2[0],
78
+ setHasMessageWrapper = _useState2[1];
79
+ var _useContext = (0, _react.useContext)(MessageWrapperContext),
80
+ isWrapper = _useContext.isWrapper;
81
+ (0, _react.useEffect)(function () {
82
+ if (messageRef.current) {
83
+ setHasMessageWrapper(isWrapper);
84
+ }
85
+ }, [isWrapper]);
72
86
 
73
87
  /**
74
88
  * The wrapping span is necessary to preserve spaces between children.
@@ -78,13 +92,16 @@ var Message = function Message(_ref2) {
78
92
  * If the child is just a string, this is not required and we can use one
79
93
  * less DOM element.
80
94
  */
81
- var content = typeof children === 'string' ? children : (0, _react.jsx)("span", null, children);
82
- return (0, _react.jsx)("div", {
95
+ var content = typeof children === 'string' ? children : (0, _react2.jsx)("span", null, children);
96
+ return (0, _react2.jsx)("div", {
83
97
  css: [messageStyles, messageAppearanceStyles[appearance]],
84
98
  "data-testid": testId,
85
99
  id: fieldId,
86
- "aria-live": "polite"
87
- }, icon && (0, _react.jsx)(IconWrapper, null, icon), content);
100
+ ref: messageRef
101
+ // For backwards compatability, if there is a wrapper, aria-live is not needed
102
+ ,
103
+ "aria-live": !hasMessageWrapper ? 'polite' : undefined
104
+ }, icon && (0, _react2.jsx)(IconWrapper, null, icon), content);
88
105
  };
89
106
 
90
107
  /**
@@ -97,8 +114,8 @@ var Message = function Message(_ref2) {
97
114
  var HelperMessage = exports.HelperMessage = function HelperMessage(_ref3) {
98
115
  var children = _ref3.children,
99
116
  testId = _ref3.testId;
100
- return (0, _react.jsx)(_fieldIdContext.FieldId.Consumer, null, function (fieldId) {
101
- return (0, _react.jsx)(Message, {
117
+ return (0, _react2.jsx)(_fieldIdContext.FieldId.Consumer, null, function (fieldId) {
118
+ return (0, _react2.jsx)(Message, {
102
119
  fieldId: fieldId ? "".concat(fieldId, "-helper") : undefined,
103
120
  testId: testId
104
121
  }, children);
@@ -115,8 +132,8 @@ var HelperMessage = exports.HelperMessage = function HelperMessage(_ref3) {
115
132
  var ErrorMessage = exports.ErrorMessage = function ErrorMessage(_ref4) {
116
133
  var children = _ref4.children,
117
134
  testId = _ref4.testId;
118
- return (0, _react.jsx)(_fieldIdContext.FieldId.Consumer, null, function (fieldId) {
119
- return (0, _react.jsx)(Message, {
135
+ return (0, _react2.jsx)(_fieldIdContext.FieldId.Consumer, null, function (fieldId) {
136
+ return (0, _react2.jsx)(Message, {
120
137
  appearance: "error",
121
138
  fieldId: fieldId ? "".concat(fieldId, "-error") : undefined,
122
139
  testId: testId
@@ -134,11 +151,43 @@ var ErrorMessage = exports.ErrorMessage = function ErrorMessage(_ref4) {
134
151
  var ValidMessage = exports.ValidMessage = function ValidMessage(_ref5) {
135
152
  var children = _ref5.children,
136
153
  testId = _ref5.testId;
137
- return (0, _react.jsx)(_fieldIdContext.FieldId.Consumer, null, function (fieldId) {
138
- return (0, _react.jsx)(Message, {
154
+ return (0, _react2.jsx)(_fieldIdContext.FieldId.Consumer, null, function (fieldId) {
155
+ return (0, _react2.jsx)(Message, {
139
156
  appearance: "valid",
140
157
  fieldId: fieldId ? "".concat(fieldId, "-valid") : undefined,
141
158
  testId: testId
142
159
  }, children);
143
160
  });
161
+ };
162
+
163
+ /**
164
+ * __Message wrapper context__
165
+ *
166
+ * A message wrapper context allows the children to check
167
+ * if it is contained within the MessageWrapper.
168
+ */
169
+ var MessageWrapperContext = exports.MessageWrapperContext = /*#__PURE__*/(0, _react.createContext)({
170
+ isWrapper: false
171
+ });
172
+
173
+ /**
174
+ * __Message wrapper __
175
+ *
176
+ * A message wrapper is used to allow assistive technologies, like screen readers, to announce error or
177
+ * valid messages. This must be loaded into the DOM before the
178
+ * ErrorMessage, ValidMessage is loaded. Otherwise, assistive technologies
179
+ * may not render the message.
180
+ *
181
+ */
182
+ var MessageWrapper = exports.MessageWrapper = function MessageWrapper(_ref6) {
183
+ var children = _ref6.children;
184
+ var contextValue = {
185
+ isWrapper: true
186
+ };
187
+ return (0, _react2.jsx)(MessageWrapperContext.Provider, {
188
+ value: contextValue
189
+ }, (0, _react2.jsx)("div", {
190
+ "aria-live": "polite",
191
+ "data-testid": "message-wrapper"
192
+ }, children));
144
193
  };
@@ -1 +1 @@
1
- export { HelperMessage, ErrorMessage, ValidMessage } from '../messages';
1
+ export { HelperMessage, ErrorMessage, MessageWrapper, ValidMessage } from '../messages';
@@ -4,11 +4,9 @@
4
4
  */
5
5
 
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
- import { css, jsx } from '@emotion/react';
7
+ import { jsx } from '@emotion/react';
8
8
  import Heading from '@atlaskit/heading';
9
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
9
  import { Box, xcss } from '@atlaskit/primitives';
11
- import { h700 } from '@atlaskit/theme/typography';
12
10
  const formHeaderContentStyles = xcss({
13
11
  minWidth: '100%',
14
12
  marginBlockStart: 'space.100'
@@ -16,52 +14,6 @@ const formHeaderContentStyles = xcss({
16
14
  const formHeaderDescriptionStyles = xcss({
17
15
  marginBlockStart: 'space.100'
18
16
  });
19
- const formHeaderTitleStyles = css({
20
- lineHeight: "var(--ds-font-lineHeight-500, 32px)",
21
- marginBlockStart: 0,
22
- marginInlineEnd: "var(--ds-space-400, 32px)",
23
- overflow: 'hidden',
24
- textOverflow: 'ellipsis',
25
- whiteSpace: 'nowrap'
26
- });
27
- const formHeaderWrapperStyles = css({
28
- fontFamily: "var(--ds-font-family-body, ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
29
- });
30
-
31
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
32
- const lightH700Styles = css(h700({
33
- theme: {
34
- mode: 'light'
35
- }
36
- }));
37
- const FormHeaderContent = ({
38
- children
39
- }) => {
40
- return jsx(Box, {
41
- xcss: formHeaderContentStyles
42
- }, children);
43
- };
44
- const FormHeaderDescription = ({
45
- children
46
- }) => {
47
- return jsx(Box, {
48
- xcss: formHeaderDescriptionStyles
49
- }, children);
50
- };
51
- const FormHeaderTitle = ({
52
- children
53
- }) => {
54
- return jsx("h2", {
55
- css: [lightH700Styles, formHeaderTitleStyles]
56
- }, children);
57
- };
58
- const FormHeaderWrapper = ({
59
- children
60
- }) => {
61
- return jsx("div", {
62
- css: formHeaderWrapperStyles
63
- }, children);
64
- };
65
17
 
66
18
  /**
67
19
  * __Form header__.
@@ -78,9 +30,12 @@ const FormHeader = ({
78
30
  description,
79
31
  title
80
32
  }) => {
81
- return getBooleanFF('platform.design-system-team.form-header-typography-updates_4f1g6') ? jsx(Box, null, title && jsx(Heading, {
33
+ return jsx(Box, null, title && jsx(Heading, {
82
34
  size: "large"
83
- }, title), description && jsx(FormHeaderDescription, null, description), children && jsx(FormHeaderContent, null, children)) : jsx(FormHeaderWrapper, null, title && jsx(FormHeaderTitle, null, title), description && jsx(FormHeaderDescription, null, description), children && jsx(FormHeaderContent, null, children));
35
+ }, title), description && jsx(Box, {
36
+ xcss: formHeaderDescriptionStyles
37
+ }, description), children && jsx(Box, {
38
+ xcss: formHeaderContentStyles
39
+ }, children));
84
40
  };
85
- export default FormHeader;
86
- export { FormHeaderContent, FormHeaderDescription, FormHeaderTitle };
41
+ export default FormHeader;
@@ -6,7 +6,7 @@ export { default as Field } from './field';
6
6
  export { default as CheckboxField } from './checkbox-field';
7
7
  export { default as RangeField } from './range-field';
8
8
  export { Label, Legend } from './label';
9
- export { HelperMessage, ErrorMessage, ValidMessage } from './messages';
9
+ export { HelperMessage, ErrorMessage, MessageWrapper, ValidMessage } from './messages';
10
10
  export { default as Fieldset } from './fieldset';
11
11
  export { default as RequiredAsterisk } from './required-asterisk';
12
12
  // eslint-disable-next-line import/no-unresolved
@@ -5,22 +5,14 @@
5
5
 
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
7
  import { css, jsx } from '@emotion/react';
8
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
- import { N200 } from '@atlaskit/theme/colors';
10
8
  const fieldsetLabelStyles = css({
11
9
  display: 'inline-block',
10
+ color: "var(--ds-text-subtle, #44546F)",
12
11
  font: "var(--ds-font-body-UNSAFE_small, normal 400 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
12
+ fontWeight: "var(--ds-font-weight-bold, 700)",
13
13
  marginBlockEnd: "var(--ds-space-050, 4px)",
14
14
  marginBlockStart: "var(--ds-space-0, 0px)"
15
15
  });
16
- const oldFieldsetLabelStyles = css({
17
- color: `var(--ds-text-subtle, ${N200})`,
18
- fontWeight: "var(--ds-font-weight-semibold, 600)"
19
- });
20
- const newFieldsetLabelStyles = css({
21
- color: "var(--ds-text-subtle, #44546F)",
22
- fontWeight: "var(--ds-font-weight-bold, 700)"
23
- });
24
16
 
25
17
  /**
26
18
  * __Label__
@@ -36,9 +28,7 @@ export const Label = ({
36
28
  id,
37
29
  testId
38
30
  }) => jsx("label", {
39
- css: [fieldsetLabelStyles,
40
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
41
- getBooleanFF('platform.design-system-team.form-label-typography-updates') ? newFieldsetLabelStyles : oldFieldsetLabelStyles],
31
+ css: fieldsetLabelStyles,
42
32
  id: id,
43
33
  htmlFor: htmlFor,
44
34
  "data-testid": testId
@@ -53,9 +43,7 @@ export const Legend = ({
53
43
  children
54
44
  }) => {
55
45
  return jsx("legend", {
56
- css: [fieldsetLabelStyles,
57
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
58
- getBooleanFF('platform.design-system-team.form-label-typography-updates') ? newFieldsetLabelStyles : oldFieldsetLabelStyles]
46
+ css: fieldsetLabelStyles
59
47
  }, children);
60
48
  };
61
49
  export default Label;
@@ -3,6 +3,8 @@
3
3
  * @jsx jsx
4
4
  */
5
5
 
6
+ import { createContext, useContext, useEffect, useRef, useState } from 'react';
7
+
6
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
9
  import { css, jsx } from '@emotion/react';
8
10
  import SuccessIcon from '@atlaskit/icon/glyph/editor/success';
@@ -63,6 +65,16 @@ const Message = ({
63
65
  testId
64
66
  }) => {
65
67
  const icon = messageIcons[appearance];
68
+ const messageRef = useRef(null);
69
+ const [hasMessageWrapper, setHasMessageWrapper] = useState(false);
70
+ const {
71
+ isWrapper
72
+ } = useContext(MessageWrapperContext);
73
+ useEffect(() => {
74
+ if (messageRef.current) {
75
+ setHasMessageWrapper(isWrapper);
76
+ }
77
+ }, [isWrapper]);
66
78
 
67
79
  /**
68
80
  * The wrapping span is necessary to preserve spaces between children.
@@ -77,7 +89,10 @@ const Message = ({
77
89
  css: [messageStyles, messageAppearanceStyles[appearance]],
78
90
  "data-testid": testId,
79
91
  id: fieldId,
80
- "aria-live": "polite"
92
+ ref: messageRef
93
+ // For backwards compatability, if there is a wrapper, aria-live is not needed
94
+ ,
95
+ "aria-live": !hasMessageWrapper ? 'polite' : undefined
81
96
  }, icon && jsx(IconWrapper, null, icon), content);
82
97
  };
83
98
 
@@ -126,4 +141,37 @@ export const ValidMessage = ({
126
141
  appearance: "valid",
127
142
  fieldId: fieldId ? `${fieldId}-valid` : undefined,
128
143
  testId: testId
129
- }, children));
144
+ }, children));
145
+
146
+ /**
147
+ * __Message wrapper context__
148
+ *
149
+ * A message wrapper context allows the children to check
150
+ * if it is contained within the MessageWrapper.
151
+ */
152
+ export const MessageWrapperContext = /*#__PURE__*/createContext({
153
+ isWrapper: false
154
+ });
155
+
156
+ /**
157
+ * __Message wrapper __
158
+ *
159
+ * A message wrapper is used to allow assistive technologies, like screen readers, to announce error or
160
+ * valid messages. This must be loaded into the DOM before the
161
+ * ErrorMessage, ValidMessage is loaded. Otherwise, assistive technologies
162
+ * may not render the message.
163
+ *
164
+ */
165
+ export const MessageWrapper = ({
166
+ children
167
+ }) => {
168
+ const contextValue = {
169
+ isWrapper: true
170
+ };
171
+ return jsx(MessageWrapperContext.Provider, {
172
+ value: contextValue
173
+ }, jsx("div", {
174
+ "aria-live": "polite",
175
+ "data-testid": "message-wrapper"
176
+ }, children));
177
+ };
@@ -1 +1 @@
1
- export { HelperMessage, ErrorMessage, ValidMessage } from '../messages';
1
+ export { HelperMessage, ErrorMessage, MessageWrapper, ValidMessage } from '../messages';
@@ -4,11 +4,9 @@
4
4
  */
5
5
 
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
- import { css, jsx } from '@emotion/react';
7
+ import { jsx } from '@emotion/react';
8
8
  import Heading from '@atlaskit/heading';
9
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
9
  import { Box, xcss } from '@atlaskit/primitives';
11
- import { h700 } from '@atlaskit/theme/typography';
12
10
  var formHeaderContentStyles = xcss({
13
11
  minWidth: '100%',
14
12
  marginBlockStart: 'space.100'
@@ -16,48 +14,6 @@ var formHeaderContentStyles = xcss({
16
14
  var formHeaderDescriptionStyles = xcss({
17
15
  marginBlockStart: 'space.100'
18
16
  });
19
- var formHeaderTitleStyles = css({
20
- lineHeight: "var(--ds-font-lineHeight-500, 32px)",
21
- marginBlockStart: 0,
22
- marginInlineEnd: "var(--ds-space-400, 32px)",
23
- overflow: 'hidden',
24
- textOverflow: 'ellipsis',
25
- whiteSpace: 'nowrap'
26
- });
27
- var formHeaderWrapperStyles = css({
28
- fontFamily: "var(--ds-font-family-body, ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
29
- });
30
-
31
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
32
- var lightH700Styles = css(h700({
33
- theme: {
34
- mode: 'light'
35
- }
36
- }));
37
- var FormHeaderContent = function FormHeaderContent(_ref) {
38
- var children = _ref.children;
39
- return jsx(Box, {
40
- xcss: formHeaderContentStyles
41
- }, children);
42
- };
43
- var FormHeaderDescription = function FormHeaderDescription(_ref2) {
44
- var children = _ref2.children;
45
- return jsx(Box, {
46
- xcss: formHeaderDescriptionStyles
47
- }, children);
48
- };
49
- var FormHeaderTitle = function FormHeaderTitle(_ref3) {
50
- var children = _ref3.children;
51
- return jsx("h2", {
52
- css: [lightH700Styles, formHeaderTitleStyles]
53
- }, children);
54
- };
55
- var FormHeaderWrapper = function FormHeaderWrapper(_ref4) {
56
- var children = _ref4.children;
57
- return jsx("div", {
58
- css: formHeaderWrapperStyles
59
- }, children);
60
- };
61
17
 
62
18
  /**
63
19
  * __Form header__.
@@ -69,13 +25,16 @@ var FormHeaderWrapper = function FormHeaderWrapper(_ref4) {
69
25
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
70
26
  * - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout).
71
27
  */
72
- var FormHeader = function FormHeader(_ref5) {
73
- var children = _ref5.children,
74
- description = _ref5.description,
75
- title = _ref5.title;
76
- return getBooleanFF('platform.design-system-team.form-header-typography-updates_4f1g6') ? jsx(Box, null, title && jsx(Heading, {
28
+ var FormHeader = function FormHeader(_ref) {
29
+ var children = _ref.children,
30
+ description = _ref.description,
31
+ title = _ref.title;
32
+ return jsx(Box, null, title && jsx(Heading, {
77
33
  size: "large"
78
- }, title), description && jsx(FormHeaderDescription, null, description), children && jsx(FormHeaderContent, null, children)) : jsx(FormHeaderWrapper, null, title && jsx(FormHeaderTitle, null, title), description && jsx(FormHeaderDescription, null, description), children && jsx(FormHeaderContent, null, children));
34
+ }, title), description && jsx(Box, {
35
+ xcss: formHeaderDescriptionStyles
36
+ }, description), children && jsx(Box, {
37
+ xcss: formHeaderContentStyles
38
+ }, children));
79
39
  };
80
- export default FormHeader;
81
- export { FormHeaderContent, FormHeaderDescription, FormHeaderTitle };
40
+ export default FormHeader;
package/dist/esm/index.js CHANGED
@@ -6,7 +6,7 @@ export { default as Field } from './field';
6
6
  export { default as CheckboxField } from './checkbox-field';
7
7
  export { default as RangeField } from './range-field';
8
8
  export { Label, Legend } from './label';
9
- export { HelperMessage, ErrorMessage, ValidMessage } from './messages';
9
+ export { HelperMessage, ErrorMessage, MessageWrapper, ValidMessage } from './messages';
10
10
  export { default as Fieldset } from './fieldset';
11
11
  export { default as RequiredAsterisk } from './required-asterisk';
12
12
  // eslint-disable-next-line import/no-unresolved
package/dist/esm/label.js CHANGED
@@ -5,22 +5,14 @@
5
5
 
6
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
7
  import { css, jsx } from '@emotion/react';
8
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
- import { N200 } from '@atlaskit/theme/colors';
10
8
  var fieldsetLabelStyles = css({
11
9
  display: 'inline-block',
10
+ color: "var(--ds-text-subtle, #44546F)",
12
11
  font: "var(--ds-font-body-UNSAFE_small, normal 400 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
12
+ fontWeight: "var(--ds-font-weight-bold, 700)",
13
13
  marginBlockEnd: "var(--ds-space-050, 4px)",
14
14
  marginBlockStart: "var(--ds-space-0, 0px)"
15
15
  });
16
- var oldFieldsetLabelStyles = css({
17
- color: "var(--ds-text-subtle, ".concat(N200, ")"),
18
- fontWeight: "var(--ds-font-weight-semibold, 600)"
19
- });
20
- var newFieldsetLabelStyles = css({
21
- color: "var(--ds-text-subtle, #44546F)",
22
- fontWeight: "var(--ds-font-weight-bold, 700)"
23
- });
24
16
 
25
17
  /**
26
18
  * __Label__
@@ -36,9 +28,7 @@ export var Label = function Label(_ref) {
36
28
  id = _ref.id,
37
29
  testId = _ref.testId;
38
30
  return jsx("label", {
39
- css: [fieldsetLabelStyles,
40
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
41
- getBooleanFF('platform.design-system-team.form-label-typography-updates') ? newFieldsetLabelStyles : oldFieldsetLabelStyles],
31
+ css: fieldsetLabelStyles,
42
32
  id: id,
43
33
  htmlFor: htmlFor,
44
34
  "data-testid": testId
@@ -53,9 +43,7 @@ export var Label = function Label(_ref) {
53
43
  export var Legend = function Legend(_ref2) {
54
44
  var children = _ref2.children;
55
45
  return jsx("legend", {
56
- css: [fieldsetLabelStyles,
57
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
58
- getBooleanFF('platform.design-system-team.form-label-typography-updates') ? newFieldsetLabelStyles : oldFieldsetLabelStyles]
46
+ css: fieldsetLabelStyles
59
47
  }, children);
60
48
  };
61
49
  export default Label;
@@ -1,8 +1,11 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
2
  /**
2
3
  * @jsxRuntime classic
3
4
  * @jsx jsx
4
5
  */
5
6
 
7
+ import { createContext, useContext, useEffect, useRef, useState } from 'react';
8
+
6
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
10
  import { css, jsx } from '@emotion/react';
8
11
  import SuccessIcon from '@atlaskit/icon/glyph/editor/success';
@@ -62,6 +65,18 @@ var Message = function Message(_ref2) {
62
65
  fieldId = _ref2.fieldId,
63
66
  testId = _ref2.testId;
64
67
  var icon = messageIcons[appearance];
68
+ var messageRef = useRef(null);
69
+ var _useState = useState(false),
70
+ _useState2 = _slicedToArray(_useState, 2),
71
+ hasMessageWrapper = _useState2[0],
72
+ setHasMessageWrapper = _useState2[1];
73
+ var _useContext = useContext(MessageWrapperContext),
74
+ isWrapper = _useContext.isWrapper;
75
+ useEffect(function () {
76
+ if (messageRef.current) {
77
+ setHasMessageWrapper(isWrapper);
78
+ }
79
+ }, [isWrapper]);
65
80
 
66
81
  /**
67
82
  * The wrapping span is necessary to preserve spaces between children.
@@ -76,7 +91,10 @@ var Message = function Message(_ref2) {
76
91
  css: [messageStyles, messageAppearanceStyles[appearance]],
77
92
  "data-testid": testId,
78
93
  id: fieldId,
79
- "aria-live": "polite"
94
+ ref: messageRef
95
+ // For backwards compatability, if there is a wrapper, aria-live is not needed
96
+ ,
97
+ "aria-live": !hasMessageWrapper ? 'polite' : undefined
80
98
  }, icon && jsx(IconWrapper, null, icon), content);
81
99
  };
82
100
 
@@ -134,4 +152,36 @@ export var ValidMessage = function ValidMessage(_ref5) {
134
152
  testId: testId
135
153
  }, children);
136
154
  });
155
+ };
156
+
157
+ /**
158
+ * __Message wrapper context__
159
+ *
160
+ * A message wrapper context allows the children to check
161
+ * if it is contained within the MessageWrapper.
162
+ */
163
+ export var MessageWrapperContext = /*#__PURE__*/createContext({
164
+ isWrapper: false
165
+ });
166
+
167
+ /**
168
+ * __Message wrapper __
169
+ *
170
+ * A message wrapper is used to allow assistive technologies, like screen readers, to announce error or
171
+ * valid messages. This must be loaded into the DOM before the
172
+ * ErrorMessage, ValidMessage is loaded. Otherwise, assistive technologies
173
+ * may not render the message.
174
+ *
175
+ */
176
+ export var MessageWrapper = function MessageWrapper(_ref6) {
177
+ var children = _ref6.children;
178
+ var contextValue = {
179
+ isWrapper: true
180
+ };
181
+ return jsx(MessageWrapperContext.Provider, {
182
+ value: contextValue
183
+ }, jsx("div", {
184
+ "aria-live": "polite",
185
+ "data-testid": "message-wrapper"
186
+ }, children));
137
187
  };
@@ -1 +1 @@
1
- export { HelperMessage, ErrorMessage, ValidMessage } from '../messages';
1
+ export { HelperMessage, ErrorMessage, MessageWrapper, ValidMessage } from '../messages';
@@ -18,15 +18,6 @@ export interface FormHeaderProps {
18
18
  */
19
19
  children?: ReactNode;
20
20
  }
21
- declare const FormHeaderContent: ({ children }: {
22
- children: ReactNode;
23
- }) => jsx.JSX.Element;
24
- declare const FormHeaderDescription: ({ children }: {
25
- children: ReactNode;
26
- }) => jsx.JSX.Element;
27
- declare const FormHeaderTitle: ({ children }: {
28
- children: ReactNode;
29
- }) => jsx.JSX.Element;
30
21
  /**
31
22
  * __Form header__.
32
23
  *
@@ -39,4 +30,3 @@ declare const FormHeaderTitle: ({ children }: {
39
30
  */
40
31
  declare const FormHeader: ({ children, description, title }: FormHeaderProps) => jsx.JSX.Element;
41
32
  export default FormHeader;
42
- export { FormHeaderContent, FormHeaderDescription, FormHeaderTitle };
@@ -11,7 +11,7 @@ export { default as RangeField } from './range-field';
11
11
  export type { RangeFieldProps } from './range-field';
12
12
  export { Label, Legend } from './label';
13
13
  export type { LabelProps, LegendProps } from './label';
14
- export { HelperMessage, ErrorMessage, ValidMessage } from './messages';
14
+ export { HelperMessage, ErrorMessage, MessageWrapper, ValidMessage } from './messages';
15
15
  export { default as Fieldset } from './fieldset';
16
16
  export { default as RequiredAsterisk } from './required-asterisk';
17
17
  export type { OnSubmitHandler, FormApi } from './types';
@@ -53,4 +53,23 @@ export declare const ErrorMessage: ({ children, testId }: MessageProps) => jsx.J
53
53
  *
54
54
  */
55
55
  export declare const ValidMessage: ({ children, testId }: MessageProps) => jsx.JSX.Element;
56
+ /**
57
+ * __Message wrapper context__
58
+ *
59
+ * A message wrapper context allows the children to check
60
+ * if it is contained within the MessageWrapper.
61
+ */
62
+ export declare const MessageWrapperContext: import("react").Context<{
63
+ isWrapper: boolean;
64
+ }>;
65
+ /**
66
+ * __Message wrapper __
67
+ *
68
+ * A message wrapper is used to allow assistive technologies, like screen readers, to announce error or
69
+ * valid messages. This must be loaded into the DOM before the
70
+ * ErrorMessage, ValidMessage is loaded. Otherwise, assistive technologies
71
+ * may not render the message.
72
+ *
73
+ */
74
+ export declare const MessageWrapper: ({ children }: MessageProps) => jsx.JSX.Element;
56
75
  export {};
@@ -1 +1 @@
1
- export { HelperMessage, ErrorMessage, ValidMessage } from '../messages';
1
+ export { HelperMessage, ErrorMessage, MessageWrapper, ValidMessage } from '../messages';
@@ -18,15 +18,6 @@ export interface FormHeaderProps {
18
18
  */
19
19
  children?: ReactNode;
20
20
  }
21
- declare const FormHeaderContent: ({ children }: {
22
- children: ReactNode;
23
- }) => jsx.JSX.Element;
24
- declare const FormHeaderDescription: ({ children }: {
25
- children: ReactNode;
26
- }) => jsx.JSX.Element;
27
- declare const FormHeaderTitle: ({ children }: {
28
- children: ReactNode;
29
- }) => jsx.JSX.Element;
30
21
  /**
31
22
  * __Form header__.
32
23
  *
@@ -39,4 +30,3 @@ declare const FormHeaderTitle: ({ children }: {
39
30
  */
40
31
  declare const FormHeader: ({ children, description, title }: FormHeaderProps) => jsx.JSX.Element;
41
32
  export default FormHeader;
42
- export { FormHeaderContent, FormHeaderDescription, FormHeaderTitle };
@@ -11,7 +11,7 @@ export { default as RangeField } from './range-field';
11
11
  export type { RangeFieldProps } from './range-field';
12
12
  export { Label, Legend } from './label';
13
13
  export type { LabelProps, LegendProps } from './label';
14
- export { HelperMessage, ErrorMessage, ValidMessage } from './messages';
14
+ export { HelperMessage, ErrorMessage, MessageWrapper, ValidMessage } from './messages';
15
15
  export { default as Fieldset } from './fieldset';
16
16
  export { default as RequiredAsterisk } from './required-asterisk';
17
17
  export type { OnSubmitHandler, FormApi } from './types';
@@ -53,4 +53,23 @@ export declare const ErrorMessage: ({ children, testId }: MessageProps) => jsx.J
53
53
  *
54
54
  */
55
55
  export declare const ValidMessage: ({ children, testId }: MessageProps) => jsx.JSX.Element;
56
+ /**
57
+ * __Message wrapper context__
58
+ *
59
+ * A message wrapper context allows the children to check
60
+ * if it is contained within the MessageWrapper.
61
+ */
62
+ export declare const MessageWrapperContext: import("react").Context<{
63
+ isWrapper: boolean;
64
+ }>;
65
+ /**
66
+ * __Message wrapper __
67
+ *
68
+ * A message wrapper is used to allow assistive technologies, like screen readers, to announce error or
69
+ * valid messages. This must be loaded into the DOM before the
70
+ * ErrorMessage, ValidMessage is loaded. Otherwise, assistive technologies
71
+ * may not render the message.
72
+ *
73
+ */
74
+ export declare const MessageWrapper: ({ children }: MessageProps) => jsx.JSX.Element;
56
75
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/form",
3
- "version": "10.5.1",
3
+ "version": "10.5.3",
4
4
  "description": "A form allows users to input information.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,8 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@atlaskit/heading": "^2.4.0",
32
- "@atlaskit/icon": "^22.12.0",
33
- "@atlaskit/platform-feature-flags": "^0.3.0",
32
+ "@atlaskit/icon": "^22.13.0",
34
33
  "@atlaskit/primitives": "^12.0.0",
35
34
  "@atlaskit/theme": "^13.0.0",
36
35
  "@atlaskit/tokens": "^1.58.0",
@@ -50,7 +49,7 @@
50
49
  "@af/integration-testing": "*",
51
50
  "@af/visual-regression": "*",
52
51
  "@atlaskit/banner": "^12.5.0",
53
- "@atlaskit/button": "^19.2.0",
52
+ "@atlaskit/button": "^20.0.0",
54
53
  "@atlaskit/checkbox": "^13.7.0",
55
54
  "@atlaskit/ds-lib": "^2.4.0",
56
55
  "@atlaskit/modal-dialog": "^12.15.0",
@@ -122,13 +121,5 @@
122
121
  "./Label": "./src/entry-points/label.tsx",
123
122
  ".": "./src/index.tsx"
124
123
  },
125
- "homepage": "https://atlassian.design/components/form/",
126
- "platform-feature-flags": {
127
- "platform.design-system-team.form-header-typography-updates_4f1g6": {
128
- "type": "boolean"
129
- },
130
- "platform.design-system-team.form-label-typography-updates": {
131
- "type": "boolean"
132
- }
133
- }
124
+ "homepage": "https://atlassian.design/components/form/"
134
125
  }