@bspk/ui 1.1.27 → 1.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/Avatar.d.ts +2 -1
  2. package/dist/Avatar.js.map +1 -1
  3. package/dist/Button.js +1 -1
  4. package/dist/Button.js.map +1 -1
  5. package/dist/Popover.d.ts +2 -3
  6. package/dist/Popover.js +3 -4
  7. package/dist/Popover.js.map +1 -1
  8. package/dist/ProgressBar.d.ts +6 -7
  9. package/dist/ProgressBar.js +6 -7
  10. package/dist/ProgressBar.js.map +1 -1
  11. package/dist/ProgressCircle.d.ts +6 -7
  12. package/dist/ProgressCircle.js +6 -7
  13. package/dist/ProgressCircle.js.map +1 -1
  14. package/dist/ProgressionStepper.d.ts +3 -8
  15. package/dist/ProgressionStepper.js +3 -8
  16. package/dist/ProgressionStepper.js.map +1 -1
  17. package/dist/RadioGroup.d.ts +9 -2
  18. package/dist/RadioGroup.js.map +1 -1
  19. package/dist/SearchBar.d.ts +1 -2
  20. package/dist/SearchBar.js +5 -6
  21. package/dist/SearchBar.js.map +1 -1
  22. package/dist/SegmentedControl.d.ts +8 -15
  23. package/dist/SegmentedControl.js +2 -4
  24. package/dist/SegmentedControl.js.map +1 -1
  25. package/dist/Select.d.ts +1 -1
  26. package/dist/Select.js +10 -11
  27. package/dist/Select.js.map +1 -1
  28. package/dist/StylesProviderAnywhere.js +1 -1
  29. package/dist/StylesProviderBetterHomesGardens.js +1 -1
  30. package/dist/StylesProviderCartus.js +1 -1
  31. package/dist/StylesProviderCentury21.js +1 -1
  32. package/dist/StylesProviderColdwellBanker.js +1 -1
  33. package/dist/StylesProviderCorcoran.js +1 -1
  34. package/dist/StylesProviderDenaliBoss.js +1 -1
  35. package/dist/StylesProviderEra.js +1 -1
  36. package/dist/StylesProviderSothebys.js +1 -1
  37. package/dist/TabGroup.d.ts +5 -6
  38. package/dist/TabGroup.js.map +1 -1
  39. package/dist/Tag.d.ts +1 -2
  40. package/dist/Tag.js +1 -2
  41. package/dist/Tag.js.map +1 -1
  42. package/dist/TextField.d.ts +2 -3
  43. package/dist/TextField.js +2 -4
  44. package/dist/TextField.js.map +1 -1
  45. package/dist/TextInput.d.ts +4 -13
  46. package/dist/TextInput.js +3 -11
  47. package/dist/TextInput.js.map +1 -1
  48. package/dist/Textarea.d.ts +5 -14
  49. package/dist/Textarea.js +6 -16
  50. package/dist/Textarea.js.map +1 -1
  51. package/dist/TextareaField.d.ts +1 -2
  52. package/dist/TextareaField.js +1 -2
  53. package/dist/TextareaField.js.map +1 -1
  54. package/dist/Txt.d.ts +1 -2
  55. package/dist/Txt.js +1 -2
  56. package/dist/Txt.js.map +1 -1
  57. package/dist/base.css +1 -1
  58. package/dist/demo/ExamplePlaceholder.js.map +1 -1
  59. package/dist/demo/examples.js +83 -14
  60. package/dist/demo/examples.js.map +1 -1
  61. package/dist/hooks/useCombobox.d.ts +45 -0
  62. package/dist/hooks/{useFloatingMenu.js → useCombobox.js} +17 -8
  63. package/dist/hooks/useCombobox.js.map +1 -0
  64. package/dist/hooks/useFloating.d.ts +39 -8
  65. package/dist/hooks/useFloating.js +2 -13
  66. package/dist/hooks/useFloating.js.map +1 -1
  67. package/dist/index.d.ts +3 -1
  68. package/dist/index.js +3 -1
  69. package/dist/index.js.map +1 -1
  70. package/package.json +3 -2
  71. package/src/Avatar.tsx +2 -1
  72. package/src/Button.tsx +2 -2
  73. package/src/Popover.tsx +5 -27
  74. package/src/ProgressBar.tsx +6 -7
  75. package/src/ProgressCircle.tsx +6 -7
  76. package/src/ProgressionStepper.tsx +3 -8
  77. package/src/RadioGroup.tsx +9 -2
  78. package/src/SearchBar.tsx +8 -20
  79. package/src/SegmentedControl.tsx +14 -37
  80. package/src/Select.tsx +9 -11
  81. package/src/TabGroup.tsx +6 -10
  82. package/src/Tag.tsx +1 -2
  83. package/src/TextField.tsx +6 -19
  84. package/src/TextInput.tsx +6 -27
  85. package/src/Textarea.tsx +10 -31
  86. package/src/TextareaField.tsx +3 -8
  87. package/src/Txt.tsx +2 -7
  88. package/src/base.scss +53 -70
  89. package/src/demo/ExamplePlaceholder.tsx +6 -1
  90. package/src/demo/examples.tsx +94 -16
  91. package/src/hooks/{useFloatingMenu.ts → useCombobox.ts} +28 -40
  92. package/src/hooks/useFloating.ts +45 -24
  93. package/src/index.ts +3 -1
  94. package/dist/hooks/useFloatingMenu.d.ts +0 -36
  95. package/dist/hooks/useFloatingMenu.js.map +0 -1
