@atlaskit/form 14.4.0 → 15.0.1

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,28 @@
1
1
  # @atlaskit/form
2
2
 
3
+ ## 15.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1f2184e410650`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1f2184e410650) -
8
+ Updates internal useEffect depenedency array to include isRequired. This fixes an issue where
9
+ validation was not rerun when the prop was dynamically updated.
10
+ - Updated dependencies
11
+
12
+ ## 15.0.0
13
+
14
+ ### Major Changes
15
+
16
+ - [`903d3e8f3b8ad`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/903d3e8f3b8ad) -
17
+ Removes `aria-required` from use directly on field. It is automatically applied via `fieldProps`
18
+ when using `isRequired`, so this change is purely to ensure people appropriately apply
19
+ accessibility props to their fields without the false sense of security of an invalid use of
20
+ `aria-required`.
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+
3
26
  ## 14.4.0
4
27
 
5
28
  ### Minor Changes
package/dist/cjs/field.js CHANGED
@@ -14,6 +14,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
14
14
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
15
  var _react = _interopRequireWildcard(require("react"));
16
16
  var _useId = require("@atlaskit/ds-lib/use-id");
17
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
18
  var _fieldIdContext = require("./field-id-context");
18
19
  var _form = require("./form");
19
20
  var _label = require("./label");
@@ -121,6 +122,7 @@ function Field(props) {
121
122
  state = _useState2[0],
122
123
  setState = _useState2[1];
123
124
  var latestStateRef = usePreviousRef(state);
125
+ var isRequiredDependency = (0, _platformFeatureFlags.fg)('platform_dst_form_fix_isrequired_effect') ? props.isRequired : undefined;
124
126
  (0, _react.useEffect)(function () {
125
127
  function fieldStateToMeta() {
126
128
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -229,7 +231,7 @@ function Field(props) {
229
231
  }
230
232
  });
231
233
  return unregister;
232
- }, [latestPropsRef, latestStateRef, registerField, props.name, isDefaultValueChanged]);
234
+ }, [latestPropsRef, latestStateRef, registerField, props.name, isRequiredDependency, isDefaultValueChanged]);
233
235
  var uid = (0, _useId.useId)();
234
236
  var fieldId = (0, _react.useMemo)(function () {
235
237
  return props.id ? props.id : "".concat(props.name, "-").concat(uid);
@@ -3,6 +3,7 @@ import "./field.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import { useId } from '@atlaskit/ds-lib/use-id';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import { FieldId } from './field-id-context';
7
8
  import { FormContext, IsDisabledContext } from './form';
8
9
  import { Label } from './label';
@@ -104,6 +105,7 @@ export default function Field(props) {
104
105
  }
105
106
  });
106
107
  const latestStateRef = usePreviousRef(state);
108
+ const isRequiredDependency = fg('platform_dst_form_fix_isrequired_effect') ? props.isRequired : undefined;
107
109
  useEffect(() => {
108
110
  function fieldStateToMeta(value = {}) {
109
111
  return {
@@ -211,7 +213,7 @@ export default function Field(props) {
211
213
  }
212
214
  });
213
215
  return unregister;
214
- }, [latestPropsRef, latestStateRef, registerField, props.name, isDefaultValueChanged]);
216
+ }, [latestPropsRef, latestStateRef, registerField, props.name, isRequiredDependency, isDefaultValueChanged]);
215
217
  const uid = useId();
216
218
  const fieldId = useMemo(() => {
217
219
  return props.id ? props.id : `${props.name}-${uid}`;
package/dist/esm/field.js CHANGED
@@ -8,6 +8,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
8
8
  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) { _defineProperty(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; }
9
9
  import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
10
10
  import { useId } from '@atlaskit/ds-lib/use-id';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { FieldId } from './field-id-context';
12
13
  import { FormContext, IsDisabledContext } from './form';
13
14
  import { Label } from './label';
@@ -112,6 +113,7 @@ export default function Field(props) {
112
113
  state = _useState2[0],
113
114
  setState = _useState2[1];
114
115
  var latestStateRef = usePreviousRef(state);
116
+ var isRequiredDependency = fg('platform_dst_form_fix_isrequired_effect') ? props.isRequired : undefined;
115
117
  useEffect(function () {
116
118
  function fieldStateToMeta() {
117
119
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -220,7 +222,7 @@ export default function Field(props) {
220
222
  }
221
223
  });
222
224
  return unregister;
223
- }, [latestPropsRef, latestStateRef, registerField, props.name, isDefaultValueChanged]);
225
+ }, [latestPropsRef, latestStateRef, registerField, props.name, isRequiredDependency, isDefaultValueChanged]);
224
226
  var uid = useId();
