@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.
Files changed (168) hide show
  1. package/AGENTS.md +46 -4
  2. package/README.md +15 -15
  3. package/dist/client.cjs +149 -124
  4. package/dist/client.css +503 -525
  5. package/dist/client.d.cts +71 -96
  6. package/dist/client.d.ts +71 -96
  7. package/dist/client.js +149 -124
  8. package/dist/index.cjs +149 -124
  9. package/dist/index.css +503 -525
  10. package/dist/index.d.cts +71 -96
  11. package/dist/index.d.ts +71 -96
  12. package/dist/index.js +149 -124
  13. package/dist/web-components/{chunk-6MH5UWUD.js → chunk-2FGATTGT.js} +5 -0
  14. package/dist/web-components/{chunk-5IPHEONG.js → chunk-6I2DBFQ7.js} +1 -0
  15. package/dist/web-components/{chunk-DI46Q2EA.js → chunk-OCODKRVZ.js} +57 -82
  16. package/dist/web-components/index.d.ts +571 -1
  17. package/dist/web-components/index.js +1501 -4
  18. package/dist/web-components/interaction/bds-collapsible.js +1 -1
  19. package/dist/web-components/interaction/bds-drawer.js +1 -1
  20. package/dist/web-components/interaction/form/bds-segmented-control.js +1 -1
  21. package/package.json +1 -1
  22. package/src/components/interaction/Command/Command.tsx +4 -3
  23. package/src/components/interaction/Dialog/Dialog.tsx +4 -5
  24. package/src/components/interaction/Drawer/Drawer.module.css +37 -62
  25. package/src/components/interaction/Drawer/Drawer.spec.tsx +3 -3
  26. package/src/components/interaction/Drawer/Drawer.tsx +25 -24
  27. package/src/components/interaction/DropdownMenu/DropdownMenu.tsx +4 -2
  28. package/src/components/interaction/Popover/Popover.tsx +4 -3
  29. package/src/components/interaction/Rating/Rating.tsx +4 -2
  30. package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.tsx +4 -6
  31. package/src/components/interaction/form/Combobox/Combobox.tsx +4 -2
  32. package/src/components/interaction/form/FileInput/FileInput.tsx +4 -3
  33. package/src/components/interaction/form/NumberInput/NumberInput.tsx +4 -3
  34. package/src/components/interaction/form/RadioGroup/RadioGroup.tsx +4 -6
  35. package/src/components/interaction/form/SegmentedControl/SegmentedControl.mdx +8 -4
  36. package/src/components/interaction/form/SegmentedControl/SegmentedControl.module.css +13 -6
  37. package/src/components/interaction/form/SegmentedControl/SegmentedControl.tsx +4 -6
  38. package/src/components/interaction/form/atoms/InputContainer.tsx +2 -2
  39. package/src/components/layout/ButtonGroup/ButtonGroup.tsx +4 -6
  40. package/src/components/layout/Card/Card.tsx +4 -10
  41. package/src/components/layout/IconWrapper/IconWrapper.tsx +4 -5
  42. package/src/components/layout/SectionHeader/SectionHeader.tsx +5 -4
  43. package/src/components/ui/Accordion/Accordion.tsx +4 -3
  44. package/src/components/ui/Alert/Alert.tsx +4 -3
  45. package/src/components/ui/Avatar/Avatar.tsx +5 -3
  46. package/src/components/ui/Badge/Badge.tsx +4 -5
  47. package/src/components/ui/Breadcrumb/Breadcrumb.tsx +4 -3
  48. package/src/components/ui/Calendar/Calendar.tsx +4 -4
  49. package/src/components/ui/Carousel/Carousel.tsx +4 -4
  50. package/src/components/ui/DescriptionList/DescriptionList.tsx +4 -4
  51. package/src/components/ui/Loading/Loading.tsx +4 -3
  52. package/src/components/ui/NotificationBanner/NotificationBanner.tsx +4 -2
  53. package/src/components/ui/Pagination/Pagination.tsx +4 -2
  54. package/src/components/ui/Progress/Progress.tsx +4 -2
  55. package/src/components/ui/ProgressCircle/ProgressCircle.tsx +4 -1
  56. package/src/components/ui/Separator/Separator.tsx +5 -3
  57. package/src/components/ui/Skeleton/Skeleton.tsx +4 -3
  58. package/src/components/ui/SkipLink/SkipLink.tsx +4 -5
  59. package/src/components/ui/Tabs/Tabs.tsx +4 -4
  60. package/src/components/ui/Tooltip/Tooltip.tsx +4 -2
  61. package/src/components/ui/Typography/Typography.tsx +4 -5
  62. package/src/stories/DesignSystem/Grid.mdx +2 -0
  63. package/src/stories/Introduction.mdx +2 -1
  64. package/src/web-components/index.ts +12 -0
  65. package/src/web-components/interaction/BdsAccordion.mdx +80 -28
  66. package/src/web-components/interaction/BdsAccordion.stories.tsx +67 -58
  67. package/src/web-components/interaction/BdsCollapsible.mdx +93 -23
  68. package/src/web-components/interaction/BdsCollapsible.stories.tsx +29 -48
  69. package/src/web-components/interaction/BdsDialog.mdx +88 -27
  70. package/src/web-components/interaction/BdsDialog.stories.tsx +129 -47
  71. package/src/web-components/interaction/BdsDrawer.mdx +85 -27
  72. package/src/web-components/interaction/BdsDrawer.stories.tsx +161 -31
  73. package/src/web-components/interaction/BdsDropdownMenu.mdx +108 -0
  74. package/src/web-components/interaction/BdsDropdownMenu.stories.tsx +91 -0
  75. package/src/web-components/interaction/BdsSkipLink.mdx +72 -16
  76. package/src/web-components/interaction/BdsSkipLink.stories.tsx +47 -34
  77. package/src/web-components/interaction/BdsTabs.mdx +97 -27
  78. package/src/web-components/interaction/BdsTabs.stories.tsx +69 -55
  79. package/src/web-components/interaction/BdsTooltip.mdx +84 -18
  80. package/src/web-components/interaction/BdsTooltip.stories.tsx +49 -30
  81. package/src/web-components/interaction/bds-collapsible.ts +1 -0
  82. package/src/web-components/interaction/bds-drawer.ts +59 -82
  83. package/src/web-components/interaction/bds-dropdown-menu-item.ts +124 -0
  84. package/src/web-components/interaction/bds-dropdown-menu.spec.ts +102 -0
  85. package/src/web-components/interaction/bds-dropdown-menu.ts +200 -0
  86. package/src/web-components/interaction/form/BdsCheckbox.mdx +57 -20
  87. package/src/web-components/interaction/form/BdsCheckbox.stories.tsx +35 -36
  88. package/src/web-components/interaction/form/BdsCheckboxGroup.mdx +70 -0
  89. package/src/web-components/interaction/form/BdsCheckboxGroup.stories.tsx +81 -0
  90. package/src/web-components/interaction/form/BdsCombobox.mdx +52 -33
  91. package/src/web-components/interaction/form/BdsCombobox.stories.tsx +55 -53
  92. package/src/web-components/interaction/form/BdsFileInput.mdx +59 -24
  93. package/src/web-components/interaction/form/BdsFileInput.stories.tsx +38 -53
  94. package/src/web-components/interaction/form/BdsFormInput.mdx +98 -0
  95. package/src/web-components/interaction/form/BdsFormInput.stories.tsx +139 -0
  96. package/src/web-components/interaction/form/BdsNumberInput.mdx +51 -22
  97. package/src/web-components/interaction/form/BdsNumberInput.stories.tsx +24 -46
  98. package/src/web-components/interaction/form/BdsRadio.mdx +53 -22
  99. package/src/web-components/interaction/form/BdsRadio.stories.tsx +19 -51
  100. package/src/web-components/interaction/form/BdsRadioGroup.mdx +73 -0
  101. package/src/web-components/interaction/form/BdsRadioGroup.stories.tsx +88 -0
  102. package/src/web-components/interaction/form/BdsSegmentedControl.mdx +76 -23
  103. package/src/web-components/interaction/form/BdsSegmentedControl.stories.tsx +64 -54
  104. package/src/web-components/interaction/form/BdsSelect.mdx +59 -21
  105. package/src/web-components/interaction/form/BdsSelect.stories.tsx +47 -56
  106. package/src/web-components/interaction/form/BdsSlider.mdx +55 -27
  107. package/src/web-components/interaction/form/BdsSlider.stories.tsx +23 -44
  108. package/src/web-components/interaction/form/BdsSwitch.mdx +53 -20
  109. package/src/web-components/interaction/form/BdsSwitch.stories.tsx +22 -37
  110. package/src/web-components/interaction/form/BdsTextarea.mdx +54 -22
  111. package/src/web-components/interaction/form/BdsTextarea.stories.tsx +35 -44
  112. package/src/web-components/interaction/form/bds-checkbox-group.spec.ts +55 -0
  113. package/src/web-components/interaction/form/bds-checkbox-group.ts +117 -0
  114. package/src/web-components/interaction/form/bds-form-input.spec.ts +83 -0
  115. package/src/web-components/interaction/form/bds-form-input.ts +268 -0
  116. package/src/web-components/interaction/form/bds-radio-group.spec.ts +62 -0
  117. package/src/web-components/interaction/form/bds-radio-group.ts +142 -0
  118. package/src/web-components/interaction/form/bds-segmented-control.ts +5 -0
  119. package/src/web-components/ui/BdsAvatar.mdx +29 -20
  120. package/src/web-components/ui/BdsAvatar.stories.tsx +14 -28
  121. package/src/web-components/ui/BdsBreadcrumb.mdx +22 -19
  122. package/src/web-components/ui/BdsBreadcrumb.stories.tsx +11 -21
  123. package/src/web-components/ui/BdsButtonGroup.mdx +69 -0
  124. package/src/web-components/ui/BdsButtonGroup.stories.tsx +66 -0
  125. package/src/web-components/ui/BdsCalendar.mdx +93 -0
  126. package/src/web-components/ui/BdsCalendar.stories.tsx +63 -0
  127. package/src/web-components/ui/BdsCard.mdx +30 -25
  128. package/src/web-components/ui/BdsCard.stories.tsx +19 -42
  129. package/src/web-components/ui/BdsCarousel.mdx +83 -0
  130. package/src/web-components/ui/BdsCarousel.stories.tsx +96 -0
  131. package/src/web-components/ui/BdsDescriptionList.mdx +13 -16
  132. package/src/web-components/ui/BdsDescriptionList.stories.tsx +34 -49
  133. package/src/web-components/ui/BdsIconWrapper.mdx +20 -20
  134. package/src/web-components/ui/BdsIconWrapper.stories.tsx +46 -41
  135. package/src/web-components/ui/BdsLink.mdx +21 -17
  136. package/src/web-components/ui/BdsLink.stories.tsx +19 -20
  137. package/src/web-components/ui/BdsLoading.mdx +9 -13
  138. package/src/web-components/ui/BdsLoading.stories.tsx +8 -10
  139. package/src/web-components/ui/BdsNotificationBanner.mdx +32 -37
  140. package/src/web-components/ui/BdsNotificationBanner.stories.tsx +38 -47
  141. package/src/web-components/ui/BdsPagination.mdx +74 -0
  142. package/src/web-components/ui/BdsPagination.stories.tsx +36 -0
  143. package/src/web-components/ui/BdsProgress.mdx +24 -17
  144. package/src/web-components/ui/BdsProgress.stories.tsx +55 -29
  145. package/src/web-components/ui/BdsProgressCircle.mdx +24 -18
  146. package/src/web-components/ui/BdsProgressCircle.stories.tsx +17 -29
  147. package/src/web-components/ui/BdsRating.mdx +22 -22
  148. package/src/web-components/ui/BdsRating.stories.tsx +19 -13
  149. package/src/web-components/ui/BdsSectionHeader.mdx +31 -28
  150. package/src/web-components/ui/BdsSectionHeader.stories.tsx +21 -23
  151. package/src/web-components/ui/BdsSeparator.mdx +22 -8
  152. package/src/web-components/ui/BdsSeparator.stories.tsx +27 -19
  153. package/src/web-components/ui/BdsSkeleton.mdx +20 -26
  154. package/src/web-components/ui/BdsSkeleton.stories.tsx +23 -23
  155. package/src/web-components/ui/BdsTable.mdx +81 -0
  156. package/src/web-components/ui/BdsTable.stories.tsx +83 -0
  157. package/src/web-components/ui/BdsTypography.mdx +20 -29
  158. package/src/web-components/ui/BdsTypography.stories.tsx +19 -18
  159. package/src/web-components/ui/bds-button-group.spec.ts +40 -0
  160. package/src/web-components/ui/bds-button-group.ts +78 -0
  161. package/src/web-components/ui/bds-calendar.spec.ts +91 -0
  162. package/src/web-components/ui/bds-calendar.ts +427 -0
  163. package/src/web-components/ui/bds-carousel.spec.ts +64 -0
  164. package/src/web-components/ui/bds-carousel.ts +296 -0
  165. package/src/web-components/ui/bds-pagination.spec.ts +67 -0
  166. package/src/web-components/ui/bds-pagination.ts +197 -0
  167. package/src/web-components/ui/bds-table.spec.ts +45 -0
  168. 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 { ReactNode, ElementType } from 'react';
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="../../src/static/logo.svg" alt="BoostDev logo" width={200}/>
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
- # Accordion
6
+ # &lt;bds-accordion&gt;
7
7
 
