@atlaskit/textfield 6.8.2 → 7.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.
@@ -1,25 +1,71 @@
1
+ /* text-field.tsx generated by @compiled/babel-plugin v0.36.1 */
1
2
  import _extends from "@babel/runtime/helpers/extends";
2
3
  import _typeof from "@babel/runtime/helpers/typeof";
3
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
5
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
6
  var _excluded = ["appearance", "className", "elemAfterInput", "elemBeforeInput", "isCompact", "isDisabled", "isInvalid", "isMonospaced", "isReadOnly", "isRequired", "name", "onBlur", "onChange", "onFocus", "onMouseDown", "placeholder", "testId", "width"];
7
+ import "./text-field.compiled.css";
8
+ import { ax, ix } from "@compiled/react/runtime";
6
9
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
10
  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; }
8
- /**
9
- * @jsxRuntime classic
10
- * @jsx jsx
11
- */
12
- import React, { forwardRef, useCallback, useMemo, useRef } from 'react';
13
-
14
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
15
- import { jsx } from '@emotion/react';
11
+ import React, { forwardRef, useCallback, useRef } from 'react';
16
12
  import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
17
- import { containerStyles as getContainerStyles, inputStyles as getInputStyles } from './styles';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
14
+ var containerMedia = {
15
+ invalid: "_srjtgir2",
16
+ disabled: "_6up518qt"
17
+ };
18
+ var inputMediaDisabled = null;
18
19
  var analyticsParams = {
19
20
  componentName: 'textField',
20
21
  packageName: "@atlaskit/textfield",
21
- packageVersion: "6.8.2"
22
+ packageVersion: "7.0.0"
23
+ };
24
+ var disabledStyle = {
25
+ standard: "_1h6dsyzs _bfhksyzs _syaz1lh4 _80om13gf",
26
+ subtle: "_1h6d1j28 _bfhk1j28 _syaz1lh4 _80om13gf",
27
+ none: "_1h6d1j28 _bfhk1j28 _syaz1lh4 _80om13gf"
28
+ };
29
+ var invalidStyle = null;
30
+ var focusWithinStyle = {
31
+ standard: "_ochr1p6i _195er01l _bqhtq049",
32
+ subtle: "_ochr1p6i _195er01l _bqhtq049",
33
+ none: "_ochr1j28 _195e1j28 _bqht3sij"
34
+ };
35
+ var hoverStyle = {
36
+ standard: "_4cvx1elr _irr31d5g",
37
+ subtle: "_4cvx1elr _irr31d5g",
38
+ none: "_4cvx1j28 _irr31j28"
22
39
  };
40
+ var getContainerTextBgAndBorderColor = {
41
+ standard: "_1h6d1elr _1dqonqa1 _syaz1fxt _80om1kdv _bfhk1j9a _srjtgir2",
42
+ subtle: "_1h6d1j28 _1dqonqa1 _syaz1fxt _80om1kdv _16hg1j28 _srjtgir2",
43
+ none: "_1h6d1j28 _1dqoglyw _syaz1fxt _80om1kdv _16hg1j28 _srjtgir2"
44
+ };
45
+ var widthMap = {
46
+ xsmall: 80,
47
+ small: 160,
48
+ medium: 240,
49
+ large: 320,
50
+ xlarge: 480
51
+ };
52
+ var getMaxWidth = function getMaxWidth(width) {
53
+ return !width ? "100%" : width in widthMap ? "".concat(widthMap[width], "px") : "".concat(+width, "px");
54
+ };
55
+ var containerStyleAppearance = {
56
+ standard: "_1dqonqa1 _1q51e4h9 _85i5e4h9 _bozgidpf _y4tiidpf",
57
+ subtle: "_1dqonqa1 _1q51e4h9 _85i5e4h9 _bozgidpf _y4tiidpf",
58
+ none: "_1dqoglyw"
59
+ };
60
+ var containerStyles = null;
61
+ var inputDisabledStyle = null;
62
+ var inputCompactStyleWithFg = null;
63
+ var inputCompactStyle = null;
64
+ var inputMonospacedStyle = null;
65
+ var inputFontStyleWithFG = null;
66
+ var inputStyleMonospacedWithFg = null;
67
+ var inputStyleNotDataCompactWithFG = null;
68
+ var inputStyle = null;
23
69
 
