Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VEL-1590] Road to Glint support: Stage 2 — Kickoff Glint support #351

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
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
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module.exports = {
'ember/no-mixins': 'off',
'ember/no-get': 'off',
'ember/avoid-leaking-state-in-ember-objects': 'off',
'ember/no-global-jquery': 'off',
'ember/no-classic-classes': 'off',
'ember/no-classic-components': 'off',
'ember/require-tagless-components': 'off',
Expand Down
1 change: 1 addition & 0 deletions addon/components/o-s-s/access-panel.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{! @glint-nocheck: not typesafe yet }}
<div class="oss-access-panel-backdrop" role="button" {{on "click" @onClose}}></div>
<div class="oss-access-panel-container" {{did-insert this.setupAnimation}} ...attributes>
{{#if (has-block "header")}}
Expand Down
33 changes: 25 additions & 8 deletions addon/components/o-s-s/access-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@ import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { later } from '@ember/runloop';

interface OSSAccessPanelArgs {
records: unknown[];
initialLoad: boolean;
loading?: boolean;
onSearch(keyword: string): void;
onBottomReached(): void;
onClose(): void;
interface OSSAccessPanelSignature {
Args: {
records: unknown[];
initialLoad: boolean;
loading?: boolean;
onSearch(keyword: string): void;
onBottomReached(): void;
onClose(): void;
};
Blocks: {
columns: [];
'empty-state': [];
header: [];
'no-results': [];
row: [unknown];
};
Element: HTMLDivElement;
}

export default class OSSAccessPanel extends Component<OSSAccessPanelArgs> {
export default class OSSAccessPanelComponent extends Component<OSSAccessPanelSignature> {
loadingRows = new Array(12);
loadingMoreRows = new Array(3);

Expand All @@ -39,3 +49,10 @@ export default class OSSAccessPanel extends Component<OSSAccessPanelArgs> {
this.args.onSearch(this.searchKeyword!);
}
}

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
'OSS::AccessPanel': typeof OSSAccessPanelComponent;
'o-s-s/access-panel': typeof OSSAccessPanelComponent;
}
}
29 changes: 21 additions & 8 deletions addon/components/o-s-s/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ type skinType = 'success' | 'error' | 'warning';

const DEFAULT_SKIN = 'info';

interface OSSAlertArgs {
skin?: skinType;
title?: string;
subtitle?: string;
plain?: boolean;
closable?: boolean;
onClose?(): void;
interface OSSAlertSignature {
Args: {
skin?: skinType;
title?: string;
subtitle?: string;
plain?: boolean;
closable?: boolean;
onClose?(): void;
};
Blocks: {
'extra-content': [];
};
Element: HTMLDivElement;
}

export default class OSSAlert extends Component<OSSAlertArgs> {
export default class OSSAlertComponent extends Component<OSSAlertSignature> {
private declare _DOMElement: HTMLElement;

get skinClass(): string {
Expand Down Expand Up @@ -50,3 +56,10 @@ export default class OSSAlert extends Component<OSSAlertArgs> {
this._DOMElement?.remove();
}
}

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
'OSS::Alert': typeof OSSAlertComponent;
'o-s-s/alert': typeof OSSAlertComponent;
}
}
30 changes: 20 additions & 10 deletions addon/components/o-s-s/array-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@ import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';

interface OSSArrayInputArgs {
values?: string[];
keyboardTriggers?: string[];
errorMessage?: string;
disabled?: boolean;
validator?: (value: string) => boolean;
onChange?: (values: string[]) => void;
placeholder?: string;
interface OSSArrayInputSignature {
Args: {
values?: string[];
keyboardTriggers?: string[];
errorMessage?: string;
disabled?: boolean;
validator?: (value: string) => boolean;
onChange?: (values: string[]) => void;
placeholder?: string;
};
Element: HTMLDivElement;
}

const DEFAULT_KEYBOARD_TRIGGERS = ['Enter'];

export default class OSSArrayInput extends Component<OSSArrayInputArgs> {
export default class OSSArrayInputComponent extends Component<OSSArrayInputSignature> {
@tracked currentValue = '';
@tracked items: string[] = [];

constructor(owner: unknown, args: OSSArrayInputArgs) {
constructor(owner: unknown, args: OSSArrayInputSignature['Args']) {
super(owner, args);
if (this.args.values) {
this.items = this.args.values;
Expand Down Expand Up @@ -97,3 +100,10 @@ export default class OSSArrayInput extends Component<OSSArrayInputArgs> {
this._onChange();
}
}

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
'OSS::ArrayInput': typeof OSSArrayInputComponent;
'o-s-s/array-input': typeof OSSArrayInputComponent;
}
}
1 change: 1 addition & 0 deletions addon/components/o-s-s/attribute/base.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{! @glint-nocheck: not typesafe yet }}
<div class="oss-attribute"
{{on "mouseenter" (fn (mut this.displayCopyBtn) true)}}
{{on "mouseleave" (fn (mut this.displayCopyBtn) false)}}
Expand Down
22 changes: 18 additions & 4 deletions addon/components/o-s-s/attribute/base.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
import { isBlank } from '@ember/utils';
import Component from '@glimmer/component';

interface OSSAttributeBaseArgs {
value: string;
copyable?: boolean;
interface OSSAttributeBaseSignature {
Args: {
value: string;
copyable?: boolean;
};
Blocks: {
label: [];
value: [];
};
Element: HTMLDivElement;
}

export default class OSSAttributeBase extends Component<OSSAttributeBaseArgs> {
export default class OSSAttributeBaseComponent extends Component<OSSAttributeBaseSignature> {
get isCopyable(): boolean {
return (this.args.copyable ?? true) && !isBlank(this.args.value) && this.args.value !== '-';
}
}

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
'OSS::Attribute::Base': typeof OSSAttributeBaseComponent;
'o-s-s/attribute/base': typeof OSSAttributeBaseComponent;
}
}
1 change: 1 addition & 0 deletions addon/components/o-s-s/attribute/country.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{! @glint-nocheck: not typesafe yet }}
<OSS::Attribute::Base @value={{this.countryName}} data-control-name="attribute-country" ...attributes>
<:label>
<span>{{t "oss-components.attribute.country"}}</span>
Expand Down
16 changes: 13 additions & 3 deletions addon/components/o-s-s/attribute/country.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import Component from '@glimmer/component';
import { type CountryData, countries } from '@upfluence/oss-components/utils/country-codes';
import { tracked } from '@glimmer/tracking';

interface OSSAttributeCountryArgs {
countryCode?: string;
interface OSSAttributeCountrySignature {
Args: {
countryCode?: string;
};
Element: HTMLElement;
}

export default class OSSAttributeCountry extends Component<OSSAttributeCountryArgs> {
export default class OSSAttributeCountryComponent extends Component<OSSAttributeCountrySignature> {
@tracked displayCopyBtn: boolean = false;

private countryDictionnary: CountryData[] = countries;
Expand All @@ -17,3 +20,10 @@ export default class OSSAttributeCountry extends Component<OSSAttributeCountryAr
);
}
}

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
'OSS::Attribute::Country': typeof OSSAttributeCountryComponent;
'o-s-s/attribute/country': typeof OSSAttributeCountryComponent;
}
}
1 change: 1 addition & 0 deletions addon/components/o-s-s/attribute/phone-number.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{! @glint-nocheck: not typesafe yet }}
<OSS::Attribute::Base @value={{this.formattedPhoneNumber}} data-control-name="attribute-phone-number" ...attributes>
<:label>
<span>{{t "oss-components.attribute.phone_number"}}</span>
Expand Down
20 changes: 15 additions & 5 deletions addon/components/o-s-s/attribute/phone-number.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import Component from '@glimmer/component';
import { type CountryData, countries } from '@upfluence/oss-components/utils/country-codes';

interface OSSAttributePhoneNumberArgs {
countryCode?: string;
prefix?: string;
number?: string;
interface OSSAttributePhoneNumberSignature {
Args: {
countryCode?: string;
prefix?: string;
number?: string;
};
Element: HTMLElement;
}

export default class OSSAttributePhoneNumber extends Component<OSSAttributePhoneNumberArgs> {
export default class OSSAttributePhoneNumberComponent extends Component<OSSAttributePhoneNumberSignature> {
private countryDictionnary: CountryData[] = countries;

get formattedPhoneNumber(): string {
Expand All @@ -22,3 +25,10 @@ export default class OSSAttributePhoneNumber extends Component<OSSAttributePhone
return this.args.prefix ? `${this.args.prefix} ` : '';
}
}

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
'OSS::Attribute::PhoneNumber': typeof OSSAttributePhoneNumberComponent;
'o-s-s/attribute/phone-number': typeof OSSAttributePhoneNumberComponent;
}
}
1 change: 1 addition & 0 deletions addon/components/o-s-s/attribute/rating.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{! @glint-nocheck: not typesafe yet }}
<OSS::Attribute::Base class="oss-attribute--no-hover-effect" data-control-name="attribute-rating" ...attributes>
<:label>
<span>{{@label}}</span>
Expand Down
20 changes: 15 additions & 5 deletions addon/components/o-s-s/attribute/rating.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import { assert } from '@ember/debug';
import Component from '@glimmer/component';