225
227
  var fieldId = useMemo(function () {
226
228
  return props.id ? props.id : "".concat(props.name, "-").concat(uid);
@@ -97,6 +97,10 @@ export type FieldComponentProps<FieldValue, Element extends SupportedElements> =
97
97
  * A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
98
98
  */
99
99
  testId?: string;
100
+ /**
101
+ * The `aria-required` prop is disallowed. It is automatically applied when using `isRequired` via `fieldProps`.
102
+ */
103
+ 'aria-required'?: never;
100
104
  };
101
105
  export default function Field<FieldValue = string, Element extends SupportedElements = HTMLInputElement>(props: FieldComponentProps<FieldValue, Element>): JSX.Element;
102
106
  export {};
@@ -97,6 +97,10 @@ export type FieldComponentProps<FieldValue, Element extends SupportedElements> =
97
97
  * A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
98
98
  */
99
99
  testId?: string;
100
+ /**
101
+ * The `aria-required` prop is disallowed. It is automatically applied when using `isRequired` via `fieldProps`.
102
+ */
103
+ 'aria-required'?: never;
100
104
  };
101
105
  export default function Field<FieldValue = string, Element extends SupportedElements = HTMLInputElement>(props: FieldComponentProps<FieldValue, Element>): JSX.Element;
102
106
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaskit/form",
3
- "version": "14.4.0",
4
- "description": "A form allows users to input information.",
3
+ "version": "15.0.1",
4
+ "description": "A form allows people to input information.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
7
7
  },
@@ -25,13 +25,13 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "@atlaskit/css": "^0.17.0",
28
+ "@atlaskit/css": "^0.18.0",
29
29
  "@atlaskit/ds-lib": "^5.3.0",
30
30
  "@atlaskit/heading": "^5.2.0",
31
- "@atlaskit/icon": "^29.0.0",
31
+ "@atlaskit/icon": "^29.2.0",
32
32
  "@atlaskit/platform-feature-flags": "^1.1.0",
33
33
  "@atlaskit/primitives": "^16.4.0",
34
- "@atlaskit/tokens": "^8.4.0",
34
+ "@atlaskit/tokens": "^8.6.0",
35
35
  "@atlaskit/visually-hidden": "^3.0.0",
36
36
  "@babel/runtime": "^7.0.0",
37
37
  "@compiled/react": "^0.18.6",
@@ -47,23 +47,24 @@
47
47
  "@af/integration-testing": "workspace:^",
48
48
  "@af/visual-regression": "workspace:^",
49
49
  "@atlaskit/banner": "^14.0.0",
50
- "@atlaskit/button": "^23.7.0",
50
+ "@atlaskit/button": "^23.8.0",
51
51
  "@atlaskit/checkbox": "^17.2.0",
52
52
  "@atlaskit/codemod-utils": "^4.2.0",
53
53
  "@atlaskit/datetime-picker": "^17.2.0",
54
54
  "@atlaskit/docs": "^11.2.0",
55
55
  "@atlaskit/link": "^3.2.0",
56
- "@atlaskit/lozenge": "^13.1.0",
57
- "@atlaskit/modal-dialog": "^14.8.0",
56
+ "@atlaskit/lozenge": "^13.2.0",
57
+ "@atlaskit/modal-dialog": "^14.9.0",
58
58
  "@atlaskit/radio": "^8.3.0",
59
59
  "@atlaskit/range": "^9.3.0",
60
- "@atlaskit/section-message": "^8.10.0",
61
- "@atlaskit/select": "^21.5.0",
60
+ "@atlaskit/section-message": "^8.11.0",
61
+ "@atlaskit/select": "^21.6.0",
62
62
  "@atlaskit/textarea": "^8.2.0",
63
63
  "@atlaskit/textfield": "^8.2.0",
64
64
  "@atlaskit/toggle": "^15.2.0",
65
65
  "@atlassian/feature-flags-test-utils": "^1.0.0",
66
66
  "@atlassian/ssr-tests": "workspace:^",
67
+ "@atlassian/testing-library": "^0.4.0",
67
68
  "@testing-library/react": "^13.4.0",
68
69
  "@testing-library/react-hooks": "^8.0.1",
69
70
  "@testing-library/user-event": "^14.4.3",
@@ -117,6 +118,9 @@
117
118
  },
118
119
  "platform-form-reset-field-state": {
119
120
  "type": "boolean"
121
+ },
122
+ "platform_dst_form_fix_isrequired_effect": {
123
+ "type": "boolean"
120
124
  }
121
125
  }
122
126
  }