@atlaskit/form 8.8.2 → 8.8.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/checkbox-field.js +15 -29
  3. package/dist/cjs/entry-points/checkbox-field.js +0 -2
  4. package/dist/cjs/entry-points/field.js +0 -2
  5. package/dist/cjs/entry-points/fieldset.js +0 -2
  6. package/dist/cjs/entry-points/form-footer.js +0 -2
  7. package/dist/cjs/entry-points/form-header.js +0 -2
  8. package/dist/cjs/entry-points/form-section.js +0 -2
  9. package/dist/cjs/entry-points/form.js +0 -2
  10. package/dist/cjs/entry-points/label.js +0 -2
  11. package/dist/cjs/entry-points/messages.js +0 -1
  12. package/dist/cjs/entry-points/range-field.js +0 -2
  13. package/dist/cjs/field.js +49 -85
  14. package/dist/cjs/fieldset.js +27 -23
  15. package/dist/cjs/form-footer.js +4 -6
  16. package/dist/cjs/form-header.js +9 -23
  17. package/dist/cjs/form-section.js +9 -21
  18. package/dist/cjs/form.js +40 -63
  19. package/dist/cjs/index.js +0 -11
  20. package/dist/cjs/label.js +29 -23
  21. package/dist/cjs/messages.js +54 -55
  22. package/dist/cjs/range-field.js +8 -19
  23. package/dist/cjs/version.json +1 -1
  24. package/dist/es2019/checkbox-field.js +6 -5
  25. package/dist/es2019/field.js +16 -31
  26. package/dist/es2019/fieldset.js +21 -12
  27. package/dist/es2019/form-footer.js +2 -1
  28. package/dist/es2019/form-header.js +6 -10
  29. package/dist/es2019/form-section.js +5 -9
  30. package/dist/es2019/form.js +4 -11
  31. package/dist/es2019/index.js +2 -1
  32. package/dist/es2019/label.js +22 -11
  33. package/dist/es2019/messages.js +47 -31
  34. package/dist/es2019/range-field.js +2 -4
  35. package/dist/es2019/version.json +1 -1
  36. package/dist/esm/checkbox-field.js +15 -22
  37. package/dist/esm/field.js +49 -73
  38. package/dist/esm/fieldset.js +27 -18
  39. package/dist/esm/form-footer.js +4 -3
  40. package/dist/esm/form-header.js +9 -15
  41. package/dist/esm/form-section.js +8 -14
  42. package/dist/esm/form.js +40 -53
  43. package/dist/esm/index.js +2 -1
  44. package/dist/esm/label.js +29 -18
  45. package/dist/esm/messages.js +53 -38
  46. package/dist/esm/range-field.js +8 -15
  47. package/dist/esm/version.json +1 -1
  48. package/dist/types/messages.d.ts +11 -7
  49. package/package.json +5 -4
  50. package/report.api.md +27 -9
@@ -1,54 +1,36 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.ValidMessage = exports.HelperMessage = exports.ErrorMessage = void 0;
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _react2 = require("@emotion/react");
13
-
14
10
  var _success = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/success"));
15
-
16
11
  var _error = _interopRequireDefault(require("@atlaskit/icon/glyph/error"));
17
-
18
12
  var _colors = require("@atlaskit/theme/colors");
19
-
20
13
  var _components = require("@atlaskit/theme/components");
21
-
22
14
  var _constants = require("@atlaskit/theme/constants");
23
-
24
15
  var _typography = require("@atlaskit/theme/typography");
25
-
26
16
  var _field = require("./field");
27
-
28
17
  /** @jsx jsx */
18
+
29
19
  var gridSize = (0, _constants.gridSize)();
30
- var fontFamily = (0, _constants.fontFamily)(); // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
20
+ var fontFamily = (0, _constants.fontFamily)();
31
21
 
22
+ // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
32
23
  var lightH200Styles = (0, _react2.css)((0, _typography.h200)({
33
24
  theme: {
34
25
  mode: 'light'
35
26
  }
36
- })); // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
37
-
27
+ }));
28
+ // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
38
29
  var darkH200Styles = (0, _react2.css)((0, _typography.h200)({
39
30
  theme: {
40
31
  mode: 'dark'
41
32
  }
42
33
  }));
