mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 22:03:36 +00:00
Fix strict typescript for Component Library stories (#12423)
Fixing some low hanging fruits for moving CL to strict typescript. This primarily removes the types from args since TS infers them differently. We previously needed them since storybook would use any for args but now provides proper typings
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
|
||||||
// @ts-strict-ignore
|
|
||||||
import { Meta, StoryObj } from "@storybook/angular";
|
import { Meta, StoryObj } from "@storybook/angular";
|
||||||
|
|
||||||
import { ButtonComponent } from "./button.component";
|
import { ButtonComponent } from "./button.component";
|
||||||
@@ -107,7 +105,7 @@ export const DisabledWithAttribute: Story = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const Block: Story = {
|
export const Block: Story = {
|
||||||
render: (args: ButtonComponent) => ({
|
render: (args) => ({
|
||||||
props: args,
|
props: args,
|
||||||
template: `
|
template: `
|
||||||
<span class="tw-flex">
|
<span class="tw-flex">
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
|
||||||
// @ts-strict-ignore
|
|
||||||
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from "@angular/forms";
|
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||||
import { NoopAnimationsModule } from "@angular/platform-browser/animations";
|
import { NoopAnimationsModule } from "@angular/platform-browser/animations";
|
||||||
import { Meta, StoryObj, moduleMetadata } from "@storybook/angular";
|
import { Meta, StoryObj, moduleMetadata } from "@storybook/angular";
|
||||||
@@ -78,7 +76,7 @@ export default {
|
|||||||
type Story = StoryObj<DialogComponent & { title: string }>;
|
type Story = StoryObj<DialogComponent & { title: string }>;
|
||||||
|
|
||||||
export const Default: Story = {
|
export const Default: Story = {
|
||||||
render: (args: DialogComponent) => ({
|
render: (args) => ({
|
||||||
props: args,
|
props: args,
|
||||||
template: `
|
template: `
|
||||||
<bit-dialog [dialogSize]="dialogSize" [title]="title" [subtitle]="subtitle" [loading]="loading" [disablePadding]="disablePadding">
|
<bit-dialog [dialogSize]="dialogSize" [title]="title" [subtitle]="subtitle" [loading]="loading" [disablePadding]="disablePadding">
|
||||||
@@ -142,7 +140,7 @@ export const Loading: Story = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const ScrollingContent: Story = {
|
export const ScrollingContent: Story = {
|
||||||
render: (args: DialogComponent) => ({
|
render: (args) => ({
|
||||||
props: args,
|
props: args,
|
||||||
template: `
|
template: `
|
||||||
<bit-dialog title="Scrolling Example" [dialogSize]="dialogSize" [loading]="loading" [disablePadding]="disablePadding">
|
<bit-dialog title="Scrolling Example" [dialogSize]="dialogSize" [loading]="loading" [disablePadding]="disablePadding">
|
||||||
@@ -197,7 +195,7 @@ export const TabContent: Story = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const WithCards: Story = {
|
export const WithCards: Story = {
|
||||||
render: (args: DialogComponent) => ({
|
render: (args) => ({
|
||||||
props: {
|
props: {
|
||||||
formObj: new FormGroup({
|
formObj: new FormGroup({
|
||||||
name: new FormControl(""),
|
name: new FormControl(""),
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
|
||||||
// @ts-strict-ignore
|
|
||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
||||||
import { Meta, StoryObj, applicationConfig, moduleMetadata } from "@storybook/angular";
|
import { Meta, StoryObj, applicationConfig, moduleMetadata } from "@storybook/angular";
|
||||||
@@ -72,7 +70,7 @@ class StoryDialogComponent {
|
|||||||
content: this.i18nService.t("dialogContent"),
|
content: this.i18nService.t("dialogContent"),
|
||||||
type: "primary",
|
type: "primary",
|
||||||
acceptButtonText: "Ok",
|
acceptButtonText: "Ok",
|
||||||
cancelButtonText: null,
|
cancelButtonText: undefined,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: this.i18nService.t("primaryTypeSimpleDialog"),
|
title: this.i18nService.t("primaryTypeSimpleDialog"),
|
||||||
@@ -123,7 +121,7 @@ class StoryDialogComponent {
|
|||||||
|
|
||||||
showCallout = false;
|
showCallout = false;
|
||||||
calloutType = "info";
|
calloutType = "info";
|
||||||
dialogCloseResult: boolean;
|
dialogCloseResult?: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public dialogService: DialogService,
|
public dialogService: DialogService,
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
|
||||||
// @ts-strict-ignore
|
|
||||||
import { FormsModule, ReactiveFormsModule, FormBuilder } from "@angular/forms";
|
import { FormsModule, ReactiveFormsModule, FormBuilder } from "@angular/forms";
|
||||||
import { StoryObj, Meta, moduleMetadata } from "@storybook/angular";
|
import { StoryObj, Meta, moduleMetadata } from "@storybook/angular";
|
||||||
|
|
||||||
@@ -51,7 +49,7 @@ const template = `
|
|||||||
</form>`;
|
</form>`;
|
||||||
|
|
||||||
export const ForbiddenCharacters: StoryObj<BitFormFieldComponent> = {
|
export const ForbiddenCharacters: StoryObj<BitFormFieldComponent> = {
|
||||||
render: (args: BitFormFieldComponent) => ({
|
render: (args) => ({
|
||||||
props: {
|
props: {
|
||||||
formObj: new FormBuilder().group({
|
formObj: new FormBuilder().group({
|
||||||
name: ["", forbiddenCharacters(["\\", "/", "@", "#", "$", "%", "^", "&", "*", "(", ")"])],
|
name: ["", forbiddenCharacters(["\\", "/", "@", "#", "$", "%", "^", "&", "*", "(", ")"])],
|
||||||
@@ -62,7 +60,7 @@ export const ForbiddenCharacters: StoryObj<BitFormFieldComponent> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const TrimValidator: StoryObj<BitFormFieldComponent> = {
|
export const TrimValidator: StoryObj<BitFormFieldComponent> = {
|
||||||
render: (args: BitFormFieldComponent) => ({
|
render: (args) => ({
|
||||||
props: {
|
props: {
|
||||||
formObj: new FormBuilder().group({
|
formObj: new FormBuilder().group({
|
||||||
name: [
|
name: [
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
|
||||||
// @ts-strict-ignore
|
|
||||||
import { TextFieldModule } from "@angular/cdk/text-field";
|
import { TextFieldModule } from "@angular/cdk/text-field";
|
||||||
import {
|
import {
|
||||||
AbstractControl,
|
AbstractControl,
|
||||||
@@ -200,7 +198,7 @@ export const Required: Story = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const Hint: Story = {
|
export const Hint: Story = {
|
||||||
render: (args: BitFormFieldComponent) => ({
|
render: (args) => ({
|
||||||
props: {
|
props: {
|
||||||
formObj: formObj,
|
formObj: formObj,
|
||||||
...args,
|
...args,
|
||||||
@@ -361,7 +359,7 @@ export const PartiallyDisabledButtonInputGroup: Story = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const Select: Story = {
|
export const Select: Story = {
|
||||||
render: (args: BitFormFieldComponent) => ({
|
render: (args) => ({
|
||||||
props: args,
|
props: args,
|
||||||
template: /*html*/ `
|
template: /*html*/ `
|
||||||
<bit-form-field>
|
<bit-form-field>
|
||||||
@@ -377,7 +375,7 @@ export const Select: Story = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const AdvancedSelect: Story = {
|
export const AdvancedSelect: Story = {
|
||||||
render: (args: BitFormFieldComponent) => ({
|
render: (args) => ({
|
||||||
props: args,
|
props: args,
|
||||||
template: /*html*/ `
|
template: /*html*/ `
|
||||||
<bit-form-field>
|
<bit-form-field>
|
||||||
@@ -422,7 +420,7 @@ export const FileInput: Story = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const Textarea: Story = {
|
export const Textarea: Story = {
|
||||||
render: (args: BitFormFieldComponent) => ({
|
render: (args) => ({
|
||||||
props: args,
|
props: args,
|
||||||
template: /*html*/ `
|
template: /*html*/ `
|
||||||
<bit-form-field>
|
<bit-form-field>
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
|
||||||
// @ts-strict-ignore
|
|
||||||
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||||
import { Meta, StoryObj, moduleMetadata } from "@storybook/angular";
|
import { Meta, StoryObj, moduleMetadata } from "@storybook/angular";
|
||||||
|
|
||||||
@@ -34,7 +32,7 @@ export default {
|
|||||||
type Story = StoryObj<SearchComponent>;
|
type Story = StoryObj<SearchComponent>;
|
||||||
|
|
||||||
export const Default: Story = {
|
export const Default: Story = {
|
||||||
render: (args: SearchComponent) => ({
|
render: (args) => ({
|
||||||
props: args,
|
props: args,
|
||||||
template: `
|
template: `
|
||||||
<bit-search [(ngModel)]="searchText" [placeholder]="placeholder" [disabled]="disabled"></bit-search>
|
<bit-search [(ngModel)]="searchText" [placeholder]="placeholder" [disabled]="disabled"></bit-search>
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
|
||||||
// @ts-strict-ignore
|
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, Input } from "@angular/core";
|
import { Component, Input } from "@angular/core";
|
||||||
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
||||||
@@ -24,7 +22,7 @@ const toastServiceExampleTemplate = `
|
|||||||
})
|
})
|
||||||
export class ToastServiceExampleComponent {
|
export class ToastServiceExampleComponent {
|
||||||
@Input()
|
@Input()
|
||||||
toastOptions: ToastOptions;
|
toastOptions?: ToastOptions;
|
||||||
|
|
||||||
constructor(protected toastService: ToastService) {}
|
constructor(protected toastService: ToastService) {}
|
||||||
}
|
}
|
||||||
@@ -40,7 +38,7 @@ export default {
|
|||||||
}),
|
}),
|
||||||
applicationConfig({
|
applicationConfig({
|
||||||
providers: [
|
providers: [
|
||||||
ToastModule.forRoot().providers,
|
ToastModule.forRoot().providers!,
|
||||||
{
|
{
|
||||||
provide: I18nService,
|
provide: I18nService,
|
||||||
useFactory: () => {
|
useFactory: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user