@storybook/angular 7.0.0-alpha.7 → 7.0.0-beta.0
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/README.md +1 -1
- package/dist/{types/builders → builders}/build-storybook/index.d.ts +3 -3
- package/dist/{types/builders → builders}/build-storybook/index.js +0 -0
- package/dist/builders/build-storybook/index.spec.d.ts +1 -0
- package/dist/builders/build-storybook/index.spec.js +218 -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 +3 -3
- package/dist/{types/builders → builders}/start-storybook/index.js +0 -0
- package/dist/builders/start-storybook/index.spec.d.ts +1 -0
- package/dist/builders/start-storybook/index.spec.js +214 -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 +3 -6
- package/dist/{types/builders → builders}/utils/run-compodoc.d.ts +0 -0
- package/dist/{types/builders → builders}/utils/run-compodoc.js +0 -1
- package/dist/builders/utils/run-compodoc.spec.d.ts +1 -0
- package/dist/builders/utils/run-compodoc.spec.js +59 -0
- package/dist/{types/builders → builders}/utils/standalone-options.d.ts +3 -3
- 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 -1
- 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 +3 -3
- package/dist/{types/client → client}/angular/helpers.js +1 -2
- package/dist/{types/client → client}/angular-beta/AbstractRenderer.d.ts +1 -1
- package/dist/{types/client → client}/angular-beta/AbstractRenderer.js +13 -13
- 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 +3 -3
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.d.ts +1 -0
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +390 -0
- package/dist/{types/client → client}/angular-beta/DocsRenderer.d.ts +0 -0
- package/dist/{types/client → client}/angular-beta/DocsRenderer.js +5 -8
- package/dist/{types/client → client}/angular-beta/RendererFactory.d.ts +1 -1
- package/dist/{types/client → client}/angular-beta/RendererFactory.js +3 -3
- package/dist/client/angular-beta/RendererFactory.test.d.ts +1 -0
- package/dist/client/angular-beta/RendererFactory.test.js +297 -0
- package/dist/{types/client → client}/angular-beta/StorybookModule.d.ts +2 -2
- package/dist/{types/client → client}/angular-beta/StorybookModule.js +4 -23
- 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 -1
- 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 +2 -2
- 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/client/config.d.ts +6 -0
- package/dist/client/config.js +10 -0
- package/dist/client/decorateStory.d.ts +4 -0
- package/dist/{types/client → client}/decorateStory.js +3 -3
- package/dist/client/decorateStory.test.d.ts +1 -0
- package/dist/client/decorateStory.test.js +335 -0
- package/dist/client/decorators.d.ts +5 -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 +5 -11
- package/dist/{types/client → client}/docs/compodoc.js +7 -7
- package/dist/client/docs/compodoc.test.d.ts +1 -0
- package/dist/client/docs/compodoc.test.js +131 -0
- package/dist/client/docs/config.d.ts +4 -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 +3 -3
- package/dist/{types/client → client}/docs/sourceDecorator.js +3 -3
- package/dist/{types/client → client}/docs/types.d.ts +1 -1
- 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 +3 -0
- package/dist/client/public-api.d.ts +15 -0
- package/dist/{types/client → client}/public-api.js +2 -9
- package/dist/client/public-types.d.ts +36 -0
- package/dist/{types/client → client}/public-types.js +0 -0
- package/dist/client/render.d.ts +6 -0
- package/dist/{types/client → client}/render.js +3 -3
- package/dist/{types/client → client}/types.d.ts +9 -13
- 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 -1
- 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/__mocks-ng-workspace__/some-config → server/__mocks-ng-workspace__/minimal-config}/tsconfig.json +1 -4
- 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/__mocks-ng-workspace__/with-angularBrowserTarget → server/__mocks-ng-workspace__/some-config}/tsconfig.json +1 -4
- 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/__mocks-ng-workspace__/minimal-config → server/__mocks-ng-workspace__/with-angularBrowserTarget}/tsconfig.json +1 -4
- 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/__mocks-ng-workspace__/without-projects-entry → server/__mocks-ng-workspace__/with-lib}/projects/pattern-lib/tsconfig.lib.json +2 -8
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/tsconfig.json +1 -4
- 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/server/__mocks-ng-workspace__/with-nx/tsconfig.json +14 -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/server/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +14 -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/server/__mocks-ng-workspace__/with-options-styles/tsconfig.json +13 -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/__mocks-ng-workspace__/with-lib → server/__mocks-ng-workspace__/without-projects-entry}/projects/pattern-lib/tsconfig.lib.json +2 -8
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +13 -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/server/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +13 -0
- package/dist/server/__tests__/angular.json +96 -0
- package/dist/{types/server/angular-cli-webpack-12.2.x.d.ts → server/angular-cli-webpack.d.ts} +0 -0
- package/dist/{types/server/angular-cli-webpack-13.x.x.js → server/angular-cli-webpack.js} +6 -1
- package/dist/{types/server → server}/angular-read-workspace.d.ts +0 -0
- package/dist/{types/server → server}/angular-read-workspace.js +1 -1
- package/dist/{types/server → server}/framework-preset-angular-cli.d.ts +1 -1
- package/dist/{types/server → server}/framework-preset-angular-cli.js +5 -24
- package/dist/server/framework-preset-angular-cli.test.d.ts +1 -0
- package/dist/server/framework-preset-angular-cli.test.js +698 -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 +4 -2
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.d.ts +25 -0
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +46 -0
- package/dist/{types/server → server}/preset-options.d.ts +2 -2
- 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.d.ts +29 -0
- package/dist/{types/types.js → types.js} +0 -0
- package/jest.config.js +8 -1
- package/package.json +49 -54
- 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 +51 -0
- package/template/cli/Header.stories.ts +37 -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
- package/LICENSE +0 -21
- package/dist/types/client/config.d.ts +0 -6
- package/dist/types/client/config.js +0 -10
- package/dist/types/client/decorateStory.d.ts +0 -4
- package/dist/types/client/decorators.d.ts +0 -5
- package/dist/types/client/docs/config.d.ts +0 -14
- package/dist/types/client/public-api.d.ts +0 -23
- package/dist/types/client/public-types.d.ts +0 -27
- package/dist/types/client/render.d.ts +0 -7
- package/dist/types/server/__mocks-ng-workspace__/with-nx/tsconfig.json +0 -19
- package/dist/types/server/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +0 -19
- package/dist/types/server/__mocks-ng-workspace__/with-options-styles/tsconfig.json +0 -16
- package/dist/types/server/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +0 -16
- package/dist/types/server/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +0 -16
- package/dist/types/server/angular-cli-webpack-12.2.x.js +0 -66
- package/dist/types/server/angular-cli-webpack-13.x.x.d.ts +0 -1
- package/dist/types/server/angular-cli-webpack-older.d.ts +0 -6
- package/dist/types/server/angular-cli-webpack-older.js +0 -111
- package/dist/types/server/angular-devkit-build-webpack.d.ts +0 -30
- package/dist/types/server/angular-devkit-build-webpack.js +0 -164
- package/dist/types/server/create-fork-ts-checker-plugin.d.ts +0 -3
- package/dist/types/server/create-fork-ts-checker-plugin.js +0 -19
- package/dist/types/server/framework-preset-angular.d.ts +0 -5
- package/dist/types/server/framework-preset-angular.js +0 -103
- package/dist/types/server/ngx-template-loader/index.d.ts +0 -1
- package/dist/types/server/ngx-template-loader/index.js +0 -46
- package/dist/types/server/ts_config.d.ts +0 -2
- package/dist/types/server/ts_config.js +0 -28
- package/dist/types/types.d.ts +0 -28
|
@@ -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' };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PipeTransform, Pipe } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Pipe({
|
|
4
|
+
name: 'chipText',
|
|
5
|
+
})
|
|
6
|
+
export class ChipTextPipe implements PipeTransform {
|
|
7
|
+
transform(value: string): string {
|
|
8
|
+
return Array.from(value)
|
|
9
|
+
.map((char) => this.accentVowel(char))
|
|
10
|
+
.join('');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
accentVowel(char: string): string {
|
|
14
|
+
switch (char) {
|
|
15
|
+
case 'a':
|
|
16
|
+
return 'á';
|
|
17
|
+
case 'e':
|
|
18
|
+
return 'é';
|
|
19
|
+
case 'i':
|
|
20
|
+
return 'í';
|
|
21
|
+
case 'o':
|
|
22
|
+
return 'ó';
|
|
23
|
+
case 'u':
|
|
24
|
+
return 'ú';
|
|
25
|
+
default:
|
|
26
|
+
return char;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Component, Input, Output, EventEmitter, Inject, HostBinding } from '@angular/core';
|
|
2
|
+
import { CHIP_COLOR } from './chip-color.token';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'storybook-chip',
|
|
6
|
+
template: `
|
|
7
|
+
<span class="text">{{ displayText | chipText }}</span>
|
|
8
|
+
<div class="remove" (click)="removeClicked.emit()">
|
|
9
|
+
<span class="x">✕</span>
|
|
10
|
+
</div>
|
|
11
|
+
`,
|
|
12
|
+
styles: [
|
|
13
|
+
`
|
|
14
|
+
:host {
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
cursor: default;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
padding: 0.2rem 0.5rem;
|
|
20
|
+
border-radius: 1rem;
|
|
21
|
+
border: solid 0.1rem transparent;
|
|
22
|
+
}
|
|
23
|
+
:host:hover {
|
|
24
|
+
border-color: black;
|
|
25
|
+
}
|
|
26
|
+
.text {
|
|
27
|
+
font-family: inherit;
|
|
28
|
+
}
|
|
29
|
+
.remove {
|
|
30
|
+
margin-left: 1rem;
|
|
31
|
+
background-color: lightgrey;
|
|
32
|
+
border-radius: 50%;
|
|
33
|
+
width: 1rem;
|
|
34
|
+
height: 1rem;
|
|
35
|
+
text-align: center;
|
|
36
|
+
}
|
|
37
|
+
.remove:hover {
|
|
38
|
+
background-color: palevioletred;
|
|
39
|
+
}
|
|
40
|
+
.x {
|
|
41
|
+
display: inline-block;
|
|
42
|
+
color: #eeeeee;
|
|
43
|
+
text-align: center;
|
|
44
|
+
vertical-align: baseline;
|
|
45
|
+
line-height: 1rem;
|
|
46
|
+
}
|
|
47
|
+
`,
|
|
48
|
+
],
|
|
49
|
+
})
|
|
50
|
+
export class ChipComponent {
|
|
51
|
+
@Input() displayText?: string;
|
|
52
|
+
|
|
53
|
+
@Output() removeClicked = new EventEmitter();
|
|
54
|
+
|
|
55
|
+
@HostBinding('style.background-color') backgroundColor: string;
|
|
56
|
+
|
|
57
|
+
constructor(@Inject(CHIP_COLOR) chipColor: string) {
|
|
58
|
+
this.backgroundColor = chipColor;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'storybook-chips-group',
|
|
5
|
+
template: `
|
|
6
|
+
<storybook-chip
|
|
7
|
+
*ngFor="let chip of chips"
|
|
8
|
+
class="chip"
|
|
9
|
+
[displayText]="chip.text"
|
|
10
|
+
(removeClicked)="removeChipClick.emit(chip.id)"
|
|
11
|
+
></storybook-chip>
|
|
12
|
+
<div *ngIf="chips.length > 1" class="remove-all" (click)="removeAllChipsClick.emit()">
|
|
13
|
+
Remove All
|
|
14
|
+
</div>
|
|
15
|
+
`,
|
|
16
|
+
styles: [
|
|
17
|
+
`
|
|
18
|
+
:host {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-content: center;
|
|
21
|
+
padding: 0.5rem;
|
|
22
|
+
background-color: lightgrey;
|
|
23
|
+
border-radius: 0.5rem;
|
|
24
|
+
width: fit-content;
|
|
25
|
+
}
|
|
26
|
+
.chip:not(:first-of-type) {
|
|
27
|
+
margin-left: 0.5rem;
|
|
28
|
+
}
|
|
29
|
+
.remove-all {
|
|
30
|
+
margin-left: 0.5rem;
|
|
31
|
+
padding: 0.2rem 0.5rem;
|
|
32
|
+
border: solid 0.1rem #eeeeee;
|
|
33
|
+
}
|
|
34
|
+
.remove-all:hover {
|
|
35
|
+
background-color: palevioletred;
|
|
36
|
+
}
|
|
37
|
+
`,
|
|
38
|
+
],
|
|
39
|
+
})
|
|
40
|
+
export class ChipsGroupComponent {
|
|
41
|
+
@Input() chips?: {
|
|
42
|
+
id: number;
|
|
43
|
+
text: string;
|
|
44
|
+
}[];
|
|
45
|
+
|
|
46
|
+
@Output() removeChipClick = new EventEmitter<number>();
|
|
47
|
+
|
|
48
|
+
@Output() removeAllChipsClick = new EventEmitter();
|
|
49
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ModuleWithProviders, NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { ChipComponent } from './chip.component';
|
|
4
|
+
import { ChipsGroupComponent } from './chips-group.component';
|
|
5
|
+
import { ChipTextPipe } from './chip-text.pipe';
|
|
6
|
+
import { CHIP_COLOR } from './chip-color.token';
|
|
7
|
+
|
|
8
|
+
@NgModule({
|
|
9
|
+
imports: [CommonModule],
|
|
10
|
+
exports: [ChipsGroupComponent, ChipComponent],
|
|
11
|
+
declarations: [ChipsGroupComponent, ChipComponent, ChipTextPipe],
|
|
12
|
+
providers: [
|
|
13
|
+
{
|
|
14
|
+
provide: CHIP_COLOR,
|
|
15
|
+
useValue: '#eeeeee',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
})
|
|
19
|
+
export class ChipsModule {
|
|
20
|
+
public static forRoot(): ModuleWithProviders<ChipsModule> {
|
|
21
|
+
return {
|
|
22
|
+
ngModule: ChipsModule,
|
|
23
|
+
providers: [
|
|
24
|
+
{
|
|
25
|
+
provide: CHIP_COLOR,
|
|
26
|
+
useValue: '#ff5454',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { StoryFn, Meta, moduleMetadata } from '@storybook/angular';
|
|
2
|
+
import { ChipsModule } from './angular-src/chips.module';
|
|
3
|
+
import { ChipsGroupComponent } from './angular-src/chips-group.component';
|
|
4
|
+
import { CHIP_COLOR } from './angular-src/chip-color.token';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
// title: 'Basics / NgModule / forRoot() pattern',
|
|
8
|
+
component: ChipsGroupComponent,
|
|
9
|
+
decorators: [
|
|
10
|
+
moduleMetadata({
|
|
11
|
+
imports: [ChipsModule.forRoot()],
|
|
12
|
+
}),
|
|
13
|
+
],
|
|
14
|
+
args: {
|
|
15
|
+
chips: [
|
|
16
|
+
{
|
|
17
|
+
id: 1,
|
|
18
|
+
text: 'Chip 1',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 2,
|
|
22
|
+
text: 'Chip 2',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
argTypes: {
|
|
27
|
+
removeChipClick: { action: 'Remove chip' },
|
|
28
|
+
removeAllChipsClick: { action: 'Remove all chips clicked' },
|
|
29
|
+
},
|
|
30
|
+
} as Meta;
|
|
31
|
+
|
|
32
|
+
const Template = (): StoryFn => (args) => ({
|
|
33
|
+
props: args,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const Base = Template();
|
|
37
|
+
Base.storyName = 'Chips group';
|
|
38
|
+
|
|
39
|
+
export const WithCustomProvider = Template();
|
|
40
|
+
WithCustomProvider.decorators = [
|
|
41
|
+
moduleMetadata({
|
|
42
|
+
providers: [
|
|
43
|
+
{
|
|
44
|
+
provide: CHIP_COLOR,
|
|
45
|
+
useValue: 'yellow',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
}),
|
|
49
|
+
];
|
|
50
|
+
WithCustomProvider.storyName = 'Chips group with overridden provider';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { StoryFn, Meta, moduleMetadata } from '@storybook/angular';
|
|
2
|
+
import { ChipsModule } from './angular-src/chips.module';
|
|
3
|
+
import { ChipsGroupComponent } from './angular-src/chips-group.component';
|
|
4
|
+
import { ChipComponent } from './angular-src/chip.component';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
// title: 'Basics / NgModule / Module with multiple component',
|
|
8
|
+
component: ChipsGroupComponent,
|
|
9
|
+
decorators: [
|
|
10
|
+
moduleMetadata({
|
|
11
|
+
imports: [ChipsModule],
|
|
12
|
+
}),
|
|
13
|
+
],
|
|
14
|
+
} as Meta;
|
|
15
|
+
|
|
16
|
+
export const ChipsGroup: StoryFn = (args) => ({
|
|
17
|
+
component: ChipsGroupComponent,
|
|
18
|
+
props: args,
|
|
19
|
+
});
|
|
20
|
+
ChipsGroup.args = {
|
|
21
|
+
chips: [
|
|
22
|
+
{
|
|
23
|
+
id: 1,
|
|
24
|
+
text: 'Chip 1',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 2,
|
|
28
|
+
text: 'Chip 2',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
ChipsGroup.argTypes = {
|
|
33
|
+
removeChipClick: { action: 'Remove chip' },
|
|
34
|
+
removeAllChipsClick: { action: 'Remove all chips clicked' },
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const Chip: StoryFn = (args) => ({
|
|
38
|
+
component: ChipComponent,
|
|
39
|
+
props: args,
|
|
40
|
+
});
|
|
41
|
+
Chip.args = {
|
|
42
|
+
displayText: 'Chip',
|
|
43
|
+
};
|
|
44
|
+
Chip.argTypes = {
|
|
45
|
+
removeClicked: { action: 'Remove icon clicked' },
|
|
46
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'storybook-button-component',
|
|
5
|
+
template: ` <button (click)="onClick.emit($event)">{{ text }}</button> `,
|
|
6
|
+
styles: [
|
|
7
|
+
`
|
|
8
|
+
button {
|
|
9
|
+
border: 1px solid #eee;
|
|
10
|
+
border-radius: 3px;
|
|
11
|
+
background-color: #ffffff;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
font-size: 15px;
|
|
14
|
+
padding: 3px 10px;
|
|
15
|
+
margin: 10px;
|
|
16
|
+
}
|
|
17
|
+
`,
|
|
18
|
+
],
|
|
19
|
+
})
|
|
20
|
+
export default class ButtonComponent {
|
|
21
|
+
@Input()
|
|
22
|
+
text = '';
|
|
23
|
+
|
|
24
|
+
@Output()
|
|
25
|
+
onClick = new EventEmitter<any>();
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'child-component',
|
|
5
|
+
template: `
|
|
6
|
+
Child<br />
|
|
7
|
+
Input text: {{ childText }} <br />
|
|
8
|
+
Output : <button (click)="onClickChild.emit($event)">Click here !</button> <br />
|
|
9
|
+
Private text: {{ childPrivateText }} <br />
|
|
10
|
+
`,
|
|
11
|
+
})
|
|
12
|
+
export default class ChildComponent {
|
|
13
|
+
@Input()
|
|
14
|
+
childText = '';
|
|
15
|
+
|
|
16
|
+
childPrivateText = '';
|
|
17
|
+
|
|
18
|
+
@Output()
|
|
19
|
+
onClickChild = new EventEmitter<any>();
|
|
20
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// your-component.stories.ts
|
|
2
|
+
|
|
3
|
+
import { Args, Meta, Story, componentWrapperDecorator, moduleMetadata } from '@storybook/angular';
|
|
4
|
+
import ChildComponent from './child.component';
|
|
5
|
+
import ParentComponent from './parent.component';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
// title: 'Core / Decorators / ComponentWrapperDecorator',
|
|
9
|
+
component: ChildComponent,
|
|
10
|
+
decorators: [
|
|
11
|
+
componentWrapperDecorator(
|
|
12
|
+
(story) => `Grandparent<br><div style="margin: 3em; border:solid;">${story}</div>`
|
|
13
|
+
),
|
|
14
|
+
],
|
|
15
|
+
args: { childText: 'Child text', childPrivateText: 'Child private text' },
|
|
16
|
+
argTypes: { onClickChild: { action: 'onClickChild' } },
|
|
17
|
+
} as Meta;
|
|
18
|
+
|
|
19
|
+
export const WithTemplate = (args: Args) => ({
|
|
20
|
+
template: `Child Template`,
|
|
21
|
+
props: {
|
|
22
|
+
...args,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const WithComponent = (args: Args) => ({
|
|
27
|
+
props: {
|
|
28
|
+
...args,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export const WithLegacyComponent = (args: Args) => ({
|
|
33
|
+
component: ChildComponent,
|
|
34
|
+
props: {
|
|
35
|
+
...args,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const WithComponentWrapperDecorator = (args: Args) => ({
|
|
40
|
+
component: ChildComponent,
|
|
41
|
+
props: {
|
|
42
|
+
...args,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
WithComponentWrapperDecorator.decorators = [
|
|
46
|
+
moduleMetadata({ declarations: [ParentComponent] }),
|
|
47
|
+
componentWrapperDecorator(ParentComponent),
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
export const WithComponentWrapperDecoratorAndProps = (args: Args) => ({
|
|
51
|
+
component: ChildComponent,
|
|
52
|
+
props: {
|
|
53
|
+
...args,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
WithComponentWrapperDecoratorAndProps.decorators = [
|
|
57
|
+
moduleMetadata({ declarations: [ParentComponent] }),
|
|
58
|
+
componentWrapperDecorator(ParentComponent, {
|
|
59
|
+
parentText: 'Parent text',
|
|
60
|
+
onClickParent: () => {
|
|
61
|
+
console.log('onClickParent');
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
export const WithComponentWrapperDecoratorAndArgs = (args: Args) => ({
|
|
67
|
+
component: ChildComponent,
|
|
68
|
+
props: {
|
|
69
|
+
...args,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
WithComponentWrapperDecoratorAndArgs.argTypes = {
|
|
73
|
+
parentText: { control: { type: 'text' } },
|
|
74
|
+
onClickParent: { action: 'onClickParent' },
|
|
75
|
+
};
|
|
76
|
+
WithComponentWrapperDecoratorAndArgs.decorators = [
|
|
77
|
+
moduleMetadata({ declarations: [ParentComponent] }),
|
|
78
|
+
componentWrapperDecorator(ParentComponent, ({ args }) => ({
|
|
79
|
+
parentText: args.parentText,
|
|
80
|
+
onClickParent: args.onClickParent,
|
|
81
|
+
})),
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
export const WithCustomDecorator = (args: Args) => ({
|
|
85
|
+
template: `Child Template`,
|
|
86
|
+
props: {
|
|
87
|
+
...args,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
WithCustomDecorator.decorators = [
|
|
91
|
+
(storyFunc) => {
|
|
92
|
+
const story = storyFunc();
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
...story,
|
|
96
|
+
template: `Custom Decorator <div style="margin: 3em">${story.template}</div>`,
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
] as Story['decorators'];
|
|
100
|
+
|
|
101
|
+
export const AngularLegacyRendering = (args: Args) => ({
|
|
102
|
+
template: `Child Template`,
|
|
103
|
+
props: {
|
|
104
|
+
...args,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
AngularLegacyRendering.parameters = { angularLegacyRendering: true };
|
|
108
|
+
AngularLegacyRendering.decorators = [
|
|
109
|
+
(storyFunc) => {
|
|
110
|
+
const story = storyFunc();
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
...story,
|
|
114
|
+
template: `Custom Decorator <div style="margin: 3em">${story.template}</div>`,
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
] as Story['decorators'];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'parent-component',
|
|
5
|
+
template: `
|
|
6
|
+
Parent<br />
|
|
7
|
+
Input text: {{ parentText }} <br />
|
|
8
|
+
Output : <button (click)="onClickParent.emit($event)">Click here !</button> <br />
|
|
9
|
+
<div style="margin: 3em; border:solid;"><ng-content></ng-content></div>
|
|
10
|
+
`,
|
|
11
|
+
})
|
|
12
|
+
export default class ParentComponent {
|
|
13
|
+
@Input()
|
|
14
|
+
parentText = '';
|
|
15
|
+
|
|
16
|
+
@Output()
|
|
17
|
+
onClickParent = new EventEmitter<any>();
|
|
18
|
+
}
|