@storybook/angular 7.3.2 → 7.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +18 -17
- package/src/server/angular-cli-webpack.d.ts +0 -7
- package/src/server/angular-cli-webpack.js +0 -127
- package/src/server/plugins/storybook-normalize-angular-entry-plugin.js +0 -54
- package/src/typings.d.ts +0 -21
- package/template/components/button.component.ts +0 -54
- package/template/components/button.css +0 -30
- package/template/components/form.component.ts +0 -37
- package/template/components/html.component.ts +0 -22
- package/template/components/pre.component.ts +0 -29
- package/template/stories/angular-mdx.stories.mdx +0 -25
- package/template/stories/argTypes/doc-button/doc-button.component.html +0 -7
- package/template/stories/argTypes/doc-button/doc-button.component.scss +0 -3
- package/template/stories/argTypes/doc-button/doc-button.component.ts +0 -232
- package/template/stories/argTypes/doc-button/doc-button.stories.ts +0 -24
- package/template/stories/argTypes/doc-directive/doc-directive.directive.ts +0 -24
- package/template/stories/argTypes/doc-directive/doc-directive.stories.ts +0 -14
- package/template/stories/argTypes/doc-injectable/doc-injectable.service.ts +0 -27
- package/template/stories/argTypes/doc-injectable/doc-injectable.stories.ts +0 -14
- package/template/stories/argTypes/doc-pipe/doc-pipe.pipe.ts +0 -18
- package/template/stories/argTypes/doc-pipe/doc-pipe.stories.ts +0 -14
- package/template/stories/basics/README.stories.mdx +0 -7
- package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva-component.stories.ts +0 -27
- package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva.component.ts +0 -57
- package/template/stories/basics/component-with-complex-selectors/attribute-selector.component.ts +0 -19
- package/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts +0 -8
- package/template/stories/basics/component-with-complex-selectors/class-selector.component.stories.ts +0 -8
- package/template/stories/basics/component-with-complex-selectors/class-selector.component.ts +0 -19
- package/template/stories/basics/component-with-complex-selectors/multiple-class-selector.component.stories.ts +0 -8
- package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.stories.ts +0 -8
- package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.ts +0 -37
- package/template/stories/basics/component-with-enums/enums.component.html +0 -8
- package/template/stories/basics/component-with-enums/enums.component.stories.ts +0 -24
- package/template/stories/basics/component-with-enums/enums.component.ts +0 -53
- package/template/stories/basics/component-with-inheritance/base-button.component.ts +0 -10
- package/template/stories/basics/component-with-inheritance/base-button.stories.ts +0 -12
- package/template/stories/basics/component-with-inheritance/icon-button.component.ts +0 -11
- package/template/stories/basics/component-with-inheritance/icon-button.stories.ts +0 -13
- package/template/stories/basics/component-with-ng-content/ng-content-about-parent.stories.ts +0 -58
- package/template/stories/basics/component-with-ng-content/ng-content-simple.stories.ts +0 -29
- package/template/stories/basics/component-with-ng-on-destroy/component-with-on-destroy.stories.ts +0 -40
- package/template/stories/basics/component-with-on-push/on-push-box.component.ts +0 -21
- package/template/stories/basics/component-with-on-push/on-push.stories.ts +0 -21
- package/template/stories/basics/component-with-pipe/custom-pipes.stories.ts +0 -31
- package/template/stories/basics/component-with-pipe/custom.pipe.ts +0 -10
- package/template/stories/basics/component-with-pipe/with-pipe.component.ts +0 -10
- package/template/stories/basics/component-with-provider/di.component.html +0 -7
- package/template/stories/basics/component-with-provider/di.component.stories.ts +0 -26
- package/template/stories/basics/component-with-provider/di.component.ts +0 -28
- package/template/stories/basics/component-with-style/styled.component.css +0 -3
- package/template/stories/basics/component-with-style/styled.component.html +0 -5
- package/template/stories/basics/component-with-style/styled.component.scss +0 -5
- package/template/stories/basics/component-with-style/styled.component.stories.ts +0 -10
- package/template/stories/basics/component-with-style/styled.component.ts +0 -8
- package/template/stories/basics/component-without-selector/without-selector-ng-component-outlet.stories.ts +0 -73
- package/template/stories/basics/component-without-selector/without-selector-ng-factory-resolver.stories.ts +0 -71
- package/template/stories/basics/component-without-selector/without-selector.component.ts +0 -30
- package/template/stories/basics/component-without-selector/without-selector.stories.ts +0 -30
- package/template/stories/basics/ng-module/angular-src/chip-color.token.ts +0 -3
- package/template/stories/basics/ng-module/angular-src/chip-text.pipe.ts +0 -29
- package/template/stories/basics/ng-module/angular-src/chip.component.ts +0 -60
- package/template/stories/basics/ng-module/angular-src/chips-group.component.ts +0 -49
- package/template/stories/basics/ng-module/angular-src/chips.module.ts +0 -31
- package/template/stories/basics/ng-module/import-module-chip.stories.ts +0 -23
- package/template/stories/basics/ng-module/import-module-for-root.stories.ts +0 -50
- package/template/stories/basics/ng-module/import-module.stories.ts +0 -35
- package/template/stories/button.component.ts +0 -26
- package/template/stories/core/README.stories.mdx +0 -7
- package/template/stories/core/applicationConfig/with-browser-animations.stories.ts +0 -40
- package/template/stories/core/applicationConfig/with-noop-browser-animations.stories.ts +0 -35
- package/template/stories/core/decorators/componentWrapperDecorator/child.component.ts +0 -20
- package/template/stories/core/decorators/componentWrapperDecorator/decorators.stories.ts +0 -99
- package/template/stories/core/decorators/componentWrapperDecorator/parent.component.ts +0 -18
- package/template/stories/core/decorators/theme-decorator/decorators.stories.ts +0 -20
- package/template/stories/core/moduleMetadata/angular-src/custom.pipe.ts +0 -10
- package/template/stories/core/moduleMetadata/angular-src/dummy.service.ts +0 -14
- package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.css +0 -13
- package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.html +0 -7
- package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.ts +0 -39
- package/template/stories/core/moduleMetadata/angular-src/service.component.ts +0 -24
- package/template/stories/core/moduleMetadata/angular-src/token.component.ts +0 -31
- package/template/stories/core/moduleMetadata/in-export-default.stories.ts +0 -38
- package/template/stories/core/moduleMetadata/in-stories.stories.ts +0 -46
- package/template/stories/core/moduleMetadata/merge-default-and-story.stories.ts +0 -35
- package/template/stories/core/parameters/bootstrap-options.stories.ts +0 -18
- package/template/stories/core/styles/story-styles.stories.ts +0 -50
- package/template/stories/others/app-initializer-use-factory/app-initializer-use-factory.stories.ts +0 -34
- package/template/stories/others/issues/12009-unknown-component.stories.ts +0 -14
- package/template/stories/others/ngx-translate/README.stories.mdx +0 -65
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
/* eslint-disable no-underscore-dangle */
|
|
3
|
-
import {
|
|
4
|
-
Component,
|
|
5
|
-
EventEmitter,
|
|
6
|
-
HostBinding,
|
|
7
|
-
HostListener,
|
|
8
|
-
Input,
|
|
9
|
-
Output,
|
|
10
|
-
ViewChild,
|
|
11
|
-
ElementRef,
|
|
12
|
-
} from '@angular/core';
|
|
13
|
-
|
|
14
|
-
export const exportedConstant = 'An exported constant';
|
|
15
|
-
|
|
16
|
-
export type ButtonSize = 'small' | 'medium' | 'large' | 'xlarge';
|
|
17
|
-
|
|
18
|
-
export interface ISomeInterface {
|
|
19
|
-
one: string;
|
|
20
|
-
two: boolean;
|
|
21
|
-
three: any[];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export enum ButtonAccent {
|
|
25
|
-
'Normal' = 'Normal',
|
|
26
|
-
'High' = 'High',
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* This is a simple button that demonstrates various JSDoc handling in Storybook Docs for Angular.
|
|
31
|
-
*
|
|
32
|
-
* It supports [markdown](https://en.wikipedia.org/wiki/Markdown), so you can embed formatted text,
|
|
33
|
-
* like **bold**, _italic_, and `inline code`.
|
|
34
|
-
*
|
|
35
|
-
* > How you like dem apples?! It's never been easier to document all your components.
|
|
36
|
-
*
|
|
37
|
-
* @string Hello world
|
|
38
|
-
* @link [Example](http://example.com)
|
|
39
|
-
* @code `ThingThing`
|
|
40
|
-
* @html <span class="badge">aaa</span>
|
|
41
|
-
*/
|
|
42
|
-
@Component({
|
|
43
|
-
selector: 'my-button',
|
|
44
|
-
templateUrl: './doc-button.component.html',
|
|
45
|
-
styleUrls: ['./doc-button.component.scss'],
|
|
46
|
-
})
|
|
47
|
-
export class DocButtonComponent<T> {
|
|
48
|
-
@ViewChild('buttonRef', { static: false }) buttonRef!: ElementRef;
|
|
49
|
-
|
|
50
|
-
/** Test default value. */
|
|
51
|
-
@Input()
|
|
52
|
-
public theDefaultValue = 'Default value in component';
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Setting default value here because compodoc won't get the default value for accessors
|
|
56
|
-
* @default Another default value
|
|
57
|
-
* */
|
|
58
|
-
@Input()
|
|
59
|
-
get anotherDefaultValue() {
|
|
60
|
-
return this._anotherDefaultValue;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
set anotherDefaultValue(v: string) {
|
|
64
|
-
this._anotherDefaultValue = v;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
_anotherDefaultValue = 'Another default value';
|
|
68
|
-
|
|
69
|
-
/** Test null default value. */
|
|
70
|
-
@Input()
|
|
71
|
-
public aNullValue: string | null = null;
|
|
72
|
-
|
|
73
|
-
/** Test null default value. */
|
|
74
|
-
@Input()
|
|
75
|
-
public anUndefinedValue: undefined;
|
|
76
|
-
|
|
77
|
-
/** Test numeric default value. */
|
|
78
|
-
@Input()
|
|
79
|
-
public aNumericValue = 123;
|
|
80
|
-
|
|
81
|
-
/** Appearance style of the button. */
|
|
82
|
-
@Input()
|
|
83
|
-
public appearance: 'primary' | 'secondary' = 'secondary';
|
|
84
|
-
|
|
85
|
-
/** Sets the button to a disabled state. */
|
|
86
|
-
@Input()
|
|
87
|
-
public isDisabled = false;
|
|
88
|
-
|
|
89
|
-
/** Specify the accent-type of the button */
|
|
90
|
-
@Input()
|
|
91
|
-
public accent: ButtonAccent = ButtonAccent.Normal;
|
|
92
|
-
|
|
93
|
-
/** Specifies some arbitrary object. This comment is to test certain chars like apostrophes - it's working */
|
|
94
|
-
@Input() public someDataObject!: ISomeInterface;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* The inner text of the button.
|
|
98
|
-
*
|
|
99
|
-
* @required
|
|
100
|
-
*/
|
|
101
|
-
@Input()
|
|
102
|
-
public label!: string;
|
|
103
|
-
|
|
104
|
-
/** Size of the button. */
|
|
105
|
-
@Input()
|
|
106
|
-
public size?: ButtonSize = 'medium';
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Some input you shouldn't use.
|
|
110
|
-
*
|
|
111
|
-
* @deprecated
|
|
112
|
-
*/
|
|
113
|
-
@Input()
|
|
114
|
-
public somethingYouShouldNotUse = false;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Handler to be called when the button is clicked by a user.
|
|
118
|
-
*
|
|
119
|
-
* Will also block the emission of the event if `isDisabled` is true.
|
|
120
|
-
*/
|
|
121
|
-
@Output()
|
|
122
|
-
public onClick = new EventEmitter<Event>();
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* This is an internal method that we don't want to document and have added the `ignore` annotation to.
|
|
126
|
-
*
|
|
127
|
-
* @ignore
|
|
128
|
-
*/
|
|
129
|
-
public handleClick(event: Event) {
|
|
130
|
-
event.stopPropagation();
|
|
131
|
-
|
|
132
|
-
if (!this.isDisabled) {
|
|
133
|
-
this.onClick.emit(event);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
private _inputValue = 'some value';
|
|
138
|
-
|
|
139
|
-
/** Setter for `inputValue` that is also an `@Input`. */
|
|
140
|
-
@Input()
|
|
141
|
-
public set inputValue(value: string) {
|
|
142
|
-
this._inputValue = value;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/** Getter for `inputValue`. */
|
|
146
|
-
public get inputValue() {
|
|
147
|
-
return this._inputValue;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
@HostListener('click', ['$event'])
|
|
151
|
-
onClickListener(event: Event) {
|
|
152
|
-
console.log('button', event.target);
|
|
153
|
-
this.handleClick(event);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
@HostBinding('class.focused') focus = false;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Returns all the CSS classes for the button.
|
|
160
|
-
*
|
|
161
|
-
* @ignore
|
|
162
|
-
*/
|
|
163
|
-
public get classes(): string[] {
|
|
164
|
-
return [this.appearance, this.size]
|
|
165
|
-
.filter((_class) => !!_class)
|
|
166
|
-
.map((_class) => `btn-${_class}`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* @ignore
|
|
171
|
-
*/
|
|
172
|
-
public ignoredProperty = 'Ignore me';
|
|
173
|
-
|
|
174
|
-
/** Public value. */
|
|
175
|
-
public internalProperty = 'Public hello';
|
|
176
|
-
|
|
177
|
-
/** Private value. */
|
|
178
|
-
private _value = 'Private hello';
|
|
179
|
-
|
|
180
|
-
/** Set the private value. */
|
|
181
|
-
public set value(value: string | number) {
|
|
182
|
-
this._value = `${value}`;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/** Get the private value. */
|
|
186
|
-
public get value(): string | number {
|
|
187
|
-
return this._value;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* An internal calculation method which adds `x` and `y` together.
|
|
192
|
-
*
|
|
193
|
-
* @param x Some number you'd like to use.
|
|
194
|
-
* @param y Some other number or string you'd like to use, will have `parseInt()` applied before calculation.
|
|
195
|
-
*/
|
|
196
|
-
public calc(x: number, y: string | number): number {
|
|
197
|
-
return x + parseInt(`${y}`, 10);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/** A public method using an interface. */
|
|
201
|
-
public publicMethod(things: ISomeInterface) {
|
|
202
|
-
console.log(things);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* A protected method.
|
|
207
|
-
*
|
|
208
|
-
* @param id Some `id`.
|
|
209
|
-
*/
|
|
210
|
-
protected protectedMethod(id?: number) {
|
|
211
|
-
console.log(id);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* A private method.
|
|
216
|
-
*
|
|
217
|
-
* @param password Some `password`.
|
|
218
|
-
*/
|
|
219
|
-
private privateMethod(password: string) {
|
|
220
|
-
console.log(password);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
@Input('showKeyAlias')
|
|
224
|
-
public showKey!: keyof T;
|
|
225
|
-
|
|
226
|
-
@Input()
|
|
227
|
-
public set item(item: T[]) {
|
|
228
|
-
this.processedItem = item;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
public processedItem!: T[];
|
|
232
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Args } from '@storybook/angular';
|
|
2
|
-
import { DocButtonComponent } from './doc-button.component';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
component: DocButtonComponent,
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const Basic = (args: Args) => ({
|
|
9
|
-
props: args,
|
|
10
|
-
});
|
|
11
|
-
Basic.args = { label: 'Args test', isDisabled: false };
|
|
12
|
-
Basic.ArgTypes = {
|
|
13
|
-
theDefaultValue: {
|
|
14
|
-
table: {
|
|
15
|
-
defaultValue: { summary: 'Basic default value' },
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const WithTemplate = (args: Args) => ({
|
|
21
|
-
props: args,
|
|
22
|
-
template: '<my-button [label]="label" [appearance]="appearance"></my-button>',
|
|
23
|
-
});
|
|
24
|
-
WithTemplate.args = { label: 'Template test', appearance: 'primary' };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ElementRef, AfterViewInit, Directive, Input } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This is an Angular Directive
|
|
5
|
-
* example that has a Prop Table.
|
|
6
|
-
*/
|
|
7
|
-
@Directive({
|
|
8
|
-
selector: '[docDirective]',
|
|
9
|
-
})
|
|
10
|
-
export class DocDirective implements AfterViewInit {
|
|
11
|
-
constructor(private ref: ElementRef) {}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Will apply gray background color
|
|
15
|
-
* if set to true.
|
|
16
|
-
*/
|
|
17
|
-
@Input() hasGrayBackground = false;
|
|
18
|
-
|
|
19
|
-
ngAfterViewInit(): void {
|
|
20
|
-
if (this.hasGrayBackground) {
|
|
21
|
-
this.ref.nativeElement.style = 'background-color: lightgray';
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DocDirective } from './doc-directive.directive';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
component: DocDirective,
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const modules = {
|
|
8
|
-
declarations: [DocDirective],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const Basic = () => ({
|
|
12
|
-
moduleMetadata: modules,
|
|
13
|
-
template: '<div docDirective [hasGrayBackground]="true"><h1>DocDirective</h1></div>',
|
|
14
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { HttpHeaders } from '@angular/common/http';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This is an Angular Injectable
|
|
6
|
-
* example that has a Prop Table.
|
|
7
|
-
*/
|
|
8
|
-
@Injectable({
|
|
9
|
-
providedIn: 'root',
|
|
10
|
-
})
|
|
11
|
-
export class DocInjectableService {
|
|
12
|
-
/**
|
|
13
|
-
* Auth headers to use.
|
|
14
|
-
*/
|
|
15
|
-
auth: any;
|
|
16
|
-
|
|
17
|
-
constructor() {
|
|
18
|
-
this.auth = new HttpHeaders({ 'Content-Type': 'application/json' });
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Get posts from Backend.
|
|
23
|
-
*/
|
|
24
|
-
getPosts(): unknown[] {
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DocInjectableService } from './doc-injectable.service';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
component: DocInjectableService,
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const modules = {
|
|
8
|
-
provider: [DocInjectableService],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const Basic = () => ({
|
|
12
|
-
moduleMetadata: modules,
|
|
13
|
-
template: '<div><h1>DocInjectable</h1></div>',
|
|
14
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PipeTransform, Pipe } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This is an Angular Pipe
|
|
5
|
-
* example that has a Prop Table.
|
|
6
|
-
*/
|
|
7
|
-
@Pipe({
|
|
8
|
-
name: 'docPipe',
|
|
9
|
-
})
|
|
10
|
-
export class DocPipe implements PipeTransform {
|
|
11
|
-
/**
|
|
12
|
-
* Transforms a string into uppercase.
|
|
13
|
-
* @param value string
|
|
14
|
-
*/
|
|
15
|
-
transform(value: string): string {
|
|
16
|
-
return value?.toUpperCase();
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DocPipe } from './doc-pipe.pipe';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
component: DocPipe,
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const modules = {
|
|
8
|
-
declarations: [DocPipe],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const Basic = () => ({
|
|
12
|
-
moduleMetadata: modules,
|
|
13
|
-
template: `<div><h1>{{ 'DocPipe' | docPipe }}</h1></div>`,
|
|
14
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { FormsModule } from '@angular/forms';
|
|
2
|
-
import { Meta, StoryFn, moduleMetadata } from '@storybook/angular';
|
|
3
|
-
import { CustomCvaComponent } from './custom-cva.component';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
// title: 'Basics / Angular forms / ControlValueAccessor',
|
|
7
|
-
component: CustomCvaComponent,
|
|
8
|
-
decorators: [
|
|
9
|
-
moduleMetadata({
|
|
10
|
-
imports: [FormsModule],
|
|
11
|
-
}),
|
|
12
|
-
(storyFn) => {
|
|
13
|
-
const story = storyFn();
|
|
14
|
-
console.log(story);
|
|
15
|
-
return story;
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
} as Meta;
|
|
19
|
-
|
|
20
|
-
export const SimpleInput: StoryFn = () => ({
|
|
21
|
-
props: {
|
|
22
|
-
ngModel: 'Type anything',
|
|
23
|
-
ngModelChange: () => {},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
SimpleInput.storyName = 'Simple input';
|
package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva.component.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Component, forwardRef } from '@angular/core';
|
|
2
|
-
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
|
-
|
|
4
|
-
const NOOP = () => {};
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'storybook-custom-cva-component',
|
|
8
|
-
template: `
|
|
9
|
-
<div>{{ value }}</div>
|
|
10
|
-
<input type="text" [(ngModel)]="value" />
|
|
11
|
-
`,
|
|
12
|
-
providers: [
|
|
13
|
-
{
|
|
14
|
-
provide: NG_VALUE_ACCESSOR,
|
|
15
|
-
useExisting: forwardRef(() => CustomCvaComponent),
|
|
16
|
-
multi: true,
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
})
|
|
20
|
-
export class CustomCvaComponent implements ControlValueAccessor {
|
|
21
|
-
disabled?: boolean;
|
|
22
|
-
|
|
23
|
-
protected onChange: (value: any) => void = NOOP;
|
|
24
|
-
|
|
25
|
-
protected onTouch: () => void = NOOP;
|
|
26
|
-
|
|
27
|
-
protected internalValue: any;
|
|
28
|
-
|
|
29
|
-
get value(): any {
|
|
30
|
-
return this.internalValue;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
set value(value: any) {
|
|
34
|
-
if (value !== this.internalValue) {
|
|
35
|
-
this.internalValue = value;
|
|
36
|
-
this.onChange(value);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
writeValue(value: any): void {
|
|
41
|
-
if (value !== this.internalValue) {
|
|
42
|
-
this.internalValue = value;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
registerOnChange(fn: any): void {
|
|
47
|
-
this.onChange = fn;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
registerOnTouched(fn: any): void {
|
|
51
|
-
this.onTouch = fn;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
setDisabledState(isDisabled: boolean): void {
|
|
55
|
-
this.disabled = isDisabled;
|
|
56
|
-
}
|
|
57
|
-
}
|
package/template/stories/basics/component-with-complex-selectors/attribute-selector.component.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ComponentFactoryResolver, ElementRef, Component } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Component({
|
|
4
|
-
selector: 'storybook-attribute-selector[foo=bar]',
|
|
5
|
-
template: `<h3>Attribute selector</h3>
|
|
6
|
-
Selector: {{ selectors }} <br />
|
|
7
|
-
Generated template: {{ generatedTemplate }}`,
|
|
8
|
-
})
|
|
9
|
-
export class AttributeSelectorComponent {
|
|
10
|
-
generatedTemplate!: string;
|
|
11
|
-
|
|
12
|
-
selectors!: string;
|
|
13
|
-
|
|
14
|
-
constructor(public el: ElementRef, private resolver: ComponentFactoryResolver) {
|
|
15
|
-
const factory = this.resolver.resolveComponentFactory(AttributeSelectorComponent);
|
|
16
|
-
this.selectors = factory.selector;
|
|
17
|
-
this.generatedTemplate = el.nativeElement.outerHTML;
|
|
18
|
-
}
|
|
19
|
-
}
|
package/template/stories/basics/component-with-complex-selectors/class-selector.component.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ComponentFactoryResolver, ElementRef, Component } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Component({
|
|
4
|
-
selector: 'storybook-class-selector.foo, storybook-class-selector.bar',
|
|
5
|
-
template: `<h3>Class selector</h3>
|
|
6
|
-
Selector: {{ selectors }} <br />
|
|
7
|
-
Generated template: {{ generatedTemplate }}`,
|
|
8
|
-
})
|
|
9
|
-
export class ClassSelectorComponent {
|
|
10
|
-
generatedTemplate!: string;
|
|
11
|
-
|
|
12
|
-
selectors!: string;
|
|
13
|
-
|
|
14
|
-
constructor(public el: ElementRef, private resolver: ComponentFactoryResolver) {
|
|
15
|
-
const factory = this.resolver.resolveComponentFactory(ClassSelectorComponent);
|
|
16
|
-
this.selectors = factory.selector;
|
|
17
|
-
this.generatedTemplate = el.nativeElement.outerHTML;
|
|
18
|
-
}
|
|
19
|
-
}
|
package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ComponentFactoryResolver, ElementRef, Component } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Component({
|
|
4
|
-
selector: 'storybook-multiple-selector, storybook-multiple-selector2',
|
|
5
|
-
template: `<h3>Multiple selector</h3>
|
|
6
|
-
Selector: {{ selectors }} <br />
|
|
7
|
-
Generated template: {{ generatedTemplate }}`,
|
|
8
|
-
})
|
|
9
|
-
export class MultipleSelectorComponent {
|
|
10
|
-
generatedTemplate!: string;
|
|
11
|
-
|
|
12
|
-
selectors!: string;
|
|
13
|
-
|
|
14
|
-
constructor(public el: ElementRef, private resolver: ComponentFactoryResolver) {
|
|
15
|
-
const factory = this.resolver.resolveComponentFactory(MultipleClassSelectorComponent);
|
|
16
|
-
this.selectors = factory.selector;
|
|
17
|
-
this.generatedTemplate = el.nativeElement.outerHTML;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@Component({
|
|
22
|
-
selector: 'storybook-button, button[foo], .button[foo], button[baz]',
|
|
23
|
-
template: `<h3>Multiple selector</h3>
|
|
24
|
-
Selector: {{ selectors }} <br />
|
|
25
|
-
Generated template: {{ generatedTemplate }}`,
|
|
26
|
-
})
|
|
27
|
-
export class MultipleClassSelectorComponent {
|
|
28
|
-
generatedTemplate!: string;
|
|
29
|
-
|
|
30
|
-
selectors!: string;
|
|
31
|
-
|
|
32
|
-
constructor(public el: ElementRef, private resolver: ComponentFactoryResolver) {
|
|
33
|
-
const factory = this.resolver.resolveComponentFactory(MultipleClassSelectorComponent);
|
|
34
|
-
this.selectors = factory.selector;
|
|
35
|
-
this.generatedTemplate = el.nativeElement.outerHTML;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<div>
|
|
2
|
-
<div>unionType: {{ unionType }}</div>
|
|
3
|
-
<div>aliasedUnionType: {{ aliasedUnionType }}</div>
|
|
4
|
-
<div>enumNumeric: {{ enumNumeric }}</div>
|
|
5
|
-
<div>enumNumericInitial: {{ enumNumericInitial }}</div>
|
|
6
|
-
<div>enumStrings: {{ enumStrings }}</div>
|
|
7
|
-
<div>enumAlias: {{ enumAlias }}</div>
|
|
8
|
-
</div>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryFn } from '@storybook/angular';
|
|
2
|
-
import {
|
|
3
|
-
EnumsComponent,
|
|
4
|
-
EnumNumeric,
|
|
5
|
-
EnumNumericInitial,
|
|
6
|
-
EnumStringValues,
|
|
7
|
-
} from './enums.component';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
// title: 'Basics / Component / With Enum Types',
|
|
11
|
-
component: EnumsComponent,
|
|
12
|
-
} as Meta;
|
|
13
|
-
|
|
14
|
-
export const Basic: StoryFn = (args) => ({
|
|
15
|
-
props: args,
|
|
16
|
-
});
|
|
17
|
-
Basic.args = {
|
|
18
|
-
unionType: 'union a',
|
|
19
|
-
aliasedUnionType: 'Type Alias 1',
|
|
20
|
-
enumNumeric: EnumNumeric.FIRST,
|
|
21
|
-
enumNumericInitial: EnumNumericInitial.UNO,
|
|
22
|
-
enumStrings: EnumStringValues.PRIMARY,
|
|
23
|
-
enumAlias: EnumNumeric.FIRST,
|
|
24
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Component, Input } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This component is used for testing the various forms of enum types
|
|
5
|
-
*/
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'app-enums',
|
|
8
|
-
templateUrl: './enums.component.html',
|
|
9
|
-
})
|
|
10
|
-
export class EnumsComponent {
|
|
11
|
-
/** Union Type of string literals */
|
|
12
|
-
@Input() unionType?: 'Union A' | 'Union B' | 'Union C';
|
|
13
|
-
|
|
14
|
-
/** Union Type assigned as a Type Alias */
|
|
15
|
-
@Input() aliasedUnionType?: TypeAlias;
|
|
16
|
-
|
|
17
|
-
/** Base Enum Type with no assigned values */
|
|
18
|
-
@Input() enumNumeric?: EnumNumeric;
|
|
19
|
-
|
|
20
|
-
/** Enum with initial numeric value and auto-incrementing subsequent values */
|
|
21
|
-
@Input() enumNumericInitial?: EnumNumericInitial;
|
|
22
|
-
|
|
23
|
-
/** Enum with string values */
|
|
24
|
-
@Input() enumStrings?: EnumStringValues;
|
|
25
|
-
|
|
26
|
-
/** Type Aliased Enum Type */
|
|
27
|
-
@Input() enumAlias?: EnumAlias;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Button Priority
|
|
32
|
-
*/
|
|
33
|
-
export enum EnumNumeric {
|
|
34
|
-
FIRST,
|
|
35
|
-
SECOND,
|
|
36
|
-
THIRD,
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export enum EnumNumericInitial {
|
|
40
|
-
UNO = 1,
|
|
41
|
-
DOS,
|
|
42
|
-
TRES,
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export enum EnumStringValues {
|
|
46
|
-
PRIMARY = 'PRIMARY',
|
|
47
|
-
SECONDARY = 'SECONDARY',
|
|
48
|
-
TERTIARY = 'TERTIARY',
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export type EnumAlias = EnumNumeric;
|
|
52
|
-
|
|
53
|
-
type TypeAlias = 'Type Alias 1' | 'Type Alias 2' | 'Type Alias 3';
|