interface OSSAttributeRatingArgs {
label: string;
rating?: number;
interface OSSAttributeRatingSignature {
Args: {
label: string;
rating?: number;
};
Element: HTMLElement;
}

export default class OSSAttributeRating extends Component<OSSAttributeRatingArgs> {
constructor(owner: unknown, args: OSSAttributeRatingArgs) {
export default class OSSAttributeRatingComponent extends Component<OSSAttributeRatingSignature> {
constructor(owner: unknown, args: OSSAttributeRatingSignature['Args']) {
super(owner, args);
assert('[component][OSS::Attribute::Rating] @label is required', typeof args.label === 'string');
}
}

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
'OSS::Attribute::Rating': typeof OSSAttributeRatingComponent;
'o-s-s/attribute/rating': typeof OSSAttributeRatingComponent;
}
}
1 change: 1 addition & 0 deletions addon/components/o-s-s/attribute/removable-text.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{! @glint-nocheck: not typesafe yet }}
<OSS::Attribute::Base @copyable={{false}} data-control-name="attribute-removable-text"
{{on "mouseenter" (fn (mut this.displayRemoveIcon) true)}}
{{on "mouseleave" (fn (mut this.displayRemoveIcon) false)}}
Expand Down
24 changes: 17 additions & 7 deletions addon/components/o-s-s/attribute/removable-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { assert } from '@ember/debug';

