@rhtml/modifiers 0.0.89 → 0.0.90

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.
@@ -0,0 +1,9 @@
1
+ import { LitElement, TemplateResult } from '@rxdi/lit-html';
2
+ export declare enum Attributes {
3
+ NgIf = "ngIf"
4
+ }
5
+ export declare class AngularLayout extends LitElement {
6
+ self: LitElement;
7
+ OnUpdate(): void;
8
+ static modifier(template: TemplateResult): TemplateResult;
9
+ }
@@ -0,0 +1,58 @@
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.AngularLayout = exports.Attributes = void 0;
13
+ const lit_html_1 = require("@rxdi/lit-html");
14
+ const helpers_1 = require("../helpers");
15
+ var Attributes;
16
+ (function (Attributes) {
17
+ Attributes["NgIf"] = "ngIf";
18
+ })(Attributes = exports.Attributes || (exports.Attributes = {}));
19
+ function recursion(div) {
20
+ const ngIf = div.getAttribute(Attributes.NgIf);
21
+ if (helpers_1.isAttribute(ngIf)) {
22
+ helpers_1.subscribeToAttributeChanges(Attributes.NgIf)(element => (element.style.display =
23
+ element.getAttribute(Attributes.NgIf) === 'true' ? 'block' : 'none'))(div);
24
+ }
25
+ const divs = [...div.children];
26
+ for (const div of divs) {
27
+ recursion.call(this, div);
28
+ }
29
+ }
30
+ let AngularLayout = class AngularLayout extends lit_html_1.LitElement {
31
+ OnUpdate() {
32
+ const slot = this.shadowRoot.querySelector('slot');
33
+ for (const div of [...slot === null || slot === void 0 ? void 0 : slot.assignedElements()]) {
34
+ recursion.call(this.self, div);
35
+ }
36
+ }
37
+ static modifier(template) {
38
+ return lit_html_1.html `
39
+ <angular-layout .self=${this}>${template}</angular-layout>
40
+ `;
41
+ }
42
+ };
43
+ __decorate([
44
+ lit_html_1.property(),
45
+ __metadata("design:type", lit_html_1.LitElement)
46
+ ], AngularLayout.prototype, "self", void 0);
47
+ AngularLayout = __decorate([
48
+ lit_html_1.Component({
49
+ selector: 'angular-layout',
50
+ template() {
51
+ return lit_html_1.html `
52
+ <slot></slot>
53
+ `;
54
+ }
55
+ })
56
+ ], AngularLayout);
57
+ exports.AngularLayout = AngularLayout;
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/angular/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAMwB;AAExB,wCAAsE;AAEtE,IAAY,UAEX;AAFD,WAAY,UAAU;IACpB,2BAAa,CAAA;AACf,CAAC,EAFW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAErB;AAED,SAAS,SAAS,CAAC,GAAgB;IACjC,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAE/C,IAAI,qBAAW,CAAC,IAAI,CAAC,EAAE;QACrB,qCAA2B,CAAC,UAAU,CAAC,IAAI,CAAC,CAC1C,OAAO,CAAC,EAAE,CACR,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO;YACpB,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CACzE,CAAC,GAAG,CAAC,CAAC;KACR;IAED,MAAM,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAkB,CAAC;IAChD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;KAC3B;AACH,CAAC;AAUD,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,qBAAU;IAI3C,QAAQ;QACN,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,gBAAgB,EAAE,CAAC,EAAE;YAC/C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAY,CAAC,CAAC;SACzC;IACH,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,QAAwB;QAC7C,OAAO,eAAI,CAAA;8BACe,IAAI,IAAI,QAAQ;KACzC,CAAC;IACJ,CAAC;CACF,CAAA;AAdC;IADC,mBAAQ,EAAE;8BACL,qBAAU;2CAAC;AAFN,aAAa;IARzB,oBAAS,CAAC;QACT,QAAQ,EAAE,gBAAgB;QAC1B,QAAQ;YACN,OAAO,eAAI,CAAA;;KAEV,CAAC;QACJ,CAAC;KACF,CAAC;GACW,aAAa,CAgBzB;AAhBY,sCAAa"}
@@ -0,0 +1,2 @@
1
+ export declare const isAttribute: (attr: string) => boolean | string;
2
+ export declare const subscribeToAttributeChanges: (name: string) => (fn: (element: HTMLElement) => void) => (element: HTMLElement) => void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.subscribeToAttributeChanges = exports.isAttribute = void 0;
4
+ exports.isAttribute = (attr) => typeof attr === 'string' && (attr || attr === '');
5
+ exports.subscribeToAttributeChanges = (name) => (fn) => (element) => {
6
+ fn(element);
7
+ return new MutationObserver(() => fn(element)).observe(element, {
8
+ attributeFilter: [name.toLocaleLowerCase()],
9
+ attributes: true
10
+ });
11
+ };
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,CAAC,IAAY,EAAoB,EAAE,CAC5D,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;AAEvC,QAAA,2BAA2B,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAC3D,EAAkC,EAClC,EAAE,CAAC,CAAC,OAAoB,EAAE,EAAE;IAC5B,EAAE,CAAC,OAAO,CAAC,CAAC;IACZ,OAAO,IAAI,gBAAgB,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;QAC9D,eAAe,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC3C,UAAU,EAAE,IAAI;KACjB,CAAC,CAAC;AACL,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,3 @@
1
- import { LitElement, TemplateResult } from '@rxdi/lit-html';
2
- import { AsyncDirective } from '@rxdi/lit-html/dist/lit-html/async-directive';
3
- import { AttributePart } from '@rxdi/lit-html/dist/lit-html/directive';
4
- export declare class LayoutDirective extends AsyncDirective {
5
- render(): symbol;
6
- update(part: AttributePart): symbol;
7
- }
8
- export declare class FlexLayout extends LitElement {
9
- OnUpdate(): void;
10
- static modifier(template: TemplateResult): TemplateResult;
11
- }
12
- export declare const layout: import("@rxdi/lit-html/dist/lit-html/directive").DirectiveResult<typeof LayoutDirective>;
1
+ export * from './angular';
2
+ export * from './helpers';
3
+ export * from './layout';
package/dist/index.js CHANGED
@@ -1,52 +1,16 @@
1
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;
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
7
11
  };
