@spark-web/text-input 5.0.0-rc.31 → 5.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,65 @@
1
1
  # @spark-web/text-input
2
2
 
3
+ ## 5.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#600](https://github.com/brighte-labs/spark-web/pull/600)
8
+ [`8e0bb68`](https://github.com/brighte-labs/spark-web/commit/8e0bb683181ee4f56f9fdcf378e48d9adae9475e)
9
+ Thanks [@chrischua-brighte](https://github.com/chrischua-brighte)! - add
10
+ readonly and overflowstrategy
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+ [[`8e0bb68`](https://github.com/brighte-labs/spark-web/commit/8e0bb683181ee4f56f9fdcf378e48d9adae9475e)]:
16
+ - @spark-web/field@5.1.0
17
+
18
+ ## 5.0.0
19
+
20
+ ### Major Changes
21
+
22
+ - This release of spark-web standardises the version across all packages to be
23
+ **`v5`**, primarily signifying the switch from `@emotion/css` to
24
+ `@emotion/react` as one of the key dependencies of the entire library, in
25
+ order to support server-side rendering / SSR.
26
+
27
+ This release also introduces support for theming, to allow for more co-branded
28
+ experiences across our web applications. It also supports component-level
29
+ theming for `<Button />`, `<ButtonLink />`, and `<Checkbox />`, which provides
30
+ the capability to override the global theme available inside an application.
31
+
32
+ To use this in an application, you can wrap the affected areas with a
33
+ `ThemeProvider`:
34
+
35
+ ```
36
+ <ThemeProvider theme="pantheon">
37
+ <Input type="text" />
38
+ <Button type="submit" />
39
+ </ThemeProvider>
40
+ ```
41
+
42
+ Part of the theming capabilities includes a new theme for `spark-web` called
43
+ "pantheon", which should map with our co-branding efforts in the Pantheon
44
+ project. It currently includes a small set of colors and its corresponding
45
+ font family.
46
+
47
+ ### Patch Changes
48
+
49
+ - [#532](https://github.com/brighte-labs/spark-web/pull/532)
50
+ [`631573c`](https://github.com/brighte-labs/spark-web/commit/631573cb72981d99b9afa4ad559123f44e47b2a9)
51
+ Thanks [@ralcoriza-brighte](https://github.com/ralcoriza-brighte)! - Fix
52
+ type-related issues
53
+
54
+ - Updated dependencies
55
+ [[`631573c`](https://github.com/brighte-labs/spark-web/commit/631573cb72981d99b9afa4ad559123f44e47b2a9)]:
56
+ - @spark-web/field@5.0.0
57
+ - @spark-web/theme@5.0.0
58
+ - @spark-web/utils@5.0.0
59
+ - @spark-web/a11y@5.0.0
60
+ - @spark-web/text@5.0.0
61
+ - @spark-web/box@5.0.0
62
+
3
63
  ## 5.0.0-rc.31
4
64
 
5
65
  ### Patch Changes
@@ -1,4 +1,5 @@
1
1
  import type { FieldState } from '@spark-web/field';
2
+ import type { TextOverflowStrategy } from '@spark-web/text';
2
3
  import type { DataAttributeMap } from '@spark-web/utils/internal';
3
4
  import type { InputHTMLAttributes } from 'react';
4
5
  import type { AdornmentsAsChildren } from "./children-to-adornments.js";
@@ -22,6 +23,8 @@ export declare type TextInputProps = {
22
23
  * otherwise it will not be rendered.
23
24
  */
24
25
  children?: AdornmentsAsChildren;
26
+ /** Manage how text behaves with regard to overflow. */
27
+ overflowStrategy?: TextOverflowStrategy;
25
28
  } & NativeInputProps;
26
29
  /** Organize and emphasize information quickly and effectively in a list of text elements. */
27
30
  export declare const TextInput: import("react").ForwardRefExoticComponent<{
@@ -41,17 +44,21 @@ export declare const TextInput: import("react").ForwardRefExoticComponent<{
41
44
  * otherwise it will not be rendered.
42
45
  */
43
46
  children?: AdornmentsAsChildren;
47
+ /** Manage how text behaves with regard to overflow. */
48
+ overflowStrategy?: "truncate" | "nowrap" | "breakword" | undefined;
44
49
  } & NativeInputProps & import("react").RefAttributes<HTMLInputElement>>;
45
50
  export declare type UseInputStylesProps = FieldState & {
46
51
  startAdornment?: boolean;
47
52
  endAdornment?: boolean;
53
+ readOnly?: boolean;
54
+ overflowStrategy?: TextOverflowStrategy;
48
55
  };
49
56
  /**
50
57
  * Returns a tuple where the first item is an object of props to spread onto the
51
58
  * underlying Box component that our inputs are created with, and the second
52
59
  * item is a CSS object to be passed to Emotion's `css` function
53
60
  **/
54
- export declare const useInputStyles: ({ disabled, startAdornment, endAdornment, }: UseInputStylesProps) => readonly [{
61
+ export declare const useInputStyles: ({ disabled, startAdornment, endAdornment, readOnly, overflowStrategy, }: UseInputStylesProps) => readonly [{
55
62
  readonly flex: 1;
56
63
  readonly position: "relative";
57
64
  readonly height: "medium";
@@ -180,17 +180,19 @@ var childrenToAdornments = function childrenToAdornments(children) {
180
180
  };
181
181
  };
182
182
 
183
- var _excluded = ["children", "data"];
183
+ var _excluded = ["children", "data", "overflowStrategy"];
184
184
  /** Organize and emphasize information quickly and effectively in a list of text elements. */
185
185
  var TextInput = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
186
186
  var children = _ref.children,
187
187
  data = _ref.data,
188
+ overflowStrategy = _ref.overflowStrategy,
188
189
  consumerProps = _objectWithoutProperties(_ref, _excluded);
189
190
  var _useFieldContext = field.useFieldContext(),
190
191
  _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
191
192
  _useFieldContext2$ = _useFieldContext2[0],
192
193
  disabled = _useFieldContext2$.disabled,
193
194
  invalid = _useFieldContext2$.invalid,
195
+ readOnly = _useFieldContext2$.readOnly,
194
196
  a11yProps = _useFieldContext2[1];
195
197
  var _childrenToAdornments = childrenToAdornments(children),
196
198
  startAdornment = _childrenToAdornments.startAdornment,
@@ -199,7 +201,9 @@ var TextInput = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
199
201
  disabled: disabled,
200
202
  invalid: invalid,
201
203
  startAdornment: Boolean(startAdornment),
202
- endAdornment: Boolean(endAdornment)
204
+ endAdornment: Boolean(endAdornment),
205
+ readOnly: readOnly,
206
+ overflowStrategy: overflowStrategy
203
207
  }),
204
208
  _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
205
209
  boxProps = _useInputStyles2[0],
@@ -214,6 +218,7 @@ var TextInput = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
214
218
  css: react$1.css(inputStyles),
215
219
  data: data,
216
220
  disabled: disabled,
221
+ readOnly: readOnly,
217
222
  ref: forwardedRef
218
223
  }))
219
224
  });
@@ -227,15 +232,18 @@ TextInput.displayName = 'TextInput';
227
232
  var useInputStyles = function useInputStyles(_ref2) {
228
233
  var disabled = _ref2.disabled,
229
234
  startAdornment = _ref2.startAdornment,
230
- endAdornment = _ref2.endAdornment;
235
+ endAdornment = _ref2.endAdornment,
236
+ readOnly = _ref2.readOnly,
237
+ _ref2$overflowStrateg = _ref2.overflowStrategy,
238
+ overflowStrategy = _ref2$overflowStrateg === void 0 ? 'truncate' : _ref2$overflowStrateg;
231
239
  var theme$1 = theme.useTheme();
232
- var overflowStyles = text.useOverflowStrategy('truncate');
240
+ var overflowStyles = text.useOverflowStrategy(overflowStrategy);
233
241
  var focusRingStyles = a11y.useFocusRing({
234
242
  always: true
235
243
  });
236
244
  var textStyles = text.useText({
237
245
  baseline: false,
238
- tone: disabled ? 'disabled' : 'neutral',
246
+ tone: disabled || readOnly ? 'disabled' : 'neutral',
239
247
  size: 'standard',
240
248
  weight: 'regular'
241
249
  });
@@ -180,17 +180,19 @@ var childrenToAdornments = function childrenToAdornments(children) {
180
180
  };
181
181
  };
182
182
 
183
- var _excluded = ["children", "data"];
183
+ var _excluded = ["children", "data", "overflowStrategy"];
184
184
  /** Organize and emphasize information quickly and effectively in a list of text elements. */
185
185
  var TextInput = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
186
186
  var children = _ref.children,
187
187
  data = _ref.data,
188
+ overflowStrategy = _ref.overflowStrategy,
188
189
  consumerProps = _objectWithoutProperties(_ref, _excluded);
189
190
  var _useFieldContext = field.useFieldContext(),
190
191
  _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
191
192
  _useFieldContext2$ = _useFieldContext2[0],
192
193
  disabled = _useFieldContext2$.disabled,
193
194
  invalid = _useFieldContext2$.invalid,
195
+ readOnly = _useFieldContext2$.readOnly,
194
196
  a11yProps = _useFieldContext2[1];
195
197
  var _childrenToAdornments = childrenToAdornments(children),
196
198
  startAdornment = _childrenToAdornments.startAdornment,
@@ -199,7 +201,9 @@ var TextInput = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
199
201
  disabled: disabled,
200
202
  invalid: invalid,
201
203
  startAdornment: Boolean(startAdornment),
202
- endAdornment: Boolean(endAdornment)
204
+ endAdornment: Boolean(endAdornment),
205
+ readOnly: readOnly,
206
+ overflowStrategy: overflowStrategy
203
207
  }),
204
208
  _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
205
209
  boxProps = _useInputStyles2[0],
@@ -214,6 +218,7 @@ var TextInput = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
214
218
  css: react$1.css(inputStyles),
215
219
  data: data,
216
220
  disabled: disabled,
221
+ readOnly: readOnly,
217
222
  ref: forwardedRef
218
223
  }))
219
224
  });
