@boostdev/design-system-components 2.6.0 → 2.7.0

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 (29) hide show
  1. package/dist/client.cjs +257 -219
  2. package/dist/client.css +585 -537
  3. package/dist/client.d.cts +27 -1
  4. package/dist/client.d.ts +27 -1
  5. package/dist/client.js +220 -183
  6. package/dist/index.cjs +257 -219
  7. package/dist/index.css +585 -537
  8. package/dist/index.d.cts +27 -1
  9. package/dist/index.d.ts +27 -1
  10. package/dist/index.js +220 -183
  11. package/dist/web-components/index.d.ts +56 -1
  12. package/dist/web-components/index.js +117 -0
  13. package/package.json +3 -2
  14. package/src/components/interaction/form/FieldGroup/FieldGroup.mdx +113 -0
  15. package/src/components/interaction/form/FieldGroup/FieldGroup.module.css +96 -0
  16. package/src/components/interaction/form/FieldGroup/FieldGroup.spec.tsx +196 -0
  17. package/src/components/interaction/form/FieldGroup/FieldGroup.stories.tsx +99 -0
  18. package/src/components/interaction/form/FieldGroup/FieldGroup.tsx +64 -0
  19. package/src/components/interaction/form/FieldGroup/index.ts +2 -0
  20. package/src/components/interaction/form/atoms/Message.module.css +4 -0
  21. package/src/index.ts +2 -0
  22. package/src/web-components/index.ts +2 -0
  23. package/src/web-components/interaction/form/BdsFieldGroup.mdx +67 -0
  24. package/src/web-components/interaction/form/BdsFieldGroup.stories.tsx +110 -0
  25. package/src/web-components/interaction/form/bds-checkbox-group.ts +1 -0
  26. package/src/web-components/interaction/form/bds-field-group.spec.ts +64 -0
  27. package/src/web-components/interaction/form/bds-field-group.ts +157 -0
  28. package/src/web-components/interaction/form/bds-form-input.ts +1 -0
  29. package/src/web-components/interaction/form/bds-radio-group.ts +1 -0
