@atlaskit/textfield 5.0.5 → 5.1.3
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 +35 -0
- package/codemods/{5.0.0-lite-mode.ts → 5.0.0-lite-mode.tsx} +1 -1
- package/codemods/__tests__/{5.0.0-lite-mode.ts → 5.0.0-lite-mode.tsx} +0 -0
- package/codemods/__tests__/remove-imports.tsx +1 -1
- package/codemods/__tests__/remove-prop.tsx +1 -1
- package/codemods/__tests__/rename-imports.tsx +1 -1
- package/codemods/migrations/{remove-imports.ts → remove-imports.tsx} +1 -1
- package/codemods/migrations/{remove-props.ts → remove-props.tsx} +1 -1
- package/codemods/migrations/{rename-imports.ts → rename-imports.tsx} +1 -1
- package/codemods/{utils.ts → migrations/utils.tsx} +0 -0
- package/dist/cjs/component-tokens.js +27 -29
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/styles.js +22 -30
- package/dist/cjs/text-field.js +48 -45
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/component-tokens.js +25 -28
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/styles.js +18 -28
- package/dist/es2019/text-field.js +47 -44
- package/dist/es2019/version.json +1 -1
- package/dist/esm/component-tokens.js +25 -28
- package/dist/esm/index.js +1 -1
- package/dist/esm/styles.js +18 -28
- package/dist/esm/text-field.js +48 -46
- package/dist/esm/version.json +1 -1
- package/dist/types/component-tokens.d.ts +22 -22
- package/dist/types/index.d.ts +2 -2
- package/dist/types/styles.d.ts +135 -46
- package/dist/types/text-field.d.ts +11 -2
- package/dist/types/types.d.ts +1 -6
- package/package.json +17 -21
- package/extract-react-types/text-field-props.tsx +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @atlaskit/textfield
|
|
2
2
|
|
|
3
|
+
## 5.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 5.1.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 5.1.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
21
|
+
## 5.1.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- [`78ba9e045b8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/78ba9e045b8) - Internal refactor to align to the design system techstack.
|
|
26
|
+
- [`4d34d35270e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4d34d35270e) - Instrumented text field with the new theming package, `@atlaskit/tokens`.
|
|
27
|
+
|
|
28
|
+
New tokens will be visible only in applications configured to use the new Tokens API (currently in alpha).
|
|
29
|
+
These changes are intended to be interoperable with the legacy theme implementation.
|
|
30
|
+
Legacy dark mode users should expect no visual or breaking changes.
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- [`af4bca32ad4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/af4bca32ad4) - Internal changes to supress eslint rules.
|
|
35
|
+
- [`ac656b4875e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ac656b4875e) - Internal style refactor with no visual change.
|
|
36
|
+
- Updated dependencies
|
|
37
|
+
|
|
3
38
|
## 5.0.5
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
renameThemeAppearanceImport,
|
|
5
5
|
renamethemeTokensImport,
|
|
6
6
|
} from './migrations/rename-imports';
|
|
7
|
-
import { createTransformer } from './utils';
|
|
7
|
+
import { createTransformer } from './migrations/utils';
|
|
8
8
|
|
|
9
9
|
const transformer = createTransformer('@atlaskit/textfield', [
|
|
10
10
|
removeThemeProp,
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
jest.autoMockOff();
|
|
2
2
|
|
|
3
3
|
import { removeThemeImports } from '../migrations/remove-imports';
|
|
4
|
-
import { createTransformer } from '../utils';
|
|
4
|
+
import { createTransformer } from '../migrations/utils';
|
|
5
5
|
|
|
6
6
|
const transformer = createTransformer('@atlaskit/textfield', [
|
|
7
7
|
removeThemeImports,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
jest.autoMockOff();
|
|
2
2
|
|
|
3
3
|
import { removeThemeProp } from '../migrations/remove-props';
|
|
4
|
-
import { createTransformer } from '../utils';
|
|
4
|
+
import { createTransformer } from '../migrations/utils';
|
|
5
5
|
|
|
6
6
|
const transformer = createTransformer('@atlaskit/textfield', [removeThemeProp]);
|
|
7
7
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
renameThemeAppearanceImport,
|
|
5
5
|
renamethemeTokensImport,
|
|
6
6
|
} from '../migrations/rename-imports';
|
|
7
|
-
import { createTransformer } from '../utils';
|
|
7
|
+
import { createTransformer } from '../migrations/utils';
|
|
8
8
|
|
|
9
9
|
const transformer = createTransformer('@atlaskit/textfield', [
|
|
10
10
|
renamethemeTokensImport,
|
|
File without changes
|
|
@@ -3,47 +3,45 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.placeholderTextColor = exports.disabledTextColor = exports.textColor = exports.transparent = exports.defaultBorderColorFocus = exports.defaultBorderColor = exports.
|
|
6
|
+
exports.placeholderTextColor = exports.disabledTextColor = exports.textColor = exports.transparent = exports.defaultBorderColorFocus = exports.defaultBorderColor = exports.subtleBackgroundColorHover = exports.defaultBackgroundColorHover = exports.defaultBackgroundColorFocus = exports.defaultBackgroundColor = exports.disabledBackgroundColor = void 0;
|
|
7
7
|
|
|
8
8
|
var _colors = require("@atlaskit/theme/colors");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
// The exports are the functions, not the objects, so could not be used here
|
|
12
|
-
var disabledBackgroundColor = {
|
|
13
|
-
light: _colors.N20,
|
|
14
|
-
dark: _colors.DN20
|
|
15
|
-
}; // For validation red is the new 'yellow' which was { light: Y300, dark: Y300 }
|
|
10
|
+
var _tokens = require("@atlaskit/tokens");
|
|
16
11
|
|
|
12
|
+
var disabledBackgroundColor = {
|
|
13
|
+
light: (0, _tokens.token)('color.background.disabled', _colors.N10),
|
|
14
|
+
dark: (0, _tokens.token)('color.background.disabled', _colors.DN10)
|
|
15
|
+
};
|
|
17
16
|
exports.disabledBackgroundColor = disabledBackgroundColor;
|
|
18
|
-
var invalidBorderColor = {
|
|
19
|
-
light: _colors.R400,
|
|
20
|
-
dark: _colors.R400
|
|
21
|
-
}; // The following do not yet have a darkmode 'map': N20A, N10
|
|
22
|
-
|
|
23
|
-
exports.invalidBorderColor = invalidBorderColor;
|
|
24
17
|
var defaultBackgroundColor = {
|
|
25
|
-
light: _colors.N10,
|
|
26
|
-
dark: _colors.DN10
|
|
18
|
+
light: (0, _tokens.token)('color.background.subtleBorderedNeutral.resting', _colors.N10),
|
|
19
|
+
dark: (0, _tokens.token)('color.background.subtleBorderedNeutral.resting', _colors.DN10)
|
|
27
20
|
};
|
|
28
21
|
exports.defaultBackgroundColor = defaultBackgroundColor;
|
|
29
22
|
var defaultBackgroundColorFocus = {
|
|
30
|
-
light: _colors.N0,
|
|
31
|
-
dark: _colors.DN10
|
|
23
|
+
light: (0, _tokens.token)('color.background.default', _colors.N0),
|
|
24
|
+
dark: (0, _tokens.token)('color.background.default', _colors.DN10)
|
|
32
25
|
};
|
|
33
26
|
exports.defaultBackgroundColorFocus = defaultBackgroundColorFocus;
|
|
34
27
|
var defaultBackgroundColorHover = {
|
|
35
|
-
light: _colors.N30,
|
|
36
|
-
dark: _colors.DN30
|
|
28
|
+
light: (0, _tokens.token)('color.background.default', _colors.N30),
|
|
29
|
+
dark: (0, _tokens.token)('color.background.default', _colors.DN30)
|
|
37
30
|
};
|
|
38
31
|
exports.defaultBackgroundColorHover = defaultBackgroundColorHover;
|
|
32
|
+
var subtleBackgroundColorHover = {
|
|
33
|
+
light: (0, _tokens.token)('color.background.transparentNeutral.hover', _colors.N30),
|
|
34
|
+
dark: (0, _tokens.token)('color.background.transparentNeutral.hover', _colors.DN30)
|
|
35
|
+
};
|
|
36
|
+
exports.subtleBackgroundColorHover = subtleBackgroundColorHover;
|
|
39
37
|
var defaultBorderColor = {
|
|
40
|
-
light: _colors.N40,
|
|
41
|
-
dark: _colors.DN40
|
|
38
|
+
light: (0, _tokens.token)('color.border.neutral', _colors.N40),
|
|
39
|
+
dark: (0, _tokens.token)('color.border.neutral', _colors.DN40)
|
|
42
40
|
};
|
|
43
41
|
exports.defaultBorderColor = defaultBorderColor;
|
|
44
42
|
var defaultBorderColorFocus = {
|
|
45
|
-
light: _colors.B100,
|
|
46
|
-
dark: _colors.B75
|
|
43
|
+
light: (0, _tokens.token)('color.border.focus', _colors.B100),
|
|
44
|
+
dark: (0, _tokens.token)('color.border.focus', _colors.B75)
|
|
47
45
|
};
|
|
48
46
|
exports.defaultBorderColorFocus = defaultBorderColorFocus;
|
|
49
47
|
var transparent = {
|
|
@@ -52,17 +50,17 @@ var transparent = {
|
|
|
52
50
|
};
|
|
53
51
|
exports.transparent = transparent;
|
|
54
52
|
var textColor = {
|
|
55
|
-
light: _colors.N900,
|
|
56
|
-
dark: _colors.DN600
|
|
53
|
+
light: (0, _tokens.token)('color.text.highEmphasis', _colors.N900),
|
|
54
|
+
dark: (0, _tokens.token)('color.text.highEmphasis', _colors.DN600)
|
|
57
55
|
};
|
|
58
56
|
exports.textColor = textColor;
|
|
59
57
|
var disabledTextColor = {
|
|
60
|
-
light: _colors.N70,
|
|
61
|
-
dark: _colors.DN90
|
|
58
|
+
light: (0, _tokens.token)('color.text.disabled', _colors.N70),
|
|
59
|
+
dark: (0, _tokens.token)('color.text.disabled', _colors.DN90)
|
|
62
60
|
};
|
|
63
61
|
exports.disabledTextColor = disabledTextColor;
|
|
64
62
|
var placeholderTextColor = {
|
|
65
|
-
light: _colors.N100,
|
|
66
|
-
dark: _colors.DN90
|
|
63
|
+
light: (0, _tokens.token)('color.text.lowEmphasis', _colors.N100),
|
|
64
|
+
dark: (0, _tokens.token)('color.text.lowEmphasis', _colors.DN90)
|
|
67
65
|
};
|
|
68
66
|
exports.placeholderTextColor = placeholderTextColor;
|
package/dist/cjs/index.js
CHANGED
package/dist/cjs/styles.js
CHANGED
|
@@ -7,12 +7,16 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.
|
|
10
|
+
exports.textFieldColors = exports.inputStyles = exports.containerStyles = void 0;
|
|
11
11
|
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
13
|
|
|
14
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
15
|
+
|
|
14
16
|
var _constants = require("@atlaskit/theme/constants");
|
|
15
17
|
|
|
18
|
+
var _tokens = require("@atlaskit/tokens");
|
|
19
|
+
|
|
16
20
|
var componentTokens = _interopRequireWildcard(require("./component-tokens"));
|
|
17
21
|
|
|
18
22
|
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); }
|
|
@@ -27,37 +31,35 @@ var fontSize = (0, _constants.fontSize)();
|
|
|
27
31
|
var gridSize = (0, _constants.gridSize)();
|
|
28
32
|
var disabledRules = {
|
|
29
33
|
light: {
|
|
30
|
-
backgroundColor: componentTokens.
|
|
31
|
-
backgroundColorFocus: componentTokens.disabledBackgroundColor.light,
|
|
34
|
+
backgroundColor: componentTokens.disabledBackgroundColor.light,
|
|
32
35
|
backgroundColorHover: componentTokens.disabledBackgroundColor.light,
|
|
33
|
-
|
|
34
|
-
borderColor: componentTokens.defaultBackgroundColor.light,
|
|
35
|
-
borderColorFocus: componentTokens.defaultBorderColorFocus.light,
|
|
36
|
+
borderColor: componentTokens.disabledBackgroundColor.light,
|
|
36
37
|
textColor: componentTokens.disabledTextColor.light
|
|
37
38
|
},
|
|
38
39
|
dark: {
|
|
39
|
-
backgroundColor: componentTokens.
|
|
40
|
-
backgroundColorFocus: componentTokens.disabledBackgroundColor.dark,
|
|
40
|
+
backgroundColor: componentTokens.disabledBackgroundColor.dark,
|
|
41
41
|
backgroundColorHover: componentTokens.disabledBackgroundColor.dark,
|
|
42
|
-
|
|
43
|
-
borderColor: componentTokens.defaultBackgroundColor.dark,
|
|
44
|
-
borderColorFocus: componentTokens.defaultBorderColorFocus.dark,
|
|
42
|
+
borderColor: componentTokens.disabledBackgroundColor.dark,
|
|
45
43
|
textColor: componentTokens.disabledTextColor.dark
|
|
46
44
|
}
|
|
47
45
|
};
|
|
48
46
|
var invalidRules = {
|
|
49
47
|
light: {
|
|
48
|
+
// ----
|
|
50
49
|
backgroundColor: componentTokens.defaultBackgroundColor.light,
|
|
51
|
-
backgroundColorFocus: componentTokens.defaultBackgroundColorFocus.light,
|
|
52
50
|
backgroundColorHover: componentTokens.defaultBackgroundColorHover.light,
|
|
53
|
-
|
|
51
|
+
// ^--- the above values aren't used directly they remain because its exposed by the `textFieldColors` export
|
|
52
|
+
backgroundColorFocus: componentTokens.defaultBackgroundColorFocus.light,
|
|
53
|
+
borderColor: (0, _tokens.token)('color.iconBorder.danger', _colors.R400),
|
|
54
54
|
borderColorFocus: componentTokens.defaultBorderColorFocus.light
|
|
55
55
|
},
|
|
56
56
|
dark: {
|
|
57
|
+
// ----
|
|
57
58
|
backgroundColor: componentTokens.defaultBackgroundColor.dark,
|
|
58
|
-
backgroundColorFocus: componentTokens.defaultBackgroundColorFocus.dark,
|
|
59
59
|
backgroundColorHover: componentTokens.defaultBackgroundColorHover.dark,
|
|
60
|
-
|
|
60
|
+
// ^--- the above values aren't used directly they remain because its exposed by the `textFieldColors` export
|
|
61
|
+
backgroundColorFocus: componentTokens.defaultBackgroundColorFocus.dark,
|
|
62
|
+
borderColor: (0, _tokens.token)('color.iconBorder.danger', _colors.R400),
|
|
61
63
|
borderColorFocus: componentTokens.defaultBorderColorFocus.dark
|
|
62
64
|
}
|
|
63
65
|
};
|
|
@@ -73,7 +75,7 @@ var backgroundColorFocus = {
|
|
|
73
75
|
};
|
|
74
76
|
var backgroundColorHover = {
|
|
75
77
|
standard: componentTokens.defaultBackgroundColorHover,
|
|
76
|
-
subtle: componentTokens.
|
|
78
|
+
subtle: componentTokens.subtleBackgroundColorHover,
|
|
77
79
|
none: componentTokens.transparent
|
|
78
80
|
};
|
|
79
81
|
var borderColor = {
|
|
@@ -106,24 +108,13 @@ var getContainerTextBgAndBorderColor = function getContainerTextBgAndBorderColor
|
|
|
106
108
|
color: disabledRules[mode].textColor,
|
|
107
109
|
cursor: 'not-allowed'
|
|
108
110
|
},
|
|
109
|
-
'&[data-disabled]:focus-within': {
|
|
110
|
-
backgroundColor: disabledRules[mode].backgroundColorFocus,
|
|
111
|
-
borderColor: disabledRules[mode].borderColorFocus
|
|
112
|
-
},
|
|
113
|
-
'&[data-disabled]:hover': {
|
|
114
|
-
backgroundColor: disabledRules[mode].backgroundColorHover
|
|
115
|
-
},
|
|
116
111
|
'&[data-invalid]': {
|
|
117
|
-
backgroundColor: invalidRules[mode].backgroundColor,
|
|
118
112
|
borderColor: invalidRules[mode].borderColor
|
|
119
113
|
},
|
|
120
114
|
'&[data-invalid]:focus-within': {
|
|
121
115
|
backgroundColor: invalidRules[mode].backgroundColorFocus,
|
|
122
116
|
borderColor: invalidRules[mode].borderColorFocus
|
|
123
117
|
},
|
|
124
|
-
'&[data-invalid]:hover': {
|
|
125
|
-
backgroundColor: invalidRules[mode].backgroundColorHover
|
|
126
|
-
},
|
|
127
118
|
'@media screen and (-ms-high-contrast: active)': {
|
|
128
119
|
'&[data-invalid]:focus-within': {
|
|
129
120
|
borderColor: 'Highlight'
|
|
@@ -222,10 +213,11 @@ var inputStyles = function inputStyles(mode) {
|
|
|
222
213
|
}
|
|
223
214
|
}
|
|
224
215
|
};
|
|
225
|
-
};
|
|
216
|
+
}; // TODO: Remove when removing legacy theming.
|
|
217
|
+
|
|
226
218
|
|
|
227
219
|
exports.inputStyles = inputStyles;
|
|
228
|
-
var
|
|
220
|
+
var textFieldColors = {
|
|
229
221
|
backgroundColor: backgroundColor,
|
|
230
222
|
backgroundColorFocus: backgroundColorFocus,
|
|
231
223
|
backgroundColorHover: backgroundColorHover,
|
|
@@ -236,4 +228,4 @@ var TextFieldColors = {
|
|
|
236
228
|
invalidRules: invalidRules,
|
|
237
229
|
disabledRules: disabledRules
|
|
238
230
|
};
|
|
239
|
-
exports.
|
|
231
|
+
exports.textFieldColors = textFieldColors;
|
package/dist/cjs/text-field.js
CHANGED
|
@@ -23,7 +23,7 @@ var _core = require("@emotion/core");
|
|
|
23
23
|
|
|
24
24
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
25
25
|
|
|
26
|
-
var _components =
|
|
26
|
+
var _components = require("@atlaskit/theme/components");
|
|
27
27
|
|
|
28
28
|
var _styles = require("./styles");
|
|
29
29
|
|
|
@@ -38,10 +38,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
38
38
|
var analyticsParams = {
|
|
39
39
|
componentName: 'textField',
|
|
40
40
|
packageName: "@atlaskit/textfield",
|
|
41
|
-
packageVersion: "5.
|
|
41
|
+
packageVersion: "5.1.3"
|
|
42
42
|
};
|
|
43
|
-
var
|
|
44
|
-
var input = (0, _react.useRef)(null);
|
|
43
|
+
var Textfield = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
45
44
|
var _props$appearance = props.appearance,
|
|
46
45
|
appearance = _props$appearance === void 0 ? 'standard' : _props$appearance,
|
|
47
46
|
_props$isCompact = props.isCompact,
|
|
@@ -57,7 +56,6 @@ var TextfieldWithMode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref
|
|
|
57
56
|
_props$isMonospaced = props.isMonospaced,
|
|
58
57
|
isMonospaced = _props$isMonospaced === void 0 ? false : _props$isMonospaced,
|
|
59
58
|
width = props.width,
|
|
60
|
-
mode = props.mode,
|
|
61
59
|
elemAfterInput = props.elemAfterInput,
|
|
62
60
|
elemBeforeInput = props.elemBeforeInput,
|
|
63
61
|
testId = props.testId,
|
|
@@ -65,7 +63,12 @@ var TextfieldWithMode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref
|
|
|
65
63
|
onBlur = props.onBlur,
|
|
66
64
|
onMouseDown = props.onMouseDown,
|
|
67
65
|
className = props.className,
|
|
68
|
-
|
|
66
|
+
spreadProps = (0, _objectWithoutProperties2.default)(props, ["appearance", "isCompact", "isDisabled", "isInvalid", "isRequired", "isReadOnly", "isMonospaced", "width", "elemAfterInput", "elemBeforeInput", "testId", "onFocus", "onBlur", "onMouseDown", "className"]);
|
|
67
|
+
var inputRef = (0, _react.useRef)(null);
|
|
68
|
+
|
|
69
|
+
var _useGlobalTheme = (0, _components.useGlobalTheme)(),
|
|
70
|
+
mode = _useGlobalTheme.mode;
|
|
71
|
+
|
|
69
72
|
var handleOnFocus = (0, _analyticsNext.usePlatformLeafEventHandler)(_objectSpread({
|
|
70
73
|
fn: function fn(event) {
|
|
71
74
|
onFocus && onFocus(event);
|
|
@@ -79,7 +82,7 @@ var TextfieldWithMode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref
|
|
|
79
82
|
action: 'blurred'
|
|
80
83
|
}, analyticsParams));
|
|
81
84
|
var handleOnMouseDown = (0, _react.useCallback)(function (event) {
|
|
82
|
-
|
|
85
|
+
// Running e.preventDefault() on the INPUT prevents double click behaviour
|
|
83
86
|
// Sadly we needed this cast as the target type is being correctly set
|
|
84
87
|
var target = event.target;
|
|
85
88
|
|
|
@@ -87,80 +90,80 @@ var TextfieldWithMode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref
|
|
|
87
90
|
event.preventDefault();
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
if (
|
|
91
|
-
|
|
93
|
+
if (inputRef && inputRef.current && !isDisabled && document.activeElement !== inputRef.current) {
|
|
94
|
+
inputRef.current.focus();
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
onMouseDown && onMouseDown(event);
|
|
95
|
-
}, [onMouseDown,
|
|
96
|
-
|
|
98
|
+
}, [onMouseDown, isDisabled]);
|
|
97
99
|
var setInputRef = (0, _react.useCallback)(function (inputElement) {
|
|
98
|
-
|
|
99
|
-
var forwardedRef = ref;
|
|
100
|
+
inputRef.current = inputElement;
|
|
100
101
|
|
|
101
|
-
if (!
|
|
102
|
+
if (!ref) {
|
|
102
103
|
return;
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
if ((0, _typeof2.default)(
|
|
106
|
+
if ((0, _typeof2.default)(ref) === 'object') {
|
|
106
107
|
// This is a blunder on the part of @types/react
|
|
107
108
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31065
|
|
108
109
|
// .current should be assignable
|
|
109
|
-
// @ts-
|
|
110
|
-
|
|
110
|
+
// @ts-expect-error
|
|
111
|
+
ref.current = inputElement;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
if (typeof
|
|
114
|
-
|
|
114
|
+
if (typeof ref === 'function') {
|
|
115
|
+
ref(inputElement);
|
|
115
116
|
}
|
|
116
117
|
}, [ref]);
|
|
117
|
-
var inputControlProps = {
|
|
118
|
-
'data-compact': isCompact ? isCompact : undefined,
|
|
119
|
-
'data-monospaced': isMonospaced ? isMonospaced : undefined,
|
|
120
|
-
'aria-invalid': isInvalid ? isInvalid : undefined
|
|
121
|
-
};
|
|
122
|
-
var containerControlProps = {
|
|
123
|
-
'data-disabled': isDisabled ? isDisabled : undefined,
|
|
124
|
-
'data-invalid': isInvalid ? isInvalid : undefined
|
|
125
|
-
};
|
|
126
118
|
var containerStyles = (0, _react.useMemo)(function () {
|
|
127
119
|
return (0, _styles.containerStyles)(appearance, mode, width);
|
|
128
120
|
}, [appearance, mode, width]);
|
|
129
121
|
var inputStyle = (0, _react.useMemo)(function () {
|
|
130
122
|
return (0, _styles.inputStyles)(mode);
|
|
131
123
|
}, [mode]);
|
|
132
|
-
return (//
|
|
124
|
+
return (// We use event bubbling here to listen to any child element mouse down event.
|
|
133
125
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
134
|
-
(0, _core.jsx)("div",
|
|
135
|
-
|
|
126
|
+
(0, _core.jsx)("div", {
|
|
127
|
+
"data-disabled": isDisabled ? isDisabled : undefined,
|
|
128
|
+
"data-invalid": isInvalid ? isInvalid : undefined,
|
|
136
129
|
"data-ds--text-field--container": true,
|
|
137
130
|
"data-testid": testId && "".concat(testId, "-container"),
|
|
131
|
+
onMouseDown: handleOnMouseDown // TODO: When removing legacy theming fix this.
|
|
132
|
+
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
133
|
+
,
|
|
138
134
|
css: containerStyles,
|
|
139
135
|
className: className
|
|
140
|
-
}
|
|
136
|
+
}, elemBeforeInput, (0, _core.jsx)("input", (0, _extends2.default)({}, spreadProps, {
|
|
137
|
+
"data-compact": isCompact ? isCompact : undefined,
|
|
138
|
+
"data-monospaced": isMonospaced ? isMonospaced : undefined,
|
|
139
|
+
"data-ds--text-field--input": true,
|
|
140
|
+
"data-testid": testId,
|
|
141
|
+
"aria-invalid": isInvalid ? isInvalid : undefined,
|
|
141
142
|
disabled: isDisabled,
|
|
142
143
|
readOnly: isReadOnly,
|
|
143
144
|
required: isRequired,
|
|
144
145
|
onBlur: handleOnBlur,
|
|
145
146
|
onFocus: handleOnFocus,
|
|
146
|
-
ref: setInputRef
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
ref: setInputRef // TODO: When removing legacy theming fix this.
|
|
148
|
+
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
149
|
+
,
|
|
149
150
|
css: inputStyle
|
|
150
151
|
})), elemAfterInput)
|
|
151
152
|
);
|
|
152
153
|
});
|
|
153
|
-
var Textfield = /*#__PURE__*/(0, _react.forwardRef)(function Textfield(props, ref) {
|
|
154
|
-
return (0, _core.jsx)(_components.default.Consumer, null, function (_ref) {
|
|
155
|
-
var mode = _ref.mode;
|
|
156
|
-
return (0, _core.jsx)(TextfieldWithMode, (0, _extends2.default)({}, props, {
|
|
157
|
-
mode: mode,
|
|
158
|
-
ref: ref
|
|
159
|
-
}));
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
154
|
Textfield.displayName = 'Textfield';
|
|
155
|
+
/**
|
|
156
|
+
* __Textfield__
|
|
157
|
+
*
|
|
158
|
+
* A text field is an input that allows a user to write or edit text.
|
|
159
|
+
*
|
|
160
|
+
* - [Examples](https://atlassian.design/components/textfield/examples)
|
|
161
|
+
* - [Code](https://atlassian.design/components/textfield/code)
|
|
162
|
+
* - [Usage](https://atlassian.design/components/textfield/usage)
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
var _default = /*#__PURE__*/(0, _react.memo)(Textfield); // The above generic is used to let ERTC know what props to extract.
|
|
166
|
+
// See: https://github.com/atlassian/extract-react-types/issues/201
|
|
163
167
|
|
|
164
|
-
var _default = /*#__PURE__*/(0, _react.memo)(Textfield);
|
|
165
168
|
|
|
166
169
|
exports.default = _default;
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,49 +1,46 @@
|
|
|
1
|
-
import { B100, B75, DN10,
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { B100, B75, DN10, DN30, DN40, DN600, DN90, N0, N10, N100, N30, N40, N70, N900 } from '@atlaskit/theme/colors';
|
|
2
|
+
import { token } from '@atlaskit/tokens';
|
|
4
3
|
export const disabledBackgroundColor = {
|
|
5
|
-
light:
|
|
6
|
-
dark:
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const invalidBorderColor = {
|
|
10
|
-
light: R400,
|
|
11
|
-
dark: R400
|
|
12
|
-
}; // The following do not yet have a darkmode 'map': N20A, N10
|
|
13
|
-
|
|
4
|
+
light: token('color.background.disabled', N10),
|
|
5
|
+
dark: token('color.background.disabled', DN10)
|
|
6
|
+
};
|
|
14
7
|
export const defaultBackgroundColor = {
|
|
15
|
-
light: N10,
|
|
16
|
-
dark: DN10
|
|
8
|
+
light: token('color.background.subtleBorderedNeutral.resting', N10),
|
|
9
|
+
dark: token('color.background.subtleBorderedNeutral.resting', DN10)
|
|
17
10
|
};
|
|
18
11
|
export const defaultBackgroundColorFocus = {
|
|
19
|
-
light: N0,
|
|
20
|
-
dark: DN10
|
|
12
|
+
light: token('color.background.default', N0),
|
|
13
|
+
dark: token('color.background.default', DN10)
|
|
21
14
|
};
|
|
22
15
|
export const defaultBackgroundColorHover = {
|
|
23
|
-
light: N30,
|
|
24
|
-
dark: DN30
|
|
16
|
+
light: token('color.background.default', N30),
|
|
17
|
+
dark: token('color.background.default', DN30)
|
|
18
|
+
};
|
|
19
|
+
export const subtleBackgroundColorHover = {
|
|
20
|
+
light: token('color.background.transparentNeutral.hover', N30),
|
|
21
|
+
dark: token('color.background.transparentNeutral.hover', DN30)
|
|
25
22
|
};
|
|
26
23
|
export const defaultBorderColor = {
|
|
27
|
-
light: N40,
|
|
28
|
-
dark: DN40
|
|
24
|
+
light: token('color.border.neutral', N40),
|
|
25
|
+
dark: token('color.border.neutral', DN40)
|
|
29
26
|
};
|
|
30
27
|
export const defaultBorderColorFocus = {
|
|
31
|
-
light: B100,
|
|
32
|
-
dark: B75
|
|
28
|
+
light: token('color.border.focus', B100),
|
|
29
|
+
dark: token('color.border.focus', B75)
|
|
33
30
|
};
|
|
34
31
|
export const transparent = {
|
|
35
32
|
light: 'transparent',
|
|
36
33
|
dark: 'transparent'
|
|
37
34
|
};
|
|
38
35
|
export const textColor = {
|
|
39
|
-
light: N900,
|
|
40
|
-
dark: DN600
|
|
36
|
+
light: token('color.text.highEmphasis', N900),
|
|
37
|
+
dark: token('color.text.highEmphasis', DN600)
|
|
41
38
|
};
|
|
42
39
|
export const disabledTextColor = {
|
|
43
|
-
light: N70,
|
|
44
|
-
dark: DN90
|
|
40
|
+
light: token('color.text.disabled', N70),
|
|
41
|
+
dark: token('color.text.disabled', DN90)
|
|
45
42
|
};
|
|
46
43
|
export const placeholderTextColor = {
|
|
47
|
-
light: N100,
|
|
48
|
-
dark: DN90
|
|
44
|
+
light: token('color.text.lowEmphasis', N100),
|
|
45
|
+
dark: token('color.text.lowEmphasis', DN90)
|
|
49
46
|
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from './text-field';
|
|
2
|
-
export { TextFieldColors } from './styles';
|
|
2
|
+
export { textFieldColors as TextFieldColors } from './styles';
|