@bspk/ui 1.3.4 → 1.3.6
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/dist/components/Avatar/Avatar.d.ts +3 -3
- package/dist/components/Avatar/Avatar.js +8 -8
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/Avatar/AvatarExample.js +1 -1
- package/dist/components/Avatar/AvatarExample.js.map +1 -1
- package/dist/components/Avatar/avatar.css +5 -1
- package/dist/components/Avatar/avatar.css.js +5 -1
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +11 -6
- package/dist/components/AvatarGroup/AvatarGroup.js +5 -6
- package/dist/components/AvatarGroup/AvatarGroup.js.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroupExample.js +36 -9
- package/dist/components/AvatarGroup/AvatarGroupExample.js.map +1 -1
- package/dist/components/AvatarGroup/Overflow.d.ts +11 -0
- package/dist/components/AvatarGroup/Overflow.js +37 -0
- package/dist/components/AvatarGroup/Overflow.js.map +1 -0
- package/dist/components/AvatarGroup/avatar-group.css +27 -13
- package/dist/components/AvatarGroup/avatar-group.css.js +27 -13
- package/dist/components/Badge/BadgeExample.js +1 -1
- package/dist/components/Badge/BadgeExample.js.map +1 -1
- package/dist/components/BadgeDot/BadgeDotExample.js +1 -1
- package/dist/components/BadgeDot/BadgeDotExample.js.map +1 -1
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Card/Card.d.ts +2 -1
- package/dist/components/Card/Card.js +2 -2
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts +2 -2
- package/dist/components/Checkbox/Checkbox.js +2 -2
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +5 -5
- package/dist/components/CheckboxGroup/CheckboxGroup.js +7 -8
- package/dist/components/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/dist/components/CheckboxGroupField/CheckboxGroupField.d.ts +1 -1
- package/dist/components/CheckboxGroupField/CheckboxGroupField.js +2 -2
- package/dist/components/CheckboxGroupField/CheckboxGroupField.js.map +1 -1
- package/dist/components/CheckboxOption/CheckboxOption.d.ts +3 -2
- package/dist/components/CheckboxOption/CheckboxOption.js +2 -2
- package/dist/components/CheckboxOption/CheckboxOption.js.map +1 -1
- package/dist/components/DatePickerField/DatePickerField.d.ts +1 -1
- package/dist/components/DatePickerField/DatePickerField.js +2 -2
- package/dist/components/DatePickerField/DatePickerField.js.map +1 -1
- package/dist/components/Fab/Fab.d.ts +2 -2
- package/dist/components/Fab/Fab.js.map +1 -1
- package/dist/components/Field/utils.d.ts +1 -1
- package/dist/components/FormField/FormField.d.ts +3 -2
- package/dist/components/FormField/FormField.js +2 -2
- package/dist/components/FormField/FormField.js.map +1 -1
- package/dist/components/InputField/InputField.d.ts +1 -1
- package/dist/components/InputField/InputField.js +2 -2
- package/dist/components/InputField/InputField.js.map +1 -1
- package/dist/components/InputNumberField/InputNumberField.d.ts +1 -1
- package/dist/components/InputNumberField/InputNumberField.js +2 -2
- package/dist/components/InputNumberField/InputNumberField.js.map +1 -1
- package/dist/components/InputPhoneField/InputPhoneField.d.ts +1 -1
- package/dist/components/InputPhoneField/InputPhoneField.js +2 -2
- package/dist/components/InputPhoneField/InputPhoneField.js.map +1 -1
- package/dist/components/Layout/Layout.d.ts +2 -2
- package/dist/components/Layout/Layout.js.map +1 -1
- package/dist/components/ListItem/ListItem.d.ts +1 -1
- package/dist/components/Menu/Menu.d.ts +8 -1
- package/dist/components/Menu/Menu.js +1 -1
- package/dist/components/Menu/Menu.js.map +1 -1
- package/dist/components/Menu/MenuExample.js +1 -1
- package/dist/components/Menu/MenuExample.js.map +1 -1
- package/dist/components/PasswordField/PasswordField.d.ts +1 -1
- package/dist/components/PasswordField/PasswordField.js +2 -2
- package/dist/components/PasswordField/PasswordField.js.map +1 -1
- package/dist/components/ProgressCircle/progress-circle.css +2 -0
- package/dist/components/ProgressCircle/progress-circle.css.js +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/RadioGroup/RadioGroup.js +4 -5
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/RadioGroupField/RadioGroupField.d.ts +1 -1
- package/dist/components/RadioGroupField/RadioGroupField.js +2 -2
- package/dist/components/RadioGroupField/RadioGroupField.js.map +1 -1
- package/dist/components/SearchBar/SearchBar.d.ts +2 -2
- package/dist/components/SearchBar/SearchBar.js +2 -2
- package/dist/components/SearchBar/SearchBar.js.map +1 -1
- package/dist/components/Select/Select.d.ts +9 -2
- package/dist/components/Select/Select.js +4 -3
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/SelectExample.js +36 -1
- package/dist/components/Select/SelectExample.js.map +1 -1
- package/dist/components/SelectField/SelectField.d.ts +1 -1
- package/dist/components/SelectField/SelectField.js +2 -2
- package/dist/components/SelectField/SelectField.js.map +1 -1
- package/dist/components/SkeletonText/SkeletonText.js +1 -1
- package/dist/components/SkeletonText/SkeletonText.js.map +1 -1
- package/dist/components/Slider/slider.css +1 -0
- package/dist/components/Slider/slider.css.js +1 -0
- package/dist/components/Switch/Switch.d.ts +1 -7
- package/dist/components/Switch/Switch.js +1 -2
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/Textarea/Textarea.d.ts +3 -9
- package/dist/components/Textarea/Textarea.js +2 -2
- package/dist/components/Textarea/Textarea.js.map +1 -1
- package/dist/components/TextareaField/TextareaField.d.ts +1 -1
- package/dist/components/TextareaField/TextareaField.js +2 -2
- package/dist/components/TextareaField/TextareaField.js.map +1 -1
- package/dist/components/TimePicker/TimePicker.js +10 -4
- package/dist/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/components/TimePickerField/TimePickerField.d.ts +1 -1
- package/dist/components/TimePickerField/TimePickerField.js +2 -2
- package/dist/components/TimePickerField/TimePickerField.js.map +1 -1
- package/dist/components/ToggleOption/ToggleOption.d.ts +3 -3
- package/dist/components/ToggleOption/ToggleOption.js +2 -2
- package/dist/components/ToggleOption/ToggleOption.js.map +1 -1
- package/dist/components/Truncated/Truncated.d.ts +2 -2
- package/dist/components/Truncated/Truncated.js.map +1 -1
- package/dist/components/Txt/Txt.d.ts +2 -2
- package/dist/components/Txt/Txt.js.map +1 -1
- package/dist/hooks/useArrowNavigation.d.ts +0 -2
- package/dist/hooks/useArrowNavigation.js +0 -2
- package/dist/hooks/useArrowNavigation.js.map +1 -1
- package/dist/hooks/useCheckboxGroupState.d.ts +7 -10
- package/dist/hooks/useCheckboxGroupState.js +7 -10
- package/dist/hooks/useCheckboxGroupState.js.map +1 -1
- package/dist/hooks/useFloating.js +8 -7
- package/dist/hooks/useFloating.js.map +1 -1
- package/dist/styles/base.css +4 -0
- package/dist/styles/base.css.js +4 -0
- package/dist/types/common.d.ts +12 -1
- package/dist/types/common.js.map +1 -1
- package/meta.ts +4 -4
- package/package.json +1 -3
- package/src/components/Avatar/Avatar.tsx +10 -11
- package/src/components/Avatar/AvatarExample.tsx +1 -1
- package/src/components/Avatar/avatar.scss +6 -1
- package/src/components/AvatarGroup/AvatarGroup.tsx +20 -24
- package/src/components/AvatarGroup/AvatarGroupExample.tsx +35 -9
- package/src/components/AvatarGroup/Overflow.tsx +91 -0
- package/src/components/AvatarGroup/avatar-group.scss +34 -14
- package/src/components/Badge/BadgeExample.tsx +1 -1
- package/src/components/BadgeDot/BadgeDotExample.tsx +1 -1
- package/src/components/Button/Button.tsx +2 -2
- package/src/components/Card/Card.tsx +3 -2
- package/src/components/Checkbox/Checkbox.tsx +3 -8
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +5 -10
- package/src/components/CheckboxGroupField/CheckboxGroupField.tsx +3 -2
- package/src/components/CheckboxOption/CheckboxOption.tsx +5 -4
- package/src/components/DatePickerField/DatePickerField.tsx +8 -1
- package/src/components/Fab/Fab.tsx +2 -2
- package/src/components/Field/utils.ts +1 -1
- package/src/components/FormField/FormField.tsx +13 -3
- package/src/components/InputField/InputField.tsx +15 -2
- package/src/components/InputNumberField/InputNumberField.tsx +8 -1
- package/src/components/InputPhoneField/InputPhoneField.tsx +8 -1
- package/src/components/Layout/Layout.tsx +2 -2
- package/src/components/ListItem/ListItem.tsx +1 -1
- package/src/components/Menu/Menu.tsx +9 -1
- package/src/components/Menu/MenuExample.tsx +1 -1
- package/src/components/PasswordField/PasswordField.tsx +15 -2
- package/src/components/ProgressCircle/progress-circle.scss +2 -0
- package/src/components/RadioGroup/RadioGroup.tsx +18 -22
- package/src/components/RadioGroupField/RadioGroupField.tsx +2 -1
- package/src/components/SearchBar/SearchBar.tsx +3 -1
- package/src/components/Select/Select.tsx +12 -3
- package/src/components/Select/SelectExample.tsx +36 -1
- package/src/components/SelectField/SelectField.tsx +15 -2
- package/src/components/SkeletonText/SkeletonText.tsx +1 -1
- package/src/components/Slider/slider.scss +1 -0
- package/src/components/Switch/Switch.tsx +1 -9
- package/src/components/Textarea/Textarea.tsx +34 -39
- package/src/components/TextareaField/TextareaField.tsx +15 -2
- package/src/components/TimePicker/TimePicker.tsx +13 -3
- package/src/components/TimePickerField/TimePickerField.tsx +8 -1
- package/src/components/ToggleOption/ToggleOption.tsx +20 -19
- package/src/components/Truncated/Truncated.tsx +2 -2
- package/src/components/Txt/Txt.tsx +2 -2
- package/src/hooks/useArrowNavigation.ts +0 -2
- package/src/hooks/useCheckboxGroupState.ts +7 -10
- package/src/hooks/useFloating.ts +8 -7
- package/src/styles/base.scss +4 -0
- package/src/types/common.ts +11 -0
- package/dist/components/MenuButton/MenuButton.d.ts +0 -19
- package/dist/components/MenuButton/MenuButton.js +0 -20
- package/dist/components/MenuButton/MenuButton.js.map +0 -1
- package/dist/components/MenuButton/index.d.ts +0 -1
- package/dist/components/MenuButton/index.js +0 -2
- package/dist/components/MenuButton/index.js.map +0 -1
- package/dist/components/MenuButton/menu-button.css +0 -16
- package/dist/components/MenuButton/menu-button.css.js +0 -21
- package/src/components/MenuButton/MenuButton.rtl.test.tsx +0 -15
- package/src/components/MenuButton/MenuButton.tsx +0 -29
- package/src/components/MenuButton/index.tsx +0 -1
- package/src/components/MenuButton/menu-button.scss +0 -16
|
@@ -3,7 +3,7 @@ import { SvgKeyboardArrowDown } from '@bspk/icons/KeyboardArrowDown';
|
|
|
3
3
|
import { useMemo, KeyboardEvent, MouseEvent } from 'react';
|
|
4
4
|
import { useFieldInit } from '-/components/Field';
|
|
5
5
|
import { ListItem, ListItemProps } from '-/components/ListItem';
|
|
6
|
-
import { Menu } from '-/components/Menu';
|
|
6
|
+
import { Menu, MenuProps } from '-/components/Menu';
|
|
7
7
|
import { useArrowNavigation } from '-/hooks/useArrowNavigation';
|
|
8
8
|
import { useFloating } from '-/hooks/useFloating';
|
|
9
9
|
import { useOutsideClick } from '-/hooks/useOutsideClick';
|
|
@@ -18,7 +18,7 @@ import { scrollListItemsStyle, ScrollListItemsStyleProps } from '-/utils/scrollL
|
|
|
18
18
|
* Essentially the props of ListItemProps.
|
|
19
19
|
*/
|
|
20
20
|
export type SelectOption = CommonProps<'disabled'> &
|
|
21
|
-
Omit<ListItemProps, 'id' | 'onClick' | '
|
|
21
|
+
Omit<ListItemProps, 'id' | 'onClick' | 'value'> & { value: string };
|
|
22
22
|
|
|
23
23
|
export type SelectItem = SelectOption & { id: string };
|
|
24
24
|
|
|
@@ -52,6 +52,12 @@ export type SelectProps = CommonProps<'size'> &
|
|
|
52
52
|
* @default Select one
|
|
53
53
|
*/
|
|
54
54
|
placeholder?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The width of the menu.
|
|
57
|
+
*
|
|
58
|
+
* If not provided, the menu will match the width of the select control.
|
|
59
|
+
*/
|
|
60
|
+
menuWidth?: MenuProps['width'];
|
|
55
61
|
};
|
|
56
62
|
|
|
57
63
|
/**
|
|
@@ -126,6 +132,7 @@ export function Select({
|
|
|
126
132
|
scrollLimit,
|
|
127
133
|
required = false,
|
|
128
134
|
'aria-label': ariaLabel,
|
|
135
|
+
menuWidth,
|
|
129
136
|
...elementProps
|
|
130
137
|
}: ElementProps<SelectProps, 'button'>) {
|
|
131
138
|
const { id, ariaDescribedBy, ariaErrorMessage, invalid } = useFieldInit({
|
|
@@ -162,7 +169,8 @@ export function Select({
|
|
|
162
169
|
const { elements, floatingStyles } = useFloating({
|
|
163
170
|
hide: !open,
|
|
164
171
|
offsetOptions: 4,
|
|
165
|
-
|
|
172
|
+
//match reference width if menuWidth not provided
|
|
173
|
+
refWidth: !menuWidth,
|
|
166
174
|
});
|
|
167
175
|
|
|
168
176
|
useOutsideClick({
|
|
@@ -266,6 +274,7 @@ export function Select({
|
|
|
266
274
|
...floatingStyles,
|
|
267
275
|
}}
|
|
268
276
|
tabIndex={-1}
|
|
277
|
+
width={menuWidth}
|
|
269
278
|
>
|
|
270
279
|
{items.map((item) => {
|
|
271
280
|
const isActive = activeElementId === item.id;
|
|
@@ -30,6 +30,37 @@ export const presets: Preset<SelectProps>[] = [
|
|
|
30
30
|
options: DEFAULT_OPTIONS,
|
|
31
31
|
name: 'demo-select',
|
|
32
32
|
value: '',
|
|
33
|
+
menuWidth: '',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: 'SubText',
|
|
38
|
+
propState: {
|
|
39
|
+
options: [
|
|
40
|
+
{
|
|
41
|
+
value: 'Claude 3.7 Sonnet',
|
|
42
|
+
label: 'Claude 3.7 Sonnet',
|
|
43
|
+
subText: 'bedrock • us.anthropic.claude-3-7-sonnet-20250219-v1:0',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
value: 'Claude 4 Sonnet',
|
|
47
|
+
label: 'Claude 4 Sonnet',
|
|
48
|
+
subText: 'bedrock • us.anthropic.claude-sonnet-4-20250514-v1:0',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
value: 'Claude 4.5 Sonnet',
|
|
52
|
+
label: 'Claude 4.5 Sonnet',
|
|
53
|
+
subText: 'bedrock • us.anthropic.claude-sonnet-4-5-20250929-v1:0',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
value: 'GPT 4.1',
|
|
57
|
+
label: 'GPT 4.1',
|
|
58
|
+
subText: 'azure • gpt-41',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
name: 'demo-select-long',
|
|
62
|
+
value: '',
|
|
63
|
+
menuWidth: '600px',
|
|
33
64
|
},
|
|
34
65
|
},
|
|
35
66
|
{
|
|
@@ -43,6 +74,7 @@ export const presets: Preset<SelectProps>[] = [
|
|
|
43
74
|
],
|
|
44
75
|
name: 'demo-select-long',
|
|
45
76
|
value: '',
|
|
77
|
+
menuWidth: '',
|
|
46
78
|
},
|
|
47
79
|
},
|
|
48
80
|
{
|
|
@@ -65,6 +97,7 @@ export const presets: Preset<SelectProps>[] = [
|
|
|
65
97
|
],
|
|
66
98
|
name: 'demo-select-tags',
|
|
67
99
|
value: 'a',
|
|
100
|
+
menuWidth: '',
|
|
68
101
|
},
|
|
69
102
|
},
|
|
70
103
|
{
|
|
@@ -82,6 +115,7 @@ export const presets: Preset<SelectProps>[] = [
|
|
|
82
115
|
],
|
|
83
116
|
name: 'demo-select-trailing',
|
|
84
117
|
value: '',
|
|
118
|
+
menuWidth: '',
|
|
85
119
|
},
|
|
86
120
|
},
|
|
87
121
|
{
|
|
@@ -112,6 +146,7 @@ export const presets: Preset<SelectProps>[] = [
|
|
|
112
146
|
],
|
|
113
147
|
name: 'demo-select-avatar',
|
|
114
148
|
value: '',
|
|
149
|
+
menuWidth: '',
|
|
115
150
|
},
|
|
116
151
|
},
|
|
117
152
|
];
|
|
@@ -122,6 +157,6 @@ export const SelectExample: ComponentExample<SelectProps> = {
|
|
|
122
157
|
scrollLimit: 5,
|
|
123
158
|
value: '',
|
|
124
159
|
},
|
|
125
|
-
render: ({ props, Component }) => <Component {...props} />,
|
|
160
|
+
render: ({ props, Component, preset }) => <Component key={preset?.label} {...props} />,
|
|
126
161
|
presets,
|
|
127
162
|
};
|
|
@@ -13,9 +13,22 @@ export type SelectFieldProps = FormFieldControlProps<SelectProps>;
|
|
|
13
13
|
*
|
|
14
14
|
* @generated
|
|
15
15
|
*/
|
|
16
|
-
export function SelectField({
|
|
16
|
+
export function SelectField({
|
|
17
|
+
label,
|
|
18
|
+
helperText,
|
|
19
|
+
labelTrailing,
|
|
20
|
+
errorMessage,
|
|
21
|
+
style,
|
|
22
|
+
...controlProps
|
|
23
|
+
}: SelectFieldProps) {
|
|
17
24
|
return (
|
|
18
|
-
<FormField
|
|
25
|
+
<FormField
|
|
26
|
+
errorMessage={errorMessage}
|
|
27
|
+
helperText={helperText}
|
|
28
|
+
label={label}
|
|
29
|
+
labelTrailing={labelTrailing}
|
|
30
|
+
style={style}
|
|
31
|
+
>
|
|
19
32
|
<Select {...controlProps} />
|
|
20
33
|
</FormField>
|
|
21
34
|
);
|
|
@@ -48,7 +48,7 @@ export type SkeletonTextProps = {
|
|
|
48
48
|
* @name SkeletonText
|
|
49
49
|
* @phase UXReview
|
|
50
50
|
*/
|
|
51
|
-
export function SkeletonText({ lines = 3, variant, children = null }: SkeletonTextProps) {
|
|
51
|
+
export function SkeletonText({ lines = 3, variant = 'body-base', children = null }: SkeletonTextProps) {
|
|
52
52
|
return children !== null && children !== undefined && children !== false ? (
|
|
53
53
|
children
|
|
54
54
|
) : (
|
|
@@ -16,12 +16,6 @@ export type SwitchProps = CommonProps<'aria-label' | 'disabled' | 'name'> & {
|
|
|
16
16
|
* @required
|
|
17
17
|
*/
|
|
18
18
|
onChange: (checked: boolean, event: ChangeEvent<HTMLInputElement>) => void;
|
|
19
|
-
/**
|
|
20
|
-
* Only exists as a alias for `disabled` and to match other input properties.
|
|
21
|
-
*
|
|
22
|
-
* @default false
|
|
23
|
-
*/
|
|
24
|
-
readOnly?: boolean;
|
|
25
19
|
/** The value of the switch. */
|
|
26
20
|
value: string;
|
|
27
21
|
};
|
|
@@ -53,9 +47,7 @@ export type SwitchProps = CommonProps<'aria-label' | 'disabled' | 'name'> & {
|
|
|
53
47
|
* @name Switch
|
|
54
48
|
* @phase UXReview
|
|
55
49
|
*/
|
|
56
|
-
export function Switch({ checked = false, disabled
|
|
57
|
-
const disabled = readOnly || disabledProp;
|
|
58
|
-
|
|
50
|
+
export function Switch({ checked = false, disabled = false, ...props }: SwitchProps) {
|
|
59
51
|
return (
|
|
60
52
|
<span data-bspk="switch">
|
|
61
53
|
<input
|
|
@@ -1,45 +1,40 @@
|
|
|
1
1
|
import './textarea.scss';
|
|
2
2
|
import { ChangeEvent, useRef } from 'react';
|
|
3
3
|
import { useFieldInit } from '-/components/Field';
|
|
4
|
-
import { FieldControlProps, SetRef } from '-/types/common';
|
|
4
|
+
import { CommonProps, FieldControlProps, SetRef } from '-/types/common';
|
|
5
5
|
import { cssWithVars } from '-/utils/cwv';
|
|
6
6
|
|
|
7
|
-
export type TextareaProps =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* @minimum 3
|
|
39
|
-
* @maximum 10
|
|
40
|
-
*/
|
|
41
|
-
maxRows?: number;
|
|
42
|
-
};
|
|
7
|
+
export type TextareaProps = CommonProps<'size'> &
|
|
8
|
+
FieldControlProps<string, ChangeEvent<HTMLTextAreaElement>> & {
|
|
9
|
+
/** The ref of the field. */
|
|
10
|
+
innerRef?: SetRef<HTMLTextAreaElement>;
|
|
11
|
+
/** The placeholder of the field. */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The maximum number of characters that the field will accept.
|
|
15
|
+
*
|
|
16
|
+
* @minimum 1
|
|
17
|
+
*/
|
|
18
|
+
maxLength?: number;
|
|
19
|
+
/**
|
|
20
|
+
* The minimum number of rows that the textarea will show.
|
|
21
|
+
*
|
|
22
|
+
* @default 3
|
|
23
|
+
* @minimum 3
|
|
24
|
+
* @maximum 10
|
|
25
|
+
*/
|
|
26
|
+
minRows?: number;
|
|
27
|
+
/**
|
|
28
|
+
* The maximum number of rows that the textarea will show.
|
|
29
|
+
*
|
|
30
|
+
* When set the textarea will automatically adjust its height to fit the content up to this limit.
|
|
31
|
+
*
|
|
32
|
+
* @default 10
|
|
33
|
+
* @minimum 3
|
|
34
|
+
* @maximum 10
|
|
35
|
+
*/
|
|
36
|
+
maxRows?: number;
|
|
37
|
+
};
|
|
43
38
|
|
|
44
39
|
/**
|
|
45
40
|
* A component that allows users to input large amounts of text that could span multiple lines.
|
|
@@ -79,7 +74,7 @@ export type TextareaProps = FieldControlProps<string, ChangeEvent<HTMLTextAreaEl
|
|
|
79
74
|
export function Textarea({
|
|
80
75
|
invalid: invalidProp,
|
|
81
76
|
onChange,
|
|
82
|
-
|
|
77
|
+
size = 'medium',
|
|
83
78
|
value = '',
|
|
84
79
|
name,
|
|
85
80
|
innerRef,
|
|
@@ -117,7 +112,7 @@ export function Textarea({
|
|
|
117
112
|
data-disabled={disabled || undefined}
|
|
118
113
|
data-invalid={invalid || undefined}
|
|
119
114
|
data-read-only={readOnly || undefined}
|
|
120
|
-
data-size={
|
|
115
|
+
data-size={size}
|
|
121
116
|
style={cssWithVars({
|
|
122
117
|
'--min-rows': minRows,
|
|
123
118
|
'--max-rows': maxRows,
|
|
@@ -13,9 +13,22 @@ export type TextareaFieldProps = FormFieldControlProps<TextareaProps>;
|
|
|
13
13
|
*
|
|
14
14
|
* @generated
|
|
15
15
|
*/
|
|
16
|
-
export function TextareaField({
|
|
16
|
+
export function TextareaField({
|
|
17
|
+
label,
|
|
18
|
+
helperText,
|
|
19
|
+
labelTrailing,
|
|
20
|
+
errorMessage,
|
|
21
|
+
style,
|
|
22
|
+
...controlProps
|
|
23
|
+
}: TextareaFieldProps) {
|
|
17
24
|
return (
|
|
18
|
-
<FormField
|
|
25
|
+
<FormField
|
|
26
|
+
errorMessage={errorMessage}
|
|
27
|
+
helperText={helperText}
|
|
28
|
+
label={label}
|
|
29
|
+
labelTrailing={labelTrailing}
|
|
30
|
+
style={style}
|
|
31
|
+
>
|
|
19
32
|
<Textarea {...controlProps} />
|
|
20
33
|
</FormField>
|
|
21
34
|
);
|
|
@@ -99,7 +99,7 @@ export function TimePicker({
|
|
|
99
99
|
|
|
100
100
|
const { floatingStyles, elements } = useFloating({
|
|
101
101
|
strategy: 'fixed',
|
|
102
|
-
refWidth:
|
|
102
|
+
refWidth: false,
|
|
103
103
|
offsetOptions: 4,
|
|
104
104
|
hide: !open,
|
|
105
105
|
});
|
|
@@ -230,7 +230,7 @@ export function TimePicker({
|
|
|
230
230
|
variant="tertiary"
|
|
231
231
|
/>
|
|
232
232
|
</div>
|
|
233
|
-
{
|
|
233
|
+
{open && (
|
|
234
234
|
<Portal>
|
|
235
235
|
<Menu
|
|
236
236
|
id={menuId}
|
|
@@ -241,6 +241,7 @@ export function TimePicker({
|
|
|
241
241
|
label="Select time"
|
|
242
242
|
owner="time-picker"
|
|
243
243
|
style={floatingStyles}
|
|
244
|
+
width="fit-content"
|
|
244
245
|
>
|
|
245
246
|
<FocusTrap
|
|
246
247
|
focusTrapOptions={{
|
|
@@ -256,7 +257,16 @@ export function TimePicker({
|
|
|
256
257
|
minutes: node?.querySelector('[data-scroll-column="minutes"]') as HTMLElement,
|
|
257
258
|
meridiem: node?.querySelector('[data-scroll-column="meridiem"]') as HTMLElement,
|
|
258
259
|
};
|
|
259
|
-
|
|
260
|
+
const activeHour =
|
|
261
|
+
listBoxRefs.current.hours?.querySelector<HTMLElement>('[data-active]');
|
|
262
|
+
const activeMinute =
|
|
263
|
+
listBoxRefs.current.minutes?.querySelector<HTMLElement>('[data-active]');
|
|
264
|
+
const activeMeridiem =
|
|
265
|
+
listBoxRefs.current.meridiem?.querySelector<HTMLElement>('[data-active]');
|
|
266
|
+
activeHour?.scrollIntoView({ block: 'nearest' });
|
|
267
|
+
activeMinute?.scrollIntoView({ block: 'nearest' });
|
|
268
|
+
activeMeridiem?.scrollIntoView({ block: 'nearest' });
|
|
269
|
+
activeHour?.focus();
|
|
260
270
|
}}
|
|
261
271
|
>
|
|
262
272
|
<TimePickerListbox
|
|
@@ -18,10 +18,17 @@ export function TimePickerField({
|
|
|
18
18
|
helperText,
|
|
19
19
|
labelTrailing,
|
|
20
20
|
errorMessage,
|
|
21
|
+
style,
|
|
21
22
|
...controlProps
|
|
22
23
|
}: TimePickerFieldProps) {
|
|
23
24
|
return (
|
|
24
|
-
<FormField
|
|
25
|
+
<FormField
|
|
26
|
+
errorMessage={errorMessage}
|
|
27
|
+
helperText={helperText}
|
|
28
|
+
label={label}
|
|
29
|
+
labelTrailing={labelTrailing}
|
|
30
|
+
style={style}
|
|
31
|
+
>
|
|
25
32
|
<TimePicker {...controlProps} />
|
|
26
33
|
</FormField>
|
|
27
34
|
);
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import './toggle-option.scss';
|
|
2
2
|
import { ReactElement } from 'react';
|
|
3
|
-
import { ListItem } from '-/components/ListItem';
|
|
3
|
+
import { ListItem, ListItemProps } from '-/components/ListItem';
|
|
4
4
|
import { CommonProps } from '-/types/common';
|
|
5
5
|
|
|
6
6
|
export type ToggleOptionControlProps<T extends { 'aria-label'?: string }> = Omit<T, 'aria-label'> &
|
|
7
7
|
Pick<ToggleOptionProps, 'description' | 'label'>;
|
|
8
8
|
|
|
9
|
-
export type ToggleOptionProps = CommonProps<'disabled' | 'readOnly'> &
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
9
|
+
export type ToggleOptionProps = CommonProps<'disabled' | 'readOnly'> &
|
|
10
|
+
Omit<ListItemProps, 'as' | 'label' | 'leading' | 'subtext' | 'trailing'> & {
|
|
11
|
+
/**
|
|
12
|
+
* The label of the option. Also used as the aria-label of the control.
|
|
13
|
+
*
|
|
14
|
+
* @required
|
|
15
|
+
*/
|
|
16
|
+
label: string;
|
|
17
|
+
/**
|
|
18
|
+
* The description of the option.
|
|
19
|
+
*
|
|
20
|
+
* @type multiline
|
|
21
|
+
*/
|
|
22
|
+
description?: string;
|
|
23
|
+
/** The control element to use. */
|
|
24
|
+
children?: ReactElement;
|
|
25
|
+
};
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* A utility component that wraps a checkbox, radio, and switch.
|
|
@@ -30,9 +30,10 @@ export type ToggleOptionProps = CommonProps<'disabled' | 'readOnly'> & {
|
|
|
30
30
|
* @name ToggleOption
|
|
31
31
|
* @phase Utility
|
|
32
32
|
*/
|
|
33
|
-
export function ToggleOption({ label, description, children, disabled, readOnly }: ToggleOptionProps) {
|
|
33
|
+
export function ToggleOption({ label, description, children, disabled, readOnly, ...props }: ToggleOptionProps) {
|
|
34
34
|
return (
|
|
35
35
|
<ListItem
|
|
36
|
+
{...props}
|
|
36
37
|
as="label"
|
|
37
38
|
data-disabled={disabled}
|
|
38
39
|
data-readonly={readOnly}
|
|
@@ -4,7 +4,7 @@ import { Tooltip, TooltipTriggerProps } from '-/components/Tooltip';
|
|
|
4
4
|
import { useTruncatedText } from '-/hooks/useTruncatedText';
|
|
5
5
|
import { ElementConstructorProps } from '-/types/common';
|
|
6
6
|
|
|
7
|
-
export type TruncatedProps<As extends ElementType =
|
|
7
|
+
export type TruncatedProps<As extends ElementType = ElementType> = {
|
|
8
8
|
/**
|
|
9
9
|
* The element type to render as.
|
|
10
10
|
*
|
|
@@ -35,7 +35,7 @@ export type TruncatedProps<As extends ElementType = 'span'> = {
|
|
|
35
35
|
* @name Truncated
|
|
36
36
|
* @phase Utility
|
|
37
37
|
*/
|
|
38
|
-
export function Truncated<As extends ElementType =
|
|
38
|
+
export function Truncated<As extends ElementType = ElementType>({
|
|
39
39
|
children,
|
|
40
40
|
label,
|
|
41
41
|
...props
|
|
@@ -4,7 +4,7 @@ import { SkeletonText } from '-/components/SkeletonText';
|
|
|
4
4
|
import { ElementProps } from '-/types/common';
|
|
5
5
|
import { TxtVariant } from '-/utils/txtVariants';
|
|
6
6
|
|
|
7
|
-
export type TxtProps<As extends ElementType =
|
|
7
|
+
export type TxtProps<As extends ElementType = ElementType> = {
|
|
8
8
|
/**
|
|
9
9
|
* The element type to render as.
|
|
10
10
|
*
|
|
@@ -56,7 +56,7 @@ export type TxtProps<As extends ElementType = 'span'> = {
|
|
|
56
56
|
* @name Txt
|
|
57
57
|
* @phase UXReview
|
|
58
58
|
*/
|
|
59
|
-
export function Txt<As extends ElementType =
|
|
59
|
+
export function Txt<As extends ElementType = ElementType>({
|
|
60
60
|
children,
|
|
61
61
|
as,
|
|
62
62
|
variant = 'body-base',
|
|
@@ -39,9 +39,7 @@ type UseArrowNavigationProps = {
|
|
|
39
39
|
* A hook to manage arrow key navigation for a list of elements.
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
42
|
-
* ```tsx
|
|
43
42
|
* const { activeElementId, setActiveElementId, arrowKeyCallbacks } = useArrowNavigation(['id1', 'id2', 'id3']);
|
|
44
|
-
* ```;
|
|
45
43
|
*
|
|
46
44
|
* @returns An object containing:
|
|
47
45
|
*
|
|
@@ -6,22 +6,19 @@ import { CheckboxProps } from '-/components/Checkbox';
|
|
|
6
6
|
* A hook to manage the state of a group of checkboxes. Used alongside the CheckboxGroup component.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
|
-
* import { Checkbox } from
|
|
10
|
-
* import { useCheckboxGroupState } from
|
|
9
|
+
* import { Checkbox } from '@bspk/ui/Checkbox';
|
|
10
|
+
* import { useCheckboxGroupState } from '@bspk/ui/hooks/useCheckboxGroupState';
|
|
11
11
|
*
|
|
12
12
|
* function Example() {
|
|
13
|
-
* const allValues = [
|
|
14
|
-
*
|
|
15
|
-
* const { allCheckboxProps, checkboxProps, values } = useCheckboxGroupState(allValues, "fruits");
|
|
16
|
-
*
|
|
13
|
+
* const allValues = ['Red', 'Orange', 'Yellow', 'Green'];
|
|
14
|
+
* const { allCheckboxProps, checkboxProps, values } = useCheckboxGroupState(allValues, 'fruits');
|
|
17
15
|
* return (
|
|
18
|
-
*
|
|
19
|
-
* <pre>Selected Values: {values.join(
|
|
20
|
-
* <Checkbox aria-label="All" {...allCheckboxProps} />
|
|
16
|
+
* <div>
|
|
17
|
+
* <pre>Selected Values: {values.join(', ')}</pre> <Checkbox aria-label="All" {...allCheckboxProps} />{' '}
|
|
21
18
|
* {allValues.map((value) => (
|
|
22
19
|
* <Checkbox key={value} aria-label={value} {...checkboxProps(value)} />
|
|
23
20
|
* ))}
|
|
24
|
-
*
|
|
21
|
+
* </div>
|
|
25
22
|
* );
|
|
26
23
|
* }
|
|
27
24
|
*
|
package/src/hooks/useFloating.ts
CHANGED
|
@@ -158,13 +158,14 @@ export function useFloating({
|
|
|
158
158
|
arrowRef?.current && arrow({ element: arrowRef.current, padding: 8 }),
|
|
159
159
|
offset(offsetOptions),
|
|
160
160
|
flip(),
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
161
|
+
refWidth &&
|
|
162
|
+
size({
|
|
163
|
+
apply({ rects, elements }: MiddlewareState) {
|
|
164
|
+
Object.assign(elements.floating.style, {
|
|
165
|
+
width: `${rects.reference.width}px`,
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
}),
|
|
168
169
|
],
|
|
169
170
|
}).then((value: ComputePositionReturn) => {
|
|
170
171
|
setFloatingStyles(() => ({
|
package/src/styles/base.scss
CHANGED
package/src/types/common.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
AriaRole,
|
|
14
14
|
ChangeEvent,
|
|
15
15
|
KeyboardEvent,
|
|
16
|
+
CSSProperties,
|
|
16
17
|
} from 'react';
|
|
17
18
|
|
|
18
19
|
export type AlertVariant = 'error' | 'informational' | 'success' | 'warning';
|
|
@@ -31,6 +32,10 @@ export type ElementConstructorProps<
|
|
|
31
32
|
O extends string = '',
|
|
32
33
|
> = Omit<ComponentPropsWithoutRef<E>, O>;
|
|
33
34
|
|
|
35
|
+
type CSSVariables = `--${string}`;
|
|
36
|
+
|
|
37
|
+
export type CSSWithVariables = CSSProperties | (CSSProperties & { [key in CSSVariables]: unknown });
|
|
38
|
+
|
|
34
39
|
export type DataProps = Record<`data-${string}`, string>;
|
|
35
40
|
|
|
36
41
|
export type ButtonSize = 'large' | 'medium' | 'small' | 'x-small';
|
|
@@ -129,6 +134,12 @@ export type CommonPropsLibrary = {
|
|
|
129
134
|
* @type string
|
|
130
135
|
*/
|
|
131
136
|
role?: AriaRole;
|
|
137
|
+
/**
|
|
138
|
+
* Inline styles to apply to the element.
|
|
139
|
+
*
|
|
140
|
+
* Allows for CSS variables to be passed in as well.
|
|
141
|
+
*/
|
|
142
|
+
style?: CSSWithVariables;
|
|
132
143
|
};
|
|
133
144
|
|
|
134
145
|
export type CommonProps<K extends keyof CommonPropsLibrary> = Pick<CommonPropsLibrary, K>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import './menu-button.scss';
|
|
2
|
-
import { ButtonProps } from '-/components/Button';
|
|
3
|
-
import { ElementProps } from '-/types/common';
|
|
4
|
-
export type MenuButtonProps = Pick<ButtonProps, 'as' | 'onClick'>;
|
|
5
|
-
/**
|
|
6
|
-
* Utility component used within top navigation.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* import { MenuButton } from '@bspk/ui/MenuButton';
|
|
10
|
-
*
|
|
11
|
-
* function Example() {
|
|
12
|
-
* return <MenuButton />;
|
|
13
|
-
* }
|
|
14
|
-
*
|
|
15
|
-
* @name MenuButton
|
|
16
|
-
* @phase Utility
|
|
17
|
-
*/
|
|
18
|
-
export declare function MenuButton(props: ElementProps<MenuButtonProps, 'button'>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import './menu-button.css.js';
|
|
3
|
-
import { SvgMenu } from '@bspk/icons/Menu';
|
|
4
|
-
/**
|
|
5
|
-
* Utility component used within top navigation.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* import { MenuButton } from '@bspk/ui/MenuButton';
|
|
9
|
-
*
|
|
10
|
-
* function Example() {
|
|
11
|
-
* return <MenuButton />;
|
|
12
|
-
* }
|
|
13
|
-
*
|
|
14
|
-
* @name MenuButton
|
|
15
|
-
* @phase Utility
|
|
16
|
-
*/
|
|
17
|
-
export function MenuButton(props) {
|
|
18
|
-
return (_jsx("button", { "data-bspk": "menu-button", ...props, children: _jsx(SvgMenu, {}) }));
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=MenuButton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MenuButton.js","sourceRoot":"","sources":["../../../src/components/MenuButton/MenuButton.tsx"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU,CAAC,KAA8C;IACrE,OAAO,CACH,8BAAkB,aAAa,KAAK,KAAK,YACrC,KAAC,OAAO,KAAG,GACN,CACZ,CAAC;AACN,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './MenuButton';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/MenuButton/index.tsx"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|