@spark-web/text-input 1.1.1 → 2.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,4 +1,6 @@
1
1
  export { InputAdornment } from './InputAdornment';
2
- export { TextInput, useInput } from './TextInput';
2
+ export { InputContainer } from './InputContainer';
3
+ export { TextInput, useInputStyles } from './TextInput';
3
4
  export type { AdornmentChild } from './childrenToAdornments';
4
- export type { TextInputProps, UseInputProps } from './TextInput';
5
+ export type { InputContainerProps } from './InputContainer';
6
+ export type { TextInputProps, UseInputStylesProps } from './TextInput';
@@ -112,6 +112,51 @@ var FieldAdornment = function FieldAdornment(_ref2) {
112
112
  });
113
113
  };
114
114
 
115
+ var _excluded$1 = ["children", "startAdornment", "endAdornment"];
116
+ var InputContainer = function InputContainer(_ref) {
117
+ var children = _ref.children,
118
+ startAdornment = _ref.startAdornment,
119
+ endAdornment = _ref.endAdornment,
120
+ boxProps = _objectWithoutProperties(_ref, _excluded$1);
121
+
122
+ var _useFieldContext = field.useFieldContext(),
123
+ _useFieldContext2 = _slicedToArray(_useFieldContext, 1),
124
+ _useFieldContext2$ = _useFieldContext2[0],
125
+ disabled = _useFieldContext2$.disabled,
126
+ invalid = _useFieldContext2$.invalid;
127
+
128
+ return /*#__PURE__*/jsxRuntime.jsxs(box.Box, _objectSpread(_objectSpread({
129
+ position: "relative",
130
+ background: disabled ? 'inputDisabled' : 'input'
131
+ }, boxProps), {}, {
132
+ children: [startAdornment, children, /*#__PURE__*/jsxRuntime.jsx(FocusIndicator, {
133
+ invalid: invalid
134
+ }), endAdornment]
135
+ }));
136
+ };
137
+
138
+ var FocusIndicator = function FocusIndicator(_ref2) {
139
+ var invalid = _ref2.invalid;
140
+ return /*#__PURE__*/jsxRuntime.jsx(box.Box, {
141
+ "aria-hidden": "true",
142
+ as: "span",
143
+ data: {
144
+ 'focus-indicator': 'true'
145
+ } // Styles
146
+ ,
147
+ border: invalid ? 'critical' : 'field',
148
+ borderRadius: "small",
149
+ position: "absolute",
150
+ bottom: 0,
151
+ left: 0,
152
+ right: 0,
153
+ top: 0,
154
+ className: css.css({
155
+ pointerEvents: 'none'
156
+ })
157
+ });
158
+ };
159
+
115
160
  /**
116
161
  * Map children for placement within the `TextInput` flex container. Ensures that
117
162
  * placeholders are provided for unused placements.
@@ -144,8 +189,7 @@ var childrenToAdornments = function childrenToAdornments(children) {
144
189
  };
145
190
  };
146
191
 
147
- var _excluded = ["children", "data"],
148
- _excluded2 = ["disabled", "invalid"];
192
+ var _excluded = ["children", "data"];
149
193
 
150
194
  /** Organize and emphasize information quickly and effectively in a list of text elements. */
151
195
  var TextInput = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
@@ -154,53 +198,53 @@ var TextInput = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
154
198
  consumerProps = _objectWithoutProperties(_ref, _excluded);
155
199
 
156
200
  var _useFieldContext = field.useFieldContext(),
157
- disabled = _useFieldContext.disabled,
158
- invalid = _useFieldContext.invalid,
159
- a11yProps = _objectWithoutProperties(_useFieldContext, _excluded2);
201
+ _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
202
+ _useFieldContext2$ = _useFieldContext2[0],
203
+ disabled = _useFieldContext2$.disabled,
204
+ invalid = _useFieldContext2$.invalid,
205
+ a11yProps = _useFieldContext2[1];
160
206
 
161
207
  var _childrenToAdornments = childrenToAdornments(children),
