@rhtml/modifiers 0.0.89 → 0.0.92

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,12 @@
1
+ import { LitElement, OnDestroy, OnUpdate, TemplateResult } from '@rxdi/lit-html';
2
+ export declare class FlexLayout extends LitElement implements OnUpdate, OnDestroy {
3
+ child: LitElement;
4
+ private observables;
5
+ OnUpdate(): void;
6
+ OnDestroy(): void;
7
+ private unsubscribe;
8
+ private updateAttributes;
9
+ private isFxLayout;
10
+ private subscribe;
11
+ static modifier(template: TemplateResult): TemplateResult;
12
+ }
@@ -0,0 +1,75 @@
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
+ constructor() {
17
+ super(...arguments);
18
+ this.observables = [];
19
+ }
20
+ OnUpdate() {
21
+ this.updateAttributes();
22
+ }
23
+ OnDestroy() {
24
+ this.unsubscribe();
25
+ }
26
+ unsubscribe() {
27
+ for (const observable of this.observables) {
28
+ observable.disconnect();
29
+ }
30
+ this.observables = [];
31
+ }
32
+ updateAttributes() {
33
+ const slot = this.shadowRoot.querySelector('slot');
34
+ for (const element of [...slot === null || slot === void 0 ? void 0 : slot.assignedElements()]) {
35
+ if (this.isFxLayout(element)) {
36
+ this.unsubscribe();
37
+ this.subscribe(element);
38
+ }
39
+ modifiers_1.recursion.call(this.child, element);
40
+ }
41
+ }
42
+ isFxLayout(element) {
43
+ return element.getAttribute(modifiers_1.Attributes.FxLayout.toLowerCase());
44
+ }
45
+ subscribe(element) {
46
+ this.unsubscribe();
47
+ const observer = new MutationObserver(() => this.updateAttributes());
48
+ observer.observe(element, {
49
+ subtree: true,
50
+ childList: true
51
+ });
52
+ this.observables.push(observer);
53
+ }
54
+ static modifier(template) {
55
+ return lit_html_1.html `
56
+ <flex-layout .child=${this}>${template}</flex-layout>
57
+ `;
58
+ }
59
+ };
60
+ __decorate([
61
+ lit_html_1.property(),
62
+ __metadata("design:type", lit_html_1.LitElement)
63
+ ], FlexLayout.prototype, "child", void 0);
64
+ FlexLayout = __decorate([
65
+ lit_html_1.Component({
66
+ selector: 'flex-layout',
67
+ template() {
68
+ return lit_html_1.html `
69
+ <slot></slot>
70
+ `;
71
+ }
72
+ })
73
+ ], FlexLayout);
74
+ exports.FlexLayout = FlexLayout;
75
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAQwB;AAExB,2CAAoD;AAUpD,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,qBAAU;IAA1C;;QAIU,gBAAW,GAAuB,EAAE,CAAC;IA+C/C,CAAC;IA7CC,QAAQ;QACN,IAAI,CAAC,gBAAgB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,QAAQ;KACvC,CAAC;IACJ,CAAC;CACF,CAAA;AAjDC;IADC,mBAAQ,EAAE;8BACJ,qBAAU;yCAAC;AAFP,UAAU;IARtB,oBAAS,CAAC;QACT,QAAQ,EAAE,aAAa;QACvB,QAAQ;YACN,OAAO,eAAI,CAAA;;KAEV,CAAC;QACJ,CAAC;KACF,CAAC;GACW,UAAU,CAmDtB;AAnDY,gCAAU"}
@@ -6,12 +6,18 @@ export declare enum Attributes {
6
6
  FxFlex = "fxFlex",
7
7
  FxFlexFill = "fxFlexFill",
8
8
  FxLayoutAlign = "fxLayoutAlign",
9
- FxLayoutGap = "fxLayoutGap"
9
+ FxLayoutGap = "fxLayoutGap",
10
+ FxFlexAlign = "fxFlexAlign",
11
+ FxFlexOffset = "fxFlexOffset",
12
+ FxFlexOrder = "fxFlexOrder"
10
13
  }
11
14
  export declare const isAttribute: (attr: string) => boolean | string;
12
15
  export declare const setFxLayoutAlign: (element: HTMLElement) => void;
13
16
  export declare const setChildrensFlexFill: (div: HTMLElement) => void;
14
17
  export declare const setChildrensFlex: (div: HTMLElement) => void;
18
+ export declare const setFlexAlign: (div: HTMLElement) => void;
19
+ export declare const setFlexOffset: (div: HTMLElement) => void;
20
+ export declare const setFlexOrder: (div: HTMLElement) => void;
15
21
  export declare const subscribeToAttributeChanges: (name: string) => (fn: (element: HTMLElement) => void) => (element: HTMLElement) => void;