@@ -0,0 +1,99 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { FieldGroup } from './FieldGroup';
3
+ import { FormInput } from '../FormInput';
4
+ import { Select } from '../Select';
5
+
6
+ const meta = {
7
+ title: 'React/Form/FieldGroup',
8
+ component: FieldGroup,
9
+ parameters: {
10
+ docs: {
11
+ description: {
12
+ component:
13
+ 'A `<fieldset>` wrapper that groups related form fields under a styled `<legend>`. ' +
14
+ 'The `horizontal` variant lays fields out in a row that auto-collapses to a single ' +
15
+ 'column via a CSS container query when the FieldGroup itself is too narrow.',
16
+ },
17
+ },
18
+ },
19
+ } satisfies Meta<typeof FieldGroup>;
20
+
21
+ export default meta;
22
+ type Story = StoryObj<typeof meta>;
23
+
24
+ export const Horizontal: Story = {
25
+ args: { legend: 'Contact details', variant: 'horizontal' },
26
+ render: args => (
27
+ <FieldGroup {...args}>
28
+ <FormInput label="First name" name="firstName" />
29
+ <FormInput label="Last name" name="lastName" />
30
+ <FormInput label="Email" name="email" type="email" />
31
+ </FieldGroup>
32
+ ),
33
+ };
34
+
35
+ export const Vertical: Story = {
36
+ args: { legend: 'Contact details', variant: 'vertical' },
37
+ render: args => (
38
+ <FieldGroup {...args}>
39
+ <FormInput label="First name" name="firstName" />
40
+ <FormInput label="Last name" name="lastName" />
41
+ <FormInput label="Email" name="email" type="email" />
42
+ </FieldGroup>
43
+ ),
44
+ };
45
+
46
+ export const HorizontalCollapsesInNarrowContainer: Story = {
47
+ name: 'Horizontal — collapses in narrow container',
48
+ args: { legend: 'Same fields, narrower parent', variant: 'horizontal' },
49
+ render: args => (
50
+ <div style={{ inlineSize: '20rem', border: '1px dashed currentcolor', padding: '1rem' }}>
51
+ <FieldGroup {...args}>
52
+ <FormInput label="First name" name="firstName" />
53
+ <FormInput label="Last name" name="lastName" />
54
+ <FormInput label="Email" name="email" type="email" />
55
+ </FieldGroup>
56
+ </div>
57
+ ),
58
+ };
59
+
60
+ export const WithSelectAndInputs: Story = {
61
+ args: { legend: 'Address', variant: 'horizontal' },
62
+ render: args => (
63
+ <FieldGroup {...args}>
64
+ <FormInput label="Street" name="street" />
65
+ <FormInput label="House number" name="houseNumber" />
66
+ <FormInput label="Postal code" name="postalCode" />
67
+ <Select
68
+ label="Country"
69
+ name="country"
70
+ options={[
71
+ { value: 'nl', label: 'Netherlands' },
72
+ { value: 'be', label: 'Belgium' },
73
+ { value: 'de', label: 'Germany' },
74
+ ]}
75
+ />
76
+ </FieldGroup>
77
+ ),
78
+ };
79
+
80
+ export const WithoutLegend: Story = {
81
+ args: { 'aria-label': 'Search filters', variant: 'horizontal' },
82
+ render: args => (
83
+ <FieldGroup {...args}>
84
+ <FormInput label="Query" name="q" />
85
+ <FormInput label="From" name="from" type="date" />
86
+ <FormInput label="To" name="to" type="date" />
87
+ </FieldGroup>
88
+ ),
89
+ };
90
+
91
+ export const Disabled: Story = {
92
+ args: { legend: 'Disabled section', variant: 'horizontal', disabled: true },
93
+ render: args => (
94
+ <FieldGroup {...args}>
95
+ <FormInput label="First name" name="firstName" />
96
+ <FormInput label="Last name" name="lastName" />
97
+ </FieldGroup>
98
+ ),
99
+ };
@@ -0,0 +1,64 @@
1
+ import { Children, CSSProperties, FieldsetHTMLAttributes, ReactNode } from 'react';
2
+ import { cn } from '@boostdev/design-system-foundation';
3
+ import css from './FieldGroup.module.css';
4
+ import type { WithClassName } from '../../../../types';
5
+
6
+ /**
7
+ * Layout variants for FieldGroup.
8
+ *
9
+ * - `horizontal` (default) — fields flow into a row, each claiming at least
10
+ * `--fieldGroup_min-field-width`. When the container's inline-size is too
11
+ * narrow to fit the row, a CSS container query collapses the layout to a
12
+ * single column.
13
+ * - `vertical` — fields always stack one per row.
14
+ */
15
+ export type FieldGroupVariant = 'horizontal' | 'vertical';
16
+
17
+ export interface FieldGroupProps
18
+ extends WithClassName,
19
+ FieldsetHTMLAttributes<HTMLFieldSetElement> {
20
+ /** Layout direction. Defaults to `horizontal`. */
21
+ variant?: FieldGroupVariant;
22
+ /**
23
+ * Optional legend rendered above the fields. When omitted, set
24
+ * `aria-label` or `aria-labelledby` on the fieldset for accessibility.
25
+ */
26
+ legend?: ReactNode;
27
+ }
28
+
29
+ /**
30
+ * `FieldGroup` semantically groups related form fields under a single
31
+ * `<fieldset>` and lays them out either horizontally (with container-query
32
+ * fallback to vertical) or vertically.
33
+ */
34
+ export function FieldGroup({
35
+ variant = 'horizontal',
36
+ legend,
37
+ children,
38
+ className,
39
+ style,
40
+ ...rest
41
+ }: Readonly<FieldGroupProps>) {
42
+ // Surface the field count to CSS so the @container collapse threshold
43
+ // scales with the actual content. The CSS uses
44
+ // N * --fieldGroup_min-field-width + (N - 1) * --fieldGroup_gap
45
+ // which is exactly the inline-size required to lay all fields out at
46
+ // their minimum width with the configured gap. When the FieldGroup's own
47
+ // inline-size drops below that, the layout collapses to a single column.
48
+ const fieldCount = Children.count(children);
49
+ const styleWithCount = {
50
+ ...style,
51
+ '--fieldGroup_field-count': fieldCount,
52
+ } as CSSProperties;
53
+
54
+ return (
55
+ <fieldset
56
+ {...rest}
57
+ style={styleWithCount}
58
+ className={cn(css.fieldGroup, css[`--variant_${variant}`], className)}
59
+ >
60
+ {legend !== undefined && <legend className={css.legend}>{legend}</legend>}
61
+ <div className={css.fields}>{children}</div>
62
+ </fieldset>
63
+ );
64
+ }
@@ -0,0 +1,2 @@
1
+ export { FieldGroup } from './FieldGroup';
2
+ export type { FieldGroupProps, FieldGroupVariant } from './FieldGroup';
@@ -8,4 +8,8 @@
8
8
  .error {
9
9
  color: var(--bds-color_error_on-bg);
10
10
  }