@@ -227,15 +232,18 @@ TextInput.displayName = 'TextInput';
227
232
  var useInputStyles = function useInputStyles(_ref2) {
228
233
  var disabled = _ref2.disabled,
229
234
  startAdornment = _ref2.startAdornment,
230
- endAdornment = _ref2.endAdornment;
235
+ endAdornment = _ref2.endAdornment,
236
+ readOnly = _ref2.readOnly,
237
+ _ref2$overflowStrateg = _ref2.overflowStrategy,
238
+ overflowStrategy = _ref2$overflowStrateg === void 0 ? 'truncate' : _ref2$overflowStrateg;
231
239
  var theme$1 = theme.useTheme();
232
- var overflowStyles = text.useOverflowStrategy('truncate');
240
+ var overflowStyles = text.useOverflowStrategy(overflowStrategy);
233
241
  var focusRingStyles = a11y.useFocusRing({
234
242
  always: true
235
243
  });
236
244
  var textStyles = text.useText({
237
245
  baseline: false,
238
- tone: disabled ? 'disabled' : 'neutral',
246
+ tone: disabled || readOnly ? 'disabled' : 'neutral',
239
247
  size: 'standard',
240
248
  weight: 'regular'
241
249
  });
@@ -176,17 +176,19 @@ var childrenToAdornments = function childrenToAdornments(children) {
176
176
  };
177
177
  };