43
- var messageErrorColorStyles = (0, _react2.css)({
44
- color: "var(--ds-text-danger, #AE2A19)"
45
- });
46
- var messageNeutralColorStyles = (0, _react2.css)({
47
- color: "var(--ds-text-subtlest, ".concat(_colors.N200, ")")
48
- });
49
- var messageValidColorStyles = (0, _react2.css)({
50
- color: "var(--ds-text-success, #216E4E)"
51
- });
52
34
  var messageStyles = (0, _react2.css)({
53
35
  display: 'flex',
54
36
  marginTop: "".concat(gridSize * 0.5, "px"),
@@ -56,32 +38,60 @@ var messageStyles = (0, _react2.css)({
56
38
  fontFamily: "".concat(fontFamily),
57
39
  fontWeight: 'normal'
58
40
  });
41
+ var messageAppearanceStyles = {
42
+ default: (0, _react2.css)({
43
+ color: "var(--ds-text-subtlest, ".concat(_colors.N200, ")")
44
+ }),
45
+ error: (0, _react2.css)({
46
+ color: "var(--ds-text-danger, #AE2A19)"
47
+ }),
48
+ valid: (0, _react2.css)({
49
+ color: "var(--ds-text-success, #216E4E)"
50
+ })
51
+ };
59
52
  var iconWrapperStyles = (0, _react2.css)({
60
53
  display: 'flex'
61
54
  });
62
-
63
55
  var IconWrapper = function IconWrapper(_ref) {
64
56
  var children = _ref.children;
65
57
  return (0, _react2.jsx)("span", {
66
58
  css: iconWrapperStyles
67
59
  }, children);
68
60
  };
69
-
61
+ var messageIcons = {
62
+ error: (0, _react2.jsx)(_error.default, {
63
+ size: "small",
64
+ label: "error"
65
+ }),
66
+ valid: (0, _react2.jsx)(_success.default, {
67
+ size: "small",
68
+ label: "success"
69
+ })
70
+ };
70
71
  var Message = function Message(_ref2) {
71
72
  var children = _ref2.children,
72
- error = _ref2.error,
73
- valid = _ref2.valid,
74
- fieldId = _ref2.fieldId,
75
- testId = _ref2.testId;
76
-
73
+ _ref2$appearance = _ref2.appearance,
74
+ appearance = _ref2$appearance === void 0 ? 'default' : _ref2$appearance,
75
+ fieldId = _ref2.fieldId,
76
+ testId = _ref2.testId;
77
77
  var _useGlobalTheme = (0, _components.useGlobalTheme)(),
78
- mode = _useGlobalTheme.mode;
79
-
78
+ mode = _useGlobalTheme.mode;
79
+ var icon = messageIcons[appearance];
80
+
81
+ /**
82
+ * The wrapping span is necessary to preserve spaces between children.
83
+ * Otherwise the flex layout of the message will remove any whitespace
84
+ * between children.
85
+ *
86
+ * If the child is just a string, this is not required and we can use one
87
+ * less DOM element.
88
+ */
89
+ var content = typeof children === 'string' ? children : (0, _react2.jsx)("span", null, children);
80
90
  return (0, _react2.jsx)("div", {
81
- css: [mode === 'light' ? lightH200Styles : darkH200Styles, messageStyles, error ? messageErrorColorStyles : valid ? messageValidColorStyles : messageNeutralColorStyles],
91
+ css: [mode === 'light' ? lightH200Styles : darkH200Styles, messageStyles, messageAppearanceStyles[appearance]],
82
92
  "data-testid": testId,
83
93
  id: fieldId
84
- }, children);
94
+ }, icon && (0, _react2.jsx)(IconWrapper, null, icon), content);
85
95
  };
86
96
 
87
97
  /**
@@ -93,7 +103,7 @@ var Message = function Message(_ref2) {
93
103
  */
