Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .eslintignore

This file was deleted.

52 changes: 0 additions & 52 deletions .eslintrc.js

This file was deleted.

1 change: 0 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

// eslint-disable-next-line no-undef
module.exports = {
arrowParens: 'always',
bracketSpacing: true,
Expand Down
11 changes: 10 additions & 1 deletion .template-lintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ module.exports = {
plugins: ['./linters/handlebars'],

rules: {
'u-template-lint/no-bare-button': 'error'
'u-template-lint/no-bare-button': 'error',
// Disabled: in v3 this rule also flags `keydown`, which is a known false positive. The rule enforces WCAG F101,
// which only covers pointer-down events (mousedown / pointerdown) and never the keyboard. Upstream narrowed it
// accordingly and renamed it `no-pointer-down-event-binding` in v5.0.0 (PR ember-template-lint#2054), so the
// current version of the rule reports nothing here.
// Every violation in this repo is a `keydown` handler calling preventDefault, either to filter keystrokes
// (currency, number and phone inputs) or to stop the page from scrolling on arrow keys (select navigation).
// `keyup` fires once the character is inserted and the page has scrolled, so it cannot replace them.
// Drop this entry when ember-template-lint is upgraded to v5 or later: the rule no longer exists under this name.
'no-down-event-binding': false
}
};
23 changes: 10 additions & 13 deletions addon-test-support/custom-assertions/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export interface TooltipAssertions {
const assertion = (selector: string): TooltipAssertions => {
return {
exists: async (trigger?: string, message?: string): Promise<void> => {
let result: boolean = true;
let actual: Element | null = null;
const result: boolean = true;
const actual: Element | null = null;

await triggerEventOnElement(selector, trigger);

Expand Down Expand Up @@ -131,12 +131,9 @@ const assertion = (selector: string): TooltipAssertions => {
doesNotHaveSubtitle: async (message?: string): Promise<void> => {
await triggerEventOnElement(selector);

let result = false;
let actual = undefined;
const subtitleContainer = document.querySelector('.upf-tooltip .subtitle');

actual = (<HTMLElement>subtitleContainer)?.innerText;
result = isEmpty(actual);
const actual = (<HTMLElement>subtitleContainer)?.innerText;
const result = isEmpty(actual);

QUnit.assert.pushResult({
result,
Expand Down Expand Up @@ -170,8 +167,8 @@ const assertion = (selector: string): TooltipAssertions => {
await triggerEventOnElement(selector);

const iconI = document.querySelector('.upf-tooltip .title-container i');
let actual = iconI?.className;
let result = isEmpty(actual);
const actual = iconI?.className;
const result = isEmpty(actual);

QUnit.assert.pushResult({
result,
Expand Down Expand Up @@ -205,8 +202,8 @@ const assertion = (selector: string): TooltipAssertions => {
await triggerEventOnElement(selector);

const titleContainer = document.querySelector('.upf-tooltip .title-container .title');
let actual = (<HTMLElement>titleContainer)?.dataset.htmlSafe;
let result = actual === 'true';
const actual = (<HTMLElement>titleContainer)?.dataset.htmlSafe;
const result = actual === 'true';

QUnit.assert.pushResult({
result,
Expand All @@ -220,8 +217,8 @@ const assertion = (selector: string): TooltipAssertions => {
await triggerEventOnElement(selector);

const titleContainer = document.querySelector('.upf-tooltip .title-container .title');
let actual = (<HTMLElement>titleContainer)?.dataset.htmlSafe;
let result = actual === undefined;
const actual = (<HTMLElement>titleContainer)?.dataset.htmlSafe;
const result = actual === undefined;

QUnit.assert.pushResult({
result,
Expand Down
2 changes: 1 addition & 1 deletion addon-test-support/register-assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const ASSERTIONS = [tooltipAssertions, infiniteSelectOptionAssertions, dcnAssert

export default function registerAssertions(assert: Assert) {
ASSERTIONS.forEach((assertion) => {
// @ts-ignore
// @ts-expect-error custom assertions are dynamically registered on Assert
assert[assertion.__name__] = assertion;
});
}
2 changes: 1 addition & 1 deletion addon/components/o-s-s/anchor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class OSSAnchor extends Component<OSSAnchorArgs> {
const route = this.args.routePrefix ? this.args.routePrefix + '.' + this.args.link : this.args.link;
try {
return Boolean(this.router.urlFor(route));
} catch (error) {
} catch {
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions addon/components/o-s-s/array-input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Input
@value={{this.currentValue}}
placeholder={{@placeholder}}
aria-label={{@ariaLabel}}
autocomplete="off"
disabled={{@disabled}}
{{on "keydown" this.keyListener}}
Expand Down
10 changes: 10 additions & 0 deletions addon/components/o-s-s/array-input.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ export default {
},
control: { type: 'array' }
},
ariaLabel: {
description: 'Accessible name of the input, used when no visible label is associated with it',
table: {
type: {
summary: 'string'
},
defaultValue: { summary: 'undefined' }
},
control: { type: 'text' }
},
placeholder: {
description: 'The placeholder to show when the input is empty',
table: {
Expand Down
7 changes: 3 additions & 4 deletions addon/components/o-s-s/array-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface OSSArrayInputArgs {
validator?: (value: string) => boolean;
onChange?: (values: string[]) => void;
placeholder?: string;
ariaLabel?: string;
}

const DEFAULT_KEYBOARD_TRIGGERS = ['Enter'];
Expand All @@ -26,7 +27,7 @@ export default class OSSArrayInput extends Component<OSSArrayInputArgs> {
}

get computedClasses(): string {
let arr: string[] = ['array-input-container'];
const arr: string[] = ['array-input-container'];

if (this.args.disabled) {
arr.push('array-input-container--disabled');
Expand All @@ -44,9 +45,7 @@ export default class OSSArrayInput extends Component<OSSArrayInputArgs> {
}

private _triggerComponentRedraw(): void {
// Since this.items is not properly tracked upon updating the values,
// re-assigning this way triggers the component redraw.
this.items = this.items;
this.items = [...this.items];
}

private _addEntry() {
Expand Down
4 changes: 2 additions & 2 deletions addon/components/o-s-s/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export default class OSSAvatar extends Component<OSSAvatarArgs> {
Object.keys(SizeDefinition).includes(size as SizeType)
);

classes.push(SizeDefinition[size as SizeType])
return classes.join(' ')
classes.push(SizeDefinition[size as SizeType]);
return classes.join(' ');
}

@action
Expand Down
16 changes: 14 additions & 2 deletions addon/components/o-s-s/button-dropdown.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
{{if this.displayDropdown 'oss-button-dropdown__trigger--active'}}
fx-row fx-xalign-center"
role={{unless @mainAction "button"}}
tabindex={{unless @mainAction "0"}}
{{on "click" this.onDropdownClick}}
...attributes
>
<div class="fx-row fx-xalign-center fx-gap-px-6" role={{if @mainAction "button"}} {{on "click" this.onMainAction}}>
<div
class="fx-row fx-xalign-center fx-gap-px-6"
role={{if @mainAction "button"}}
tabindex={{if @mainAction "0"}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another tabIndex here, my guess is that a rule requires this, you can disregard my first comment above I guess ^^

{{on "click" this.onMainAction}}
>
{{#if @icon}}
<OSS::Icon @style={{fa-icon-style @icon}} @icon={{fa-icon-value @icon}} />
{{/if}}
Expand All @@ -17,14 +23,20 @@
{{/if}}
</div>
{{#unless @hideArrow}}
<div class="fx-row fx-xalign-center" role={{if @mainAction "button"}} {{on "click" this.toggleDropdown}}>
<div
class="fx-row fx-xalign-center"
role={{if @mainAction "button"}}
tabindex={{if @mainAction "0"}}
{{on "click" this.toggleDropdown}}
>
<OSS::Icon @icon="fa-caret-{{if this.displayDropdown 'up' 'down'}}" />
</div>
{{/unless}}
</div>

{{#if this.displayDropdown}}
<div
{{! template-lint-disable no-invalid-interactive }}
class="oss-button-dropdown__items"
{{on "click" this.toggleDropdown}}
{{did-insert this.setupChildrenClickHandler}}
Expand Down
2 changes: 1 addition & 1 deletion addon/components/o-s-s/button-dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class extends Component<OSSButtonDropdownArgs> {
}

@action
closeDropdown(e?: Event): void {
closeDropdown(event?: Event): void {
event?.stopPropagation();
this.displayDropdown = false;
}
Expand Down
5 changes: 3 additions & 2 deletions addon/components/o-s-s/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export interface OSSButtonArgs {
theme?: string;
square?: boolean;
countDown?: {
callback: () => {};
callback: () => void;
time?: number;
step?: number;
};
Expand Down Expand Up @@ -132,7 +132,7 @@ export default class OSSButton<T extends OSSButtonArgs> extends Component<T> {
}

get computedClass() {
let classes = [this.args.square ? SQUARE_CLASS : BASE_CLASS, `upf-btn--${this.skin}`];
const classes = [this.args.square ? SQUARE_CLASS : BASE_CLASS, `upf-btn--${this.skin}`];

if (this.size) {
classes.push(this.args.square ? `upf-square-btn--${this.size}` : `upf-btn--${this.size}`);
Expand All @@ -151,6 +151,7 @@ export default class OSSButton<T extends OSSButtonArgs> extends Component<T> {
}

if (this.args.loading && !this.args.loadingOptions?.showLabel) {
// eslint-disable-next-line ember/no-side-effects
this.DOMElement.style.width = `${this.DOMElement?.offsetWidth}px`;
} else {
this.DOMElement.style.removeProperty('width');
Expand Down
2 changes: 1 addition & 1 deletion addon/components/o-s-s/carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class OSSCarousel extends Component<OSSCarouselArgs> {
}

get showControls(): boolean {
return !!this.args.showControls ?? false;
return !!this.args.showControls;
}

get loop(): boolean {
Expand Down
7 changes: 6 additions & 1 deletion addon/components/o-s-s/checkbox.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<div class="upf-checkbox {{this.modifierClasses}}" ...attributes {{on "click" this.updateValue}}>
<div
{{! template-lint-disable no-invalid-interactive }}
class="upf-checkbox {{this.modifierClasses}}"
...attributes
{{on "click" this.updateValue}}
>
<Input
@type="checkbox"
@checked={{@checked}}
Expand Down
7 changes: 6 additions & 1 deletion addon/components/o-s-s/chip.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<div class={{this.computedClass}} ...attributes {{on "click" this.stopPropagation}}>
<div
{{! template-lint-disable no-invalid-interactive }}
class={{this.computedClass}}
...attributes
{{on "click" this.stopPropagation}}
>
{{#if (has-block "prefix")}}
{{yield to="prefix"}}
{{/if}}
Expand Down
2 changes: 2 additions & 0 deletions addon/components/o-s-s/content-panel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Component from '@glimmer/component';

// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface OSSContentPanelArgs {}

// eslint-disable-next-line ember/no-empty-glimmer-component-classes
export default class OSSContentPanel extends Component<OSSContentPanelArgs> {}
11 changes: 8 additions & 3 deletions addon/components/o-s-s/context-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export type ContextMenuItem = {
interface OSSContextMenuArgs extends OSSButtonArgs {
items: ContextMenuItem[];
closeOnMouseLeave?: boolean;
onMenuOpened?: () => {};
onMenuClosed?: () => {};
onMenuOpened?: () => void;
onMenuClosed?: () => void;
}

export default class OSSContextMenuComponent extends Component<OSSContextMenuArgs> {
Expand All @@ -34,7 +34,12 @@ export default class OSSContextMenuComponent extends Component<OSSContextMenuArg
event.stopPropagation();
if (this.args.loading) return;
this.displayContextMenuPanel = !this.displayContextMenuPanel;
this.displayContextMenuPanel ? this.args.onMenuOpened?.() : this.args.onMenuClosed?.();

if (this.displayContextMenuPanel) {
this.args.onMenuOpened?.();
} else {
this.args.onMenuClosed?.();
}
}

@action
Expand Down
4 changes: 1 addition & 3 deletions addon/components/o-s-s/context-menu/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ export default class OSSContextMenuPanelComponent extends Component<OSSContextMe
registerPanel(element: HTMLElement): void {
this.currentPanel = element;
this.args.registerPanel?.(this.currentPanel);
scheduleOnce('afterRender', this, () => {
this.initializeDropdown();
});
scheduleOnce('afterRender', this, this.initializeDropdown);

this.currentPanel.querySelector('.oss-scrollable-panel-content')?.addEventListener('scroll', this.onScrollbound);
}
Expand Down
Loading