178
178
 
179
- var _excluded = ["children", "data"];
179
+ var _excluded = ["children", "data", "overflowStrategy"];
180
180
  /** Organize and emphasize information quickly and effectively in a list of text elements. */
181
181
  var TextInput = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
182
182
  var children = _ref.children,
183
183
  data = _ref.data,
184
+ overflowStrategy = _ref.overflowStrategy,
184
185
  consumerProps = _objectWithoutProperties(_ref, _excluded);
185
186
  var _useFieldContext = useFieldContext(),
186
187
  _useFieldContext2 = _slicedToArray(_useFieldContext, 2),
187
188
  _useFieldContext2$ = _useFieldContext2[0],
188
189
  disabled = _useFieldContext2$.disabled,
189
190
  invalid = _useFieldContext2$.invalid,
191
+ readOnly = _useFieldContext2$.readOnly,
190
192
  a11yProps = _useFieldContext2[1];
191
193
  var _childrenToAdornments = childrenToAdornments(children),
192
194
  startAdornment = _childrenToAdornments.startAdornment,
@@ -195,7 +197,9 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
195
197
  disabled: disabled,
196
198
  invalid: invalid,
197
199
  startAdornment: Boolean(startAdornment),
198
- endAdornment: Boolean(endAdornment)
200
+ endAdornment: Boolean(endAdornment),
201
+ readOnly: readOnly,
202
+ overflowStrategy: overflowStrategy
199
203
  }),