8
12
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.layout = exports.FlexLayout = exports.LayoutDirective = void 0;
10
- const lit_html_1 = require("@rxdi/lit-html");
11
- const async_directive_1 = require("@rxdi/lit-html/dist/lit-html/async-directive");
12
- const directive_1 = require("@rxdi/lit-html/dist/lit-html/directive");
13
- const modifiers_1 = require("./modifiers");
14
- class LayoutDirective extends async_directive_1.AsyncDirective {
15
- render() {
16
- return lit_html_1.noChange;
17
- }
18
- update(part) {
19
- const divs = [...part.element.children];
20
- for (const div of divs) {
21
- modifiers_1.recursion(div);
22
- }
23
- return this.render();
24
- }
25
- }
26
- exports.LayoutDirective = LayoutDirective;
27
- let FlexLayout = class FlexLayout extends lit_html_1.LitElement {
28
- OnUpdate() {
29
- const slot = this.shadowRoot.querySelector('slot');
30
- for (const div of [...slot === null || slot === void 0 ? void 0 : slot.assignedElements()]) {
31
- modifiers_1.recursion(div);
32
- }
33
- }
34
- static modifier(template) {
35
- return lit_html_1.html `
36
- <flex-layout>${template}</flex-layout>
37
- `;
38
- }
39
- };
40
- FlexLayout = __decorate([
41
- lit_html_1.Component({
42
- selector: 'flex-layout',
43
- template() {
44
- return lit_html_1.html `
45
- <slot></slot>
46
- `;
47
- }
48
- })
49
- ], FlexLayout);
50
- exports.FlexLayout = FlexLayout;
51
- exports.layout = directive_1.directive(LayoutDirective)();
13
+ __exportStar(require("./angular"), exports);
14
+ __exportStar(require("./helpers"), exports);
15
+ __exportStar(require("./layout"), exports);
52
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6CAMwB;AACxB,kFAA8E;AAC9E,sEAGgD;AAEhD,2CAAwC;AAExC,MAAa,eAAgB,SAAQ,gCAAc;IACjD,MAAM;QACJ,OAAO,mBAAQ,CAAC;IAClB,CAAC;IACD,MAAM,CAAC,IAAmB;QACxB,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAkB,CAAC;QACzD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,qBAAS,CAAC,GAAG,CAAC,CAAC;SAChB;QACD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACF;AAXD,0CAWC;AAUD,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,qBAAU;IACxC,QAAQ;QACN,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,gBAAgB,EAAE,CAAC,EAAE;YAC/C,qBAAS,CAAC,GAAY,CAAC,CAAC;SACzB;IACH,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,QAAwB;QAC7C,OAAO,eAAI,CAAA;qBACM,QAAQ;KACxB,CAAC;IACJ,CAAC;CACF,CAAA;AAbY,UAAU;IARtB,oBAAS,CAAC;QACT,QAAQ,EAAE,aAAa;QACvB,QAAQ;YACN,OAAO,eAAI,CAAA;;KAEV,CAAC;QACJ,CAAC;KACF,CAAC;GACW,UAAU,CAatB;AAbY,gCAAU;AAeV,QAAA,MAAM,GAAG,qBAAS,CAAC,eAAe,CAAC,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B;AAC1B,2CAAyB"}
@@ -0,0 +1,6 @@
1
+ import { LitElement, TemplateResult } from '@rxdi/lit-html';
2
+ export declare class FlexLayout extends LitElement {
3
+ self: LitElement;
4
+ OnUpdate(): void;
5
+ static modifier(template: TemplateResult): TemplateResult;
6
+ }
@@ -0,0 +1,43 @@
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.FlexLayout = void 0;
13
+ const lit_html_1 = require("@rxdi/lit-html");
14
+ const modifiers_1 = require("./modifiers");
15
+ let FlexLayout = class FlexLayout extends lit_html_1.LitElement {
16
+ OnUpdate() {
17
+ const slot = this.shadowRoot.querySelector('slot');
18
+ for (const div of [...slot === null || slot === void 0 ? void 0 : slot.assignedElements()]) {
19
+ modifiers_1.recursion.call(this.self, div);
20
+ }
21
+ }
22
+ static modifier(template) {
23
+ return lit_html_1.html `
24
+ <flex-layout .self=${this}>${template}</flex-layout>
25
+ `;
26
+ }
27
+ };
28
+ __decorate([
29
+ lit_html_1.property(),
30
+ __metadata("design:type", lit_html_1.LitElement)
31
+ ], FlexLayout.prototype, "self", void 0);
32
+ FlexLayout = __decorate([
33
+ lit_html_1.Component({
34
+ selector: 'flex-layout',
35
+ template() {
36
+ return lit_html_1.html `
37
+ <slot></slot>
38
+ `;
39
+ }
40
+ })
41
+ ], FlexLayout);
42
+ exports.FlexLayout = FlexLayout;
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAMwB;AAExB,2CAAwC;AAUxC,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,qBAAU;IAIxC,QAAQ;QACN,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,gBAAgB,EAAE,CAAC,EAAE;YAC/C,qBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAY,CAAC,CAAC;SACzC;IACH,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,QAAwB;QAC7C,OAAO,eAAI,CAAA;2BACY,IAAI,IAAI,QAAQ;KACtC,CAAC;IACJ,CAAC;CACF,CAAA;AAdC;IADC,mBAAQ,EAAE;8BACL,qBAAU;wCAAC;AAFN,UAAU;IARtB,oBAAS,CAAC;QACT,QAAQ,EAAE,aAAa;QACvB,QAAQ;YACN,OAAO,eAAI,CAAA;;KAEV,CAAC;QACJ,CAAC;KACF,CAAC;GACW,UAAU,CAgBtB;AAhBY,gCAAU"}
@@ -14,4 +14,4 @@ export declare const setChildrensFlexFill: (div: HTMLElement) => void;
14
14
  export declare const setChildrensFlex: (div: HTMLElement) => void;