162
208
  startAdornment = _childrenToAdornments.startAdornment,
163
209
  endAdornment = _childrenToAdornments.endAdornment;
164
210
 
165
- return /*#__PURE__*/jsxRuntime.jsxs(box.Box, {
166
- background: disabled ? 'inputDisabled' : 'input',
167
- border: invalid ? 'critical' : 'field',
168
- borderRadius: "small",
211
+ var _useInputStyles = useInputStyles({
212
+ disabled: disabled,
213
+ invalid: invalid,
214
+ startAdornment: Boolean(startAdornment),
215
+ endAdornment: Boolean(endAdornment)
216
+ }),
217
+ _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
218
+ boxProps = _useInputStyles2[0],
219
+ inputStyles = _useInputStyles2[1];
220
+
221
+ return /*#__PURE__*/jsxRuntime.jsx(InputContainer, {
169
222
  display: "inline-flex",
170
223
  alignItems: "center",
171
- flexDirection: "row",
172
- height: "medium",
173
- marginY: "none",
174
- className: css.css(useInput({
175
- disabled: disabled,
176
- invalid: invalid
177
- })),
178
- children: [startAdornment, /*#__PURE__*/jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread({
224
+ startAdornment: startAdornment,
225
+ endAdornment: endAdornment,
226
+ children: /*#__PURE__*/jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, boxProps), consumerProps), a11yProps), {}, {
179
227
  as: "input",
180
- "aria-invalid": invalid || undefined,
181
- ref: forwardedRef,
182
- disabled: disabled // Styles
183
- ,
184
- flex: 1,
185
- height: "medium",
186
- paddingX: "medium",
187
- paddingLeft: startAdornment ? 'none' : 'medium',
188
- paddingRight: endAdornment ? 'none' : 'medium',
189
- className: css.css(useInput({
190
- disabled: disabled,
191
- invalid: invalid,
192
- isNested: true
193
- })),
194
- data: data
195
- }, a11yProps), consumerProps)), endAdornment]
228
+ className: css.css(inputStyles),
229
+ data: data,
230
+ disabled: disabled,
231
+ ref: forwardedRef
232
+ }))
196
233
  });
197
234
  });
198
235
  TextInput.displayName = 'TextInput';
199
- var useInput = function useInput(_ref2) {
236
+
237
+ /**
238
+ * Returns a tuple where the first item is an object of props to spread onto the
239
+ * underlying Box component that our inputs are created with, and the second
240
+ * item is a CSS object to be passed to Emotion's `css` function
241
+ **/
242
+ var useInputStyles = function useInputStyles(_ref2) {
200
243
  var disabled = _ref2.disabled,
201
- _ref2$isNested = _ref2.isNested,
202
- isNested = _ref2$isNested === void 0 ? false : _ref2$isNested;
244
+ startAdornment = _ref2.startAdornment,
245
+ endAdornment = _ref2.endAdornment;
203
246
  var theme$1 = theme.useTheme();
247
+ var overflowStyles = text.useOverflowStrategy('truncate');
204
248
  var focusRingStyles = a11y.useFocusRing({
205
249
  always: true
206
250
  });
@@ -215,27 +259,30 @@ var useInput = function useInput(_ref2) {
215
259
  typographyStyles = _textStyles[0],
216
260
  responsiveStyles = _textStyles[1];
217
261
 
218
- return _objectSpread(_objectSpread(_objectSpread({}, typographyStyles), responsiveStyles), isNested ? {
219
- ':focus': {
220
- // This removes the nested input outline visibility since
221
- // the wrapper will be outlined, but still visibly focusable
222
- // to windows high contrast mode users.
223
- // @see https://tailwindcss.com/docs/outline-style#removing-outlines
224
- outline: '2px solid transparent',
225
- outlineOffset: '2px'
226
- }
227
- } : {
262
+ return [{
263
+ flex: 1,
264
+ position: 'relative',
265
+ height: 'medium',
266
+ paddingLeft: startAdornment ? 'none' : 'medium',
267
+ paddingRight: endAdornment ? 'none' : 'medium',
268
+ shadow: 'small',
269
+ width: 'full'
270
+ }, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, typographyStyles), responsiveStyles), overflowStyles), {}, {
228
271
  ':enabled': {
229
- '&:focus': _objectSpread(_objectSpread({}, focusRingStyles), {}, {
272
+ ':focus + [data-focus-indicator]': _objectSpread({
230
273
  borderColor: theme$1.border.color.fieldAccent
231
- })
274
+ }, focusRingStyles)
232
275
  },
233
- ':focus-within': _objectSpread(_objectSpread({}, focusRingStyles), {}, {
234
- borderColor: theme$1.border.color.fieldAccent
235
- })
236
- });
276
+ ':focus': {
277
+ outline: 'none'
278
+ },
279
+ ':invalid': {
280
+ color: theme$1.color.foreground.muted
281
+ }
282
+ })];
237
283
  };