94
104
  var HelperMessage = function HelperMessage(_ref3) {
95
105
  var children = _ref3.children,
96
- testId = _ref3.testId;
106
+ testId = _ref3.testId;
97
107
  return (0, _react2.jsx)(_field.FieldId.Consumer, null, function (fieldId) {
98
108
  return (0, _react2.jsx)(Message, {
99
109
  fieldId: fieldId ? "".concat(fieldId, "-helper") : undefined,
@@ -101,6 +111,7 @@ var HelperMessage = function HelperMessage(_ref3) {
101
111
  }, children);
102
112
  });
103
113
  };
114
+
104
115
  /**
105
116
  * __Error message__
106
117
  *
@@ -108,24 +119,19 @@ var HelperMessage = function HelperMessage(_ref3) {
108
119
  * 'Invalid username, needs to be more than 4 characters'.
109
120
  *
110
121
  */
111
-
112
-
113
122
  exports.HelperMessage = HelperMessage;
114
-
115
123
  var ErrorMessage = function ErrorMessage(_ref4) {
116
124
  var children = _ref4.children,
117
- testId = _ref4.testId;
125
+ testId = _ref4.testId;
118
126
  return (0, _react2.jsx)(_field.FieldId.Consumer, null, function (fieldId) {
119
127
  return (0, _react2.jsx)(Message, {
120
- error: true,
128
+ appearance: "error",
121
129
  fieldId: fieldId ? "".concat(fieldId, "-error") : undefined,
122
130
  testId: testId
123
- }, (0, _react2.jsx)(IconWrapper, null, (0, _react2.jsx)(_error.default, {
124
- size: "small",
125
- label: "error"
126
- })), children);
131
+ }, children);
127
132
  });
128
133
  };
134
+
129
135
  /**
130
136
  * __Valid message__
131
137
  *
@@ -133,23 +139,16 @@ var ErrorMessage = function ErrorMessage(_ref4) {
133
139
  * a helper message could be 'Nice one, this username is available'.
134
140
  *
135
141
  */
136
-
137
-
138
142
  exports.ErrorMessage = ErrorMessage;
139
-
140
143
  var ValidMessage = function ValidMessage(_ref5) {
141
144
  var children = _ref5.children,
142
- testId = _ref5.testId;
145
+ testId = _ref5.testId;
143
146
  return (0, _react2.jsx)(_field.FieldId.Consumer, null, function (fieldId) {
144
147
  return (0, _react2.jsx)(Message, {
148
+ appearance: "valid",
145
149
  fieldId: fieldId ? "".concat(fieldId, "-valid") : undefined,
146
- testId: testId,
147
- valid: true
148
- }, (0, _react2.jsx)(IconWrapper, null, (0, _react2.jsx)(_success.default, {
149
- size: "small",
150
- label: "success"
151
- })), children);
150
+ testId: testId
151
+ }, children);
152
152
  });
153
153
  };
154
-
155
154
  exports.ValidMessage = ValidMessage;
@@ -1,30 +1,20 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
-
16
11
  var _react = _interopRequireDefault(require("react"));
17
-
18
12
  var _field = _interopRequireDefault(require("./field"));
19
-
20
13
  var _excluded = ["children"],
21
- _excluded2 = ["isInvalid", "isRequired"],
22
- _excluded3 = ["fieldProps"];
23
-
14
+ _excluded2 = ["isInvalid", "isRequired"],
15
+ _excluded3 = ["fieldProps"];
24
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
-
26
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
-
28
18
  /**
29
19
  * __Range field__
30
20
  *
@@ -36,8 +26,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
36
26
  */
37
27
  var RangeField = function RangeField(props) {
38
28
  var children = props.children,
39
- strippedProps = (0, _objectWithoutProperties2.default)(props, _excluded); // isInvalid and isRequired are specifically invalid for range inputs
40
-
29
+ strippedProps = (0, _objectWithoutProperties2.default)(props, _excluded);
30
+ // isInvalid and isRequired are specifically invalid for range inputs
41
31
  return (
42
32
  /*#__PURE__*/
43
33
  // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
@@ -45,16 +35,15 @@ var RangeField = function RangeField(props) {
45
35
  transform: Number
46
36
  }), function (_ref) {
47
37
  var _ref$fieldProps = _ref.fieldProps,
48
- isInvalid = _ref$fieldProps.isInvalid,
49
- isRequired = _ref$fieldProps.isRequired,
50
- fieldProps = (0, _objectWithoutProperties2.default)(_ref$fieldProps, _excluded2),
51
- rest = (0, _objectWithoutProperties2.default)(_ref, _excluded3);
38
+ isInvalid = _ref$fieldProps.isInvalid,
39
+ isRequired = _ref$fieldProps.isRequired,
40
+ fieldProps = (0, _objectWithoutProperties2.default)(_ref$fieldProps, _excluded2),
41
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded3);
52
42
  return children(_objectSpread({
53
43
  fieldProps: fieldProps
54
44
  }, rest));
55
45
  })