16
22
  export declare const setFxLayout: (element: HTMLElement) => void;
17
- export declare const recursion: (div: HTMLElement) => void;
23
+ export declare function recursion(div: HTMLElement): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recursion = exports.setFxLayout = exports.subscribeToAttributeChanges = exports.setChildrensFlex = exports.setChildrensFlexFill = exports.setFxLayoutAlign = exports.isAttribute = exports.Attributes = void 0;
3
+ exports.recursion = exports.setFxLayout = exports.subscribeToAttributeChanges = exports.setFlexOrder = exports.setFlexOffset = exports.setFlexAlign = exports.setChildrensFlex = exports.setChildrensFlexFill = exports.setFxLayoutAlign = exports.isAttribute = exports.Attributes = void 0;
4
4
  var Attributes;
5
5
  (function (Attributes) {
6
6
  Attributes["FxLayout"] = "fxLayout";
@@ -8,6 +8,9 @@ var Attributes;
8
8
  Attributes["FxFlexFill"] = "fxFlexFill";
9
9
  Attributes["FxLayoutAlign"] = "fxLayoutAlign";
10
10
  Attributes["FxLayoutGap"] = "fxLayoutGap";
11
+ Attributes["FxFlexAlign"] = "fxFlexAlign";
12
+ Attributes["FxFlexOffset"] = "fxFlexOffset";
13
+ Attributes["FxFlexOrder"] = "fxFlexOrder";
11
14
  })(Attributes = exports.Attributes || (exports.Attributes = {}));
12
15
  /* TODO we need to update to typescript 4 */
13
16
  // export type FxLayoutAlign = `${MainAxis} ${CrossAxis}`;
@@ -16,8 +19,10 @@ exports.setFxLayoutAlign = (element) => {
16
19
  const fxLayoutAlign = element.getAttribute(Attributes.FxLayoutAlign);
17
20
  if (exports.isAttribute(fxLayoutAlign)) {
18
21
  const [mainAxis, crossAxis] = fxLayoutAlign.split(' ');
19
- element.style['place-content'] = `${crossAxis} ${mainAxis}`;
20
- element.style['align-items'] = crossAxis;
22
+ element.style['place-content'] = crossAxis
23
+ ? `${crossAxis} ${mainAxis}`
24
+ : `${mainAxis} ${mainAxis}`;
25
+ element.style['align-items'] = crossAxis ? crossAxis : mainAxis;
21
26
  }
22
27
  element.style['display'] = 'flex';
23
28
  };
@@ -41,6 +46,27 @@ exports.setChildrensFlex = (div) => {
41
46
  }
42
47
  }
43
48
  };
