@spark-web/text-input 4.0.0-rc.2 → 4.0.0-rc.21

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 CHANGED
@@ -1,5 +1,309 @@
1
1
  # @spark-web/text-input
2
2
 
3
+ ## 4.0.0-rc.21
4
+
5
+ ### Minor Changes
6
+
7
+ - Introduce global theming provider to set global default theme
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies []:
12
+ - @spark-web/field@4.0.0-rc.21
13
+ - @spark-web/theme@4.0.0-rc.21
14
+ - @spark-web/utils@2.0.0-rc.21
15
+ - @spark-web/a11y@2.0.0-rc.21
16
+ - @spark-web/text@2.0.0-rc.21
17
+ - @spark-web/box@2.0.0-rc.21
18
+
19
+ ## 4.0.0-rc.20
20
+
21
+ ### Minor Changes
22
+
23
+ - Support for component-level theming; button-level theming
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies []:
28
+ - @spark-web/field@4.0.0-rc.20
29
+ - @spark-web/theme@4.0.0-rc.20
30
+ - @spark-web/utils@2.0.0-rc.20
31
+ - @spark-web/a11y@2.0.0-rc.20
32
+ - @spark-web/text@2.0.0-rc.20
33
+ - @spark-web/box@2.0.0-rc.20
34
+
35
+ ## 4.0.0-rc.19
36
+
37
+ ### Major Changes
38
+
39
+ - test
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies []:
44
+ - @spark-web/field@4.0.0-rc.19
45
+ - @spark-web/theme@4.0.0-rc.19
46
+ - @spark-web/utils@2.0.0-rc.19
47
+ - @spark-web/a11y@2.0.0-rc.19
48
+ - @spark-web/text@2.0.0-rc.19
49
+ - @spark-web/box@2.0.0-rc.19
50
+
51
+ ## 4.0.0-rc.18
52
+
53
+ ### Major Changes
54
+
55
+ - tests
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies []:
60
+ - @spark-web/field@4.0.0-rc.18
61
+ - @spark-web/theme@4.0.0-rc.18
62
+ - @spark-web/utils@2.0.0-rc.18
63
+ - @spark-web/a11y@2.0.0-rc.18
64
+ - @spark-web/text@2.0.0-rc.18
65
+ - @spark-web/box@2.0.0-rc.18
66
+
67
+ ## 4.0.0-rc.17
68
+
69
+ ### Major Changes
70
+
71
+ - test
72
+
73
+ ### Patch Changes
74
+
75
+ - Updated dependencies []:
76
+ - @spark-web/field@4.0.0-rc.17
77
+ - @spark-web/theme@4.0.0-rc.17
78
+ - @spark-web/utils@2.0.0-rc.17
79
+ - @spark-web/a11y@2.0.0-rc.17
80
+ - @spark-web/text@2.0.0-rc.17
81
+ - @spark-web/box@2.0.0-rc.17
82
+
83
+ ## 4.0.0-rc.16
84
+
85
+ ### Major Changes
86
+
87
+ - test
88
+
89
+ ### Patch Changes
90
+
91
+ - Updated dependencies []:
92
+ - @spark-web/field@4.0.0-rc.16
93
+ - @spark-web/theme@4.0.0-rc.16
94
+ - @spark-web/utils@2.0.0-rc.16
95
+ - @spark-web/a11y@2.0.0-rc.16
96
+ - @spark-web/text@2.0.0-rc.16
97
+ - @spark-web/box@2.0.0-rc.16
98
+
99
+ ## 4.0.0-rc.15
100
+
101
+ ### Major Changes
102
+
103
+ - test
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies []:
108
+ - @spark-web/field@4.0.0-rc.15
109
+ - @spark-web/theme@4.0.0-rc.15
110
+ - @spark-web/utils@2.0.0-rc.15
111
+ - @spark-web/a11y@2.0.0-rc.15
112
+ - @spark-web/text@2.0.0-rc.15
113
+ - @spark-web/box@2.0.0-rc.15
114
+
115
+ ## 4.0.0-rc.14
116
+
117
+ ### Major Changes
118
+
119
+ - test
120
+
121
+ ### Patch Changes
122
+
123
+ - Updated dependencies []:
124
+ - @spark-web/field@4.0.0-rc.14
125
+ - @spark-web/theme@4.0.0-rc.14
126
+ - @spark-web/utils@2.0.0-rc.14
127
+ - @spark-web/a11y@2.0.0-rc.14
128
+ - @spark-web/text@2.0.0-rc.14
129
+ - @spark-web/box@2.0.0-rc.14
130
+
131
+ ## 4.0.0-rc.13
132
+
133
+ ### Major Changes
134
+
135
+ - test
136
+
137
+ ### Patch Changes
138
+
139
+ - Updated dependencies []:
140
+ - @spark-web/field@4.0.0-rc.13
141
+ - @spark-web/theme@4.0.0-rc.13
142
+ - @spark-web/utils@2.0.0-rc.13
143
+ - @spark-web/a11y@2.0.0-rc.13
144
+ - @spark-web/text@2.0.0-rc.13
145
+ - @spark-web/box@2.0.0-rc.13
146
+
147
+ ## 4.0.0-rc.12
148
+
149
+ ### Major Changes
150
+
151
+ - test
152
+
153
+ ### Patch Changes
154
+
155
+ - Updated dependencies []:
156
+ - @spark-web/field@4.0.0-rc.12
157
+ - @spark-web/theme@4.0.0-rc.12
158
+ - @spark-web/utils@2.0.0-rc.12
159
+ - @spark-web/a11y@2.0.0-rc.12
160
+ - @spark-web/text@2.0.0-rc.12
161
+ - @spark-web/box@2.0.0-rc.12
162
+
163
+ ## 4.0.0-rc.11
164
+
165
+ ### Major Changes
166
+
167
+ - test
168
+
169
+ ### Patch Changes
170
+
171
+ - Updated dependencies []:
172
+ - @spark-web/field@4.0.0-rc.11
173
+ - @spark-web/theme@4.0.0-rc.11
174
+ - @spark-web/utils@2.0.0-rc.11
175
+ - @spark-web/a11y@2.0.0-rc.11
176
+ - @spark-web/text@2.0.0-rc.11
177
+ - @spark-web/box@2.0.0-rc.11
178
+
179
+ ## 4.0.0-rc.10
180
+
181
+ ### Major Changes
182
+
183
+ - test
184
+
185
+ ### Patch Changes
186
+
187
+ - Updated dependencies []:
188
+ - @spark-web/field@4.0.0-rc.10
189
+ - @spark-web/theme@4.0.0-rc.10
190
+ - @spark-web/utils@2.0.0-rc.10
191
+ - @spark-web/a11y@2.0.0-rc.10
192
+ - @spark-web/text@2.0.0-rc.10
193
+ - @spark-web/box@2.0.0-rc.10
194
+
195
+ ## 4.0.0-rc.9
196
+
197
+ ### Major Changes
198
+
199
+ - test
200
+
201
+ ### Patch Changes
202
+
203
+ - Updated dependencies []:
204
+ - @spark-web/field@4.0.0-rc.9
205
+ - @spark-web/theme@4.0.0-rc.9
206
+ - @spark-web/utils@2.0.0-rc.9
207
+ - @spark-web/a11y@2.0.0-rc.9
208
+ - @spark-web/text@2.0.0-rc.9
209
+ - @spark-web/box@2.0.0-rc.9
210
+
211
+ ## 4.0.0-rc.8
212
+
213
+ ### Major Changes
214
+
215
+ - test
216
+
217
+ ### Patch Changes
218
+
219
+ - Updated dependencies []:
220
+ - @spark-web/field@4.0.0-rc.8
221
+ - @spark-web/theme@4.0.0-rc.8
222
+ - @spark-web/utils@2.0.0-rc.8
223
+ - @spark-web/a11y@2.0.0-rc.8
224
+ - @spark-web/text@2.0.0-rc.8
225
+ - @spark-web/box@2.0.0-rc.8
226
+
227
+ ## 4.0.0-rc.7
228
+
229
+ ### Major Changes
230
+
231
+ - test
232
+
233
+ ### Patch Changes
234
+
235
+ - Updated dependencies []:
236
+ - @spark-web/field@4.0.0-rc.7
237
+ - @spark-web/theme@4.0.0-rc.7
238
+ - @spark-web/utils@2.0.0-rc.7
239
+ - @spark-web/a11y@2.0.0-rc.7
240
+ - @spark-web/text@2.0.0-rc.7
241
+ - @spark-web/box@2.0.0-rc.7
242
+
243
+ ## 4.0.0-rc.6
244
+
245
+ ### Major Changes
246
+
247
+ - test
248
+
249
+ ### Patch Changes
250
+
251
+ - Updated dependencies []:
252
+ - @spark-web/field@4.0.0-rc.6
253
+ - @spark-web/theme@4.0.0-rc.6
254
+ - @spark-web/utils@2.0.0-rc.6
255
+ - @spark-web/a11y@2.0.0-rc.6
256
+ - @spark-web/text@2.0.0-rc.6
257
+ - @spark-web/box@2.0.0-rc.6
258
+
259
+ ## 4.0.0-rc.5
260
+
261
+ ### Major Changes
262
+
263
+ - test
264
+
265
+ ### Patch Changes
266
+
267
+ - Updated dependencies []:
268
+ - @spark-web/field@4.0.0-rc.5
269
+ - @spark-web/theme@4.0.0-rc.5
270
+ - @spark-web/utils@2.0.0-rc.5
271
+ - @spark-web/a11y@2.0.0-rc.5
272
+ - @spark-web/text@2.0.0-rc.5
273
+ - @spark-web/box@2.0.0-rc.5
274
+
275
+ ## 4.0.0-rc.4
276
+
277
+ ### Major Changes
278
+
279
+ - bug
280
+
281
+ ### Patch Changes
282
+
283
+ - Updated dependencies []:
284
+ - @spark-web/field@4.0.0-rc.4
285
+ - @spark-web/theme@4.0.0-rc.4
286
+ - @spark-web/utils@2.0.0-rc.4
287
+ - @spark-web/a11y@2.0.0-rc.4
288
+ - @spark-web/text@2.0.0-rc.4
289
+ - @spark-web/box@2.0.0-rc.4
290
+
291
+ ## 4.0.0-rc.3
292
+
293
+ ### Major Changes
294
+
295
+ - upgrade package
296
+
297
+ ### Patch Changes
298
+
299
+ - Updated dependencies []:
300
+ - @spark-web/field@4.0.0-rc.3
301
+ - @spark-web/theme@4.0.0-rc.3
302
+ - @spark-web/utils@2.0.0-rc.3
303
+ - @spark-web/a11y@2.0.0-rc.3
304
+ - @spark-web/text@2.0.0-rc.3
305
+ - @spark-web/box@2.0.0-rc.3
306
+
3
307
  ## 4.0.0-rc.2