56
46
  );
57
47
  };
58
-
59
48
  var _default = RangeField;
60
49
  exports.default = _default;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/form",
3
- "version": "8.8.2",
3
+ "version": "8.8.4",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback } from 'react';
3
3
  import Field from './field';
4
-
5
4
  /**
6
5
  * __Checkbox field__
7
6
  *
@@ -17,8 +16,9 @@ const CheckboxField = props => {
17
16
  defaultIsChecked = false,
18
17
  value,
19
18
  ...rest
20
- } = props; // Maintains a memoised list of the default values
19
+ } = props;
21
20
 
21
+ // Maintains a memoised list of the default values
22
22
  const defaultValue = useCallback((currentValue = []) => defaultIsChecked && value !== undefined ? [...currentValue, value] : currentValue, [value, defaultIsChecked]);
23
23
  return value !== undefined ? /*#__PURE__*/React.createElement(Field, _extends({}, rest, {
24
24
  defaultValue: defaultValue,
@@ -30,7 +30,8 @@ const CheckboxField = props => {
30
30
  },
31
31
  ...others
32
32
  }) => children({
33
- fieldProps: { ...otherFieldProps,
33
+ fieldProps: {
34
+ ...otherFieldProps,
34
35
  isChecked: !!fieldValue.find(v => v === value),
35
36
  value
36
37
  },
@@ -45,14 +46,14 @@ const CheckboxField = props => {
45
46
  },
46
47
  ...others
47
48
  }) => children({
48
- fieldProps: { ...otherFieldProps,
49
+ fieldProps: {
50
+ ...otherFieldProps,
49
51
  isChecked: fieldValue,
50
52
  value
51
53
  },
52
54
  ...others
53
55
  }));
54
56
  };
55
-
56
57
  CheckboxField.defaultProps = {
57
58
  defaultIsChecked: false
58
59
  };
@@ -17,56 +17,48 @@ const requiredIndicatorStyles = css({
17
17
  color: `var(--ds-text-danger, ${R400})`,
18
18
  fontFamily
19
19
  });
20
-
21
20
  function isEvent(event) {
22
21
  return Boolean(event && event.target);
23
22
  }
24
-
25
23
  function isFunction(x) {
26
24
  return typeof x === 'function';
27
25
  }
28
-
29
26
  /**
30
27
  * __Field id__
31
28
  *
32
29
  * A field id uses the context API. It provides the id of the field to message components. This links the message with the field of screenreaders.
33
30
  */
34
31
  export const FieldId = /*#__PURE__*/createContext(undefined);
35
-
36
32
  function usePreviousRef(current) {
37
- const ref = useRef(current); // will be updated on the next render
33
+ const ref = useRef(current);
38
34
 
35
+ // will be updated on the next render
39
36
  useEffect(() => {
40
37
  ref.current = current;
41
- }); // return the existing current (pre render)
38
+ });
42
39
 
40
+ // return the existing current (pre render)
43
41
  return ref;
44
42
  }
45
-
46
43
  function isShallowEqual(previousValue, currentValue) {
47
44
  if (previousValue === currentValue) {
48
45
  return true;
49
- } // not checking functions
50
-
46
+ }
51
47
 
48
+ // not checking functions
52
49
  if (typeof previousValue === 'function' && typeof currentValue === 'function') {
53
50
  return true;
54
51
  }
55
-
56
52
  if (Array.isArray(previousValue) && Array.isArray(currentValue)) {
57
53
  return JSON.stringify(previousValue) === JSON.stringify(currentValue);
58
54
  }
59
-
60
55
  if (typeof previousValue === 'object' && typeof currentValue === 'object') {
61
56
  return JSON.stringify(previousValue) === JSON.stringify(currentValue);
62
57
  }