238
284
 
239
285
  exports.InputAdornment = InputAdornment;
286
+ exports.InputContainer = InputContainer;
240
287
  exports.TextInput = TextInput;
241
- exports.useInput = useInput;
288
+ exports.useInputStyles = useInputStyles;
@@ -112,6 +112,51 @@ var FieldAdornment = function FieldAdornment(_ref2) {
112
112
  });
113
113
  };
114
114
 
115
+ var _excluded$1 = ["children", "startAdornment", "endAdornment"];
116
+ var InputContainer = function InputContainer(_ref) {
117
+ var children = _ref.children,
118
+ startAdornment = _ref.startAdornment,
119
+ endAdornment = _ref.endAdornment,
120
+ boxProps = _objectWithoutProperties(_ref, _excluded$1);
121
+
122
+ var _useFieldContext = field.useFieldContext(),
123
+ _useFieldContext2 = _slicedToArray(_useFieldContext, 1),
124
+ _useFieldContext2$ = _useFieldContext2[0],
125
+ disabled = _useFieldContext2$.disabled,
126
+ invalid = _useFieldContext2$.invalid;
127
+
128
+ return /*#__PURE__*/jsxRuntime.jsxs(box.Box, _objectSpread(_objectSpread({
129
+ position: "relative",
130
+ background: disabled ? 'inputDisabled' : 'input'
131
+ }, boxProps), {}, {
132
+ children: [startAdornment, children, /*#__PURE__*/jsxRuntime.jsx(FocusIndicator, {
133
+ invalid: invalid
134
+ }), endAdornment]
135
+ }));
136
+ };
137
+
138
+ var FocusIndicator = function FocusIndicator(_ref2) {
139
+ var invalid = _ref2.invalid;
140
+ return /*#__PURE__*/jsxRuntime.jsx(box.Box, {
141
+ "aria-hidden": "true",
142
+ as: "span",
143
+ data: {
144
+ 'focus-indicator': 'true'
145
+ } // Styles
146
+ ,
147
+ border: invalid ? 'critical' : 'field',
148
+ borderRadius: "small",
149
+ position: "absolute",
150
+ bottom: 0,
151
+ left: 0,
152
+ right: 0,
153
+ top: 0,
154
+ className: css.css({
155
+ pointerEvents: 'none'
156
+ })
157
+ });
158
+ };
159
+
115
160
  /**
116
161
  * Map children for placement within the `TextInput` flex container. Ensures that
117
162
  * placeholders are provided for unused placements.
@@ -144,8 +189,7 @@ var childrenToAdornments = function childrenToAdornments(children) {
144
189
  };
145
190
  };
146
191
 
147
- var _excluded = ["children", "data"],
148
- _excluded2 = ["disabled", "invalid"];
192
+ var _excluded = ["children", "data"];
149
193
 
150
194
  /** Organize and emphasize information quickly and effectively in a list of text elements. */
151
195
  var TextInput = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
@@ -154,53 +198,53 @@ var TextInput = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
154
198
  consumerProps = _objectWithoutProperties(_ref, _excluded);
