@storybook/angular 6.5.0-alpha.10 → 6.5.0-alpha.14

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.
@@ -1,4 +1,4 @@
1
- import { Component, Input, Output, Type } from '@angular/core';
1
+ import { Component, Type } from '@angular/core';
2
2
  export declare type ComponentInputsOutputs = {
3
3
  inputs: {
4
4
  propName: string;
@@ -19,7 +19,9 @@ export declare const isComponent: (component: any) => component is Type<unknown>
19
19
  * Returns all component decorator properties
20
20
  * is used to get all `@Input` and `@Output` Decorator
21
21
  */
22
- export declare const getComponentPropsDecoratorMetadata: (component: any) => Record<string, (Input | Output)[]>;
22
+ export declare const getComponentPropsDecoratorMetadata: (component: any) => {
23
+ [key: string]: any[];
24
+ };
23
25
  /**
24
26
  * Returns component decorator `@Component`
25
27
  */
@@ -93,6 +93,25 @@ exports.computesTemplateSourceFromComponent = function (component, initialProps,
93
93
  return buildTemplate(ngComponentMetadata.selector, '', templateInputs, templateOutputs);
94
94
  };
95
95
  var buildTemplate = function (selector, innerTemplate, inputs, outputs) {
96
+ // https://www.w3.org/TR/2011/WD-html-markup-20110113/syntax.html#syntax-elements
97
+ var voidElements = [
98
+ 'area',
99
+ 'base',
100
+ 'br',
101
+ 'col',
102
+ 'command',
103
+ 'embed',
104
+ 'hr',
105
+ 'img',
106
+ 'input',
107
+ 'keygen',
108
+ 'link',
109
+ 'meta',
110
+ 'param',
111
+ 'source',
112
+ 'track',
113
+ 'wbr',
114
+ ];
96
115
  var firstSelector = selector.split(',')[0];
97
116
  var templateReplacers = [
98
117
  [/(^.*?)(?=[,])/, '$1'],
@@ -102,7 +121,14 @@ var buildTemplate = function (selector, innerTemplate, inputs, outputs) {
102
121
  [/#([\w-]+)/, " id=\"$1\""],
103
122
  [/((\.[\w-]+)+)/, function (_, c) { return " class=\"" + c.split(templateObject_1 || (templateObject_1 = __makeTemplateObject(["."], ["."]))).join(templateObject_2 || (templateObject_2 = __makeTemplateObject([" "], [" "]))).trim() + "\""; }],
104
123
  [/(\[.+?])/g, function (_, a) { return " " + a.slice(1, -1); }],
105
- [/([\S]+)(.*)/, "<$1$2" + inputs + outputs + ">" + innerTemplate + "</$1>"],
124
+ [
125
+ /([\S]+)(.*)/,
126
+ function (template, elementSelector) {
127
+ return voidElements.some(function (element) { return elementSelector === element; })
128
+ ? template.replace(/([\S]+)(.*)/, "<$1$2" + inputs + outputs + " />")
129
+ : template.replace(/([\S]+)(.*)/, "<$1$2" + inputs + outputs + ">" + innerTemplate + "</$1>");
130
+ },
131
+ ],
106
132
  ];
107
133
  return templateReplacers.reduce(function (prevSelector, _a) {
108
134
  var searchValue = _a[0], replacer = _a[1];
@@ -1,4 +1,4 @@
1
- import { Component, Input, Output, Type } from '@angular/core';
1
+ import { Component, Type } from '@angular/core';
2
2
  export declare type ComponentInputsOutputs = {
3
3
  inputs: {
4
4
  propName: string;
@@ -19,7 +19,9 @@ export declare const isComponent: (component: any) => component is Type<unknown>
19
19
  * Returns all component decorator properties
20
20
  * is used to get all `@Input` and `@Output` Decorator
21
21
  */
22
- export declare const getComponentPropsDecoratorMetadata: (component: any) => Record<string, (Input | Output)[]>;
22
+ export declare const getComponentPropsDecoratorMetadata: (component: any) => {
23
+ [key: string]: any[];
24
+ };
23
25
  /**
24
26
  * Returns component decorator `@Component`
25
27
  */
@@ -20,6 +20,7 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.getComponentDecoratorMetadata = exports.getComponentPropsDecoratorMetadata = exports.isComponent = exports.isDeclarable = exports.getComponentInputsOutputs = void 0;
22
22
  var core_1 = require("@angular/core");
23
+ var reflectionCapabilities = new core_1.ɵReflectionCapabilities();
23
24
  /**
24
25
  * Returns component Inputs / Outputs by browsing these properties and decorator
25
26
  */
@@ -70,20 +71,14 @@ exports.isDeclarable = function (component) {
70
71
  if (!component) {
71
72
  return false;
72
73
  }
73
- var decoratorKey = '__annotations__';
74
- var decorators = Reflect.getOwnPropertyDescriptor(component, decoratorKey)
75
- ? Reflect.getOwnPropertyDescriptor(component, decoratorKey).value
76
- : component[decoratorKey];
74
+ var decorators = reflectionCapabilities.annotations(component);
77
75
  return !!(decorators || []).find(function (d) { return d instanceof core_1.Directive || d instanceof core_1.Pipe || d instanceof core_1.Component; });
78
76
  };
79
77
  exports.isComponent = function (component) {
80
78
  if (!component) {
81
79
  return false;
82
80
  }
83
- var decoratorKey = '__annotations__';
84
- var decorators = Reflect.getOwnPropertyDescriptor(component, decoratorKey)
85
- ? Reflect.getOwnPropertyDescriptor(component, decoratorKey).value
86
- : component[decoratorKey];
81
+ var decorators = reflectionCapabilities.annotations(component);
87
82
  return (decorators || []).some(function (d) { return d instanceof core_1.Component; });
88
83
  };
89
84
  /**
@@ -91,34 +86,12 @@ exports.isComponent = function (component) {
91
86
  * is used to get all `@Input` and `@Output` Decorator
92
87
  */
93
88
  exports.getComponentPropsDecoratorMetadata = function (component) {
94
- var decoratorKey = '__prop__metadata__';
95
- var propsDecorators = Reflect &&
96
- Reflect.getOwnPropertyDescriptor &&
97
- Reflect.getOwnPropertyDescriptor(component, decoratorKey)
98
- ? Reflect.getOwnPropertyDescriptor(component, decoratorKey).value
99
- : component[decoratorKey];
100
- var parent = Reflect && Reflect.getPrototypeOf && Reflect.getPrototypeOf(component);
101
- if (parent) {
102
- var parentPropsDecorators = exports.getComponentPropsDecoratorMetadata(parent);
103
- propsDecorators = __assign(__assign({}, parentPropsDecorators), propsDecorators);
104
- }
105
- return propsDecorators;
89
+ return reflectionCapabilities.propMetadata(component);
106
90
  };
107
91
  /**
108
92
  * Returns component decorator `@Component`
109
93
  */
110
94
  exports.getComponentDecoratorMetadata = function (component) {
111
- var decoratorKey = '__annotations__';
112
- var decorators = Reflect &&
113
- Reflect.getOwnPropertyDescriptor &&
114
- Reflect.getOwnPropertyDescriptor(component, decoratorKey)
115
- ? Reflect.getOwnPropertyDescriptor(component, decoratorKey).value
116
- : component[decoratorKey];
117
- if (!decorators) {
118
- return (component.decorators &&
119
- component.decorators[0] &&
120
- component.decorators[0].args &&
121
- component.decorators[0].args[0]);
122
- }
123
- return decorators.find(function (d) { return d instanceof core_1.Component; });
95
+ var decorators = reflectionCapabilities.annotations(component);
96
+ return decorators.reverse().find(function (d) { return d instanceof core_1.Component; });
124
97
  };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isComponentAlreadyDeclaredInModules = void 0;
4
4
  var core_1 = require("@angular/core");
5
+ var reflectionCapabilities = new core_1.ɵReflectionCapabilities();
5
6
  /**
6
7
  * Avoid component redeclaration
7
8
  *
@@ -27,12 +28,7 @@ exports.isComponentAlreadyDeclaredInModules = function (componentToFind, moduleD
27
28
  };
28
29
  var extractNgModuleMetadata = function (importItem) {
29
30
  var target = importItem && importItem.ngModule ? importItem.ngModule : importItem;
30
- var decoratorKey = '__annotations__';
31
- var decorators = Reflect &&
32
- Reflect.getOwnPropertyDescriptor &&
33
- Reflect.getOwnPropertyDescriptor(target, decoratorKey)
34
- ? Reflect.getOwnPropertyDescriptor(target, decoratorKey).value
35
- : target[decoratorKey];
31
+ var decorators = reflectionCapabilities.annotations(target);
36
32
  if (!decorators || decorators.length === 0) {
37
33
  return null;
38
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/angular",
3
- "version": "6.5.0-alpha.10",
3
+ "version": "6.5.0-alpha.14",
4
4
  "description": "Storybook for Angular: Develop Angular Components in isolation with Hot Reloading.",
5
5
  "keywords": [
6
6
  "storybook"
@@ -45,15 +45,15 @@
45
45
  "prepare": "node ../../scripts/prepare.js"
46
46
  },
47
47
  "dependencies": {
48
- "@storybook/addons": "6.5.0-alpha.10",
49
- "@storybook/api": "6.5.0-alpha.10",
50
- "@storybook/core": "6.5.0-alpha.10",
51
- "@storybook/core-common": "6.5.0-alpha.10",
52
- "@storybook/core-events": "6.5.0-alpha.10",
48
+ "@storybook/addons": "6.5.0-alpha.14",
49
+ "@storybook/api": "6.5.0-alpha.14",
50
+ "@storybook/core": "6.5.0-alpha.14",
51
+ "@storybook/core-common": "6.5.0-alpha.14",
52
+ "@storybook/core-events": "6.5.0-alpha.14",
53
53
  "@storybook/csf": "0.0.2--canary.87bc651.0",
54
- "@storybook/node-logger": "6.5.0-alpha.10",
54
+ "@storybook/node-logger": "6.5.0-alpha.14",
55
55
  "@storybook/semver": "^7.3.2",
56
- "@storybook/store": "6.5.0-alpha.10",
56
+ "@storybook/store": "6.5.0-alpha.14",
57
57
  "@types/node": "^14.14.20 || ^16.0.0",
58
58
  "@types/webpack-env": "^1.16.0",
59
59
  "autoprefixer": "^9.8.6",
@@ -86,14 +86,12 @@
86
86
  "@angular/compiler": "^11.2.14",
87
87
  "@angular/compiler-cli": "^11.2.14",
88
88
  "@angular/core": "^11.2.14",
89
- "@angular/elements": "^11.2.14",
90
89
  "@angular/forms": "^11.2.14",
91
90
  "@angular/platform-browser": "^11.2.14",
92
91
  "@angular/platform-browser-dynamic": "^11.2.14",
93
92
  "@nrwl/workspace": "^11.6.3",
94
93
  "@types/autoprefixer": "^9.7.2",
95
94
  "@types/jest": "^26.0.16",
96
- "@webcomponents/custom-elements": "^1.4.3",
97
95
  "jest": "^26.6.3",
98
96
  "jest-preset-angular": "^8.3.2",
99
97
  "ts-jest": "^26.4.4"
@@ -107,13 +105,11 @@
107
105
  "@angular/compiler": ">=6.0.0",
108
106
  "@angular/compiler-cli": ">=6.0.0",
109
107
  "@angular/core": ">=6.0.0",
110
- "@angular/elements": ">=6.0.0",
111
108
  "@angular/forms": ">=6.0.0",
112
109
  "@angular/platform-browser": ">=6.0.0",
113
110
  "@angular/platform-browser-dynamic": ">=6.0.0",
114
111
  "@babel/core": "*",
115
112
  "@nrwl/workspace": ">=11.1.0",
116
- "@webcomponents/custom-elements": ">=1.4.3",
117
113
  "rxjs": "^6.0.0 || ^7.4.0",
118
114
  "typescript": "^3.4.0 || >=4.0.0",
119
115
  "zone.js": "^0.8.29 || ^0.9.0 || ^0.10.0 || ^0.11.0"
@@ -122,14 +118,8 @@
122
118
  "@angular/cli": {
123
119
  "optional": true
124
120
  },
125
- "@angular/elements": {
126
- "optional": true
127
- },
128
121
  "@nrwl/workspace": {
129
122
  "optional": true
130
- },
131
- "@webcomponents/custom-elements": {
132
- "optional": true
133
123
  }
134
124
  },
135
125
  "engines": {
@@ -139,5 +129,5 @@
139
129
  "access": "public"
140
130
  },
141
131
  "builders": "dist/ts3.9/builders/builders.json",
142
- "gitHead": "9f7d260e82218d8bbf4fedda39e34d2e9d9813a3"
132
+ "gitHead": "24b50ac6f5f3f5e03e020144f5e0fb5dfe2e0dbe"
143
133
  }