63
-
64
58
  return false;
65
59
  }
66
-
67
60
  export default function Field(props) {
68
61
  var _getCurrentValue;
69
-
70
62
  const {
71
63
  registerField,
72
64
  getCurrentValue
@@ -74,19 +66,18 @@ export default function Field(props) {
74
66
  const isDisabled = useContext(IsDisabledContext) || props.isDisabled || false;
75
67
  const defaultValue = isFunction(props.defaultValue) ? props.defaultValue() : props.defaultValue;
76
68
  const latestPropsRef = usePreviousRef(props);
69
+
77
70
  /**
78
71
  * HACK: defaultValue can potentially be an array or object which cannot be
79
72
  * passed directly into a `useEffect` dependency array, since it will trigger
80
73
  * the hook every time.
81
74
  */
82
-
83
75
  const isDefaultValueChanged = !isShallowEqual(latestPropsRef.current.defaultValue, props.defaultValue);
84
76
  const [state, setState] = useState({
85
77
  fieldProps: {
86
78
  onChange: () => {},
87
79
  onBlur: () => {},
88
80
  onFocus: () => {},
89
-
90
81
  /* Previously, defaultValue was being set as undefined in Field.defaultProps, which
91
82
  * effectively made it an optional prop to external consumers of Field. However the
92
83
  * prop types defined defaultValue as required, so inside the component it was not
@@ -119,7 +110,6 @@ export default function Field(props) {
119
110
  if (process.env.NODE_ENV !== 'production' && !process.env.CI) {
120
111
  invariant(latestPropsRef.current.name, '@atlaskit/form: Field components have a required name prop');
121
112
  }
122
-
123
113
  function fieldStateToMeta(value = {}) {
124
114
  return {
125
115
  dirty: value.dirty || false,
@@ -133,7 +123,6 @@ export default function Field(props) {
133
123
  validating: !!value.validating
134
124
  };
135
125
  }
136
-
137
126
  const unregister = registerField(latestPropsRef.current.name,
138
127
  /**
139
128
  * Similar as for setting initial state value.
@@ -144,47 +133,44 @@ export default function Field(props) {
144
133
  * the key prop to re-run validation.
145
134
  */
146
135
  // @ts-ignore
147
- isDefaultValueChanged || // @ts-ignore
136
+ isDefaultValueChanged ||
137
+ // @ts-ignore
148
138
  isFunction(latestPropsRef.current.defaultValue) ? latestPropsRef.current.defaultValue : latestStateRef.current.fieldProps.value, fieldState => {
149
139
  /**
150
140
  * Do not update dirtySinceLastSubmit until submission has finished.
151
141
  */
152
142
  const modifiedDirtySinceLastSubmit = fieldState.submitting ? latestStateRef.current.meta.dirtySinceLastSubmit : fieldState.dirtySinceLastSubmit;
143
+
153
144
  /**
154
145
  * Do not update submitFailed until submission has finished.
155
146
  */
156
-
157
147
  const modifiedSubmitFailed = fieldState.submitting ? latestStateRef.current.meta.submitFailed : fieldState.submitFailed;
148
+
158
149
  /**
159
150
  * Do not use submitError if the value has changed.
160
151
  */
161
-
162
152
  const modifiedSubmitError = modifiedDirtySinceLastSubmit && latestPropsRef.current.validate ? undefined : fieldState.submitError;
163
153
  const modifiedError = modifiedSubmitError || (fieldState.touched || fieldState.dirty) && fieldState.error;
154
+
164
155
  /**
165
156
  * If there has been a submit error, then use logic in modifiedError to determine validity,
166
157
  * so we can determine when there is a submit error which we do not want to display
167
158
  * because the value has been changed.
168
159
  */
169
-
170
160
  const modifiedValid = modifiedSubmitFailed ? modifiedError === undefined : fieldState.valid;
171
-
172
161
  function getTransform(eventOrValue, currentValue) {
173
162
  if (latestPropsRef.current.transform) {
174
163
  return latestPropsRef.current.transform(eventOrValue, currentValue);
175
164
  }
176
-
177
165
  if (isEvent(eventOrValue)) {
178
166
  const {
179
167
  currentTarget
180
168
  } = eventOrValue;
181
-
182
169
  if (currentTarget.type === 'checkbox') {
183
170
  //@ts-expect-error TODO Fix legit TypeScript 3.9.6 improved inference error
184
171
  if (currentTarget.checked) {
185
172
  return currentTarget.value || true;
186
173
  }
187
-
188
174
  return currentTarget.value ? undefined : false;
189
175
  } else if (currentTarget) {
190
176
  return currentTarget.value;
@@ -193,7 +179,6 @@ export default function Field(props) {
193
179
  return eventOrValue;
194
180
  }
195
181
  }
196
-
197
182
  setState({
198
183
  fieldProps: {
199
184
  onChange: e => {
@@ -204,7 +189,6 @@ export default function Field(props) {
204
189
  value: fieldState.value
205
190
  },
206
191
  error: modifiedError || undefined,
207
-
208
192
  /**
209
193
  * The following parameters are optionally typed in final-form to indicate that not all parameters need
210
194
  * to be subscribed to. We cast them as booleans (using || false), since this is what they are semantically.
@@ -226,7 +210,6 @@ export default function Field(props) {
226
210
  }, {
227
211
  getValidator: () => function validate(value, formState, fieldState) {
228
212
  const supplied = latestPropsRef.current.validate;
229
-
230
213
  if (supplied && fieldState) {
231
214
  return supplied(value, formState, fieldStateToMeta(fieldState));
232
215
  }
@@ -234,11 +217,13 @@ export default function Field(props) {
234
217
  });
235
218
  return unregister;
236
219
  }, [latestPropsRef, latestStateRef, registerField, props.name, isDefaultValueChanged]);
237
- const fieldId = useMemo( // eslint-disable-next-line @repo/internal/react/disallow-unstable-values
220
+ const fieldId = useMemo(
221
+ // eslint-disable-next-line @repo/internal/react/disallow-unstable-values
238
222
  () => props.id ? props.id : `${props.name}-${uid({
239
223
  id: props.name
240
224
  })}`, [props.id, props.name]);
241
- const extendedFieldProps = { ...state.fieldProps,
225
+ const extendedFieldProps = {
226
+ ...state.fieldProps,
242
227
  name: props.name,
243
228
  isDisabled,
244
229
  isInvalid: Boolean(state.error),
@@ -1,5 +1,7 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import { css, jsx } from '@emotion/react';
4
+ import { subtleHeading } from '@atlaskit/theme/colors';
3
5
  import { useGlobalTheme } from '@atlaskit/theme/components';
4
6
  import { fontFamily as getFontFamily, gridSize as getGridSize } from '@atlaskit/theme/constants';
5
7
  import { h200 } from '@atlaskit/theme/typography';
@@ -13,20 +15,29 @@ const fieldsetLabelStyles = css({
13
15
  });
14
16
  const fieldSetStyles = css({
15
17
  marginTop: `${gridSize}px`
16
- }); // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
18
+ });
17
19
 
18
- const lightH200Styles = css(h200({
20
+ /**
21
+ * TODO: Address duplication with packages/design-system/form/src/label.tsx
22
+ * in https://product-fabric.atlassian.net/browse/DSP-7731
23
+ */
24
+ const getFieldsetLabelDynamicStyles = mode => css([h200({
19
25
  theme: {
20
- mode: 'light'
26
+ mode
21
27
  }
22
- })); // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
28
+ }), {
29
+ color: `var(--ds-text-subtle, ${subtleHeading({
30
+ theme: {
31
+ mode
32
+ }
33
+ })})`
34
+ }]);
23
35
 
24
- const darkH200Styles = css(h200({
25
- theme: {
26
- mode: 'dark'
27
- }
28
- }));
36
+ // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
37
+ const lightH200Styles = getFieldsetLabelDynamicStyles('light');
29
38
 
39
+ // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
40
+ const darkH200Styles = getFieldsetLabelDynamicStyles('dark');
30
41
  const FieldsetLabel = ({
31
42
  children
32
43
  }) => {
@@ -37,6 +48,7 @@ const FieldsetLabel = ({
37
48
  css: [mode === 'light' ? lightH200Styles : darkH200Styles, fieldsetLabelStyles]
38
49
  }, children);
39
50
  };
51
+
40
52
  /**
41
53
  * __Fieldset__
42
54
  *
@@ -47,8 +59,6 @@ const FieldsetLabel = ({
47
59
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields)
48
60
  * - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields)
49
61
  */
50
-
51
-
52
62
  const Fieldset = ({
53
63
  children,
54
64
  legend
@@ -57,5 +67,4 @@ const Fieldset = ({
57
67
  css: fieldSetStyles
58
68
  }, legend && jsx("legend", null, jsx(FieldsetLabel, null, legend)), children);
59
69
  };
60
-
61
70
  export default Fieldset;
@@ -1,4 +1,5 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import { css, jsx } from '@emotion/react';
3
4
  import { gridSize as getGridSize } from '@atlaskit/theme/constants';
4
5
  const gridSize = getGridSize();
@@ -10,6 +11,7 @@ const formFooterWrapperStyles = css({
10
11
  const justifyContentStyles = css({
11
12
  justifyContent: 'flex-start'
12
13
  });
14
+
13
15
  /**
14
16
  * __Form footer__
15
17
  *
@@ -19,7 +21,6 @@ const justifyContentStyles = css({
19
21
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
20
22
  * - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
21
23
  */
22
-
23
24
  export default function FormFooter({
24
25
  align = 'end',
25
26
  children
@@ -1,4 +1,5 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import { css, jsx } from '@emotion/react';
3
4
  import { useGlobalTheme } from '@atlaskit/theme/components';
4
5
  import { fontFamily as getFontFamily, gridSize as getGridSize } from '@atlaskit/theme/constants';
@@ -22,20 +23,20 @@ const formHeaderTitleStyles = css({
22
23
  });
23
24
  const formHeaderWrapperStyles = css({
24
25
  fontFamily: `${fontFamily}`
25
- }); // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
26
+ });
26
27
 
28
+ // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
27
29
  const darkH700Styles = css(h700({
28
30
  theme: {
29
31
  mode: 'dark'
30
32
  }
31
- })); // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
32
-
33
+ }));
34
+ // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
33
35
  const lightH700Styles = css(h700({
34
36
  theme: {
35
37
  mode: 'light'
36
38
  }
37
39
  }));
38
-
39
40
  const FormHeaderContent = ({
40
41
  children
41
42
  }) => {
@@ -43,7 +44,6 @@ const FormHeaderContent = ({
43
44
  css: formHeaderContentStyles
44
45
  }, children);
45
46
  };
46
-
47
47
  const FormHeaderDescription = ({
48
48
  children
49
49
  }) => {
@@ -51,7 +51,6 @@ const FormHeaderDescription = ({
51
51
  css: formHeaderDescriptionStyles
52
52
  }, children);
53
53
  };
54
-
55
54
  const FormHeaderTitle = ({
56
55
  children
57
56
  }) => {
@@ -62,7 +61,6 @@ const FormHeaderTitle = ({
62
61
  css: [mode === 'light' ? lightH700Styles : darkH700Styles, formHeaderTitleStyles]
63
62
  }, children);
64
63
  };
65
-
66
64
  const FormHeaderWrapper = ({
67
65
  children
68
66
  }) => {
@@ -70,6 +68,7 @@ const FormHeaderWrapper = ({
70
68
  css: formHeaderWrapperStyles
71
69
  }, children);
72
70
  };
71
+
73
72
  /**
74
73
  * __Form header__
75
74
  *
@@ -80,8 +79,6 @@ const FormHeaderWrapper = ({
80
79
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
81
80
  * - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
82
81
  */
83
-
84
-
85
82
  const FormHeader = ({
86
83
  children,
87
84
  description,
@@ -89,6 +86,5 @@ const FormHeader = ({
89
86
  }) => {
90
87
  return jsx(FormHeaderWrapper, null, title && jsx(FormHeaderTitle, null, title), description && jsx(FormHeaderDescription, null, description), children && jsx(FormHeaderContent, null, children));
91
88
  };
92
-
93
89
  export default FormHeader;
94
90
  export { FormHeaderContent, FormHeaderDescription, FormHeaderTitle };