155
199
 
156
200
  var _useFieldContext = field.useFieldContext(),
157
- disabled = _useFieldContext.disabled,
158
- invalid = _useFieldContext.invalid,
159
- a11yProps = _objectWithoutProperties(_useFieldContext, _excluded2);
201
+ _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
202
+ _useFieldContext2$ = _useFieldContext2[0],
203
+ disabled = _useFieldContext2$.disabled,
204
+ invalid = _useFieldContext2$.invalid,
205
+ a11yProps = _useFieldContext2[1];
160
206
 
161
207
  var _childrenToAdornments = childrenToAdornments(children),
162
208
  startAdornment = _childrenToAdornments.startAdornment,
163
209
  endAdornment = _childrenToAdornments.endAdornment;
164
210
 
165
- return /*#__PURE__*/jsxRuntime.jsxs(box.Box, {
166
- background: disabled ? 'inputDisabled' : 'input',
167
- border: invalid ? 'critical' : 'field',
168
- borderRadius: "small",
211
+ var _useInputStyles = useInputStyles({
212
+ disabled: disabled,
213
+ invalid: invalid,
214
+ startAdornment: Boolean(startAdornment),
215
+ endAdornment: Boolean(endAdornment)
216
+ }),
217
+ _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
218
+ boxProps = _useInputStyles2[0],
219
+ inputStyles = _useInputStyles2[1];
220
+
221
+ return /*#__PURE__*/jsxRuntime.jsx(InputContainer, {
169
222
  display: "inline-flex",
170
223
  alignItems: "center",
171
- flexDirection: "row",
172
- height: "medium",
173
- marginY: "none",
174
- className: css.css(useInput({
175
- disabled: disabled,
176
- invalid: invalid
177
- })),
178
- children: [startAdornment, /*#__PURE__*/jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread({
224
+ startAdornment: startAdornment,
225
+ endAdornment: endAdornment,
226
+ children: /*#__PURE__*/jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, boxProps), consumerProps), a11yProps), {}, {
179
227
  as: "input",
180
- "aria-invalid": invalid || undefined,
181
- ref: forwardedRef,
182
- disabled: disabled // Styles
183
- ,
184
- flex: 1,
185
- height: "medium",
186
- paddingX: "medium",
187
- paddingLeft: startAdornment ? 'none' : 'medium',
188
- paddingRight: endAdornment ? 'none' : 'medium',
189
- className: css.css(useInput({
190
- disabled: disabled,
191
- invalid: invalid,
192
- isNested: true
193
- })),
194
- data: data
195
- }, a11yProps), consumerProps)), endAdornment]
228
+ className: css.css(inputStyles),
229
+ data: data,
230
+ disabled: disabled,
231
+ ref: forwardedRef
232
+ }))
196
233
  });
197
234
  });
198
235
  TextInput.displayName = 'TextInput';