24
70
  /**
25
71
  * __Textfield__
@@ -94,52 +140,39 @@ var Textfield = /*#__PURE__*/forwardRef(function (props, ref) {
94
140
  ref(inputElement);
95
141
  }
96
142
  }, [ref]);
97
- var containerStyles = useMemo(function () {
98
- return getContainerStyles(appearance, width);
99
- }, [appearance, width]);
100
- var inputStyle = getInputStyles();
101
- return (
102
- /**
103
- * It is not normally acceptable to add click and key handlers to
104
- * non-interactive elements as this is an accessibility anti-pattern.
105
- * However, because this instance is to handle events on all children that
106
- * should be associated with the input, we can add role="presentation" so
107
- * that there are no negative impacts to assistive technologies.
108
- */
109
- jsx("div", {
110
- role: "presentation",
111
- "data-disabled": isDisabled ? isDisabled : undefined,
112
- "data-invalid": isInvalid ? isInvalid : undefined,
113
- "data-ds--text-field--container": true,
114
- "data-testid": testId && "".concat(testId, "-container"),
115
- onMouseDown: handleOnMouseDown
116
- // TODO: When removing legacy theming fix this.
117
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
118
- ,
119
- css: containerStyles
120
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
121
- ,
122
- className: className
123
- }, elemBeforeInput, jsx("input", _extends({}, spreadProps, {
124
- "aria-invalid": isInvalid ? isInvalid : undefined
125
- // TODO: When removing legacy theming fix this.
126
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
127
- ,
128
- css: inputStyle,
129
- "data-compact": isCompact ? isCompact : undefined,
130
- "data-ds--text-field--input": true,
131
- "data-monospaced": isMonospaced ? isMonospaced : undefined,
132
- "data-testid": testId,
133
- disabled: isDisabled,
134
- name: name,
135
- onBlur: handleOnBlur,
136
- onChange: onChange,
137
- onFocus: handleOnFocus,
138
- placeholder: placeholder,
139
- readOnly: isReadOnly,
140
- ref: setInputRef,
141
- required: isRequired
142
- })), elemAfterInput)
143
- );
143
+ return /*#__PURE__*/React.createElement("div", {
144
+ role: "presentation",
145
+ "data-disabled": isDisabled ? isDisabled : undefined,
146
+ "data-invalid": isInvalid ? isInvalid : undefined,
147
+ "data-ds--text-field--container": true,
148
+ "data-testid": testId && "".concat(testId, "-container"),
149
+ onMouseDown: handleOnMouseDown,
150
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
151
+ className: ax(["_16jlkb7n _1o9zkb7n _i0dl1osq _11c81oud _1reo15vq _18m915vq _v564r5cv _189ee4h9 _1e0c1txw _vchhusvi _4cvr1h6o _1bah1yb4 _lcxv1wug _s7n4jp4b _slp31hna _1tnq1l7b", getContainerTextBgAndBorderColor[appearance], containerStyleAppearance[appearance], !isDisabled && focusWithinStyle[appearance], !isDisabled && hoverStyle[appearance], isDisabled && containerMedia.disabled, isDisabled && disabledStyle[appearance], isInvalid && containerMedia.invalid, isInvalid && "_1h6d1bqt _4cvx1bqt _16qs13x5 _1dbz13x5 _10j7r01l", className]),
152
+ style: {
153
+ maxWidth: "".concat(getMaxWidth(width)),
154
+ "--_x5k4n9": ix("inset 0 0 0 ".concat("var(--ds-border-width, 1px)", " ", "var(--ds-border-danger, #E2483D)"))
155
+ }
156
+ }, elemBeforeInput, /*#__PURE__*/React.createElement("input", _extends({}, spreadProps, {
157
+ "aria-invalid": isInvalid ? isInvalid : undefined
158
+ // TODO: When removing legacy theming fix this.
159
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
160
+ ,
161
+
162
+ "data-compact": isCompact ? isCompact : undefined,
163
+ "data-ds--text-field--input": true,
164
+ "data-monospaced": isMonospaced ? isMonospaced : undefined,
165
+ "data-testid": testId,
166
+ disabled: isDisabled,
167
+ name: name,
168
+ onBlur: handleOnBlur,
169
+ onChange: onChange,
170
+ onFocus: handleOnFocus,
171
+ placeholder: placeholder,
172
+ readOnly: isReadOnly,
173
+ ref: setInputRef,
174
+ required: isRequired,
175
+ className: ax(["_19itidpf _11c81oud _12ji1r31 _1qu2glyw _12y31o36 _vchhusvi _1bsb1osq _1ul9idpf _bfhk1j28 _syaz1kw7 _80om1kw7 _14jiu2gc _olc6u2gc _1kod12x7 _7ba012x7 _1goxglyw _13xeglyw _1n7e1l2s _1idr131l _3hog1lh4", isMonospaced && "_ect41odn", isCompact && "_85i51b66 _1q511b66 _y4ti12x7 _bozg12x7", isDisabled && "_oo9g1lh4", isDisabled && "_1fnx18qt", !isCompact && fg('platform_design_system_team_safari_input_fix') && "_14ji12x7 _olc612x7 _1kod12x7 _7ba012x7 _l9oiu2gc _549yu2gc _1h5w12x7 _124212x7", fg('platform_design_system_team_safari_input_fix') && "_11c81doa _1tn21oud", isCompact && fg('platform_design_system_team_safari_input_fix') && "_11zpv77o _1l02v77o _daj712x7 _141f12x7 _1srd1b66 _oi9h1b66 _1e3012x7 _1txv12x7", isMonospaced && fg('platform_design_system_team_safari_input_fix') && "_ect41odn _14md1odn"])
176
+ })), elemAfterInput);
144
177
  });
