@rhtml/modifiers 0.0.103 → 0.0.104

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.
@@ -31,7 +31,7 @@ IfOperator = __decorate([
31
31
  custom_attributes_1.Modifier({
32
32
  selector: 'ngIf',
33
33
  registry() {
34
- return new custom_attributes_1.CustomAttributeRegistry(this.shadowRoot);
34
+ return new custom_attributes_1.CustomAttributeRegistry(this);
35
35
  }
36
36
  })
37
37
  ], IfOperator);
@@ -1 +1 @@
1
- {"version":3,"file":"if.js","sourceRoot":"","sources":["../../src/angular/if.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gEAIkC;AAQlC,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,6BAAS;IACvC,MAAM;QACJ,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;IAED,SAAS;QACP,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;IACpC,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;IAED,QAAQ;QACN,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE;YACzB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;SACnC;aAAM;YACL,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;SACrC;IACH,CAAC;CACF,CAAA;AApBY,UAAU;IANtB,4BAAQ,CAAC;QACR,QAAQ,EAAE,MAAM;QAChB,QAAQ;YACN,OAAO,IAAI,2CAAuB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACtD,CAAC;KACF,CAAC;GACW,UAAU,CAoBtB;AApBY,gCAAU"}
1
+ {"version":3,"file":"if.js","sourceRoot":"","sources":["../../src/angular/if.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gEAIkC;AAQlC,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,6BAAS;IACvC,MAAM;QACJ,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;IAED,SAAS;QACP,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;IACpC,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;IAED,QAAQ;QACN,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE;YACzB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;SACnC;aAAM;YACL,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;SACrC;IACH,CAAC;CACF,CAAA;AApBY,UAAU;IANtB,4BAAQ,CAAC;QACR,QAAQ,EAAE,MAAM;QAChB,QAAQ;YACN,OAAO,IAAI,2CAAuB,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;GACW,UAAU,CAoBtB;AApBY,gCAAU"}
@@ -1,2 +1,2 @@
1
- import { IfOperator } from './if';
2
- export declare const AngularLayout: (typeof IfOperator)[];
1
+ import { Registry } from './registry';
2
+ export declare const AngularLayout: (typeof Registry)[];
@@ -2,5 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AngularLayout = void 0;
4
4
  const if_1 = require("./if");
5
- exports.AngularLayout = [if_1.IfOperator];
5
+ const ng_for_1 = require("./ng-for");
6
+ const registry_1 = require("./registry");
7
+ exports.AngularLayout = [registry_1.Registry, if_1.IfOperator, ng_for_1.NgFor];
6
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/angular/index.ts"],"names":[],"mappings":";;;AAAA,6BAAkC;AAErB,QAAA,aAAa,GAAG,CAAC,eAAU,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/angular/index.ts"],"names":[],"mappings":";;;AAAA,6BAAkC;AAClC,qCAAiC;AACjC,yCAAsC;AAEzB,QAAA,aAAa,GAAG,CAAC,mBAAQ,EAAE,eAAU,EAAE,cAAK,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Attribute } from '@rhtml/custom-attributes';
2
+ export declare class NgFor extends Attribute {
3
+ ngFor: string;
4
+ regexes: RegExp[];
5
+ OnInit(): void;
6
+ OnDestroy(): void;
7
+ OnUpdate(): void;
8
+ private interpolate;
9
+ modify(): void;
10
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.NgFor = void 0;
13
+ const custom_attributes_1 = require("@rhtml/custom-attributes");
14
+ const lit_html_1 = require("@rxdi/lit-html");
15
+ let NgFor = class NgFor extends custom_attributes_1.Attribute {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.regexes = [/\${[^{]+}/g, /\@\{(.*?)(?!\@\{)\}/g, /{([^}]+)}/g];
19
+ }
20
+ OnInit() {
21
+ this.modify();
22
+ }
23
+ OnDestroy() {
24
+ //
25
+ }
26
+ OnUpdate() {
27
+ this.modify();
28
+ }
29
+ interpolate(object, string) {
30
+ return string.replace(this.regexes[2], match => match
31
+ .slice(2, -1)
32
+ .trim()
33
+ .split('.')
34
+ .reduce((el, k) => String(el[k]), object));
35
+ }
36
+ modify() {
37
+ const [, , , items] = this.ngFor.split(' ');
38
+ const template = this.element.innerHTML;
39
+ this.element.innerHTML = '';
40
+ lit_html_1.render(lit_html_1.html `
41
+ <r-for .of=${this.parent[items]}>
42
+ <r-let
43
+ .item=${i => lit_html_1.unsafeHTML(this.interpolate(i, template))}
44
+ ></r-let>
45
+ </r-for>
46
+ `, this.element);
47
+ }
48
+ };
49
+ __decorate([
50
+ custom_attributes_1.Input(),
51
+ __metadata("design:type", String)
52
+ ], NgFor.prototype, "ngFor", void 0);
53
+ NgFor = __decorate([
54
+ custom_attributes_1.Modifier({
55
+ selector: 'ngFor'
56
+ })
57
+ ], NgFor);
58
+ exports.NgFor = NgFor;
59
+ //# sourceMappingURL=ng-for.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ng-for.js","sourceRoot":"","sources":["../../src/angular/ng-for.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gEAAsE;AACtE,6CAA0D;AAK1D,IAAa,KAAK,GAAlB,MAAa,KAAM,SAAQ,6BAAS;IAApC;;QAIE,YAAO,GAAG,CAAC,YAAY,EAAE,sBAAsB,EAAE,YAAY,CAAC,CAAC;IAuCjE,CAAC;IArCC,MAAM;QACJ,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,SAAS;QACP,EAAE;IACJ,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAEO,WAAW,CAAC,MAAM,EAAE,MAAc;QACxC,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAC7C,KAAK;aACF,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aACZ,IAAI,EAAE;aACN,KAAK,CAAC,GAAG,CAAC;aACV,MAAM,CAAC,CAAC,EAAE,EAAE,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CACpD,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,MAAM,CAAC,EAAE,AAAD,EAAG,AAAD,EAAG,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC;QAC5B,iBAAM,CACJ,eAAI,CAAA;qBACW,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;;oBAEnB,CAAC,CAAC,EAAE,CAAC,qBAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;;;OAG3D,EACD,IAAI,CAAC,OAAO,CACb,CAAC;IACJ,CAAC;CACF,CAAA;AAzCC;IADC,yBAAK,EAAE;;oCACM;AAFH,KAAK;IAHjB,4BAAQ,CAAC;QACR,QAAQ,EAAE,OAAO;KAClB,CAAC;GACW,KAAK,CA2CjB;AA3CY,sBAAK"}
@@ -0,0 +1,3 @@
1
+ import { Attribute } from '@rhtml/custom-attributes';
2
+ export declare class Registry extends Attribute {
3
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Registry = void 0;
10
+ const custom_attributes_1 = require("@rhtml/custom-attributes");
11
+ let Registry = class Registry extends custom_attributes_1.Attribute {
12
+ };
13
+ Registry = __decorate([
14
+ custom_attributes_1.Modifier({
15
+ selector: 'registry',
16
+ registry() {
17
+ return new custom_attributes_1.CustomAttributeRegistry(this);
18
+ }
19
+ })
20
+ ], Registry);
21
+ exports.Registry = Registry;
22
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/angular/registry.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gEAIkC;AAQlC,IAAa,QAAQ,GAArB,MAAa,QAAS,SAAQ,6BAAS;CAAG,CAAA;AAA7B,QAAQ;IANpB,4BAAQ,CAAC;QACR,QAAQ,EAAE,UAAU;QACpB,QAAQ;YACN,OAAO,IAAI,2CAAuB,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;GACW,QAAQ,CAAqB;AAA7B,4BAAQ"}
@@ -1,10 +1,6 @@
1
1
  import { Flex } from './flex';
2
- import { FlexAlign } from './flex-align';
3
2
  import { FlexFill } from './flex-fill';
4
- import { FlexOffset } from './flex-offset';
5
3
  import { FlexOrder } from './flex-order';
6
- import { Layout } from './layout';
7
- import { LayoutAlign } from './layout-align';
8
- import { LayoutGap } from './layout-gap';
4
+ import { Registry } from './registry';
9
5
  export * from './layout';
10
- export declare const FlexLayout: (typeof Flex | typeof FlexAlign | typeof FlexFill | typeof FlexOffset | typeof FlexOrder | typeof Layout | typeof LayoutAlign | typeof LayoutGap)[];
6
+ export declare const FlexLayout: (typeof Flex | typeof FlexFill | typeof FlexOrder | typeof Registry)[];
@@ -19,8 +19,10 @@ const flex_order_1 = require("./flex-order");
19
19
  const layout_1 = require("./layout");
20
20
  const layout_align_1 = require("./layout-align");
21
21
  const layout_gap_1 = require("./layout-gap");
22
+ const registry_1 = require("./registry");
22
23
  __exportStar(require("./layout"), exports);
23
24
  exports.FlexLayout = [
25
+ registry_1.Registry,
24
26
  layout_1.Layout,
25
27
  layout_align_1.LayoutAlign,
26
28
  layout_gap_1.LayoutGap,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iCAA8B;AAC9B,6CAAyC;AACzC,2CAAuC;AACvC,+CAA2C;AAC3C,6CAAyC;AACzC,qCAAkC;AAClC,iDAA6C;AAC7C,6CAAyC;AAEzC,2CAAyB;AAEZ,QAAA,UAAU,GAAG;IACxB,eAAM;IACN,0BAAW;IACX,sBAAS;IACT,oBAAQ;IACR,WAAI;IACJ,sBAAS;IACT,wBAAU;IACV,sBAAS;CACV,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iCAA8B;AAC9B,6CAAyC;AACzC,2CAAuC;AACvC,+CAA2C;AAC3C,6CAAyC;AACzC,qCAAkC;AAClC,iDAA6C;AAC7C,6CAAyC;AACzC,yCAAsC;AAEtC,2CAAyB;AAEZ,QAAA,UAAU,GAAG;IACxB,mBAAQ;IACR,eAAM;IACN,0BAAW;IACX,sBAAS;IACT,oBAAQ;IACR,WAAI;IACJ,sBAAS;IACT,wBAAU;IACV,sBAAS;CACV,CAAC"}
@@ -41,10 +41,7 @@ let Layout = class Layout extends custom_attributes_1.Attribute {
41
41
  };
42
42
  Layout = __decorate([
43
43
  custom_attributes_1.Modifier({
44
- selector: 'fxLayout',
45
- registry() {
46
- return new custom_attributes_1.CustomAttributeRegistry(this.shadowRoot);
47
- }
44
+ selector: 'fxLayout'
48
45
  })
49
46
  ], Layout);
50
47
  exports.Layout = Layout;
@@ -1 +1 @@
1
- {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/layout/layout.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gEAIkC;AAclC,IAAa,MAAM,GAAnB,MAAa,MAAO,SAAQ,6BAAiB;IAA7C;;QACE,UAAK,GAAG,KAAK,CAAC;IA8BhB,CAAC;IA5BC,MAAM;QACJ,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,SAAS;QACP,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAEO,KAAK;QACX,IAAI,CAAC,SAAS,CAAC;YACb,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,IAAI;YACjB,OAAO,EAAE,IAAI;SACd,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IACO,MAAM;QACZ,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC;QACvC,IAAI,CAAC,SAAS,CAAC;YACb,YAAY,EAAE,MAAM;YACpB,WAAW,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,QAAQ;YACxE,OAAO,EAAE,MAAM;SAChB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;CACF,CAAA;AA/BY,MAAM;IANlB,4BAAQ,CAAC;QACR,QAAQ,EAAE,UAAU;QACpB,QAAQ;YACN,OAAO,IAAI,2CAAuB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACtD,CAAC;KACF,CAAC;GACW,MAAM,CA+BlB;AA/BY,wBAAM"}
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/layout/layout.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gEAA+D;AAW/D,IAAa,MAAM,GAAnB,MAAa,MAAO,SAAQ,6BAAiB;IAA7C;;QACE,UAAK,GAAG,KAAK,CAAC;IA8BhB,CAAC;IA5BC,MAAM;QACJ,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,SAAS;QACP,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAEO,KAAK;QACX,IAAI,CAAC,SAAS,CAAC;YACb,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,IAAI;YACjB,OAAO,EAAE,IAAI;SACd,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IACO,MAAM;QACZ,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC;QACvC,IAAI,CAAC,SAAS,CAAC;YACb,YAAY,EAAE,MAAM;YACpB,WAAW,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,QAAQ;YACxE,OAAO,EAAE,MAAM;SAChB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;CACF,CAAA;AA/BY,MAAM;IAHlB,4BAAQ,CAAC;QACR,QAAQ,EAAE,UAAU;KACrB,CAAC;GACW,MAAM,CA+BlB;AA/BY,wBAAM"}
@@ -0,0 +1,3 @@
1
+ import { Attribute } from '@rhtml/custom-attributes';
2
+ export declare class Registry extends Attribute {
3
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Registry = void 0;
10
+ const custom_attributes_1 = require("@rhtml/custom-attributes");
11
+ let Registry = class Registry extends custom_attributes_1.Attribute {
12
+ };
13
+ Registry = __decorate([
14
+ custom_attributes_1.Modifier({
15
+ selector: 'registry',
16
+ registry() {
17
+ return new custom_attributes_1.CustomAttributeRegistry(this);
18
+ }
19
+ })
20
+ ], Registry);
21
+ exports.Registry = Registry;
22
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/layout/registry.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gEAIkC;AAQlC,IAAa,QAAQ,GAArB,MAAa,QAAS,SAAQ,6BAAS;CAAG,CAAA;AAA7B,QAAQ;IANpB,4BAAQ,CAAC;QACR,QAAQ,EAAE,UAAU;QACpB,QAAQ;YACN,OAAO,IAAI,2CAAuB,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;GACW,QAAQ,CAAqB;AAA7B,4BAAQ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhtml/modifiers",
3
- "version": "0.0.103",
3
+ "version": "0.0.104",
4
4
  "description": "Reactive HyperText Markup Language",
5
5
  "scripts": {
6
6
  "start": "npx parcel ./examples/index.html --out-dir build/examples",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@rxdi/lit-html": "^0.7.133",
20
- "@rhtml/custom-attributes": "0.0.103"
20
+ "@rhtml/custom-attributes": "0.0.104"
21
21
  },
22
22
  "devDependencies": {
23
23
  "eslint": "^6.7.2",
package/src/angular/if.ts CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  @Modifier({
8
8
  selector: 'ngIf',
9
9
  registry(this) {
10
- return new CustomAttributeRegistry(this.shadowRoot);
10
+ return new CustomAttributeRegistry(this);
11
11
  }
12
12
  })
13
13
  export class IfOperator extends Attribute {
@@ -1,3 +1,5 @@
1
1
  import { IfOperator } from './if';
2
+ import { NgFor } from './ng-for';
3
+ import { Registry } from './registry';
2
4
 
3
- export const AngularLayout = [IfOperator];
5
+ export const AngularLayout = [Registry, IfOperator, NgFor];
@@ -0,0 +1,50 @@
1
+ import { Attribute, Input, Modifier } from '@rhtml/custom-attributes';
2
+ import { html, render, unsafeHTML } from '@rxdi/lit-html';
3
+
4
+ @Modifier({
5
+ selector: 'ngFor'
6
+ })
7
+ export class NgFor extends Attribute {
8
+ @Input()
9
+ ngFor: string;
10
+
11
+ regexes = [/\${[^{]+}/g, /\@\{(.*?)(?!\@\{)\}/g, /{([^}]+)}/g];
12
+
13
+ OnInit() {
14
+ this.modify();
15
+ }
16
+
17
+ OnDestroy() {
18
+ //
19
+ }
20
+
21
+ OnUpdate() {
22
+ this.modify();
23
+ }
24
+
25
+ private interpolate(object, string: string) {
26
+ return string.replace(this.regexes[2], match =>
27
+ match
28
+ .slice(2, -1)
29
+ .trim()
30
+ .split('.')
31
+ .reduce((el, k: string) => String(el[k]), object)
32
+ );
33
+ }
34
+
35
+ modify() {
36
+ const [, , , items] = this.ngFor.split(' ');
37
+ const template = this.element.innerHTML;
38
+ this.element.innerHTML = '';
39
+ render(
40
+ html`
41
+ <r-for .of=${this.parent[items]}>
42
+ <r-let
43
+ .item=${i => unsafeHTML(this.interpolate(i, template))}
44
+ ></r-let>
45
+ </r-for>
46
+ `,
47
+ this.element
48
+ );
49
+ }
50
+ }
@@ -0,0 +1,13 @@
1
+ import {
2
+ Attribute,
3
+ CustomAttributeRegistry,
4
+ Modifier
5
+ } from '@rhtml/custom-attributes';
6
+
7
+ @Modifier({
8
+ selector: 'registry',
9
+ registry(this) {
10
+ return new CustomAttributeRegistry(this);
11
+ }
12
+ })
13
+ export class Registry extends Attribute {}
@@ -6,10 +6,12 @@ import { FlexOrder } from './flex-order';
6
6
  import { Layout } from './layout';
7
7
  import { LayoutAlign } from './layout-align';
8
8
  import { LayoutGap } from './layout-gap';
9
+ import { Registry } from './registry';
9
10
 
10
11
  export * from './layout';
11
12
 
12
13
  export const FlexLayout = [
14
+ Registry,
13
15
  Layout,
14
16
  LayoutAlign,
15
17
  LayoutGap,
@@ -1,8 +1,4 @@
1
- import {
2
- Attribute,
3
- CustomAttributeRegistry,
4
- Modifier
5
- } from '@rhtml/custom-attributes';
1
+ import { Attribute, Modifier } from '@rhtml/custom-attributes';
6
2
 
7
3
  interface Styles {
8
4
  'flex-flow': string;
@@ -11,10 +7,7 @@ interface Styles {
11
7
  }
12
8
 
13
9
  @Modifier({
14
- selector: 'fxLayout',
15
- registry(this) {
16
- return new CustomAttributeRegistry(this.shadowRoot);
17
- }
10
+ selector: 'fxLayout'
18
11
  })
19
12
  export class Layout extends Attribute<Styles> {
20
13
  value = 'row';
@@ -0,0 +1,13 @@
1
+ import {
2
+ Attribute,
3
+ CustomAttributeRegistry,
4
+ Modifier
5
+ } from '@rhtml/custom-attributes';
6
+
7
+ @Modifier({
8
+ selector: 'registry',
9
+ registry(this) {
10
+ return new CustomAttributeRegistry(this);
11
+ }
12
+ })
13
+ export class Registry extends Attribute {}