199
- var useInput = function useInput(_ref2) {
236
+
237
+ /**
238
+ * Returns a tuple where the first item is an object of props to spread onto the
239
+ * underlying Box component that our inputs are created with, and the second
240
+ * item is a CSS object to be passed to Emotion's `css` function
241
+ **/
242
+ var useInputStyles = function useInputStyles(_ref2) {
200
243
  var disabled = _ref2.disabled,
201
- _ref2$isNested = _ref2.isNested,
202
- isNested = _ref2$isNested === void 0 ? false : _ref2$isNested;
244
+ startAdornment = _ref2.startAdornment,
245
+ endAdornment = _ref2.endAdornment;
203
246
  var theme$1 = theme.useTheme();
247
+ var overflowStyles = text.useOverflowStrategy('truncate');
204
248
  var focusRingStyles = a11y.useFocusRing({
205
249
  always: true
206
250
  });
@@ -215,27 +259,30 @@ var useInput = function useInput(_ref2) {
215
259
  typographyStyles = _textStyles[0],
216
260
  responsiveStyles = _textStyles[1];
217
261
 
218
- return _objectSpread(_objectSpread(_objectSpread({}, typographyStyles), responsiveStyles), isNested ? {
219
- ':focus': {
220
- // This removes the nested input outline visibility since
221
- // the wrapper will be outlined, but still visibly focusable
222
- // to windows high contrast mode users.
223
- // @see https://tailwindcss.com/docs/outline-style#removing-outlines
224
- outline: '2px solid transparent',
225
- outlineOffset: '2px'
226
- }
227
- } : {
262
+ return [{
263
+ flex: 1,
264
+ position: 'relative',
265
+ height: 'medium',
266
+ paddingLeft: startAdornment ? 'none' : 'medium',
267
+ paddingRight: endAdornment ? 'none' : 'medium',
268
+ shadow: 'small',
269
+ width: 'full'
270
+ }, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, typographyStyles), responsiveStyles), overflowStyles), {}, {
228
271
  ':enabled': {
229
- '&:focus': _objectSpread(_objectSpread({}, focusRingStyles), {}, {
272
+ ':focus + [data-focus-indicator]': _objectSpread({
230
273
  borderColor: theme$1.border.color.fieldAccent
231
- })
274
+ }, focusRingStyles)
232
275
  },
233
- ':focus-within': _objectSpread(_objectSpread({}, focusRingStyles), {}, {
234
- borderColor: theme$1.border.color.fieldAccent
235
- })
236
- });
276
+ ':focus': {
277
+ outline: 'none'
278
+ },
279
+ ':invalid': {
280
+ color: theme$1.color.foreground.muted
281
+ }
282
+ })];
237
283
  };
238
284
 
239
285
  exports.InputAdornment = InputAdornment;
286
+ exports.InputContainer = InputContainer;
240
287
  exports.TextInput = TextInput;
241
- exports.useInput = useInput;
288
+ exports.useInputStyles = useInputStyles;
@@ -8,7 +8,7 @@ import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
8
8
  import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
9
9
  import { css } from '@emotion/css';
10
10
  import { useFocusRing } from '@spark-web/a11y';
11
- import { useText } from '@spark-web/text';
11
+ import { useOverflowStrategy, useText } from '@spark-web/text';
12
12
 
13
13
  /**
14
14
  * Components like the `SelectInput` may subscribe to the adornment context and
@@ -108,6 +108,51 @@ var FieldAdornment = function FieldAdornment(_ref2) {
108
108
  });
109
109
  };
110
110
 
111
+ var _excluded$1 = ["children", "startAdornment", "endAdornment"];
112
+ var InputContainer = function InputContainer(_ref) {
113
+ var children = _ref.children,
114
+ startAdornment = _ref.startAdornment,
115
+ endAdornment = _ref.endAdornment,
116
+ boxProps = _objectWithoutProperties(_ref, _excluded$1);
117
+
118
+ var _useFieldContext = useFieldContext(),
119
+ _useFieldContext2 = _slicedToArray(_useFieldContext, 1),
120
+ _useFieldContext2$ = _useFieldContext2[0],
121
+ disabled = _useFieldContext2$.disabled,
122
+ invalid = _useFieldContext2$.invalid;
123
+
124
+ return /*#__PURE__*/jsxs(Box, _objectSpread(_objectSpread({
125
+ position: "relative",
126
+ background: disabled ? 'inputDisabled' : 'input'
127
+ }, boxProps), {}, {
128
+ children: [startAdornment, children, /*#__PURE__*/jsx(FocusIndicator, {
129
+ invalid: invalid
130
+ }), endAdornment]
131
+ }));
132
+ };
133
+
134
+ var FocusIndicator = function FocusIndicator(_ref2) {
135
+ var invalid = _ref2.invalid;
136
+ return /*#__PURE__*/jsx(Box, {
137
+ "aria-hidden": "true",
138
+ as: "span",
139
+ data: {
140
+ 'focus-indicator': 'true'
141
+ } // Styles
142
+ ,
143
+ border: invalid ? 'critical' : 'field',
144
+ borderRadius: "small",
145
+ position: "absolute",
146
+ bottom: 0,
147
+ left: 0,
148
+ right: 0,
149
+ top: 0,
150
+ className: css({
151
+ pointerEvents: 'none'
152
+ })
153
+ });
154
+ };
155
+
111
156
  /**
112
157
  * Map children for placement within the `TextInput` flex container. Ensures that
113
158
  * placeholders are provided for unused placements.
@@ -140,8 +185,7 @@ var childrenToAdornments = function childrenToAdornments(children) {
140
185
  };
141
186
  };
142
187
 
143
- var _excluded = ["children", "data"],
144
- _excluded2 = ["disabled", "invalid"];
188
+ var _excluded = ["children", "data"];
145
189
 
146
190
  /** Organize and emphasize information quickly and effectively in a list of text elements. */