145
178
  export default Textfield;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/textfield",
3
- "version": "6.8.2",
3
+ "version": "7.0.0",
4
4
  "description": "A text field is an input that allows a user to write or edit text.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -26,12 +26,11 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@atlaskit/analytics-next": "^10.3.0",
29
- "@atlaskit/platform-feature-flags": "^1.0.0",
30
- "@atlaskit/primitives": "^13.4.0",
31
- "@atlaskit/theme": "^15.0.0",
29
+ "@atlaskit/platform-feature-flags": "^1.1.0",
30
+ "@atlaskit/theme": "^16.0.0",
32
31
  "@atlaskit/tokens": "^3.3.0",
33
32
  "@babel/runtime": "^7.0.0",
34
- "@emotion/react": "^11.7.1"
33
+ "@compiled/react": "^0.18.1"
35
34
  },
36
35
  "peerDependencies": {
37
36
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
@@ -1,181 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.inputStyles = exports.containerStyles = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
- var _primitives = require("@atlaskit/primitives");
11
- var _colors = require("@atlaskit/theme/colors");
12
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
- 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) { (0, _defineProperty2.default)(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; }
14
- var backgroundColor = {
15
- standard: "var(--ds-background-input, ".concat(_colors.N10, ")"),
16
- subtle: 'transparent',
17
- none: 'transparent'
18
- };
19
- var backgroundColorFocus = {
20
- standard: "var(--ds-background-input-pressed, ".concat(_colors.N0, ")"),
21
- subtle: "var(--ds-background-input-pressed, ".concat(_colors.N0, ")"),
22
- none: 'transparent'
23
- };
24
- var backgroundColorHover = {
25
- standard: "var(--ds-background-input-hovered, ".concat(_colors.N30, ")"),
26
- subtle: "var(--ds-background-input-hovered, ".concat(_colors.N30, ")"),
27
- none: 'transparent'
28
- };
29
- var borderColor = {
30
- standard: "var(--ds-border-input, ".concat(_colors.N100, ")"),
31
- subtle: 'transparent',
32
- none: 'transparent'
33
- };
34
- var borderColorFocus = {
35
- standard: "var(--ds-border-focused, ".concat(_colors.B200, ")"),
36
- subtle: "var(--ds-border-focused, ".concat(_colors.B200, ")"),
37
- none: 'transparent'
38
- };
39
- var borderColorHover = {
40
- standard: "var(--ds-border-input, ".concat(_colors.N100, ")"),
41
- subtle: "var(--ds-border-input, transparent)",
42
- none: 'transparent'
43
- };
44
- var getContainerTextBgAndBorderColor = function getContainerTextBgAndBorderColor(appearance) {
45
- return {
46
- backgroundColor: backgroundColor[appearance],
47
- borderColor: borderColor[appearance],
48
- color: "var(--ds-text, ".concat(_colors.N900, ")"),
49
- cursor: 'text',
50
- '&:hover:not([data-disabled])': {
51
- backgroundColor: backgroundColorHover[appearance],
52
- borderColor: borderColorHover[appearance]
53
- },
54
- '&:focus-within:not([data-disabled])': {
55
- backgroundColor: backgroundColorFocus[appearance],
56
- borderColor: borderColorFocus[appearance],
57
- boxShadow: "inset 0 0 0 ".concat("var(--ds-border-width, 1px)", " ", borderColorFocus[appearance])
58
- },
59
- '&[data-disabled]': _objectSpread({
60
- color: "var(--ds-text-disabled, ".concat(_colors.N70, ")"),
61
- cursor: 'not-allowed'
62
- }, appearance === 'standard' && {
63
- backgroundColor: "var(--ds-background-disabled, ".concat(_colors.N10, ")"),
64
- borderColor: "var(--ds-background-disabled, ".concat(_colors.N10, ")")
65
- }),
66
- '&[data-invalid], &[data-invalid]:hover': {
67
- borderColor: "var(--ds-border-danger, ".concat(_colors.R400, ")"),
68
- boxShadow: "inset 0 0 0 ".concat("var(--ds-border-width, 1px)", " ", "var(--ds-border-danger, ".concat(_colors.R400, ")"))
69
- },
70
- '&[data-invalid]:focus-within': {
71
- backgroundColor: "var(--ds-background-input-pressed, ".concat(_colors.N0, ")"),
72
- borderColor: "var(--ds-border-focused, ".concat(_colors.B200, ")"),
73
- boxShadow: "inset 0 0 0 ".concat("var(--ds-border-width, 1px)", " ", "var(--ds-border-focused, ".concat(_colors.B200, ")"))
74
- },
75
- '@media screen and (-ms-high-contrast: active)': {
76
- '&[data-invalid]:focus-within': {
77
- borderColor: 'Highlight'
78
- },
79
- '&:focus-within': {
80
- borderColor: 'Highlight'
81
- },
82
- '&[data-disabled]': {
83
- borderColor: 'GrayText'
84
- }
85
- }
86
- };
87
- };
88
- var widthMap = {
89
- xsmall: 80,
90
- small: 160,
91
- medium: 240,
92
- large: 320,
93
- xlarge: 480
94
- };
95
- var getMaxWidth = function getMaxWidth(width) {
96
- return !width ? "100%" : width in widthMap ? widthMap[width] : +width;
97
- };
98
- var containerStyles = exports.containerStyles = function containerStyles(appearance, width) {
99
- return _objectSpread(_objectSpread(_objectSpread({
100
- alignItems: 'center'
101
- }, getContainerTextBgAndBorderColor(appearance)), {}, {
102
- borderRadius: 3,
103
- borderWidth: "var(--ds-border-width, 1px)"
104
- }, appearance !== 'none' ? {
105
- padding: "var(--ds-border-width, 1px)".concat(" 0")
106
- } : {}), {}, {
107
- borderStyle: appearance === 'none' ? 'none' : 'solid',
108
- boxSizing: 'border-box',
109
- display: 'flex',
110
- flex: '1 1 100%',
111
- font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
112
- justifyContent: 'space-between',
113
- maxWidth: getMaxWidth(width),
114
- overflow: 'hidden',
115
- transition: "background-color 0.2s ease-in-out, border-color 0.2s ease-in-out",
116
- wordWrap: 'break-word',
117
- verticalAlign: 'top',
118
- pointerEvents: 'auto'
119
- });
120
- };
121
- var inputStyles = exports.inputStyles = function inputStyles() {
122
- return (0, _defineProperty2.default)({
123
- backgroundColor: 'transparent',
124
- border: 0,
125
- boxSizing: 'border-box',
126
- color: 'inherit',
127
- cursor: 'inherit',
128
- font: (0, _platformFeatureFlags.fg)('platform_design_system_team_safari_input_fix') ? "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)" : "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
129
- minWidth: '0',
130
- outline: 'none',
131
- width: '100%',
132
- '&[data-monospaced]': (0, _defineProperty2.default)({
133
- fontFamily: "var(--ds-font-family-code, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)"
134
- }, _primitives.media.above.xs, {
135
- // Reapply the monospaced font family as the font declaration in a breakpoint on the root will override it otherwise
136
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
137
- fontFamily: (0, _platformFeatureFlags.fg)('platform_design_system_team_safari_input_fix') ? "var(--ds-font-family-code, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)" : undefined
138
- }),
139
- '&[data-compact]': {
140
- padding: (0, _platformFeatureFlags.fg)('platform_design_system_team_safari_input_fix') ? "var(--ds-space-025, 2px)".concat(" ", "var(--ds-space-075, 6px)") : "var(--ds-space-050, 4px)".concat(" ", "var(--ds-space-075, 6px)")
141
- },
142
- '&:not([data-compact])': {
143
- padding: (0, _platformFeatureFlags.fg)('platform_design_system_team_safari_input_fix') ? "var(--ds-space-075, 6px)".concat(" ", "var(--ds-space-075, 6px)") : "var(--ds-space-100, 8px)".concat(" ", "var(--ds-space-075, 6px)")
144
- },
145
- '&[disabled]': {
146
- // Safari (WebKit) adds a -webkit-text-fill-color style to disabled inputs
147
- // which takes priority over color and makes the text unreadable. Need to
148
- // override it with the color we want.
149
- WebkitTextFillColor: "var(--ds-text-disabled, ".concat(_colors.N70, ")")
150
- },
151
- // Hide the clear indicator on Edge (Windows only)
152
- '&::-ms-clear': {
153
- display: 'none'
154
- },
155
- '&:invalid': {
156
- boxShadow: 'none'
157
- },
158
- '&:placeholder-shown': {
159
- textOverflow: 'ellipsis'
160
- },
161
- '&::placeholder': {
162
- color: "var(--ds-text-subtlest, ".concat(_colors.N200, ")"),
163
- '&:disabled': {
164
- color: "var(--ds-text-disabled, ".concat(_colors.N70, ")")
165
- }
166
- },
167
- '@media screen and (-ms-high-contrast: active)': {
168
- '&[disabled]': {
169
- color: 'GrayText'
170
- }
171
- }
172
- }, _primitives.media.above.xs, {
173
- font: (0, _platformFeatureFlags.fg)('platform_design_system_team_safari_input_fix') ? "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)" : undefined,
174
- '&[data-compact]': {
175
- padding: (0, _platformFeatureFlags.fg)('platform_design_system_team_safari_input_fix') ? "var(--ds-space-050, 4px)".concat(" ", "var(--ds-space-075, 6px)") : undefined
176
- },
177
- '&:not([data-compact])': {
178
- padding: (0, _platformFeatureFlags.fg)('platform_design_system_team_safari_input_fix') ? "var(--ds-space-100, 8px)".concat(" ", "var(--ds-space-075, 6px)") : undefined
179
- }
180
- });
181
- };
@@ -1,169 +0,0 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
- import { media } from '@atlaskit/primitives';
3
- import { B200, N0, N10, N100, N200, N30, N70, N900, R400 } from '@atlaskit/theme/colors';
4
- const backgroundColor = {
5
- standard: `var(--ds-background-input, ${N10})`,
6
- subtle: 'transparent',
7
- none: 'transparent'
8
- };
9
- const backgroundColorFocus = {
10
- standard: `var(--ds-background-input-pressed, ${N0})`,
11
- subtle: `var(--ds-background-input-pressed, ${N0})`,
12
- none: 'transparent'
13
- };
14
- const backgroundColorHover = {
15
- standard: `var(--ds-background-input-hovered, ${N30})`,
16
- subtle: `var(--ds-background-input-hovered, ${N30})`,
17
- none: 'transparent'
18
- };
19
- const borderColor = {
20
- standard: `var(--ds-border-input, ${N100})`,
21
- subtle: 'transparent',
22
- none: 'transparent'
23
- };
24
- const borderColorFocus = {
25
- standard: `var(--ds-border-focused, ${B200})`,
26
- subtle: `var(--ds-border-focused, ${B200})`,
27
- none: 'transparent'
28
- };
29
- const borderColorHover = {
30
- standard: `var(--ds-border-input, ${N100})`,
31
- subtle: "var(--ds-border-input, transparent)",
32
- none: 'transparent'
33
- };
34
- const getContainerTextBgAndBorderColor = appearance => ({
35
- backgroundColor: backgroundColor[appearance],
36
- borderColor: borderColor[appearance],
37
- color: `var(--ds-text, ${N900})`,
38
- cursor: 'text',
39
- '&:hover:not([data-disabled])': {
40
- backgroundColor: backgroundColorHover[appearance],
41
- borderColor: borderColorHover[appearance]
42
- },
43
- '&:focus-within:not([data-disabled])': {
44
- backgroundColor: backgroundColorFocus[appearance],
45
- borderColor: borderColorFocus[appearance],
46
- boxShadow: `inset 0 0 0 ${"var(--ds-border-width, 1px)"} ${borderColorFocus[appearance]}`
47
- },
48
- '&[data-disabled]': {
49
- color: `var(--ds-text-disabled, ${N70})`,
50
- cursor: 'not-allowed',
51
- // Disabled background and border styles should not be applied to components that
52
- // have either no background or transparent background to begin with
53
- ...(appearance === 'standard' && {
54
- backgroundColor: `var(--ds-background-disabled, ${N10})`,
55
- borderColor: `var(--ds-background-disabled, ${N10})`
56
- })
57
- },
58
- '&[data-invalid], &[data-invalid]:hover': {
59
- borderColor: `var(--ds-border-danger, ${R400})`,
60
- boxShadow: `inset 0 0 0 ${"var(--ds-border-width, 1px)"} ${`var(--ds-border-danger, ${R400})`}`
61
- },
62
- '&[data-invalid]:focus-within': {
63
- backgroundColor: `var(--ds-background-input-pressed, ${N0})`,
64
- borderColor: `var(--ds-border-focused, ${B200})`,
65
- boxShadow: `inset 0 0 0 ${"var(--ds-border-width, 1px)"} ${`var(--ds-border-focused, ${B200})`}`
66
- },
67
- '@media screen and (-ms-high-contrast: active)': {
68
- '&[data-invalid]:focus-within': {
69
- borderColor: 'Highlight'
70
- },
71
- '&:focus-within': {
72
- borderColor: 'Highlight'
73
- },
74
- '&[data-disabled]': {
75
- borderColor: 'GrayText'
76
- }
77
- }
78
- });
79
- const widthMap = {
80
- xsmall: 80,
81
- small: 160,
82
- medium: 240,
83
- large: 320,
84
- xlarge: 480
85
- };
86
- const getMaxWidth = width => !width ? `100%` : width in widthMap ? widthMap[width] : +width;
87
- export const containerStyles = (appearance, width) => ({
88
- alignItems: 'center',
89
- ...getContainerTextBgAndBorderColor(appearance),
90
- borderRadius: 3,
91
- borderWidth: "var(--ds-border-width, 1px)",
92
- // add 1px padding on both top and bottom to keep the same overall height after border reduced from 2px to 1px under feature flag
93
- ...(appearance !== 'none' ? {
94
- padding: `${"var(--ds-border-width, 1px)"} 0`
95
- } : {}),
96
- borderStyle: appearance === 'none' ? 'none' : 'solid',
97
- boxSizing: 'border-box',
98
- display: 'flex',
99
- flex: '1 1 100%',
100
- font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
101
- justifyContent: 'space-between',
102
- maxWidth: getMaxWidth(width),
103
- overflow: 'hidden',
104
- transition: `background-color 0.2s ease-in-out, border-color 0.2s ease-in-out`,
105
- wordWrap: 'break-word',
106
- verticalAlign: 'top',
107
- pointerEvents: 'auto'
108
- });
109
- export const inputStyles = () => ({
110
- backgroundColor: 'transparent',
111
- border: 0,
112
- boxSizing: 'border-box',
113
- color: 'inherit',
114
- cursor: 'inherit',
115
- font: fg('platform_design_system_team_safari_input_fix') ? "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)" : "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
116
- minWidth: '0',
117
- outline: 'none',
118
- width: '100%',
119
- '&[data-monospaced]': {
120
- fontFamily: "var(--ds-font-family-code, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)",
121
- [media.above.xs]: {
122
- // Reapply the monospaced font family as the font declaration in a breakpoint on the root will override it otherwise
123
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
124
- fontFamily: fg('platform_design_system_team_safari_input_fix') ? "var(--ds-font-family-code, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)" : undefined
125
- }
126
- },
127
- '&[data-compact]': {
128
- padding: fg('platform_design_system_team_safari_input_fix') ? `${"var(--ds-space-025, 2px)"} ${"var(--ds-space-075, 6px)"}` : `${"var(--ds-space-050, 4px)"} ${"var(--ds-space-075, 6px)"}`
129
- },
130
- '&:not([data-compact])': {
131
- padding: fg('platform_design_system_team_safari_input_fix') ? `${"var(--ds-space-075, 6px)"} ${"var(--ds-space-075, 6px)"}` : `${"var(--ds-space-100, 8px)"} ${"var(--ds-space-075, 6px)"}`
132
- },
133
- '&[disabled]': {
134
- // Safari (WebKit) adds a -webkit-text-fill-color style to disabled inputs
135
- // which takes priority over color and makes the text unreadable. Need to
136
- // override it with the color we want.
137
- WebkitTextFillColor: `var(--ds-text-disabled, ${N70})`
138
- },
139
- // Hide the clear indicator on Edge (Windows only)
140
- '&::-ms-clear': {
141
- display: 'none'
142
- },
143
- '&:invalid': {
144
- boxShadow: 'none'
145
- },
146
- '&:placeholder-shown': {
147
- textOverflow: 'ellipsis'
148
- },
149
- '&::placeholder': {
150
- color: `var(--ds-text-subtlest, ${N200})`,
151
- '&:disabled': {
152
- color: `var(--ds-text-disabled, ${N70})`
153
- }
154
- },
155
- '@media screen and (-ms-high-contrast: active)': {
156
- '&[disabled]': {
157
- color: 'GrayText'
158
- }
159
- },
160
- [media.above.xs]: {
161
- font: fg('platform_design_system_team_safari_input_fix') ? "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)" : undefined,
162
- '&[data-compact]': {
163
- padding: fg('platform_design_system_team_safari_input_fix') ? `${"var(--ds-space-050, 4px)"} ${"var(--ds-space-075, 6px)"}` : undefined
164
- },
165
- '&:not([data-compact])': {
166
- padding: fg('platform_design_system_team_safari_input_fix') ? `${"var(--ds-space-100, 8px)"} ${"var(--ds-space-075, 6px)"}` : undefined
167
- }
168
- }
169
- });