11
+
12
+ .hint {
13
+ font-style: italic;
14
+ }
11
15
  }
package/src/index.ts CHANGED
@@ -48,6 +48,8 @@ export { Checkbox } from './components/interaction/form/Checkbox';
48
48
  export { CheckboxGroup } from './components/interaction/form/CheckboxGroup';
49
49
  export type { CheckboxGroupProps } from './components/interaction/form/CheckboxGroup';
50
50
  export { Combobox } from './components/interaction/form/Combobox';
51
+ export { FieldGroup } from './components/interaction/form/FieldGroup';
52
+ export type { FieldGroupProps, FieldGroupVariant } from './components/interaction/form/FieldGroup';
51
53
  export type { ComboboxOption } from './components/interaction/form/Combobox';
52
54
  export { FileInput } from './components/interaction/form/FileInput';
53
55
  export { FormInput } from './components/interaction/form/FormInput';
@@ -68,6 +68,8 @@ export { BdsTable } from './ui/bds-table';
68
68
  export { BdsPagination } from './ui/bds-pagination';
69
69
  export { BdsCheckboxGroup } from './interaction/form/bds-checkbox-group';
70
70
  export { BdsRadioGroup } from './interaction/form/bds-radio-group';
71
+ export { BdsFieldGroup } from './interaction/form/bds-field-group';
72
+ export type { FieldGroupVariant as BdsFieldGroupVariant } from './interaction/form/bds-field-group';
71
73
  export { BdsFormInput } from './interaction/form/bds-form-input';
72
74
  export { BdsCarousel } from './ui/bds-carousel';
73
75
  export { BdsCalendar } from './ui/bds-calendar';