147
191
  var TextInput = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
@@ -150,53 +194,53 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
150
194
  consumerProps = _objectWithoutProperties(_ref, _excluded);
151
195
 
152
196
  var _useFieldContext = useFieldContext(),
153
- disabled = _useFieldContext.disabled,
154
- invalid = _useFieldContext.invalid,
155
- a11yProps = _objectWithoutProperties(_useFieldContext, _excluded2);
197
+ _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
198
+ _useFieldContext2$ = _useFieldContext2[0],
199
+ disabled = _useFieldContext2$.disabled,
200
+ invalid = _useFieldContext2$.invalid,
201
+ a11yProps = _useFieldContext2[1];
156
202
 
157
203
  var _childrenToAdornments = childrenToAdornments(children),
158
204
  startAdornment = _childrenToAdornments.startAdornment,
159
205
  endAdornment = _childrenToAdornments.endAdornment;
160
206
 
161
- return /*#__PURE__*/jsxs(Box, {
162
- background: disabled ? 'inputDisabled' : 'input',
163
- border: invalid ? 'critical' : 'field',
164
- borderRadius: "small",
207
+ var _useInputStyles = useInputStyles({
208
+ disabled: disabled,
209
+ invalid: invalid,
210
+ startAdornment: Boolean(startAdornment),
211
+ endAdornment: Boolean(endAdornment)
212
+ }),
213
+ _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
214
+ boxProps = _useInputStyles2[0],
215
+ inputStyles = _useInputStyles2[1];
216
+
217
+ return /*#__PURE__*/jsx(InputContainer, {
165
218
  display: "inline-flex",
166
219
  alignItems: "center",
167
- flexDirection: "row",
168
- height: "medium",
169
- marginY: "none",
170
- className: css(useInput({
171
- disabled: disabled,
172
- invalid: invalid
173
- })),
174
- children: [startAdornment, /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({
220
+ startAdornment: startAdornment,
221
+ endAdornment: endAdornment,
222
+ children: /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, boxProps), consumerProps), a11yProps), {}, {
175
223
  as: "input",
176
- "aria-invalid": invalid || undefined,
177
- ref: forwardedRef,
178
- disabled: disabled // Styles
179
- ,
180
- flex: 1,
181
- height: "medium",
182
- paddingX: "medium",
183
- paddingLeft: startAdornment ? 'none' : 'medium',
184
- paddingRight: endAdornment ? 'none' : 'medium',
185
- className: css(useInput({
186
- disabled: disabled,
187
- invalid: invalid,
188
- isNested: true
189
- })),
190
- data: data
191
- }, a11yProps), consumerProps)), endAdornment]
224
+ className: css(inputStyles),
225
+ data: data,
226
+ disabled: disabled,
227
+ ref: forwardedRef
228
+ }))
192
229
  });
193
230
  });
194
231
  TextInput.displayName = 'TextInput';