8
- `<bds-accordion>` is a container for one or more `<bds-accordion-item>` elements. Each item shows a header and reveals its body on click. By default only one item can be open at a time; set `allow-multiple` to allow several.
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
- ## Usage
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
- <bds-accordion>
14
- <bds-accordion-item>
15
- <span slot="header">Section 1</span>
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 | Type | Default | Description |
28
- |------------------|-----------|---------|-----------------------------------------|
29
- | `allow-multiple` | `boolean` | `false` | Allow more than one item open at a time |
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 | Type | Default | Description |
34
- |------------|-----------|---------|-----------------------------------|
35
- | `disabled` | `boolean` | `false` | Prevents this item from toggling |
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 | Description |
40
- |-----------|--------------------------|
41
- | `header` | The clickable header text |
42
- | (default) | The collapsible body content |
67
+ | Slot | Description |
68
+ |------|-------------|
69
+ | `header` | The always-visible trigger label |
70
+ | `(default)` | The content revealed when the item is open |
43
71
 
44
- ## Stories
72
+ ## Events
45
73
 
46
- <Canvas of={Stories.Default} />
47
- <Canvas of={Stories.AllVariants} />
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
- ## Controls
78
+ ## Usage in plain HTML
50
79
 
51
- <ArgTypes of={Stories} />
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
- function BdsAccordion({ allowMultiple }: { allowMultiple?: boolean }) {
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
- React.createElement(
10
- 'bds-accordion-item',
11
- null,
12
- React.createElement('span', { slot: 'header' }, 'What is a web component?'),
13
- React.createElement('p', { style: { margin: 0 } }, 'A web component is a reusable custom element built with native web platform APIs — no framework required.'),
14
- ),
15
- React.createElement(
16
- 'bds-accordion-item',
17
- null,
18
- React.createElement('span', { slot: 'header' }, 'How do I use it?'),
19
- React.createElement('p', { style: { margin: 0 } }, 'Import the package and add the custom element tag to your HTML. Works in any framework.'),
20
- ),
21
- React.createElement(
22
- 'bds-accordion-item',
23
- null,
24
- React.createElement('span', { slot: 'header' }, 'Is it accessible?'),
25
- React.createElement('p', { style: { margin: 0 } }, 'Yes. Each item uses proper ARIA attributes: aria-expanded, aria-controls, and aria-labelledby.'),
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: BdsAccordion,
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 BdsAccordion>;
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 WithDisabledItem: Story = {
47
- render: () =>
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 AllVariants: Story = {
80
+ export const WithDisabledItem: Story = {
73
81
  render: () => (
74
- <div style={{ display: 'flex', flexDirection: 'column', gap: '24px' }}>
75
- <div>
76
- <p style={{ margin: '0 0 8px', fontSize: '0.75rem', color: '#888', fontWeight: 600 }}>Single open (default)</p>
77
- <BdsAccordion />
78
- </div>
79
- <div>
80
- <p style={{ margin: '0 0 8px', fontSize: '0.75rem', color: '#888', fontWeight: 600 }}>Multiple open</p>
81
- <BdsAccordion allowMultiple />
82
- </div>
83
- </div>
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
- # Collapsible
6
+ # &lt;bds-collapsible&gt;
7
7
 
8
- `<bds-collapsible>` reveals or hides content on demand. Built on native `<details>/<summary>` semantics for built-in accessibility. Set the same `name` on multiple collapsibles to link them — opening one will close the others.
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
- ## Usage
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
- <bds-collapsible>
14
- <span slot="summary">Show more</span>
15
- <p>Hidden content revealed on click.</p>
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 | Default | Description |
22
- |-----------|-----------|-------------|----------------------------------------------|
23
- | `open` | `boolean` | `false` | Controls the open/closed state |
24
- | `name` | `string` | `undefined` | Links collapsibles into a mutually-exclusive group |
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 | Description |
29
- |-----------|----------------------------------|
30
- | `summary` | The always-visible clickable label |
31
- | (default) | The collapsible body content |
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 | Detail | Description |
36
- |--------------|---------------------------------|--------------------------------|
37
- | `bds-toggle` | `{ open: boolean }` | Fired when open state changes |
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
- ## Stories
72
+ ## Usage in plain HTML
40
73
 
41
- <Canvas of={Stories.Default} />
42
- <Canvas of={Stories.Grouped} />
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
- ## Controls
97
+ ## CSS Custom Properties
45
98
 
46
- <ArgTypes of={Stories} />
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