@atlaskit/textfield 5.1.2

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 (38) hide show
  1. package/CHANGELOG.md +673 -0
  2. package/LICENSE +13 -0
  3. package/README.md +13 -0
  4. package/__perf__/default.tsx +5 -0
  5. package/__perf__/examples.tsx +58 -0
  6. package/codemods/5.0.0-lite-mode.tsx +16 -0
  7. package/codemods/__tests__/5.0.0-lite-mode.tsx +87 -0
  8. package/codemods/__tests__/remove-imports.tsx +64 -0
  9. package/codemods/__tests__/remove-prop.tsx +142 -0
  10. package/codemods/__tests__/rename-imports.tsx +85 -0
  11. package/codemods/migrations/remove-imports.tsx +8 -0
  12. package/codemods/migrations/remove-props.tsx +10 -0
  13. package/codemods/migrations/rename-imports.tsx +15 -0
  14. package/codemods/migrations/utils.tsx +375 -0
  15. package/dist/cjs/component-tokens.js +66 -0
  16. package/dist/cjs/index.js +23 -0
  17. package/dist/cjs/styles.js +231 -0
  18. package/dist/cjs/text-field.js +169 -0
  19. package/dist/cjs/types.js +5 -0
  20. package/dist/cjs/version.json +5 -0
  21. package/dist/es2019/component-tokens.js +46 -0
  22. package/dist/es2019/index.js +2 -0
  23. package/dist/es2019/styles.js +192 -0
  24. package/dist/es2019/text-field.js +129 -0
  25. package/dist/es2019/types.js +1 -0
  26. package/dist/es2019/version.json +5 -0
  27. package/dist/esm/component-tokens.js +46 -0
  28. package/dist/esm/index.js +2 -0
  29. package/dist/esm/styles.js +206 -0
  30. package/dist/esm/text-field.js +145 -0
  31. package/dist/esm/types.js +1 -0
  32. package/dist/esm/version.json +5 -0
  33. package/dist/types/component-tokens.d.ts +44 -0
  34. package/dist/types/index.d.ts +3 -0
  35. package/dist/types/styles.d.ts +208 -0
  36. package/dist/types/text-field.d.ts +14 -0
  37. package/dist/types/types.d.ts +71 -0
  38. package/package.json +79 -0
