@atlaskit/form 10.5.2 → 10.5.4
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 +13 -0
- package/dist/cjs/checkbox-field.js +1 -1
- package/dist/cjs/entry-points/messages.js +6 -0
- package/dist/cjs/form.js +4 -4
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/messages.js +69 -20
- package/dist/es2019/entry-points/messages.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/messages.js +50 -2
- package/dist/esm/entry-points/messages.js +1 -1
- package/dist/esm/form.js +3 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/messages.js +51 -1
- package/dist/types/entry-points/messages.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/messages.d.ts +19 -0
- package/dist/types-ts4.5/entry-points/messages.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/messages.d.ts +19 -0
- package/package.json +10 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/form
|
|
2
2
|
|
|
3
|
+
## 10.5.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 10.5.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`34d8c0a75098e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/34d8c0a75098e) -
|
|
14
|
+
[ux] accessibility improvements to the error validation
|
|
15
|
+
|
|
3
16
|
## 10.5.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -18,7 +18,7 @@ var _excluded = ["children", "defaultIsChecked", "value"],
|
|
|
18
18
|
_excluded4 = ["value"],
|
|
19
19
|
_excluded5 = ["fieldProps"];
|
|
20
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
21
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
23
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
24
|
/**
|
|
@@ -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() {
|
package/dist/cjs/form.js
CHANGED
|
@@ -13,7 +13,7 @@ var _finalForm = require("final-form");
|
|
|
13
13
|
var _finalFormFocus = _interopRequireDefault(require("final-form-focus"));
|
|
14
14
|
var _set = _interopRequireDefault(require("lodash/set"));
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
16
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
17
|
/**
|
|
18
18
|
* __Form context__
|
|
19
19
|
*
|
|
@@ -55,12 +55,12 @@ function Form(props) {
|
|
|
55
55
|
name = _ref2[0],
|
|
56
56
|
defaultValue = _ref2[1];
|
|
57
57
|
if (state.formState.initialValues) {
|
|
58
|
-
var
|
|
58
|
+
var initialValues = state.formState.initialValues;
|
|
59
59
|
var values = state.formState.values;
|
|
60
|
-
var _value = name && typeof defaultValue === 'function' ? defaultValue(
|
|
60
|
+
var _value = name && typeof defaultValue === 'function' ? defaultValue(initialValues[name]) : defaultValue;
|
|
61
61
|
|
|
62
62
|
/* eslint-disable no-param-reassign */
|
|
63
|
-
(0, _set.default)(
|
|
63
|
+
(0, _set.default)(initialValues, name, _value);
|
|
64
64
|
(0, _set.default)(values, name, _value);
|
|
65
65
|
/* eslint-enable */
|
|
66
66
|
}
|
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/messages.js
CHANGED
|
@@ -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
|
|
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,
|
|
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,
|
|
38
|
+
default: (0, _react2.css)({
|
|
37
39
|
color: "var(--ds-text-subtlest, ".concat(_colors.N200, ")")
|
|
38
40
|
}),
|
|
39
|
-
error: (0,
|
|
41
|
+
error: (0, _react2.css)({
|
|
40
42
|
color: "var(--ds-text-danger, #AE2A19)"
|
|
41
43
|
}),
|
|
42
|
-
valid: (0,
|
|
44
|
+
valid: (0, _react2.css)({
|
|
43
45
|
color: "var(--ds-text-success, #216E4E)"
|
|
44
46
|
})
|
|
45
47
|
};
|
|
46
|
-
var iconWrapperStyles = (0,
|
|
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,
|
|
53
|
+
return (0, _react2.jsx)("span", {
|
|
52
54
|
css: iconWrapperStyles
|
|
53
55
|
}, children);
|
|
54
56
|
};
|
|
55
57
|
var messageIcons = {
|
|
56
|
-
error: (0,
|
|
58
|
+
error: (0, _react2.jsx)(_error.default, {
|
|
57
59
|
size: "small",
|
|
58
60
|
label: "error"
|
|
59
61
|
}),
|
|
60
|
-
valid: (0,
|
|
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,
|
|
82
|
-
return (0,
|
|
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
|
-
|
|
87
|
-
|
|
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,
|
|
101
|
-
return (0,
|
|
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,
|
|
119
|
-
return (0,
|
|
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,
|
|
138
|
-
return (0,
|
|
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';
|
package/dist/es2019/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/es2019/messages.js
CHANGED
|
@@ -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
|
-
|
|
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';
|
package/dist/esm/form.js
CHANGED
|
@@ -44,12 +44,12 @@ export default function Form(props) {
|
|
|
44
44
|
name = _ref2[0],
|
|
45
45
|
defaultValue = _ref2[1];
|
|
46
46
|
if (state.formState.initialValues) {
|
|
47
|
-
var
|
|
47
|
+
var initialValues = state.formState.initialValues;
|
|
48
48
|
var values = state.formState.values;
|
|
49
|
-
var _value = name && typeof defaultValue === 'function' ? defaultValue(
|
|
49
|
+
var _value = name && typeof defaultValue === 'function' ? defaultValue(initialValues[name]) : defaultValue;
|
|
50
50
|
|
|
51
51
|
/* eslint-disable no-param-reassign */
|
|
52
|
-
set(
|
|
52
|
+
set(initialValues, name, _value);
|
|
53
53
|
set(values, name, _value);
|
|
54
54
|
/* eslint-enable */
|
|
55
55
|
}
|
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/messages.js
CHANGED
|
@@ -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
|
-
|
|
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';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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';
|
package/dist/types/messages.d.ts
CHANGED
|
@@ -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';
|
|
@@ -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.
|
|
3
|
+
"version": "10.5.4",
|
|
4
4
|
"description": "A form allows users to input information.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -17,10 +17,6 @@
|
|
|
17
17
|
"atlaskit:designLink": "https://atlassian.design/guidelines/product/patterns/forms",
|
|
18
18
|
"atlassian": {
|
|
19
19
|
"team": "Design System Team",
|
|
20
|
-
"productPushConsumption": [
|
|
21
|
-
"jira"
|
|
22
|
-
],
|
|
23
|
-
"releaseModel": "continuous",
|
|
24
20
|
"website": {
|
|
25
21
|
"name": "Form",
|
|
26
22
|
"category": "Components"
|
|
@@ -29,10 +25,10 @@
|
|
|
29
25
|
},
|
|
30
26
|
"dependencies": {
|
|
31
27
|
"@atlaskit/heading": "^2.4.0",
|
|
32
|
-
"@atlaskit/icon": "^22.
|
|
33
|
-
"@atlaskit/primitives": "^12.
|
|
28
|
+
"@atlaskit/icon": "^22.18.0",
|
|
29
|
+
"@atlaskit/primitives": "^12.2.0",
|
|
34
30
|
"@atlaskit/theme": "^13.0.0",
|
|
35
|
-
"@atlaskit/tokens": "^
|
|
31
|
+
"@atlaskit/tokens": "^2.0.0",
|
|
36
32
|
"@babel/runtime": "^7.0.0",
|
|
37
33
|
"@emotion/react": "^11.7.1",
|
|
38
34
|
"final-form": "^4.20.3",
|
|
@@ -49,16 +45,16 @@
|
|
|
49
45
|
"@af/integration-testing": "*",
|
|
50
46
|
"@af/visual-regression": "*",
|
|
51
47
|
"@atlaskit/banner": "^12.5.0",
|
|
52
|
-
"@atlaskit/button": "^
|
|
53
|
-
"@atlaskit/checkbox": "^
|
|
54
|
-
"@atlaskit/ds-lib": "^2.
|
|
55
|
-
"@atlaskit/modal-dialog": "^12.
|
|
48
|
+
"@atlaskit/button": "^20.2.0",
|
|
49
|
+
"@atlaskit/checkbox": "^14.0.0",
|
|
50
|
+
"@atlaskit/ds-lib": "^2.6.0",
|
|
51
|
+
"@atlaskit/modal-dialog": "^12.17.0",
|
|
56
52
|
"@atlaskit/radio": "^6.5.0",
|
|
57
53
|
"@atlaskit/range": "^7.4.0",
|
|
58
|
-
"@atlaskit/select": "^17.
|
|
54
|
+
"@atlaskit/select": "^17.19.0",
|
|
59
55
|
"@atlaskit/ssr": "*",
|
|
60
56
|
"@atlaskit/textfield": "^6.5.0",
|
|
61
|
-
"@atlaskit/toggle": "^13.
|
|
57
|
+
"@atlaskit/toggle": "^13.4.0",
|
|
62
58
|
"@atlaskit/visual-regression": "*",
|
|
63
59
|
"@testing-library/react": "^12.1.5",
|
|
64
60
|
"@testing-library/react-hooks": "^8.0.1",
|
|
@@ -68,7 +64,6 @@
|
|
|
68
64
|
"react-dom": "^16.8.0",
|
|
69
65
|
"react-router": "^4.2.0",
|
|
70
66
|
"react-router-dom": "^4.2.2",
|
|
71
|
-
"react-test-renderer": "^16.8.0",
|
|
72
67
|
"typescript": "~5.4.2",
|
|
73
68
|
"validator": "^9.4.1",
|
|
74
69
|
"wait-for-expect": "^1.2.0"
|