Skip to content

Commit

Permalink
forgot some type
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauryD committed Nov 12, 2023
1 parent 0cf228d commit 8ae0e4d
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 52 deletions.
60 changes: 30 additions & 30 deletions app/components/inputs/file.gts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import TpkFile from "@triptyk/ember-input/components/tpk-file";
import InputsFileInputLayout from "ember-boilerplate/components/inputs/file/input-layout";
import TpkFile from '@triptyk/ember-input/components/tpk-file';
import InputsFileInputLayout from 'ember-boilerplate/components/inputs/file/input-layout';

import type { TOC } from "@ember/component/template-only";
import type { TOC } from '@ember/component/template-only';

export interface InputsFileSignature {
Args: {
Expand All @@ -16,36 +16,36 @@ export interface InputsFileSignature {
Element: HTMLDivElement;
Blocks: {
default: [];
}
};
}

const InputsFile: TOC<InputsFileSignature> = <template>
<TpkFile
@label={{@label}}
@accept={{@accept}}
@onChange={{@onChange}}
@multiple={{@multiple}}
class={{if @disabled "disabled"}}
...attributes
as |TI|
>
<div>
<TI.Label>
{{@label}}
</TI.Label>
{{#unless @disabled}}
{{!-- @glint-expect-error --}}
<InputsFileInputLayout>
<TI.Input
placeholder={{@placeholder}}
disabled={{@disabled}}
class="{{@inputClass}}
absolute opacity-0 w-full left-0 top-0 h-full hover:cursor-pointer hover:underline"
/>
</InputsFileInputLayout>
{{/unless}}
</div>
</TpkFile>
</template>
@label={{@label}}
@accept={{@accept}}
@onChange={{@onChange}}
@multiple={{@multiple}}
class={{if @disabled "disabled"}}
...attributes
as |TI|
>
<div>
<TI.Label>
{{@label}}
</TI.Label>
{{#unless @disabled}}
{{! @glint-expect-error }}
<InputsFileInputLayout>
<TI.Input
placeholder={{@placeholder}}
disabled={{@disabled}}
class="{{@inputClass}}
absolute opacity-0 w-full left-0 top-0 h-full hover:cursor-pointer hover:underline"
/>
</InputsFileInputLayout>
{{/unless}}
</div>
</TpkFile>
</template>;

export default InputsFile;
18 changes: 13 additions & 5 deletions tests/integration/components/login/forms/login-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable qunit/require-expect */
import { render } from '@ember/test-helpers';
import { render, type TestContext } from '@ember/test-helpers';
import click from '@ember/test-helpers/dom/click';
import { hbs } from 'ember-cli-htmlbars';
import { module, test } from 'qunit';
Expand All @@ -11,6 +11,14 @@ import { type Changeset,ImmerChangeset } from 'ember-immer-changeset';

import { setupIntl } from 'ember-intl/test-support';

import type { LoginChangeset } from 'ember-boilerplate/changesets/login';

interface LoginTestContext extends TestContext {
changeset: LoginChangeset;
saveFunction: (changeset: Changeset) => void;
validationSchema: typeof loginSchema;
}

module('Integration | Component | FormsLogin', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks, ['fr-fr']);
Expand All @@ -24,8 +32,8 @@ module('Integration | Component | FormsLogin', function (hooks) {
assert.strictEqual(changeset.get('password'), 'edited');
});

await render(
hbs`{{! @glint-nocheck }}<Forms::Login @validationSchema={{this.validationSchema}} @changeset={{this.changeset}} @saveFunction={{this.saveFunction}} />`,
await render<LoginTestContext>(
hbs`<Forms::Login @validationSchema={{this.validationSchema}} @changeset={{this.changeset}} @saveFunction={{this.saveFunction}} />`,
);

assert.dom('[data-test-input="email"] input').hasValue('');
Expand Down Expand Up @@ -53,8 +61,8 @@ module('Integration | Component | FormsLogin', function (hooks) {
assert.step('saveFunction');
});

await render(
hbs`{{! @glint-nocheck }}<Forms::Login @validationSchema={{this.validationSchema}} @saveFunction={{this.saveFunction}} @changeset={{this.changeset}}/>`,
await render<LoginTestContext>(
hbs`<Forms::Login @validationSchema={{this.validationSchema}} @saveFunction={{this.saveFunction}} @changeset={{this.changeset}}/>`,
);

assert.dom('[data-test-input="email"] input').hasValue('hello');
Expand Down
37 changes: 35 additions & 2 deletions tests/integration/components/yeti-table/pagination/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,45 @@ import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';

export interface YetiTablePaginationSignature {
Args: {
theme: {
pagination: {
controls: string;
previous: string;
next: string;
info: string;
pageSize: string;
};
},
customClass?: string;
disabled: boolean;
paginationData: {
isFirstPage: boolean;
isLastPage: boolean;
totalRows: number;
nextPage: number;
pageSize: number;
pageEnd: number;
pageStart: number;
},
paginationActions: {
previousPage: () => void;
changePageSize: (value: string) => void;
nextPage: () => void;
}
},
Blocks: {
default: []
},
Element: HTMLDivElement;
}

/**
* GLIMMERIZED PAGINATION COMPONENT
* DO NOT MODIFY
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
class Pagination extends Component<any> {
class Pagination extends Component<YetiTablePaginationSignature> {
/**
* Array of page sizes to populate the page size `<select>`.
* Particularly useful with an array helper, e.g `@pageSize={{array 10 12 23 50 100}}`
Expand Down
19 changes: 4 additions & 15 deletions tests/integration/components/yeti-table/pagination/template.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{! @glint-nocheck: not typesafe yet }}
{{! template-lint-disable no-inline-styles }}
{{! template-lint-disable template-length }}
<div
Expand All @@ -11,8 +10,7 @@
{{! template-lint-disable no-bare-strings }}
<button
type="button"
class="{{@theme.pagination.previous}}
yeti-table-pagination-controls-previous"
class="{{@theme.pagination.previous}} yeti-table-pagination-controls-previous"
disabled={{this.shouldDisablePrevious}}
title={{t "global.previous"}}
{{on "click" @paginationActions.previousPage}}
Expand All @@ -37,29 +35,20 @@
</div>
{{/if}}
<div>
<div
class="{{@theme.pagination.info}}
yeti-table-pagination-controls-page-info"
>
<div class="{{@theme.pagination.info}} yeti-table-pagination-controls-page-info">
{{@paginationData.pageStart}}
-
{{@paginationData.pageEnd}}
{{t "global.table.on"}}
{{@paginationData.totalRows}}
{{t "global.table.results"}}
</div>
<div
class="{{@theme.pagination.pageSize}}
yeti-table-pagination-controls-page-size"
>
<div class="{{@theme.pagination.pageSize}} yeti-table-pagination-controls-page-size">
{{t "global.table.resultsByPage"}}:
{{! template-lint-disable require-input-label }}
<select disabled={{@disabled}} {{on "change" this.changePageSize}}>
{{#each this.pageSizes as |pageSize|}}
<option
value={{pageSize}}
selected={{eq @paginationData.pageSize pageSize}}
>
<option value={{pageSize}} selected={{eq @paginationData.pageSize pageSize}}>
{{pageSize}}
</option>
{{/each}}
Expand Down
5 changes: 5 additions & 0 deletions types/template-registry.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ import '@glint/environment-template-components';
import type RenderModifiersRegistry from '@ember/render-modifiers/template-registry';
import type EmberInputRegistry from '@triptyk/ember-input/template-registry';
import type EmberInputValidationRegistry from '@triptyk/ember-input-validation/template-registry';
import type FormsLogin from 'ember-boilerplate/components/forms/login';
import type FormsRegister from 'ember-boilerplate/components/forms/register';
import type EmberIntlRegistry from 'ember-intl/template-registry';
import type EmberTruthHelpersRegistry from 'ember-truth-helpers/template-registry';

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry
extends RenderModifiersRegistry,
EmberInputRegistry,
EmberInputValidationRegistry,
EmberTruthHelpersRegistry,
EmberIntlRegistry {
// Used for tests only
FormsRegister: typeof FormsRegister;
'Forms::Register': typeof FormsRegister;
FormsLogin: typeof FormsLogin;
'Forms::Login': typeof FormsLogin;
}
}

0 comments on commit 8ae0e4d

Please sign in to comment.