49
+ exports.setFlexAlign = (div) => {
50
+ const fxFlexAlign = div.getAttribute(Attributes.FxFlexAlign);
51
+ if (exports.isAttribute(fxFlexAlign)) {
52
+ div.style['align-self'] = fxFlexAlign;
53
+ }
54
+ };
55
+ exports.setFlexOffset = (div) => {
56
+ const fxFlexOffset = div.getAttribute(Attributes.FxFlexOffset);
57
+ if (exports.isAttribute(fxFlexOffset)) {
58
+ div.style['margin-left'] = fxFlexOffset;
59
+ }
60
+ };
61
+ exports.setFlexOrder = (div) => {
62
+ const fxFlexOrder = div.getAttribute(Attributes.FxFlexOrder);
63
+ if (exports.isAttribute(fxFlexOrder)) {
64
+ div.style['order'] = fxFlexOrder;
65
+ }
66
+ else {
67
+ div.style['order'] = '0';
68
+ }
69
+ };
44
70
  exports.subscribeToAttributeChanges = (name) => (fn) => (element) => {
45
71
  fn(element);
46
72
  return new MutationObserver(() => fn(element)).observe(element, {
@@ -59,12 +85,24 @@ exports.setFxLayout = (element) => {
59
85
  element.style['display'] = 'flex';
60
86
  }
61
87
  };
62
- exports.recursion = (div) => {
88
+ function recursion(div) {
63
89
  const fxFlex = div.getAttribute(Attributes.FxFlex);
64
90
  const fxFlexFill = div.getAttribute(Attributes.FxFlexFill);
65
91
  const fxLayout = div.getAttribute(Attributes.FxLayout);
66
92
  const fxLayoutAlign = div.getAttribute(Attributes.FxLayoutAlign);
67
93
  const fxLayoutGap = div.getAttribute(Attributes.FxLayoutGap);
94
+ const fxFlexAlign = div.getAttribute(Attributes.FxFlexAlign);
95
+ const fxFlexOffset = div.getAttribute(Attributes.FxFlexOffset);
96
+ const fxFlexOrder = div.getAttribute(Attributes.FxFlexOrder);
97
+ if (exports.isAttribute(fxFlexOrder)) {
98
+ exports.subscribeToAttributeChanges(Attributes.FxFlexOrder)(exports.setFlexOrder)(div);
99
+ }
100
+ if (exports.isAttribute(fxFlexOffset)) {
101
+ exports.subscribeToAttributeChanges(Attributes.FxFlexAlign)(exports.setFlexOffset)(div);
102
+ }
103
+ if (exports.isAttribute(fxFlexAlign)) {
104
+ exports.subscribeToAttributeChanges(Attributes.FxFlexAlign)(exports.setFlexAlign)(div);
105
+ }
68
106
  if (exports.isAttribute(fxFlex)) {
69
107
  exports.subscribeToAttributeChanges(Attributes.FxFlex)(exports.setChildrensFlex)(div);
70
108
  }
@@ -86,7 +124,8 @@ exports.recursion = (div) => {
86
124
  }
87
125
  const divs = [...div.children];
88
126
  for (const div of divs) {
89
- exports.recursion(div);
127
+ recursion.call(this, div);
90
128
  }
91
- };
129
+ }
130
+ exports.recursion = recursion;
92
131
  //# sourceMappingURL=modifiers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modifiers.js","sourceRoot":"","sources":["../../src/layout/modifiers.ts"],"names":[],"mappings":";;;AAkBA,IAAY,UASX;AATD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,+BAAiB,CAAA;IACjB,uCAAyB,CAAA;IACzB,6CAA+B,CAAA;IAC/B,yCAA2B,CAAA;IAC3B,yCAA2B,CAAA;IAC3B,2CAA6B,CAAA;IAC7B,yCAA2B,CAAA;AAC7B,CAAC,EATW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QASrB;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;QAC9B,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvD,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,SAAS;YACxC,CAAC,CAAC,GAAG,SAAS,IAAI,QAAQ,EAAE;YAC5B,CAAC,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;KACjE;IACD,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;AACpC,CAAC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  {
2
2
  "name": "@rhtml/modifiers",
3
- "version": "0.0.89",
3
+ "version": "0.0.92",
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,72 @@
1
+ import {
2
+ Component,
3
+ html,
4
+ LitElement,
5
+ OnDestroy,
6
+ OnUpdate,
7
+ property,
8
+ TemplateResult
9
+ } from '@rxdi/lit-html';
10
+
11
+ import { Attributes, recursion } from './modifiers';
12
+
13
+ @Component({
14
+ selector: 'flex-layout',
15
+ template() {
16
+ return html`
17
+ <slot></slot>
18
+ `;
19
+ }
20
+ })
21
+ export class FlexLayout extends LitElement implements OnUpdate, OnDestroy {
22
+ @property()
23
+ child: LitElement;
24
+
25
+ private observables: MutationObserver[] = [];
26
+
27
+ OnUpdate(): void {
28
+ this.updateAttributes();
29
+ }
30
+
31
+ OnDestroy() {
32
+ this.unsubscribe();
33
+ }
34
+
35
+ private unsubscribe() {
36
+ for (const observable of this.observables) {
37
+ observable.disconnect();
38
+ }
39
+ this.observables = [];
40
+ }
41
+
42
+ private updateAttributes() {
43
+ const slot = this.shadowRoot.querySelector('slot');
44
+ for (const element of [...slot?.assignedElements()]) {
45
+ if (this.isFxLayout(element)) {
46
+ this.unsubscribe();
47
+ this.subscribe(element);
48
+ }
49
+ recursion.call(this.child, element);
50
+ }
51
+ }
52
+
53
+ private isFxLayout(element: Element) {
54
+ return element.getAttribute(Attributes.FxLayout.toLowerCase());
55
+ }
56
+
57
+ private subscribe(element: Element) {
58
+ this.unsubscribe();
59
+ const observer = new MutationObserver(() => this.updateAttributes());
60
+ observer.observe(element, {
61
+ subtree: true,
62
+ childList: true
63
+ });
64
+ this.observables.push(observer);
65
+ }
66
+
67
+ public static modifier(template: TemplateResult): TemplateResult {
68
+ return html`
69
+ <flex-layout .child=${this}>${template}</flex-layout>
70
+ `;
71
+ }
72
+ }
@@ -21,7 +21,10 @@ export enum Attributes {
21
21
  FxFlex = 'fxFlex',
22
22
  FxFlexFill = 'fxFlexFill',
23
23
  FxLayoutAlign = 'fxLayoutAlign',
24
- FxLayoutGap = 'fxLayoutGap'
24
+ FxLayoutGap = 'fxLayoutGap',
25
+ FxFlexAlign = 'fxFlexAlign',
26
+ FxFlexOffset = 'fxFlexOffset',
27
+ FxFlexOrder = 'fxFlexOrder'
25
28
  }
26
29
  /* TODO we need to update to typescript 4 */
27
30
  // export type FxLayoutAlign = `${MainAxis} ${CrossAxis}`;
@@ -33,8 +36,10 @@ export const setFxLayoutAlign = (element: HTMLElement) => {
33
36
  const fxLayoutAlign = element.getAttribute(Attributes.FxLayoutAlign);
34
37
  if (isAttribute(fxLayoutAlign)) {
35
38
  const [mainAxis, crossAxis] = fxLayoutAlign.split(' ');
36
- element.style['place-content'] = `${crossAxis} ${mainAxis}`;
37
- element.style['align-items'] = crossAxis;
39
+ element.style['place-content'] = crossAxis
40
+ ? `${crossAxis} ${mainAxis}`
41
+ : `${mainAxis} ${mainAxis}`;
42
+ element.style['align-items'] = crossAxis ? crossAxis : mainAxis;
38
43
  }
39
44
  element.style['display'] = 'flex';
40
45
  };
@@ -61,6 +66,29 @@ export const setChildrensFlex = (div: HTMLElement) => {
61
66
  }
62
67
  };
63
68
 
69
+ export const setFlexAlign = (div: HTMLElement) => {
70
+ const fxFlexAlign = div.getAttribute(Attributes.FxFlexAlign);
71
+ if (isAttribute(fxFlexAlign)) {
72
+ div.style['align-self'] = fxFlexAlign;
73
+ }
74
+ };
75
+
76
+ export const setFlexOffset = (div: HTMLElement) => {
77
+ const fxFlexOffset = div.getAttribute(Attributes.FxFlexOffset);
78
+ if (isAttribute(fxFlexOffset)) {
79
+ div.style['margin-left'] = fxFlexOffset;
80
+ }
81
+ };
82
+
83
+ export const setFlexOrder = (div: HTMLElement) => {
84
+ const fxFlexOrder = div.getAttribute(Attributes.FxFlexOrder);
85
+ if (isAttribute(fxFlexOrder)) {
86
+ div.style['order'] = fxFlexOrder;
87
+ } else {
88
+ div.style['order'] = '0';
89
+ }
90
+ };
91
+
64
92
  export const subscribeToAttributeChanges = (name: string) => (
65
93
  fn: (element: HTMLElement) => void
66
94
  ) => (element: HTMLElement) => {
@@ -83,12 +111,26 @@ export const setFxLayout = (element: HTMLElement) => {
83
111
  }
84
112
  };
85
113
 
86
- export const recursion = (div: HTMLElement): void => {
114
+ export function recursion(div: HTMLElement) {
87
115
  const fxFlex = div.getAttribute(Attributes.FxFlex);
88
116
  const fxFlexFill = div.getAttribute(Attributes.FxFlexFill);
89
117
  const fxLayout = div.getAttribute(Attributes.FxLayout);
90
118
  const fxLayoutAlign = div.getAttribute(Attributes.FxLayoutAlign);
91
119
  const fxLayoutGap = div.getAttribute(Attributes.FxLayoutGap);
120
+ const fxFlexAlign = div.getAttribute(Attributes.FxFlexAlign);
121
+ const fxFlexOffset = div.getAttribute(Attributes.FxFlexOffset);
122
+ const fxFlexOrder = div.getAttribute(Attributes.FxFlexOrder);
123
+
124
+ if (isAttribute(fxFlexOrder)) {
125
+ subscribeToAttributeChanges(Attributes.FxFlexOrder)(setFlexOrder)(div);
126
+ }
127
+ if (isAttribute(fxFlexOffset)) {
128
+ subscribeToAttributeChanges(Attributes.FxFlexAlign)(setFlexOffset)(div);
129
+ }
130
+
131
+ if (isAttribute(fxFlexAlign)) {
132
+ subscribeToAttributeChanges(Attributes.FxFlexAlign)(setFlexAlign)(div);
133
+ }
92
134
 
93
135
  if (isAttribute(fxFlex)) {
94
136
  subscribeToAttributeChanges(Attributes.FxFlex)(setChildrensFlex)(div);
@@ -120,6 +162,6 @@ export const recursion = (div: HTMLElement): void => {
120
162
 
121
163
  const divs = [...div.children] as HTMLElement[];
122
164
  for (const div of divs) {
123
- recursion(div);
165
+ recursion.call(this, div);
124
166
  }
125
- };
167
+ }
@@ -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;IACvD,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACrE,IAAI,mBAAW,CAAC,aAAa,CAAC,EAAE;QAC9B,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,aAAa,C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