200
204
  _useInputStyles2 = _slicedToArray(_useInputStyles, 2),
201
205
  boxProps = _useInputStyles2[0],
@@ -210,6 +214,7 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
210
214
  css: css(inputStyles),
211
215
  data: data,
212
216
  disabled: disabled,
217
+ readOnly: readOnly,
213
218
  ref: forwardedRef
214
219
  }))
215
220
  });
@@ -223,15 +228,18 @@ TextInput.displayName = 'TextInput';
223
228
  var useInputStyles = function useInputStyles(_ref2) {
224
229
  var disabled = _ref2.disabled,
225
230
  startAdornment = _ref2.startAdornment,
226
- endAdornment = _ref2.endAdornment;
231
+ endAdornment = _ref2.endAdornment,
232
+ readOnly = _ref2.readOnly,
233
+ _ref2$overflowStrateg = _ref2.overflowStrategy,
234
+ overflowStrategy = _ref2$overflowStrateg === void 0 ? 'truncate' : _ref2$overflowStrateg;
227
235
  var theme = useTheme();
228
- var overflowStyles = useOverflowStrategy('truncate');
236
+ var overflowStyles = useOverflowStrategy(overflowStrategy);
229
237
  var focusRingStyles = useFocusRing({
230
238
  always: true
231
239
  });
232
240
  var textStyles = useText({
233
241
  baseline: false,
234
- tone: disabled ? 'disabled' : 'neutral',
242
+ tone: disabled || readOnly ? 'disabled' : 'neutral',
235
243
  size: 'standard',
236
244
  weight: 'regular'
237
245
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-web/text-input",
3
- "version": "5.0.0-rc.31",
3
+ "version": "5.1.0",
4
4
  "homepage": "https://github.com/brighte-labs/spark-web#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,19 +17,19 @@
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.25.0",
19
19
  "@emotion/react": "^11.14.0",
20
- "@spark-web/a11y": "^5.0.0-rc.31",
21
- "@spark-web/box": "^5.0.0-rc.31",
22
- "@spark-web/text": "^5.0.0-rc.31",
23
- "@spark-web/theme": "^5.0.0-rc.31",
24
- "@spark-web/utils": "^5.0.0-rc.31"
20
+ "@spark-web/a11y": "^5.0.0",
21
+ "@spark-web/box": "^5.0.0",
22
+ "@spark-web/text": "^5.0.0",
23
+ "@spark-web/theme": "^5.0.0",
24
+ "@spark-web/utils": "^5.0.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@spark-web/field": "^5.0.0-rc.31",
27
+ "@spark-web/field": "^5.1.0",
28
28
  "@types/react": "^18.2.0",
29
29
  "react": "^18.2.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "@spark-web/field": "^5.0.0-rc.31",
32
+ "@spark-web/field": "^5.1.0",
33
33
  "react": ">=17.0.2"
34
34
  },
35
35
  "engines": {