@bspk/ui 1.1.21 → 1.1.22
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/Avatar.d.ts +18 -2
- package/dist/Avatar.js +18 -2
- package/dist/Avatar.js.map +1 -1
- package/dist/AvatarGroup.d.ts +14 -0
- package/dist/AvatarGroup.js +14 -0
- package/dist/AvatarGroup.js.map +1 -1
- package/dist/Badge.d.ts +23 -2
- package/dist/Badge.js +12 -3
- package/dist/Badge.js.map +1 -1
- package/dist/BannerAlert.d.ts +17 -0
- package/dist/BannerAlert.js +17 -0
- package/dist/BannerAlert.js.map +1 -1
- package/dist/Button.d.ts +16 -0
- package/dist/Button.js +16 -0
- package/dist/Button.js.map +1 -1
- package/dist/Card.d.ts +12 -0
- package/dist/Card.js +12 -0
- package/dist/Card.js.map +1 -1
- package/dist/Checkbox.d.ts +21 -0
- package/dist/Checkbox.js +21 -0
- package/dist/Checkbox.js.map +1 -1
- package/dist/CheckboxGroup.d.ts +30 -0
- package/dist/CheckboxGroup.js +23 -0
- package/dist/CheckboxGroup.js.map +1 -1
- package/dist/CheckboxOption.d.ts +23 -1
- package/dist/CheckboxOption.js +25 -2
- package/dist/CheckboxOption.js.map +1 -1
- package/dist/Chip.d.ts +11 -0
- package/dist/Chip.js +11 -0
- package/dist/Chip.js.map +1 -1
- package/dist/Dialog.d.ts +19 -0
- package/dist/Dialog.js +19 -0
- package/dist/Dialog.js.map +1 -1
- package/dist/Divider.d.ts +13 -0
- package/dist/Divider.js +13 -0
- package/dist/Divider.js.map +1 -1
- package/dist/Dropdown.d.ts +30 -0
- package/dist/Dropdown.js +30 -0
- package/dist/Dropdown.js.map +1 -1
- package/dist/DropdownField.d.ts +22 -0
- package/dist/DropdownField.js +22 -0
- package/dist/DropdownField.js.map +1 -1
- package/dist/EmptyState.d.ts +11 -0
- package/dist/EmptyState.js +11 -0
- package/dist/EmptyState.js.map +1 -1
- package/dist/Fab.d.ts +8 -0
- package/dist/Fab.js +8 -0
- package/dist/Fab.js.map +1 -1
- package/dist/FormField.d.ts +25 -0
- package/dist/FormField.js +25 -0
- package/dist/FormField.js.map +1 -1
- package/dist/Img.d.ts +7 -0
- package/dist/Img.js +7 -0
- package/dist/Img.js.map +1 -1
- package/dist/InlineAlert.d.ts +7 -0
- package/dist/InlineAlert.js +7 -0
- package/dist/InlineAlert.js.map +1 -1
- package/dist/Layout.d.ts +7 -0
- package/dist/Layout.js +7 -0
- package/dist/Layout.js.map +1 -1
- package/dist/Link.d.ts +7 -0
- package/dist/Link.js +7 -0
- package/dist/Link.js.map +1 -1
- package/dist/ListItem.d.ts +15 -0
- package/dist/ListItem.js +15 -0
- package/dist/ListItem.js.map +1 -1
- package/dist/Menu.d.ts +28 -0
- package/dist/Menu.js +29 -1
- package/dist/Menu.js.map +1 -1
- package/dist/MenuButton.d.ts +7 -0
- package/dist/MenuButton.js +7 -0
- package/dist/MenuButton.js.map +1 -1
- package/dist/Modal.d.ts +23 -1
- package/dist/Modal.js +23 -1
- package/dist/Modal.js.map +1 -1
- package/dist/NumberField.d.ts +19 -0
- package/dist/NumberField.js +19 -0
- package/dist/NumberField.js.map +1 -1
- package/dist/NumberInput.d.ts +16 -0
- package/dist/NumberInput.js +16 -0
- package/dist/NumberInput.js.map +1 -1
- package/dist/Popover.d.ts +29 -2
- package/dist/Popover.js +30 -3
- package/dist/Popover.js.map +1 -1
- package/dist/ProgressBar.d.ts +8 -0
- package/dist/ProgressBar.js +9 -1
- package/dist/ProgressBar.js.map +1 -1
- package/dist/ProgressCircle.d.ts +8 -0
- package/dist/ProgressCircle.js +8 -0
- package/dist/ProgressCircle.js.map +1 -1
- package/dist/ProgressionStepper.d.ts +12 -0
- package/dist/ProgressionStepper.js +12 -0
- package/dist/ProgressionStepper.js.map +1 -1
- package/dist/RadioGroup.d.ts +38 -6
- package/dist/RadioGroup.js +34 -5
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioOption.d.ts +3 -1
- package/dist/RadioOption.js +5 -2
- package/dist/RadioOption.js.map +1 -1
- package/dist/SearchBar.d.ts +34 -0
- package/dist/SearchBar.js +34 -0
- package/dist/SearchBar.js.map +1 -1
- package/dist/SegmentedControl.d.ts +35 -8
- package/dist/SegmentedControl.js +24 -2
- package/dist/SegmentedControl.js.map +1 -1
- package/dist/Skeleton.d.ts +3 -1
- package/dist/Skeleton.js +3 -1
- package/dist/Skeleton.js.map +1 -1
- package/dist/Switch.d.ts +18 -1
- package/dist/Switch.js +18 -1
- package/dist/Switch.js.map +1 -1
- package/dist/SwitchOption.d.ts +4 -2
- package/dist/SwitchOption.js +5 -2
- package/dist/SwitchOption.js.map +1 -1
- package/dist/TabGroup.d.ts +26 -5
- package/dist/TabGroup.js +20 -0
- package/dist/TabGroup.js.map +1 -1
- package/dist/Tag.d.ts +13 -1
- package/dist/Tag.js +13 -1
- package/dist/Tag.js.map +1 -1
- package/dist/TextField.d.ts +21 -2
- package/dist/TextField.js +22 -2
- package/dist/TextField.js.map +1 -1
- package/dist/TextInput.d.ts +22 -3
- package/dist/TextInput.js +20 -2
- package/dist/TextInput.js.map +1 -1
- package/dist/Textarea.d.ts +23 -4
- package/dist/Textarea.js +27 -7
- package/dist/Textarea.js.map +1 -1
- package/dist/TextareaField.d.ts +21 -1
- package/dist/TextareaField.js +24 -2
- package/dist/TextareaField.js.map +1 -1
- package/dist/ToggleOption.d.ts +8 -5
- package/dist/ToggleOption.js +3 -3
- package/dist/ToggleOption.js.map +1 -1
- package/dist/Tooltip.d.ts +15 -3
- package/dist/Tooltip.js +20 -3
- package/dist/Tooltip.js.map +1 -1
- package/dist/Txt.d.ts +9 -1
- package/dist/Txt.js +9 -1
- package/dist/Txt.js.map +1 -1
- package/dist/badge.css +1 -1
- package/dist/demo/examples.js +3 -0
- package/dist/demo/examples.js.map +1 -1
- package/dist/progress-bar.css +1 -1
- package/dist/radio-group.css +1 -0
- package/dist/textarea.css +1 -1
- package/dist/toggle-option.css +1 -1
- package/meta.ts +8 -6
- package/package.json +1 -1
- package/src/Avatar.tsx +18 -2
- package/src/AvatarGroup.tsx +14 -0
- package/src/Badge.tsx +30 -4
- package/src/BannerAlert.tsx +17 -0
- package/src/Button.tsx +16 -0
- package/src/Card.tsx +12 -0
- package/src/Checkbox.tsx +21 -0
- package/src/CheckboxGroup.tsx +30 -0
- package/src/CheckboxOption.tsx +29 -4
- package/src/Chip.tsx +11 -0
- package/src/Dialog.tsx +19 -0
- package/src/Divider.tsx +13 -0
- package/src/Dropdown.tsx +30 -0
- package/src/DropdownField.tsx +22 -0
- package/src/EmptyState.tsx +11 -0
- package/src/Fab.tsx +8 -0
- package/src/FormField.tsx +25 -0
- package/src/Img.tsx +7 -0
- package/src/InlineAlert.tsx +7 -0
- package/src/Layout.tsx +7 -0
- package/src/Link.tsx +7 -0
- package/src/ListItem.tsx +15 -0
- package/src/Menu.tsx +29 -0
- package/src/MenuButton.tsx +7 -0
- package/src/Modal.tsx +23 -1
- package/src/NumberField.tsx +19 -0
- package/src/NumberInput.tsx +16 -0
- package/src/Popover.tsx +53 -5
- package/src/ProgressBar.tsx +8 -0
- package/src/ProgressCircle.tsx +8 -0
- package/src/ProgressionStepper.tsx +12 -0
- package/src/RadioGroup.tsx +68 -25
- package/src/RadioOption.tsx +9 -4
- package/src/SearchBar.tsx +47 -3
- package/src/SegmentedControl.tsx +57 -14
- package/src/Skeleton.tsx +3 -1
- package/src/Switch.tsx +18 -1
- package/src/SwitchOption.tsx +11 -6
- package/src/TabGroup.tsx +30 -6
- package/src/Tag.tsx +13 -1
- package/src/TextField.tsx +37 -6
- package/src/TextInput.tsx +36 -5
- package/src/Textarea.tsx +41 -9
- package/src/TextareaField.tsx +33 -4
- package/src/ToggleOption.tsx +9 -6
- package/src/Tooltip.tsx +29 -5
- package/src/Txt.tsx +14 -2
- package/src/badge.scss +17 -4
- package/src/demo/examples.tsx +3 -0
- package/src/progress-bar.scss +0 -2
- package/src/radio-group.scss +5 -0
- package/src/textarea.scss +4 -0
- package/src/toggle-option.scss +1 -20
- package/dist/SwitchGroup.d.ts +0 -42
- package/dist/SwitchGroup.js +0 -16
- package/dist/SwitchGroup.js.map +0 -1
- package/dist/hooks/useSwitchGroupState.d.ts +0 -37
- package/dist/hooks/useSwitchGroupState.js +0 -57
- package/dist/hooks/useSwitchGroupState.js.map +0 -1
- package/src/SwitchGroup.tsx +0 -72
- package/src/hooks/useSwitchGroupState.ts +0 -75
package/src/InlineAlert.tsx
CHANGED
|
@@ -30,6 +30,13 @@ export type InlineAlertProps = {
|
|
|
30
30
|
* Inline alerts provide contextual feedback messages for typical user actions with a handful of available and flexible
|
|
31
31
|
* alert messages.
|
|
32
32
|
*
|
|
33
|
+
* @example
|
|
34
|
+
* import { InlineAlert } from '@bspk/ui/InlineAlert';
|
|
35
|
+
*
|
|
36
|
+
* export function Example() {
|
|
37
|
+
* return <InlineAlert variant="informational">Example informational inline alert</InlineAlert>;
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
33
40
|
* @name InlineAlert
|
|
34
41
|
*/
|
|
35
42
|
function InlineAlert({ children, variant = 'informational', id }: InlineAlertProps) {
|
package/src/Layout.tsx
CHANGED
|
@@ -41,6 +41,13 @@ export type LayoutProps<As extends ElementType = 'div'> = {
|
|
|
41
41
|
/**
|
|
42
42
|
* Utility component used within other components for layout purposes.
|
|
43
43
|
*
|
|
44
|
+
* @example
|
|
45
|
+
* import { Layout } from '@bspk/ui/Layout';
|
|
46
|
+
*
|
|
47
|
+
* export function Example() {
|
|
48
|
+
* return <Layout>Low effort example</Layout>;
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
44
51
|
* @name Layout
|
|
45
52
|
*/
|
|
46
53
|
function Layout<As extends ElementType = 'div'>({
|
package/src/Link.tsx
CHANGED
|
@@ -36,6 +36,13 @@ export type LinkProps = Pick<AnchorHTMLAttributes<unknown>, 'target'> &
|
|
|
36
36
|
/**
|
|
37
37
|
* This is the standalone link component. Inline links can use the native `a` element.
|
|
38
38
|
*
|
|
39
|
+
* @example
|
|
40
|
+
* import { Link } from '@bspk/ui/Link';
|
|
41
|
+
*
|
|
42
|
+
* export function Example() {
|
|
43
|
+
* return <Link href="https://bspk.dev" label="Example label" trailingIcon="external" />;
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
39
46
|
* @name Link
|
|
40
47
|
*/
|
|
41
48
|
function Link({ label, trailingIcon, size, variant, ...props }: LinkProps) {
|
package/src/ListItem.tsx
CHANGED
|
@@ -67,6 +67,21 @@ export type ListItemProps<As extends ElementType = 'div'> = CommonProps<'active'
|
|
|
67
67
|
*
|
|
68
68
|
* The ListItemButton is a more limited Button with context specific options.
|
|
69
69
|
*
|
|
70
|
+
* @example
|
|
71
|
+
* import { SvgSquare } from '@bspk/icons/square';
|
|
72
|
+
* import { ListItem } from '@bspk/ui/ListItem';
|
|
73
|
+
*
|
|
74
|
+
* export function Example() {
|
|
75
|
+
* return (
|
|
76
|
+
* <ListItem
|
|
77
|
+
* label="Example label"
|
|
78
|
+
* leading={<SvgSquare />}
|
|
79
|
+
* subText="Example subtest"
|
|
80
|
+
* trailing={<ListItem.Button label="Click me" onClick={() => console.log('Hello world')} />}
|
|
81
|
+
* />
|
|
82
|
+
* );
|
|
83
|
+
* }
|
|
84
|
+
*
|
|
70
85
|
* @subComponents ListItemButton
|
|
71
86
|
*
|
|
72
87
|
* @name ListItem
|
package/src/Menu.tsx
CHANGED
|
@@ -114,6 +114,34 @@ export type MenuProps<T extends MenuItem = MenuItem> = CommonProps<'disabled' |
|
|
|
114
114
|
/**
|
|
115
115
|
* A container housing a simple list of options presented to the user to select one option at a time.
|
|
116
116
|
*
|
|
117
|
+
* @example
|
|
118
|
+
* import React from 'react';
|
|
119
|
+
*
|
|
120
|
+
* import { Menu } from '@bspk/ui/Menu';
|
|
121
|
+
*
|
|
122
|
+
* export function Example() {
|
|
123
|
+
* const [selected, setSelected] = React.useState<string[]>([]);
|
|
124
|
+
*
|
|
125
|
+
* return (
|
|
126
|
+
* <Menu
|
|
127
|
+
* items={[
|
|
128
|
+
* { value: '1', label: 'Option 1' },
|
|
129
|
+
* { value: '2', label: 'Option 2' },
|
|
130
|
+
* { value: '3', label: 'Option 3' },
|
|
131
|
+
* { value: '4', label: 'Option 4' },
|
|
132
|
+
* { value: '5', label: 'Option 5' },
|
|
133
|
+
* { value: '6', label: 'Option 6' },
|
|
134
|
+
* { value: '7', label: 'Option 7' },
|
|
135
|
+
* { value: '8', label: 'Option 8' },
|
|
136
|
+
* { value: '9', label: 'Option 9' },
|
|
137
|
+
* { value: '10', label: 'Option 10' },
|
|
138
|
+
* ]}
|
|
139
|
+
* onChange={(selectedValues: string[]) => setSelected(selectedValues)}
|
|
140
|
+
* selectedValues={selected}
|
|
141
|
+
* />
|
|
142
|
+
* );
|
|
143
|
+
* }
|
|
144
|
+
*
|
|
117
145
|
* @name Menu
|
|
118
146
|
*/
|
|
119
147
|
function Menu({
|
|
@@ -185,6 +213,7 @@ function Menu({
|
|
|
185
213
|
<Checkbox
|
|
186
214
|
aria-label={selectAll}
|
|
187
215
|
checked={!!allSelected}
|
|
216
|
+
indeterminate={!allSelected && selectedValues.length > 0}
|
|
188
217
|
name=""
|
|
189
218
|
onChange={(checked) => {
|
|
190
219
|
onChange?.(checked ? items.map((item) => item.value) : []);
|
package/src/MenuButton.tsx
CHANGED
|
@@ -10,6 +10,13 @@ export type MenuButtonProps = Pick<ButtonProps, 'as' | 'onClick'>;
|
|
|
10
10
|
/**
|
|
11
11
|
* Utility component used within top navigation.
|
|
12
12
|
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { MenuButton } from '@bspk/ui/MenuButton';
|
|
15
|
+
*
|
|
16
|
+
* export function Example() {
|
|
17
|
+
* return <MenuButton />;
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
13
20
|
* @name MenuButton
|
|
14
21
|
*/
|
|
15
22
|
function MenuButton(props: ElementProps<MenuButtonProps, 'button'>) {
|
package/src/Modal.tsx
CHANGED
|
@@ -28,7 +28,29 @@ export type ModalProps = DialogProps & {
|
|
|
28
28
|
* interactions until an action is selected. Modal is a wrapper around the Dialog component that provides a header and
|
|
29
29
|
* footer for the dialog.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
31
|
+
* @example
|
|
32
|
+
* import React from 'react';
|
|
33
|
+
*
|
|
34
|
+
* import { Button } from '@bspk/ui/Button';
|
|
35
|
+
* import { Modal } from '@bspk/ui/Modal';
|
|
36
|
+
*
|
|
37
|
+
* export function Example() {
|
|
38
|
+
* const [open, setOpen] = React.useState(false);
|
|
39
|
+
*
|
|
40
|
+
* return (
|
|
41
|
+
* <>
|
|
42
|
+
* <Button label="Open Dialog" onClick={() => setOpen(true)} />
|
|
43
|
+
* <Modal
|
|
44
|
+
* description="Example description"
|
|
45
|
+
* header="Example header"
|
|
46
|
+
* onClose={() => setOpen(false)}
|
|
47
|
+
* open={open}
|
|
48
|
+
* >
|
|
49
|
+
* Example Modal
|
|
50
|
+
* </Modal>
|
|
51
|
+
* </>
|
|
52
|
+
* );
|
|
53
|
+
* }
|
|
32
54
|
*
|
|
33
55
|
* @name Modal
|
|
34
56
|
*/
|
package/src/NumberField.tsx
CHANGED
|
@@ -13,6 +13,25 @@ export type NumberFieldProps = InvalidPropsLibrary &
|
|
|
13
13
|
*
|
|
14
14
|
* This component takes properties from the FormField and NumberInput components.
|
|
15
15
|
*
|
|
16
|
+
* @example
|
|
17
|
+
* import React from 'react';
|
|
18
|
+
*
|
|
19
|
+
* import { NumberField } from '@bspk/ui/NumberField';
|
|
20
|
+
*
|
|
21
|
+
* export function Example() {
|
|
22
|
+
* const [state, setState] = React.useState<number>();
|
|
23
|
+
*
|
|
24
|
+
* return (
|
|
25
|
+
* <NumberField
|
|
26
|
+
* controlId="Example controlId"
|
|
27
|
+
* label="Example label"
|
|
28
|
+
* name="Example name"
|
|
29
|
+
* onChange={(nextValue) => setState(nextValue)}
|
|
30
|
+
* value={state}
|
|
31
|
+
* />
|
|
32
|
+
* );
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
16
35
|
* @name NumberField
|
|
17
36
|
*/
|
|
18
37
|
function NumberField({
|
package/src/NumberInput.tsx
CHANGED
|
@@ -61,6 +61,22 @@ export type NumberInputProps = CommonProps<'aria-label' | 'disabled' | 'id' | 'n
|
|
|
61
61
|
*
|
|
62
62
|
* The value of the input is a number. The value is clamped to the min and max values if they are provided.
|
|
63
63
|
*
|
|
64
|
+
* @example
|
|
65
|
+
* import { NumberInput } from '@bspk/ui/NumberInput';
|
|
66
|
+
*
|
|
67
|
+
* export function Example() {
|
|
68
|
+
* const [state, setState] = React.useState<number>();
|
|
69
|
+
*
|
|
70
|
+
* return (
|
|
71
|
+
* <NumberInput
|
|
72
|
+
* aria-label="Example aria-label"
|
|
73
|
+
* name="Example name"
|
|
74
|
+
* onChange={(nextValue) => setState(nextValue)}
|
|
75
|
+
* value={state}
|
|
76
|
+
* />
|
|
77
|
+
* );
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
64
80
|
* @name NumberInput
|
|
65
81
|
*/
|
|
66
82
|
function NumberInput({
|
package/src/Popover.tsx
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { SvgClose } from '@bspk/icons/Close';
|
|
2
2
|
import './popover.scss';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ReactElement,
|
|
5
|
+
cloneElement,
|
|
6
|
+
useId,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from 'react';
|
|
4
11
|
|
|
5
12
|
import { Button } from './Button';
|
|
6
13
|
import { Portal } from './Portal';
|
|
@@ -41,11 +48,45 @@ export type PopoverProps = CommonProps<'disabled'> & {
|
|
|
41
48
|
};
|
|
42
49
|
|
|
43
50
|
/**
|
|
44
|
-
* Brief message that provide additional guidance and helps users perform an
|
|
51
|
+
* Brief message that provide additional guidance and helps users perform an
|
|
52
|
+
* action if needed.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* import { useState } from 'react';
|
|
56
|
+
* import { Popover } from '@bspk/ui/Popover';
|
|
57
|
+
* import { Button } from '@bspk/ui/Button';
|
|
58
|
+
*
|
|
59
|
+
* export function Example() {
|
|
60
|
+
* const [showPopover, setShowPopover] = useState<boolean>(false);
|
|
61
|
+
*
|
|
62
|
+
* const togglePopover = () => setShowPopover(!showPopover);
|
|
63
|
+
* const onPopoverCallToActionClick = () => alert('Action clicked');
|
|
64
|
+
*
|
|
65
|
+
* return (
|
|
66
|
+
* <Popover
|
|
67
|
+
* placement="bottom"
|
|
68
|
+
* content="This is a popover content"
|
|
69
|
+
* header="Popover Header"
|
|
70
|
+
* callToAction={{
|
|
71
|
+
* label: 'Action',
|
|
72
|
+
* onClick: onPopoverCallToActionClick,
|
|
73
|
+
* }}
|
|
74
|
+
* >
|
|
75
|
+
* <Button label="Toggle popover" onClick={togglePopover} />
|
|
76
|
+
* </Popover>
|
|
77
|
+
* );
|
|
78
|
+
* }
|
|
45
79
|
*
|
|
46
80
|
* @name Popover
|
|
47
81
|
*/
|
|
48
|
-
function Popover({
|
|
82
|
+
function Popover({
|
|
83
|
+
placement = 'top',
|
|
84
|
+
header,
|
|
85
|
+
content,
|
|
86
|
+
callToAction,
|
|
87
|
+
children,
|
|
88
|
+
disabled = false,
|
|
89
|
+
}: PopoverProps) {
|
|
49
90
|
const id = useId();
|
|
50
91
|
const [show, setShow] = useState(false);
|
|
51
92
|
const arrowRef = useRef<HTMLElement | null>(null);
|
|
@@ -83,13 +124,20 @@ function Popover({ placement = 'top', header, content, callToAction, children, d
|
|
|
83
124
|
id={id}
|
|
84
125
|
ref={(node) => {
|
|
85
126
|
elements.setFloating(node);
|
|
86
|
-
elements.setTrigger(
|
|
127
|
+
elements.setTrigger(
|
|
128
|
+
document.querySelector<HTMLElement>(
|
|
129
|
+
`[aria-describedby="${id}"]`,
|
|
130
|
+
),
|
|
131
|
+
);
|
|
87
132
|
}}
|
|
88
133
|
style={floatingStyles}
|
|
89
134
|
>
|
|
90
135
|
<header>
|
|
91
136
|
<Txt variant="heading-h6">{header}</Txt>
|
|
92
|
-
<button
|
|
137
|
+
<button
|
|
138
|
+
aria-label="Close"
|
|
139
|
+
onClick={() => setShow(false)}
|
|
140
|
+
>
|
|
93
141
|
<SvgClose />
|
|
94
142
|
</button>
|
|
95
143
|
</header>
|
package/src/ProgressBar.tsx
CHANGED
|
@@ -36,6 +36,14 @@ export type ProgressBarProps = {
|
|
|
36
36
|
* occurring in the background.
|
|
37
37
|
*
|
|
38
38
|
* @name ProgressBar
|
|
39
|
+
* @example
|
|
40
|
+
* import { ProgressBar } from '@bspk/ui/ProgressBar';
|
|
41
|
+
*
|
|
42
|
+
* export function Example() {
|
|
43
|
+
* return (
|
|
44
|
+
* <ProgressBar label="Example label" completion={50} />
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
39
47
|
*/
|
|
40
48
|
function ProgressBar({ size = 'large', completion = 0, align = 'center', label }: ProgressBarProps) {
|
|
41
49
|
const id = useId();
|
package/src/ProgressCircle.tsx
CHANGED
|
@@ -27,6 +27,14 @@ export type ProgressCircleProps = {
|
|
|
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
29
|
* @name ProgressCircle
|
|
30
|
+
* @example
|
|
31
|
+
* import { ProgressCircle } from '@bspk/ui/ProgressCircle';
|
|
32
|
+
*
|
|
33
|
+
* export function Example() {
|
|
34
|
+
* return (
|
|
35
|
+
* <ProgressCircle label="Example label"/>
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
30
38
|
*/
|
|
31
39
|
function ProgressCircle({ label, labelPosition, size = 'medium' }: ProgressCircleProps) {
|
|
32
40
|
let variant: TxtVariant = 'labels-base';
|
|
@@ -66,6 +66,18 @@ export type ProgressionStepperProps = {
|
|
|
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
68
|
* @name ProgressionStepper
|
|
69
|
+
* @example
|
|
70
|
+
* import { ProgressionStepper } from '@bspk/ui/ProgressionStepper';
|
|
71
|
+
*
|
|
72
|
+
* export function Example() {
|
|
73
|
+
* return (
|
|
74
|
+
* <ProgressionStepper steps={[
|
|
75
|
+
* { name: 'Step 1' },
|
|
76
|
+
* { name: 'Step 2' },
|
|
77
|
+
* { name: 'Step 3' },
|
|
78
|
+
* ]} />
|
|
79
|
+
* );
|
|
80
|
+
* }
|
|
69
81
|
*/
|
|
70
82
|
function ProgressionStepper({
|
|
71
83
|
steps = [],
|
package/src/RadioGroup.tsx
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { useId } from 'react';
|
|
2
|
+
|
|
1
3
|
import { Radio } from './Radio';
|
|
2
4
|
import { ToggleOptionProps, ToggleOption } from './ToggleOption';
|
|
3
5
|
|
|
4
6
|
import { ElementProps, CommonProps } from './';
|
|
5
7
|
|
|
8
|
+
import './radio-group.scss';
|
|
9
|
+
|
|
6
10
|
export type RadioGroupOption = Pick<ToggleOptionProps, 'description' | 'label'> & Required<CommonProps<'value'>>;
|
|
7
11
|
|
|
8
12
|
export type RadioGroupProps = CommonProps<'name'> & {
|
|
@@ -29,8 +33,8 @@ export type RadioGroupProps = CommonProps<'name'> & {
|
|
|
29
33
|
*
|
|
30
34
|
* @example
|
|
31
35
|
* [
|
|
32
|
-
* { value: '1', label: 'Option 1'
|
|
33
|
-
* { value: '2', label: 'Option 2' },
|
|
36
|
+
* { value: '1', label: 'Option 1' },
|
|
37
|
+
* { value: '2', label: 'Option 2', description: 'Description here' },
|
|
34
38
|
* { value: '3', label: 'Option 3' },
|
|
35
39
|
* ];
|
|
36
40
|
*
|
|
@@ -39,16 +43,47 @@ export type RadioGroupProps = CommonProps<'name'> & {
|
|
|
39
43
|
*/
|
|
40
44
|
options: RadioGroupOption[];
|
|
41
45
|
/**
|
|
42
|
-
* The
|
|
46
|
+
* The label of the radio group.
|
|
47
|
+
*
|
|
48
|
+
* @required
|
|
49
|
+
*/
|
|
50
|
+
label: string;
|
|
51
|
+
/**
|
|
52
|
+
* Shows the RadioGroup label. When label isn't showing it is used as the aria-label prop.
|
|
43
53
|
*
|
|
44
|
-
* @default
|
|
54
|
+
* @default true
|
|
45
55
|
*/
|
|
46
|
-
|
|
56
|
+
showLabel?: boolean;
|
|
47
57
|
};
|
|
48
58
|
|
|
49
59
|
/**
|
|
50
60
|
* A group of radios that allows users to choose one or more items from a list or turn an feature on or off.
|
|
51
61
|
*
|
|
62
|
+
* @example
|
|
63
|
+
* import { useState } from 'react';
|
|
64
|
+
* import { RadioGroup } from '@bspk/ui/RadioGroup';
|
|
65
|
+
*
|
|
66
|
+
* export function Example() {
|
|
67
|
+
* const [selectedOption, setSelectedOption] = useState<string>('1');
|
|
68
|
+
*
|
|
69
|
+
* return (
|
|
70
|
+
* <RadioGroup
|
|
71
|
+
* name="Example name"
|
|
72
|
+
* onChange={(nextValue) => setSelectedOption(nextValue)}
|
|
73
|
+
* options={[
|
|
74
|
+
* {
|
|
75
|
+
* value: '1',
|
|
76
|
+
* label: 'Option 1',
|
|
77
|
+
* description: 'Description here',
|
|
78
|
+
* },
|
|
79
|
+
* { value: '2', label: 'Option 2' },
|
|
80
|
+
* { value: '3', label: 'Option 3' },
|
|
81
|
+
* ]}
|
|
82
|
+
* value={selectedOption}
|
|
83
|
+
* />
|
|
84
|
+
* );
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
52
87
|
* @name RadioGroup
|
|
53
88
|
*/
|
|
54
89
|
function RadioGroup({
|
|
@@ -56,29 +91,37 @@ function RadioGroup({
|
|
|
56
91
|
options = [],
|
|
57
92
|
name,
|
|
58
93
|
value: groupValue,
|
|
59
|
-
|
|
94
|
+
label: groupLabel,
|
|
95
|
+
showLabel = true,
|
|
60
96
|
...props
|
|
61
97
|
}: ElementProps<RadioGroupProps, 'div'>) {
|
|
98
|
+
const id = `radio-group-${useId()}`;
|
|
99
|
+
|
|
62
100
|
return (
|
|
63
|
-
<div
|
|
64
|
-
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
101
|
+
<div
|
|
102
|
+
{...props}
|
|
103
|
+
aria-label={!showLabel ? groupLabel : undefined}
|
|
104
|
+
aria-labelledby={showLabel ? `${id}-label` : undefined}
|
|
105
|
+
data-bspk="radio-group"
|
|
106
|
+
id={id}
|
|
107
|
+
role="group"
|
|
108
|
+
>
|
|
109
|
+
{showLabel && <label id={`${id}-label`}>{groupLabel}</label>}
|
|
110
|
+
<div role="radiogroup">
|
|
111
|
+
{options.map(({ label, description, value }, index) => {
|
|
112
|
+
return (
|
|
113
|
+
<ToggleOption description={description} key={`toggle-option-${value || index}`} label={label}>
|
|
114
|
+
<Radio
|
|
115
|
+
aria-label={label}
|
|
116
|
+
checked={groupValue === value}
|
|
117
|
+
name={name}
|
|
118
|
+
onChange={(checked) => checked && onChange(value)}
|
|
119
|
+
value={value}
|
|
120
|
+
/>
|
|
121
|
+
</ToggleOption>
|
|
122
|
+
);
|
|
123
|
+
})}
|
|
124
|
+
</div>
|
|
82
125
|
</div>
|
|
83
126
|
);
|
|
84
127
|
}
|
package/src/RadioOption.tsx
CHANGED
|
@@ -19,13 +19,18 @@ export type RadioOptionProps = InvalidPropsLibrary &
|
|
|
19
19
|
/**
|
|
20
20
|
* A control that allows users to choose one or more items from a list or turn an feature on or off.
|
|
21
21
|
*
|
|
22
|
+
* If only a radio button is needed, consider using the `Radio` component directly.
|
|
23
|
+
*
|
|
22
24
|
* @name RadioOption
|
|
23
25
|
*/
|
|
24
|
-
function RadioOption({ label, description, ...checkboxProps }: RadioOptionProps) {
|
|
26
|
+
function RadioOption({ label: labelProp, description, ...checkboxProps }: RadioOptionProps) {
|
|
27
|
+
const label = labelProp || description;
|
|
25
28
|
return (
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
+
label && (
|
|
30
|
+
<ToggleOption data-bspk="radio-option" description={description} label={label}>
|
|
31
|
+
<Radio {...checkboxProps} aria-label={label} />
|
|
32
|
+
</ToggleOption>
|
|
33
|
+
)
|
|
29
34
|
);
|
|
30
35
|
}
|
|
31
36
|
|
package/src/SearchBar.tsx
CHANGED
|
@@ -10,7 +10,10 @@ import { useFloatingMenu } from './hooks/useFloatingMenu';
|
|
|
10
10
|
import { useId } from './hooks/useId';
|
|
11
11
|
//import { useFloatingMenu } from './hooks/useFloatingMenu';
|
|
12
12
|
|
|
13
|
-
export type SearchBarProps<T extends MenuItem = MenuItem> = Pick<
|
|
13
|
+
export type SearchBarProps<T extends MenuItem = MenuItem> = Pick<
|
|
14
|
+
MenuProps<T>,
|
|
15
|
+
'itemCount' | 'noResultsMessage'
|
|
16
|
+
> &
|
|
14
17
|
Pick<TextInputProps, 'aria-label' | 'id' | 'inputRef' | 'name' | 'size'> & {
|
|
15
18
|
/** The current value of the search bar. */
|
|
16
19
|
value?: string;
|
|
@@ -73,6 +76,40 @@ export type SearchBarProps<T extends MenuItem = MenuItem> = Pick<MenuProps<T>, '
|
|
|
73
76
|
/**
|
|
74
77
|
* Component description coming soon.
|
|
75
78
|
*
|
|
79
|
+
* @example
|
|
80
|
+
* import { useState } from 'react';
|
|
81
|
+
* import { SearchBar } from '@bspk/ui/SearchBar';
|
|
82
|
+
*
|
|
83
|
+
* export function Example() {
|
|
84
|
+
* const [searchText, setSearchText] = useState<string>('');
|
|
85
|
+
*
|
|
86
|
+
* const handleItemSelect = (item) =>
|
|
87
|
+
* console.log('Selected item:', item);
|
|
88
|
+
*
|
|
89
|
+
* return (
|
|
90
|
+
* <SearchBar
|
|
91
|
+
* aria-label="Example aria-label"
|
|
92
|
+
* items={[
|
|
93
|
+
* { value: '1', label: 'Apple Pie' },
|
|
94
|
+
* { value: '2', label: 'Banana Split' },
|
|
95
|
+
* { value: '3', label: 'Cherry Tart' },
|
|
96
|
+
* { value: '4', label: 'Dragonfruit Sorbet' },
|
|
97
|
+
* { value: '5', label: 'Elderberry Jam' },
|
|
98
|
+
* { value: '6', label: 'Fig Newton' },
|
|
99
|
+
* { value: '7', label: 'Grape Soda' },
|
|
100
|
+
* { value: '8', label: 'Honeydew Smoothie' },
|
|
101
|
+
* { value: '9', label: 'Ice Cream Sandwich' },
|
|
102
|
+
* { value: '10', label: 'Jackfruit Pudding' },
|
|
103
|
+
* ]}
|
|
104
|
+
* name="Example name"
|
|
105
|
+
* placeholder="Search"
|
|
106
|
+
* value={searchText}
|
|
107
|
+
* onChange={setSearchText}
|
|
108
|
+
* onSelect={handleItemSelect}
|
|
109
|
+
* />
|
|
110
|
+
* );
|
|
111
|
+
* }
|
|
112
|
+
*
|
|
76
113
|
* @name SearchBar
|
|
77
114
|
*/
|
|
78
115
|
function SearchBar({
|
|
@@ -92,7 +129,12 @@ function SearchBar({
|
|
|
92
129
|
}: SearchBarProps) {
|
|
93
130
|
const id = useId(idProp);
|
|
94
131
|
const {
|
|
95
|
-
triggerProps: {
|
|
132
|
+
triggerProps: {
|
|
133
|
+
ref: triggerRef,
|
|
134
|
+
onClick,
|
|
135
|
+
onKeyDownCapture,
|
|
136
|
+
...triggerProps
|
|
137
|
+
},
|
|
96
138
|
menuProps,
|
|
97
139
|
closeMenu,
|
|
98
140
|
} = useFloatingMenu({
|
|
@@ -154,7 +196,9 @@ function SearchBar({
|
|
|
154
196
|
}
|
|
155
197
|
onChange={(selectedValues, event) => {
|
|
156
198
|
event?.preventDefault();
|
|
157
|
-
const item = items?.find(
|
|
199
|
+
const item = items?.find(
|
|
200
|
+
(i) => i.value === selectedValues[0],
|
|
201
|
+
);
|
|
158
202
|
onSelect?.(item);
|
|
159
203
|
onChange(item?.label || '');
|
|
160
204
|
closeMenu();
|