15
15
  export declare const subscribeToAttributeChanges: (name: string) => (fn: (element: HTMLElement) => void) => (element: HTMLElement) => void;
16
16
  export declare const setFxLayout: (element: HTMLElement) => void;
17
- export declare const recursion: (div: HTMLElement) => void;
17
+ export declare function recursion(div: HTMLElement): void;
@@ -59,7 +59,7 @@ exports.setFxLayout = (element) => {
59
59
  element.style['display'] = 'flex';
60
60
  }
61
61
  };
62
- exports.recursion = (div) => {
62
+ function recursion(div) {
63
63
  const fxFlex = div.getAttribute(Attributes.FxFlex);
64
64
  const fxFlexFill = div.getAttribute(Attributes.FxFlexFill);
65
65
  const fxLayout = div.getAttribute(Attributes.FxLayout);
@@ -86,7 +86,8 @@ exports.recursion = (div) => {
86
86
  }
87
87
  const divs = [...div.children];
88
88
  for (const div of divs) {
89
- exports.recursion(div);
89
+ recursion.call(this, div);
90
90
  }
91
- };
91
+ }
92
+ exports.recursion = recursion;
92
93
  //# sourceMappingURL=modifiers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modifiers.js","sourceRoot":"","sources":["../../src/layout/modifiers.ts"],"names":[],"mappings":";;;AAkBA,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,+BAAiB,CAAA;IACjB,uCAAyB,CAAA;IACzB,6CAA+B,CAAA;IAC/B,yCAA2B,CAAA;AAC7B,CAAC,EANW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAMrB;AACD,4CAA4C;AAC5C,0DAA0D;AAE7C,QAAA,WAAW,GAAG,CAAC,IAAY,EAAoB,EAAE,CAC5D,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;AAEvC,QAAA,gBAAgB,GAAG,CAAC,OAAoB,EAAE,EAAE;IACvD,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACrE,IAAI,mBAAW,CAAC,aAAa,CAAC,EAAE;Q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AAtCD,8BAsCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhtml/modifiers",