4
308
 
5
309
  ### Major Changes
@@ -1,2 +1,2 @@
1
- export * from "./declarations/src/index";
2
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3Bhcmstd2ViLXRleHQtaW5wdXQuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuL2RlY2xhcmF0aW9ucy9zcmMvaW5kZXguZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
1
+ export * from "../src/index";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3Bhcmstd2ViLXRleHQtaW5wdXQuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
@@ -1,7 +1,16 @@
1
- 'use strict';
1
+ "use strict";
2
+ // this file might look strange and you might be wondering what it's for
3
+ // it's lets you import your source files by importing this entrypoint
4
+ // as you would import it if it was built with preconstruct build
5
+ // this file is slightly different to some others though
6
+ // it has a require hook which compiles your code with Babel
7
+ // this means that you don't have to set up @babel/register or anything like that
8
+ // but you can still require this module and it'll be compiled
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./spark-web-text-input.cjs.prod.js");
5
- } else {
6
- module.exports = require("./spark-web-text-input.cjs.dev.js");
7
- }
10
+ // this bit of code imports the require hook and registers it
11
+ let unregister = require("../../../node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../..", "..");
12
+
13
+ // this re-exports the source file
14
+ module.exports = require("../src/index.ts");
15
+
16
+ unregister();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-web/text-input",
3
- "version": "4.0.0-rc.2",
3
+ "version": "4.0.0-rc.21",
4
4
  "homepage": "https://github.com/brighte-labs/spark-web#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,20 +16,20 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.25.0",