interface OSSAttributeRemovableTextArgs {
label: string;
value?: string;
removeTooltip?: string;
onRemove(): Promise<unknown>;
interface OSSAttributeRemovableTextSignature {
Args: {
label: string;
value?: string;
removeTooltip?: string;
onRemove(): Promise<unknown>;
};
Element: HTMLElement;
}

export default class OSSAttributeRemovableText extends Component<OSSAttributeRemovableTextArgs> {
export default class OSSAttributeRemovableTextComponent extends Component<OSSAttributeRemovableTextSignature> {
@service declare intl: any;
@tracked loading: boolean = false;

constructor(owner: unknown, args: OSSAttributeRemovableTextArgs) {
constructor(owner: unknown, args: OSSAttributeRemovableTextSignature['Args']) {
super(owner, args);
assert('[component][OSS::Attribute::RemovableText] @label parameter is required', typeof args.label === 'string');
assert(
Expand All @@ -39,3 +42,10 @@ export default class OSSAttributeRemovableText extends Component<OSSAttributeRem
this.args.onRemove().finally(() => (this.loading = false));
}
}

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
'OSS::Attribute::RemovableText': typeof OSSAttributeRemovableTextComponent;
'o-s-s/attribute/removable-text': typeof OSSAttributeRemovableTextComponent;
}
}
1 change: 1 addition & 0 deletions addon/components/o-s-s/attribute/revealable-email.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{! @glint-nocheck: not typesafe yet }}
<OSS::Attribute::Base @copyable={{false}} data-control-name="attribute-revealable-email"
{{on "mouseenter" (fn (mut this.displayLockIcon) true)}}
{{on "mouseleave" (fn (mut this.displayLockIcon) false)}}
Expand Down
22 changes: 16 additions & 6 deletions addon/components/o-s-s/attribute/revealable-email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { assert } from '@ember/debug';

interface OSSAttributeRevealableEmailArgs {
tooltip?: string;
lockTooltip?: string;
onRevealEmail(): Promise<unknown>;
interface OSSAttributeRevealableEmailSignature {
Args: {
tooltip?: string;
lockTooltip?: string;
onRevealEmail(): Promise<unknown>;
};
Element: HTMLElement;
}

export default class OSSAttributeRevealableEmail extends Component<OSSAttributeRevealableEmailArgs> {
export default class OSSAttributeRevealableEmailComponent extends Component<OSSAttributeRevealableEmailSignature> {
@service declare intl: any;
@tracked loading: boolean = false;

constructor(owner: unknown, args: OSSAttributeRevealableEmailArgs) {
constructor(owner: unknown, args: OSSAttributeRevealableEmailSignature['Args']) {
super(owner, args);
assert(
'[component][OSS::Attribute::RevealableEmail] @onRevealEmail method is required',
Expand All @@ -32,3 +35,10 @@ export default class OSSAttributeRevealableEmail extends Component<OSSAttributeR
this.args.onRevealEmail().finally(() => (this.loading = false));
}
}

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
'OSS::Attribute::RevealableEmail': typeof OSSAttributeRevealableEmailComponent;
'o-s-s/attribute/revealable-email': typeof OSSAttributeRevealableEmailComponent;
}
}
1 change: 1 addition & 0 deletions addon/components/o-s-s/attribute/tag-array.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{! @glint-nocheck: not typesafe yet }}
<OSS::Attribute::Base class="oss-attribute--auto-height oss-attribute--no-hover-effect"
data-control-name="attribute-tag-array" ...attributes>
<:label>
Expand Down
Loading
Loading