@bspk/ui 1.3.6 → 1.3.7
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/AvatarGroup/AvatarGroup.d.ts +2 -2
- package/dist/components/AvatarGroup/Overflow.d.ts +1 -2
- package/dist/components/BadgeDot/BadgeDot.d.ts +1 -2
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/components/Breadcrumb/{BreadcumbDropdown.d.ts → BreadcrumbDropdown.d.ts} +1 -2
- package/dist/components/Breadcrumb/{BreadcumbDropdown.js → BreadcrumbDropdown.js} +1 -1
- package/dist/components/Breadcrumb/BreadcrumbDropdown.js.map +1 -0
- package/dist/components/Breadcrumb/index.d.ts +1 -0
- package/dist/components/Breadcrumb/index.js +1 -0
- package/dist/components/Breadcrumb/index.js.map +1 -1
- package/dist/components/Calendar/Calendar.d.ts +32 -0
- package/dist/components/Checkbox/CheckboxExample.d.ts +3 -0
- package/dist/components/Checkbox/CheckboxExample.js +5 -0
- package/dist/components/Checkbox/CheckboxExample.js.map +1 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +3 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.js +2 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroupExample.js +12 -0
- package/dist/components/CheckboxGroup/CheckboxGroupExample.js.map +1 -1
- package/dist/components/CheckboxGroupField/CheckboxGroupFieldExample.d.ts +4 -0
- package/dist/components/CheckboxGroupField/CheckboxGroupFieldExample.js +15 -0
- package/dist/components/CheckboxGroupField/CheckboxGroupFieldExample.js.map +1 -0
- package/dist/components/Chip/Chip.d.ts +1 -1
- package/dist/components/Field/field.css +2 -0
- package/dist/components/Field/field.css.js +2 -0
- package/dist/components/FormField/FormFieldExample.d.ts +1 -2
- package/dist/components/Input/InputElement.d.ts +1 -2
- package/dist/components/Input/InputExample.d.ts +1 -2
- package/dist/components/Modal/Modal.d.ts +0 -2
- package/dist/components/Modal/Modal.js +0 -2
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/PageControl/PageControl.d.ts +3 -2
- package/dist/components/Pagination/PageInput.d.ts +1 -2
- package/dist/components/Portal/Portal.d.ts +1 -5
- package/dist/components/Portal/Portal.js.map +1 -1
- package/dist/components/Radio/RadioExample.js +1 -1
- package/dist/components/Radio/RadioExample.js.map +1 -1
- package/dist/components/Radio/radio.css +2 -1
- package/dist/components/Radio/radio.css.js +2 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +3 -1
- package/dist/components/RadioGroup/RadioGroup.js +2 -0
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/RadioGroup/RadioGroupExample.d.ts +2 -2
- package/dist/components/RadioGroup/RadioGroupExample.js +72 -4
- package/dist/components/RadioGroup/RadioGroupExample.js.map +1 -1
- package/dist/components/RadioGroupField/RadioGroupFieldExample.d.ts +4 -0
- package/dist/components/RadioGroupField/RadioGroupFieldExample.js +15 -0
- package/dist/components/RadioGroupField/RadioGroupFieldExample.js.map +1 -0
- package/dist/components/SearchBar/SearchBar.d.ts +2 -2
- package/dist/components/SearchBar/SearchBar.js +10 -12
- package/dist/components/SearchBar/SearchBar.js.map +1 -1
- package/dist/components/Slider/SliderIntervalDots.d.ts +1 -2
- package/dist/components/Switch/SwitchExample.d.ts +3 -0
- package/dist/components/Switch/SwitchExample.js +5 -0
- package/dist/components/Switch/SwitchExample.js.map +1 -0
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/Table/index.js +1 -0
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/TimePicker/Listbox.d.ts +2 -3
- package/dist/components/TimePicker/Segment.d.ts +1 -2
- package/dist/components/ToggleOption/ToggleOption.d.ts +2 -2
- package/dist/components/ToggleOption/ToggleOption.js +2 -2
- package/dist/components/ToggleOption/ToggleOption.js.map +1 -1
- package/dist/hooks/useArrowNavigation.d.ts +2 -3
- package/dist/hooks/useDebounceCallback.d.ts +1 -2
- package/dist/hooks/useDebounceState.d.ts +0 -1
- package/dist/hooks/useDebounceState.js +0 -1
- package/dist/hooks/useDebounceState.js.map +1 -1
- package/dist/hooks/useOutsideClick.d.ts +4 -5
- package/dist/hooks/useOutsideClick.js +5 -5
- package/dist/hooks/useOutsideClick.js.map +1 -1
- package/dist/hooks/useTimeout.d.ts +1 -2
- package/dist/types/common.d.ts +5 -8
- package/dist/types/common.js.map +1 -1
- package/dist/utils/countryCodes.d.ts +1 -2
- package/dist/utils/createExampleChildElement.d.ts +1 -2
- package/dist/utils/demo.d.ts +1 -2
- package/package.json +1 -1
- package/src/components/AvatarGroup/AvatarGroup.tsx +2 -2
- package/src/components/AvatarGroup/Overflow.tsx +1 -1
- package/src/components/BadgeDot/BadgeDot.tsx +1 -1
- package/src/components/Breadcrumb/Breadcrumb.tsx +1 -1
- package/src/components/Breadcrumb/{BreadcumbDropdown.tsx → BreadcrumbDropdown.tsx} +1 -1
- package/src/components/Breadcrumb/index.tsx +1 -0
- package/src/components/Calendar/Calendar.tsx +3 -3
- package/src/components/Checkbox/CheckboxExample.tsx +8 -0
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +3 -1
- package/src/components/CheckboxGroup/CheckboxGroupExample.tsx +12 -0
- package/src/components/CheckboxGroupField/CheckboxGroupFieldExample.tsx +18 -0
- package/src/components/Chip/Chip.tsx +1 -1
- package/src/components/Field/field.scss +2 -0
- package/src/components/FormField/FormFieldExample.tsx +1 -1
- package/src/components/Input/InputElement.tsx +1 -1
- package/src/components/Input/InputExample.tsx +1 -1
- package/src/components/Modal/Modal.tsx +0 -2
- package/src/components/PageControl/PageControl.tsx +3 -3
- package/src/components/Pagination/PageInput.tsx +1 -1
- package/src/components/Portal/Portal.tsx +1 -5
- package/src/components/Radio/RadioExample.tsx +3 -1
- package/src/components/Radio/radio.scss +2 -1
- package/src/components/RadioGroup/RadioGroup.tsx +3 -1
- package/src/components/RadioGroup/RadioGroupExample.tsx +72 -5
- package/src/components/RadioGroupField/RadioGroupFieldExample.tsx +18 -0
- package/src/components/SearchBar/SearchBar.tsx +14 -12
- package/src/components/Slider/SliderIntervalDots.tsx +1 -1
- package/src/components/Switch/SwitchExample.tsx +6 -0
- package/src/components/Table/index.tsx +1 -0
- package/src/components/TimePicker/Listbox.tsx +2 -2
- package/src/components/TimePicker/Segment.tsx +1 -1
- package/src/components/ToggleOption/ToggleOption.tsx +3 -4
- package/src/hooks/useArrowNavigation.ts +2 -2
- package/src/hooks/useDebounceCallback.ts +1 -1
- package/src/hooks/useDebounceState.ts +0 -1
- package/src/hooks/useOutsideClick.ts +4 -8
- package/src/hooks/useTimeout.ts +1 -1
- package/src/types/common.ts +5 -7
- package/src/utils/countryCodes.ts +1 -1
- package/src/utils/createExampleChildElement.tsx +1 -1
- package/src/utils/demo.ts +1 -1
- package/dist/components/Breadcrumb/BreadcumbDropdown.js.map +0 -1
- package/dist/hooks/useModalState.d.ts +0 -22
- package/dist/hooks/useModalState.js +0 -34
- package/dist/hooks/useModalState.js.map +0 -1
- package/src/hooks/useModalState.ts +0 -37
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InputProps } from '.';
|
|
2
2
|
import { ComponentExample } from '-/utils/demo';
|
|
3
3
|
|
|
4
|
-
type InputExampleProps = InputProps & { label: string; description?: string };
|
|
4
|
+
export type InputExampleProps = InputProps & { label: string; description?: string };
|
|
5
5
|
|
|
6
6
|
export const InputExample: ComponentExample<InputExampleProps> = {
|
|
7
7
|
defaultState: {
|
|
@@ -9,7 +9,7 @@ export type PageControlProps = {
|
|
|
9
9
|
* @example
|
|
10
10
|
* 1;
|
|
11
11
|
*
|
|
12
|
-
* @
|
|
12
|
+
* @minimum 1
|
|
13
13
|
* @required
|
|
14
14
|
*/
|
|
15
15
|
currentPage: number;
|
|
@@ -19,7 +19,7 @@ export type PageControlProps = {
|
|
|
19
19
|
* @example
|
|
20
20
|
* 5;
|
|
21
21
|
*
|
|
22
|
-
* @
|
|
22
|
+
* @minimum 1
|
|
23
23
|
* @required
|
|
24
24
|
*/
|
|
25
25
|
numPages: number;
|
|
@@ -31,7 +31,7 @@ export type PageControlProps = {
|
|
|
31
31
|
variant?: 'flat' | 'floating';
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
type DotSize = 'medium' | 'small' | 'x-small';
|
|
34
|
+
export type DotSize = 'medium' | 'small' | 'x-small';
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* A visual indicator that displays a series of dots representing the number of pages or elements within a moving
|
|
@@ -4,7 +4,7 @@ import { PaginationProps } from './Pagination';
|
|
|
4
4
|
import { Input } from '-/components/Input';
|
|
5
5
|
import { Txt } from '-/components/Txt';
|
|
6
6
|
|
|
7
|
-
type PageInputProps = Pick<PaginationProps, 'numPages' | 'onChange' | 'value'>;
|
|
7
|
+
export type PageInputProps = Pick<PaginationProps, 'numPages' | 'onChange' | 'value'>;
|
|
8
8
|
|
|
9
9
|
export const PageInput: FC<PageInputProps> = ({ numPages, onChange, value }) => {
|
|
10
10
|
const [page, setPage] = useState<string>(String(value));
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ComponentExample, createUid } from '-/utils/demo';
|
|
2
2
|
|
|
3
3
|
export const RadioExample: ComponentExample = {
|
|
4
|
-
render: ({ props, Component }) =>
|
|
4
|
+
render: ({ props, Component }) => (
|
|
5
|
+
<Component {...props} aria-label={props['aria-label'] || 'radio aria-label'} name={createUid('radio')} />
|
|
6
|
+
),
|
|
5
7
|
};
|
|
@@ -7,7 +7,7 @@ import { ElementProps, FieldControlProps } from '-/types/common';
|
|
|
7
7
|
export type RadioGroupOption = Pick<RadioOptionProps, 'checked' | 'description' | 'disabled' | 'label'> &
|
|
8
8
|
Pick<RadioProps, 'value'>;
|
|
9
9
|
|
|
10
|
-
export type RadioGroupProps = FieldControlProps & {
|
|
10
|
+
export type RadioGroupProps = Omit<FieldControlProps, 'readOnly'> & {
|
|
11
11
|
/**
|
|
12
12
|
* The options for the radios.
|
|
13
13
|
*
|
|
@@ -34,6 +34,8 @@ export type RadioGroupProps = FieldControlProps & {
|
|
|
34
34
|
/**
|
|
35
35
|
* A group of radios that allows users to choose one or more items from a list or turn an feature on or off.
|
|
36
36
|
*
|
|
37
|
+
* For a more complete example with field usage, see the RadioGroupField component.
|
|
38
|
+
*
|
|
37
39
|
* @example
|
|
38
40
|
* import { useState } from 'react';
|
|
39
41
|
* import { RadioGroup } from '@bspk/ui/RadioGroup';
|
|
@@ -1,11 +1,78 @@
|
|
|
1
1
|
import { RadioGroupProps } from '.';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ComponentExample } from '-/utils/demo';
|
|
2
|
+
import { ComponentExample, Preset } from '-/utils/demo';
|
|
3
|
+
import { randomString } from '-/utils/random';
|
|
5
4
|
|
|
6
|
-
export const presets
|
|
5
|
+
export const presets: Preset<RadioGroupProps>[] = [
|
|
6
|
+
{
|
|
7
|
+
label: 'With Descriptions',
|
|
8
|
+
propState: {
|
|
9
|
+
value: 'option2',
|
|
10
|
+
disabled: false,
|
|
11
|
+
options: [
|
|
12
|
+
{ label: 'Option 1', value: 'option1', description: 'Description for option 1' },
|
|
13
|
+
{
|
|
14
|
+
label: 'Option 2',
|
|
15
|
+
value: 'option2',
|
|
16
|
+
description: 'Description for option 2 (disabled)',
|
|
17
|
+
disabled: true,
|
|
18
|
+
},
|
|
19
|
+
{ label: 'Option 3', value: 'option3', description: 'Description for option 3' },
|
|
20
|
+
],
|
|
21
|
+
['aria-label']: 'Radio group',
|
|
22
|
+
name: 'Radio group',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: 'Group disabled',
|
|
27
|
+
propState: {
|
|
28
|
+
value: 'option2',
|
|
29
|
+
disabled: true,
|
|
30
|
+
options: [
|
|
31
|
+
{ label: 'Option 1', value: 'option1', description: 'Description for option 1' },
|
|
32
|
+
{
|
|
33
|
+
label: 'Option 2',
|
|
34
|
+
value: 'option2',
|
|
35
|
+
description: 'Description for option 2 (disabled)',
|
|
36
|
+
},
|
|
37
|
+
{ label: 'Option 3', value: 'option3', description: 'Description for option 3' },
|
|
38
|
+
],
|
|
39
|
+
['aria-label']: 'Radio group',
|
|
40
|
+
name: 'Radio group',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: 'Long labels',
|
|
45
|
+
propState: {
|
|
46
|
+
value: 'option2',
|
|
47
|
+
disabled: false,
|
|
48
|
+
options: [
|
|
49
|
+
{ label: 'This is a very long label for option 1 that never seems to end', value: 'option1' },
|
|
50
|
+
{ label: 'This is a very long label for option 2 that never seems to end', value: 'option2' },
|
|
51
|
+
{ label: 'This is a very long label for option 3', value: 'option3' },
|
|
52
|
+
],
|
|
53
|
+
['aria-label']: 'Radio group',
|
|
54
|
+
name: 'Radio group',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
];
|
|
7
58
|
|
|
8
59
|
export const RadioGroupExample: ComponentExample<RadioGroupProps> = {
|
|
9
|
-
render: RadioExample.render,
|
|
10
60
|
presets,
|
|
61
|
+
render: ({ props, Component }) => {
|
|
62
|
+
const id = randomString();
|
|
63
|
+
return <Component {...props} id={id} name={props.name + id} />;
|
|
64
|
+
},
|
|
65
|
+
defaultState: {
|
|
66
|
+
value: 'option3',
|
|
67
|
+
options: [
|
|
68
|
+
{ label: 'Option 1', value: 'option1', description: 'Description for option 1' },
|
|
69
|
+
{
|
|
70
|
+
label: 'Option 2',
|
|
71
|
+
value: 'option2',
|
|
72
|
+
description: 'Description for option 2 (disabled)',
|
|
73
|
+
disabled: true,
|
|
74
|
+
},
|
|
75
|
+
{ label: 'Option 3', value: 'option3', description: 'Description for option 3' },
|
|
76
|
+
],
|
|
77
|
+
},
|
|
11
78
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RadioGroupFieldProps } from '.';
|
|
2
|
+
import { RadioGroupExample as radioGroupExample } from '-/components/RadioGroup/RadioGroupExample';
|
|
3
|
+
import { ComponentExample, Preset } from '-/utils/demo';
|
|
4
|
+
|
|
5
|
+
export const presets: Preset<RadioGroupFieldProps>[] = radioGroupExample.presets!.map((preset) => ({
|
|
6
|
+
...preset,
|
|
7
|
+
propState: {
|
|
8
|
+
label: 'Radio Group Field',
|
|
9
|
+
...preset.propState,
|
|
10
|
+
},
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
export const RadioGroupFieldExample: ComponentExample<RadioGroupFieldProps> = {
|
|
14
|
+
presets,
|
|
15
|
+
defaultState: {
|
|
16
|
+
...radioGroupExample.defaultState,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -23,7 +23,10 @@ import { useIds } from '-/utils/useIds';
|
|
|
23
23
|
*/
|
|
24
24
|
export type SearchBarOption = Pick<ListItemProps, 'label' | 'leading' | 'trailing'>;
|
|
25
25
|
|
|
26
|
-
export type SearchBarProps<O extends SearchBarOption = SearchBarOption> =
|
|
26
|
+
export type SearchBarProps<O extends SearchBarOption = SearchBarOption> = Omit<
|
|
27
|
+
FieldControlProps<string, O>,
|
|
28
|
+
'invalid' | 'readOnly' | 'required'
|
|
29
|
+
> &
|
|
27
30
|
Pick<InputProps, 'inputRef' | 'size' | 'trailing'> &
|
|
28
31
|
ScrollListItemsStyleProps & {
|
|
29
32
|
/**
|
|
@@ -111,9 +114,11 @@ export function SearchBar<O extends SearchBarOption>({
|
|
|
111
114
|
disabled = false,
|
|
112
115
|
scrollLimit,
|
|
113
116
|
trailing,
|
|
117
|
+
'aria-label': ariaLabel,
|
|
114
118
|
}: SearchBarProps<O>) {
|
|
115
119
|
const id = useId(idProp);
|
|
116
120
|
const menuId = `${id}-menu`;
|
|
121
|
+
const noResultsId = `${id}-no-results`;
|
|
117
122
|
|
|
118
123
|
const items = useIds(`search-bar-${id}`, itemsProp || []);
|
|
119
124
|
|
|
@@ -162,23 +167,20 @@ export function SearchBar<O extends SearchBarOption>({
|
|
|
162
167
|
};
|
|
163
168
|
|
|
164
169
|
useEffect(() => {
|
|
165
|
-
if (!hasFocus)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
170
|
+
if (!hasFocus) return setActiveElementId(null);
|
|
171
|
+
|
|
172
|
+
if (!filteredItems.length) return setActiveElementId(noResultsId);
|
|
169
173
|
|
|
170
174
|
if (activeElementId) return;
|
|
171
175
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
setActiveElementId(value?.trim().length ? filteredItems[0].id : null);
|
|
175
|
-
}
|
|
176
|
-
}, [hasFocus, filteredItems, activeElementId, setActiveElementId, value]);
|
|
176
|
+
setActiveElementId(value?.trim().length ? filteredItems[0].id : null);
|
|
177
|
+
}, [hasFocus, filteredItems, activeElementId, setActiveElementId, value, noResultsId]);
|
|
177
178
|
|
|
178
179
|
return (
|
|
179
180
|
<>
|
|
180
181
|
<div data-bspk="search-bar">
|
|
181
182
|
<Input
|
|
183
|
+
aria-label={ariaLabel}
|
|
182
184
|
autoComplete="off"
|
|
183
185
|
containerRef={elements.setReference}
|
|
184
186
|
disabled={disabled}
|
|
@@ -242,8 +244,8 @@ export function SearchBar<O extends SearchBarOption>({
|
|
|
242
244
|
}}
|
|
243
245
|
tabIndex={-1}
|
|
244
246
|
>
|
|
245
|
-
{
|
|
246
|
-
<div data-bspk="no-items-found">
|
|
247
|
+
{activeElementId === noResultsId && (
|
|
248
|
+
<div data-bspk="no-items-found" id={noResultsId}>
|
|
247
249
|
<Txt as="div" variant="heading-h5">
|
|
248
250
|
No results found
|
|
249
251
|
</Txt>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SwitchProps } from '.';
|
|
2
|
+
import { ComponentExample } from '-/utils/demo';
|
|
3
|
+
|
|
4
|
+
export const SwitchExample: ComponentExample<SwitchProps> = {
|
|
5
|
+
render: ({ props, Component }) => <Component {...props} aria-label={props['aria-label'] || 'switch aria-label'} />,
|
|
6
|
+
};
|
|
@@ -3,13 +3,13 @@ import { useArrowNavigation } from '-/hooks/useArrowNavigation';
|
|
|
3
3
|
import { getElementById } from '-/utils/dom';
|
|
4
4
|
import { handleKeyDown } from '-/utils/handleKeyDown';
|
|
5
5
|
|
|
6
|
-
type Option = {
|
|
6
|
+
export type Option = {
|
|
7
7
|
id: string;
|
|
8
8
|
value: string;
|
|
9
9
|
label: string;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
type TimePickerListboxProps = {
|
|
12
|
+
export type TimePickerListboxProps = {
|
|
13
13
|
options: Option[];
|
|
14
14
|
selectedValue?: string;
|
|
15
15
|
type: TimePickerType;
|
|
@@ -9,7 +9,7 @@ export const NUMBER_PLACEHOLDER = '--' as const;
|
|
|
9
9
|
|
|
10
10
|
export type TimePickerType = 'hours' | 'meridiem' | 'minutes';
|
|
11
11
|
|
|
12
|
-
type TimePickerSegmentProps<T extends string> = {
|
|
12
|
+
export type TimePickerSegmentProps<T extends string> = {
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
name: string;
|
|
15
15
|
readOnly?: boolean;
|
|
@@ -6,7 +6,7 @@ import { CommonProps } from '-/types/common';
|
|
|
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'
|
|
9
|
+
export type ToggleOptionProps = CommonProps<'disabled'> &
|
|
10
10
|
Omit<ListItemProps, 'as' | 'label' | 'leading' | 'subtext' | 'trailing'> & {
|
|
11
11
|
/**
|
|
12
12
|
* The label of the option. Also used as the aria-label of the control.
|
|
@@ -30,13 +30,12 @@ export type ToggleOptionProps = CommonProps<'disabled' | 'readOnly'> &
|
|
|
30
30
|
* @name ToggleOption
|
|
31
31
|
* @phase Utility
|
|
32
32
|
*/
|
|
33
|
-
export function ToggleOption({ label, description, children, disabled,
|
|
33
|
+
export function ToggleOption({ label, description, children, disabled, ...props }: ToggleOptionProps) {
|
|
34
34
|
return (
|
|
35
35
|
<ListItem
|
|
36
36
|
{...props}
|
|
37
|
+
aria-disabled={disabled || undefined}
|
|
37
38
|
as="label"
|
|
38
|
-
data-disabled={disabled}
|
|
39
|
-
data-readonly={readOnly}
|
|
40
39
|
label={label}
|
|
41
40
|
leading={children}
|
|
42
41
|
subText={description}
|
|
@@ -3,7 +3,7 @@ import { getElementById } from '-/utils/dom';
|
|
|
3
3
|
import { KeysCallback } from '-/utils/handleKeyDown';
|
|
4
4
|
import { KeyboardEventCode } from '-/utils/keyboard';
|
|
5
5
|
|
|
6
|
-
type ArrowKeyNames = Extract<KeyboardEventCode, `Arrow${string}`>;
|
|
6
|
+
export type ArrowKeyNames = Extract<KeyboardEventCode, `Arrow${string}`>;
|
|
7
7
|
|
|
8
8
|
const ARROW_KEYS: ArrowKeyNames[] = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'];
|
|
9
9
|
|
|
@@ -14,7 +14,7 @@ export type ArrowKeyNavigationCallbackParams = {
|
|
|
14
14
|
increment: number;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
type UseArrowNavigationProps = {
|
|
17
|
+
export type UseArrowNavigationProps = {
|
|
18
18
|
/**
|
|
19
19
|
* An array of string IDs representing the navigable elements. These IDs should correspond to the `id` attributes of
|
|
20
20
|
* the elements in the DOM. Ensure the elements are not disabled.
|
|
@@ -5,7 +5,6 @@ import { useTimeout } from './useTimeout';
|
|
|
5
5
|
/**
|
|
6
6
|
* A hook that debounces a state update, ensuring that the function is not called again until a specified delay
|
|
7
7
|
*
|
|
8
|
-
* @param defaultValue The initial value of the state
|
|
9
8
|
* @param delay [1000] The delay (in ms) for the state to update
|
|
10
9
|
* @returns A tuple containing the current state and a debounced setter function that updates the state after the
|
|
11
10
|
* specified delay
|
|
@@ -24,16 +24,12 @@ import { useEffect } from 'react';
|
|
|
24
24
|
* </>
|
|
25
25
|
* );
|
|
26
26
|
* }
|
|
27
|
-
*
|
|
28
|
-
* @param elements - The elements to check if the click occurred outside of.
|
|
29
|
-
* @param callback - The callback to call when a click occurs outside of the ref.
|
|
30
|
-
* @param disabled - Whether the hook should be disabled. Defaults to false.
|
|
31
27
|
*/
|
|
32
28
|
export function useOutsideClick({
|
|
33
|
-
elements,
|
|
34
|
-
callback,
|
|
35
|
-
disabled,
|
|
36
|
-
handleTabs = false,
|
|
29
|
+
elements, // The elements to check if the click occurred outside of.
|
|
30
|
+
callback, // The callback to call when a click occurs outside of the ref.
|
|
31
|
+
disabled, // Whether the hook should be disabled. Defaults to false.
|
|
32
|
+
handleTabs = false, // Whether to handle tab key presses as outside clicks.
|
|
37
33
|
}: {
|
|
38
34
|
elements: (HTMLElement | null)[] | null;
|
|
39
35
|
callback: (event?: KeyboardEvent | MouseEvent) => void;
|
package/src/hooks/useTimeout.ts
CHANGED
package/src/types/common.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type ElementConstructorProps<
|
|
|
32
32
|
O extends string = '',
|
|
33
33
|
> = Omit<ComponentPropsWithoutRef<E>, O>;
|
|
34
34
|
|
|
35
|
-
type CSSVariables = `--${string}`;
|
|
35
|
+
export type CSSVariables = `--${string}`;
|
|
36
36
|
|
|
37
37
|
export type CSSWithVariables = CSSProperties | (CSSProperties & { [key in CSSVariables]: unknown });
|
|
38
38
|
|
|
@@ -119,14 +119,12 @@ export type CommonPropsLibrary = {
|
|
|
119
119
|
/**
|
|
120
120
|
* The aria-label for the element.
|
|
121
121
|
*
|
|
122
|
-
*
|
|
123
|
-
*/
|
|
124
|
-
'aria-label'?: string;
|
|
125
|
-
/**
|
|
126
|
-
* Identifies the parent component. Helps with styling, debugging, and/or testing purposes.
|
|
122
|
+
* This is used to provide an accessible name for the element when a visible label is not present.
|
|
127
123
|
*
|
|
128
|
-
*
|
|
124
|
+
* Ensure this is provided when using the element in isolation to maintain accessibility.
|
|
129
125
|
*/
|
|
126
|
+
'aria-label'?: string;
|
|
127
|
+
/** Identifies the parent component. Helps with styling, debugging, and/or testing purposes. */
|
|
130
128
|
owner?: string;
|
|
131
129
|
/**
|
|
132
130
|
* The ARIA role of the element.
|
|
@@ -11,7 +11,7 @@ import { Switch } from '-/components/Switch';
|
|
|
11
11
|
import { Tag } from '-/components/Tag';
|
|
12
12
|
import { Txt } from '-/components/Txt';
|
|
13
13
|
|
|
14
|
-
type ExampleChildElementProps = {
|
|
14
|
+
export type ExampleChildElementProps = {
|
|
15
15
|
exampleState: Record<string, any>;
|
|
16
16
|
name: string;
|
|
17
17
|
setState: DemoSetState;
|
package/src/utils/demo.ts
CHANGED
|
@@ -55,7 +55,7 @@ export type ComponentExampleRender<Props = Record<string, unknown>> = (
|
|
|
55
55
|
params: ComponentExampleRenderProps<Props>,
|
|
56
56
|
) => React.ReactNode;
|
|
57
57
|
|
|
58
|
-
type ComponentVariantOverride<Props> = {
|
|
58
|
+
export type ComponentVariantOverride<Props> = {
|
|
59
59
|
[K in keyof Props]?: Props[K] | { options: Props[K][] };
|
|
60
60
|
};
|
|
61
61
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BreadcumbDropdown.js","sourceRoot":"","sources":["../../../src/components/Breadcrumb/BreadcumbDropdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM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AC,UAAU,GACpB,EACD,IAAI,IAAI,CACL,KAAC,IAAI,IACD,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,QAAQ,CAAC,WAAW,EAC9B,KAAK,EAAC,qBAAqB,EAC3B,KAAK,EAAC,YAAY,EAClB,IAAI,EAAC,MAAM,EACX,KAAK,EAAE;oBACH,GAAG,oBAAoB,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;oBAClD,GAAG,cAAc;oBACjB,KAAK,EAAE,aAAa;oBACpB,QAAQ,EAAE,OAAO;oBACjB,QAAQ,EAAE,OAAO;iBACpB,YAEA,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACjB,KAAC,QAAQ,OAAmB,IAAI,EAAE,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,IAApE,IAAI,CAAC,EAAE,CAAiE,CAC1F,CAAC,GACC,CACV,EACD,KAAC,eAAe,0BAAe,IAC9B,CACR,CAAC;AACN,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A hook to manage the state of a modal.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* import { Modal } from '@bspk/ui/Modal';
|
|
6
|
-
* import { useModalState } from '@bspk/ui/hooks/useModalState';
|
|
7
|
-
*
|
|
8
|
-
* function Example() {
|
|
9
|
-
* const modalProps = useModalState(false);
|
|
10
|
-
* return <Modal {...modalProps}>...</Modal>
|
|
11
|
-
* }
|
|
12
|
-
*
|
|
13
|
-
* @param parentValue - The value of the parent state.
|
|
14
|
-
* @param setParentState - A function to set the parent state.
|
|
15
|
-
* @returns An object with the open state and the `onClose` and `onOpen` callbacks.
|
|
16
|
-
*/
|
|
17
|
-
export declare function useModalState(parentValue?: boolean, setParentState?: (next: boolean) => void): {
|
|
18
|
-
open: boolean;
|
|
19
|
-
onClose: () => void;
|
|
20
|
-
onOpen: () => void;
|
|
21
|
-
};
|
|
22
|
-
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* A hook to manage the state of a modal.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* import { Modal } from '@bspk/ui/Modal';
|
|
7
|
-
* import { useModalState } from '@bspk/ui/hooks/useModalState';
|
|
8
|
-
*
|
|
9
|
-
* function Example() {
|
|
10
|
-
* const modalProps = useModalState(false);
|
|
11
|
-
* return <Modal {...modalProps}>...</Modal>
|
|
12
|
-
* }
|
|
13
|
-
*
|
|
14
|
-
* @param parentValue - The value of the parent state.
|
|
15
|
-
* @param setParentState - A function to set the parent state.
|
|
16
|
-
* @returns An object with the open state and the `onClose` and `onOpen` callbacks.
|
|
17
|
-
*/
|
|
18
|
-
export function useModalState(parentValue = false, setParentState) {
|
|
19
|
-
const [open, setOpen] = useState(parentValue);
|
|
20
|
-
useEffect(() => setOpen(parentValue), [parentValue]);
|
|
21
|
-
return {
|
|
22
|
-
open,
|
|
23
|
-
onClose: () => {
|
|
24
|
-
setOpen(false);
|
|
25
|
-
setParentState?.(false);
|
|
26
|
-
},
|
|
27
|
-
onOpen: () => {
|
|
28
|
-
setOpen(true);
|
|
29
|
-
setParentState?.(true);
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|
|
34
|
-
//# sourceMappingURL=useModalState.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useModalState.js","sourceRoot":"","sources":["../../src/hooks/useModalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa,CAAC,cAAuB,KAAK,EAAE,cAAwC;IAChG,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;IAE9C,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAErD,OAAO;QACH,IAAI;QACJ,OAAO,EAAE,GAAG,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QACD,MAAM,EAAE,GAAG,EAAE;YACT,OAAO,CAAC,IAAI,CAAC,CAAC;YACd,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;KACJ,CAAC;AACN,CAAC;AAED,sDAAsD"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A hook to manage the state of a modal.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* import { Modal } from '@bspk/ui/Modal';
|
|
8
|
-
* import { useModalState } from '@bspk/ui/hooks/useModalState';
|
|
9
|
-
*
|
|
10
|
-
* function Example() {
|
|
11
|
-
* const modalProps = useModalState(false);
|
|
12
|
-
* return <Modal {...modalProps}>...</Modal>
|
|
13
|
-
* }
|
|
14
|
-
*
|
|
15
|
-
* @param parentValue - The value of the parent state.
|
|
16
|
-
* @param setParentState - A function to set the parent state.
|
|
17
|
-
* @returns An object with the open state and the `onClose` and `onOpen` callbacks.
|
|
18
|
-
*/
|
|
19
|
-
export function useModalState(parentValue: boolean = false, setParentState?: (next: boolean) => void) {
|
|
20
|
-
const [open, setOpen] = useState(parentValue);
|
|
21
|
-
|
|
22
|
-
useEffect(() => setOpen(parentValue), [parentValue]);
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
open,
|
|
26
|
-
onClose: () => {
|
|
27
|
-
setOpen(false);
|
|
28
|
-
setParentState?.(false);
|
|
29
|
-
},
|
|
30
|
-
onOpen: () => {
|
|
31
|
-
setOpen(true);
|
|
32
|
-
setParentState?.(true);
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** Copyright 2025 Anywhere Real Estate - CC BY 4.0 */
|