@storybook/angular 7.0.0-alpha.46 → 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/dist/{types/builders → builders}/build-storybook/index.d.ts +0 -0
- 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 +0 -0
- 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 +0 -0
- package/dist/{types/builders → builders}/utils/standalone-options.js +0 -0
- package/dist/{types/client → client}/angular/app.component.d.ts +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- 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 +0 -0
- package/dist/{types/client → client}/public-api.js +0 -0
- package/dist/{types/client → client}/public-types.d.ts +0 -0
- package/dist/{types/client → client}/public-types.js +0 -0
- package/dist/{types/client → client}/render.d.ts +0 -0
- package/dist/{types/client → client}/render.js +0 -0
- package/dist/{types/client → client}/types.d.ts +0 -0
- 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} +0 -0
- 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 +0 -0
- 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 +0 -0
- package/dist/{types/server → server}/framework-preset-angular-docs.js +1 -1
- package/dist/{types/server → server}/framework-preset-angular-ivy.d.ts +0 -0
- package/dist/{types/server → server}/framework-preset-angular-ivy.js +0 -0
- package/dist/{types/server → server}/preset-options.d.ts +0 -0
- package/dist/{types/server → server}/preset-options.js +0 -0
- package/dist/{types/server → server}/utils/filter-out-styling-rules.d.ts +0 -0
- 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 +0 -0
- 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} +0 -0
- 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,24 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
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';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseButtonComponent } from './base-button.component';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
// title: 'Basics / Component / With Inheritance',
|
|
5
|
+
component: BaseButtonComponent,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const BaseButton = () => ({
|
|
9
|
+
props: {
|
|
10
|
+
label: 'this is label',
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
|
+
import { BaseButtonComponent } from './base-button.component';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: `storybook-icon-button`,
|
|
6
|
+
template: ` <button>{{ label }} - {{ icon }}</button> `,
|
|
7
|
+
})
|
|
8
|
+
export class IconButtonComponent extends BaseButtonComponent {
|
|
9
|
+
@Input()
|
|
10
|
+
icon?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IconButtonComponent } from './icon-button.component';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
// title: 'Basics / Component / With Inheritance',
|
|
5
|
+
component: IconButtonComponent,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const IconButton = () => ({
|
|
9
|
+
props: {
|
|
10
|
+
icon: 'this is icon',
|
|
11
|
+
label: 'this is label',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
|
+
import { componentWrapperDecorator, Meta, StoryFn } from '@storybook/angular';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'sb-button',
|
|
6
|
+
template: `<button [style.background-color]="color"><ng-content></ng-content></button>`,
|
|
7
|
+
styles: [
|
|
8
|
+
`
|
|
9
|
+
button {
|
|
10
|
+
padding: 4px;
|
|
11
|
+
}
|
|
12
|
+
`,
|
|
13
|
+
],
|
|
14
|
+
})
|
|
15
|
+
class SbButtonComponent {
|
|
16
|
+
@Input()
|
|
17
|
+
color = '#5eadf5';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
// title: 'Basics / Component / With ng-content / Button with different contents',
|
|
22
|
+
// Implicitly declares the component to Angular
|
|
23
|
+
// This will be the component described by the addon docs
|
|
24
|
+
component: SbButtonComponent,
|
|
25
|
+
decorators: [
|
|
26
|
+
// Wrap all stories with this template
|
|
27
|
+
componentWrapperDecorator(
|
|
28
|
+
(story) => `<sb-button [color]="propsColor">${story}</sb-button>`,
|
|
29
|
+
|
|
30
|
+
({ args }) => ({ propsColor: args['color'] })
|
|
31
|
+
),
|
|
32
|
+
],
|
|
33
|
+
argTypes: {
|
|
34
|
+
color: { control: 'color' },
|
|
35
|
+
},
|
|
36
|
+
} as Meta;
|
|
37
|
+
|
|
38
|
+
// By default storybook uses the default export component if no template or component is defined in the story
|
|
39
|
+
// So Storybook nests the component twice because it is first added by the componentWrapperDecorator.
|
|
40
|
+
export const AlwaysDefineTemplateOrComponent: StoryFn = () => ({});
|
|
41
|
+
|
|
42
|
+
export const EmptyButton: StoryFn = () => ({
|
|
43
|
+
template: '',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const WithDynamicContentAndArgs: StoryFn = (args) => ({
|
|
47
|
+
template: `${args['content']}`,
|
|
48
|
+
});
|
|
49
|
+
WithDynamicContentAndArgs.argTypes = {
|
|
50
|
+
content: { control: 'text' },
|
|
51
|
+
};
|
|
52
|
+
WithDynamicContentAndArgs.args = { content: 'My button text' };
|
|
53
|
+
|
|
54
|
+
export const InH1: StoryFn = () => ({
|
|
55
|
+
template: 'My button in h1',
|
|
56
|
+
});
|
|
57
|
+
InH1.decorators = [componentWrapperDecorator((story) => `<h1>${story}</h1>`)];
|
|
58
|
+
InH1.storyName = 'In <h1>';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { Meta, StoryFn } from '@storybook/angular/';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'storybook-with-ng-content',
|
|
7
|
+
template: `Content value:
|
|
8
|
+
<div style="color: #1e88e5;"><ng-content></ng-content></div>`,
|
|
9
|
+
})
|
|
10
|
+
class WithNgContentComponent {}
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
// title: 'Basics / Component / With ng-content / Simple',
|
|
14
|
+
component: WithNgContentComponent,
|
|
15
|
+
} as Meta;
|
|
16
|
+
|
|
17
|
+
export const OnlyComponent: StoryFn = () => ({});
|
|
18
|
+
|
|
19
|
+
export const Default: StoryFn = () => ({
|
|
20
|
+
template: `<storybook-with-ng-content><h1>This is rendered in ng-content</h1></storybook-with-ng-content>`,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const WithDynamicContentAndArgs: StoryFn = (args) => ({
|
|
24
|
+
template: `<storybook-with-ng-content><h1>${args['content']}</h1></storybook-with-ng-content>`,
|
|
25
|
+
});
|
|
26
|
+
WithDynamicContentAndArgs.argTypes = {
|
|
27
|
+
content: { control: 'text' },
|
|
28
|
+
};
|
|
29
|
+
WithDynamicContentAndArgs.args = { content: 'Default content' };
|
package/template/stories/basics/component-with-ng-on-destroy/component-with-on-destroy.stories.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { OnDestroy, OnInit, Component } from '@angular/core';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/angular';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'on-destroy',
|
|
6
|
+
template: `Current time: {{ time }} <br />
|
|
7
|
+
📝 The current time in console should no longer display after a change of story`,
|
|
8
|
+
})
|
|
9
|
+
class OnDestroyComponent implements OnInit, OnDestroy {
|
|
10
|
+
time?: string;
|
|
11
|
+
|
|
12
|
+
interval: any;
|
|
13
|
+
|
|
14
|
+
ngOnInit(): void {
|
|
15
|
+
const myTimer = () => {
|
|
16
|
+
const d = new Date();
|
|
17
|
+
this.time = d.toLocaleTimeString();
|
|
18
|
+
console.info(`Current time: ${this.time}`);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
myTimer();
|
|
22
|
+
this.interval = setInterval(myTimer, 3000);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
ngOnDestroy(): void {
|
|
26
|
+
clearInterval(this.interval);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default {
|
|
31
|
+
// title: 'Basics / Component / with ngOnDestroy',
|
|
32
|
+
component: OnDestroyComponent,
|
|
33
|
+
parameters: {
|
|
34
|
+
// disabled due to new Date()
|
|
35
|
+
storyshots: { disable: true },
|
|
36
|
+
chromatic: { disable: true },
|
|
37
|
+
},
|
|
38
|
+
} as Meta;
|
|
39
|
+
|
|
40
|
+
export const SimpleComponent: StoryFn = () => ({
|
|
41
|
+
component: OnDestroyComponent,
|
|
42
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Component, Input, ChangeDetectionStrategy, HostBinding } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'storybook-on-push-box',
|
|
5
|
+
template: ` Word of the day: {{ word }} `,
|
|
6
|
+
styles: [
|
|
7
|
+
`
|
|
8
|
+
:host {
|
|
9
|
+
display: block;
|
|
10
|
+
padding: 1rem;
|
|
11
|
+
width: fit-content;
|
|
12
|
+
}
|
|
13
|
+
`,
|
|
14
|
+
],
|
|
15
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
16
|
+
})
|
|
17
|
+
export class OnPushBoxComponent {
|
|
18
|
+
@Input() word?: string;
|
|
19
|
+
|
|
20
|
+
@Input() @HostBinding('style.background-color') bgColor?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/angular';
|
|
2
|
+
import { OnPushBoxComponent } from './on-push-box.component';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
// title: 'Basics / Component / With OnPush strategy',
|
|
6
|
+
component: OnPushBoxComponent,
|
|
7
|
+
argTypes: {
|
|
8
|
+
word: { control: 'text' },
|
|
9
|
+
bgColor: { control: 'color' },
|
|
10
|
+
},
|
|
11
|
+
args: {
|
|
12
|
+
word: 'The text',
|
|
13
|
+
bgColor: '#FFF000',
|
|
14
|
+
},
|
|
15
|
+
} as Meta;
|
|
16
|
+
|
|
17
|
+
export const ClassSpecifiedComponentWithOnPushAndArgs: StoryFn = (args) => ({
|
|
18
|
+
props: args,
|
|
19
|
+
});
|
|
20
|
+
ClassSpecifiedComponentWithOnPushAndArgs.storyName =
|
|
21
|
+
'Class-specified component with OnPush and Args';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Meta, StoryFn, moduleMetadata } from '@storybook/angular';
|
|
2
|
+
|
|
3
|
+
import { CustomPipePipe } from './custom.pipe';
|
|
4
|
+
import { WithPipeComponent } from './with-pipe.component';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
// title: 'Basics / Component / With Pipes',
|
|
8
|
+
component: WithPipeComponent,
|
|
9
|
+
decorators: [
|
|
10
|
+
moduleMetadata({
|
|
11
|
+
declarations: [CustomPipePipe],
|
|
12
|
+
}),
|
|
13
|
+
],
|
|
14
|
+
} as Meta;
|
|
15
|
+
|
|
16
|
+
export const Simple: StoryFn = () => ({
|
|
17
|
+
props: {
|
|
18
|
+
field: 'foobar',
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const WithArgsStory: StoryFn = (args) => ({
|
|
23
|
+
props: args,
|
|
24
|
+
});
|
|
25
|
+
WithArgsStory.storyName = 'With args';
|
|
26
|
+
WithArgsStory.argTypes = {
|
|
27
|
+
field: { control: 'text' },
|
|
28
|
+
};
|
|
29
|
+
WithArgsStory.args = {
|
|
30
|
+
field: 'Foo Bar',
|
|
31
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Args } from '@storybook/angular';
|
|
2
|
+
import { DiComponent } from './di.component';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
// title: 'Basics / Component / With Provider',
|
|
6
|
+
component: DiComponent,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const InputsAndInjectDependencies = () => ({
|
|
10
|
+
props: {
|
|
11
|
+
title: 'Component dependencies',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
InputsAndInjectDependencies.storyName = 'inputs and inject dependencies';
|
|
16
|
+
|
|
17
|
+
export const InputsAndInjectDependenciesWithArgs = (args: Args) => ({
|
|
18
|
+
props: args,
|
|
19
|
+
});
|
|
20
|
+
InputsAndInjectDependenciesWithArgs.storyName = 'inputs and inject dependencies with args';
|
|
21
|
+
InputsAndInjectDependenciesWithArgs.argTypes = {
|
|
22
|
+
title: { control: 'text' },
|
|
23
|
+
};
|
|
24
|
+
InputsAndInjectDependenciesWithArgs.args = {
|
|
25
|
+
title: 'Component dependencies',
|
|
26
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Injector, ElementRef, Component, Input, InjectionToken, Inject } from '@angular/core';
|
|
2
|
+
import { stringify } from 'telejson';
|
|
3
|
+
|
|
4
|
+
export const TEST_TOKEN = new InjectionToken<string>('test');
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'storybook-di-component',
|
|
8
|
+
templateUrl: './di.component.html',
|
|
9
|
+
providers: [{ provide: TEST_TOKEN, useValue: 123 }],
|
|
10
|
+
})
|
|
11
|
+
export class DiComponent {
|
|
12
|
+
@Input()
|
|
13
|
+
title?: string;
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
protected injector: Injector,
|
|
17
|
+
protected elRef: ElementRef,
|
|
18
|
+
@Inject(TEST_TOKEN) protected testToken: number
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
isAllDeps(): boolean {
|
|
22
|
+
return Boolean(this.testToken && this.elRef && this.injector && this.title);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
elRefStr(): string {
|
|
26
|
+
return stringify(this.elRef, { maxDepth: 1 });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StyledComponent } from './styled.component';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
// title: 'Basics / Component / With StyleUrls',
|
|
5
|
+
component: StyledComponent,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const ComponentWithStyles = () => ({});
|
|
9
|
+
|
|
10
|
+
ComponentWithStyles.storyName = 'Component with styles';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { OnInit, Type, Component, Injector, Input } from '@angular/core';
|
|
2
|
+
import { StoryFn, Meta, componentWrapperDecorator, moduleMetadata } from '@storybook/angular';
|
|
3
|
+
import { WithoutSelectorComponent, WITHOUT_SELECTOR_DATA } from './without-selector.component';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
// title: 'Basics / Component / without selector / Custom wrapper *NgComponentOutlet',
|
|
7
|
+
component: WithoutSelectorComponent,
|
|
8
|
+
decorators: [
|
|
9
|
+
moduleMetadata({
|
|
10
|
+
entryComponents: [WithoutSelectorComponent],
|
|
11
|
+
}),
|
|
12
|
+
],
|
|
13
|
+
} as Meta;
|
|
14
|
+
|
|
15
|
+
// Advanced example with custom *ngComponentOutlet
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'ng-component-outlet-wrapper',
|
|
19
|
+
template: `<ng-container
|
|
20
|
+
*ngComponentOutlet="componentOutlet; injector: componentInjector; content: componentContent"
|
|
21
|
+
></ng-container>`,
|
|
22
|
+
})
|
|
23
|
+
class NgComponentOutletWrapperComponent implements OnInit {
|
|
24
|
+
@Input()
|
|
25
|
+
componentOutlet?: Type<unknown>;
|
|
26
|
+
|
|
27
|
+
@Input()
|
|
28
|
+
name?: string;
|
|
29
|
+
|
|
30
|
+
@Input()
|
|
31
|
+
color?: string;
|
|
32
|
+
|
|
33
|
+
componentInjector?: Injector;
|
|
34
|
+
|
|
35
|
+
componentContent = [
|
|
36
|
+
[document.createTextNode('Ng-content : Inspired by ')],
|
|
37
|
+
[document.createTextNode('https://angular.io/api/common/NgComponentOutlet')],
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
constructor(private readonly injector: Injector) {}
|
|
41
|
+
|
|
42
|
+
ngOnInit(): void {
|
|
43
|
+
this.componentInjector = Injector.create({
|
|
44
|
+
providers: [
|
|
45
|
+
{ provide: WITHOUT_SELECTOR_DATA, useValue: { color: this.color, name: this.name } },
|
|
46
|
+
],
|
|
47
|
+
parent: this.injector,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Live changing of args by controls does not work at the moment. When changing args storybook does not fully
|
|
53
|
+
// reload and therefore does not take into account the change of provider.
|
|
54
|
+
export const WithCustomNgComponentOutletWrapper: StoryFn = (args) => ({
|
|
55
|
+
props: args,
|
|
56
|
+
});
|
|
57
|
+
WithCustomNgComponentOutletWrapper.storyName = 'Custom wrapper *NgComponentOutlet';
|
|
58
|
+
WithCustomNgComponentOutletWrapper.argTypes = {
|
|
59
|
+
name: { control: 'text' },
|
|
60
|
+
color: { control: 'color' },
|
|
61
|
+
};
|
|
62
|
+
WithCustomNgComponentOutletWrapper.args = { name: 'Dixie Normous', color: 'green' };
|
|
63
|
+
WithCustomNgComponentOutletWrapper.decorators = [
|
|
64
|
+
moduleMetadata({
|
|
65
|
+
declarations: [NgComponentOutletWrapperComponent],
|
|
66
|
+
}),
|
|
67
|
+
componentWrapperDecorator(NgComponentOutletWrapperComponent, (args) => ({
|
|
68
|
+
name: args.name,
|
|
69
|
+
|
|
70
|
+
color: args['color'],
|
|
71
|
+
componentOutlet: WithoutSelectorComponent,
|
|
72
|
+
})),
|
|
73
|
+
];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AfterViewInit,
|
|
3
|
+
ComponentFactoryResolver,
|
|
4
|
+
Type,
|
|
5
|
+
Component,
|
|
6
|
+
Input,
|
|
7
|
+
ViewChild,
|
|
8
|
+
ViewContainerRef,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import { StoryFn, Meta, componentWrapperDecorator, moduleMetadata } from '@storybook/angular';
|
|
11
|
+
|
|
12
|
+
import { WithoutSelectorComponent } from './without-selector.component';
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
// title: 'Basics / Component / without selector / Custom wrapper ComponentFactoryResolver',
|
|
16
|
+
component: WithoutSelectorComponent,
|
|
17
|
+
decorators: [
|
|
18
|
+
moduleMetadata({
|
|
19
|
+
entryComponents: [WithoutSelectorComponent],
|
|
20
|
+
}),
|
|
21
|
+
],
|
|
22
|
+
} as Meta;
|
|
23
|
+
|
|
24
|
+
// Advanced example with custom ComponentFactoryResolver
|
|
25
|
+
|
|
26
|
+
@Component({ selector: 'component-factory-wrapper', template: '' })
|
|
27
|
+
class ComponentFactoryWrapperComponent implements AfterViewInit {
|
|
28
|
+
@ViewChild('dynamicInsert', { read: ViewContainerRef }) dynamicInsert: any;
|
|
29
|
+
|
|
30
|
+
@Input()
|
|
31
|
+
componentOutlet?: Type<unknown>;
|
|
32
|
+
|
|
33
|
+
@Input()
|
|
34
|
+
args: any;
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
private viewContainerRef: ViewContainerRef,
|
|
38
|
+
private componentFactoryResolver: ComponentFactoryResolver
|
|
39
|
+
) {}
|
|
40
|
+
|
|
41
|
+
ngAfterViewInit() {
|
|
42
|
+
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(
|
|
43
|
+
this.componentOutlet!
|
|
44
|
+
);
|
|
45
|
+
const containerRef = this.viewContainerRef;
|
|
46
|
+
containerRef.clear();
|
|
47
|
+
const dynamicComponent = containerRef.createComponent(componentFactory);
|
|
48
|
+
Object.assign(dynamicComponent.instance as any, this.args);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Live changing of args by controls does not work at the moment. When changing args storybook does not fully
|
|
53
|
+
// reload and therefore does not take into account the change of provider.
|
|
54
|
+
export const WithComponentFactoryResolver: StoryFn = (args) => ({
|
|
55
|
+
props: args,
|
|
56
|
+
});
|
|
57
|
+
WithComponentFactoryResolver.storyName = 'Custom wrapper ComponentFactoryResolver';
|
|
58
|
+
WithComponentFactoryResolver.argTypes = {
|
|
59
|
+
name: { control: 'text' },
|
|
60
|
+
color: { control: 'color' },
|
|
61
|
+
};
|
|
62
|
+
WithComponentFactoryResolver.args = { name: 'Dixie Normous', color: 'chartreuse' };
|
|
63
|
+
WithComponentFactoryResolver.decorators = [
|
|
64
|
+
moduleMetadata({
|
|
65
|
+
declarations: [ComponentFactoryWrapperComponent],
|
|
66
|
+
}),
|
|
67
|
+
componentWrapperDecorator(ComponentFactoryWrapperComponent, ({ args }) => ({
|
|
68
|
+
args,
|
|
69
|
+
componentOutlet: WithoutSelectorComponent,
|
|
70
|
+
})),
|
|
71
|
+
];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Component, Inject, InjectionToken, Optional } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
export const WITHOUT_SELECTOR_DATA = new InjectionToken<{ color: string; name: string }>(
|
|
4
|
+
'WITHOUT_SELECTOR_DATA'
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
template: `My name in color :
|
|
9
|
+
<div [style.color]="color">{{ name }}</div>
|
|
10
|
+
<ng-content></ng-content> <ng-content></ng-content>`,
|
|
11
|
+
})
|
|
12
|
+
export class WithoutSelectorComponent {
|
|
13
|
+
color = '#1e88e5';
|
|
14
|
+
|
|
15
|
+
name = 'Joe Bar';
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
@Inject(WITHOUT_SELECTOR_DATA)
|
|
19
|
+
@Optional()
|
|
20
|
+
data: {
|
|
21
|
+
color: string;
|
|
22
|
+
name: string;
|
|
23
|
+
} | null
|
|
24
|
+
) {
|
|
25
|
+
if (data) {
|
|
26
|
+
this.color = data.color;
|
|
27
|
+
this.name = data.name;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StoryFn, Meta, moduleMetadata } from '@storybook/angular';
|
|
2
|
+
import { WithoutSelectorComponent, WITHOUT_SELECTOR_DATA } from './without-selector.component';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
// title: 'Basics / Component / without selector',
|
|
6
|
+
component: WithoutSelectorComponent,
|
|
7
|
+
decorators: [
|
|
8
|
+
moduleMetadata({
|
|
9
|
+
entryComponents: [WithoutSelectorComponent],
|
|
10
|
+
}),
|
|
11
|
+
],
|
|
12
|
+
} as Meta;
|
|
13
|
+
|
|
14
|
+
export const SimpleComponent: StoryFn = () => ({});
|
|
15
|
+
|
|
16
|
+
// Live changing of args by controls does not work for now. When changing args storybook does not fully
|
|
17
|
+
// reload and therefore does not take into account the change of provider.
|
|
18
|
+
export const WithInjectionTokenAndArgs: StoryFn = (args) => ({
|
|
19
|
+
props: args,
|
|
20
|
+
moduleMetadata: {
|
|
21
|
+
providers: [
|
|
22
|
+
{ provide: WITHOUT_SELECTOR_DATA, useValue: { color: args['color'], name: args['name'] } },
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
WithInjectionTokenAndArgs.argTypes = {
|
|
27
|
+
name: { control: 'text' },
|
|
28
|
+
color: { control: 'color' },
|
|
29
|
+
};
|
|
30
|
+
WithInjectionTokenAndArgs.args = { name: 'Dixie Normous', color: 'red' };
|