From 0fc5f40191bcab18f901984e86d75607edc304e4 Mon Sep 17 00:00:00 2001
From: Davide Mininni
<101575400+DavideMininni-Fincons@users.noreply.github.com>
Date: Tue, 9 Jul 2024 18:18:24 +0200
Subject: [PATCH] feat(sbb-autocomplete-grid): component implementation (#2512)
---
src/elements/autocomplete-grid.ts | 6 +
.../autocomplete-grid-button.ts | 1 +
...complete-grid-button.snapshot.spec.snap.js | 116 ++++
.../autocomplete-grid-button.scss | 15 +
.../autocomplete-grid-button.snapshot.spec.ts | 104 ++++
.../autocomplete-grid-button.spec.ts | 53 ++
.../autocomplete-grid-button.ssr.spec.ts | 21 +
.../autocomplete-grid-button.stories.ts | 155 +++++
.../autocomplete-grid-button.ts | 111 ++++
.../autocomplete-grid-button.visual.spec.ts | 69 +++
.../autocomplete-grid-button/readme.md | 109 ++++
.../autocomplete-grid-cell.ts | 1 +
...tocomplete-grid-cell.snapshot.spec.snap.js | 59 ++
.../autocomplete-grid-cell.scss | 13 +
.../autocomplete-grid-cell.snapshot.spec.ts | 44 ++
.../autocomplete-grid-cell.spec.ts | 18 +
.../autocomplete-grid-cell.ssr.spec.ts | 20 +
.../autocomplete-grid-cell.stories.ts | 130 +++++
.../autocomplete-grid-cell.ts | 34 ++
.../autocomplete-grid-cell.visual.spec.ts | 21 +
.../autocomplete-grid-cell/readme.md | 42 ++
.../autocomplete-grid-optgroup.ts | 1 +
...mplete-grid-optgroup.snapshot.spec.snap.js | 166 ++++++
...utocomplete-grid-optgroup.snapshot.spec.ts | 63 +++
.../autocomplete-grid-optgroup.spec.ts | 114 ++++
.../autocomplete-grid-optgroup.ssr.spec.ts | 56 ++
.../autocomplete-grid-optgroup.stories.ts | 154 +++++
.../autocomplete-grid-optgroup.ts | 46 ++
.../autocomplete-grid-optgroup.visual.spec.ts | 106 ++++
.../autocomplete-grid-optgroup/index.ts | 1 +
.../autocomplete-grid-optgroup/readme.md | 78 +++
.../autocomplete-grid-option.ts | 1 +
...complete-grid-option.snapshot.spec.snap.js | 97 ++++
.../autocomplete-grid-option.scss | 70 +++
.../autocomplete-grid-option.snapshot.spec.ts | 67 +++
.../autocomplete-grid-option.spec.ts | 225 ++++++++
.../autocomplete-grid-option.ssr.spec.ts | 47 ++
.../autocomplete-grid-option.stories.ts | 195 +++++++
.../autocomplete-grid-option.ts | 100 ++++
.../autocomplete-grid-option.visual.spec.ts | 114 ++++
.../autocomplete-grid-option/readme.md | 115 ++++
.../autocomplete-grid-row.ts | 1 +
...utocomplete-grid-row.snapshot.spec.snap.js | 81 +++
.../autocomplete-grid-row.scss | 87 +++
.../autocomplete-grid-row.snapshot.spec.ts | 44 ++
.../autocomplete-grid-row.spec.ts | 20 +
.../autocomplete-grid-row.ssr.spec.ts | 20 +
.../autocomplete-grid-row.stories.ts | 73 +++
.../autocomplete-grid-row.ts | 41 ++
.../autocomplete-grid-row.visual.spec.ts | 78 +++
.../autocomplete-grid-row/readme.md | 40 ++
.../autocomplete-grid/autocomplete-grid.ts | 1 +
.../autocomplete-grid.snapshot.spec.snap.js | 235 ++++++++
.../autocomplete-grid.snapshot.spec.ts | 67 +++
.../autocomplete-grid.spec.ts | 373 ++++++++++++
.../autocomplete-grid.ssr.spec.ts | 62 ++
.../autocomplete-grid.stories.ts | 530 ++++++++++++++++++
.../autocomplete-grid/autocomplete-grid.ts | 226 ++++++++
.../autocomplete-grid.visual.spec.ts | 302 ++++++++++
.../autocomplete-grid/readme.md | 180 ++++++
src/elements/autocomplete.ts | 1 +
...te.scss => autocomplete-base-element.scss} | 4 +
.../autocomplete/autocomplete-base-element.ts | 447 +++++++++++++++
.../autocomplete/autocomplete.spec.ts | 46 +-
src/elements/autocomplete/autocomplete.ts | 455 +--------------
.../autocomplete/autocomplete.visual.spec.ts | 276 +++++++++
src/elements/autocomplete/readme.md | 4 +-
.../breadcrumb-group/breadcrumb-group.ts | 1 +
src/elements/button/mini-button.ts | 1 +
.../mini-button/mini-button-base-element.ts | 15 +
.../button/mini-button/mini-button.stories.ts | 2 +-
.../button/mini-button/mini-button.ts | 17 +-
.../overlay/overlay-trigger-attributes.ts | 5 +-
src/elements/core/styles/core.scss | 1 +
src/elements/core/styles/mixins/buttons.scss | 13 +-
.../form-field-clear/form-field-clear.ts | 1 +
.../form-field/form-field/form-field.ts | 4 +-
src/elements/icon/icon-base.ts | 1 +
src/elements/icon/icon.ts | 1 +
.../navigation-marker/navigation-marker.ts | 1 +
src/elements/option/optgroup.ts | 1 +
...tgroup.scss => optgroup-base-element.scss} | 0
.../option/optgroup/optgroup-base-element.ts | 149 +++++
.../option/optgroup/optgroup.stories.ts | 3 +-
src/elements/option/optgroup/optgroup.ts | 145 +----
.../option/optgroup/optgroup.visual.spec.ts | 133 +++++
src/elements/option/option.ts | 1 +
.../option/option/option-base-element.ts | 281 ++++++++++
src/elements/option/option/option.scss | 2 +-
src/elements/option/option/option.stories.ts | 3 +-
src/elements/option/option/option.ts | 340 ++---------
.../option/option/option.visual.spec.ts | 129 +++++
src/elements/option/option/readme.md | 2 +-
.../stepper.snapshot.spec.snap.js | 2 +-
.../table-wrapper.snapshot.spec.snap.js | 2 +-
.../time-input.snapshot.spec.snap.js | 6 +-
.../custom-elements-manifest.config.js | 3 +-
97 files changed, 7017 insertions(+), 900 deletions(-)
create mode 100644 src/elements/autocomplete-grid.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-button.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-button/__snapshots__/autocomplete-grid-button.snapshot.spec.snap.js
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.scss
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.snapshot.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.ssr.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.stories.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.visual.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-button/readme.md
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-cell.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-cell/__snapshots__/autocomplete-grid-cell.snapshot.spec.snap.js
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.scss
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.snapshot.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.ssr.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.stories.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.visual.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-cell/readme.md
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-optgroup.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-optgroup/__snapshots__/autocomplete-grid-optgroup.snapshot.spec.snap.js
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.snapshot.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.ssr.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.stories.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.visual.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-optgroup/index.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-optgroup/readme.md
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-option.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-option/__snapshots__/autocomplete-grid-option.snapshot.spec.snap.js
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.scss
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.snapshot.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.ssr.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.stories.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.visual.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-option/readme.md
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-row.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-row/__snapshots__/autocomplete-grid-row.snapshot.spec.snap.js
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.scss
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.snapshot.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.ssr.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.stories.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.visual.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid-row/readme.md
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid/__snapshots__/autocomplete-grid.snapshot.spec.snap.js
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid/autocomplete-grid.snapshot.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid/autocomplete-grid.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid/autocomplete-grid.ssr.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid/autocomplete-grid.stories.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid/autocomplete-grid.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid/autocomplete-grid.visual.spec.ts
create mode 100644 src/elements/autocomplete-grid/autocomplete-grid/readme.md
rename src/elements/autocomplete/{autocomplete.scss => autocomplete-base-element.scss} (96%)
create mode 100644 src/elements/autocomplete/autocomplete-base-element.ts
create mode 100644 src/elements/autocomplete/autocomplete.visual.spec.ts
create mode 100644 src/elements/button/mini-button/mini-button-base-element.ts
rename src/elements/option/optgroup/{optgroup.scss => optgroup-base-element.scss} (100%)
create mode 100644 src/elements/option/optgroup/optgroup-base-element.ts
create mode 100644 src/elements/option/optgroup/optgroup.visual.spec.ts
create mode 100644 src/elements/option/option/option-base-element.ts
create mode 100644 src/elements/option/option/option.visual.spec.ts
diff --git a/src/elements/autocomplete-grid.ts b/src/elements/autocomplete-grid.ts
new file mode 100644
index 0000000000..e8733d6230
--- /dev/null
+++ b/src/elements/autocomplete-grid.ts
@@ -0,0 +1,6 @@
+export * from './autocomplete-grid/autocomplete-grid.js';
+export * from './autocomplete-grid/autocomplete-grid-button.js';
+export * from './autocomplete-grid/autocomplete-grid-cell.js';
+export * from './autocomplete-grid/autocomplete-grid-optgroup.js';
+export * from './autocomplete-grid/autocomplete-grid-option.js';
+export * from './autocomplete-grid/autocomplete-grid-row.js';
diff --git a/src/elements/autocomplete-grid/autocomplete-grid-button.ts b/src/elements/autocomplete-grid/autocomplete-grid-button.ts
new file mode 100644
index 0000000000..5621819751
--- /dev/null
+++ b/src/elements/autocomplete-grid/autocomplete-grid-button.ts
@@ -0,0 +1 @@
+export * from './autocomplete-grid-button/autocomplete-grid-button.js';
diff --git a/src/elements/autocomplete-grid/autocomplete-grid-button/__snapshots__/autocomplete-grid-button.snapshot.spec.snap.js b/src/elements/autocomplete-grid/autocomplete-grid-button/__snapshots__/autocomplete-grid-button.snapshot.spec.snap.js
new file mode 100644
index 0000000000..6e9ab44f1f
--- /dev/null
+++ b/src/elements/autocomplete-grid/autocomplete-grid-button/__snapshots__/autocomplete-grid-button.snapshot.spec.snap.js
@@ -0,0 +1,116 @@
+/* @web/test-runner snapshot v1 */
+export const snapshots = {};
+
+snapshots["sbb-autocomplete-grid-button renders DOM"] =
+`
+ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "" + } + ] +} +
+`; +/* end snapshot sbb-autocomplete-grid-button A11y tree Chrome */ + +snapshots["sbb-autocomplete-grid-button A11y tree Firefox"] = +`+ { + "role": "document", + "name": "", + "children": [ + { + "role": "button", + "name": "" + } + ] +} +
+`; +/* end snapshot sbb-autocomplete-grid-button A11y tree Firefox */ + diff --git a/src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.scss b/src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.scss new file mode 100644 index 0000000000..43a5b2d3c4 --- /dev/null +++ b/src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.scss @@ -0,0 +1,15 @@ +@use '../../core/styles' as sbb; + +// Box-sizing rules contained in typography are not traversing Shadow DOM boundaries. We need to include box-sizing mixin in every component. +@include sbb.box-sizing; + +:host { + // Use !important here to not interfere with Firefox focus ring definition + // which appears in normalize css of several frameworks. + outline: none !important; + display: block; + + --sbb-button-display: flex; +} + +@include sbb.icon-button('.sbb-autocomplete-grid-button', '::slotted(sbb-icon), sbb-icon'); diff --git a/src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.snapshot.spec.ts b/src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.snapshot.spec.ts new file mode 100644 index 0000000000..7654417e29 --- /dev/null +++ b/src/elements/autocomplete-grid/autocomplete-grid-button/autocomplete-grid-button.snapshot.spec.ts @@ -0,0 +1,104 @@ +import { expect } from '@open-wc/testing'; +import { html } from 'lit/static-html.js'; + +import { fixture, testA11yTreeSnapshot } from '../../core/testing/private.js'; +import { waitForLitRender } from '../../core/testing.js'; + +import type { SbbAutocompleteGridButtonElement } from './autocomplete-grid-button.js'; +import '../../form-field.js'; +import '../autocomplete-grid.js'; +import '../autocomplete-grid-row.js'; +import '../autocomplete-grid-cell.js'; +import './autocomplete-grid-button.js'; + +describe('sbb-autocomplete-grid-button', () => { + describe('renders', () => { + let root: SbbAutocompleteGridButtonElement; + beforeEach(async () => { + root = ( + await fixture(html` ++ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "button", + "name": "" + } + ] +} +
+`; +/* end snapshot sbb-autocomplete-grid-cell renders A11y tree Chrome */ + +snapshots["sbb-autocomplete-grid-cell renders A11y tree Firefox"] = +`+ { + "role": "document", + "name": "", + "children": [ + { + "role": "button", + "name": "" + } + ] +} +
+`; +/* end snapshot sbb-autocomplete-grid-cell renders A11y tree Firefox */ + diff --git a/src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.scss b/src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.scss new file mode 100644 index 0000000000..558678f4cc --- /dev/null +++ b/src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.scss @@ -0,0 +1,13 @@ +@use '../../core/styles' as sbb; + +// Box-sizing rules contained in typography are not traversing Shadow DOM boundaries. We need to include box-sizing mixin in every component. +@include sbb.box-sizing; + +:host { + display: block; +} + +.sbb-autocomplete-grid-cell { + display: flex; + column-gap: var(--sbb-spacing-fixed-6x); +} diff --git a/src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.snapshot.spec.ts b/src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.snapshot.spec.ts new file mode 100644 index 0000000000..5c51a97d48 --- /dev/null +++ b/src/elements/autocomplete-grid/autocomplete-grid-cell/autocomplete-grid-cell.snapshot.spec.ts @@ -0,0 +1,44 @@ +import { expect } from '@open-wc/testing'; +import { html } from 'lit/static-html.js'; + +import { fixture, testA11yTreeSnapshot } from '../../core/testing/private.js'; + +import type { SbbAutocompleteGridCellElement } from './autocomplete-grid-cell.js'; +import '../autocomplete-grid.js'; +import '../autocomplete-grid-row.js'; +import './autocomplete-grid-cell.js'; +import '../autocomplete-grid-button.js'; + +describe('sbb-autocomplete-grid-cell', () => { + describe('renders', () => { + let root: SbbAutocompleteGridCellElement; + beforeEach(async () => { + root = ( + await fixture(html` ++ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Option 1" + }, + { + "role": "text", + "name": "Option 2" + } + ] +} +
+`; +/* end snapshot sbb-autocomplete-grid-optgroup renders Chrome-Firefox A11y tree Chrome */ + +snapshots["sbb-autocomplete-grid-optgroup renders Chrome-Firefox A11y tree Firefox"] = +`+ { + "role": "document", + "name": "", + "children": [ + { + "role": "text leaf", + "name": "Option 1" + }, + { + "role": "text leaf", + "name": "Option 2" + } + ] +} +
+`; +/* end snapshot sbb-autocomplete-grid-optgroup renders Chrome-Firefox A11y tree Firefox */ + diff --git a/src/elements/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.snapshot.spec.ts b/src/elements/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.snapshot.spec.ts new file mode 100644 index 0000000000..0c66713349 --- /dev/null +++ b/src/elements/autocomplete-grid/autocomplete-grid-optgroup/autocomplete-grid-optgroup.snapshot.spec.ts @@ -0,0 +1,63 @@ +import { expect } from '@open-wc/testing'; +import type { TemplateResult } from 'lit'; +import { html } from 'lit/static-html.js'; + +import { isSafari } from '../../core/dom.js'; +import { fixture, testA11yTreeSnapshot } from '../../core/testing/private.js'; +import { describeIf } from '../../core/testing.js'; + +import './autocomplete-grid-optgroup.js'; +import '../autocomplete-grid.js'; +import '../autocomplete-grid-row.js'; +import '../autocomplete-grid-option.js'; +import '../autocomplete-grid-cell.js'; +import '../autocomplete-grid-button.js'; +import type { SbbAutocompleteGridOptgroupElement } from './autocomplete-grid-optgroup.js'; + +describe('sbb-autocomplete-grid-optgroup', () => { + describe('renders', () => { + let root: SbbAutocompleteGridOptgroupElement; + const opt: TemplateResult = html` ++ { + "role": "document", + "name": "", + "children": [ + { + "role": "text leaf", + "name": "Option 1" + } + ] +} +
+`; +/* end snapshot sbb-autocomplete-grid-option A11y tree Firefox */ + +snapshots["sbb-autocomplete-grid-option A11y tree Chrome"] = +`+ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Option 1" + } + ] +} +
+`; +/* end snapshot sbb-autocomplete-grid-option A11y tree Chrome */ + diff --git a/src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.scss b/src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.scss new file mode 100644 index 0000000000..acb964f983 --- /dev/null +++ b/src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.scss @@ -0,0 +1,70 @@ +@use '../../core/styles' as sbb; + +// Box-sizing rules contained in typography are not traversing Shadow DOM boundaries. We need to include box-sizing mixin in every component. +@include sbb.box-sizing; + +:host { + --sbb-option-color: var(--sbb-color-charcoal); + --sbb-option-column-gap: var(--sbb-spacing-responsive-xxxs); + --sbb-option-icon-color: var(--sbb-color-metal); + --sbb-option-border-radius: var(--sbb-border-radius-4x); + --sbb-option-padding-inline: var(--sbb-spacing-responsive-xxxs); + --sbb-option-padding-block: calc(var(--sbb-spacing-fixed-2x) + var(--sbb-border-width-2x)); + + display: block; +} + +:host([active]) { + --sbb-focus-outline-offset: calc(-1 * var(--sbb-spacing-fixed-1x)); +} + +:host([data-negative]) { + --sbb-option-color: var(--sbb-color-milk); + --sbb-option-icon-color: var(--sbb-color-smoke); +} + +// If highlighting is enabled, hide the original slot content +:host(:not([data-disable-highlight])) { + .sbb-option__label slot { + display: none; + } +} + +.sbb-option { + @include sbb.text-s--regular; + + display: flex; + align-items: center; + column-gap: var(--sbb-option-column-gap); + justify-content: start; + padding-block: var(--sbb-option-padding-block); + padding-inline: var(--sbb-option-padding-inline); + color: var(--sbb-option-color); + + :host([active]) & { + @include sbb.focus-outline; + + border-radius: var(--sbb-option-border-radius); + } +} + +.sbb-option__label--highlight { + :host(:not(:is([disabled], [data-group-disabled]))) & { + @include sbb.text--bold; + @include sbb.if-forced-colors { + color: Highlight; + } + } +} + +.sbb-option__icon { + display: flex; + min-width: var(--sbb-size-icon-ui-small); + min-height: var(--sbb-size-icon-ui-small); + color: var(--sbb-option-icon-color); + + :host(:not([data-slot-names~='icon'], [icon-name])) & { + // Can be overridden by the 'preserve-icon-space' on the autocomplete + display: var(--sbb-option-icon-container-display, none); + } +} diff --git a/src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.snapshot.spec.ts b/src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.snapshot.spec.ts new file mode 100644 index 0000000000..cdc6c4278a --- /dev/null +++ b/src/elements/autocomplete-grid/autocomplete-grid-option/autocomplete-grid-option.snapshot.spec.ts @@ -0,0 +1,67 @@ +import { expect } from '@open-wc/testing'; +import { html } from 'lit/static-html.js'; + +import { fixture, testA11yTreeSnapshot } from '../../core/testing/private.js'; + +import type { SbbAutocompleteGridOptionElement } from './autocomplete-grid-option.js'; +import '../autocomplete-grid.js'; +import '../autocomplete-grid-row.js'; +import './autocomplete-grid-option.js'; +import '../autocomplete-grid-cell.js'; +import '../autocomplete-grid-button.js'; + +describe('sbb-autocomplete-grid-option', () => { + describe('renders', () => { + let root: SbbAutocompleteGridOptionElement; + beforeEach(async () => { + root = ( + await fixture(html` ++ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "Option 1" + }, + { + "role": "button", + "name": "" + } + ] +} +
+`; +/* end snapshot sbb-autocomplete-grid-row renders A11y tree Chrome */ + +snapshots["sbb-autocomplete-grid-row renders A11y tree Firefox"] = +`+ { + "role": "document", + "name": "", + "children": [ + { + "role": "text leaf", + "name": "Option 1" + }, + { + "role": "button", + "name": "" + } + ] +} +
+`; +/* end snapshot sbb-autocomplete-grid-row renders A11y tree Firefox */ + diff --git a/src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.scss b/src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.scss new file mode 100644 index 0000000000..c6a77c7f8c --- /dev/null +++ b/src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.scss @@ -0,0 +1,87 @@ +@use '../../core/styles' as sbb; + +// Box-sizing rules contained in typography are not traversing Shadow DOM boundaries. We need to include box-sizing mixin in every component. +@include sbb.box-sizing; + +:host { + --sbb-autocomplete-grid-row-color: var(--sbb-color-charcoal); + --sbb-autocomplete-grid-row-background-color: inherit; + --sbb-autocomplete-grid-row-background-color-hover: var(--sbb-color-milk); + --sbb-autocomplete-grid-row-background-color-active: var(--sbb-color-cloud); + --sbb-autocomplete-grid-row-disabled-border-color: var(--sbb-color-graphite); + --sbb-autocomplete-grid-row-disabled-background-color: var(--sbb-color-milk); + --sbb-autocomplete-grid-row-padding-inline-end: var(--sbb-spacing-responsive-xxxs); + --sbb-autocomplete-grid-row-justify-content: space-between; + --sbb-autocomplete-grid-row-min-height: var(--sbb-size-button-m-min-height); + --sbb-autocomplete-grid-row-cursor: pointer; + --sbb-autocomplete-grid-row-border-radius: var(--sbb-border-radius-4x); + --sbb-autocomplete-grid-row-icon-color: var(--sbb-color-metal); + + display: block; +} + +:host([data-negative]) { + --sbb-autocomplete-grid-row-color: var(--sbb-color-milk); + --sbb-autocomplete-grid-row-icon-color: var(--sbb-color-smoke); + --sbb-autocomplete-grid-row-background-color-hover: var(--sbb-color-charcoal); + --sbb-autocomplete-grid-row-background-color-active: var(--sbb-color-iron); + --sbb-autocomplete-grid-row-disabled-border-color: var(--sbb-color-smoke); + --sbb-autocomplete-grid-row-disabled-background-color: var(--sbb-color-charcoal); + --sbb-focus-outline-color: var(--sbb-focus-outline-color-dark); +} + +:host(:hover:not([data-disabled])) { + @include sbb.hover-mq($hover: true) { + --sbb-autocomplete-grid-row-background-color: var( + --sbb-autocomplete-grid-row-background-color-hover + ); + } +} + +:host([data-disabled]) { + --sbb-autocomplete-grid-row-cursor: default; + + @include sbb.if-forced-colors { + --sbb-autocomplete-grid-row-color: GrayText; + } +} + +::slotted(sbb-autocomplete-grid-option) { + flex: 1 1 auto; + margin-right: calc(-1 * var(--sbb-spacing-fixed-2x)); +} + +.sbb-autocomplete-grid-row { + display: flex; + align-items: center; + padding-inline-end: var(--sbb-autocomplete-grid-row-padding-inline-end); + justify-content: var(--sbb-autocomplete-grid-row-justify-content); + gap: var(--sbb-spacing-fixed-6x); + color: var(--sbb-autocomplete-grid-row-color); + background-color: var(--sbb-autocomplete-grid-row-background-color); + cursor: var(--sbb-autocomplete-grid-row-cursor); + -webkit-tap-highlight-color: transparent; + -webkit-text-fill-color: var(--sbb-autocomplete-grid-row-color); + + // Add inner border and background for disabled option when it's not multiple + :host([data-disabled]) & { + position: relative; + z-index: 0; + + &::before { + content: ''; + display: block; + position: absolute; + inset: #{sbb.px-to-rem-build(6)}; + border: var(--sbb-border-width-1x) dashed + var(--sbb-autocomplete-grid-row-disabled-border-color); + border-radius: var(--sbb-border-radius-2x); + background-color: var(--sbb-autocomplete-grid-row-disabled-background-color); + z-index: -1; + + @include sbb.if-forced-colors { + border-color: GrayText; + } + } + } +} diff --git a/src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.snapshot.spec.ts b/src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.snapshot.spec.ts new file mode 100644 index 0000000000..068eb01c57 --- /dev/null +++ b/src/elements/autocomplete-grid/autocomplete-grid-row/autocomplete-grid-row.snapshot.spec.ts @@ -0,0 +1,44 @@ +import { expect } from '@open-wc/testing'; +import type { TemplateResult } from 'lit'; +import { html } from 'lit/static-html.js'; + +import { fixture, testA11yTreeSnapshot } from '../../core/testing/private.js'; + +import type { SbbAutocompleteGridRowElement } from './autocomplete-grid-row.js'; +import '../autocomplete-grid.js'; +import './autocomplete-grid-row.js'; +import '../autocomplete-grid-option.js'; +import '../autocomplete-grid-cell.js'; +import '../autocomplete-grid-button.js'; + +describe('sbb-autocomplete-grid-row', () => { + describe('renders', () => { + let root: SbbAutocompleteGridRowElement; + const row: TemplateResult = html` ++ { + "role": "WebArea", + "name": "", + "children": [ + { + "role": "text", + "name": "" + }, + { + "role": "combobox", + "name": "", + "autocomplete": "list", + "haspopup": "grid" + } + ] +} +
+`; +/* end snapshot sbb-autocomplete-grid Chrome-Firefox A11y tree Chrome */ + +snapshots["sbb-autocomplete-grid Chrome-Firefox A11y tree Firefox"] = +`+ { + "role": "document", + "name": "", + "children": [ + { + "role": "statictext", + "name": "" + }, + { + "role": "combobox", + "name": "", + "autocomplete": "list", + "haspopup": "grid" + } + ] +} +
+`; +/* end snapshot sbb-autocomplete-grid Chrome-Firefox A11y tree Firefox */ + +snapshots["sbb-autocomplete-grid Safari DOM"] = +`z-index
greater than the form
+ field, but it must always be covered by the autocomplete overlay.
+ z-index
greater than the form field, but it must always be
+ covered by the autocomplete overlay.
+ z-index
greater than the form field, but it must always be
+ covered by the autocomplete overlay.
+ { "role": "WebArea", diff --git a/src/elements/table/table-wrapper/__snapshots__/table-wrapper.snapshot.spec.snap.js b/src/elements/table/table-wrapper/__snapshots__/table-wrapper.snapshot.spec.snap.js index af5743f875..956b7eacac 100644 --- a/src/elements/table/table-wrapper/__snapshots__/table-wrapper.snapshot.spec.snap.js +++ b/src/elements/table/table-wrapper/__snapshots__/table-wrapper.snapshot.spec.snap.js @@ -40,7 +40,7 @@ snapshots["sbb-table-wrapper renders Shadow DOM"] = `; /* end snapshot sbb-table-wrapper renders Shadow DOM */ -snapshots["sbb-table-wrapper renders A11y tree Chrome"] = +snapshots["sbb-table-wrapper renders A11y tree Chrome"] = `
{ "role": "WebArea", diff --git a/src/elements/time-input/__snapshots__/time-input.snapshot.spec.snap.js b/src/elements/time-input/__snapshots__/time-input.snapshot.spec.snap.js index 4e883f9860..3cad41657a 100644 --- a/src/elements/time-input/__snapshots__/time-input.snapshot.spec.snap.js +++ b/src/elements/time-input/__snapshots__/time-input.snapshot.spec.snap.js @@ -1,7 +1,7 @@ /* @web/test-runner snapshot v1 */ export const snapshots = {}; -snapshots["sbb-time-input A11y tree Chrome"] = +snapshots["sbb-time-input A11y tree Chrome"] = `
{ "role": "WebArea", @@ -17,7 +17,7 @@ snapshots["sbb-time-input A11y tree Chrome"] = `; /* end snapshot sbb-time-input A11y tree Chrome */ -snapshots["sbb-time-input A11y tree Firefox"] = +snapshots["sbb-time-input A11y tree Firefox"] = `
{ "role": "document", @@ -55,7 +55,7 @@ snapshots["sbb-time-input renders Shadow DOM"] = `; /* end snapshot sbb-time-input renders Shadow DOM */ -snapshots["sbb-time-input renders A11y tree Chrome"] = +snapshots["sbb-time-input renders A11y tree Chrome"] = `
{ "role": "WebArea", diff --git a/tools/manifest/custom-elements-manifest.config.js b/tools/manifest/custom-elements-manifest.config.js index baccff68fb..927f02bdf5 100644 --- a/tools/manifest/custom-elements-manifest.config.js +++ b/tools/manifest/custom-elements-manifest.config.js @@ -52,7 +52,8 @@ export function createManifestConfig(library = '') { for (const module of customElementsManifest.modules) { fixModulePaths(module, fixTsPaths); for (const declaration of module.declarations.filter((d) => d.kind === 'class')) { - if (declaration.name === 'SbbIconBase') { + // Abstract base classes are considered components even if they don't have the `customElement` annotation. + if (declaration.name.includes('Base')) { delete declaration.customElement; } for (const member of declaration.members) {