@@ -0,0 +1,2 @@
1
+ export { default } from './text-field';
2
+ export { textFieldColors as TextFieldColors } from './styles';
@@ -0,0 +1,192 @@
1
+ import { R400 } from '@atlaskit/theme/colors';
2
+ import { codeFontFamily, fontFamily, fontSize as getFontSize, gridSize as getGridSize } from '@atlaskit/theme/constants';
3
+ import { token } from '@atlaskit/tokens';
4
+ import * as componentTokens from './component-tokens';
5
+ const fontSize = getFontSize();
6
+ const gridSize = getGridSize();
7
+ const disabledRules = {
8
+ light: {
9
+ backgroundColor: componentTokens.disabledBackgroundColor.light,
10
+ backgroundColorHover: componentTokens.disabledBackgroundColor.light,
11
+ borderColor: componentTokens.disabledBackgroundColor.light,
12
+ textColor: componentTokens.disabledTextColor.light
13
+ },
14
+ dark: {
15
+ backgroundColor: componentTokens.disabledBackgroundColor.dark,
16
+ backgroundColorHover: componentTokens.disabledBackgroundColor.dark,
17
+ borderColor: componentTokens.disabledBackgroundColor.dark,
18
+ textColor: componentTokens.disabledTextColor.dark
19
+ }
20
+ };
21
+ const invalidRules = {
22
+ light: {
23
+ // ----
24
+ backgroundColor: componentTokens.defaultBackgroundColor.light,
25
+ backgroundColorHover: componentTokens.defaultBackgroundColorHover.light,
26
+ // ^--- the above values aren't used directly they remain because its exposed by the `textFieldColors` export
27
+ backgroundColorFocus: componentTokens.defaultBackgroundColorFocus.light,
28
+ borderColor: token('color.iconBorder.danger', R400),
29
+ borderColorFocus: componentTokens.defaultBorderColorFocus.light
30
+ },
31
+ dark: {
32
+ // ----
33
+ backgroundColor: componentTokens.defaultBackgroundColor.dark,
34
+ backgroundColorHover: componentTokens.defaultBackgroundColorHover.dark,
35
+ // ^--- the above values aren't used directly they remain because its exposed by the `textFieldColors` export
36
+ backgroundColorFocus: componentTokens.defaultBackgroundColorFocus.dark,
37
+ borderColor: token('color.iconBorder.danger', R400),
38
+ borderColorFocus: componentTokens.defaultBorderColorFocus.dark
39
+ }
40
+ };
41
+ const backgroundColor = {
42
+ standard: componentTokens.defaultBackgroundColor,
43
+ subtle: componentTokens.transparent,
44
+ none: componentTokens.transparent
45
+ };
46
+ const backgroundColorFocus = {
47
+ standard: componentTokens.defaultBackgroundColorFocus,
48
+ subtle: componentTokens.defaultBackgroundColorFocus,
49
+ none: componentTokens.transparent
50
+ };
51
+ const backgroundColorHover = {
52
+ standard: componentTokens.defaultBackgroundColorHover,
53
+ subtle: componentTokens.subtleBackgroundColorHover,
54
+ none: componentTokens.transparent
55
+ };
56
+ const borderColor = {
57
+ standard: componentTokens.defaultBorderColor,
58
+ subtle: componentTokens.transparent,
59
+ none: componentTokens.transparent
60
+ };
61
+ const borderColorFocus = {
62
+ standard: componentTokens.defaultBorderColorFocus,
63
+ subtle: componentTokens.defaultBorderColorFocus,
64
+ none: componentTokens.transparent
65
+ };
66
+
67
+ const getContainerTextBgAndBorderColor = (appearance, mode) => ({
68
+ backgroundColor: backgroundColor[appearance][mode],
69
+ borderColor: borderColor[appearance][mode],
70
+ color: componentTokens.textColor[mode],
71
+ cursor: 'text',
72
+ '&:hover': {
73
+ backgroundColor: backgroundColorHover[appearance][mode]
74
+ },
75
+ '&:focus-within': {
76
+ backgroundColor: backgroundColorFocus[appearance][mode],
77
+ borderColor: borderColorFocus[appearance][mode]
78
+ },
79
+ '&[data-disabled]': {
80
+ backgroundColor: disabledRules[mode].backgroundColor,
81
+ borderColor: disabledRules[mode].borderColor,
82
+ color: disabledRules[mode].textColor,
83
+ cursor: 'not-allowed'
84
+ },
85
+ '&[data-invalid]': {
86
+ borderColor: invalidRules[mode].borderColor
87
+ },
88
+ '&[data-invalid]:focus-within': {
89
+ backgroundColor: invalidRules[mode].backgroundColorFocus,
90
+ borderColor: invalidRules[mode].borderColorFocus
91
+ },
92
+ '@media screen and (-ms-high-contrast: active)': {
93
+ '&[data-invalid]:focus-within': {
94
+ borderColor: 'Highlight'
95
+ },
96
+ '&:focus-within': {
97
+ borderColor: 'Highlight'
98
+ },
99
+ '&[data-disabled]': {
100
+ borderColor: 'GrayText'
101
+ }
102
+ }
103
+ });
104
+
105
+ const widthMap = {
106
+ xsmall: 80,
107
+ small: 160,
108
+ medium: 240,
109
+ large: 320,
110
+ xlarge: 480
111
+ };
112
+
113
+ const getMaxWidth = width => !width ? `100%` : width in widthMap ? widthMap[width] : +width;
114
+
115
+ export const containerStyles = (appearance, mode, width) => ({
116
+ alignItems: 'center',
117
+ ...getContainerTextBgAndBorderColor(appearance, mode),
118
+ borderRadius: 3,
119
+ borderWidth: 2,
120
+ borderStyle: appearance === 'none' ? 'none' : 'solid',
121
+ boxSizing: 'border-box',
122
+ display: 'flex',
123
+ flex: '1 1 100%',
124
+ fontSize,
125
+ justifyContent: 'space-between',
126
+ maxWidth: getMaxWidth(width),
127
+ overflow: 'hidden',
128
+ transition: `background-color 0.2s ease-in-out, border-color 0.2s ease-in-out`,
129
+ wordWrap: 'break-word',
130
+ verticalAlign: 'top',
131
+ pointerEvents: 'auto'
132
+ });
133
+ export const inputStyles = mode => ({
134
+ backgroundColor: 'transparent',
135
+ border: 0,
136
+ boxSizing: 'border-box',
137
+ color: 'inherit',
138
+ cursor: 'inherit',
139
+ fontSize,
140
+ minWidth: '0',
141
+ outline: 'none',
142
+ width: '100%',
143
+ lineHeight: gridSize * 2.5 / fontSize,
144
+ fontFamily: fontFamily(),
145
+ '&[data-monospaced]': {
146
+ fontFamily: codeFontFamily()
147
+ },
148
+ '&[data-compact]': {
149
+ padding: `${gridSize / 2}px ${gridSize - 2}px`,
150
+ height: `${(gridSize * 3.5 / fontSize).toFixed(2)}em`
151
+ },
152
+ '&:not([data-compact])': {
153
+ padding: `${gridSize}px ${gridSize - 2}px`,
154
+ height: `${(gridSize * 4.5 / fontSize).toFixed(2)}em`
155
+ },
156
+ '&[disabled]': {
157
+ // Safari (WebKit) adds a -webkit-text-fill-color style to disabled inputs
158
+ // which takes priority over color and makes the text unreadable. Need to
159
+ // override it with the color we want.
160
+ WebkitTextFillColor: disabledRules[mode].textColor
161
+ },
162
+ // Hide the clear indicator on Edge (Windows only)
163
+ '&::-ms-clear': {
164
+ display: 'none'
165
+ },
166
+ '&:invalid': {
167
+ boxShadow: 'none'
168
+ },
169
+ '&::placeholder': {
170
+ color: componentTokens.placeholderTextColor[mode],
171
+ '&:disabled': {
172
+ color: disabledRules[mode].textColor
173
+ }
174
+ },
175
+ '@media screen and (-ms-high-contrast: active)': {
176
+ '&[disabled]': {
177
+ color: 'GrayText'
178
+ }
179
+ }
180
+ }); // TODO: Remove when removing legacy theming.
181
+
182
+ export const textFieldColors = {
183
+ backgroundColor,
184
+ backgroundColorFocus,
185
+ backgroundColorHover,
186
+ borderColor,
187
+ borderColorFocus,
188
+ placeholderTextColor: componentTokens.placeholderTextColor,
189
+ textColor: componentTokens.textColor,
190
+ invalidRules,
191
+ disabledRules
192
+ };
@@ -0,0 +1,129 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+
3
+ /** @jsx jsx */
4
+ import React, { forwardRef, memo, useCallback, useMemo, useRef } from 'react';
5
+ import { jsx } from '@emotion/core';
6
+ import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
7
+ import { useGlobalTheme } from '@atlaskit/theme/components';
8
+ import { containerStyles as getContainerStyles, inputStyles as getInputStyles } from './styles';
9
+ const analyticsParams = {
10
+ componentName: 'textField',
11
+ packageName: "@atlaskit/textfield",
12
+ packageVersion: "5.1.2"
13
+ };
14
+ const Textfield = /*#__PURE__*/forwardRef((props, ref) => {
15
+ const {
16
+ appearance = 'standard',
17
+ isCompact = false,
18
+ isDisabled = false,
19
+ isInvalid = false,
20
+ isRequired = false,
21
+ isReadOnly = false,
22
+ isMonospaced = false,
23
+ width,
24
+ elemAfterInput,
25
+ elemBeforeInput,
26
+ testId,
27
+ onFocus,
28
+ onBlur,
29
+ onMouseDown,
30
+ className,
31
+ ...spreadProps
32
+ } = props;
33
+ const inputRef = useRef(null);
34
+ const {
35
+ mode
36
+ } = useGlobalTheme();
37
+ const handleOnFocus = usePlatformLeafEventHandler({
38
+ fn: event => {
39
+ onFocus && onFocus(event);
40
+ },
41
+ action: 'focused',
42
+ ...analyticsParams
43
+ });
44
+ const handleOnBlur = usePlatformLeafEventHandler({
45
+ fn: event => {
46
+ onBlur && onBlur(event);
47
+ },
48
+ action: 'blurred',
49
+ ...analyticsParams
50
+ });
51
+ const handleOnMouseDown = useCallback(event => {
52
+ // Running e.preventDefault() on the INPUT prevents double click behaviour
53
+ // Sadly we needed this cast as the target type is being correctly set
54
+ const target = event.target;
55
+
56
+ if (target.tagName !== 'INPUT') {
57
+ event.preventDefault();
58
+ }
59
+
60
+ if (inputRef && inputRef.current && !isDisabled && document.activeElement !== inputRef.current) {
61
+ inputRef.current.focus();
62
+ }
63
+
64
+ onMouseDown && onMouseDown(event);
65
+ }, [onMouseDown, isDisabled]);
66
+ const setInputRef = useCallback(inputElement => {
67
+ inputRef.current = inputElement;
68
+
69
+ if (!ref) {
70
+ return;
71
+ }
72
+
73
+ if (typeof ref === 'object') {
74
+ // This is a blunder on the part of @types/react
75
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31065
76
+ // .current should be assignable
77
+ // @ts-expect-error
78
+ ref.current = inputElement;
79
+ }
80
+
81
+ if (typeof ref === 'function') {
82
+ ref(inputElement);
83
+ }
84
+ }, [ref]);
85
+ const containerStyles = useMemo(() => getContainerStyles(appearance, mode, width), [appearance, mode, width]);
86
+ const inputStyle = useMemo(() => getInputStyles(mode), [mode]);
87
+ return (// We use event bubbling here to listen to any child element mouse down event.
88
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
89
+ jsx("div", {
90
+ "data-disabled": isDisabled ? isDisabled : undefined,
91
+ "data-invalid": isInvalid ? isInvalid : undefined,
92
+ "data-ds--text-field--container": true,
93
+ "data-testid": testId && `${testId}-container`,
94
+ onMouseDown: handleOnMouseDown // TODO: When removing legacy theming fix this.
95
+ // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
96
+ ,
97
+ css: containerStyles,
98
+ className: className
99
+ }, elemBeforeInput, jsx("input", _extends({}, spreadProps, {
100
+ "data-compact": isCompact ? isCompact : undefined,
101
+ "data-monospaced": isMonospaced ? isMonospaced : undefined,
102
+ "data-ds--text-field--input": true,
103
+ "data-testid": testId,
104
+ "aria-invalid": isInvalid ? isInvalid : undefined,
105
+ disabled: isDisabled,
106
+ readOnly: isReadOnly,
107
+ required: isRequired,
108
+ onBlur: handleOnBlur,
109
+ onFocus: handleOnFocus,
110
+ ref: setInputRef // TODO: When removing legacy theming fix this.
111
+ // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
112
+ ,
113
+ css: inputStyle
114
+ })), elemAfterInput)
115
+ );
116
+ });
117
+ Textfield.displayName = 'Textfield';
118
+ /**
119
+ * __Textfield__
120
+ *
121
+ * A text field is an input that allows a user to write or edit text.
122
+ *
123
+ * - [Examples](https://atlassian.design/components/textfield/examples)
124
+ * - [Code](https://atlassian.design/components/textfield/code)
125
+ * - [Usage](https://atlassian.design/components/textfield/usage)
126
+ */
127
+
128
+ export default /*#__PURE__*/memo(Textfield); // The above generic is used to let ERTC know what props to extract.
129
+ // See: https://github.com/atlassian/extract-react-types/issues/201
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/textfield",
3
+ "version": "5.1.2",
4
+ "sideEffects": false
5
+ }
@@ -0,0 +1,46 @@
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';
3
+ export var disabledBackgroundColor = {
4
+ light: token('color.background.disabled', N10),
5
+ dark: token('color.background.disabled', DN10)
6
+ };
7
+ export var defaultBackgroundColor = {
8
+ light: token('color.background.subtleBorderedNeutral.resting', N10),
9
+ dark: token('color.background.subtleBorderedNeutral.resting', DN10)
10
+ };
11
+ export var defaultBackgroundColorFocus = {
12
+ light: token('color.background.default', N0),
13
+ dark: token('color.background.default', DN10)
14
+ };
15
+ export var defaultBackgroundColorHover = {
16
+ light: token('color.background.default', N30),
17
+ dark: token('color.background.default', DN30)
18
+ };
19
+ export var subtleBackgroundColorHover = {
20
+ light: token('color.background.transparentNeutral.hover', N30),
21
+ dark: token('color.background.transparentNeutral.hover', DN30)
22
+ };
23
+ export var defaultBorderColor = {
24
+ light: token('color.border.neutral', N40),
25
+ dark: token('color.border.neutral', DN40)
26
+ };
27
+ export var defaultBorderColorFocus = {
28
+ light: token('color.border.focus', B100),
29
+ dark: token('color.border.focus', B75)
30
+ };
31
+ export var transparent = {
32
+ light: 'transparent',
33
+ dark: 'transparent'
34
+ };
35
+ export var textColor = {
36
+ light: token('color.text.highEmphasis', N900),
37
+ dark: token('color.text.highEmphasis', DN600)
38
+ };
39
+ export var disabledTextColor = {
40
+ light: token('color.text.disabled', N70),
41
+ dark: token('color.text.disabled', DN90)
42
+ };
43
+ export var placeholderTextColor = {
44
+ light: token('color.text.lowEmphasis', N100),
45
+ dark: token('color.text.lowEmphasis', DN90)
46
+ };
@@ -0,0 +1,2 @@
1
+ export { default } from './text-field';
2
+ export { textFieldColors as TextFieldColors } from './styles';
@@ -0,0 +1,206 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+
7
+ import { R400 } from '@atlaskit/theme/colors';
8
+ import { codeFontFamily, fontFamily, fontSize as getFontSize, gridSize as getGridSize } from '@atlaskit/theme/constants';
9
+ import { token } from '@atlaskit/tokens';
10
+ import * as componentTokens from './component-tokens';
11
+ var fontSize = getFontSize();
12
+ var gridSize = getGridSize();
13
+ var disabledRules = {
14
+ light: {
15
+ backgroundColor: componentTokens.disabledBackgroundColor.light,
16
+ backgroundColorHover: componentTokens.disabledBackgroundColor.light,
17
+ borderColor: componentTokens.disabledBackgroundColor.light,
18
+ textColor: componentTokens.disabledTextColor.light
19
+ },
20
+ dark: {
21
+ backgroundColor: componentTokens.disabledBackgroundColor.dark,
22
+ backgroundColorHover: componentTokens.disabledBackgroundColor.dark,
23
+ borderColor: componentTokens.disabledBackgroundColor.dark,
24
+ textColor: componentTokens.disabledTextColor.dark
25
+ }
26
+ };
27
+ var invalidRules = {
28
+ light: {
29
+ // ----
30
+ backgroundColor: componentTokens.defaultBackgroundColor.light,
31
+ backgroundColorHover: componentTokens.defaultBackgroundColorHover.light,
32
+ // ^--- the above values aren't used directly they remain because its exposed by the `textFieldColors` export
33
+ backgroundColorFocus: componentTokens.defaultBackgroundColorFocus.light,
34
+ borderColor: token('color.iconBorder.danger', R400),
35
+ borderColorFocus: componentTokens.defaultBorderColorFocus.light
36
+ },
37
+ dark: {
38
+ // ----
39
+ backgroundColor: componentTokens.defaultBackgroundColor.dark,
40
+ backgroundColorHover: componentTokens.defaultBackgroundColorHover.dark,
41
+ // ^--- the above values aren't used directly they remain because its exposed by the `textFieldColors` export
42
+ backgroundColorFocus: componentTokens.defaultBackgroundColorFocus.dark,
43
+ borderColor: token('color.iconBorder.danger', R400),
44
+ borderColorFocus: componentTokens.defaultBorderColorFocus.dark
45
+ }
46
+ };
47
+ var backgroundColor = {
48
+ standard: componentTokens.defaultBackgroundColor,
49
+ subtle: componentTokens.transparent,
50
+ none: componentTokens.transparent
51
+ };
52
+ var backgroundColorFocus = {
53
+ standard: componentTokens.defaultBackgroundColorFocus,
54
+ subtle: componentTokens.defaultBackgroundColorFocus,
55
+ none: componentTokens.transparent
56
+ };
57
+ var backgroundColorHover = {
58
+ standard: componentTokens.defaultBackgroundColorHover,
59
+ subtle: componentTokens.subtleBackgroundColorHover,
60
+ none: componentTokens.transparent
61
+ };
62
+ var borderColor = {
63
+ standard: componentTokens.defaultBorderColor,
64
+ subtle: componentTokens.transparent,
65
+ none: componentTokens.transparent
66
+ };
67
+ var borderColorFocus = {
68
+ standard: componentTokens.defaultBorderColorFocus,
69
+ subtle: componentTokens.defaultBorderColorFocus,
70
+ none: componentTokens.transparent
71
+ };
72
+
73
+ var getContainerTextBgAndBorderColor = function getContainerTextBgAndBorderColor(appearance, mode) {
74
+ return {
75
+ backgroundColor: backgroundColor[appearance][mode],
76
+ borderColor: borderColor[appearance][mode],
77
+ color: componentTokens.textColor[mode],
78
+ cursor: 'text',
79
+ '&:hover': {
80
+ backgroundColor: backgroundColorHover[appearance][mode]
81
+ },
82
+ '&:focus-within': {
83
+ backgroundColor: backgroundColorFocus[appearance][mode],
84
+ borderColor: borderColorFocus[appearance][mode]
85
+ },
86
+ '&[data-disabled]': {
87
+ backgroundColor: disabledRules[mode].backgroundColor,
88
+ borderColor: disabledRules[mode].borderColor,
89
+ color: disabledRules[mode].textColor,
90
+ cursor: 'not-allowed'
91
+ },
92
+ '&[data-invalid]': {
93
+ borderColor: invalidRules[mode].borderColor
94
+ },
95
+ '&[data-invalid]:focus-within': {
96
+ backgroundColor: invalidRules[mode].backgroundColorFocus,
97
+ borderColor: invalidRules[mode].borderColorFocus
98
+ },
99
+ '@media screen and (-ms-high-contrast: active)': {
100
+ '&[data-invalid]:focus-within': {
101
+ borderColor: 'Highlight'
102
+ },
103
+ '&:focus-within': {
104
+ borderColor: 'Highlight'
105
+ },
106
+ '&[data-disabled]': {
107
+ borderColor: 'GrayText'
108
+ }
109
+ }
110
+ };
111
+ };
112
+
113
+ var widthMap = {
114
+ xsmall: 80,
115
+ small: 160,
116
+ medium: 240,
117
+ large: 320,
118
+ xlarge: 480
119
+ };
120
+
121
+ var getMaxWidth = function getMaxWidth(width) {
122
+ return !width ? "100%" : width in widthMap ? widthMap[width] : +width;
123
+ };
124
+
125
+ export var containerStyles = function containerStyles(appearance, mode, width) {
126
+ return _objectSpread(_objectSpread({
127
+ alignItems: 'center'
128
+ }, getContainerTextBgAndBorderColor(appearance, mode)), {}, {
129
+ borderRadius: 3,
130
+ borderWidth: 2,
131
+ borderStyle: appearance === 'none' ? 'none' : 'solid',
132
+ boxSizing: 'border-box',
133
+ display: 'flex',
134
+ flex: '1 1 100%',
135
+ fontSize: fontSize,
136
+ justifyContent: 'space-between',
137
+ maxWidth: getMaxWidth(width),
138
+ overflow: 'hidden',
139
+ transition: "background-color 0.2s ease-in-out, border-color 0.2s ease-in-out",
140
+ wordWrap: 'break-word',
141
+ verticalAlign: 'top',
142
+ pointerEvents: 'auto'
143
+ });
144
+ };
145
+ export var inputStyles = function inputStyles(mode) {
146
+ return {
147
+ backgroundColor: 'transparent',
148
+ border: 0,
149
+ boxSizing: 'border-box',
150
+ color: 'inherit',
151
+ cursor: 'inherit',
152
+ fontSize: fontSize,
153
+ minWidth: '0',
154
+ outline: 'none',
155
+ width: '100%',
156
+ lineHeight: gridSize * 2.5 / fontSize,
157
+ fontFamily: fontFamily(),
158
+ '&[data-monospaced]': {
159
+ fontFamily: codeFontFamily()
160
+ },
161
+ '&[data-compact]': {
162
+ padding: "".concat(gridSize / 2, "px ").concat(gridSize - 2, "px"),
163
+ height: "".concat((gridSize * 3.5 / fontSize).toFixed(2), "em")
164
+ },
165
+ '&:not([data-compact])': {
166
+ padding: "".concat(gridSize, "px ").concat(gridSize - 2, "px"),
167
+ height: "".concat((gridSize * 4.5 / fontSize).toFixed(2), "em")
168
+ },
169
+ '&[disabled]': {
170
+ // Safari (WebKit) adds a -webkit-text-fill-color style to disabled inputs
171
+ // which takes priority over color and makes the text unreadable. Need to
172
+ // override it with the color we want.
173
+ WebkitTextFillColor: disabledRules[mode].textColor
174
+ },
175
+ // Hide the clear indicator on Edge (Windows only)
176
+ '&::-ms-clear': {
177
+ display: 'none'
178
+ },
179
+ '&:invalid': {
180
+ boxShadow: 'none'
181
+ },
182
+ '&::placeholder': {
183
+ color: componentTokens.placeholderTextColor[mode],
184
+ '&:disabled': {
185
+ color: disabledRules[mode].textColor
186
+ }
187
+ },
188
+ '@media screen and (-ms-high-contrast: active)': {
189
+ '&[disabled]': {
190
+ color: 'GrayText'
191
+ }
192
+ }
193
+ };
194
+ }; // TODO: Remove when removing legacy theming.
195
+
196
+ export var textFieldColors = {
197
+ backgroundColor: backgroundColor,
198
+ backgroundColorFocus: backgroundColorFocus,
199
+ backgroundColorHover: backgroundColorHover,
200
+ borderColor: borderColor,
201
+ borderColorFocus: borderColorFocus,
202
+ placeholderTextColor: componentTokens.placeholderTextColor,
203
+ textColor: componentTokens.textColor,
204
+ invalidRules: invalidRules,
205
+ disabledRules: disabledRules
206
+ };