@atlaskit/form 12.0.16 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/CheckboxField/package.json +1 -1
- package/Field/package.json +1 -1
- package/Fieldset/package.json +1 -1
- package/Form/package.json +1 -1
- package/FormFooter/package.json +1 -1
- package/FormHeader/package.json +1 -1
- package/FormSection/package.json +1 -1
- package/Label/package.json +1 -1
- package/Messages/package.json +1 -1
- package/RangeField/package.json +1 -1
- package/dist/cjs/messages.js +38 -10
- package/dist/es2019/messages.js +31 -8
- package/dist/esm/messages.js +39 -11
- package/dist/types/field-id-context.d.ts +0 -1
- package/dist/types/form.d.ts +1 -1
- package/dist/types/required-asterisk.d.ts +0 -1
- package/dist/types-ts4.5/field-id-context.d.ts +0 -1
- package/dist/types-ts4.5/form.d.ts +1 -1
- package/dist/types-ts4.5/required-asterisk.d.ts +0 -1
- package/package.json +11 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/form
|
|
2
2
|
|
|
3
|
+
## 12.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`a32c90b3928be`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a32c90b3928be) -
|
|
8
|
+
We are testing a fix to message components behind a feature flag. There was an issue with messages
|
|
9
|
+
that made them not announce when using screenreaders, this has been fixed by adding a slight delay
|
|
10
|
+
to render message content. If this fix is successful it will be available in a later release.
|
|
11
|
+
|
|
3
12
|
## 12.0.16
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/Field/package.json
CHANGED
package/Fieldset/package.json
CHANGED
package/Form/package.json
CHANGED
package/FormFooter/package.json
CHANGED
package/FormHeader/package.json
CHANGED
package/FormSection/package.json
CHANGED
package/Label/package.json
CHANGED
package/Messages/package.json
CHANGED
package/RangeField/package.json
CHANGED
package/dist/cjs/messages.js
CHANGED
|
@@ -14,6 +14,7 @@ var _runtime = require("@compiled/react/runtime");
|
|
|
14
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
15
|
var _statusErrorError = _interopRequireDefault(require("@atlaskit/icon/core/migration/status-error--error"));
|
|
16
16
|
var _statusSuccessEditorSuccess = _interopRequireDefault(require("@atlaskit/icon/core/migration/status-success--editor-success"));
|
|
17
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
18
|
var _fieldIdContext = require("./field-id-context");
|
|
18
19
|
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); }
|
|
19
20
|
/**
|
|
@@ -62,18 +63,41 @@ var Message = function Message(_ref2) {
|
|
|
62
63
|
fieldId = _ref2.fieldId,
|
|
63
64
|
testId = _ref2.testId;
|
|
64
65
|
var icon = messageIcons[appearance];
|
|
65
|
-
var
|
|
66
|
-
var _useState = (0, _react.useState)(false),
|
|
67
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
68
|
-
hasMessageWrapper = _useState2[0],
|
|
69
|
-
setHasMessageWrapper = _useState2[1];
|
|
66
|
+
var isFeatureFlagEnabled = (0, _platformFeatureFlags.fg)('platform_dst_form_screenreader_message_fix');
|
|
70
67
|
var _useContext = (0, _react.useContext)(MessageWrapperContext),
|
|
71
68
|
isWrapper = _useContext.isWrapper;
|
|
69
|
+
var _useState = (0, _react.useState)(isWrapper),
|
|
70
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
71
|
+
shouldRenderContent = _useState2[0],
|
|
72
|
+
setShouldRenderContent = _useState2[1];
|
|
73
|
+
|
|
74
|
+
// TODO: DSP-23603 - To clean up when removing "platform_dst_form_screenreader_message_fix" feature flag
|
|
75
|
+
var messageRef = (0, _react.useRef)(null);
|
|
76
|
+
var _useState3 = (0, _react.useState)(isWrapper),
|
|
77
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
78
|
+
hasMessageWrapper = _useState4[0],
|
|
79
|
+
setHasMessageWrapper = _useState4[1];
|
|
72
80
|
(0, _react.useEffect)(function () {
|
|
73
|
-
if (
|
|
74
|
-
|
|
81
|
+
if (isFeatureFlagEnabled) {
|
|
82
|
+
if (!isWrapper) {
|
|
83
|
+
// Delay rendering to ensure aria-live announcements work on first render if there is no wrapper
|
|
84
|
+
var timer = setTimeout(function () {
|
|
85
|
+
setShouldRenderContent(true);
|
|
86
|
+
}, 10);
|
|
87
|
+
return function () {
|
|
88
|
+
return clearTimeout(timer);
|
|
89
|
+
};
|
|
90
|
+
} else {
|
|
91
|
+
// When using MessageWrapper, render content immediately since the wrapper handles aria-live
|
|
92
|
+
setShouldRenderContent(true);
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
// TODO: DSP-23603 - To clean up when removing "platform_dst_form_screenreader_message_fix" feature flag
|
|
96
|
+
if (messageRef.current) {
|
|
97
|
+
setHasMessageWrapper(isWrapper);
|
|
98
|
+
}
|
|
75
99
|
}
|
|
76
|
-
}, [isWrapper]);
|
|
100
|
+
}, [isWrapper, isFeatureFlagEnabled]);
|
|
77
101
|
|
|
78
102
|
/**
|
|
79
103
|
* The wrapping span is necessary to preserve spaces between children.
|
|
@@ -84,15 +108,19 @@ var Message = function Message(_ref2) {
|
|
|
84
108
|
* less DOM element.
|
|
85
109
|
*/
|
|
86
110
|
var content = typeof children === 'string' ? children : /*#__PURE__*/React.createElement("span", null, children);
|
|
111
|
+
var childrenToRender = /*#__PURE__*/React.createElement(_react.Fragment, null, icon && /*#__PURE__*/React.createElement(IconWrapper, null, icon), content);
|
|
87
112
|
return /*#__PURE__*/React.createElement("div", {
|
|
88
113
|
"data-testid": testId,
|
|
89
|
-
id: fieldId
|
|
114
|
+
id: fieldId
|
|
115
|
+
// TODO: DSP-23603 - To clean up when removing "platform_dst_form_screenreader_message_fix" feature flag
|
|
116
|
+
,
|
|
90
117
|
ref: messageRef
|
|
91
118
|
// For backwards compatability, if there is a wrapper, aria-live is not needed
|
|
119
|
+
// TODO: DSP-23603 - To clean up when removing "platform_dst_form_screenreader_message_fix" feature flag
|
|
92
120
|
,
|
|
93
121
|
"aria-live": !hasMessageWrapper ? 'polite' : undefined,
|
|
94
122
|
className: (0, _runtime.ax)(["_zulp12x7 _11c8dcr7 _1e0c1txw _1bah1q9y _1pfh1b66", messageAppearanceStyles[appearance]])
|
|
95
|
-
},
|
|
123
|
+
}, isFeatureFlagEnabled ? shouldRenderContent && childrenToRender : childrenToRender);
|
|
96
124
|
};
|
|
97
125
|
|
|
98
126
|
/**
|
package/dist/es2019/messages.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import "./messages.compiled.css";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
import { createContext, useContext, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { createContext, Fragment, useContext, useEffect, useRef, useState } from 'react';
|
|
6
6
|
import ErrorIcon from '@atlaskit/icon/core/migration/status-error--error';
|
|
7
7
|
import SuccessIcon from '@atlaskit/icon/core/migration/status-success--editor-success';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { FieldId } from './field-id-context';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -52,16 +53,34 @@ const Message = ({
|
|
|
52
53
|
testId
|
|
53
54
|
}) => {
|
|
54
55
|
const icon = messageIcons[appearance];
|
|
55
|
-
const
|
|
56
|
-
const [hasMessageWrapper, setHasMessageWrapper] = useState(false);
|
|
56
|
+
const isFeatureFlagEnabled = fg('platform_dst_form_screenreader_message_fix');
|
|
57
57
|
const {
|
|
58
58
|
isWrapper
|
|
59
59
|
} = useContext(MessageWrapperContext);
|
|
60
|
+
const [shouldRenderContent, setShouldRenderContent] = useState(isWrapper);
|
|
61
|
+
|
|
62
|
+
// TODO: DSP-23603 - To clean up when removing "platform_dst_form_screenreader_message_fix" feature flag
|
|
63
|
+
const messageRef = useRef(null);
|
|
64
|
+
const [hasMessageWrapper, setHasMessageWrapper] = useState(isWrapper);
|
|
60
65
|
useEffect(() => {
|
|
61
|
-
if (
|
|
62
|
-
|
|
66
|
+
if (isFeatureFlagEnabled) {
|
|
67
|
+
if (!isWrapper) {
|
|
68
|
+
// Delay rendering to ensure aria-live announcements work on first render if there is no wrapper
|
|
69
|
+
const timer = setTimeout(() => {
|
|
70
|
+
setShouldRenderContent(true);
|
|
71
|
+
}, 10);
|
|
72
|
+
return () => clearTimeout(timer);
|
|
73
|
+
} else {
|
|
74
|
+
// When using MessageWrapper, render content immediately since the wrapper handles aria-live
|
|
75
|
+
setShouldRenderContent(true);
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
// TODO: DSP-23603 - To clean up when removing "platform_dst_form_screenreader_message_fix" feature flag
|
|
79
|
+
if (messageRef.current) {
|
|
80
|
+
setHasMessageWrapper(isWrapper);
|
|
81
|
+
}
|
|
63
82
|
}
|
|
64
|
-
}, [isWrapper]);
|
|
83
|
+
}, [isWrapper, isFeatureFlagEnabled]);
|
|
65
84
|
|
|
66
85
|
/**
|
|
67
86
|
* The wrapping span is necessary to preserve spaces between children.
|
|
@@ -72,15 +91,19 @@ const Message = ({
|
|
|
72
91
|
* less DOM element.
|
|
73
92
|
*/
|
|
74
93
|
const content = typeof children === 'string' ? children : /*#__PURE__*/React.createElement("span", null, children);
|
|
94
|
+
const childrenToRender = /*#__PURE__*/React.createElement(Fragment, null, icon && /*#__PURE__*/React.createElement(IconWrapper, null, icon), content);
|
|
75
95
|
return /*#__PURE__*/React.createElement("div", {
|
|
76
96
|
"data-testid": testId,
|
|
77
|
-
id: fieldId
|
|
97
|
+
id: fieldId
|
|
98
|
+
// TODO: DSP-23603 - To clean up when removing "platform_dst_form_screenreader_message_fix" feature flag
|
|
99
|
+
,
|
|
78
100
|
ref: messageRef
|
|
79
101
|
// For backwards compatability, if there is a wrapper, aria-live is not needed
|
|
102
|
+
// TODO: DSP-23603 - To clean up when removing "platform_dst_form_screenreader_message_fix" feature flag
|
|
80
103
|
,
|
|
81
104
|
"aria-live": !hasMessageWrapper ? 'polite' : undefined,
|
|
82
105
|
className: ax(["_zulp12x7 _11c8dcr7 _1e0c1txw _1bah1q9y _1pfh1b66", messageAppearanceStyles[appearance]])
|
|
83
|
-
},
|
|
106
|
+
}, isFeatureFlagEnabled ? shouldRenderContent && childrenToRender : childrenToRender);
|
|
84
107
|
};
|
|
85
108
|
|
|
86
109
|
/**
|
package/dist/esm/messages.js
CHANGED
|
@@ -3,9 +3,10 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import "./messages.compiled.css";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { ax, ix } from "@compiled/react/runtime";
|
|
6
|
-
import { createContext, useContext, useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { createContext, Fragment, useContext, useEffect, useRef, useState } from 'react';
|
|
7
7
|
import ErrorIcon from '@atlaskit/icon/core/migration/status-error--error';
|
|
8
8
|
import SuccessIcon from '@atlaskit/icon/core/migration/status-success--editor-success';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { FieldId } from './field-id-context';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -54,18 +55,41 @@ var Message = function Message(_ref2) {
|
|
|
54
55
|
fieldId = _ref2.fieldId,
|
|
55
56
|
testId = _ref2.testId;
|
|
56
57
|
var icon = messageIcons[appearance];
|
|
57
|
-
var
|
|
58
|
-
var _useState = useState(false),
|
|
59
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
60
|
-
hasMessageWrapper = _useState2[0],
|
|
61
|
-
setHasMessageWrapper = _useState2[1];
|
|
58
|
+
var isFeatureFlagEnabled = fg('platform_dst_form_screenreader_message_fix');
|
|
62
59
|
var _useContext = useContext(MessageWrapperContext),
|
|
63
60
|
isWrapper = _useContext.isWrapper;
|
|
61
|
+
var _useState = useState(isWrapper),
|
|
62
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
63
|
+
shouldRenderContent = _useState2[0],
|
|
64
|
+
setShouldRenderContent = _useState2[1];
|
|
65
|
+
|
|
66
|
+
// TODO: DSP-23603 - To clean up when removing "platform_dst_form_screenreader_message_fix" feature flag
|
|
67
|
+
var messageRef = useRef(null);
|
|
68
|
+
var _useState3 = useState(isWrapper),
|
|
69
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
70
|
+
hasMessageWrapper = _useState4[0],
|
|
71
|
+
setHasMessageWrapper = _useState4[1];
|
|
64
72
|
useEffect(function () {
|
|
65
|
-
if (
|
|
66
|
-
|
|
73
|
+
if (isFeatureFlagEnabled) {
|
|
74
|
+
if (!isWrapper) {
|
|
75
|
+
// Delay rendering to ensure aria-live announcements work on first render if there is no wrapper
|
|
76
|
+
var timer = setTimeout(function () {
|
|
77
|
+
setShouldRenderContent(true);
|
|
78
|
+
}, 10);
|
|
79
|
+
return function () {
|
|
80
|
+
return clearTimeout(timer);
|
|
81
|
+
};
|
|
82
|
+
} else {
|
|
83
|
+
// When using MessageWrapper, render content immediately since the wrapper handles aria-live
|
|
84
|
+
setShouldRenderContent(true);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
// TODO: DSP-23603 - To clean up when removing "platform_dst_form_screenreader_message_fix" feature flag
|
|
88
|
+
if (messageRef.current) {
|
|
89
|
+
setHasMessageWrapper(isWrapper);
|
|
90
|
+
}
|
|
67
91
|
}
|
|
68
|
-
}, [isWrapper]);
|
|
92
|
+
}, [isWrapper, isFeatureFlagEnabled]);
|
|
69
93
|
|
|
70
94
|
/**
|
|
71
95
|
* The wrapping span is necessary to preserve spaces between children.
|
|
@@ -76,15 +100,19 @@ var Message = function Message(_ref2) {
|
|
|
76
100
|
* less DOM element.
|
|
77
101
|
*/
|
|
78
102
|
var content = typeof children === 'string' ? children : /*#__PURE__*/React.createElement("span", null, children);
|
|
103
|
+
var childrenToRender = /*#__PURE__*/React.createElement(Fragment, null, icon && /*#__PURE__*/React.createElement(IconWrapper, null, icon), content);
|
|
79
104
|
return /*#__PURE__*/React.createElement("div", {
|
|
80
105
|
"data-testid": testId,
|
|
81
|
-
id: fieldId
|
|
106
|
+
id: fieldId
|
|
107
|
+
// TODO: DSP-23603 - To clean up when removing "platform_dst_form_screenreader_message_fix" feature flag
|
|
108
|
+
,
|
|
82
109
|
ref: messageRef
|
|
83
110
|
// For backwards compatability, if there is a wrapper, aria-live is not needed
|
|
111
|
+
// TODO: DSP-23603 - To clean up when removing "platform_dst_form_screenreader_message_fix" feature flag
|
|
84
112
|
,
|
|
85
113
|
"aria-live": !hasMessageWrapper ? 'polite' : undefined,
|
|
86
114
|
className: ax(["_zulp12x7 _11c8dcr7 _1e0c1txw _1bah1q9y _1pfh1b66", messageAppearanceStyles[appearance]])
|
|
87
|
-
},
|
|
115
|
+
}, isFeatureFlagEnabled ? shouldRenderContent && childrenToRender : childrenToRender);
|
|
88
116
|
};
|
|
89
117
|
|
|
90
118
|
/**
|
package/dist/types/form.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ type GetCurrentValue = <FormValues>(name: string) => FormValues[keyof FormValues
|
|
|
12
12
|
export declare const FormContext: React.Context<{
|
|
13
13
|
registerField: RegisterField;
|
|
14
14
|
getCurrentValue: GetCurrentValue;
|
|
15
|
-
subscribe: FormApi[
|
|
15
|
+
subscribe: FormApi["subscribe"];
|
|
16
16
|
}>;
|
|
17
17
|
/**
|
|
18
18
|
* __Is disabled context__
|
|
@@ -12,7 +12,7 @@ type GetCurrentValue = <FormValues>(name: string) => FormValues[keyof FormValues
|
|
|
12
12
|
export declare const FormContext: React.Context<{
|
|
13
13
|
registerField: RegisterField;
|
|
14
14
|
getCurrentValue: GetCurrentValue;
|
|
15
|
-
subscribe: FormApi[
|
|
15
|
+
subscribe: FormApi["subscribe"];
|
|
16
16
|
}>;
|
|
17
17
|
/**
|
|
18
18
|
* __Is disabled context__
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/form",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "A form allows users to input information.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"@atlaskit/css": "^0.12.0",
|
|
29
29
|
"@atlaskit/ds-lib": "^5.0.0",
|
|
30
30
|
"@atlaskit/heading": "^5.2.0",
|
|
31
|
-
"@atlaskit/icon": "^27.
|
|
31
|
+
"@atlaskit/icon": "^27.12.0",
|
|
32
|
+
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
32
33
|
"@atlaskit/primitives": "^14.11.0",
|
|
33
34
|
"@atlaskit/theme": "^19.0.0",
|
|
34
35
|
"@atlaskit/tokens": "^6.0.0",
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
"@atlaskit/link": "^3.2.0",
|
|
54
55
|
"@atlaskit/lozenge": "^13.0.0",
|
|
55
56
|
"@atlaskit/modal-dialog": "^14.3.0",
|
|
56
|
-
"@atlaskit/radio": "^8.
|
|
57
|
+
"@atlaskit/radio": "^8.2.0",
|
|
57
58
|
"@atlaskit/range": "^9.2.0",
|
|
58
59
|
"@atlaskit/section-message": "^8.5.0",
|
|
59
60
|
"@atlaskit/select": "^21.2.0",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"@atlaskit/textfield": "^8.0.0",
|
|
62
63
|
"@atlaskit/toggle": "^15.1.0",
|
|
63
64
|
"@atlaskit/visual-regression": "workspace:^",
|
|
65
|
+
"@atlassian/feature-flags-test-utils": "^0.3.0",
|
|
64
66
|
"@atlassian/ssr-tests": "^0.2.0",
|
|
65
67
|
"@testing-library/react": "^13.4.0",
|
|
66
68
|
"@testing-library/react-hooks": "^8.0.1",
|
|
@@ -117,5 +119,10 @@
|
|
|
117
119
|
"./Label": "./src/entry-points/label.tsx",
|
|
118
120
|
".": "./src/index.tsx"
|
|
119
121
|
},
|
|
120
|
-
"homepage": "https://atlassian.design/components/form/"
|
|
122
|
+
"homepage": "https://atlassian.design/components/form/",
|
|
123
|
+
"platform-feature-flags": {
|
|
124
|
+
"platform_dst_form_screenreader_message_fix": {
|
|
125
|
+
"type": "boolean"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
121
128
|
}
|