@bspk/ui 1.1.21 → 1.1.23
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 +32 -2
- package/dist/Badge.js +29 -4
- 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 +25 -4
- package/dist/Link.js +9 -2
- 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/StylesProviderAnywhere.js +1 -1
- package/dist/StylesProviderBetterHomesGardens.js +1 -1
- package/dist/StylesProviderCartus.js +1 -1
- package/dist/StylesProviderCentury21.js +1 -1
- package/dist/StylesProviderColdwellBanker.js +1 -1
- package/dist/StylesProviderCorcoran.js +1 -1
- package/dist/StylesProviderDenaliBoss.js +1 -1
- package/dist/StylesProviderEra.js +1 -1
- package/dist/StylesProviderSothebys.js +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 +21 -7
- 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/base.css +1 -1
- package/dist/demo/examples.js +22 -1
- 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/dist/tooltip.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 +61 -8
- 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 +49 -30
- 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 -9
- package/src/Txt.tsx +14 -2
- package/src/badge.scss +36 -7
- package/src/base.scss +14 -2
- package/src/demo/examples.tsx +28 -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/src/tooltip.scss +4 -4
- 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/Avatar.tsx
CHANGED
|
@@ -80,9 +80,25 @@ export type AvatarProps = {
|
|
|
80
80
|
/**
|
|
81
81
|
* An avatar is a visual representation of a user or entity. It can be used to display an initials, icon, image.
|
|
82
82
|
*
|
|
83
|
-
*
|
|
83
|
+
* @example
|
|
84
|
+
* import { Avatar } from '@bspk/ui/Avatar';
|
|
85
|
+
* import { SvgPerson } from '@bspk/icons/Person';
|
|
84
86
|
*
|
|
85
|
-
*
|
|
87
|
+
* function Example() {
|
|
88
|
+
* return (
|
|
89
|
+
* <Avatar
|
|
90
|
+
* name="Jane Doe"
|
|
91
|
+
* initials="JD"
|
|
92
|
+
* color="blue"
|
|
93
|
+
* size="large"
|
|
94
|
+
* icon={<SvgPerson />}
|
|
95
|
+
* image="/profile.jpg"
|
|
96
|
+
* showTooltip={true}
|
|
97
|
+
* />
|
|
98
|
+
* );
|
|
99
|
+
* }
|
|
100
|
+
*
|
|
101
|
+
* @exampleDescription The image if provided is displayed first, followed by the icon if provided, and finally the initials. If no initials are provided, the first two letters of the name will be used as initials.
|
|
86
102
|
*
|
|
87
103
|
* @name Avatar
|
|
88
104
|
*/
|
package/src/AvatarGroup.tsx
CHANGED
|
@@ -43,6 +43,20 @@ export type AvatarGroupProps = {
|
|
|
43
43
|
/**
|
|
44
44
|
* AvatarGroup component displays a group of avatars.
|
|
45
45
|
*
|
|
46
|
+
* @example
|
|
47
|
+
* import { AvatarGroup } from '@bspk/ui/AvatarGroup';
|
|
48
|
+
*
|
|
49
|
+
* export function Example() {
|
|
50
|
+
* return (
|
|
51
|
+
* <AvatarGroup
|
|
52
|
+
* items={[
|
|
53
|
+
* { name: 'Jane Doe', image: '/path/to/image.jpg' },
|
|
54
|
+
* { name: 'John Smith', initials: 'JS' },
|
|
55
|
+
* ]}
|
|
56
|
+
* />
|
|
57
|
+
* );
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
46
60
|
* @name AvatarGroup
|
|
47
61
|
*/
|
|
48
62
|
function AvatarGroup({ items, size = 'small', max = 5, variant }: AvatarGroupProps) {
|
package/src/Badge.tsx
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
1
3
|
import './badge.scss';
|
|
2
4
|
import { tryIntParse } from './utils/tryIntPsrse';
|
|
3
5
|
|
|
@@ -6,9 +8,15 @@ export type BadgeProps = {
|
|
|
6
8
|
* The content of the badge. If larger than 99, the badge will display '99+'. If null or undefined, the badge will
|
|
7
9
|
* be hidden.
|
|
8
10
|
*
|
|
11
|
+
* @example
|
|
12
|
+
* 5;
|
|
13
|
+
*
|
|
14
|
+
* @default 1
|
|
15
|
+
*
|
|
9
16
|
* @type number
|
|
17
|
+
* @minimum 1
|
|
10
18
|
*/
|
|
11
|
-
count?: number
|
|
19
|
+
count?: number;
|
|
12
20
|
/**
|
|
13
21
|
* The size of the badge.
|
|
14
22
|
*
|
|
@@ -21,25 +29,70 @@ export type BadgeProps = {
|
|
|
21
29
|
* @default primary
|
|
22
30
|
*/
|
|
23
31
|
variant?: 'primary' | 'secondary';
|
|
32
|
+
/**
|
|
33
|
+
* Whether the badge should have a border that matches the surface color.
|
|
34
|
+
*
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
surfaceBorder?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The context for which the badge is applied.
|
|
40
|
+
*
|
|
41
|
+
* Could be a button, link, or any other element that the badge is associated with.
|
|
42
|
+
*
|
|
43
|
+
* @type
|
|
44
|
+
*/
|
|
45
|
+
children?: ReactNode;
|
|
24
46
|
};
|
|
25
47
|
|
|
26
48
|
/**
|
|
27
49
|
* Visual indicator for new items within a parent page represented with a numerical count of new items.
|
|
28
50
|
*
|
|
51
|
+
* @example
|
|
52
|
+
* import { Badge } from '@bspk/ui/badge';
|
|
53
|
+
*
|
|
54
|
+
* function Example() {
|
|
55
|
+
* return <Badge count={5} size="small" variant="primary" />;
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* @exampleDescription This example shows a badge with a count of 5, size small, and primary variant.
|
|
59
|
+
*
|
|
29
60
|
* @name Badge
|
|
30
61
|
*/
|
|
31
|
-
function Badge({ count: countProp, size = 'small', variant = 'primary' }: BadgeProps) {
|
|
62
|
+
function Badge({ count: countProp, size = 'small', variant = 'primary', surfaceBorder, children }: BadgeProps) {
|
|
32
63
|
const count: number | null = tryIntParse(countProp);
|
|
33
64
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
65
|
+
if (count === null) return;
|
|
66
|
+
|
|
67
|
+
const badge = (
|
|
68
|
+
<sup data-bspk="badge" data-size={size} data-surface-border={surfaceBorder || undefined} data-variant={variant}>
|
|
69
|
+
{count > 99 ? '99+' : count}
|
|
70
|
+
</sup>
|
|
40
71
|
);
|
|
72
|
+
|
|
73
|
+
if (children) {
|
|
74
|
+
return (
|
|
75
|
+
<span data-bspk="badge-wrapper">
|
|
76
|
+
{children}
|
|
77
|
+
{badge}
|
|
78
|
+
</span>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return badge;
|
|
41
83
|
}
|
|
42
84
|
|
|
85
|
+
// position: relative;
|
|
86
|
+
// display: -webkit-inline-box;
|
|
87
|
+
// display: -webkit-inline-flex;
|
|
88
|
+
// display: -ms-inline-flexbox;
|
|
89
|
+
// display: inline-flex
|
|
90
|
+
// ;
|
|
91
|
+
// vertical-align: middle;
|
|
92
|
+
// -webkit-flex-shrink: 0;
|
|
93
|
+
// -ms-flex-negative: 0;
|
|
94
|
+
// flex-shrink: 0;
|
|
95
|
+
|
|
43
96
|
Badge.bspkName = 'Badge';
|
|
44
97
|
|
|
45
98
|
export { Badge };
|
package/src/BannerAlert.tsx
CHANGED
|
@@ -51,6 +51,23 @@ export type BannerAlertProps = {
|
|
|
51
51
|
* A visual and contextual message used to communicate an important message or notification to users relating to a
|
|
52
52
|
* status or the body content of a page.
|
|
53
53
|
*
|
|
54
|
+
* @example
|
|
55
|
+
* import { BannerAlert } from '@bspk/ui/BannerAlert';
|
|
56
|
+
*
|
|
57
|
+
* function Example() {
|
|
58
|
+
* <BannerAlert
|
|
59
|
+
* variant="error"
|
|
60
|
+
* header="Error"
|
|
61
|
+
* body="There was an error processing your request."
|
|
62
|
+
* onClose={() => console.log('Alert closed')}
|
|
63
|
+
* />;
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* @exampleDescription This example shows how to use the BannerAlert component with an error variant, a header, and a body message.
|
|
67
|
+
*
|
|
68
|
+
*
|
|
69
|
+
*
|
|
70
|
+
*
|
|
54
71
|
* @name BannerAlert
|
|
55
72
|
*/
|
|
56
73
|
function BannerAlert({
|
package/src/Button.tsx
CHANGED
|
@@ -74,6 +74,22 @@ export type ButtonProps<As extends ElementType = 'button'> = CommonProps<'disabl
|
|
|
74
74
|
/**
|
|
75
75
|
* A clickable component that allows users to perform an action, make a choice or trigger a change in state.
|
|
76
76
|
*
|
|
77
|
+
* @example
|
|
78
|
+
* import { Button } from '@bspk/ui/Button';
|
|
79
|
+
* import { SvgPerson } from '@bspk/icons/Person';
|
|
80
|
+
*
|
|
81
|
+
* function Example() {
|
|
82
|
+
* return (
|
|
83
|
+
* <Button
|
|
84
|
+
* label="Click Me"
|
|
85
|
+
* size="medium"
|
|
86
|
+
* variant="primary"
|
|
87
|
+
* onClick={() => console.log('Button clicked')}
|
|
88
|
+
* icon={<SvgPerson />}
|
|
89
|
+
* />
|
|
90
|
+
* );
|
|
91
|
+
* }
|
|
92
|
+
*
|
|
77
93
|
* @name Button
|
|
78
94
|
*/
|
|
79
95
|
function Button<As extends ElementType = 'button'>(props: ElementProps<ButtonProps<As>, As>): JSX.Element {
|
package/src/Card.tsx
CHANGED
|
@@ -29,6 +29,18 @@ export type CardProps = {
|
|
|
29
29
|
* They are similar in size and shape to playing cards and are intended to encourage users to click or tap to view more
|
|
30
30
|
* details.
|
|
31
31
|
*
|
|
32
|
+
* @example
|
|
33
|
+
* import { Card } from '@bspk/ui/card';
|
|
34
|
+
*
|
|
35
|
+
* function Example() {
|
|
36
|
+
* return (
|
|
37
|
+
* <Card variant="elevated" showPadding={false}>
|
|
38
|
+
* <h3>Card Title</h3>
|
|
39
|
+
* <p>This is some content inside the card.</p>
|
|
40
|
+
* </Card>
|
|
41
|
+
* );
|
|
42
|
+
* }
|
|
43
|
+
*
|
|
32
44
|
* @name Card
|
|
33
45
|
*/
|
|
34
46
|
function Card({ children, showPadding, variant = 'elevated' }: CardProps) {
|
package/src/Checkbox.tsx
CHANGED
|
@@ -32,6 +32,27 @@ export type CheckboxProps = CommonProps<'aria-label' | 'disabled' | 'name'> &
|
|
|
32
32
|
* element and if used directly you must wrap it with a label. This will more often be used in the CheckboxOption or
|
|
33
33
|
* CheckboxGroup component.
|
|
34
34
|
*
|
|
35
|
+
* @example
|
|
36
|
+
* import { Checkbox } from '@bspk/ui/Checkbox';
|
|
37
|
+
*
|
|
38
|
+
* function Example() {
|
|
39
|
+
* const [checked, setChecked] = React.useState(false);
|
|
40
|
+
*
|
|
41
|
+
* return (
|
|
42
|
+
* <label htmlFor="sample-checkbox">
|
|
43
|
+
* <Checkbox
|
|
44
|
+
* aria-label="Sample"
|
|
45
|
+
* checked={checked}
|
|
46
|
+
* id="sample-checkbox"
|
|
47
|
+
* name="sample-checkbox"
|
|
48
|
+
* onChange={(nextChecked) => setChecked(nextChecked)}
|
|
49
|
+
* value="sample"
|
|
50
|
+
* />
|
|
51
|
+
* Checkbox Label
|
|
52
|
+
* </label>
|
|
53
|
+
* );
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
35
56
|
* @element
|
|
36
57
|
*
|
|
37
58
|
* @name Checkbox
|
package/src/CheckboxGroup.tsx
CHANGED
|
@@ -24,6 +24,13 @@ export type CheckboxGroupProps = CommonProps<'aria-label'> & {
|
|
|
24
24
|
/**
|
|
25
25
|
* The options for the checkboxes.
|
|
26
26
|
*
|
|
27
|
+
* @example
|
|
28
|
+
* [
|
|
29
|
+
* { label: 'Option 1', value: 'option1' },
|
|
30
|
+
* { label: 'Option 2', value: 'option2' },
|
|
31
|
+
* { label: 'Option 3', value: 'option3' },
|
|
32
|
+
* ];
|
|
33
|
+
*
|
|
27
34
|
* @type Array<CheckboxGroupOption>
|
|
28
35
|
* @required
|
|
29
36
|
*/
|
|
@@ -47,6 +54,29 @@ export type CheckboxGroupProps = CommonProps<'aria-label'> & {
|
|
|
47
54
|
/**
|
|
48
55
|
* A group of checkboxes that allows users to choose one or more items from a list or turn an feature on or off.
|
|
49
56
|
*
|
|
57
|
+
* @example
|
|
58
|
+
* import { CheckboxGroup } from '@bspk/ui/CheckboxGroup';
|
|
59
|
+
*
|
|
60
|
+
* function Example() {
|
|
61
|
+
* const [values, setValues] = React.useState<string[]>([]);
|
|
62
|
+
*
|
|
63
|
+
* return (
|
|
64
|
+
* <CheckboxGroup
|
|
65
|
+
* aria-label="Example Checkbox Group"
|
|
66
|
+
* name="example-checkbox-group"
|
|
67
|
+
* options={[
|
|
68
|
+
* { label: 'Option 1', value: 'option1' },
|
|
69
|
+
* { label: 'Option 2', value: 'option2' },
|
|
70
|
+
* { label: 'Option 3', value: 'option3' },
|
|
71
|
+
* ]}
|
|
72
|
+
* values={values}
|
|
73
|
+
* onChange={(nextValues: string[]) => {
|
|
74
|
+
* setValues(nextValues);
|
|
75
|
+
* }}
|
|
76
|
+
* />
|
|
77
|
+
* );
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
50
80
|
* @name CheckboxGroup
|
|
51
81
|
*/
|
|
52
82
|
function CheckboxGroup({
|
package/src/CheckboxOption.tsx
CHANGED
|
@@ -17,13 +17,38 @@ export type CheckboxOptionProps = InvalidPropsLibrary &
|
|
|
17
17
|
/**
|
|
18
18
|
* A control that allows users to choose one or more items from a list or turn an feature on or off.
|
|
19
19
|
*
|
|
20
|
+
* If only a Checkbox is needed, consider using the `Checkbox` component directly.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { CheckboxOption } from '@bspk/ui/CheckboxOption';
|
|
24
|
+
*
|
|
25
|
+
* function Example() {
|
|
26
|
+
* const [checked, setChecked] = React.useState(false);
|
|
27
|
+
* return (
|
|
28
|
+
* <CheckboxOption
|
|
29
|
+
* checked={checked}
|
|
30
|
+
* description="This is an example checkbox option."
|
|
31
|
+
* label="Example Checkbox"
|
|
32
|
+
* name="example-checkbox-name"
|
|
33
|
+
* onChange={(nextChecked, event) => {
|
|
34
|
+
* setChecked(nextChecked);
|
|
35
|
+
* console.log('Checkbox changed:', nextChecked, event);
|
|
36
|
+
* }}
|
|
37
|
+
* value="example-checkbox-value"
|
|
38
|
+
* />
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
20
42
|
* @name CheckboxOption
|
|
21
43
|
*/
|
|
22
|
-
function CheckboxOption({ label, description, ...checkboxProps }: CheckboxOptionProps) {
|
|
44
|
+
function CheckboxOption({ label: labelProp, description, ...checkboxProps }: CheckboxOptionProps) {
|
|
45
|
+
const label = labelProp || description;
|
|
23
46
|
return (
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
|
|
47
|
+
label && (
|
|
48
|
+
<ToggleOption data-bspk="checkbox-option" description={description} label={label}>
|
|
49
|
+
<Checkbox {...checkboxProps} aria-label={label} />
|
|
50
|
+
</ToggleOption>
|
|
51
|
+
)
|
|
27
52
|
);
|
|
28
53
|
}
|
|
29
54
|
|
package/src/Chip.tsx
CHANGED
|
@@ -46,6 +46,17 @@ export type ChipProps = CommonProps<'disabled'> & {
|
|
|
46
46
|
/**
|
|
47
47
|
* Dynamically generated options that are suggested to the user as responses or prompts.
|
|
48
48
|
*
|
|
49
|
+
* @example
|
|
50
|
+
* import { Chip } from '@bspk/ui/Chip';
|
|
51
|
+
*
|
|
52
|
+
* function Example() {
|
|
53
|
+
* return (
|
|
54
|
+
* <Chip variant="filter" onClick={() => console.log('Chip clicked!')}>
|
|
55
|
+
* Example Chip
|
|
56
|
+
* </Chip>
|
|
57
|
+
* );
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
49
60
|
* @name Chip
|
|
50
61
|
*/
|
|
51
62
|
function Chip({
|
package/src/Dialog.tsx
CHANGED
|
@@ -44,6 +44,25 @@ export type DialogProps = CommonProps<'id'> & {
|
|
|
44
44
|
* Dialogs display important information that users need to acknowledge. They appear over the interface and block
|
|
45
45
|
* further interactions until an action is selected.
|
|
46
46
|
*
|
|
47
|
+
* @example
|
|
48
|
+
* import { Dialog } from '@bspk/ui/Dialog';
|
|
49
|
+
* import { Button } from '@bspk/ui/Button';
|
|
50
|
+
*
|
|
51
|
+
* function Example() {
|
|
52
|
+
* const [open, setOpen] = React.useState(false);
|
|
53
|
+
*
|
|
54
|
+
* return (
|
|
55
|
+
* <>
|
|
56
|
+
* <Button label="Open Dialog" onClick={() => setOpen(true)} />
|
|
57
|
+
* <Dialog open={open} onClose={() => setOpen(false)}>
|
|
58
|
+
* <h1>Dialog Title</h1>
|
|
59
|
+
* <p>This is the content of the dialog.</p>
|
|
60
|
+
* <button onClick={() => setOpen(false)}>Close</button>
|
|
61
|
+
* </Dialog>
|
|
62
|
+
* </>
|
|
63
|
+
* );
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
47
66
|
* @name Dialog
|
|
48
67
|
*/
|
|
49
68
|
function Dialog({
|
package/src/Divider.tsx
CHANGED
|
@@ -42,6 +42,19 @@ const insetToVariable = (insetProp: number | string) => {
|
|
|
42
42
|
*
|
|
43
43
|
* Vertical thin lines that separates grouped content or other visual elements within a container.
|
|
44
44
|
*
|
|
45
|
+
* @example
|
|
46
|
+
* import { Divider } from '@bspk/ui/Divider';
|
|
47
|
+
*
|
|
48
|
+
* function Example() {
|
|
49
|
+
* return (
|
|
50
|
+
* <div>
|
|
51
|
+
* <p>Content above the divider</p>
|
|
52
|
+
* <Divider orientation="horizontal" />
|
|
53
|
+
* <p>Content below the divider</p>
|
|
54
|
+
* </div>
|
|
55
|
+
* );
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
45
58
|
* @name Divider
|
|
46
59
|
*/
|
|
47
60
|
function Divider({
|
package/src/Dropdown.tsx
CHANGED
|
@@ -74,6 +74,36 @@ export type DropdownProps<T extends DropdownOption = DropdownOption> = CommonPro
|
|
|
74
74
|
/**
|
|
75
75
|
* A field element that allows users to select one option from a list of available choices. *
|
|
76
76
|
*
|
|
77
|
+
* @example
|
|
78
|
+
* import { Dropdown } from '@bspk/ui/Dropdown';
|
|
79
|
+
*
|
|
80
|
+
* export function Example() {
|
|
81
|
+
* const [selected, setSelected] = React.useState<string[]>([]);
|
|
82
|
+
* return (
|
|
83
|
+
* <Dropdown
|
|
84
|
+
* aria-label="Select an option"
|
|
85
|
+
* itemCount={5}
|
|
86
|
+
* name="example-dropdown"
|
|
87
|
+
* onChange={setSelected}
|
|
88
|
+
* options={[
|
|
89
|
+
* { value: '1', label: 'Option 1' },
|
|
90
|
+
* { value: '2', label: 'Option 2' },
|
|
91
|
+
* { value: '3', label: 'Option 3' },
|
|
92
|
+
* { value: '4', label: 'Option 4' },
|
|
93
|
+
* { value: '5', label: 'Option 5' },
|
|
94
|
+
* { value: '6', label: 'Option 6' },
|
|
95
|
+
* { value: '7', label: 'Option 7' },
|
|
96
|
+
* { value: '8', label: 'Option 8' },
|
|
97
|
+
* { value: '9', label: 'Option 9' },
|
|
98
|
+
* { value: '10', label: 'Option 10' },
|
|
99
|
+
* ]}
|
|
100
|
+
* placeholder="Select an option"
|
|
101
|
+
* size="medium"
|
|
102
|
+
* value={selected}
|
|
103
|
+
* />
|
|
104
|
+
* );
|
|
105
|
+
* }
|
|
106
|
+
*
|
|
77
107
|
* @name Dropdown
|
|
78
108
|
*/
|
|
79
109
|
function Dropdown({
|
package/src/DropdownField.tsx
CHANGED
|
@@ -21,6 +21,28 @@ export type DropdownFieldProps = Pick<
|
|
|
21
21
|
*
|
|
22
22
|
* This component takes properties from the FormField and Dropdown components.
|
|
23
23
|
*
|
|
24
|
+
* @example
|
|
25
|
+
* import { DropdownField } from '@bspk/ui/DropdownField';
|
|
26
|
+
*
|
|
27
|
+
* export function Example() {
|
|
28
|
+
* const [state, setState] = React.useState(['option1']);
|
|
29
|
+
* return (
|
|
30
|
+
* <DropdownField
|
|
31
|
+
* controlId="Example controlId"
|
|
32
|
+
* label="Example label"
|
|
33
|
+
* name="Example name"
|
|
34
|
+
* onChange={(nextValue) => setState(nextValue)}
|
|
35
|
+
* options={[
|
|
36
|
+
* { label: 'Option 1', value: 'option1' },
|
|
37
|
+
* { label: 'Option 2', value: 'option2' },
|
|
38
|
+
* { label: 'Option 3', value: 'option3' },
|
|
39
|
+
* ]}
|
|
40
|
+
* placeholder="Select one..."
|
|
41
|
+
* value={state}
|
|
42
|
+
* />
|
|
43
|
+
* );
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
24
46
|
* @name DropdownField
|
|
25
47
|
*/
|
|
26
48
|
function DropdownField({
|
package/src/EmptyState.tsx
CHANGED
|
@@ -38,6 +38,17 @@ export type EmptyStateProps = {
|
|
|
38
38
|
/**
|
|
39
39
|
* A design pattern component that indicates to users that system has no content to display.
|
|
40
40
|
*
|
|
41
|
+
* @example
|
|
42
|
+
* import { EmptyState } from '@bspk/ui/EmptyState';
|
|
43
|
+
*
|
|
44
|
+
* export function Example() {
|
|
45
|
+
* return (
|
|
46
|
+
* <EmptyState body="Example body" header="Example header">
|
|
47
|
+
* Example EmptyState
|
|
48
|
+
* </EmptyState>
|
|
49
|
+
* );
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
41
52
|
* @name EmptyState
|
|
42
53
|
*/
|
|
43
54
|
function EmptyState({ children, header, body, callToAction, bodyAlign = 'center' }: EmptyStateProps) {
|
package/src/Fab.tsx
CHANGED
|
@@ -45,6 +45,14 @@ export type FabProps<As extends ElementType = 'button'> = Pick<
|
|
|
45
45
|
* A button that highlights a primary action that is elevated above the body content of a page; normally fixed to the
|
|
46
46
|
* bottom right of a screen.
|
|
47
47
|
*
|
|
48
|
+
* @example
|
|
49
|
+
* import { SvgBolt } from '@bspk/icons/Bolt';
|
|
50
|
+
* import { Fab } from '@bspk/ui/Fab';
|
|
51
|
+
*
|
|
52
|
+
* export function Example() {
|
|
53
|
+
* return <Fab icon={<SvgBolt />} label="Example label" placement="bottom-right" variant="neutral" />;
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
48
56
|
* @name Fab
|
|
49
57
|
*/
|
|
50
58
|
function Fab<As extends ElementType = 'button'>({
|
package/src/FormField.tsx
CHANGED
|
@@ -47,6 +47,31 @@ export type FormFieldProps = CommonProps<'required'> &
|
|
|
47
47
|
*
|
|
48
48
|
* Children may be one of the following: TextInput, Dropdown, DatePicker, or TimePicker.
|
|
49
49
|
*
|
|
50
|
+
* @example
|
|
51
|
+
* import { TextInput } from '@bspk/ui/TextInput';
|
|
52
|
+
* import { FormField } from '@bspk/ui/FormField';
|
|
53
|
+
*
|
|
54
|
+
* export function Example() {
|
|
55
|
+
* const [state, setState] = React.useState<string | undefined>(undefined);
|
|
56
|
+
* return (
|
|
57
|
+
* <FormField controlId="Example controlId" label="Example label">
|
|
58
|
+
* {(fieldProps) => {
|
|
59
|
+
* return (
|
|
60
|
+
* <TextInput
|
|
61
|
+
* aria-label="example aria-label"
|
|
62
|
+
* name="example-text"
|
|
63
|
+
* onChange={(next) => {
|
|
64
|
+
* setState(next);
|
|
65
|
+
* }}
|
|
66
|
+
* value={state}
|
|
67
|
+
* {...fieldProps}
|
|
68
|
+
* />
|
|
69
|
+
* );
|
|
70
|
+
* }}
|
|
71
|
+
* </FormField>
|
|
72
|
+
* );
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
50
75
|
* @name FormField
|
|
51
76
|
*/
|
|
52
77
|
function FormField({
|
package/src/Img.tsx
CHANGED
|
@@ -18,6 +18,13 @@ export type ImgProps = {
|
|
|
18
18
|
/**
|
|
19
19
|
* The Img component is used to display images on the page.
|
|
20
20
|
*
|
|
21
|
+
* @example
|
|
22
|
+
* import { Img } from '@bspk/ui/Img';
|
|
23
|
+
*
|
|
24
|
+
* export function Example() {
|
|
25
|
+
* return <Img alt="Example alt" src="Example src" />;
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
21
28
|
* @name Img
|
|
22
29
|
*/
|
|
23
30
|
function Img({ alt, ...props }: ElementProps<ImgProps, 'img'>) {
|
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'>({
|