@@ -35,15 +35,14 @@ export type ProgressBarProps = {
35
35
  * A progress bar is a horizontal visual indicator that let’s the user know the progression of a task or operation
36
36
  * occurring in the background.
37
37
  *
38
- * @name ProgressBar
39
38
  * @example
40
- * import { ProgressBar } from '@bspk/ui/ProgressBar';
39
+ * import { ProgressBar } from '@bspk/ui/ProgressBar';
40
+ *
41
+ * export function Example() {
42
+ * return <ProgressBar label="Example label" completion={50} />;
43
+ * }
41
44
  *
42
- * export function Example() {
43
- * return (
44
- * <ProgressBar label="Example label" completion={50} />
45
- * );
46
- * }
45
+ * @name ProgressBar
47
46
  */
48
47
  function ProgressBar({ size = 'large', completion = 0, align = 'center', label }: ProgressBarProps) {
49
48
  const id = useId();
@@ -26,15 +26,14 @@ export type ProgressCircleProps = {
26
26
  /**
27
27
  * Rotating circle or pill that indicates the status or state of completion for a process that’s part of a user flow.
28
28
  *
29
- * @name ProgressCircle
30
29
  * @example
31
- * import { ProgressCircle } from '@bspk/ui/ProgressCircle';
30
+ * import { ProgressCircle } from '@bspk/ui/ProgressCircle';
31
+ *
32
+ * export function Example() {
33
+ * return <ProgressCircle label="Example label" />;
34
+ * }
32
35
  *
33
- * export function Example() {
34
- * return (
35
- * <ProgressCircle label="Example label"/>
36
- * );
37
- * }
36
+ * @name ProgressCircle
38
37
  */
39
38
  function ProgressCircle({ label, labelPosition, size = 'medium' }: ProgressCircleProps) {
40
39
  let variant: TxtVariant = 'labels-base';
@@ -65,19 +65,14 @@ export type ProgressionStepperProps = {
65
65
  /**
66
66
  * A progress stepper is a horizontal visual indicator that let’s the user know the progression of the current process.
67
67
  *
68
- * @name ProgressionStepper
69
68
  * @example
70
69
  * import { ProgressionStepper } from '@bspk/ui/ProgressionStepper';
71
70
  *
72
71
  * export function Example() {
73
- * return (
74
- * <ProgressionStepper steps={[
75
- * { name: 'Step 1' },
76
- * { name: 'Step 2' },
77
- * { name: 'Step 3' },
78
- * ]} />
79
- * );
72
+ * return <ProgressionStepper steps={[{ name: 'Step 1' }, { name: 'Step 2' }, { name: 'Step 3' }]} />;
80
73
  * }
74
+ *
75
+ * @name ProgressionStepper
81
76
  */
82
77
  function ProgressionStepper({
83
78
  steps = [],
@@ -33,8 +33,15 @@ export type RadioGroupProps = CommonProps<'name'> & {
33
33
  *
34
34
  * @example
35
35
  * [
36
- * { value: '1', label: 'Option 1' },
37
- * { value: '2', label: 'Option 2', description: 'Description here' },
36
+ * {
37
+ * value: '1',
38
+ * label: 'Option 1',
39
+ * },
40
+ * {
41
+ * value: '2',
42
+ * label: 'Option 2',
43
+ * description: 'Description here',
44
+ * },
38
45
  * { value: '3', label: 'Option 3' },
39
46
  * ];
40
47
  *
package/src/SearchBar.tsx CHANGED
@@ -6,14 +6,10 @@ import { MenuItem, MenuProps, Menu } from './Menu';
6
6
  import { Portal } from './Portal';
7
7
  import { TextInputProps, TextInput } from './TextInput';
8
8
  import { Txt } from './Txt';
9
- import { useFloatingMenu } from './hooks/useFloatingMenu';
9
+ import { useCombobox } from './hooks/useCombobox';
10
10
  import { useId } from './hooks/useId';
11
- //import { useFloatingMenu } from './hooks/useFloatingMenu';
12
11
 
13
- export type SearchBarProps<T extends MenuItem = MenuItem> = Pick<
14
- MenuProps<T>,
15
- 'itemCount' | 'noResultsMessage'
16
- > &
12
+ export type SearchBarProps<T extends MenuItem = MenuItem> = Pick<MenuProps<T>, 'itemCount' | 'noResultsMessage'> &
17
13
  Pick<TextInputProps, 'aria-label' | 'id' | 'inputRef' | 'name' | 'size'> & {
18
14
  /** The current value of the search bar. */
19
15
  value?: string;
@@ -83,8 +79,7 @@ export type SearchBarProps<T extends MenuItem = MenuItem> = Pick<
83
79
  * export function Example() {
84
80
  * const [searchText, setSearchText] = useState<string>('');
85
81
  *
86
- * const handleItemSelect = (item) =>
87
- * console.log('Selected item:', item);
82
+ * const handleItemSelect = (item) => console.log('Selected item:', item);
88
83
  *
89
84
  * return (
90
85
  * <SearchBar
@@ -129,15 +124,10 @@ function SearchBar({
129
124
  }: SearchBarProps) {
130
125
  const id = useId(idProp);
131
126
  const {
132
- triggerProps: {
133
- ref: triggerRef,
134
- onClick,
135
- onKeyDownCapture,
136
- ...triggerProps
137
- },
127
+ toggleProps: { ref: triggerRef, onClick, onKeyDownCapture, ...triggerProps },
138
128
  menuProps,
139
129
  closeMenu,
140
- } = useFloatingMenu({
130
+ } = useCombobox({
141
131
  placement: 'bottom-start',
142
132
  });
143
133
 
@@ -162,8 +152,8 @@ function SearchBar({
162
152
  size={size}
163
153
  value={value}
164
154
  {...triggerProps}
165
- onClick={(event) => {
166
- if (items?.length) onClick(event);
155
+ onClick={() => {
156
+ if (items?.length) onClick();
167
157
  }}
168
158
  onKeyDownCapture={(event) => {
169
159
  const handled = onKeyDownCapture(event);
@@ -196,9 +186,7 @@ function SearchBar({
196
186
  }
197
187
  onChange={(selectedValues, event) => {
198
188
  event?.preventDefault();
199
- const item = items?.find(
200
- (i) => i.value === selectedValues[0],
201
- );
189
+ const item = items?.find((i) => i.value === selectedValues[0]);
202
190
  onSelect?.(item);
203
191
  onChange(item?.label || '');
204
192
  closeMenu();
@@ -8,23 +8,18 @@ import { ElementProps } from './';
8
8
 
9
9
  export type SegmentedControlOption = {
10
10
  /**
11
- * The label of the option. This is the text that will be displayed on the
12
- * option.
11
+ * The label of the option. This is the text that will be displayed on the option.
13
12
  *
14
13
  * @required
15
14
  */
16
15
  label: string;
17
16
  /**
18
- * Determines if the element is
19
- * [disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled).
17
+ * Determines if the element is [disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled).
20
18
  *
21
19
  * @default false
22
20
  */
23
21
  disabled?: boolean;
24
- /**
25
- * The value of the option. If not provided, the label will be used as the
26
- * value.
27
- */
22
+ /** The value of the option. If not provided, the label will be used as the value. */
28
23
  value?: string;
29
24
  /**
30
25
  * The the icon to display before the label.
@@ -42,8 +37,7 @@ export type SegmentedControlOption = {
42
37
 
43
38
  export type SegmentedControlProps = {
44
39
  /**
45
- * The options to display. Each option has a label and an optional leading
46
- * icon.
40
+ * The options to display. Each option has a label and an optional leading icon.
47
41
  *
48
42
  * @example
49
43
  * [
@@ -78,16 +72,15 @@ export type SegmentedControlProps = {
78
72
  */
79
73
  size?: 'medium' | 'small';
80
74
  /**
81
- * The width of the options. If set to 'fill', the options will fill the
82
- * width of the container. If set to 'hug', the options will be as wide as
83
- * their content.
75
+ * The width of the options. If set to 'fill', the options will fill the width of the container. If set to 'hug',
76
+ * the options will be as wide as their content.
84
77
  *
85
78
  * @default hug
86
79
  */
87
80
  width?: 'fill' | 'hug';
88
81
  /**
89
- * Determines if the labels of the options should be displayed. If icons are
90
- * not provided for every option this is ignored and labels are shown.
82
+ * Determines if the labels of the options should be displayed. If icons are not provided for every option this is
83
+ * ignored and labels are shown.
91
84
  *
92
85
  * @default true
93
86
  */
@@ -131,42 +124,26 @@ function SegmentedControl({
131
124
  const options = Array.isArray(optionsProp) ? optionsProp : [];
132
125
  useOptionIconsInvalid(options);
133
126
 
134
- const hideLabels =
135
- showLabelsProp === false &&
136
- options.every((item) => item.icon && item.label);
127
+ const hideLabels = showLabelsProp === false && options.every((item) => item.icon && item.label);
137
128
 
138
129
  return (
139
- <div
140
- {...containerProps}
141
- data-bspk="segmented-control"
142
- data-size={size}
143
- data-width={width}
144
- >
130
+ <div {...containerProps} data-bspk="segmented-control" data-size={size} data-width={width}>
145
131
  {options.map((item, index) => {
146
132
  const isActive = item.value === value;
147
133
  return (
148
134
  <Fragment key={item.value}>
149
- <Tooltip
150
- disabled={!hideLabels}
151
- label={item.label}
152
- placement="top"
153
- >
135
+ <Tooltip disabled={!hideLabels} label={item.label} placement="top">
154
136
  <button
155
137
  aria-label={item.label}
156
138
  data-first={index === 0 || undefined}
157
- data-last={
158
- index === options.length - 1 || undefined
159
- }
139
+ data-last={index === options.length - 1 || undefined}
160
140
  data-selected={isActive || undefined}
161
141
  disabled={item.disabled || undefined}
162
- onClick={() =>
163
- onChange(item.value || item.label)
164
- }
142
+ onClick={() => onChange(item.value || item.label)}
165
143
  >
166
144
  <span data-outer>
167
145
  <span data-inner>
168
- {(isActive && item.iconActive) ||
169
- item.icon}
146
+ {(isActive && item.iconActive) || item.icon}
170
147
  {!hideLabels && item.label}
171
148
  </span>
172
149
  </span>
package/src/Select.tsx CHANGED
@@ -4,8 +4,8 @@ import './select.scss';
4
4
  import { ListItem } from './ListItem';
5
5
  import { Menu, MenuProps } from './Menu';
6
6
  import { Portal } from './Portal';
7
+ import { useCombobox } from './hooks/useCombobox';
7
8
  import { Placement } from './hooks/useFloating';
8
- import { useFloatingMenu } from './hooks/useFloatingMenu';
9
9
  import { useId } from './hooks/useId';
10
10
 
11
11
  import { CommonProps, InvalidPropsLibrary } from './';
@@ -119,7 +119,6 @@ function Select({
119
119
  invalid,
120
120
  errorMessage,
121
121
  readOnly,
122
- placement = 'bottom',
123
122
  name,
124
123
  isMulti,
125
124
  renderListItem,
@@ -128,14 +127,13 @@ function Select({
128
127
  }: SelectProps) {
129
128
  const id = useId(propId);
130
129
 
131
- const { triggerProps, menuProps, closeMenu } = useFloatingMenu({
132
- placement,
133
- triggerProps: {
134
- disabled,
135
- invalid,
136
- readOnly,
137
- errorMessage,
138
- },
130
+ const { toggleProps, menuProps, closeMenu } = useCombobox({
131
+ placement: 'bottom',
132
+ disabled,
133
+ invalid,
134
+ readOnly,
135
+ errorMessage,
136
+ offsetOptions: 4,
139
137
  });
140
138
 
141
139
  const selectLabel = isMulti
@@ -154,7 +152,7 @@ function Select({
154
152
  disabled={disabled || readOnly}
155
153
  id={id}
156
154
  style={styleProp}
157
- {...triggerProps}
155
+ {...toggleProps}
158
156
  >
159
157
  <ListItem data-placeholder="" label={selectLabel || placeholder} readOnly />
160
158
  <span data-icon>
package/src/TabGroup.tsx CHANGED
@@ -22,8 +22,7 @@ export type TabGroupOption = {
22
22
  */
23
23
  label: string;
24
24
  /**
25
- * Determines if the element is
26
- * [disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled).
25
+ * Determines if the element is [disabled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled).
27
26
  *
28
27
  * @default false
29
28
  */
@@ -87,15 +86,15 @@ export type TabGroupProps = {
87
86
  */
88
87
  size?: TabGroupSize;
89
88
  /**
90
- * When 'fill' the options will fill the width of the container. When 'hug',
91
- * the options will be as wide as their content.
89
+ * When 'fill' the options will fill the width of the container. When 'hug', the options will be as wide as their
90
+ * content.
92
91
  *
93
92
  * @default hug
94
93
  */
95
94
  width?: 'fill' | 'hug';
96
95
  /**
97
- * When width is 'hug' this determines if the trailing underline should be
98
- * showing. When width is 'fill' this property isn't applicable.
96
+ * When width is 'hug' this determines if the trailing underline should be showing. When width is 'fill' this
97
+ * property isn't applicable.
99
98
  *
100
99
  * @default false
101
100
  */
@@ -164,10 +163,7 @@ function TabGroup({
164
163
  {(isActive && item.iconActive) || item.icon}
165
164
  {item.label}
166
165
  {item.badge && !item.disabled && !isActive && (
167
- <Badge
168
- count={item.badge}
169
- size={TAB_BADGE_SIZES[size]}
170
- />
166
+ <Badge count={item.badge} size={TAB_BADGE_SIZES[size]} />
171
167
  )}
172
168
  </span>
173
169
  </button>
package/src/Tag.tsx CHANGED
@@ -51,8 +51,7 @@ export type TagProps<As extends ElementType = 'span'> = {
51
51
  };
52
52
 
53
53
  /**
54
- * A non-interactive visual indicators to draw attention or categorization of a
55
- * component.
54
+ * A non-interactive visual indicators to draw attention or categorization of a component.
56
55
  *
57
56
  * @example
58
57
  * import { Tag } from '@bspk/ui/Tag';
package/src/TextField.tsx CHANGED
@@ -3,12 +3,7 @@ import { TextInputProps, TextInput } from './TextInput';
3
3
 
4
4
  import { InvalidPropsLibrary } from '.';
5
5
 
6
- export type TextFieldProps =
7
- InvalidPropsLibrary &
8
- Pick<
9
- FormFieldProps,
10
- 'controlId' | 'errorMessage' | 'helperText' | 'label' | 'labelTrailing'
11
- > &
6
+ export type TextFieldProps = InvalidPropsLibrary &
12
7
  Pick<
13
8
  TextInputProps,
14
9
  | 'autoComplete'
@@ -24,11 +19,11 @@ export type TextFieldProps =
24
19
  | 'trailing'
25
20
  | 'type'
26
21
  | 'value'
27
- >;
22
+ > &
23
+ Pick<FormFieldProps, 'controlId' | 'errorMessage' | 'helperText' | 'label' | 'labelTrailing'>;
28
24
 
29
25
  /**
30
- * A text input that allows users to enter text, numbers or symbols in a
31
- * singular line.
26
+ * A text input that allows users to enter text, numbers or symbols in a singular line.
32
27
  *
33
28
  * This component takes properties from the FormField and TextInput components.
34
29
  *
@@ -61,9 +56,7 @@ function TextField({
61
56
  required,
62
57
  ...inputProps
63
58
  }: TextFieldProps) {
64
- const errorMessage =
65
- (!inputProps.readOnly && !inputProps.disabled && errorMessageProp) ||
66
- undefined;
59
+ const errorMessage = (!inputProps.readOnly && !inputProps.disabled && errorMessageProp) || undefined;
67
60
 
68
61
  return (
69
62
  <FormField
@@ -76,13 +69,7 @@ function TextField({
76
69
  required={required}
77
70
  >
78
71
  {(fieldProps) => (
79
- <TextInput
80
- {...inputProps}
81
- {...fieldProps}
82
- aria-label={label}
83
- id={controlId}
84
- required={required}
85
- />
72
+ <TextInput {...inputProps} {...fieldProps} aria-label={label} id={controlId} required={required} />
86
73
  )}
87
74
  </FormField>
88
75
  );
package/src/TextInput.tsx CHANGED
@@ -1,10 +1,5 @@
1
1
  import { SvgCancel } from '@bspk/icons/Cancel';
2
- import {
3
- ChangeEvent,
4
- HTMLInputAutoCompleteAttribute,
5
- HTMLInputTypeAttribute,
6
- ReactNode,
7
- } from 'react';
2
+ import { ChangeEvent, HTMLInputAutoCompleteAttribute, HTMLInputTypeAttribute, ReactNode } from 'react';
8
3
 
9
4
  import { useId } from './hooks/useId';
10
5
 
@@ -20,14 +15,7 @@ export const DEFAULT = {
20
15
  } as const;
21
16
 
22
17
  export type TextInputProps = CommonProps<
23
- | 'aria-label'
24
- | 'disabled'
25
- | 'id'
26
- | 'name'
27
- | 'readOnly'
28
- | 'required'
29
- | 'size'
30
- | 'value'
18
+ 'aria-label' | 'disabled' | 'id' | 'name' | 'readOnly' | 'required' | 'size' | 'value'
31
19
  > &
32
20
  InvalidPropsLibrary & {
33
21
  /**
@@ -53,8 +41,7 @@ export type TextInputProps = CommonProps<
53
41
  */
54
42
  type?: Extract<HTMLInputTypeAttribute, 'number' | 'text'>;
55
43
  /**
56
- * Specifies if user agent has any permission to provide automated
57
- * assistance in filling out form field values.
44
+ * Specifies if user agent has any permission to provide automated assistance in filling out form field values.
58
45
  * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
59
46
  *
60
47
  * @default off
@@ -63,9 +50,8 @@ export type TextInputProps = CommonProps<
63
50
  };
64
51
 
65
52
  /**
66
- * A text input that allows users to enter text, numbers or symbols in a
67
- * singular line. This is the base element and is not intended to be used
68
- * directly. Use the TextField component.
53
+ * A text input that allows users to enter text, numbers or symbols in a singular line. This is the base element and is
54
+ * not intended to be used directly. Use the TextField component.
69
55
  *
70
56
  * @example
71
57
  * import { useState } from 'react';
@@ -74,14 +60,7 @@ export type TextInputProps = CommonProps<
74
60
  * export function Example() {
75
61
  * const [value, setValue] = useState<string>('');
76
62
  *
77
- * return (
78
- * <TextInput
79
- * aria-label="Example aria-label"
80
- * name="Example name"
81
- * onChange={setValue}
82
- * value={value}
83
- * />
84
- * );
63
+ * return <TextInput aria-label="Example aria-label" name="Example name" onChange={setValue} value={value} />;
85
64
  * }
86
65
  *
87
66
  * @element
package/src/Textarea.tsx CHANGED
@@ -11,9 +11,7 @@ const DEFAULT = {
11
11
  textSize: 'medium',
12
12
  } as const;
13
13
 
14
- export type TextareaProps = CommonProps<
15
- 'aria-label' | 'disabled' | 'id' | 'readOnly' | 'required'
16
- > &
14
+ export type TextareaProps = CommonProps<'aria-label' | 'disabled' | 'id' | 'readOnly' | 'required'> &
17
15
  InvalidPropsLibrary & {
18
16
  /**
19
17
  * Callback when the value of the field changes.
@@ -21,10 +19,7 @@ export type TextareaProps = CommonProps<
21
19
  * @type (next: String, Event) => void
22
20
  * @required
23
21
  */
24
- onChange: (
25
- next: string,
26
- event?: ChangeEvent<HTMLTextAreaElement>,
27
- ) => void;
22
+ onChange: (next: string, event?: ChangeEvent<HTMLTextAreaElement>) => void;
28
23
  /**
29
24
  * The text size of the field.
30
25
  *
@@ -72,13 +67,11 @@ export type TextareaProps = CommonProps<
72
67
  };
73
68
 
74
69
  /**
75
- * A component that allows users to input large amounts of text that could span
76
- * multiple lines.
70
+ * A component that allows users to input large amounts of text that could span multiple lines.
77
71
  *
78
- * This component gives you a textarea HTML element that automatically adjusts
79
- * its height to match the length of the content within maximum and minimum
80
- * rows. A character counter when a maxLength is set to show the number of
81
- * characters remaining below the limit.
72
+ * This component gives you a textarea HTML element that automatically adjusts its height to match the length of the
73
+ * content within maximum and minimum rows. A character counter when a maxLength is set to show the number of characters
74
+ * remaining below the limit.
82
75
  *
83
76
  * @example
84
77
  * import { useState } from 'react';
@@ -87,14 +80,7 @@ export type TextareaProps = CommonProps<
87
80
  * export function Example() {
88
81
  * const [value, setValue] = useState<string>('');
89
82
  *
90
- * return (
91
- * <Textarea
92
- * aria-label="Example aria-label"
93
- * name="Example name"
94
- * onChange={setValue}
95
- * value={value}
96
- * />
97
- * );
83
+ * return <Textarea aria-label="Example aria-label" name="Example name" onChange={setValue} value={value} />;
98
84
  * }
99
85
  *
100
86
  * @element
@@ -119,14 +105,8 @@ function Textarea({
119
105
  const id = useId(idProp);
120
106
  const invalid = !otherProps.readOnly && !otherProps.disabled && invalidProp;
121
107
  // ensure minRows and maxRows are within bounds
122
- const minRows = Math.min(
123
- DEFAULT.maxRows,
124
- Math.max(minRowsProp, DEFAULT.minRows),
125
- );
126
- const maxRows = Math.max(
127
- DEFAULT.minRows,
128
- Math.min(maxRowsProp, DEFAULT.maxRows),
129
- );
108
+ const minRows = Math.min(DEFAULT.maxRows, Math.max(minRowsProp, DEFAULT.minRows));
109
+ const maxRows = Math.max(DEFAULT.minRows, Math.min(maxRowsProp, DEFAULT.maxRows));
130
110
 
131
111
  return (
132
112
  <div
@@ -155,8 +135,7 @@ function Textarea({
155
135
  const target = event.target as HTMLTextAreaElement;
156
136
  // we know the textarea was resized, so we don't want to auto-size it
157
137
  if (target.style.height) return;
158
- (target.nextSibling as HTMLElement).innerText =
159
- `${target.value}\n`;
138
+ (target.nextSibling as HTMLElement).innerText = `${target.value}\n`;
160
139
  }}
161
140
  placeholder={placeholder}
162
141
  ref={innerRef}
@@ -3,14 +3,10 @@ import { TextareaProps, Textarea } from './Textarea';
3
3
  import { Txt } from './Txt';
4
4
  import { tryIntParse } from './utils/tryIntPsrse';
5
5
 
6
- export type TextareaFieldProps = Pick<
7
- FormFieldProps,
8
- 'controlId' | 'errorMessage' | 'helperText' | 'label'
9
- > &
6
+ export type TextareaFieldProps = Pick<FormFieldProps, 'controlId' | 'errorMessage' | 'helperText' | 'label'> &
10
7
  TextareaProps;
11
8
  /**
12
- * A component that allows users to input large amounts of text that could span
13
- * multiple lines.
9
+ * A component that allows users to input large amounts of text that could span multiple lines.
14
10
  *
15
11
  * This component takes properties from the FormField and Textarea components.
16
12
  *
@@ -49,8 +45,7 @@ function TextareaField({
49
45
  ...textareaProps
50
46
  }: TextareaFieldProps) {
51
47
  const maxLength = tryIntParse(maxLengthProp) || -1;
52
- const errorMessage =
53
- (!readOnly && !disabled && errorMessageProp) || undefined;
48
+ const errorMessage = (!readOnly && !disabled && errorMessageProp) || undefined;
54
49
 
55
50
  if (typeof onChange !== 'function') return null;
56
51
 
package/src/Txt.tsx CHANGED
@@ -30,8 +30,7 @@ export type TxtProps<As extends ElementType = 'span'> = {
30
30
  };
31
31
 
32
32
  /**
33
- * A text component that applies the correct font styles based on the variant
34
- * and size. variant
33
+ * A text component that applies the correct font styles based on the variant and size. variant
35
34
  *
36
35
  * @example
37
36
  * import { Txt } from '@bspk/ui/Txt';
@@ -56,11 +55,7 @@ function Txt<As extends ElementType = 'span'>({
56
55
  const As: ElementType = as || 'span';
57
56
 
58
57
  return (
59
- <As
60
- {...containerProps}
61
- data-bspk="txt"
62
- style={{ ...styleProp, font: `var(--${variant})` }}
63
- >
58
+ <As {...containerProps} data-bspk="txt" style={{ ...styleProp, font: `var(--${variant})` }}>
64
59
  {content}
65
60
  </As>
66
61
  );