3
- "version": "0.0.89",
3
+ "version": "0.0.90",
4
4
  "description": "Reactive HyperText Markup Language",
5
5
  "scripts": {
6
6
  "start": "npx parcel ./examples/index.html --out-dir build/examples",
@@ -0,0 +1,56 @@
1
+ import {
2
+ Component,
3
+ html,
4
+ LitElement,
5
+ property,
6
+ TemplateResult
7
+ } from '@rxdi/lit-html';
8
+
9
+ import { isAttribute, subscribeToAttributeChanges } from '../helpers';
10
+
11
+ export enum Attributes {
12
+ NgIf = 'ngIf'
13
+ }
14
+
15
+ function recursion(div: HTMLElement) {
16
+ const ngIf = div.getAttribute(Attributes.NgIf);
17
+
18
+ if (isAttribute(ngIf)) {
19
+ subscribeToAttributeChanges(Attributes.NgIf)(
20
+ element =>
21
+ (element.style.display =
22
+ element.getAttribute(Attributes.NgIf) === 'true' ? 'block' : 'none')
23
+ )(div);
24
+ }
25
+
26
+ const divs = [...div.children] as HTMLElement[];
27
+ for (const div of divs) {
28
+ recursion.call(this, div);
29
+ }
30
+ }
31
+
32
+ @Component({
33
+ selector: 'angular-layout',
34
+ template() {
35
+ return html`
36
+ <slot></slot>
37
+ `;
38
+ }
39
+ })
40
+ export class AngularLayout extends LitElement {
41
+ @property()
42
+ self: LitElement;
43
+
44
+ OnUpdate(): void {
45
+ const slot = this.shadowRoot.querySelector('slot');
46
+ for (const div of [...slot?.assignedElements()]) {
47
+ recursion.call(this.self, div as never);
48
+ }
49
+ }
50
+
51
+ public static modifier(template: TemplateResult): TemplateResult {
52
+ return html`
53
+ <angular-layout .self=${this}>${template}</angular-layout>
54
+ `;
55
+ }
56
+ }
@@ -0,0 +1,12 @@
1
+ export const isAttribute = (attr: string): boolean | string =>
2
+ typeof attr === 'string' && (attr || attr === '');
3
+
4
+ export const subscribeToAttributeChanges = (name: string) => (
5
+ fn: (element: HTMLElement) => void
6
+ ) => (element: HTMLElement) => {
7
+ fn(element);
8
+ return new MutationObserver(() => fn(element)).observe(element, {
9
+ attributeFilter: [name.toLocaleLowerCase()],
10
+ attributes: true
11
+ });
12
+ };
package/src/index.ts CHANGED
@@ -1,52 +1,3 @@
1
- import {
2
- Component,
3
- html,
4
- LitElement,
5
- noChange,
6
- TemplateResult
7
- } from '@rxdi/lit-html';
8
- import { AsyncDirective } from '@rxdi/lit-html/dist/lit-html/async-directive';
9
- import {
10
- AttributePart,
11
- directive
12
- } from '@rxdi/lit-html/dist/lit-html/directive';
13
-
14
- import { recursion } from './modifiers';
15
-
16
- export class LayoutDirective extends AsyncDirective {
17
- render(): symbol {
18
- return noChange;
19
- }
20
- update(part: AttributePart): symbol {
21
- const divs = [...part.element.children] as HTMLElement[];
22
- for (const div of divs) {
23
- recursion(div);
24
- }
25
- return this.render();
26
- }
27
- }
28
-
29
- @Component({
30
- selector: 'flex-layout',
31
- template() {
32
- return html`
33
- <slot></slot>
34
- `;
35
- }
36
- })
37
- export class FlexLayout extends LitElement {
38
- OnUpdate(): void {
39
- const slot = this.shadowRoot.querySelector('slot');
40
- for (const div of [...slot?.assignedElements()]) {
41
- recursion(div as never);
42
- }
43
- }
44
-
45
- public static modifier(template: TemplateResult): TemplateResult {
46
- return html`
47
- <flex-layout>${template}</flex-layout>
48
- `;
49
- }
50
- }
51
-
52
- export const layout = directive(LayoutDirective)();
1
+ export * from './angular';
2
+ export * from './helpers';
3
+ export * from './layout';
@@ -0,0 +1,35 @@
1
+ import {
2
+ Component,
3
+ html,
4
+ LitElement,
5
+ property,
6
+ TemplateResult
7
+ } from '@rxdi/lit-html';
8
+
9
+ import { recursion } from './modifiers';
10
+
11
+ @Component({
12
+ selector: 'flex-layout',
13
+ template() {
14
+ return html`
15
+ <slot></slot>
16
+ `;
17
+ }
18
+ })
19
+ export class FlexLayout extends LitElement {
20
+ @property()
21
+ self: LitElement;
22
+
23
+ OnUpdate(): void {
24
+ const slot = this.shadowRoot.querySelector('slot');
25
+ for (const div of [...slot?.assignedElements()]) {
26
+ recursion.call(this.self, div as never);
27
+ }
28
+ }
29
+
30
+ public static modifier(template: TemplateResult): TemplateResult {
31
+ return html`
32
+ <flex-layout .self=${this}>${template}</flex-layout>
33
+ `;
34
+ }
35
+ }
@@ -83,13 +83,12 @@ export const setFxLayout = (element: HTMLElement) => {
83
83
  }
84
84
  };
