@atlaskit/form 12.4.0 → 12.5.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 +13 -0
- package/dist/cjs/form.js +2 -1
- package/dist/cjs/utils.js +25 -0
- package/dist/es2019/form.js +2 -1
- package/dist/es2019/utils.js +19 -0
- package/dist/esm/form.js +2 -1
- package/dist/esm/utils.js +19 -0
- package/dist/types/utils.d.ts +2 -0
- package/dist/types-ts4.5/utils.d.ts +2 -0
- package/package.json +8 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/form
|
|
2
2
|
|
|
3
|
+
## 12.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`c22bdb7c0b0f8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c22bdb7c0b0f8) -
|
|
8
|
+
[ux] Added support for focusing error fields containing react-select when submitting with errors
|
|
9
|
+
|
|
10
|
+
## 12.4.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 12.4.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/cjs/form.js
CHANGED
|
@@ -14,6 +14,7 @@ var _finalForm = require("final-form");
|
|
|
14
14
|
var _finalFormFocus = _interopRequireDefault(require("final-form-focus"));
|
|
15
15
|
var _set = _interopRequireDefault(require("lodash/set"));
|
|
16
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
|
+
var _utils = require("./utils");
|
|
17
18
|
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); }
|
|
18
19
|
/**
|
|
19
20
|
* __Form context__
|
|
@@ -69,7 +70,7 @@ function Form(props) {
|
|
|
69
70
|
});
|
|
70
71
|
(0, _finalFormFocus.default)(function () {
|
|
71
72
|
return formRef.current ? Array.from(formRef.current.querySelectorAll('input')) : [];
|
|
72
|
-
})(finalForm);
|
|
73
|
+
}, (0, _platformFeatureFlags.fg)('platform-form-field-error-focus') ? _utils.getFirstErrorField : undefined)(finalForm);
|
|
73
74
|
return finalForm;
|
|
74
75
|
}),
|
|
75
76
|
_useState2 = (0, _slicedToArray2.default)(_useState, 1),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFirstErrorField = void 0;
|
|
7
|
+
var _finalForm = require("final-form");
|
|
8
|
+
var getFirstErrorField = exports.getFirstErrorField = function getFirstErrorField(inputs, errors) {
|
|
9
|
+
// Guaranteed to be of type HTMLInputElement[] due to getInputs function overrided in createDecorator
|
|
10
|
+
var htmlInputs = inputs;
|
|
11
|
+
return htmlInputs.find(function (input) {
|
|
12
|
+
// If input is hidden, do not focus
|
|
13
|
+
if (input.type === 'hidden') {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// If input ID matches the error, focus
|
|
18
|
+
if (input.id && (0, _finalForm.getIn)(errors, input.id)) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Default to base behavior
|
|
23
|
+
return input.name && (0, _finalForm.getIn)(errors, input.name);
|
|
24
|
+
});
|
|
25
|
+
};
|
package/dist/es2019/form.js
CHANGED
|
@@ -4,6 +4,7 @@ import { createForm } from 'final-form';
|
|
|
4
4
|
import createDecorator from 'final-form-focus';
|
|
5
5
|
import set from 'lodash/set';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { getFirstErrorField } from './utils';
|
|
7
8
|
/**
|
|
8
9
|
* __Form context__
|
|
9
10
|
*
|
|
@@ -51,7 +52,7 @@ export default function Form(props) {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
});
|
|
54
|
-
createDecorator(() => formRef.current ? Array.from(formRef.current.querySelectorAll('input')) : [])(finalForm);
|
|
55
|
+
createDecorator(() => formRef.current ? Array.from(formRef.current.querySelectorAll('input')) : [], fg('platform-form-field-error-focus') ? getFirstErrorField : undefined)(finalForm);
|
|
55
56
|
return finalForm;
|
|
56
57
|
});
|
|
57
58
|
const [state, setState] = useState({
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getIn } from 'final-form';
|
|
2
|
+
export const getFirstErrorField = (inputs, errors) => {
|
|
3
|
+
// Guaranteed to be of type HTMLInputElement[] due to getInputs function overrided in createDecorator
|
|
4
|
+
let htmlInputs = inputs;
|
|
5
|
+
return htmlInputs.find(function (input) {
|
|
6
|
+
// If input is hidden, do not focus
|
|
7
|
+
if (input.type === 'hidden') {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// If input ID matches the error, focus
|
|
12
|
+
if (input.id && getIn(errors, input.id)) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Default to base behavior
|
|
17
|
+
return input.name && getIn(errors, input.name);
|
|
18
|
+
});
|
|
19
|
+
};
|
package/dist/esm/form.js
CHANGED
|
@@ -5,6 +5,7 @@ import { createForm } from 'final-form';
|
|
|
5
5
|
import createDecorator from 'final-form-focus';
|
|
6
6
|
import set from 'lodash/set';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { getFirstErrorField } from './utils';
|
|
8
9
|
/**
|
|
9
10
|
* __Form context__
|
|
10
11
|
*
|
|
@@ -59,7 +60,7 @@ export default function Form(props) {
|
|
|
59
60
|
});
|
|
60
61
|
createDecorator(function () {
|
|
61
62
|
return formRef.current ? Array.from(formRef.current.querySelectorAll('input')) : [];
|
|
62
|
-
})(finalForm);
|
|
63
|
+
}, fg('platform-form-field-error-focus') ? getFirstErrorField : undefined)(finalForm);
|
|
63
64
|
return finalForm;
|
|
64
65
|
}),
|
|
65
66
|
_useState2 = _slicedToArray(_useState, 1),
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getIn } from 'final-form';
|
|
2
|
+
export var getFirstErrorField = function getFirstErrorField(inputs, errors) {
|
|
3
|
+
// Guaranteed to be of type HTMLInputElement[] due to getInputs function overrided in createDecorator
|
|
4
|
+
var htmlInputs = inputs;
|
|
5
|
+
return htmlInputs.find(function (input) {
|
|
6
|
+
// If input is hidden, do not focus
|
|
7
|
+
if (input.type === 'hidden') {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// If input ID matches the error, focus
|
|
12
|
+
if (input.id && getIn(errors, input.id)) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Default to base behavior
|
|
17
|
+
return input.name && getIn(errors, input.name);
|
|
18
|
+
});
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/form",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.5.0",
|
|
4
4
|
"description": "A form allows users to input information.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@atlaskit/css": "^0.
|
|
28
|
+
"@atlaskit/css": "^0.13.0",
|
|
29
29
|
"@atlaskit/ds-lib": "^5.0.0",
|
|
30
30
|
"@atlaskit/heading": "^5.2.0",
|
|
31
31
|
"@atlaskit/icon": "^28.1.0",
|
|
32
32
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
33
|
-
"@atlaskit/primitives": "^14.
|
|
33
|
+
"@atlaskit/primitives": "^14.13.0",
|
|
34
34
|
"@atlaskit/theme": "^20.0.0",
|
|
35
|
-
"@atlaskit/tokens": "^6.
|
|
35
|
+
"@atlaskit/tokens": "^6.2.0",
|
|
36
36
|
"@babel/runtime": "^7.0.0",
|
|
37
37
|
"final-form": "^4.20.3",
|
|
38
38
|
"final-form-focus": "^1.1.2",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@atlaskit/modal-dialog": "^14.3.0",
|
|
57
57
|
"@atlaskit/radio": "^8.3.0",
|
|
58
58
|
"@atlaskit/range": "^9.2.0",
|
|
59
|
-
"@atlaskit/section-message": "^8.
|
|
59
|
+
"@atlaskit/section-message": "^8.7.0",
|
|
60
60
|
"@atlaskit/select": "^21.2.0",
|
|
61
61
|
"@atlaskit/textarea": "^8.0.0",
|
|
62
62
|
"@atlaskit/textfield": "^8.0.0",
|
|
@@ -106,19 +106,6 @@
|
|
|
106
106
|
]
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
|
-
"af:exports": {
|
|
110
|
-
"./CheckboxField": "./src/entry-points/checkbox-field.tsx",
|
|
111
|
-
"./Field": "./src/entry-points/field.tsx",
|
|
112
|
-
"./Fieldset": "./src/entry-points/fieldset.tsx",
|
|
113
|
-
"./FormFooter": "./src/entry-points/form-footer.tsx",
|
|
114
|
-
"./FormHeader": "./src/entry-points/form-header.tsx",
|
|
115
|
-
"./FormSection": "./src/entry-points/form-section.tsx",
|
|
116
|
-
"./Form": "./src/entry-points/form.tsx",
|
|
117
|
-
"./Messages": "./src/entry-points/messages.tsx",
|
|
118
|
-
"./RangeField": "./src/entry-points/range-field.tsx",
|
|
119
|
-
"./Label": "./src/entry-points/label.tsx",
|
|
120
|
-
".": "./src/index.tsx"
|
|
121
|
-
},
|
|
122
109
|
"homepage": "https://atlassian.design/components/form/",
|
|
123
110
|
"platform-feature-flags": {
|
|
124
111
|
"platform_dst_form_screenreader_message_fix": {
|
|
@@ -132,6 +119,9 @@
|
|
|
132
119
|
},
|
|
133
120
|
"platform_design-system-team_checkbox-field-spread": {
|
|
134
121
|
"type": "boolean"
|
|
122
|
+
},
|
|
123
|
+
"platform-form-field-error-focus": {
|
|
124
|
+
"type": "boolean"
|
|
135
125
|
}
|
|
136
126
|
}
|
|
137
127
|
}
|