Skip to content

Commit

Permalink
refactor: move accessibleName to A11yMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoCardoso committed Nov 27, 2024
1 parent 42ed1e5 commit 20db9fc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
16 changes: 16 additions & 0 deletions packages/grid/src/vaadin-grid-a11y-mixin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @license
* Copyright (c) 2016 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import type { Constructor } from '@open-wc/dedupe-mixin';

export declare function A11yMixin<T extends Constructor<HTMLElement>>(base: T): Constructor<A11yMixinClass> & T;

export declare class A11yMixinClass {
/**
* String used to label the grid to screen reader users.
* @attr {string} accessible-name
*/
accessibleName: string;
}
11 changes: 11 additions & 0 deletions packages/grid/src/vaadin-grid-a11y-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import { iterateChildren, iterateRowCells } from './vaadin-grid-helpers.js';
*/
export const A11yMixin = (superClass) =>
class A11yMixin extends superClass {
static get properties() {
return {
/**
* String used to label the grid to screen reader users.
* @attr {string} accessible-name
*/
accessibleName: {
type: String,
},
};
}
static get observers() {
return ['_a11yUpdateGridSize(size, _columnTree)'];
}
Expand Down
11 changes: 4 additions & 7 deletions packages/grid/src/vaadin-grid-mixin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
import type { Constructor } from '@open-wc/dedupe-mixin';
import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
import type { A11yMixinClass } from './vaadin-grid-a11y-mixin.js';
import type { ActiveItemMixinClass } from './vaadin-grid-active-item-mixin.js';
import type { ArrayDataProviderMixinClass } from './vaadin-grid-array-data-provider-mixin.js';
import type { GridBodyRenderer, GridColumn, GridHeaderFooterRenderer } from './vaadin-grid-column.js';
Expand Down Expand Up @@ -162,7 +163,8 @@ export interface GridEventMap<TItem> extends HTMLElementEventMap, GridCustomEven

export declare function GridMixin<TItem, T extends Constructor<HTMLElement>>(
base: T,
): Constructor<ActiveItemMixinClass<TItem>> &
): Constructor<A11yMixinClass> &
Constructor<ActiveItemMixinClass<TItem>> &
Constructor<ArrayDataProviderMixinClass<TItem>> &
Constructor<ColumnReorderingMixinClass> &
Constructor<DataProviderMixinClass<TItem>> &
Expand All @@ -179,6 +181,7 @@ export declare function GridMixin<TItem, T extends Constructor<HTMLElement>>(

export interface GridMixinClass<TItem>
extends DisabledMixinClass,
A11yMixinClass,
ActiveItemMixinClass<TItem>,
ArrayDataProviderMixinClass<TItem>,
DataProviderMixinClass<TItem>,
Expand All @@ -199,12 +202,6 @@ export interface GridMixinClass<TItem>
*/
allRowsVisible: boolean;

/**
* String used to label the grid to screen reader users.
* @attr {string} accessible-name
*/
accessibleName: string;

/**
* Updates the `width` of all columns which have `autoWidth` set to `true`.
*/
Expand Down
8 changes: 0 additions & 8 deletions packages/grid/src/vaadin-grid-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,6 @@ export const GridMixin = (superClass) =>
reflectToAttribute: true,
},

/**
* String used to label the grid to screen reader users.
* @attr {string} accessible-name
*/
accessibleName: {
type: String,
},

/** @private */
__pendingRecalculateColumnWidths: {
type: Boolean,
Expand Down

0 comments on commit 20db9fc

Please sign in to comment.