@@ -0,0 +1,67 @@
1
+ import { Meta, Canvas } from '@storybook/blocks';
2
+ import * as Stories from './BdsFieldGroup.stories';
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # `<bds-field-group>`
7
+
8
+ Framework-agnostic FieldGroup custom element. Wraps slotted fields in a `<fieldset>` with a styled `<legend>` and lays them out horizontally (with auto-collapse to vertical via CSS container query) or vertically.
9
+
10
+ Mirrors the React `FieldGroup` component — same token surface, same behavior, same auto-derived collapse threshold.
11
+
12
+ ## Attributes
13
+
14
+ | Attribute | Values | Default | Description |
15
+ |-----------|--------|---------|-------------|
16
+ | `variant` | `horizontal` \| `vertical` | `horizontal` | Layout direction. |
17
+ | `legend` | string | — | Optional legend text. Falls back to `aria-label` semantics if you set that on the host directly. |
18
+ | `disabled` | boolean | `false` | Forwards to the inner `<fieldset>`; the UA cascades it to descendant form controls (light-DOM children projected through the slot). |
19
+
20
+ ## Slots
21
+
22
+ - `(default)` — projected form fields (`<bds-form-input>`, `<bds-select>`, etc.). The component listens for `slotchange` and surfaces the slotted-element count via `--fieldGroup_field-count`, which the auto-derived collapse threshold reads.
23
+
24
+ ## Examples
25
+
26
+ ### Horizontal
27
+ <Canvas of={Stories.Horizontal} />
28
+
29
+ ### Vertical
30
+ <Canvas of={Stories.Vertical} />
31
+
32
+ ### Horizontal collapses in a narrow container
33
+ <Canvas of={Stories.HorizontalCollapsesInNarrowContainer} />
34
+
35
+ ### Without a legend
36
+ <Canvas of={Stories.WithoutLegend} />
37
+
38
+ ### Disabled
39
+ <Canvas of={Stories.Disabled} />
40
+
41
+ ## CSS variables
42
+
43
+ Same surface as the React component. All public tokens are read with foundation-default fallbacks; consumers can set them on the host (or any ancestor) to theme one or many groups without touching internal classes.
44
+
45
+ ### Layout
46
+
47
+ | Variable | Default |
48
+ |----------|---------|
49
+ | `--fieldGroup_gap` | `var(--bds-space_m)` |
50
+ | `--fieldGroup_min-field-width` | `12rem` |
51
+ | `--fieldGroup_collapse-threshold` | `calc(N × min-field-width + (N − 1) × gap)` (computed) |
52
+
53
+ ### Legend
54
+
55
+ | Variable | Default |
56
+ |----------|---------|
57
+ | `--fieldGroup_legend-color` | `var(--bds-color_on-bg)` |
58
+ | `--fieldGroup_legend-font-size` | `var(--bds-font_size--heading-3)` |
59
+ | `--fieldGroup_legend-font-weight` | `var(--bds-font_weight--semibold)` |
60
+ | `--fieldGroup_legend-line-height` | `var(--bds-font_line-height--heading)` |
61
+ | `--fieldGroup_legend-padding-block` | `var(--bds-space_xs)` |
62
+ | `--fieldGroup_legend-gap` | `var(--bds-space_m)` |
63
+ | `--fieldGroup_legend-border-block-end` | `1px solid var(--bds-color_bg--subtle)` |
64
+
65
+ ## Notes on shadow DOM
66
+
67
+ The component renders its own `<fieldset>` inside the shadow root and projects fields through a `<slot>`. Because slotted elements stay in the host's light DOM, the native `fieldset[disabled]` cascade onto descendants is browser-dependent — modern browsers do propagate disabled to slotted form controls; older ones may not. If you support an older runtime and need a hard guarantee, set `disabled` on each slotted field too.
@@ -0,0 +1,110 @@
1
+ import React from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import '../../index'; // auto-registers all custom elements
4
+
5
+ function BdsFieldGroup({
6
+ legend,
7
+ variant,
8
+ disabled,
9
+ children,
10
+ }: {
11
+ legend?: string;
12
+ variant?: 'horizontal' | 'vertical';
13
+ disabled?: boolean;
14
+ children?: React.ReactNode;
15
+ }) {
16
+ return React.createElement(
17
+ 'bds-field-group',
18
+ {
19
+ legend: legend || undefined,
20
+ variant: variant || undefined,
21
+ disabled: disabled || undefined,
22
+ },
23
+ children,
24
+ );
25
+ }
26
+
27
+ const meta = {
28
+ title: 'Web Components/Form/FieldGroup',
29
+ component: BdsFieldGroup,
30
+ tags: ['!stable', 'experimental'],
31
+ parameters: {
32
+ layout: 'padded',
33
+ docs: {
34
+ description: {
35
+ component:
36
+ 'Framework-agnostic FieldGroup. Wraps slotted fields in a `<fieldset>` ' +
37
+ 'and lays them out horizontally with a CSS container query that auto-collapses ' +
38
+ 'to a single column when the host is too narrow to fit a complete row at minimum field width.',
39
+ },
40
+ },
41
+ },
42
+ argTypes: {
43
+ variant: { control: 'select', options: ['horizontal', 'vertical'] },
44
+ legend: { control: 'text' },
45
+ disabled: { control: 'boolean' },
46
+ },
47
+ } satisfies Meta<typeof BdsFieldGroup>;
48
+
49
+ export default meta;
50
+ type Story = StoryObj<typeof meta>;
51
+
52
+ const field = (name: string, label: string, type = 'text') =>
53
+ React.createElement('bds-form-input', { name, label, type });
54
+
55
+ export const Horizontal: Story = {
56
+ args: { legend: 'Contact details', variant: 'horizontal' },
57
+ render: args => (
58
+ <BdsFieldGroup {...args}>
59
+ {field('first', 'First name')}
60
+ {field('last', 'Last name')}
61
+ {field('email', 'Email', 'email')}
62
+ </BdsFieldGroup>
63
+ ),
64
+ };
65
+
66
+ export const Vertical: Story = {
67
+ args: { legend: 'Contact details', variant: 'vertical' },
68
+ render: args => (
69
+ <BdsFieldGroup {...args}>
70
+ {field('first', 'First name')}
71
+ {field('last', 'Last name')}
72
+ {field('email', 'Email', 'email')}
73
+ </BdsFieldGroup>
74
+ ),
75
+ };
76
+
77
+ export const HorizontalCollapsesInNarrowContainer: Story = {
78
+ name: 'Horizontal — collapses in narrow container',
79
+ args: { legend: 'Same fields, narrower parent', variant: 'horizontal' },
80
+ render: args => (
81
+ <div style={{ inlineSize: '20rem', border: '1px dashed currentcolor', padding: '1rem' }}>
82
+ <BdsFieldGroup {...args}>
83
+ {field('first', 'First name')}
84
+ {field('last', 'Last name')}
85
+ {field('email', 'Email', 'email')}
86
+ </BdsFieldGroup>
87
+ </div>
88
+ ),
89
+ };
90
+
91
+ export const WithoutLegend: Story = {
92
+ args: { variant: 'horizontal' },
93
+ render: args => (
94
+ <BdsFieldGroup {...args}>
95
+ {field('q', 'Query')}
96
+ {field('from', 'From', 'date')}
97
+ {field('to', 'To', 'date')}
98
+ </BdsFieldGroup>
99
+ ),
100
+ };
101
+
102
+ export const Disabled: Story = {
103
+ args: { legend: 'Disabled section', variant: 'horizontal', disabled: true },
104
+ render: args => (
105
+ <BdsFieldGroup {...args}>
106
+ {field('first', 'First name')}
107
+ {field('last', 'Last name')}
108
+ </BdsFieldGroup>
109
+ ),
110
+ };
@@ -64,6 +64,7 @@ export class BdsCheckboxGroup extends LitElement {
64
64
 
65
65
  .message--hint {
66
66
  color: var(--bds-color_on-bg--subtle);
67
+ font-style: italic;
67
68
  }
68
69
  `;
69
70
 
@@ -0,0 +1,64 @@
1
+ import { fixture, cleanup } from '../../test/helpers';
2
+ import { BdsFieldGroup } from './bds-field-group';
3
+
4
+ describe('bds-field-group', () => {
5
+ it('is registered as a custom element', () => {
6
+ expect(customElements.get('bds-field-group')).toBe(BdsFieldGroup);
7
+ });
8
+
9
+ it('renders a fieldset in the shadow DOM', async () => {
10
+ const el = await fixture('<bds-field-group></bds-field-group>');
11
+ expect(el.shadowRoot!.querySelector('fieldset')).not.toBeNull();
12
+ cleanup(el);
13
+ });
14
+
15
+ it('renders the legend when the legend attribute is set', async () => {
16
+ const el = await fixture('<bds-field-group legend="Contact details"></bds-field-group>');
17
+ const legend = el.shadowRoot!.querySelector('legend');
18
+ expect(legend?.textContent?.trim()).toBe('Contact details');
19
+ cleanup(el);
20
+ });
21
+
22
+ it('omits the legend element when no legend attribute is set', async () => {
23
+ const el = await fixture('<bds-field-group></bds-field-group>');
24
+ expect(el.shadowRoot!.querySelector('legend')).toBeNull();
25
+ cleanup(el);
26
+ });
27
+
28
+ it('reflects the default horizontal variant onto the host', async () => {
29
+ const el = await fixture('<bds-field-group></bds-field-group>') as BdsFieldGroup;
30
+ expect(el.getAttribute('variant')).toBe('horizontal');
31
+ });
32
+
33
+ it('honors variant="vertical" on the host', async () => {
34
+ const el = await fixture('<bds-field-group variant="vertical"></bds-field-group>') as BdsFieldGroup;
35
+ expect(el.getAttribute('variant')).toBe('vertical');
36
+ cleanup(el);
37
+ });
38
+
39
+ it('forwards the disabled attribute to the inner fieldset', async () => {
40
+ const el = await fixture('<bds-field-group disabled></bds-field-group>');
41
+ const fieldset = el.shadowRoot!.querySelector('fieldset') as HTMLFieldSetElement;
42
+ expect(fieldset.disabled).toBe(true);
43
+ cleanup(el);
44
+ });
45
+
46
+ it('renders a slot for projected fields', async () => {
47
+ const el = await fixture(
48
+ '<bds-field-group><span id="a"></span><span id="b"></span></bds-field-group>',
49
+ );
50
+ expect(el.shadowRoot!.querySelector('slot')).not.toBeNull();
51
+ expect(el.querySelectorAll('span').length).toBe(2);
52
+ cleanup(el);
53
+ });
54
+
55
+ it('exposes the slotted-element count as --fieldGroup_field-count after slotchange', async () => {
56
+ const el = await fixture(
57
+ '<bds-field-group><span></span><span></span><span></span></bds-field-group>',
58
+ ) as BdsFieldGroup;
59
+ // slotchange fires synchronously after the initial render; allow a microtask.
60
+ await new Promise(r => requestAnimationFrame(() => r(null)));
61
+ expect(el.style.getPropertyValue('--fieldGroup_field-count')).toBe('3');
62
+ cleanup(el);
63
+ });
64
+ });
@@ -0,0 +1,157 @@
1
+ import { LitElement, css, html, nothing } from 'lit';
2
+
3
+ export type FieldGroupVariant = 'horizontal' | 'vertical';
4
+
5
+ /**
6
+ * `<bds-field-group>` — framework-agnostic FieldGroup custom element.
7
+ *
8
+ * Semantically groups related form fields under a single `<fieldset>` and
9
+ * lays them out either horizontally (with a CSS container query that
10
+ * collapses to a vertical stack when the FieldGroup itself is too narrow)
11
+ * or vertically. Mirrors the React `FieldGroup` component.
12
+ *
13
+ * Attributes:
14
+ * variant — "horizontal" (default) | "vertical"
15
+ * legend — optional legend text rendered above the fields
16
+ * disabled — boolean; forwarded to the inner <fieldset>
17
+ *
18
+ * Slots:
19
+ * (default) — form fields (any element). The slotted-element count is
20
+ * measured on each `slotchange` and surfaced via the
21
+ * `--fieldGroup_field-count` custom property, which the auto-derived
22
+ * collapse threshold reads.
23
+ *
24
+ * @example
25
+ * <bds-field-group variant="horizontal" legend="Contact details">
26
+ * <bds-form-input label="First name" name="first"></bds-form-input>
27
+ * <bds-form-input label="Last name" name="last"></bds-form-input>
28
+ * <bds-form-input label="Email" name="email"></bds-form-input>
29
+ * </bds-field-group>
30
+ */
31
+ export class BdsFieldGroup extends LitElement {
32
+ static styles = css`
33
+ :host {
34
+ display: block;
35
+
36
+ /* Establish an inline-size containment context so the @container rule
37
+ queries the host's own width — independent of the viewport. */
38
+ container-type: inline-size;
39
+ container-name: field-group;
40
+
41
+ /* Auto-derived collapse threshold (mirror of the React component).
42
+ --fieldGroup_field-count is set inline by _onSlotChange; the other
43
+ tokens use foundation-default fallbacks so the calc rebuilds when
44
+ a consumer overrides --fieldGroup_min-field-width or _gap. */
45
+ --fieldGroup_collapse-threshold:
46
+ calc(
47
+ var(--fieldGroup_field-count, 1)
48
+ * var(--fieldGroup_min-field-width, 12rem)
49
+ + (var(--fieldGroup_field-count, 1) - 1)
50
+ * var(--fieldGroup_gap, var(--bds-space_m))
51
+ );
52
+ }
53
+
54
+ fieldset {
55
+ border: 0;
56
+ margin: 0;
57
+ padding: 0;
58
+ min-inline-size: 0;
59
+ }
60
+
61
+ .legend {
62
+ inline-size: 100%;
63
+ padding-inline: 0;
64
+
65
+ padding-block:
66
+ var(--fieldGroup_legend-padding-block, var(--bds-space_xs));
67
+ margin-block-end:
68
+ var(--fieldGroup_legend-gap, var(--bds-space_m));
69
+ border-block-end:
70
+ var(--fieldGroup_legend-border-block-end, 1px solid var(--bds-color_bg--subtle));
71
+
72
+ color:
73
+ var(--fieldGroup_legend-color, var(--bds-color_on-bg));
74
+ font-family: var(--bds-font_family--body);
75
+ font-size:
76
+ var(--fieldGroup_legend-font-size, var(--bds-font_size--heading-3));
77
+ font-weight:
78
+ var(--fieldGroup_legend-font-weight, var(--bds-font_weight--semibold));
79
+ line-height:
80
+ var(--fieldGroup_legend-line-height, var(--bds-font_line-height--heading));
81
+ }
82
+
83
+ .fields {
84
+ display: flex;
85
+ flex-direction: column;
86
+ gap: var(--fieldGroup_gap, var(--bds-space_m));
87
+ }
88
+
89
+ :host([variant='horizontal']) .fields {
90
+ flex-flow: row wrap;
91
+ }
92
+
93
+ :host([variant='horizontal']) .fields ::slotted(*) {
94
+ flex: 1 1 var(--fieldGroup_min-field-width, 12rem);
95
+ min-inline-size: 0;
96
+ }
97
+
98
+ /* Auto-collapse: when the host's inline-size can't fit a complete
99
+ horizontal row, switch to a single-column stack. Threshold scales
100
+ with the actual slotted-element count (see :host calc above). */
101
+ @container field-group (max-inline-size: var(--fieldGroup_collapse-threshold)) {
102
+ :host([variant='horizontal']) .fields {
103
+ flex-direction: column;
104
+ }
105
+
106
+ :host([variant='horizontal']) .fields ::slotted(*) {
107
+ flex: 1 1 auto;
108
+ }
109
+ }
110
+ `;
111
+
112
+ static properties = {
113
+ variant: { type: String, reflect: true },
114
+ legend: { type: String },
115
+ disabled: { type: Boolean, reflect: true },
116
+ };
117
+
118
+ declare variant: FieldGroupVariant;
119
+ declare legend: string;
120
+ declare disabled: boolean;
121
+
122
+ constructor() {
123
+ super();
124
+ this.variant = 'horizontal';
125
+ this.legend = '';
126
+ this.disabled = false;
127
+ }
128
+
129
+ // Arrow-bound for stable identity (unused here but matches the
130
+ // bds-popover / bds-button conventions for handlers attached in render).
131
+ private _onSlotChange = (e: Event) => {
132
+ const slot = e.target as HTMLSlotElement;
133
+ const count = slot.assignedElements().length;
134
+ this.style.setProperty('--fieldGroup_field-count', String(count));
135
+ };
136
+
137
+ render() {
138
+ return html`
139
+ <fieldset ?disabled=${this.disabled}>
140
+ ${this.legend
141
+ ? html`<legend class="legend">${this.legend}</legend>`
142
+ : nothing}
143
+ <div class="fields">
144
+ <slot @slotchange=${this._onSlotChange}></slot>
145
+ </div>
146
+ </fieldset>
147
+ `;
148
+ }
149
+ }
150
+
151
+ customElements.define('bds-field-group', BdsFieldGroup);
152
+
153
+ declare global {
154
+ interface HTMLElementTagNameMap {
155
+ 'bds-field-group': BdsFieldGroup;
156
+ }
157
+ }
@@ -138,6 +138,7 @@ export class BdsFormInput extends LitElement {
138
138
 
139
139
  .message--hint {
140
140
  color: var(--bds-color_on-bg--subtle);
141
+ font-style: italic;
141
142
  }
142
143
  `;
143
144
 
@@ -66,6 +66,7 @@ export class BdsRadioGroup extends LitElement {
66
66
 
67
67
  .message--hint {
68
68
  color: var(--bds-color_on-bg--subtle);
69
+ font-style: italic;
69
70
  }
70
71
  `;
71
72