195
- var useInput = function useInput(_ref2) {
232
+
233
+ /**
234
+ * Returns a tuple where the first item is an object of props to spread onto the
235
+ * underlying Box component that our inputs are created with, and the second
236
+ * item is a CSS object to be passed to Emotion's `css` function
237
+ **/
238
+ var useInputStyles = function useInputStyles(_ref2) {
196
239
  var disabled = _ref2.disabled,
197
- _ref2$isNested = _ref2.isNested,
198
- isNested = _ref2$isNested === void 0 ? false : _ref2$isNested;
240
+ startAdornment = _ref2.startAdornment,
241
+ endAdornment = _ref2.endAdornment;
199
242
  var theme = useTheme();
243
+ var overflowStyles = useOverflowStrategy('truncate');
200
244
  var focusRingStyles = useFocusRing({
201
245
  always: true
202
246
  });
@@ -211,25 +255,27 @@ var useInput = function useInput(_ref2) {
211
255
  typographyStyles = _textStyles[0],
212
256
  responsiveStyles = _textStyles[1];
213
257
 
214
- return _objectSpread(_objectSpread(_objectSpread({}, typographyStyles), responsiveStyles), isNested ? {
215
- ':focus': {
216
- // This removes the nested input outline visibility since
217
- // the wrapper will be outlined, but still visibly focusable
218
- // to windows high contrast mode users.
219
- // @see https://tailwindcss.com/docs/outline-style#removing-outlines
220
- outline: '2px solid transparent',
221
- outlineOffset: '2px'
222
- }
223
- } : {
258
+ return [{
259
+ flex: 1,
260
+ position: 'relative',
261
+ height: 'medium',
262
+ paddingLeft: startAdornment ? 'none' : 'medium',
263
+ paddingRight: endAdornment ? 'none' : 'medium',
264
+ shadow: 'small',
265
+ width: 'full'
266
+ }, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, typographyStyles), responsiveStyles), overflowStyles), {}, {
224
267
  ':enabled': {
225
- '&:focus': _objectSpread(_objectSpread({}, focusRingStyles), {}, {
268
+ ':focus + [data-focus-indicator]': _objectSpread({
226
269
  borderColor: theme.border.color.fieldAccent
227
- })
270
+ }, focusRingStyles)
228
271
  },
229
- ':focus-within': _objectSpread(_objectSpread({}, focusRingStyles), {}, {
230
- borderColor: theme.border.color.fieldAccent
231
- })
232
- });
272
+ ':focus': {
273
+ outline: 'none'
274
+ },
275
+ ':invalid': {
276
+ color: theme.color.foreground.muted
277
+ }
278
+ })];
233
279
  };
234
280
 
235
- export { InputAdornment, TextInput, useInput };
281
+ export { InputAdornment, InputContainer, TextInput, useInputStyles };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-web/text-input",
3
- "version": "1.1.1",
3
+ "version": "2.0.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/spark-web-text-input.cjs.js",
6
6
  "module": "dist/spark-web-text-input.esm.js",
@@ -8,20 +8,21 @@
8
8
  "dist"
9
9
  ],
10
10
  "dependencies": {
11
- "@babel/runtime": "^7.14.6",
12
- "@emotion/css": "^11.7.1",
13
- "@spark-web/a11y": "^1.0.4",
14
- "@spark-web/box": "^1.0.4",
15
- "@spark-web/field": "^1.1.0",
16
- "@spark-web/text": "^1.0.4",
17
- "@spark-web/theme": "^3.0.0",
18
- "@spark-web/utils": "^1.1.2"
11
+ "@babel/runtime": "^7.18.3",
12
+ "@emotion/css": "^11.9.0",
13
+ "@spark-web/a11y": "^1.1.0",
14
+ "@spark-web/box": "^1.0.6",
15
+ "@spark-web/text": "^1.0.6",
16
+ "@spark-web/theme": "^3.0.2",
17
+ "@spark-web/utils": "^1.1.5"
19
18
  },
20
19
  "devDependencies": {
20
+ "@spark-web/field": "^3.0.1",
21
21
  "@types/react": "^17.0.12",
22
22
  "react": "^17.0.2"
23
23
  },
24
24
  "peerDependencies": {
25
+ "@spark-web/field": "^3.0.1",
25
26
  "react": ">=17.0.2"
26
27
  },
27
28
  "engines": {