@boostdev/design-system-components 1.2.0 → 1.2.2
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/AGENTS.md +46 -4
- package/README.md +15 -15
- package/dist/client.cjs +149 -124
- package/dist/client.css +503 -525
- package/dist/client.d.cts +71 -96
- package/dist/client.d.ts +71 -96
- package/dist/client.js +149 -124
- package/dist/index.cjs +149 -124
- package/dist/index.css +503 -525
- package/dist/index.d.cts +71 -96
- package/dist/index.d.ts +71 -96
- package/dist/index.js +149 -124
- package/dist/web-components/{chunk-6MH5UWUD.js → chunk-2FGATTGT.js} +5 -0
- package/dist/web-components/{chunk-5IPHEONG.js → chunk-6I2DBFQ7.js} +1 -0
- package/dist/web-components/{chunk-DI46Q2EA.js → chunk-OCODKRVZ.js} +57 -82
- package/dist/web-components/index.d.ts +571 -1
- package/dist/web-components/index.js +1501 -4
- package/dist/web-components/interaction/bds-collapsible.js +1 -1
- package/dist/web-components/interaction/bds-drawer.js +1 -1
- package/dist/web-components/interaction/form/bds-segmented-control.js +1 -1
- package/package.json +1 -1
- package/src/components/interaction/Command/Command.tsx +4 -3
- package/src/components/interaction/Dialog/Dialog.tsx +4 -5
- package/src/components/interaction/Drawer/Drawer.module.css +37 -62
- package/src/components/interaction/Drawer/Drawer.spec.tsx +3 -3
- package/src/components/interaction/Drawer/Drawer.tsx +25 -24
- package/src/components/interaction/DropdownMenu/DropdownMenu.tsx +4 -2
- package/src/components/interaction/Popover/Popover.tsx +4 -3
- package/src/components/interaction/Rating/Rating.tsx +4 -2
- package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.tsx +4 -6
- package/src/components/interaction/form/Combobox/Combobox.tsx +4 -2
- package/src/components/interaction/form/FileInput/FileInput.tsx +4 -3
- package/src/components/interaction/form/NumberInput/NumberInput.tsx +4 -3
- package/src/components/interaction/form/RadioGroup/RadioGroup.tsx +4 -6
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.mdx +8 -4
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.module.css +13 -6
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.tsx +4 -6
- package/src/components/interaction/form/atoms/InputContainer.tsx +2 -2
- package/src/components/layout/ButtonGroup/ButtonGroup.tsx +4 -6
- package/src/components/layout/Card/Card.tsx +4 -10
- package/src/components/layout/IconWrapper/IconWrapper.tsx +4 -5
- package/src/components/layout/SectionHeader/SectionHeader.tsx +5 -4
- package/src/components/ui/Accordion/Accordion.tsx +4 -3
- package/src/components/ui/Alert/Alert.tsx +4 -3
- package/src/components/ui/Avatar/Avatar.tsx +5 -3
- package/src/components/ui/Badge/Badge.tsx +4 -5
- package/src/components/ui/Breadcrumb/Breadcrumb.tsx +4 -3
- package/src/components/ui/Calendar/Calendar.tsx +4 -4
- package/src/components/ui/Carousel/Carousel.tsx +4 -4
- package/src/components/ui/DescriptionList/DescriptionList.tsx +4 -4
- package/src/components/ui/Loading/Loading.tsx +4 -3
- package/src/components/ui/NotificationBanner/NotificationBanner.tsx +4 -2
- package/src/components/ui/Pagination/Pagination.tsx +4 -2
- package/src/components/ui/Progress/Progress.tsx +4 -2
- package/src/components/ui/ProgressCircle/ProgressCircle.tsx +4 -1
- package/src/components/ui/Separator/Separator.tsx +5 -3
- package/src/components/ui/Skeleton/Skeleton.tsx +4 -3
- package/src/components/ui/SkipLink/SkipLink.tsx +4 -5
- package/src/components/ui/Tabs/Tabs.tsx +4 -4
- package/src/components/ui/Tooltip/Tooltip.tsx +4 -2
- package/src/components/ui/Typography/Typography.tsx +4 -5
- package/src/stories/DesignSystem/Grid.mdx +2 -0
- package/src/stories/Introduction.mdx +2 -1
- package/src/web-components/index.ts +12 -0
- package/src/web-components/interaction/BdsAccordion.mdx +80 -28
- package/src/web-components/interaction/BdsAccordion.stories.tsx +67 -58
- package/src/web-components/interaction/BdsCollapsible.mdx +93 -23
- package/src/web-components/interaction/BdsCollapsible.stories.tsx +29 -48
- package/src/web-components/interaction/BdsDialog.mdx +88 -27
- package/src/web-components/interaction/BdsDialog.stories.tsx +129 -47
- package/src/web-components/interaction/BdsDrawer.mdx +85 -27
- package/src/web-components/interaction/BdsDrawer.stories.tsx +161 -31
- package/src/web-components/interaction/BdsDropdownMenu.mdx +108 -0
- package/src/web-components/interaction/BdsDropdownMenu.stories.tsx +91 -0
- package/src/web-components/interaction/BdsSkipLink.mdx +72 -16
- package/src/web-components/interaction/BdsSkipLink.stories.tsx +47 -34
- package/src/web-components/interaction/BdsTabs.mdx +97 -27
- package/src/web-components/interaction/BdsTabs.stories.tsx +69 -55
- package/src/web-components/interaction/BdsTooltip.mdx +84 -18
- package/src/web-components/interaction/BdsTooltip.stories.tsx +49 -30
- package/src/web-components/interaction/bds-collapsible.ts +1 -0
- package/src/web-components/interaction/bds-drawer.ts +59 -82
- package/src/web-components/interaction/bds-dropdown-menu-item.ts +124 -0
- package/src/web-components/interaction/bds-dropdown-menu.spec.ts +102 -0
- package/src/web-components/interaction/bds-dropdown-menu.ts +200 -0
- package/src/web-components/interaction/form/BdsCheckbox.mdx +57 -20
- package/src/web-components/interaction/form/BdsCheckbox.stories.tsx +35 -36
- package/src/web-components/interaction/form/BdsCheckboxGroup.mdx +70 -0
- package/src/web-components/interaction/form/BdsCheckboxGroup.stories.tsx +81 -0
- package/src/web-components/interaction/form/BdsCombobox.mdx +52 -33
- package/src/web-components/interaction/form/BdsCombobox.stories.tsx +55 -53
- package/src/web-components/interaction/form/BdsFileInput.mdx +59 -24
- package/src/web-components/interaction/form/BdsFileInput.stories.tsx +38 -53
- package/src/web-components/interaction/form/BdsFormInput.mdx +98 -0
- package/src/web-components/interaction/form/BdsFormInput.stories.tsx +139 -0
- package/src/web-components/interaction/form/BdsNumberInput.mdx +51 -22
- package/src/web-components/interaction/form/BdsNumberInput.stories.tsx +24 -46
- package/src/web-components/interaction/form/BdsRadio.mdx +53 -22
- package/src/web-components/interaction/form/BdsRadio.stories.tsx +19 -51
- package/src/web-components/interaction/form/BdsRadioGroup.mdx +73 -0
- package/src/web-components/interaction/form/BdsRadioGroup.stories.tsx +88 -0
- package/src/web-components/interaction/form/BdsSegmentedControl.mdx +76 -23
- package/src/web-components/interaction/form/BdsSegmentedControl.stories.tsx +64 -54
- package/src/web-components/interaction/form/BdsSelect.mdx +59 -21
- package/src/web-components/interaction/form/BdsSelect.stories.tsx +47 -56
- package/src/web-components/interaction/form/BdsSlider.mdx +55 -27
- package/src/web-components/interaction/form/BdsSlider.stories.tsx +23 -44
- package/src/web-components/interaction/form/BdsSwitch.mdx +53 -20
- package/src/web-components/interaction/form/BdsSwitch.stories.tsx +22 -37
- package/src/web-components/interaction/form/BdsTextarea.mdx +54 -22
- package/src/web-components/interaction/form/BdsTextarea.stories.tsx +35 -44
- package/src/web-components/interaction/form/bds-checkbox-group.spec.ts +55 -0
- package/src/web-components/interaction/form/bds-checkbox-group.ts +117 -0
- package/src/web-components/interaction/form/bds-form-input.spec.ts +83 -0
- package/src/web-components/interaction/form/bds-form-input.ts +268 -0
- package/src/web-components/interaction/form/bds-radio-group.spec.ts +62 -0
- package/src/web-components/interaction/form/bds-radio-group.ts +142 -0
- package/src/web-components/interaction/form/bds-segmented-control.ts +5 -0
- package/src/web-components/ui/BdsAvatar.mdx +29 -20
- package/src/web-components/ui/BdsAvatar.stories.tsx +14 -28
- package/src/web-components/ui/BdsBreadcrumb.mdx +22 -19
- package/src/web-components/ui/BdsBreadcrumb.stories.tsx +11 -21
- package/src/web-components/ui/BdsButtonGroup.mdx +69 -0
- package/src/web-components/ui/BdsButtonGroup.stories.tsx +66 -0
- package/src/web-components/ui/BdsCalendar.mdx +93 -0
- package/src/web-components/ui/BdsCalendar.stories.tsx +63 -0
- package/src/web-components/ui/BdsCard.mdx +30 -25
- package/src/web-components/ui/BdsCard.stories.tsx +19 -42
- package/src/web-components/ui/BdsCarousel.mdx +83 -0
- package/src/web-components/ui/BdsCarousel.stories.tsx +96 -0
- package/src/web-components/ui/BdsDescriptionList.mdx +13 -16
- package/src/web-components/ui/BdsDescriptionList.stories.tsx +34 -49
- package/src/web-components/ui/BdsIconWrapper.mdx +20 -20
- package/src/web-components/ui/BdsIconWrapper.stories.tsx +46 -41
- package/src/web-components/ui/BdsLink.mdx +21 -17
- package/src/web-components/ui/BdsLink.stories.tsx +19 -20
- package/src/web-components/ui/BdsLoading.mdx +9 -13
- package/src/web-components/ui/BdsLoading.stories.tsx +8 -10
- package/src/web-components/ui/BdsNotificationBanner.mdx +32 -37
- package/src/web-components/ui/BdsNotificationBanner.stories.tsx +38 -47
- package/src/web-components/ui/BdsPagination.mdx +74 -0
- package/src/web-components/ui/BdsPagination.stories.tsx +36 -0
- package/src/web-components/ui/BdsProgress.mdx +24 -17
- package/src/web-components/ui/BdsProgress.stories.tsx +55 -29
- package/src/web-components/ui/BdsProgressCircle.mdx +24 -18
- package/src/web-components/ui/BdsProgressCircle.stories.tsx +17 -29
- package/src/web-components/ui/BdsRating.mdx +22 -22
- package/src/web-components/ui/BdsRating.stories.tsx +19 -13
- package/src/web-components/ui/BdsSectionHeader.mdx +31 -28
- package/src/web-components/ui/BdsSectionHeader.stories.tsx +21 -23
- package/src/web-components/ui/BdsSeparator.mdx +22 -8
- package/src/web-components/ui/BdsSeparator.stories.tsx +27 -19
- package/src/web-components/ui/BdsSkeleton.mdx +20 -26
- package/src/web-components/ui/BdsSkeleton.stories.tsx +23 -23
- package/src/web-components/ui/BdsTable.mdx +81 -0
- package/src/web-components/ui/BdsTable.stories.tsx +83 -0
- package/src/web-components/ui/BdsTypography.mdx +20 -29
- package/src/web-components/ui/BdsTypography.stories.tsx +19 -18
- package/src/web-components/ui/bds-button-group.spec.ts +40 -0
- package/src/web-components/ui/bds-button-group.ts +78 -0
- package/src/web-components/ui/bds-calendar.spec.ts +91 -0
- package/src/web-components/ui/bds-calendar.ts +427 -0
- package/src/web-components/ui/bds-carousel.spec.ts +64 -0
- package/src/web-components/ui/bds-carousel.ts +296 -0
- package/src/web-components/ui/bds-pagination.spec.ts +67 -0
- package/src/web-components/ui/bds-pagination.ts +197 -0
- package/src/web-components/ui/bds-table.spec.ts +45 -0
- package/src/web-components/ui/bds-table.ts +96 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KeyboardEvent, ReactNode, useId, useRef, useState } from 'react';
|
|
1
|
+
import { HTMLAttributes, KeyboardEvent, ReactNode, useId, useRef, useState } from 'react';
|
|
2
2
|
import css from './Tabs.module.css';
|
|
3
3
|
import { cn } from '@boostdev/design-system-foundation';
|
|
4
4
|
import type { WithClassName } from '../../../types';
|
|
@@ -10,12 +10,12 @@ export interface TabItem {
|
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
interface TabsProps extends WithClassName {
|
|
13
|
+
interface TabsProps extends WithClassName, HTMLAttributes<HTMLDivElement> {
|
|
14
14
|
tabs: TabItem[];
|
|
15
15
|
defaultTab?: string;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export function Tabs({ tabs, defaultTab, className }: Readonly<TabsProps>) {
|
|
18
|
+
export function Tabs({ tabs, defaultTab, className, ...rest }: Readonly<TabsProps>) {
|
|
19
19
|
const baseId = useId();
|
|
20
20
|
const [activeTab, setActiveTab] = useState(defaultTab ?? tabs[0]?.id);
|
|
21
21
|
const tabRefs = useRef<(HTMLButtonElement | null)[]>([]);
|
|
@@ -49,7 +49,7 @@ export function Tabs({ tabs, defaultTab, className }: Readonly<TabsProps>) {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
return (
|
|
52
|
-
<div className={cn(css.tabs, className)}>
|
|
52
|
+
<div {...rest} className={cn(css.tabs, className)}>
|
|
53
53
|
<div role="tablist" className={css.tabList}>
|
|
54
54
|
{tabs.map((tab, i) => {
|
|
55
55
|
const tabId = `${baseId}-tab-${tab.id}`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ReactElement, ReactNode, cloneElement, isValidElement, useId, useState } from 'react';
|
|
1
|
+
import { HTMLAttributes, ReactElement, ReactNode, cloneElement, isValidElement, useId, useState } from 'react';
|
|
2
2
|
import css from './Tooltip.module.css';
|
|
3
3
|
import { cn } from '@boostdev/design-system-foundation';
|
|
4
4
|
import type { WithClassName } from '../../../types';
|
|
5
5
|
|
|
6
|
-
interface TooltipProps extends WithClassName {
|
|
6
|
+
interface TooltipProps extends WithClassName, Omit<HTMLAttributes<HTMLSpanElement>, 'content'> {
|
|
7
7
|
content: ReactNode;
|
|
8
8
|
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
9
9
|
children: ReactElement;
|
|
@@ -14,6 +14,7 @@ export function Tooltip({
|
|
|
14
14
|
placement = 'top',
|
|
15
15
|
children,
|
|
16
16
|
className,
|
|
17
|
+
...rest
|
|
17
18
|
}: Readonly<TooltipProps>) {
|
|
18
19
|
const tooltipId = useId();
|
|
19
20
|
const [isVisible, setIsVisible] = useState(false);
|
|
@@ -26,6 +27,7 @@ export function Tooltip({
|
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
29
|
<span
|
|
30
|
+
{...rest}
|
|
29
31
|
className={cn(css.wrapper, className)}
|
|
30
32
|
onMouseEnter={() => setIsVisible(true)}
|
|
31
33
|
onMouseLeave={() => setIsVisible(false)}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ElementType, HTMLAttributes } from 'react';
|
|
2
2
|
import css from './Typography.module.css';
|
|
3
3
|
import { cn } from '@boostdev/design-system-foundation';
|
|
4
4
|
import type { WithClassName } from '../../../types';
|
|
5
5
|
|
|
6
6
|
type TypographyVariant = 'h1' | 'h2' | 'h3' | 'body' | 'body_s';
|
|
7
7
|
|
|
8
|
-
interface TypographyProps extends WithClassName {
|
|
8
|
+
interface TypographyProps extends WithClassName, HTMLAttributes<HTMLElement> {
|
|
9
9
|
variant?: TypographyVariant;
|
|
10
10
|
component?: ElementType;
|
|
11
|
-
children: ReactNode;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
const variantToElement: Record<TypographyVariant, ElementType> = {
|
|
@@ -19,10 +18,10 @@ const variantToElement: Record<TypographyVariant, ElementType> = {
|
|
|
19
18
|
body_s: 'p',
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
export function Typography({ variant = 'body', component, children, className }: TypographyProps) {
|
|
21
|
+
export function Typography({ variant = 'body', component, children, className, ...rest }: TypographyProps) {
|
|
23
22
|
const Component = component || variantToElement[variant];
|
|
24
23
|
|
|
25
24
|
return (
|
|
26
|
-
<Component className={cn(css.typography, css[`--${variant}`], className)}>{children}</Component>
|
|
25
|
+
<Component {...rest} className={cn(css.typography, css[`--${variant}`], className)}>{children}</Component>
|
|
27
26
|
);
|
|
28
27
|
}
|
|
@@ -122,6 +122,8 @@ Apply the built-in layout utilities to use the grid system without writing CSS:
|
|
|
122
122
|
</div>
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
+
> **Important:** Every direct child of `utl-main-grid` **must** set `grid-column: var(--bds-grid_span-<variant>);` (e.g. `--bds-grid_span-100`, `--bds-grid_span-50`). Without it the child collapses to a single column and the responsive grid behaviour is lost.
|
|
126
|
+
|
|
125
127
|
## Custom grid usage
|
|
126
128
|
|
|
127
129
|
```css
|
|
@@ -5,6 +5,7 @@ import foundationPackageJson from '../../node_modules/@boostdev/design-system-fo
|
|
|
5
5
|
import './Introduction.css';
|
|
6
6
|
import {ButtonGroup} from "../components/layout/ButtonGroup/index.ts";
|
|
7
7
|
import {Card} from "../components/layout/Card/index.ts";
|
|
8
|
+
import logo from '../static/logo.svg';
|
|
8
9
|
|
|
9
10
|
<Meta title="Introduction"/>
|
|
10
11
|
|
|
@@ -12,7 +13,7 @@ import {Card} from "../components/layout/Card/index.ts";
|
|
|
12
13
|
|
|
13
14
|
<div>
|
|
14
15
|
<div>
|
|
15
|
-
<img src=
|
|
16
|
+
<img src={logo} alt="BoostDev logo" width={200}/>
|
|
16
17
|
<div className="title">Design System Foundation {foundationPackageJson.version} &<br/> Components {componentsPackageJson.version}</div>
|
|
17
18
|
</div>
|
|
18
19
|
<div className="main-description">
|
|
@@ -57,3 +57,15 @@ export { BdsIconWrapper } from './ui/bds-icon-wrapper';
|
|
|
57
57
|
export { BdsDescriptionList } from './ui/bds-description-list';
|
|
58
58
|
export { BdsBreadcrumb } from './ui/bds-breadcrumb';
|
|
59
59
|
export { BdsLink } from './ui/bds-link';
|
|
60
|
+
|
|
61
|
+
// Phase 8 — complete parity with React library
|
|
62
|
+
export { BdsButtonGroup } from './ui/bds-button-group';
|
|
63
|
+
export { BdsTable } from './ui/bds-table';
|
|
64
|
+
export { BdsPagination } from './ui/bds-pagination';
|
|
65
|
+
export { BdsCheckboxGroup } from './interaction/form/bds-checkbox-group';
|
|
66
|
+
export { BdsRadioGroup } from './interaction/form/bds-radio-group';
|
|
67
|
+
export { BdsFormInput } from './interaction/form/bds-form-input';
|
|
68
|
+
export { BdsCarousel } from './ui/bds-carousel';
|
|
69
|
+
export { BdsCalendar } from './ui/bds-calendar';
|
|
70
|
+
export { BdsDropdownMenu } from './interaction/bds-dropdown-menu';
|
|
71
|
+
export { BdsDropdownMenuItem } from './interaction/bds-dropdown-menu-item';
|
|
@@ -3,49 +3,101 @@ import * as Stories from './BdsAccordion.stories';
|
|
|
3
3
|
|
|
4
4
|
<Meta of={Stories} />
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# <bds-accordion>
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Framework-agnostic Accordion custom element. Coordinates open/closed state across `<bds-accordion-item>` children; by default only one item is open at a time.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
> **Status: experimental** — API may change before stable release.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
import '@boostdev/components/web-components';
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or in HTML without a bundler:
|
|
11
19
|
|
|
12
20
|
```html
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<p>Content for section 1.</p>
|
|
17
|
-
</bds-accordion-item>
|
|
18
|
-
<bds-accordion-item>
|
|
19
|
-
<span slot="header">Section 2</span>
|
|
20
|
-
<p>Content for section 2.</p>
|
|
21
|
-
</bds-accordion-item>
|
|
22
|
-
</bds-accordion>
|
|
21
|
+
<script type="module">
|
|
22
|
+
import '@boostdev/components/web-components';
|
|
23
|
+
</script>
|
|
23
24
|
```
|
|
24
25
|
|
|
26
|
+
## When to use
|
|
27
|
+
|
|
28
|
+
- Displaying a list of questions and answers (FAQ)
|
|
29
|
+
- Grouping related settings or options to reduce visual clutter
|
|
30
|
+
- Progressive disclosure of content sections on a page
|
|
31
|
+
|
|
32
|
+
## When not to use
|
|
33
|
+
|
|
34
|
+
- When all sections should be visible at once — use a regular list or `<bds-collapsible>` per section instead
|
|
35
|
+
- For navigation — use a menu or sidebar
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
### Default (single open)
|
|
40
|
+
<Canvas of={Stories.Default} />
|
|
41
|
+
|
|
42
|
+
### Allow multiple open
|
|
43
|
+
<Canvas of={Stories.AllowMultiple} />
|
|
44
|
+
|
|
45
|
+
### With disabled item
|
|
46
|
+
<Canvas of={Stories.WithDisabledItem} />
|
|
47
|
+
|
|
48
|
+
## Props
|
|
49
|
+
|
|
50
|
+
<ArgTypes of={Stories} />
|
|
51
|
+
|
|
25
52
|
## Attributes — `<bds-accordion>`
|
|
26
53
|
|
|
27
|
-
| Attribute
|
|
28
|
-
|
|
29
|
-
| `allow-multiple` |
|
|
54
|
+
| Attribute | Type | Default | Description |
|
|
55
|
+
|-----------|------|---------|-------------|
|
|
56
|
+
| `allow-multiple` | boolean | `false` | When set, multiple items can be open simultaneously |
|
|
30
57
|
|
|
31
58
|
## Attributes — `<bds-accordion-item>`
|
|
32
59
|
|
|
33
|
-
| Attribute
|
|
34
|
-
|
|
35
|
-
| `
|
|
60
|
+
| Attribute | Type | Default | Description |
|
|
61
|
+
|-----------|------|---------|-------------|
|
|
62
|
+
| `open` | boolean | `false` | Whether this panel is currently expanded |
|
|
63
|
+
| `disabled` | boolean | `false` | Prevents the user from toggling this item |
|
|
36
64
|
|
|
37
65
|
## Slots — `<bds-accordion-item>`
|
|
38
66
|
|
|
39
|
-
| Slot
|
|
40
|
-
|
|
41
|
-
| `header`
|
|
42
|
-
| (default) | The
|
|
67
|
+
| Slot | Description |
|
|
68
|
+
|------|-------------|
|
|
69
|
+
| `header` | The always-visible trigger label |
|
|
70
|
+
| `(default)` | The content revealed when the item is open |
|
|
43
71
|
|
|
44
|
-
##
|
|
72
|
+
## Events
|
|
45
73
|
|
|
46
|
-
|
|
47
|
-
|
|
74
|
+
| Event | Bubbles | Description |
|
|
75
|
+
|-------|---------|-------------|
|
|
76
|
+
| `bds-accordion-item-toggle` | Yes | Fired by `<bds-accordion-item>` when the trigger is clicked; the parent accordion handles state |
|
|
48
77
|
|
|
49
|
-
##
|
|
78
|
+
## Usage in plain HTML
|
|
50
79
|
|
|
51
|
-
|
|
80
|
+
```html
|
|
81
|
+
<bds-accordion>
|
|
82
|
+
<bds-accordion-item open>
|
|
83
|
+
<span slot="header">What is Boost Components?</span>
|
|
84
|
+
<p>A framework-agnostic component library built on web standards.</p>
|
|
85
|
+
</bds-accordion-item>
|
|
86
|
+
<bds-accordion-item>
|
|
87
|
+
<span slot="header">How do I install it?</span>
|
|
88
|
+
<p>Run npm install @boostdev/components.</p>
|
|
89
|
+
</bds-accordion-item>
|
|
90
|
+
</bds-accordion>
|
|
91
|
+
|
|
92
|
+
<!-- Allow multiple panels open at once -->
|
|
93
|
+
<bds-accordion allow-multiple>
|
|
94
|
+
<!-- ... -->
|
|
95
|
+
</bds-accordion>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Accessibility
|
|
99
|
+
|
|
100
|
+
- Each trigger is a `<button>` inside an `<h3>` heading with `aria-expanded` and `aria-controls` wired to the corresponding panel
|
|
101
|
+
- Panels use `role="region"` and `aria-labelledby` pointing back to the trigger
|
|
102
|
+
- `disabled` prevents toggle and conveys state via the native `disabled` attribute on the button
|
|
103
|
+
- Chevron icon is `aria-hidden="true"`
|
|
@@ -1,85 +1,94 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import '../index';
|
|
3
|
+
import '../index'; // auto-registers all custom elements
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// Thin wrapper for bds-accordion-item
|
|
6
|
+
function BdsAccordionItem({
|
|
7
|
+
open,
|
|
8
|
+
disabled,
|
|
9
|
+
header,
|
|
10
|
+
children,
|
|
11
|
+
}: {
|
|
12
|
+
open?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
header?: string;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
}) {
|
|
17
|
+
return React.createElement(
|
|
18
|
+
'bds-accordion-item',
|
|
19
|
+
{ open: open || undefined, disabled: disabled || undefined },
|
|
20
|
+
React.createElement('span', { slot: 'header' }, header ?? 'Accordion item'),
|
|
21
|
+
children ?? React.createElement('p', { style: { margin: 0 } }, 'Accordion panel content.'),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Thin wrapper for bds-accordion
|
|
26
|
+
function BdsAccordion({
|
|
27
|
+
allowMultiple,
|
|
28
|
+
children,
|
|
29
|
+
}: {
|
|
30
|
+
allowMultiple?: boolean;
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
}) {
|
|
6
33
|
return React.createElement(
|
|
7
34
|
'bds-accordion',
|
|
8
35
|
{ 'allow-multiple': allowMultiple || undefined },
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
children,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Top-level wrapper used by Storybook controls
|
|
41
|
+
function BdsAccordionStory({
|
|
42
|
+
allowMultiple = false,
|
|
43
|
+
}: {
|
|
44
|
+
allowMultiple?: boolean;
|
|
45
|
+
}) {
|
|
46
|
+
return (
|
|
47
|
+
<BdsAccordion allowMultiple={allowMultiple}>
|
|
48
|
+
<BdsAccordionItem header="What is Boost Components?" open>
|
|
49
|
+
{React.createElement('p', { style: { margin: 0 } }, 'A framework-agnostic component library built on web standards.')}
|
|
50
|
+
</BdsAccordionItem>
|
|
51
|
+
<BdsAccordionItem header="How do I install it?">
|
|
52
|
+
{React.createElement('p', { style: { margin: 0 } }, 'Run npm install @boostdev/components and import the web components entry point.')}
|
|
53
|
+
</BdsAccordionItem>
|
|
54
|
+
<BdsAccordionItem header="Does it support dark mode?">
|
|
55
|
+
{React.createElement('p', { style: { margin: 0 } }, 'Yes — all design tokens respond to [data-theme="dark"] and prefers-color-scheme: dark.')}
|
|
56
|
+
</BdsAccordionItem>
|
|
57
|
+
</BdsAccordion>
|
|
27
58
|
);
|
|
28
59
|
}
|
|
29
60
|
|
|
30
61
|
const meta = {
|
|
31
62
|
title: 'Web Components/Interaction/Accordion',
|
|
32
|
-
component:
|
|
63
|
+
component: BdsAccordionStory,
|
|
33
64
|
tags: ['!stable', 'experimental'],
|
|
34
65
|
parameters: { layout: 'padded' },
|
|
35
66
|
argTypes: {
|
|
36
67
|
allowMultiple: { control: 'boolean' },
|
|
37
68
|
},
|
|
38
|
-
} satisfies Meta<typeof
|
|
69
|
+
} satisfies Meta<typeof BdsAccordionStory>;
|
|
39
70
|
|
|
40
71
|
export default meta;
|
|
41
72
|
type Story = StoryObj<typeof meta>;
|
|
42
73
|
|
|
43
74
|
export const Default: Story = { args: { allowMultiple: false } };
|
|
44
|
-
export const AllowMultiple: Story = { args: { allowMultiple: true } };
|
|
45
75
|
|
|
46
|
-
export const
|
|
47
|
-
|
|
48
|
-
React.createElement(
|
|
49
|
-
'bds-accordion',
|
|
50
|
-
null,
|
|
51
|
-
React.createElement(
|
|
52
|
-
'bds-accordion-item',
|
|
53
|
-
null,
|
|
54
|
-
React.createElement('span', { slot: 'header' }, 'Available item'),
|
|
55
|
-
React.createElement('p', { style: { margin: 0 } }, 'This item can be opened and closed.'),
|
|
56
|
-
),
|
|
57
|
-
React.createElement(
|
|
58
|
-
'bds-accordion-item',
|
|
59
|
-
{ disabled: true },
|
|
60
|
-
React.createElement('span', { slot: 'header' }, 'Disabled item'),
|
|
61
|
-
React.createElement('p', { style: { margin: 0 } }, 'This item cannot be toggled.'),
|
|
62
|
-
),
|
|
63
|
-
React.createElement(
|
|
64
|
-
'bds-accordion-item',
|
|
65
|
-
null,
|
|
66
|
-
React.createElement('span', { slot: 'header' }, 'Another available item'),
|
|
67
|
-
React.createElement('p', { style: { margin: 0 } }, 'This item can also be opened.'),
|
|
68
|
-
),
|
|
69
|
-
),
|
|
76
|
+
export const AllowMultiple: Story = {
|
|
77
|
+
args: { allowMultiple: true },
|
|
70
78
|
};
|
|
71
79
|
|
|
72
|
-
export const
|
|
80
|
+
export const WithDisabledItem: Story = {
|
|
73
81
|
render: () => (
|
|
74
|
-
<
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
<BdsAccordion>
|
|
83
|
+
<BdsAccordionItem header="Available item" open>
|
|
84
|
+
{React.createElement('p', { style: { margin: 0 } }, 'This item can be toggled.')}
|
|
85
|
+
</BdsAccordionItem>
|
|
86
|
+
<BdsAccordionItem header="Disabled item" disabled>
|
|
87
|
+
{React.createElement('p', { style: { margin: 0 } }, 'This content is inaccessible because the item is disabled.')}
|
|
88
|
+
</BdsAccordionItem>
|
|
89
|
+
<BdsAccordionItem header="Another available item">
|
|
90
|
+
{React.createElement('p', { style: { margin: 0 } }, 'This item can also be toggled.')}
|
|
91
|
+
</BdsAccordionItem>
|
|
92
|
+
</BdsAccordion>
|
|
84
93
|
),
|
|
85
94
|
};
|
|
@@ -3,44 +3,114 @@ import * as Stories from './BdsCollapsible.stories';
|
|
|
3
3
|
|
|
4
4
|
<Meta of={Stories} />
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# <bds-collapsible>
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Framework-agnostic Collapsible custom element. Wraps a native `<details>`/`<summary>` pair for built-in toggle behaviour with design-system styling and a `bds-toggle` event.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
> **Status: experimental** — API may change before stable release.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
import '@boostdev/components/web-components';
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or in HTML without a bundler:
|
|
11
19
|
|
|
12
20
|
```html
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
</bds-collapsible>
|
|
21
|
+
<script type="module">
|
|
22
|
+
import '@boostdev/components/web-components';
|
|
23
|
+
</script>
|
|
17
24
|
```
|
|
18
25
|
|
|
26
|
+
## When to use
|
|
27
|
+
|
|
28
|
+
- Revealing secondary content on demand (e.g. "More details", "Advanced options")
|
|
29
|
+
- Standalone expandable sections that are independent of each other
|
|
30
|
+
- When accordion-style coordination is not required
|
|
31
|
+
|
|
32
|
+
## When not to use
|
|
33
|
+
|
|
34
|
+
- When multiple related sections need to be coordinated (open one, close others) — use `<bds-accordion>` instead
|
|
35
|
+
- For navigation menus — use a dedicated nav component
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
### Default
|
|
40
|
+
<Canvas of={Stories.Default} />
|
|
41
|
+
|
|
42
|
+
### Open by default
|
|
43
|
+
<Canvas of={Stories.Open} />
|
|
44
|
+
|
|
45
|
+
### Grouped (only one open at a time)
|
|
46
|
+
<Canvas of={Stories.Grouped} />
|
|
47
|
+
|
|
48
|
+
## Props
|
|
49
|
+
|
|
50
|
+
<ArgTypes of={Stories} />
|
|
51
|
+
|
|
19
52
|
## Attributes
|
|
20
53
|
|
|
21
|
-
| Attribute | Type
|
|
22
|
-
|
|
23
|
-
| `open`
|
|
24
|
-
| `name`
|
|
54
|
+
| Attribute | Type | Default | Description |
|
|
55
|
+
|-----------|------|---------|-------------|
|
|
56
|
+
| `open` | boolean | `false` | Whether the panel is currently expanded |
|
|
57
|
+
| `name` | string | `""` | Groups collapsibles so only one in a group is open at a time (native `<details name>` behaviour) |
|
|
25
58
|
|
|
26
59
|
## Slots
|
|
27
60
|
|
|
28
|
-
| Slot
|
|
29
|
-
|
|
30
|
-
| `summary` | The always-visible
|
|
31
|
-
| (default) | The
|
|
61
|
+
| Slot | Description |
|
|
62
|
+
|------|-------------|
|
|
63
|
+
| `summary` | The always-visible trigger text |
|
|
64
|
+
| `(default)` | The content revealed when expanded |
|
|
32
65
|
|
|
33
66
|
## Events
|
|
34
67
|
|
|
35
|
-
| Event
|
|
36
|
-
|
|
37
|
-
| `bds-toggle` | `{ open: boolean }`
|
|
68
|
+
| Event | Bubbles | Detail | Description |
|
|
69
|
+
|-------|---------|--------|-------------|
|
|
70
|
+
| `bds-toggle` | Yes | `{ open: boolean }` | Fired when the collapsible opens or closes; `detail.open` reflects the new state |
|
|
38
71
|
|
|
39
|
-
##
|
|
72
|
+
## Usage in plain HTML
|
|
40
73
|
|
|
41
|
-
|
|
42
|
-
<
|
|
74
|
+
```html
|
|
75
|
+
<bds-collapsible>
|
|
76
|
+
<span slot="summary">Show details</span>
|
|
77
|
+
<p>Hidden content revealed on toggle.</p>
|
|
78
|
+
</bds-collapsible>
|
|
79
|
+
|
|
80
|
+
<!-- Open by default -->
|
|
81
|
+
<bds-collapsible open>
|
|
82
|
+
<span slot="summary">Open section</span>
|
|
83
|
+
<p>This is visible immediately.</p>
|
|
84
|
+
</bds-collapsible>
|
|
85
|
+
|
|
86
|
+
<!-- Grouped: only one open at a time -->
|
|
87
|
+
<bds-collapsible name="faq">
|
|
88
|
+
<span slot="summary">Question 1</span>
|
|
89
|
+
<p>Answer 1</p>
|
|
90
|
+
</bds-collapsible>
|
|
91
|
+
<bds-collapsible name="faq">
|
|
92
|
+
<span slot="summary">Question 2</span>
|
|
93
|
+
<p>Answer 2</p>
|
|
94
|
+
</bds-collapsible>
|
|
95
|
+
```
|
|
43
96
|
|
|
44
|
-
##
|
|
97
|
+
## CSS Custom Properties
|
|
45
98
|
|
|
46
|
-
|
|
99
|
+
| Property | Default | Description |
|
|
100
|
+
|----------|---------|-------------|
|
|
101
|
+
| `--collapsible_bg` | `var(--bds-color_bg)` | Summary (header) background colour |
|
|
102
|
+
| `--collapsible_bg--hover` | `var(--bds-color_bg--subtle)` | Summary background on hover |
|
|
103
|
+
| `--collapsible_content-bg` | `var(--bds-color_bg)` | Content panel background colour |
|
|
104
|
+
| `--collapsible_color` | `var(--bds-color_on-bg)` | Summary text colour |
|
|
105
|
+
| `--collapsible_on-color` | `var(--bds-color_on-bg)` | Content text colour |
|
|
106
|
+
| `--collapsible_border-color` | `var(--bds-color_bg--subtle)` | Border colour |
|
|
107
|
+
| `--collapsible_border-width` | `1px` | Border width |
|
|
108
|
+
| `--collapsible_border-radius` | `var(--bds-border_radius--m)` | Border radius |
|
|
109
|
+
|
|
110
|
+
## Accessibility
|
|
111
|
+
|
|
112
|
+
- Built on native `<details>`/`<summary>`, which is keyboard accessible out of the box
|
|
113
|
+
- The `summary` slot element is focusable and responds to Enter/Space
|
|
114
|
+
- Focus outline follows design system tokens
|
|
115
|
+
- Chevron icon is `aria-hidden="true"`
|
|
116
|
+
- `prefers-reduced-motion` disables the chevron transition
|