19
- "@emotion/react": "^11.13.5",
20
- "@spark-web/a11y": "^2.0.0-rc.2",
21
- "@spark-web/box": "^2.0.0-rc.2",
22
- "@spark-web/text": "^2.0.0-rc.2",
23
- "@spark-web/theme": "^4.0.0-rc.2",
24
- "@spark-web/utils": "^2.0.0-rc.2"
19
+ "@emotion/react": "^11.14.0",
20
+ "@spark-web/a11y": "^2.0.0-rc.21",
21
+ "@spark-web/box": "^2.0.0-rc.21",
22
+ "@spark-web/text": "^2.0.0-rc.21",
23
+ "@spark-web/theme": "^4.0.0-rc.21",
24
+ "@spark-web/utils": "^2.0.0-rc.21"
25
25
  },
26
26
  "devDependencies": {
27
- "@spark-web/field": "^4.0.0-rc.2",
27
+ "@spark-web/field": "^4.0.0-rc.21",
28
28
  "@types/react": "^18.2.0",
29
29
  "react": "^18.2.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "@spark-web/field": "^4.0.0-rc.2",
32
+ "@spark-web/field": "^4.0.0-rc.21",
33
33
  "react": ">=17.0.2"
34
34
  },
35
35
  "engines": {
@@ -1,12 +0,0 @@
1
- import type { ReactElement } from 'react';
2
- import type { InputAdornmentProps } from "./input-adornment.js";
3
- export declare type AdornmentChild = ReactElement<InputAdornmentProps> | null | undefined;
4
- export declare type AdornmentsAsChildren = AdornmentChild | [AdornmentChild, AdornmentChild];
5
- /**
6
- * Map children for placement within the `TextInput` flex container. Ensures that
7
- * placeholders are provided for unused placements.
8
- */
9
- export declare const childrenToAdornments: (children?: AdornmentsAsChildren) => {
10
- startAdornment: ReactElement<InputAdornmentProps> | null;
11
- endAdornment: ReactElement<InputAdornmentProps> | null;
12
- };
@@ -1,6 +0,0 @@
1
- export { InputAdornment } from "./input-adornment.js";
2
- export { InputContainer } from "./input-container.js";
3
- export { TextInput, useInputStyles } from "./text-input.js";
4
- export type { AdornmentChild } from "./children-to-adornments.js";
5
- export type { InputContainerProps } from "./input-container.js";
6
- export type { TextInputProps, UseInputStylesProps } from "./text-input.js";
@@ -1,46 +0,0 @@
1
- import type { ReactElement } from 'react';
2
- declare type InputAdornmentContextType = {
3
- placement: PlacementType;
4
- };
5
- export declare const useInputAdornmentContext: () => InputAdornmentContextType | null;
6
- declare const placementToPadding: {
7
- readonly start: {
8
- readonly paddingLeft: "medium";
9
- readonly paddingRight: "xsmall";
10
- };
11
- readonly end: {
12
- readonly paddingLeft: "xsmall";
13
- readonly paddingRight: "medium";
14
- };
15
- };
16
- declare type PlacementType = keyof typeof placementToPadding;
17
- export declare type InputAdornmentProps = {
18
- children: ReactElement;
19
- /**
20
- * When using another input component as an adornment, you may optionally
21
- * override the parent field label.
22
- */
23
- fieldLabel?: string;
24
- /** Where to place the adornment. */
25
- placement: PlacementType;
26
- /**
27
- * By default, the adornment element will be wrapped to provide alignment and
28
- * spacing, use the "raw" property to opt-out of this behaviour.
29
- */
30
- raw?: boolean;
31
- };
32
- /**
33
- * Places an element at the "start" or "end" of the input, only one adornment
34
- * may be provided for each placement. By default, the adornment element will be
35
- * wrapped to provide alignment and spacing, use the "raw" property to opt-out
36
- * of this behaviour.
37
- *
38
- * @example
39
- * <TextInput>
40
- * <InputAdornment placement="start">
41
- * <Text tone="placeholder">$</Text>
42
- * </InputAdornment>
43
- * </TextInput>
44
- */
45
- export declare const InputAdornment: ({ children, fieldLabel, placement, raw, }: InputAdornmentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
46
- export {};
@@ -1,10 +0,0 @@
1
- import type { BoxProps } from '@spark-web/box';
2
- import type { ReactElement } from 'react';
3
- import type { InputAdornmentProps } from "./input-adornment.js";
4
- export declare type InputContainerProps = {
5
- /** Slot to start render adornment. */
6
- startAdornment?: ReactElement<InputAdornmentProps> | null;
7
- /** Slot to end render adornment. */
8
- endAdornment?: ReactElement<InputAdornmentProps> | null;
9
- } & Omit<BoxProps, 'background' | 'position'>;
10
- export declare const InputContainer: ({ children, startAdornment, endAdornment, ...boxProps }: InputContainerProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,62 +0,0 @@
1
- import type { FieldState } from '@spark-web/field';
2
- import type { DataAttributeMap } from '@spark-web/utils/internal';
3
- import type { InputHTMLAttributes } from 'react';
4
- import type { AdornmentsAsChildren } from "./children-to-adornments.js";
5
- declare type ValidTypes = 'text' | 'password' | 'email' | 'search' | 'number' | 'tel' | 'url';
6
- declare type ValidModes = 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
7
- declare type NativeInputProps = Pick<InputHTMLAttributes<HTMLInputElement>, 'name' | 'onBlur' | 'onChange' | 'onFocus' | 'placeholder' | 'value' | 'required'>;
8
- export declare type TextInputProps = {
9
- /** Sets data attributes for the element. */
10
- data?: DataAttributeMap;
11
- /**
12
- * How an input behaves varies considerably depending on the value of its type
13
- * attribute. If this attribute is not specified, the default type "text".
14
- */
15
- type?: ValidTypes;
16
- /** Sets the input mode attribute for the component. */
17
- inputMode?: ValidModes;
18
- /**
19
- * Adorn the input with ornamental element(s) to aid user input, or
20
- * interactive element(s) to augment user input. Each child **must** be
21
- * wrapped with the `InputAdornment` component to ensure proper layout,
22
- * otherwise it will not be rendered.
23
- */
24
- children?: AdornmentsAsChildren;
25
- } & NativeInputProps;
26
- /** Organize and emphasize information quickly and effectively in a list of text elements. */
27
- export declare const TextInput: import("react").ForwardRefExoticComponent<{
28
- /** Sets data attributes for the element. */
29
- data?: DataAttributeMap | undefined;
30
- /**
31
- * How an input behaves varies considerably depending on the value of its type
32
- * attribute. If this attribute is not specified, the default type "text".
33
- */
34
- type?: ValidTypes | undefined;
35
- /** Sets the input mode attribute for the component. */
36
- inputMode?: ValidModes | undefined;
37
- /**
38
- * Adorn the input with ornamental element(s) to aid user input, or
39
- * interactive element(s) to augment user input. Each child **must** be
40
- * wrapped with the `InputAdornment` component to ensure proper layout,
41
- * otherwise it will not be rendered.
42
- */
43
- children?: AdornmentsAsChildren;
44
- } & NativeInputProps & import("react").RefAttributes<HTMLInputElement>>;
45
- export declare type UseInputStylesProps = FieldState & {
46
- startAdornment?: boolean;
47
- endAdornment?: boolean;
48
- };
49
- /**
50
- * Returns a tuple where the first item is an object of props to spread onto the
51
- * underlying Box component that our inputs are created with, and the second
52
- * item is a CSS object to be passed to Emotion's `css` function
53
- **/
54
- export declare const useInputStyles: ({ disabled, startAdornment, endAdornment, }: UseInputStylesProps) => readonly [{
55
- readonly flex: 1;
56
- readonly position: "relative";
57
- readonly height: "medium";
58
- readonly paddingLeft: "medium" | "none";
59
- readonly paddingRight: "medium" | "none";
60
- readonly width: "full";
61
- }, any];
62
- export {};
@@ -1,270 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
6
- var box = require('@spark-web/box');
7
- var field = require('@spark-web/field');
8
- var theme = require('@spark-web/theme');
9
- var react = require('react');
10
- var jsxRuntime = require('@emotion/react/jsx-runtime');
11
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
12
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
13
- var react$1 = require('@emotion/react');
14
- var a11y = require('@spark-web/a11y');
15
- var text = require('@spark-web/text');
16
-
17
- /**
18
- * Components like the `SelectInput` may subscribe to the adornment context and
19
- * change their appearance or behaviour.
20
- */
21
- var InputAdornmentContext = /*#__PURE__*/react.createContext(null);
22
- var placementToPadding = {
23
- start: {
24
- paddingLeft: 'medium',
25
- paddingRight: 'xsmall'
26
- },
27
- end: {
28
- paddingLeft: 'xsmall',
29
- paddingRight: 'medium'
30
- }
31
- };
32
- /**
33
- * Places an element at the "start" or "end" of the input, only one adornment
34
- * may be provided for each placement. By default, the adornment element will be
35
- * wrapped to provide alignment and spacing, use the "raw" property to opt-out
36
- * of this behaviour.
37
- *
38
- * @example
39
- * <TextInput>
40
- * <InputAdornment placement="start">
41
- * <Text tone="placeholder">$</Text>
42
- * </InputAdornment>
43
- * </TextInput>
44
- */
45
- var InputAdornment = function InputAdornment(_ref) {
46
- var children = _ref.children,
47
- fieldLabel = _ref.fieldLabel,
48
- placement = _ref.placement,
49
- raw = _ref.raw;
50
- var theme$1 = theme.useTheme();
51
- var adornmentContext = react.useMemo(function () {
52
- return {
53
- placement: placement
54
- };
55
- }, [placement]);
56
- var _placementToPadding$p = placementToPadding[placement],
57
- paddingLeft = _placementToPadding$p.paddingLeft,
58
- paddingRight = _placementToPadding$p.paddingRight;
59
- var content = children;
60
- if (!raw) {
61
- content = jsxRuntime.jsx(box.Box, {
62
- paddingLeft: paddingLeft,
63
- paddingRight: paddingRight,
64
- children: jsxRuntime.jsx(box.Box, {
65
- display: "flex",
66
- alignItems: "center",
67
- justifyContent: "center",
68
- style: {
69
- minWidth: theme$1.sizing.xxsmall
70
- },
71
- children: children
72
- })
73
- });
74
- }
75
- var wrappedContent = jsxRuntime.jsx(InputAdornmentContext.Provider, {
76
- value: adornmentContext,
77
- children: content
78
- });
79
- if (fieldLabel) {
80
- return jsxRuntime.jsx(FieldAdornment, {
81
- fieldLabel: fieldLabel,
82
- children: wrappedContent
83
- });
84
- }
85
- return wrappedContent;
86
- };
87
-
88
- /**
89
- * Wrap the element with a field provider to override the parent field label.
90
- * Only split-out from `InputAdornment` to avoid the conditional hook rule.
91
- */
92
- var FieldAdornment = function FieldAdornment(_ref2) {
93
- var children = _ref2.children,
94
- fieldLabel = _ref2.fieldLabel;
95
- var parentFieldContext = field.useFieldContext();
96
- var fieldContext = react.useMemo(function () {
97
- return _objectSpread(_objectSpread({}, parentFieldContext), {}, {
98
- accessibilityLabel: fieldLabel
99
- });
100
- }, [fieldLabel, parentFieldContext]);
101
- return jsxRuntime.jsx(field.FieldContextProvider, {
102
- value: fieldContext,
103
- children: children
104
- });
105
- };
106
-
107
- var _excluded$1 = ["children", "startAdornment", "endAdornment"];
108
- var InputContainer = function InputContainer(_ref) {
109
- var children = _ref.children,
110
- startAdornment = _ref.startAdornment,
111
- endAdornment = _ref.endAdornment,
112
- boxProps = _objectWithoutProperties(_ref, _excluded$1);
113
- var _useFieldContext = field.useFieldContext(),
114
- _useFieldContext2 = _slicedToArray(_useFieldContext, 1),
115
- _useFieldContext2$ = _useFieldContext2[0],
116
- disabled = _useFieldContext2$.disabled,
117
- invalid = _useFieldContext2$.invalid;
118
- return jsxRuntime.jsxs(box.Box, _objectSpread(_objectSpread({
119
- borderRadius: "small",
120
- position: "relative",
121
- background: disabled ? 'inputDisabled' : 'input'
122
- }, boxProps), {}, {
123
- children: [startAdornment, children, jsxRuntime.jsx(FocusIndicator, {
124
- invalid: invalid
125
- }), endAdornment]
126
- }));
127
- };
128
- var FocusIndicator = function FocusIndicator(_ref2) {
129
- var invalid = _ref2.invalid;
130
- return jsxRuntime.jsx(box.Box, {
131
- "aria-hidden": "true",
132
- as: "span",
133
- data: {
134
- 'focus-indicator': 'true'
135
- }
136
- // Styles
137
- ,
138
- border: invalid ? 'critical' : 'field',
139
- borderRadius: "small",
140
- position: "absolute",
141
- bottom: 0,
142
- left: 0,
143
- right: 0,
144
- top: 0,
145
- shadow: "small",
146
- css: react$1.css({
147
- pointerEvents: 'none'
148
- })
149
- });
150
- };
151
-
152
- // NOTE: `null | undefined` allow consumers to conditionally render adornments
153
-
154
- /**
155
- * Map children for placement within the `TextInput` flex container. Ensures that
156
- * placeholders are provided for unused placements.
157
- */
158
- var childrenToAdornments = function childrenToAdornments(children) {
159
- var startAdornment = null;
160
- var endAdornment = null;
161
- if (!children) {
162
- return {
163
- startAdornment: startAdornment,
164
- endAdornment: endAdornment
165
- };
166
- }
167
- react.Children.forEach(children, function (child) {
168
- if ( /*#__PURE__*/react.isValidElement(child)) {
169
- if (child.props.placement === 'end') {
170
- endAdornment = child;
171
- }
172
- if (child.props.placement === 'start') {
173
- startAdornment = child;
174
- }
175
- }
176
- });
177
- return {
178
- startAdornment: startAdornment,
179
- endAdornment: endAdornment
180
- };
181
- };
182
-
183
- var _excluded = ["children", "data"];
184
- /** Organize and emphasize information quickly and effectively in a list of text elements. */
185
- var TextInput = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
186
- var children = _ref.children,
187
- data = _ref.data,
188
- consumerProps = _objectWithoutProperties(_ref, _excluded);
189
- var _useFieldContext = field.useFieldContext(),
190
- _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
191
- _useFieldContext2$ = _useFieldContext2[0],
192
- disabled = _useFieldContext2$.disabled,
193
- invalid = _useFieldContext2$.invalid,
194
- a11yProps = _useFieldContext2[1];
195
- var _childrenToAdornments = childrenToAdornments(children),
196
- startAdornment = _childrenToAdornments.startAdornment,
197
- endAdornment = _childrenToAdornments.endAdornment;
198
- var _useInputStyles = useInputStyles({
199
- disabled: disabled,
200
- invalid: invalid,
201
- startAdornment: Boolean(startAdornment),
202
- endAdornment: Boolean(endAdornment)
203
- }),
204
- _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
205
- boxProps = _useInputStyles2[0],
206
- inputStyles = _useInputStyles2[1];
207
- return jsxRuntime.jsx(InputContainer, {
208
- display: "inline-flex",
209
- alignItems: "center",
210
- startAdornment: startAdornment,
211
- endAdornment: endAdornment,
212
- children: jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, boxProps), consumerProps), a11yProps), {}, {
213
- as: "input",
214
- css: react$1.css(inputStyles),
215
- data: data,
216
- disabled: disabled,
217
- ref: forwardedRef
218
- }))
219
- });
220
- });
221
- TextInput.displayName = 'TextInput';
222
- /**
223
- * Returns a tuple where the first item is an object of props to spread onto the
224
- * underlying Box component that our inputs are created with, and the second
225
- * item is a CSS object to be passed to Emotion's `css` function
226
- **/
227
- var useInputStyles = function useInputStyles(_ref2) {
228
- var disabled = _ref2.disabled,
229
- startAdornment = _ref2.startAdornment,
230
- endAdornment = _ref2.endAdornment;
231
- var theme$1 = theme.useTheme();
232
- var overflowStyles = text.useOverflowStrategy('truncate');
233
- var focusRingStyles = a11y.useFocusRing({
234
- always: true
235
- });
236
- var textStyles = text.useText({
237
- baseline: false,
238
- tone: disabled ? 'disabled' : 'neutral',
239
- size: 'standard',
240
- weight: 'regular'
241
- });
242
- var _textStyles = _slicedToArray(textStyles, 2),
243
- typographyStyles = _textStyles[0],
244
- responsiveStyles = _textStyles[1];
245
- return [{
246
- flex: 1,
247
- position: 'relative',
248
- height: 'medium',
249
- paddingLeft: startAdornment ? 'none' : 'medium',
250
- paddingRight: endAdornment ? 'none' : 'medium',
251
- width: 'full'
252
- }, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, typographyStyles), responsiveStyles), overflowStyles), {}, {
253
- ':enabled': {
254
- ':focus + [data-focus-indicator]': _objectSpread({
255
- borderColor: theme$1.border.color.fieldAccent
256
- }, focusRingStyles)
257
- },
258
- ':focus': {
259
- outline: 'none'
260
- },
261
- '&[aria-invalid=true]': {
262
- color: theme$1.color.foreground.muted
263
- }
264
- })];
265
- };
266
-
267
- exports.InputAdornment = InputAdornment;
268
- exports.InputContainer = InputContainer;
269
- exports.TextInput = TextInput;
270
- exports.useInputStyles = useInputStyles;
@@ -1,270 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
6
- var box = require('@spark-web/box');
7
- var field = require('@spark-web/field');
8
- var theme = require('@spark-web/theme');
9
- var react = require('react');
10
- var jsxRuntime = require('@emotion/react/jsx-runtime');
11
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
12
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
13
- var react$1 = require('@emotion/react');
14
- var a11y = require('@spark-web/a11y');
15
- var text = require('@spark-web/text');
16
-
17
- /**
18
- * Components like the `SelectInput` may subscribe to the adornment context and
19
- * change their appearance or behaviour.
20
- */
21
- var InputAdornmentContext = /*#__PURE__*/react.createContext(null);
22
- var placementToPadding = {
23
- start: {
24
- paddingLeft: 'medium',
25
- paddingRight: 'xsmall'
26
- },
27
- end: {
28
- paddingLeft: 'xsmall',
29
- paddingRight: 'medium'
30
- }
31
- };
32
- /**
33
- * Places an element at the "start" or "end" of the input, only one adornment
34
- * may be provided for each placement. By default, the adornment element will be
35
- * wrapped to provide alignment and spacing, use the "raw" property to opt-out
36
- * of this behaviour.
37
- *
38
- * @example
39
- * <TextInput>
40
- * <InputAdornment placement="start">
41
- * <Text tone="placeholder">$</Text>
42
- * </InputAdornment>
43
- * </TextInput>
44
- */
45
- var InputAdornment = function InputAdornment(_ref) {
46
- var children = _ref.children,
47
- fieldLabel = _ref.fieldLabel,
48
- placement = _ref.placement,
49
- raw = _ref.raw;
50
- var theme$1 = theme.useTheme();
51
- var adornmentContext = react.useMemo(function () {
52
- return {
53
- placement: placement
54
- };
55
- }, [placement]);
56
- var _placementToPadding$p = placementToPadding[placement],
57
- paddingLeft = _placementToPadding$p.paddingLeft,
58
- paddingRight = _placementToPadding$p.paddingRight;
59
- var content = children;
60
- if (!raw) {
61
- content = jsxRuntime.jsx(box.Box, {
62
- paddingLeft: paddingLeft,
63
- paddingRight: paddingRight,
64
- children: jsxRuntime.jsx(box.Box, {
65
- display: "flex",
66
- alignItems: "center",
67
- justifyContent: "center",
68
- style: {
69
- minWidth: theme$1.sizing.xxsmall
70
- },
71
- children: children
72
- })
73
- });
74
- }
75
- var wrappedContent = jsxRuntime.jsx(InputAdornmentContext.Provider, {
76
- value: adornmentContext,
77
- children: content
78
- });
79
- if (fieldLabel) {
80
- return jsxRuntime.jsx(FieldAdornment, {
81
- fieldLabel: fieldLabel,
82
- children: wrappedContent
83
- });
84
- }
85
- return wrappedContent;
86
- };
87
-
88
- /**
89
- * Wrap the element with a field provider to override the parent field label.
90
- * Only split-out from `InputAdornment` to avoid the conditional hook rule.
91
- */
92
- var FieldAdornment = function FieldAdornment(_ref2) {
93
- var children = _ref2.children,
94
- fieldLabel = _ref2.fieldLabel;
95
- var parentFieldContext = field.useFieldContext();
96
- var fieldContext = react.useMemo(function () {
97
- return _objectSpread(_objectSpread({}, parentFieldContext), {}, {
98
- accessibilityLabel: fieldLabel
99
- });
100
- }, [fieldLabel, parentFieldContext]);
101
- return jsxRuntime.jsx(field.FieldContextProvider, {
102
- value: fieldContext,
103
- children: children
104
- });
105
- };
106
-
107
- var _excluded$1 = ["children", "startAdornment", "endAdornment"];
108
- var InputContainer = function InputContainer(_ref) {
109
- var children = _ref.children,
110
- startAdornment = _ref.startAdornment,
111
- endAdornment = _ref.endAdornment,
112
- boxProps = _objectWithoutProperties(_ref, _excluded$1);
113
- var _useFieldContext = field.useFieldContext(),
114
- _useFieldContext2 = _slicedToArray(_useFieldContext, 1),
115
- _useFieldContext2$ = _useFieldContext2[0],
116
- disabled = _useFieldContext2$.disabled,
117
- invalid = _useFieldContext2$.invalid;
118
- return jsxRuntime.jsxs(box.Box, _objectSpread(_objectSpread({
119
- borderRadius: "small",
120
- position: "relative",
121
- background: disabled ? 'inputDisabled' : 'input'
122
- }, boxProps), {}, {
123
- children: [startAdornment, children, jsxRuntime.jsx(FocusIndicator, {
124
- invalid: invalid
125
- }), endAdornment]
126
- }));
127
- };
128
- var FocusIndicator = function FocusIndicator(_ref2) {
129
- var invalid = _ref2.invalid;
130
- return jsxRuntime.jsx(box.Box, {
131
- "aria-hidden": "true",
132
- as: "span",
133
- data: {
134
- 'focus-indicator': 'true'
135
- }
136
- // Styles
137
- ,
138
- border: invalid ? 'critical' : 'field',
139
- borderRadius: "small",
140
- position: "absolute",
141
- bottom: 0,
142
- left: 0,
143
- right: 0,
144
- top: 0,
145
- shadow: "small",
146
- css: react$1.css({
147
- pointerEvents: 'none'
148
- })
149
- });
150
- };
151
-
152
- // NOTE: `null | undefined` allow consumers to conditionally render adornments
153
-
154
- /**
155
- * Map children for placement within the `TextInput` flex container. Ensures that
156
- * placeholders are provided for unused placements.
157
- */
158
- var childrenToAdornments = function childrenToAdornments(children) {
159
- var startAdornment = null;
160
- var endAdornment = null;
161
- if (!children) {
162
- return {
163
- startAdornment: startAdornment,
164
- endAdornment: endAdornment
165
- };
166
- }
167
- react.Children.forEach(children, function (child) {
168
- if ( /*#__PURE__*/react.isValidElement(child)) {
169
- if (child.props.placement === 'end') {
170
- endAdornment = child;
171
- }
172
- if (child.props.placement === 'start') {
173
- startAdornment = child;
174
- }
175
- }
176
- });
177
- return {
178
- startAdornment: startAdornment,
179
- endAdornment: endAdornment
180
- };
181
- };
182
-
183
- var _excluded = ["children", "data"];
184
- /** Organize and emphasize information quickly and effectively in a list of text elements. */
185
- var TextInput = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
186
- var children = _ref.children,
187
- data = _ref.data,
188
- consumerProps = _objectWithoutProperties(_ref, _excluded);
189
- var _useFieldContext = field.useFieldContext(),
190
- _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
191
- _useFieldContext2$ = _useFieldContext2[0],
192
- disabled = _useFieldContext2$.disabled,
193
- invalid = _useFieldContext2$.invalid,
194
- a11yProps = _useFieldContext2[1];
195
- var _childrenToAdornments = childrenToAdornments(children),
196
- startAdornment = _childrenToAdornments.startAdornment,
197
- endAdornment = _childrenToAdornments.endAdornment;
198
- var _useInputStyles = useInputStyles({
199
- disabled: disabled,
200
- invalid: invalid,
201
- startAdornment: Boolean(startAdornment),
202
- endAdornment: Boolean(endAdornment)
203
- }),
204
- _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
205
- boxProps = _useInputStyles2[0],
206
- inputStyles = _useInputStyles2[1];
207
- return jsxRuntime.jsx(InputContainer, {
208
- display: "inline-flex",
209
- alignItems: "center",
210
- startAdornment: startAdornment,
211
- endAdornment: endAdornment,
212
- children: jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, boxProps), consumerProps), a11yProps), {}, {
213
- as: "input",
214
- css: react$1.css(inputStyles),
215
- data: data,
216
- disabled: disabled,
217
- ref: forwardedRef
218
- }))
219
- });
220
- });
221
- TextInput.displayName = 'TextInput';
222
- /**
223
- * Returns a tuple where the first item is an object of props to spread onto the
224
- * underlying Box component that our inputs are created with, and the second
225
- * item is a CSS object to be passed to Emotion's `css` function
226
- **/
227
- var useInputStyles = function useInputStyles(_ref2) {
228
- var disabled = _ref2.disabled,
229
- startAdornment = _ref2.startAdornment,
230
- endAdornment = _ref2.endAdornment;
231
- var theme$1 = theme.useTheme();
232
- var overflowStyles = text.useOverflowStrategy('truncate');
233
- var focusRingStyles = a11y.useFocusRing({
234
- always: true
235
- });
236
- var textStyles = text.useText({
237
- baseline: false,
238
- tone: disabled ? 'disabled' : 'neutral',
239
- size: 'standard',
240
- weight: 'regular'
241
- });
242
- var _textStyles = _slicedToArray(textStyles, 2),
243
- typographyStyles = _textStyles[0],
244
- responsiveStyles = _textStyles[1];
245
- return [{
246
- flex: 1,
247
- position: 'relative',
248
- height: 'medium',
249
- paddingLeft: startAdornment ? 'none' : 'medium',
250
- paddingRight: endAdornment ? 'none' : 'medium',
251
- width: 'full'
252
- }, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, typographyStyles), responsiveStyles), overflowStyles), {}, {
253
- ':enabled': {
254
- ':focus + [data-focus-indicator]': _objectSpread({
255
- borderColor: theme$1.border.color.fieldAccent
256
- }, focusRingStyles)
257
- },
258
- ':focus': {
259
- outline: 'none'
260
- },
261
- '&[aria-invalid=true]': {
262
- color: theme$1.color.foreground.muted
263
- }
264
- })];
265
- };
266
-
267
- exports.InputAdornment = InputAdornment;
268
- exports.InputContainer = InputContainer;
269
- exports.TextInput = TextInput;
270
- exports.useInputStyles = useInputStyles;
@@ -1,263 +0,0 @@
1
- import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
2
- import { Box } from '@spark-web/box';
3
- import { useFieldContext, FieldContextProvider } from '@spark-web/field';
4
- import { useTheme } from '@spark-web/theme';
5
- import { useMemo, createContext, Children, isValidElement, forwardRef } from 'react';
6
- import { jsx, jsxs } from '@emotion/react/jsx-runtime';
7
- import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
8
- import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
9
- import { css } from '@emotion/react';
10
- import { useFocusRing } from '@spark-web/a11y';
11
- import { useOverflowStrategy, useText } from '@spark-web/text';
12
-
13
- /**
14
- * Components like the `SelectInput` may subscribe to the adornment context and
15
- * change their appearance or behaviour.
16
- */
17
- var InputAdornmentContext = /*#__PURE__*/createContext(null);
18
- var placementToPadding = {
19
- start: {
20
- paddingLeft: 'medium',
21
- paddingRight: 'xsmall'
22
- },
23
- end: {
24
- paddingLeft: 'xsmall',
25
- paddingRight: 'medium'
26
- }
27
- };
28
- /**
29
- * Places an element at the "start" or "end" of the input, only one adornment
30
- * may be provided for each placement. By default, the adornment element will be
31
- * wrapped to provide alignment and spacing, use the "raw" property to opt-out
32
- * of this behaviour.
33
- *
34
- * @example
35
- * <TextInput>
36
- * <InputAdornment placement="start">
37
- * <Text tone="placeholder">$</Text>
38
- * </InputAdornment>
39
- * </TextInput>
40
- */
41
- var InputAdornment = function InputAdornment(_ref) {
42
- var children = _ref.children,
43
- fieldLabel = _ref.fieldLabel,
44
- placement = _ref.placement,
45
- raw = _ref.raw;
46
- var theme = useTheme();
47
- var adornmentContext = useMemo(function () {
48
- return {
49
- placement: placement
50
- };
51
- }, [placement]);
52
- var _placementToPadding$p = placementToPadding[placement],
53
- paddingLeft = _placementToPadding$p.paddingLeft,
54
- paddingRight = _placementToPadding$p.paddingRight;
55
- var content = children;
56
- if (!raw) {
57
- content = jsx(Box, {
58
- paddingLeft: paddingLeft,
59
- paddingRight: paddingRight,
60
- children: jsx(Box, {
61
- display: "flex",
62
- alignItems: "center",
63
- justifyContent: "center",
64
- style: {
65
- minWidth: theme.sizing.xxsmall
66
- },
67
- children: children
68
- })
69
- });
70
- }
71
- var wrappedContent = jsx(InputAdornmentContext.Provider, {
72
- value: adornmentContext,
73
- children: content
74
- });
75
- if (fieldLabel) {
76
- return jsx(FieldAdornment, {
77
- fieldLabel: fieldLabel,
78
- children: wrappedContent
79
- });
80
- }
81
- return wrappedContent;
82
- };
83
-
84
- /**
85
- * Wrap the element with a field provider to override the parent field label.
86
- * Only split-out from `InputAdornment` to avoid the conditional hook rule.
87
- */
88
- var FieldAdornment = function FieldAdornment(_ref2) {
89
- var children = _ref2.children,
90
- fieldLabel = _ref2.fieldLabel;
91
- var parentFieldContext = useFieldContext();
92
- var fieldContext = useMemo(function () {
93
- return _objectSpread(_objectSpread({}, parentFieldContext), {}, {
94
- accessibilityLabel: fieldLabel
95
- });
96
- }, [fieldLabel, parentFieldContext]);
97
- return jsx(FieldContextProvider, {
98
- value: fieldContext,
99
- children: children
100
- });
101
- };
102
-
103
- var _excluded$1 = ["children", "startAdornment", "endAdornment"];
104
- var InputContainer = function InputContainer(_ref) {
105
- var children = _ref.children,
106
- startAdornment = _ref.startAdornment,
107
- endAdornment = _ref.endAdornment,
108
- boxProps = _objectWithoutProperties(_ref, _excluded$1);
109
- var _useFieldContext = useFieldContext(),
110
- _useFieldContext2 = _slicedToArray(_useFieldContext, 1),
111
- _useFieldContext2$ = _useFieldContext2[0],
112
- disabled = _useFieldContext2$.disabled,
113
- invalid = _useFieldContext2$.invalid;
114
- return jsxs(Box, _objectSpread(_objectSpread({
115
- borderRadius: "small",
116
- position: "relative",
117
- background: disabled ? 'inputDisabled' : 'input'
118
- }, boxProps), {}, {
119
- children: [startAdornment, children, jsx(FocusIndicator, {
120
- invalid: invalid
121
- }), endAdornment]
122
- }));
123
- };
124
- var FocusIndicator = function FocusIndicator(_ref2) {
125
- var invalid = _ref2.invalid;
126
- return jsx(Box, {
127
- "aria-hidden": "true",
128
- as: "span",
129
- data: {
130
- 'focus-indicator': 'true'
131
- }
132
- // Styles
133
- ,
134
- border: invalid ? 'critical' : 'field',
135
- borderRadius: "small",
136
- position: "absolute",
137
- bottom: 0,
138
- left: 0,
139
- right: 0,
140
- top: 0,
141
- shadow: "small",
142
- css: css({
143
- pointerEvents: 'none'
144
- })
145
- });
146
- };
147
-
148
- // NOTE: `null | undefined` allow consumers to conditionally render adornments
149
-
150
- /**
151
- * Map children for placement within the `TextInput` flex container. Ensures that
152
- * placeholders are provided for unused placements.
153
- */
154
- var childrenToAdornments = function childrenToAdornments(children) {
155
- var startAdornment = null;
156
- var endAdornment = null;
157
- if (!children) {
158
- return {
159
- startAdornment: startAdornment,
160
- endAdornment: endAdornment
161
- };
162
- }
163
- Children.forEach(children, function (child) {
164
- if ( /*#__PURE__*/isValidElement(child)) {
165
- if (child.props.placement === 'end') {
166
- endAdornment = child;
167
- }
168
- if (child.props.placement === 'start') {
169
- startAdornment = child;
170
- }
171
- }
172
- });
173
- return {
174
- startAdornment: startAdornment,
175
- endAdornment: endAdornment
176
- };
177
- };
178
-
179
- var _excluded = ["children", "data"];
180
- /** Organize and emphasize information quickly and effectively in a list of text elements. */
181
- var TextInput = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
182
- var children = _ref.children,
183
- data = _ref.data,
184
- consumerProps = _objectWithoutProperties(_ref, _excluded);
185
- var _useFieldContext = useFieldContext(),
186
- _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
187
- _useFieldContext2$ = _useFieldContext2[0],
188
- disabled = _useFieldContext2$.disabled,
189
- invalid = _useFieldContext2$.invalid,
190
- a11yProps = _useFieldContext2[1];
191
- var _childrenToAdornments = childrenToAdornments(children),
192
- startAdornment = _childrenToAdornments.startAdornment,
193
- endAdornment = _childrenToAdornments.endAdornment;
194
- var _useInputStyles = useInputStyles({
195
- disabled: disabled,
196
- invalid: invalid,
197
- startAdornment: Boolean(startAdornment),
198
- endAdornment: Boolean(endAdornment)
199
- }),
200
- _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
201
- boxProps = _useInputStyles2[0],
202
- inputStyles = _useInputStyles2[1];
203
- return jsx(InputContainer, {
204
- display: "inline-flex",
205
- alignItems: "center",
206
- startAdornment: startAdornment,
207
- endAdornment: endAdornment,
208
- children: jsx(Box, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, boxProps), consumerProps), a11yProps), {}, {
209
- as: "input",
210
- css: css(inputStyles),
211
- data: data,
212
- disabled: disabled,
213
- ref: forwardedRef
214
- }))
215
- });
216
- });
217
- TextInput.displayName = 'TextInput';
218
- /**
219
- * Returns a tuple where the first item is an object of props to spread onto the
220
- * underlying Box component that our inputs are created with, and the second
221
- * item is a CSS object to be passed to Emotion's `css` function
222
- **/
223
- var useInputStyles = function useInputStyles(_ref2) {
224
- var disabled = _ref2.disabled,
225
- startAdornment = _ref2.startAdornment,
226
- endAdornment = _ref2.endAdornment;
227
- var theme = useTheme();
228
- var overflowStyles = useOverflowStrategy('truncate');
229
- var focusRingStyles = useFocusRing({
230
- always: true
231
- });
232
- var textStyles = useText({
233
- baseline: false,
234
- tone: disabled ? 'disabled' : 'neutral',
235
- size: 'standard',
236
- weight: 'regular'
237
- });
238
- var _textStyles = _slicedToArray(textStyles, 2),
239
- typographyStyles = _textStyles[0],
240
- responsiveStyles = _textStyles[1];
241
- return [{
242
- flex: 1,
243
- position: 'relative',
244
- height: 'medium',
245
- paddingLeft: startAdornment ? 'none' : 'medium',
246
- paddingRight: endAdornment ? 'none' : 'medium',
247
- width: 'full'
248
- }, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, typographyStyles), responsiveStyles), overflowStyles), {}, {
249
- ':enabled': {
250
- ':focus + [data-focus-indicator]': _objectSpread({
251
- borderColor: theme.border.color.fieldAccent
252
- }, focusRingStyles)
253
- },
254
- ':focus': {
255
- outline: 'none'
256
- },
257
- '&[aria-invalid=true]': {
258
- color: theme.color.foreground.muted
259
- }
260
- })];
261
- };
262
-
263
- export { InputAdornment, InputContainer, TextInput, useInputStyles };