@atlaskit/textfield 5.6.7 → 6.0.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 +59 -47
- package/codemods/migrations/utils.tsx +2 -1
- package/dist/cjs/index.js +1 -8
- package/dist/cjs/styles.js +44 -101
- package/dist/cjs/text-field.js +40 -34
- package/dist/es2019/index.js +1 -2
- package/dist/es2019/styles.js +44 -95
- package/dist/es2019/text-field.js +34 -26
- package/dist/esm/index.js +1 -2
- package/dist/esm/styles.js +43 -94
- package/dist/esm/text-field.js +38 -31
- package/dist/types/index.d.ts +0 -1
- package/dist/types/styles.d.ts +2 -127
- package/dist/types-ts4.5/index.d.ts +0 -1
- package/dist/types-ts4.5/styles.d.ts +2 -127
- package/package.json +4 -3
- package/report.api.md +0 -126
- package/tmp/api-report-tmp.d.ts +0 -126
- package/dist/cjs/component-tokens.js +0 -63
- package/dist/es2019/component-tokens.js +0 -46
- package/dist/esm/component-tokens.js +0 -46
- package/dist/types/component-tokens.d.ts +0 -44
- package/dist/types-ts4.5/component-tokens.d.ts +0 -44
package/dist/cjs/text-field.js
CHANGED
|
@@ -13,9 +13,8 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _react2 = require("@emotion/react");
|
|
15
15
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
16
|
-
var _components = require("@atlaskit/theme/components");
|
|
17
16
|
var _styles = require("./styles");
|
|
18
|
-
var _excluded = ["appearance", "isCompact", "isDisabled", "isInvalid", "
|
|
17
|
+
var _excluded = ["appearance", "className", "elemAfterInput", "elemBeforeInput", "isCompact", "isDisabled", "isInvalid", "isMonospaced", "isReadOnly", "isRequired", "name", "onBlur", "onChange", "onFocus", "onMouseDown", "placeholder", "testId", "width"];
|
|
19
18
|
/** @jsx jsx */
|
|
20
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -24,35 +23,36 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
24
23
|
var analyticsParams = {
|
|
25
24
|
componentName: 'textField',
|
|
26
25
|
packageName: "@atlaskit/textfield",
|
|
27
|
-
packageVersion: "
|
|
26
|
+
packageVersion: "6.0.0"
|
|
28
27
|
};
|
|
29
28
|
var Textfield = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
30
29
|
var _props$appearance = props.appearance,
|
|
31
30
|
appearance = _props$appearance === void 0 ? 'standard' : _props$appearance,
|
|
31
|
+
className = props.className,
|
|
32
|
+
elemAfterInput = props.elemAfterInput,
|
|
33
|
+
elemBeforeInput = props.elemBeforeInput,
|
|
32
34
|
_props$isCompact = props.isCompact,
|
|
33
35
|
isCompact = _props$isCompact === void 0 ? false : _props$isCompact,
|
|
34
36
|
_props$isDisabled = props.isDisabled,
|
|
35
37
|
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
36
38
|
_props$isInvalid = props.isInvalid,
|
|
37
39
|
isInvalid = _props$isInvalid === void 0 ? false : _props$isInvalid,
|
|
38
|
-
_props$isRequired = props.isRequired,
|
|
39
|
-
isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
|
|
40
|
-
_props$isReadOnly = props.isReadOnly,
|
|
41
|
-
isReadOnly = _props$isReadOnly === void 0 ? false : _props$isReadOnly,
|
|
42
40
|
_props$isMonospaced = props.isMonospaced,
|
|
43
41
|
isMonospaced = _props$isMonospaced === void 0 ? false : _props$isMonospaced,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
_props$isReadOnly = props.isReadOnly,
|
|
43
|
+
isReadOnly = _props$isReadOnly === void 0 ? false : _props$isReadOnly,
|
|
44
|
+
_props$isRequired = props.isRequired,
|
|
45
|
+
isRequired = _props$isRequired === void 0 ? false : _props$isRequired,
|
|
46
|
+
name = props.name,
|
|
49
47
|
onBlur = props.onBlur,
|
|
48
|
+
onChange = props.onChange,
|
|
49
|
+
onFocus = props.onFocus,
|
|
50
50
|
onMouseDown = props.onMouseDown,
|
|
51
|
-
|
|
51
|
+
placeholder = props.placeholder,
|
|
52
|
+
testId = props.testId,
|
|
53
|
+
width = props.width,
|
|
52
54
|
spreadProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
53
55
|
var inputRef = (0, _react.useRef)(null);
|
|
54
|
-
var _useGlobalTheme = (0, _components.useGlobalTheme)(),
|
|
55
|
-
mode = _useGlobalTheme.mode;
|
|
56
56
|
var handleOnFocus = (0, _analyticsNext.usePlatformLeafEventHandler)(_objectSpread({
|
|
57
57
|
fn: function fn(event) {
|
|
58
58
|
onFocus && onFocus(event);
|
|
@@ -90,15 +90,19 @@ var Textfield = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
90
90
|
}
|
|
91
91
|
}, [ref]);
|
|
92
92
|
var containerStyles = (0, _react.useMemo)(function () {
|
|
93
|
-
return (0, _styles.containerStyles)(appearance,
|
|
94
|
-
}, [appearance,
|
|
95
|
-
var inputStyle = (0,
|
|
96
|
-
return (0, _styles.inputStyles)(mode);
|
|
97
|
-
}, [mode]);
|
|
93
|
+
return (0, _styles.containerStyles)(appearance, width);
|
|
94
|
+
}, [appearance, width]);
|
|
95
|
+
var inputStyle = (0, _styles.inputStyles)();
|
|
98
96
|
return (
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
/**
|
|
98
|
+
* It is not normally acceptable to add click and key handlers to
|
|
99
|
+
* non-interactive elements as this is an accessibility anti-pattern.
|
|
100
|
+
* However, because this instance is to handle events on all children that
|
|
101
|
+
* should be associated with the input, we can add role="presentation" so
|
|
102
|
+
* that there are no negative impacts to assistive technologies.
|
|
103
|
+
*/
|
|
101
104
|
(0, _react2.jsx)("div", {
|
|
105
|
+
role: "presentation",
|
|
102
106
|
"data-disabled": isDisabled ? isDisabled : undefined,
|
|
103
107
|
"data-invalid": isInvalid ? isInvalid : undefined,
|
|
104
108
|
"data-ds--text-field--container": true,
|
|
@@ -110,21 +114,24 @@ var Textfield = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
110
114
|
css: containerStyles,
|
|
111
115
|
className: className
|
|
112
116
|
}, elemBeforeInput, (0, _react2.jsx)("input", (0, _extends2.default)({}, spreadProps, {
|
|
117
|
+
"aria-invalid": isInvalid ? isInvalid : undefined
|
|
118
|
+
// TODO: When removing legacy theming fix this.
|
|
119
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
120
|
+
,
|
|
121
|
+
css: inputStyle,
|
|
113
122
|
"data-compact": isCompact ? isCompact : undefined,
|
|
114
|
-
"data-monospaced": isMonospaced ? isMonospaced : undefined,
|
|
115
123
|
"data-ds--text-field--input": true,
|
|
124
|
+
"data-monospaced": isMonospaced ? isMonospaced : undefined,
|
|
116
125
|
"data-testid": testId,
|
|
117
|
-
"aria-invalid": isInvalid ? isInvalid : undefined,
|
|
118
126
|
disabled: isDisabled,
|
|
119
|
-
|
|
120
|
-
required: isRequired,
|
|
127
|
+
name: name,
|
|
121
128
|
onBlur: handleOnBlur,
|
|
129
|
+
onChange: onChange,
|
|
122
130
|
onFocus: handleOnFocus,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
css: inputStyle
|
|
131
|
+
placeholder: placeholder,
|
|
132
|
+
readOnly: isReadOnly,
|
|
133
|
+
ref: setInputRef,
|
|
134
|
+
required: isRequired
|
|
128
135
|
})), elemAfterInput)
|
|
129
136
|
);
|
|
130
137
|
});
|
|
@@ -139,6 +146,5 @@ Textfield.displayName = 'Textfield';
|
|
|
139
146
|
* - [Code](https://atlassian.design/components/textfield/code)
|
|
140
147
|
* - [Usage](https://atlassian.design/components/textfield/usage)
|
|
141
148
|
*/
|
|
142
|
-
var _default = /*#__PURE__*/(0, _react.memo)(Textfield); // The above generic is used to let ERTC know what props to extract.
|
|
143
|
-
// See: https://github.com/atlassian/extract-react-types/issues/201
|
|
144
|
-
exports.default = _default;
|
|
149
|
+
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(Textfield); // The above generic is used to let ERTC know what props to extract.
|
|
150
|
+
// See: https://github.com/atlassian/extract-react-types/issues/201
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { default } from './text-field';
|
|
2
|
-
export { textFieldColors as TextFieldColors } from './styles';
|
|
1
|
+
export { default } from './text-field';
|
package/dist/es2019/styles.js
CHANGED
|
@@ -1,107 +1,72 @@
|
|
|
1
1
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
2
|
-
import { R400 } from '@atlaskit/theme/colors';
|
|
2
|
+
import { B200, N0, N10, N100, N200, N30, N40, N70, N900, R400 } from '@atlaskit/theme/colors';
|
|
3
3
|
import { codeFontFamily, fontFamily, fontSize as getFontSize,
|
|
4
4
|
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
5
5
|
gridSize as getGridSize } from '@atlaskit/theme/constants';
|
|
6
|
-
import * as componentTokens from './component-tokens';
|
|
7
6
|
const fontSize = getFontSize();
|
|
8
7
|
const gridSize = getGridSize();
|
|
9
|
-
const disabledRules = {
|
|
10
|
-
light: {
|
|
11
|
-
backgroundColor: componentTokens.disabledBackgroundColor.light,
|
|
12
|
-
backgroundColorHover: componentTokens.disabledBackgroundColor.light,
|
|
13
|
-
borderColor: componentTokens.disabledBackgroundColor.light,
|
|
14
|
-
textColor: componentTokens.disabledTextColor.light
|
|
15
|
-
},
|
|
16
|
-
dark: {
|
|
17
|
-
backgroundColor: componentTokens.disabledBackgroundColor.dark,
|
|
18
|
-
backgroundColorHover: componentTokens.disabledBackgroundColor.dark,
|
|
19
|
-
borderColor: componentTokens.disabledBackgroundColor.dark,
|
|
20
|
-
textColor: componentTokens.disabledTextColor.dark
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const invalidRules = {
|
|
24
|
-
light: {
|
|
25
|
-
// ----
|
|
26
|
-
backgroundColor: componentTokens.defaultBackgroundColor.light,
|
|
27
|
-
backgroundColorHover: componentTokens.defaultBackgroundColorHover.light,
|
|
28
|
-
// ^--- the above values aren't used directly they remain because its exposed by the `textFieldColors` export
|
|
29
|
-
backgroundColorFocus: componentTokens.defaultBackgroundColorFocus.light,
|
|
30
|
-
borderColor: `var(--ds-border-danger, ${R400})`,
|
|
31
|
-
borderColorFocus: componentTokens.defaultBorderColorFocus.light
|
|
32
|
-
},
|
|
33
|
-
dark: {
|
|
34
|
-
// ----
|
|
35
|
-
backgroundColor: componentTokens.defaultBackgroundColor.dark,
|
|
36
|
-
backgroundColorHover: componentTokens.defaultBackgroundColorHover.dark,
|
|
37
|
-
// ^--- the above values aren't used directly they remain because its exposed by the `textFieldColors` export
|
|
38
|
-
backgroundColorFocus: componentTokens.defaultBackgroundColorFocus.dark,
|
|
39
|
-
borderColor: `var(--ds-border-danger, ${R400})`,
|
|
40
|
-
borderColorFocus: componentTokens.defaultBorderColorFocus.dark
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
8
|
const backgroundColor = {
|
|
44
|
-
standard:
|
|
45
|
-
subtle:
|
|
46
|
-
none:
|
|
9
|
+
standard: `var(--ds-background-input, ${N10})`,
|
|
10
|
+
subtle: 'transparent',
|
|
11
|
+
none: 'transparent'
|
|
47
12
|
};
|
|
48
13
|
const backgroundColorFocus = {
|
|
49
|
-
standard:
|
|
50
|
-
subtle:
|
|
51
|
-
none:
|
|
14
|
+
standard: `var(--ds-background-input-pressed, ${N0})`,
|
|
15
|
+
subtle: `var(--ds-background-input-pressed, ${N0})`,
|
|
16
|
+
none: 'transparent'
|
|
52
17
|
};
|
|
53
18
|
const backgroundColorHover = {
|
|
54
|
-
standard:
|
|
55
|
-
subtle:
|
|
56
|
-
none:
|
|
19
|
+
standard: `var(--ds-background-input-hovered, ${N30})`,
|
|
20
|
+
subtle: `var(--ds-background-input-hovered, ${N30})`,
|
|
21
|
+
none: 'transparent'
|
|
57
22
|
};
|
|
58
23
|
const borderColor = {
|
|
59
|
-
standard:
|
|
60
|
-
subtle:
|
|
61
|
-
none:
|
|
24
|
+
standard: `var(--ds-border-input, ${getBooleanFF('platform.design-system-team.border-checkbox_nyoiu') ? N100 : N40})`,
|
|
25
|
+
subtle: 'transparent',
|
|
26
|
+
none: 'transparent'
|
|
62
27
|
};
|
|
63
28
|
const borderColorFocus = {
|
|
64
|
-
standard:
|
|
65
|
-
subtle:
|
|
66
|
-
none:
|
|
29
|
+
standard: `var(--ds-border-focused, ${B200})`,
|
|
30
|
+
subtle: `var(--ds-border-focused, ${B200})`,
|
|
31
|
+
none: 'transparent'
|
|
67
32
|
};
|
|
68
33
|
const borderColorHover = {
|
|
69
|
-
standard:
|
|
70
|
-
subtle:
|
|
71
|
-
none:
|
|
34
|
+
standard: `var(--ds-border-input, ${getBooleanFF('platform.design-system-team.border-checkbox_nyoiu') ? N100 : N40})`,
|
|
35
|
+
subtle: "var(--ds-border-input, transparent)",
|
|
36
|
+
none: 'transparent'
|
|
72
37
|
};
|
|
73
|
-
const getContainerTextBgAndBorderColor =
|
|
74
|
-
backgroundColor: backgroundColor[appearance]
|
|
75
|
-
borderColor: borderColor[appearance]
|
|
76
|
-
color:
|
|
38
|
+
const getContainerTextBgAndBorderColor = appearance => ({
|
|
39
|
+
backgroundColor: backgroundColor[appearance],
|
|
40
|
+
borderColor: borderColor[appearance],
|
|
41
|
+
color: `var(--ds-text, ${N900})`,
|
|
77
42
|
cursor: 'text',
|
|
78
43
|
'&:hover:not([data-disabled])': {
|
|
79
|
-
backgroundColor: backgroundColorHover[appearance]
|
|
80
|
-
borderColor: borderColorHover[appearance]
|
|
44
|
+
backgroundColor: backgroundColorHover[appearance],
|
|
45
|
+
borderColor: borderColorHover[appearance]
|
|
81
46
|
},
|
|
82
47
|
'&:focus-within:not([data-disabled])': {
|
|
83
|
-
backgroundColor: backgroundColorFocus[appearance]
|
|
84
|
-
borderColor: borderColorFocus[appearance]
|
|
85
|
-
boxShadow: getBooleanFF('platform.design-system-team.border-checkbox_nyoiu') ? `inset 0 0 0 ${"var(--ds-border-width, 1px)"} ${borderColorFocus[appearance]
|
|
48
|
+
backgroundColor: backgroundColorFocus[appearance],
|
|
49
|
+
borderColor: borderColorFocus[appearance],
|
|
50
|
+
boxShadow: getBooleanFF('platform.design-system-team.border-checkbox_nyoiu') ? `inset 0 0 0 ${"var(--ds-border-width, 1px)"} ${borderColorFocus[appearance]}` : undefined
|
|
86
51
|
},
|
|
87
52
|
'&[data-disabled]': {
|
|
88
|
-
color:
|
|
53
|
+
color: `var(--ds-text-disabled, ${N70})`,
|
|
89
54
|
cursor: 'not-allowed',
|
|
90
55
|
// Disabled background and border styles should not be applied to components that
|
|
91
56
|
// have either no background or transparent background to begin with
|
|
92
57
|
...(appearance === 'standard' && {
|
|
93
|
-
backgroundColor:
|
|
94
|
-
borderColor:
|
|
58
|
+
backgroundColor: `var(--ds-background-disabled, ${N10})`,
|
|
59
|
+
borderColor: `var(--ds-background-disabled, ${N10})`
|
|
95
60
|
})
|
|
96
61
|
},
|
|
97
62
|
'&[data-invalid], &[data-invalid]:hover': {
|
|
98
|
-
borderColor:
|
|
99
|
-
boxShadow: getBooleanFF('platform.design-system-team.border-checkbox_nyoiu') ? `inset 0 0 0 ${"var(--ds-border-width, 1px)"} ${
|
|
63
|
+
borderColor: `var(--ds-border-danger, ${R400})`,
|
|
64
|
+
boxShadow: getBooleanFF('platform.design-system-team.border-checkbox_nyoiu') ? `inset 0 0 0 ${"var(--ds-border-width, 1px)"} ${`var(--ds-border-danger, ${R400})`}` : undefined
|
|
100
65
|
},
|
|
101
66
|
'&[data-invalid]:focus-within': {
|
|
102
|
-
backgroundColor:
|
|
103
|
-
borderColor:
|
|
104
|
-
boxShadow: getBooleanFF('platform.design-system-team.border-checkbox_nyoiu') ? `inset 0 0 0 ${"var(--ds-border-width, 1px)"} ${
|
|
67
|
+
backgroundColor: `var(--ds-background-input-pressed, ${N0})`,
|
|
68
|
+
borderColor: `var(--ds-border-focused, ${B200})`,
|
|
69
|
+
boxShadow: getBooleanFF('platform.design-system-team.border-checkbox_nyoiu') ? `inset 0 0 0 ${"var(--ds-border-width, 1px)"} ${`var(--ds-border-focused, ${B200})`}` : undefined
|
|
105
70
|
},
|
|
106
71
|
'@media screen and (-ms-high-contrast: active)': {
|
|
107
72
|
'&[data-invalid]:focus-within': {
|
|
@@ -123,15 +88,13 @@ const widthMap = {
|
|
|
123
88
|
xlarge: 480
|
|
124
89
|
};
|
|
125
90
|
const getMaxWidth = width => !width ? `100%` : width in widthMap ? widthMap[width] : +width;
|
|
126
|
-
export const containerStyles = (appearance,
|
|
91
|
+
export const containerStyles = (appearance, width) => ({
|
|
127
92
|
alignItems: 'center',
|
|
128
|
-
...getContainerTextBgAndBorderColor(appearance
|
|
93
|
+
...getContainerTextBgAndBorderColor(appearance),
|
|
129
94
|
borderRadius: 3,
|
|
130
95
|
borderWidth: getBooleanFF('platform.design-system-team.border-checkbox_nyoiu') ? "var(--ds-border-width, 1px)" : 2,
|
|
131
96
|
// add 1px padding on both top and bottom to keep the same overall height after border reduced from 2px to 1px under feature flag
|
|
132
|
-
...(getBooleanFF('platform.design-system-team.border-checkbox_nyoiu') && appearance !== 'none' ?
|
|
133
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
134
|
-
{
|
|
97
|
+
...(getBooleanFF('platform.design-system-team.border-checkbox_nyoiu') && appearance !== 'none' ? {
|
|
135
98
|
padding: `${"var(--ds-border-width, 1px)"} 0`
|
|
136
99
|
} : {}),
|
|
137
100
|
borderStyle: appearance === 'none' ? 'none' : 'solid',
|
|
@@ -147,7 +110,7 @@ export const containerStyles = (appearance, mode, width) => ({
|
|
|
147
110
|
verticalAlign: 'top',
|
|
148
111
|
pointerEvents: 'auto'
|
|
149
112
|
});
|
|
150
|
-
export const inputStyles =
|
|
113
|
+
export const inputStyles = () => ({
|
|
151
114
|
backgroundColor: 'transparent',
|
|
152
115
|
border: 0,
|
|
153
116
|
boxSizing: 'border-box',
|
|
@@ -174,7 +137,7 @@ export const inputStyles = mode => ({
|
|
|
174
137
|
// Safari (WebKit) adds a -webkit-text-fill-color style to disabled inputs
|
|
175
138
|
// which takes priority over color and makes the text unreadable. Need to
|
|
176
139
|
// override it with the color we want.
|
|
177
|
-
WebkitTextFillColor:
|
|
140
|
+
WebkitTextFillColor: `var(--ds-text-disabled, ${N70})`
|
|
178
141
|
},
|
|
179
142
|
// Hide the clear indicator on Edge (Windows only)
|
|
180
143
|
'&::-ms-clear': {
|
|
@@ -187,9 +150,9 @@ export const inputStyles = mode => ({
|
|
|
187
150
|
textOverflow: 'ellipsis'
|
|
188
151
|
},
|
|
189
152
|
'&::placeholder': {
|
|
190
|
-
color:
|
|
153
|
+
color: `var(--ds-text-subtlest, ${N200})`,
|
|
191
154
|
'&:disabled': {
|
|
192
|
-
color:
|
|
155
|
+
color: `var(--ds-text-disabled, ${N70})`
|
|
193
156
|
}
|
|
194
157
|
},
|
|
195
158
|
'@media screen and (-ms-high-contrast: active)': {
|
|
@@ -197,18 +160,4 @@ export const inputStyles = mode => ({
|
|
|
197
160
|
color: 'GrayText'
|
|
198
161
|
}
|
|
199
162
|
}
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
// TODO: Remove when removing legacy theming.
|
|
203
|
-
export const textFieldColors = {
|
|
204
|
-
backgroundColor,
|
|
205
|
-
backgroundColorFocus,
|
|
206
|
-
backgroundColorHover,
|
|
207
|
-
borderColor,
|
|
208
|
-
borderColorFocus,
|
|
209
|
-
borderColorHover,
|
|
210
|
-
placeholderTextColor: componentTokens.placeholderTextColor,
|
|
211
|
-
textColor: componentTokens.textColor,
|
|
212
|
-
invalidRules,
|
|
213
|
-
disabledRules
|
|
214
|
-
};
|
|
163
|
+
});
|
|
@@ -3,36 +3,35 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
import React, { forwardRef, memo, useCallback, useMemo, useRef } from 'react';
|
|
4
4
|
import { jsx } from '@emotion/react';
|
|
5
5
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
6
|
-
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
7
6
|
import { containerStyles as getContainerStyles, inputStyles as getInputStyles } from './styles';
|
|
8
7
|
const analyticsParams = {
|
|
9
8
|
componentName: 'textField',
|
|
10
9
|
packageName: "@atlaskit/textfield",
|
|
11
|
-
packageVersion: "
|
|
10
|
+
packageVersion: "6.0.0"
|
|
12
11
|
};
|
|
13
12
|
const Textfield = /*#__PURE__*/forwardRef((props, ref) => {
|
|
14
13
|
const {
|
|
15
14
|
appearance = 'standard',
|
|
15
|
+
className,
|
|
16
|
+
elemAfterInput,
|
|
17
|
+
elemBeforeInput,
|
|
16
18
|
isCompact = false,
|
|
17
19
|
isDisabled = false,
|
|
18
20
|
isInvalid = false,
|
|
19
|
-
isRequired = false,
|
|
20
|
-
isReadOnly = false,
|
|
21
21
|
isMonospaced = false,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
testId,
|
|
26
|
-
onFocus,
|
|
22
|
+
isReadOnly = false,
|
|
23
|
+
isRequired = false,
|
|
24
|
+
name,
|
|
27
25
|
onBlur,
|
|
26
|
+
onChange,
|
|
27
|
+
onFocus,
|
|
28
28
|
onMouseDown,
|
|
29
|
-
|
|
29
|
+
placeholder,
|
|
30
|
+
testId,
|
|
31
|
+
width,
|
|
30
32
|
...spreadProps
|
|
31
33
|
} = props;
|
|
32
34
|
const inputRef = useRef(null);
|
|
33
|
-
const {
|
|
34
|
-
mode
|
|
35
|
-
} = useGlobalTheme();
|
|
36
35
|
const handleOnFocus = usePlatformLeafEventHandler({
|
|
37
36
|
fn: event => {
|
|
38
37
|
onFocus && onFocus(event);
|
|
@@ -71,12 +70,18 @@ const Textfield = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
71
70
|
ref(inputElement);
|
|
72
71
|
}
|
|
73
72
|
}, [ref]);
|
|
74
|
-
const containerStyles = useMemo(() => getContainerStyles(appearance,
|
|
75
|
-
const inputStyle =
|
|
73
|
+
const containerStyles = useMemo(() => getContainerStyles(appearance, width), [appearance, width]);
|
|
74
|
+
const inputStyle = getInputStyles();
|
|
76
75
|
return (
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
/**
|
|
77
|
+
* It is not normally acceptable to add click and key handlers to
|
|
78
|
+
* non-interactive elements as this is an accessibility anti-pattern.
|
|
79
|
+
* However, because this instance is to handle events on all children that
|
|
80
|
+
* should be associated with the input, we can add role="presentation" so
|
|
81
|
+
* that there are no negative impacts to assistive technologies.
|
|
82
|
+
*/
|
|
79
83
|
jsx("div", {
|
|
84
|
+
role: "presentation",
|
|
80
85
|
"data-disabled": isDisabled ? isDisabled : undefined,
|
|
81
86
|
"data-invalid": isInvalid ? isInvalid : undefined,
|
|
82
87
|
"data-ds--text-field--container": true,
|
|
@@ -88,21 +93,24 @@ const Textfield = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
88
93
|
css: containerStyles,
|
|
89
94
|
className: className
|
|
90
95
|
}, elemBeforeInput, jsx("input", _extends({}, spreadProps, {
|
|
96
|
+
"aria-invalid": isInvalid ? isInvalid : undefined
|
|
97
|
+
// TODO: When removing legacy theming fix this.
|
|
98
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
99
|
+
,
|
|
100
|
+
css: inputStyle,
|
|
91
101
|
"data-compact": isCompact ? isCompact : undefined,
|
|
92
|
-
"data-monospaced": isMonospaced ? isMonospaced : undefined,
|
|
93
102
|
"data-ds--text-field--input": true,
|
|
103
|
+
"data-monospaced": isMonospaced ? isMonospaced : undefined,
|
|
94
104
|
"data-testid": testId,
|
|
95
|
-
"aria-invalid": isInvalid ? isInvalid : undefined,
|
|
96
105
|
disabled: isDisabled,
|
|
97
|
-
|
|
98
|
-
required: isRequired,
|
|
106
|
+
name: name,
|
|
99
107
|
onBlur: handleOnBlur,
|
|
108
|
+
onChange: onChange,
|
|
100
109
|
onFocus: handleOnFocus,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
css: inputStyle
|
|
110
|
+
placeholder: placeholder,
|
|
111
|
+
readOnly: isReadOnly,
|
|
112
|
+
ref: setInputRef,
|
|
113
|
+
required: isRequired
|
|
106
114
|
})), elemAfterInput)
|
|
107
115
|
);
|
|
108
116
|
});
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { default } from './text-field';
|
|
2
|
-
export { textFieldColors as TextFieldColors } from './styles';
|
|
1
|
+
export { default } from './text-field';
|