@storybook/angular 7.0.0-alpha.45 → 7.0.0-alpha.47
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/.eslintrc.js +8 -0
- package/dist/{types/builders → builders}/build-storybook/index.d.ts +1 -1
- package/dist/{types/builders → builders}/build-storybook/index.js +0 -0
- package/dist/{types/builders → builders}/build-storybook/index.spec.d.ts +0 -0
- package/dist/{types/builders → builders}/build-storybook/index.spec.js +0 -0
- package/dist/{types/builders → builders}/build-storybook/schema.json +0 -0
- package/dist/{types/builders → builders}/builders.json +0 -0
- package/dist/{types/builders → builders}/start-storybook/index.d.ts +1 -1
- package/dist/{types/builders → builders}/start-storybook/index.js +0 -0
- package/dist/{types/builders → builders}/start-storybook/index.spec.d.ts +0 -0
- package/dist/{types/builders → builders}/start-storybook/index.spec.js +0 -0
- package/dist/{types/builders → builders}/start-storybook/schema.json +0 -0
- package/dist/{types/builders → builders}/utils/build-standalone-errors-handler.d.ts +0 -0
- package/dist/{types/builders → builders}/utils/build-standalone-errors-handler.js +0 -0
- package/dist/{types/builders → builders}/utils/run-compodoc.d.ts +0 -0
- package/dist/{types/builders → builders}/utils/run-compodoc.js +0 -0
- package/dist/{types/builders → builders}/utils/run-compodoc.spec.d.ts +0 -0
- package/dist/{types/builders → builders}/utils/run-compodoc.spec.js +0 -0
- package/dist/{types/builders → builders}/utils/standalone-options.d.ts +2 -2
- package/dist/{types/builders → builders}/utils/standalone-options.js +0 -0
- package/dist/{types/client → client}/angular/app.component.d.ts +1 -1
- package/dist/{types/client → client}/angular/app.component.js +0 -0
- package/dist/{types/client → client}/angular/app.token.d.ts +0 -0
- package/dist/{types/client → client}/angular/app.token.js +0 -0
- package/dist/{types/client → client}/angular/helpers.d.ts +2 -2
- package/dist/{types/client → client}/angular/helpers.js +0 -0
- package/dist/{types/client → client}/angular-beta/AbstractRenderer.d.ts +0 -0
- package/dist/{types/client → client}/angular-beta/AbstractRenderer.js +0 -0
- package/dist/{types/client → client}/angular-beta/CanvasRenderer.d.ts +0 -0
- package/dist/{types/client → client}/angular-beta/CanvasRenderer.js +0 -0
- package/dist/{types/client → client}/angular-beta/ComputesTemplateFromComponent.d.ts +3 -3
- package/dist/{types/client → client}/angular-beta/ComputesTemplateFromComponent.js +0 -0
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.d.ts +1 -0
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +389 -0
- package/dist/{types/client → client}/angular-beta/DocsRenderer.d.ts +0 -0
- package/dist/{types/client → client}/angular-beta/DocsRenderer.js +0 -0
- package/dist/{types/client → client}/angular-beta/RendererFactory.d.ts +0 -0
- package/dist/{types/client → client}/angular-beta/RendererFactory.js +0 -0
- package/dist/client/angular-beta/RendererFactory.test.d.ts +1 -0
- package/dist/client/angular-beta/RendererFactory.test.js +295 -0
- package/dist/{types/client → client}/angular-beta/StorybookModule.d.ts +1 -1
- package/dist/{types/client → client}/angular-beta/StorybookModule.js +0 -0
- package/dist/client/angular-beta/StorybookModule.test.d.ts +1 -0
- package/dist/client/angular-beta/StorybookModule.test.js +279 -0
- package/dist/{types/client → client}/angular-beta/StorybookProvider.d.ts +1 -1
- package/dist/{types/client → client}/angular-beta/StorybookProvider.js +0 -0
- package/dist/{types/client → client}/angular-beta/StorybookWrapperComponent.d.ts +0 -0
- package/dist/{types/client → client}/angular-beta/StorybookWrapperComponent.js +0 -0
- package/dist/client/angular-beta/__testfixtures__/input.component.d.ts +26 -0
- package/dist/client/angular-beta/__testfixtures__/input.component.js +67 -0
- package/dist/{types/client → client}/angular-beta/utils/NgComponentAnalyzer.d.ts +1 -1
- package/dist/{types/client → client}/angular-beta/utils/NgComponentAnalyzer.js +0 -0
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.d.ts +1 -0
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +340 -0
- package/dist/{types/client → client}/angular-beta/utils/NgModulesAnalyzer.d.ts +0 -0
- package/dist/{types/client → client}/angular-beta/utils/NgModulesAnalyzer.js +0 -0
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.d.ts +1 -0
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.js +23 -0
- package/dist/{types/client → client}/config.d.ts +0 -0
- package/dist/{types/client → client}/config.js +0 -0
- package/dist/{types/client → client}/decorateStory.d.ts +2 -2
- package/dist/{types/client → client}/decorateStory.js +0 -0
- package/dist/client/decorateStory.test.d.ts +1 -0
- package/dist/client/decorateStory.test.js +335 -0
- package/dist/{types/client → client}/decorators.d.ts +3 -3
- package/dist/{types/client → client}/decorators.js +0 -0
- package/dist/client/decorators.test.d.ts +1 -0
- package/dist/client/decorators.test.js +106 -0
- package/dist/client/docs/__testfixtures__/doc-button/input.d.ts +111 -0
- package/dist/client/docs/__testfixtures__/doc-button/input.js +207 -0
- package/dist/client/docs/__testfixtures__/doc-button/tsconfig.json +7 -0
- package/dist/client/docs/angular-properties.test.d.ts +1 -0
- package/dist/client/docs/angular-properties.test.js +56 -0
- package/dist/{types/client → client}/docs/compodoc.d.ts +2 -2
- package/dist/{types/client → client}/docs/compodoc.js +0 -0
- package/dist/client/docs/compodoc.test.d.ts +1 -0
- package/dist/client/docs/compodoc.test.js +131 -0
- package/dist/{types/client → client}/docs/config.d.ts +1 -1
- package/dist/{types/client → client}/docs/config.js +0 -0
- package/dist/{types/client → client}/docs/index.d.ts +0 -0
- package/dist/{types/client → client}/docs/index.js +0 -0
- package/dist/{types/client → client}/docs/sourceDecorator.d.ts +1 -1
- package/dist/{types/client → client}/docs/sourceDecorator.js +0 -0
- package/dist/{types/client → client}/docs/types.d.ts +0 -0
- package/dist/{types/client → client}/docs/types.js +0 -0
- package/dist/{types/client → client}/globals.d.ts +0 -0
- package/dist/{types/client → client}/globals.js +0 -0
- package/dist/{types/client → client}/index.d.ts +0 -0
- package/dist/{types/client → client}/index.js +0 -0
- package/dist/{types/client → client}/public-api.d.ts +2 -2
- package/dist/{types/client → client}/public-api.js +0 -0
- package/dist/{types/client → client}/public-types.d.ts +1 -1
- package/dist/{types/client → client}/public-types.js +0 -0
- package/dist/{types/client → client}/render.d.ts +2 -2
- package/dist/{types/client → client}/render.js +0 -0
- package/dist/{types/client → client}/types.d.ts +1 -1
- package/dist/{types/client → client}/types.js +0 -0
- package/dist/{types/index.d.ts → index.d.ts} +0 -0
- package/dist/{types/index.js → index.js} +0 -0
- package/dist/{types/preset.d.ts → preset.d.ts} +1 -1
- package/dist/{types/preset.js → preset.js} +0 -0
- package/dist/{types/renderer.d.ts → renderer.d.ts} +0 -0
- package/dist/{types/renderer.js → renderer.js} +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/empty-projects-entry/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/src/tsconfig.app.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/tsconfig.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/src/tsconfig.app.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/tsconfig.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/src/tsconfig.app.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/tsconfig.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/projects/pattern-lib/tsconfig.lib.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/tsconfig.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/nx.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/src/tsconfig.app.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/tsconfig.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/nx.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/src/tsconfig.app.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/workspace.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/src/tsconfig.app.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/tsconfig.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-architect-build/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-architect-build-options/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-compatible-projects/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/tsconfig.lib.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/src/tsconfig.app.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +0 -0
- package/dist/server/__tests__/angular.json +96 -0
- package/dist/{types/server → server}/angular-cli-webpack-13.x.x.d.ts +0 -0
- package/dist/{types/server → server}/angular-cli-webpack-13.x.x.js +0 -0
- package/dist/{types/server → server}/angular-read-workspace.d.ts +0 -0
- package/dist/{types/server → server}/angular-read-workspace.js +0 -0
- package/dist/{types/server → server}/framework-preset-angular-cli.d.ts +1 -1
- package/dist/{types/server → server}/framework-preset-angular-cli.js +0 -0
- package/dist/server/framework-preset-angular-cli.test.d.ts +1 -0
- package/dist/server/framework-preset-angular-cli.test.js +708 -0
- package/dist/{types/server → server}/framework-preset-angular-docs.d.ts +1 -1
- package/dist/{types/server → server}/framework-preset-angular-docs.js +1 -1
- package/dist/{types/server → server}/framework-preset-angular-ivy.d.ts +1 -1
- package/dist/{types/server → server}/framework-preset-angular-ivy.js +0 -0
- package/dist/{types/server → server}/preset-options.d.ts +1 -1
- package/dist/{types/server → server}/preset-options.js +0 -0
- package/dist/{types/server → server}/utils/filter-out-styling-rules.d.ts +1 -1
- package/dist/{types/server → server}/utils/filter-out-styling-rules.js +0 -0
- package/dist/{types/server → server}/utils/module-is-available.d.ts +0 -0
- package/dist/{types/server → server}/utils/module-is-available.js +0 -0
- package/dist/{types/server → server}/utils/normalize-asset-patterns.d.ts +1 -1
- package/dist/{types/server → server}/utils/normalize-asset-patterns.js +0 -0
- package/dist/{types/server → server}/utils/normalize-optimization.d.ts +0 -0
- package/dist/{types/server → server}/utils/normalize-optimization.js +0 -0
- package/dist/{types/types.d.ts → types.d.ts} +2 -2
- package/dist/{types/types.js → types.js} +0 -0
- package/package.json +23 -21
- package/preset.js +1 -1
- package/renderer.d.ts +1 -1
- package/renderer.js +1 -1
- package/template/cli/.eslintrc.json +5 -0
- package/template/cli/Button.stories.ts +52 -0
- package/template/cli/Header.stories.ts +35 -0
- package/template/cli/Page.stories.ts +46 -0
- package/template/cli/User.ts +2 -0
- package/template/cli/button.component.ts +53 -0
- package/template/cli/header.component.ts +75 -0
- package/template/cli/page.component.ts +77 -0
- package/template/components/button.component.ts +54 -0
- package/template/components/button.css +30 -0
- package/template/components/form.component.ts +37 -0
- package/template/components/html.component.ts +22 -0
- package/template/components/index.js +8 -0
- package/template/components/pre.component.ts +29 -0
- package/template/stories/angular-mdx.stories.mdx +25 -0
- package/template/stories/argTypes/doc-button/doc-button.component.html +7 -0
- package/template/stories/argTypes/doc-button/doc-button.component.scss +3 -0
- package/template/stories/argTypes/doc-button/doc-button.component.ts +233 -0
- package/template/stories/argTypes/doc-button/doc-button.stories.ts +24 -0
- package/template/stories/argTypes/doc-directive/doc-directive.directive.ts +24 -0
- package/template/stories/argTypes/doc-directive/doc-directive.stories.ts +14 -0
- package/template/stories/argTypes/doc-injectable/doc-injectable.service.ts +27 -0
- package/template/stories/argTypes/doc-injectable/doc-injectable.stories.ts +17 -0
- package/template/stories/argTypes/doc-pipe/doc-pipe.pipe.ts +18 -0
- package/template/stories/argTypes/doc-pipe/doc-pipe.stories.ts +17 -0
- package/template/stories/basics/README.stories.mdx +7 -0
- package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva-component.stories.ts +27 -0
- package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva.component.ts +57 -0
- package/template/stories/basics/component-with-complex-selectors/attribute-selector.component.ts +19 -0
- package/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts +8 -0
- package/template/stories/basics/component-with-complex-selectors/class-selector.component.stories.ts +8 -0
- package/template/stories/basics/component-with-complex-selectors/class-selector.component.ts +19 -0
- package/template/stories/basics/component-with-complex-selectors/multiple-class-selector.component.stories.ts +8 -0
- package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.stories.ts +8 -0
- package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.ts +37 -0
- package/template/stories/basics/component-with-enums/enums.component.html +8 -0
- package/template/stories/basics/component-with-enums/enums.component.stories.ts +24 -0
- package/template/stories/basics/component-with-enums/enums.component.ts +53 -0
- package/template/stories/basics/component-with-inheritance/base-button.component.ts +10 -0
- package/template/stories/basics/component-with-inheritance/base-button.stories.ts +12 -0
- package/template/stories/basics/component-with-inheritance/icon-button.component.ts +11 -0
- package/template/stories/basics/component-with-inheritance/icon-button.stories.ts +13 -0
- package/template/stories/basics/component-with-ng-content/ng-content-about-parent.stories.ts +58 -0
- package/template/stories/basics/component-with-ng-content/ng-content-simple.stories.ts +29 -0
- package/template/stories/basics/component-with-ng-on-destroy/component-with-on-destroy.stories.ts +42 -0
- package/template/stories/basics/component-with-on-push/on-push-box.component.ts +21 -0
- package/template/stories/basics/component-with-on-push/on-push.stories.ts +21 -0
- package/template/stories/basics/component-with-pipe/custom-pipes.stories.ts +31 -0
- package/template/stories/basics/component-with-pipe/custom.pipe.ts +10 -0
- package/template/stories/basics/component-with-pipe/with-pipe.component.ts +10 -0
- package/template/stories/basics/component-with-provider/di.component.html +7 -0
- package/template/stories/basics/component-with-provider/di.component.stories.ts +26 -0
- package/template/stories/basics/component-with-provider/di.component.ts +28 -0
- package/template/stories/basics/component-with-style/styled.component.css +3 -0
- package/template/stories/basics/component-with-style/styled.component.html +5 -0
- package/template/stories/basics/component-with-style/styled.component.scss +5 -0
- package/template/stories/basics/component-with-style/styled.component.stories.ts +10 -0
- package/template/stories/basics/component-with-style/styled.component.ts +8 -0
- package/template/stories/basics/component-without-selector/without-selector-ng-component-outlet.stories.ts +73 -0
- package/template/stories/basics/component-without-selector/without-selector-ng-factory-resolver.stories.ts +71 -0
- package/template/stories/basics/component-without-selector/without-selector.component.ts +30 -0
- package/template/stories/basics/component-without-selector/without-selector.stories.ts +30 -0
- package/template/stories/basics/ng-module/angular-src/chip-color.token.ts +3 -0
- package/template/stories/basics/ng-module/angular-src/chip-text.pipe.ts +29 -0
- package/template/stories/basics/ng-module/angular-src/chip.component.ts +60 -0
- package/template/stories/basics/ng-module/angular-src/chips-group.component.ts +49 -0
- package/template/stories/basics/ng-module/angular-src/chips.module.ts +31 -0
- package/template/stories/basics/ng-module/import-module-for-root.stories.ts +50 -0
- package/template/stories/basics/ng-module/import-module.stories.ts +46 -0
- package/template/stories/button.component.ts +26 -0
- package/template/stories/core/README.stories.mdx +7 -0
- package/template/stories/core/decorators/componentWrapperDecorator/child.component.ts +20 -0
- package/template/stories/core/decorators/componentWrapperDecorator/decorators.stories.ts +117 -0
- package/template/stories/core/decorators/componentWrapperDecorator/parent.component.ts +18 -0
- package/template/stories/core/decorators/theme-decorator/decorators.stories.ts +20 -0
- package/template/stories/core/moduleMetadata/angular-src/custom.pipe.ts +10 -0
- package/template/stories/core/moduleMetadata/angular-src/dummy.service.ts +14 -0
- package/template/stories/core/moduleMetadata/angular-src/service.component.ts +24 -0
- package/template/stories/core/moduleMetadata/angular-src/token.component.ts +31 -0
- package/template/stories/core/moduleMetadata/in-export-default.stories.ts +38 -0
- package/template/stories/core/moduleMetadata/in-stories.stories.ts +46 -0
- package/template/stories/core/moduleMetadata/merge-default-and-story.stories.ts +35 -0
- package/template/stories/core/parameters/bootstrap-options.stories.ts +22 -0
- package/template/stories/core/styles/story-styles.stories.ts +50 -0
- package/template/stories/others/issues/12009-unknown-component.stories.ts +14 -0
- package/template/stories/others/ngx-translate/README.stories.mdx +58 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'storybook-pre',
|
|
5
|
+
template: `<pre data-testid="pre" [ngStyle]="style">{{ finalText }}</pre>`,
|
|
6
|
+
})
|
|
7
|
+
export default class PreComponent {
|
|
8
|
+
/**
|
|
9
|
+
* Styles to apply to the component
|
|
10
|
+
*/
|
|
11
|
+
@Input()
|
|
12
|
+
style?: Object;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* An object to render
|
|
16
|
+
*/
|
|
17
|
+
@Input()
|
|
18
|
+
object?: Object;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The code to render
|
|
22
|
+
*/
|
|
23
|
+
@Input()
|
|
24
|
+
text?: string;
|
|
25
|
+
|
|
26
|
+
get finalText() {
|
|
27
|
+
return this.object ? JSON.stringify(this.object, null, 2) : this.text;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import globalThis from 'global';
|
|
2
|
+
import { moduleMetadata } from '@storybook/angular';
|
|
3
|
+
import { Meta, Story, Canvas } from '@storybook/addon-docs';
|
|
4
|
+
|
|
5
|
+
export const Button = globalThis.Components.Button;
|
|
6
|
+
|
|
7
|
+
<Meta
|
|
8
|
+
title="angular/angular-mdx"
|
|
9
|
+
component={Button}
|
|
10
|
+
decorators={[moduleMetadata({ declarations: [Button] })]}
|
|
11
|
+
/>
|
|
12
|
+
|
|
13
|
+
# Angular-specific MDX Stories
|
|
14
|
+
|
|
15
|
+
<Canvas>
|
|
16
|
+
<Story name="Angular Story">
|
|
17
|
+
{{
|
|
18
|
+
template: `<storybook-framework-button [label]="text" (onClick)="onClick($event)"></storybook-framework-button>`,
|
|
19
|
+
props: {
|
|
20
|
+
text: 'hello button',
|
|
21
|
+
onClick: () => {},
|
|
22
|
+
},
|
|
23
|
+
}}
|
|
24
|
+
</Story>
|
|
25
|
+
</Canvas>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<button [disabled]="isDisabled" [ngClass]="classes" #buttonRef>
|
|
2
|
+
<img
|
|
3
|
+
width="100"
|
|
4
|
+
src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOS4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHZpZXdCb3g9IjAgMCAyNTAgMjUwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNTAgMjUwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDojREQwMDMxO30NCgkuc3Qxe2ZpbGw6I0MzMDAyRjt9DQoJLnN0MntmaWxsOiNGRkZGRkY7fQ0KPC9zdHlsZT4NCjxnPg0KCTxwb2x5Z29uIGNsYXNzPSJzdDAiIHBvaW50cz0iMTI1LDMwIDEyNSwzMCAxMjUsMzAgMzEuOSw2My4yIDQ2LjEsMTg2LjMgMTI1LDIzMCAxMjUsMjMwIDEyNSwyMzAgMjAzLjksMTg2LjMgMjE4LjEsNjMuMiAJIi8+DQoJPHBvbHlnb24gY2xhc3M9InN0MSIgcG9pbnRzPSIxMjUsMzAgMTI1LDUyLjIgMTI1LDUyLjEgMTI1LDE1My40IDEyNSwxNTMuNCAxMjUsMjMwIDEyNSwyMzAgMjAzLjksMTg2LjMgMjE4LjEsNjMuMiAxMjUsMzAgCSIvPg0KCTxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik0xMjUsNTIuMUw2Ni44LDE4Mi42aDBoMjEuN2gwbDExLjctMjkuMmg0OS40bDExLjcsMjkuMmgwaDIxLjdoMEwxMjUsNTIuMUwxMjUsNTIuMUwxMjUsNTIuMUwxMjUsNTIuMQ0KCQlMMTI1LDUyLjF6IE0xNDIsMTM1LjRIMTA4bDE3LTQwLjlMMTQyLDEzNS40eiIvPg0KPC9nPg0KPC9zdmc+DQo="
|
|
5
|
+
/>
|
|
6
|
+
{{ label }}
|
|
7
|
+
</button>
|
|
@@ -0,0 +1,233 @@
|
|
|
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
|
+
// @ts-expect-error intentionally undefined
|
|
76
|
+
public anUndefinedValue;
|
|
77
|
+
|
|
78
|
+
/** Test numeric default value. */
|
|
79
|
+
@Input()
|
|
80
|
+
public aNumericValue = 123;
|
|
81
|
+
|
|
82
|
+
/** Appearance style of the button. */
|
|
83
|
+
@Input()
|
|
84
|
+
public appearance: 'primary' | 'secondary' = 'secondary';
|
|
85
|
+
|
|
86
|
+
/** Sets the button to a disabled state. */
|
|
87
|
+
@Input()
|
|
88
|
+
public isDisabled = false;
|
|
89
|
+
|
|
90
|
+
/** Specify the accent-type of the button */
|
|
91
|
+
@Input()
|
|
92
|
+
public accent: ButtonAccent = ButtonAccent.Normal;
|
|
93
|
+
|
|
94
|
+
/** Specifies some arbitrary object. This comment is to test certain chars like apostrophes - it's working */
|
|
95
|
+
@Input() public someDataObject!: ISomeInterface;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The inner text of the button.
|
|
99
|
+
*
|
|
100
|
+
* @required
|
|
101
|
+
*/
|
|
102
|
+
@Input()
|
|
103
|
+
public label!: string;
|
|
104
|
+
|
|
105
|
+
/** Size of the button. */
|
|
106
|
+
@Input()
|
|
107
|
+
public size?: ButtonSize = 'medium';
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Some input you shouldn't use.
|
|
111
|
+
*
|
|
112
|
+
* @deprecated
|
|
113
|
+
*/
|
|
114
|
+
@Input()
|
|
115
|
+
public somethingYouShouldNotUse = false;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Handler to be called when the button is clicked by a user.
|
|
119
|
+
*
|
|
120
|
+
* Will also block the emission of the event if `isDisabled` is true.
|
|
121
|
+
*/
|
|
122
|
+
@Output()
|
|
123
|
+
public onClick = new EventEmitter<Event>();
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* This is an internal method that we don't want to document and have added the `ignore` annotation to.
|
|
127
|
+
*
|
|
128
|
+
* @ignore
|
|
129
|
+
*/
|
|
130
|
+
public handleClick(event: Event) {
|
|
131
|
+
event.stopPropagation();
|
|
132
|
+
|
|
133
|
+
if (!this.isDisabled) {
|
|
134
|
+
this.onClick.emit(event);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private _inputValue = 'some value';
|
|
139
|
+
|
|
140
|
+
/** Setter for `inputValue` that is also an `@Input`. */
|
|
141
|
+
@Input()
|
|
142
|
+
public set inputValue(value: string) {
|
|
143
|
+
this._inputValue = value;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Getter for `inputValue`. */
|
|
147
|
+
public get inputValue() {
|
|
148
|
+
return this._inputValue;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@HostListener('click', ['$event'])
|
|
152
|
+
onClickListener(event: Event) {
|
|
153
|
+
console.log('button', event.target);
|
|
154
|
+
this.handleClick(event);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@HostBinding('class.focused') focus = false;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Returns all the CSS classes for the button.
|
|
161
|
+
*
|
|
162
|
+
* @ignore
|
|
163
|
+
*/
|
|
164
|
+
public get classes(): string[] {
|
|
165
|
+
return [this.appearance, this.size]
|
|
166
|
+
.filter((_class) => !!_class)
|
|
167
|
+
.map((_class) => `btn-${_class}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @ignore
|
|
172
|
+
*/
|
|
173
|
+
public ignoredProperty = 'Ignore me';
|
|
174
|
+
|
|
175
|
+
/** Public value. */
|
|
176
|
+
public internalProperty = 'Public hello';
|
|
177
|
+
|
|
178
|
+
/** Private value. */
|
|
179
|
+
private _value = 'Private hello';
|
|
180
|
+
|
|
181
|
+
/** Set the private value. */
|
|
182
|
+
public set value(value: string | number) {
|
|
183
|
+
this._value = `${value}`;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Get the private value. */
|
|
187
|
+
public get value(): string | number {
|
|
188
|
+
return this._value;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* An internal calculation method which adds `x` and `y` together.
|
|
193
|
+
*
|
|
194
|
+
* @param x Some number you'd like to use.
|
|
195
|
+
* @param y Some other number or string you'd like to use, will have `parseInt()` applied before calculation.
|
|
196
|
+
*/
|
|
197
|
+
public calc(x: number, y: string | number): number {
|
|
198
|
+
return x + parseInt(`${y}`, 10);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** A public method using an interface. */
|
|
202
|
+
public publicMethod(things: ISomeInterface) {
|
|
203
|
+
console.log(things);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* A protected method.
|
|
208
|
+
*
|
|
209
|
+
* @param id Some `id`.
|
|
210
|
+
*/
|
|
211
|
+
protected protectedMethod(id?: number) {
|
|
212
|
+
console.log(id);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* A private method.
|
|
217
|
+
*
|
|
218
|
+
* @param password Some `password`.
|
|
219
|
+
*/
|
|
220
|
+
private privateMethod(password: string) {
|
|
221
|
+
console.log(password);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@Input('showKeyAlias')
|
|
225
|
+
public showKey!: keyof T;
|
|
226
|
+
|
|
227
|
+
@Input()
|
|
228
|
+
public set item(item: T[]) {
|
|
229
|
+
this.processedItem = item;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public processedItem!: T[];
|
|
233
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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' };
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DocInjectableService } from './doc-injectable.service';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
component: DocInjectableService,
|
|
5
|
+
parameters: {
|
|
6
|
+
controls: { hideNoControlsWarning: true },
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const modules = {
|
|
11
|
+
provider: [DocInjectableService],
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const Basic = () => ({
|
|
15
|
+
moduleMetadata: modules,
|
|
16
|
+
template: '<div><h1>DocInjectable</h1></div>',
|
|
17
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DocPipe } from './doc-pipe.pipe';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
component: DocPipe,
|
|
5
|
+
parameters: {
|
|
6
|
+
controls: { hideNoControlsWarning: true },
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const modules = {
|
|
11
|
+
declarations: [DocPipe],
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const Basic = () => ({
|
|
15
|
+
moduleMetadata: modules,
|
|
16
|
+
template: `<div><h1>{{ 'DocPipe' | docPipe }}</h1></div>`,
|
|
17
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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>
|