diff --git a/src/elements/checkbox/checkbox-panel/readme.md b/src/elements/checkbox/checkbox-panel/readme.md
index 37d678e681..23536063b9 100644
--- a/src/elements/checkbox/checkbox-panel/readme.md
+++ b/src/elements/checkbox/checkbox-panel/readme.md
@@ -71,23 +71,26 @@ The component provides the same accessibility features as the native checkbox.
Always provide an accessible label via `aria-label` for checkboxes without descriptive text content.
If you don't want the label to appear next to the checkbox, you can use `aria-label` to specify an appropriate label.
+
## Properties
-| Name | Attribute | Privacy | Type | Default | Description |
-| --------------- | --------------- | ------- | --------------------------------- | --------- | ----------------------------------------------------------- |
-| `borderless` | `borderless` | public | `boolean` | `false` | Whether the unselected panel has a border. |
-| `checked` | `checked` | public | `boolean` | `false` | Whether the checkbox is checked. |
-| `color` | `color` | public | `'white' \| 'milk'` | `'white'` | The background color of the panel. |
-| `disabled` | `disabled` | public | `boolean` | `false` | Whether the component is disabled. |
-| `form` | - | public | `HTMLFormElement \| null` | | Returns the form owner of internals target element. |
-| `group` | - | public | `SbbCheckboxGroupElement \| null` | `null` | Reference to the connected checkbox group. |
-| `indeterminate` | `indeterminate` | public | `boolean` | `false` | Whether the checkbox is indeterminate. |
-| `name` | `name` | public | `string` | | Name of the form element. Will be read from name attribute. |
-| `required` | `required` | public | `boolean` | `false` | Whether the component is required. |
-| `size` | `size` | public | `SbbPanelSize` | `'m'` | Size variant. |
-| `value` | `value` | public | `string \| null` | `null` | Value of the form element. |
+| Name | Attribute | Privacy | Type | Default | Description |
+| --------------- | --------------- | ------- | --------------------------------- | --------- | -------------------------------------------------------------- |
+| `borderless` | `borderless` | public | `boolean` | `false` | Whether the unselected panel has a border. |
+| `checked` | `checked` | public | `boolean` | `false` | Whether the checkbox is checked. |
+| `color` | `color` | public | `'white' \| 'milk'` | `'white'` | The background color of the panel. |
+| `disabled` | `disabled` | public | `boolean` | `false` | Whether the component is disabled. |
+| `form` | - | public | `HTMLFormElement \| null` | | Returns the form owner of the internals of the target element. |
+| `group` | - | public | `SbbCheckboxGroupElement \| null` | `null` | Reference to the connected checkbox group. |
+| `indeterminate` | `indeterminate` | public | `boolean` | `false` | Whether the checkbox is indeterminate. |
+| `name` | `name` | public | `string` | | Name of the form element. Will be read from name attribute. |
+| `required` | `required` | public | `boolean` | `false` | Whether the component is required. |
+| `size` | `size` | public | `SbbPanelSize` | `'m'` | Size variant. |
+| `value` | `value` | public | `string \| null` | `null` | Value of the form element. |
## Events
diff --git a/src/elements/checkbox/checkbox/readme.md b/src/elements/checkbox/checkbox/readme.md
index 389f60190c..ce419ee5ea 100644
--- a/src/elements/checkbox/checkbox/readme.md
+++ b/src/elements/checkbox/checkbox/readme.md
@@ -77,6 +77,9 @@ If you don't want the label to appear next to the checkbox, you can use `aria-la
```
+
## Properties
@@ -85,7 +88,7 @@ If you don't want the label to appear next to the checkbox, you can use `aria-la
| --------------- | ---------------- | ------- | --------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `checked` | `checked` | public | `boolean` | `false` | Whether the checkbox is checked. |
| `disabled` | `disabled` | public | `boolean` | `false` | Whether the component is disabled. |
-| `form` | - | public | `HTMLFormElement \| null` | | Returns the form owner of internals target element. |
+| `form` | - | public | `HTMLFormElement \| null` | | Returns the form owner of the internals of the target element. |
| `group` | - | public | `SbbCheckboxGroupElement \| null` | `null` | Reference to the connected checkbox group. |
| `iconName` | `icon-name` | public | `string \| undefined` | | The icon name we want to use, choose from the small icon variants from the ui-icons category from here https://icons.app.sbb.ch. |
| `iconPlacement` | `icon-placement` | public | `SbbIconPlacement` | `'end'` | The label position relative to the labelIcon. Defaults to end |
diff --git a/src/elements/core/mixins/form-associated-checkbox-mixin.ts b/src/elements/core/mixins/form-associated-checkbox-mixin.ts
index 9d2eeae27c..d651ee40ed 100644
--- a/src/elements/core/mixins/form-associated-checkbox-mixin.ts
+++ b/src/elements/core/mixins/form-associated-checkbox-mixin.ts
@@ -35,6 +35,7 @@ export declare abstract class SbbFormAssociatedCheckboxMixinType
protected isDisabledExternally(): boolean;
protected isRequiredExternally(): boolean;
protected withUserInteraction?(): void;
+ protected updateFormValue(): void;
}
/**
diff --git a/src/elements/core/mixins/form-associated-mixin.ts b/src/elements/core/mixins/form-associated-mixin.ts
index 7ede1464f7..b25472b884 100644
--- a/src/elements/core/mixins/form-associated-mixin.ts
+++ b/src/elements/core/mixins/form-associated-mixin.ts
@@ -1,15 +1,15 @@
import type { LitElement } from 'lit';
import { property, state } from 'lit/decorators.js';
-import type { Constructor } from './constructor.js';
+import type { AbstractConstructor } from './constructor.js';
-export declare abstract class SbbFormAssociatedMixinType {
+export declare abstract class SbbFormAssociatedMixinType {
public get form(): HTMLFormElement | null;
public get name(): string;
public set name(value: string);
public get type(): string;
- public get value(): string | null;
- public set value(value: string | null);
+ public get value(): V | null;
+ public set value(value: V | null);
public get validity(): ValidityState;
public get validationMessage(): string;
@@ -29,24 +29,24 @@ export declare abstract class SbbFormAssociatedMixinType {
reason: FormRestoreReason,
): void;
- protected updateFormValue(): void;
+ protected abstract updateFormValue(): void;
}
/**
* The FormAssociatedMixin enables native form support for custom controls.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
-export const SbbFormAssociatedMixin = >(
+export const SbbFormAssociatedMixin = , V = string>(
superClass: T,
-): Constructor & T => {
+): AbstractConstructor> & T => {
abstract class SbbFormAssociatedElement
extends superClass
- implements Partial
+ implements Partial>
{
public static formAssociated = true;
/**
- * Returns the form owner of internals target element.
+ * Returns the form owner of the internals of the target element.
*/
public get form(): HTMLFormElement | null {
return this.internals.form;
@@ -73,14 +73,14 @@ export const SbbFormAssociatedMixin = >(
/** Value of the form element. */
@property()
- public set value(value: string | null) {
+ public set value(value: V | null) {
this._value = value;
this.updateFormValue();
}
- public get value(): string | null {
+ public get value(): V | null {
return this._value;
}
- private _value: string | null = null;
+ private _value: V | null = null;
/**
* Returns the ValidityState object for internals target element.
@@ -192,12 +192,15 @@ export const SbbFormAssociatedMixin = >(
reason: FormRestoreReason,
): void;
- /** Should be called when form value is changed. */
- protected updateFormValue(): void {
- this.internals.setFormValue(this.value);
- }
+ /**
+ * Should be called when form value is changed.
+ * Adapts and sets the formValue in the supported format (string | FormData | File | null)
+ * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setFormValue
+ */
+ protected abstract updateFormValue(): void;
}
- return SbbFormAssociatedElement as unknown as Constructor & T;
+ return SbbFormAssociatedElement as unknown as AbstractConstructor> &
+ T;
};
/**
diff --git a/src/elements/core/mixins/required-mixin.ts b/src/elements/core/mixins/required-mixin.ts
index 476df7f145..b9191a86a5 100644
--- a/src/elements/core/mixins/required-mixin.ts
+++ b/src/elements/core/mixins/required-mixin.ts
@@ -15,7 +15,8 @@ export declare class SbbRequiredMixinType {
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export const SbbRequiredMixin = <
- T extends AbstractConstructor,
+ T extends AbstractConstructor>,
+ V,
>(
superClass: T,
): AbstractConstructor & T => {
diff --git a/src/elements/select/readme.md b/src/elements/select/readme.md
index 39c418ec57..2f93be7a00 100644
--- a/src/elements/select/readme.md
+++ b/src/elements/select/readme.md
@@ -111,20 +111,25 @@ Opened panel:
| ShiftUp Arrow | If `multiple`, moves to the next non-disabled option and toggle its selection. |
| Any char or number | If exists, select the first non-disabled matching option after the selected value. |
+
## Properties
-| Name | Attribute | Privacy | Type | Default | Description |
-| ------------- | ------------- | ------- | --------------------------------- | ------- | ------------------------------------------------------------------------ |
-| `disabled` | `disabled` | public | `boolean` | `false` | Whether the component is disabled. |
-| `isOpen` | - | public | `boolean` | | Whether the element is open. |
-| `multiple` | `multiple` | public | `boolean` | `false` | Whether the select allows for multiple selection. |
-| `negative` | `negative` | public | `boolean` | `false` | Negative coloring variant flag. |
-| `placeholder` | `placeholder` | public | `string \| undefined` | | The placeholder used if no value has been selected. |
-| `readonly` | `readonly` | public | `boolean` | `false` | Whether the select is readonly. |
-| `required` | `required` | public | `boolean` | `false` | Whether the select is required. |
-| `value` | `value` | public | `string \| string[] \| undefined` | | The value of the select component. If `multiple` is true, it's an array. |
+| Name | Attribute | Privacy | Type | Default | Description |
+| ------------- | ------------- | ------- | ---------------------------- | ------- | -------------------------------------------------------------- |
+| `disabled` | `disabled` | public | `boolean` | `false` | Whether the component is disabled. |
+| `form` | - | public | `HTMLFormElement \| null` | | Returns the form owner of the internals of the target element. |
+| `isOpen` | - | public | `boolean` | | Whether the element is open. |
+| `multiple` | `multiple` | public | `boolean` | `false` | Whether the select allows for multiple selection. |
+| `name` | `name` | public | `string` | | Name of the form element. Will be read from name attribute. |
+| `negative` | `negative` | public | `boolean` | `false` | Negative coloring variant flag. |
+| `placeholder` | `placeholder` | public | `string \| undefined` | | The placeholder used if no value has been selected. |
+| `readonly` | `readonly` | public | `boolean` | `false` | Whether the select is readonly. |
+| `required` | `required` | public | `boolean` | `false` | Whether the component is required. |
+| `value` | `value` | public | `string \| string[] \| null` | `null` | Value of the form element. |
## Methods
diff --git a/src/elements/select/select.spec.ts b/src/elements/select/select.spec.ts
index 6b45d56260..cc67d631ac 100644
--- a/src/elements/select/select.spec.ts
+++ b/src/elements/select/select.spec.ts
@@ -10,389 +10,550 @@ import { SbbOptionElement } from '../option.js';
import { SbbSelectElement } from './select.js';
describe(`sbb-select`, () => {
- let element: SbbSelectElement,
- focusableElement: HTMLElement,
- firstOption: SbbOptionElement,
- secondOption: SbbOptionElement,
- thirdOption: SbbOptionElement,
- displayValue: HTMLElement,
- comboBoxElement: HTMLElement;
-
- beforeEach(async () => {
- const root = await fixture(html`
-