85
85
 
86
- export const recursion = (div: HTMLElement): void => {
86
+ export function recursion(div: HTMLElement) {
87
87
  const fxFlex = div.getAttribute(Attributes.FxFlex);
88
88
  const fxFlexFill = div.getAttribute(Attributes.FxFlexFill);
89
89
  const fxLayout = div.getAttribute(Attributes.FxLayout);
90
90
  const fxLayoutAlign = div.getAttribute(Attributes.FxLayoutAlign);
91
91
  const fxLayoutGap = div.getAttribute(Attributes.FxLayoutGap);
92
-
93
92
  if (isAttribute(fxFlex)) {
94
93
  subscribeToAttributeChanges(Attributes.FxFlex)(setChildrensFlex)(div);
95
94
  }
@@ -120,6 +119,6 @@ export const recursion = (div: HTMLElement): void => {
120
119
 
121
120
  const divs = [...div.children] as HTMLElement[];
122
121
  for (const div of divs) {
123
- recursion(div);
122
+ recursion.call(this, div);
124
123
  }
125
- };
124
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"modifiers.js","sourceRoot":"","sources":["../src/modifiers.ts"],"names":[],"mappings":";;;AAkBA,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,+BAAiB,CAAA;IACjB,uCAAyB,CAAA;IACzB,6CAA+B,CAAA;IAC/B,yCAA2B,CAAA;AAC7B,CAAC,EANW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAMrB;AACD,4CAA4C;AAC5C,0DAA0D;AAE7C,QAAA,WAAW,GAAG,CAAC,IAAY,EAAoB,EAAE,CAC5D,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;AAEvC,QAAA,gBAAgB,GAAG,CAAC,OAAoB,EAAE,EAAE;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