@rhtml/modifiers 0.0.87 → 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"}
@@ -0,0 +1,17 @@
1
+ export declare type FxLayout = 'row' | 'column' | 'row-reverse' | 'column-reverse';
2
+ export declare type MainAxis = 'start' | 'center' | 'end' | 'space-around' | 'space-between' | 'space-evenly';
3
+ export declare type CrossAxis = 'start' | 'center' | 'end' | 'stretch' | 'space-between' | 'space-around' | 'baseline';
4
+ export declare enum Attributes {
5
+ FxLayout = "fxLayout",
6
+ FxFlex = "fxFlex",
7
+ FxFlexFill = "fxFlexFill",
8
+ FxLayoutAlign = "fxLayoutAlign",
9
+ FxLayoutGap = "fxLayoutGap"
10
+ }
11
+ export declare const isAttribute: (attr: string) => boolean | string;
12
+ export declare const setFxLayoutAlign: (element: HTMLElement) => void;
13
+ export declare const setChildrensFlexFill: (div: HTMLElement) => void;
14
+ export declare const setChildrensFlex: (div: HTMLElement) => void;
15
+ export declare const subscribeToAttributeChanges: (name: string) => (fn: (element: HTMLElement) => void) => (element: HTMLElement) => void;
16
+ export declare const setFxLayout: (element: HTMLElement) => void;
17
+ export declare function recursion(div: HTMLElement): void;
@@ -0,0 +1,93 @@
1
+ "use strict";
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;
4
+ var Attributes;
5
+ (function (Attributes) {
6
+ Attributes["FxLayout"] = "fxLayout";
7
+ Attributes["FxFlex"] = "fxFlex";
8
+ Attributes["FxFlexFill"] = "fxFlexFill";
9
+ Attributes["FxLayoutAlign"] = "fxLayoutAlign";
10
+ Attributes["FxLayoutGap"] = "fxLayoutGap";
11
+ })(Attributes = exports.Attributes || (exports.Attributes = {}));
12
+ /* TODO we need to update to typescript 4 */
13
+ // export type FxLayoutAlign = `${MainAxis} ${CrossAxis}`;
14
+ exports.isAttribute = (attr) => typeof attr === 'string' && (attr || attr === '');
15
+ exports.setFxLayoutAlign = (element) => {
16
+ const fxLayoutAlign = element.getAttribute(Attributes.FxLayoutAlign);
17
+ if (exports.isAttribute(fxLayoutAlign)) {
18
+ const [mainAxis, crossAxis] = fxLayoutAlign.split(' ');
19
+ element.style['place-content'] = `${crossAxis} ${mainAxis}`;
20
+ element.style['align-items'] = crossAxis;
21
+ }
22
+ element.style['display'] = 'flex';
23
+ };
24
+ exports.setChildrensFlexFill = (div) => {
25
+ const fxFlexFill = div.getAttribute(Attributes.FxFlexFill);
26
+ if (exports.isAttribute(fxFlexFill)) {
27
+ div.style['margin'] = '0';
28
+ div.style['width'] = '100%';
29
+ div.style['height'] = '100%';
30
+ div.style['min-width'] = '100%';
31
+ div.style['min-height '] = '100%';
32
+ }
33
+ };
34
+ exports.setChildrensFlex = (div) => {
35
+ const fxFlex = div.getAttribute(Attributes.FxFlex);
36
+ if (exports.isAttribute(fxFlex)) {
37
+ div.style['flex'] = '1 1 100%';
38
+ div.style['box-sizing'] = 'border-box';
39
+ if (fxFlex) {
40
+ div.style['max-width'] = fxFlex;
41
+ }
42
+ }
43
+ };
44
+ exports.subscribeToAttributeChanges = (name) => (fn) => (element) => {
45
+ fn(element);
46
+ return new MutationObserver(() => fn(element)).observe(element, {
47
+ attributeFilter: [name.toLocaleLowerCase()],
48
+ attributes: true
49
+ });
50
+ };
51
+ exports.setFxLayout = (element) => {
52
+ const layout = element.getAttribute(Attributes.FxLayout);
53
+ if (exports.isAttribute(layout)) {
54
+ const splitted = layout.split(' ');
55
+ const [mainAxis, crossAxis] = splitted;
56
+ element.style['flex-flow'] =
57
+ splitted.length > 1 ? `${mainAxis} ${crossAxis}` : mainAxis;
58
+ element.style['box-sizing'] = 'flex';
59
+ element.style['display'] = 'flex';
60
+ }
61
+ };
62
+ function recursion(div) {
63
+ const fxFlex = div.getAttribute(Attributes.FxFlex);
64
+ const fxFlexFill = div.getAttribute(Attributes.FxFlexFill);
65
+ const fxLayout = div.getAttribute(Attributes.FxLayout);
66
+ const fxLayoutAlign = div.getAttribute(Attributes.FxLayoutAlign);
67
+ const fxLayoutGap = div.getAttribute(Attributes.FxLayoutGap);
68
+ if (exports.isAttribute(fxFlex)) {
69
+ exports.subscribeToAttributeChanges(Attributes.FxFlex)(exports.setChildrensFlex)(div);
70
+ }
71
+ if (exports.isAttribute(fxFlexFill)) {
72
+ exports.subscribeToAttributeChanges(Attributes.FxFlexFill)(exports.setChildrensFlexFill)(div);
73
+ }
74
+ if (exports.isAttribute(fxLayout)) {
75
+ exports.subscribeToAttributeChanges(Attributes.FxLayout)(exports.setFxLayout)(div);
76
+ }
77
+ if (exports.isAttribute(fxLayoutAlign)) {
78
+ exports.subscribeToAttributeChanges(Attributes.FxLayoutAlign)(exports.setFxLayoutAlign)(div);
79
+ }
80
+ if (exports.isAttribute(fxLayoutGap)) {
81
+ const divs = [...div.children];
82
+ for (const div of divs) {
83
+ div.style['margin'] = `0px ${fxLayoutGap} ${fxLayoutGap} 0px`;
84
+ div.style.flex = '1 1 25%';
85
+ }
86
+ }
87
+ const divs = [...div.children];
88
+ for (const div of divs) {
89
+ recursion.call(this, div);
90
+ }
91
+ }
92
+ exports.recursion = recursion;
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,m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,CAAC,CAAC;KAC3B;AACH,CAAC;AAtCD,8BAsCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhtml/modifiers",
3
- "version": "0.0.87",
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
+ }
@@ -0,0 +1,124 @@
1
+ export type FxLayout = 'row' | 'column' | 'row-reverse' | 'column-reverse';
2
+
3
+ export type MainAxis =
4
+ | 'start'
5
+ | 'center'
6
+ | 'end'
7
+ | 'space-around'
8
+ | 'space-between'
9
+ | 'space-evenly';
10
+ export type CrossAxis =
11
+ | 'start'
12
+ | 'center'
13
+ | 'end'
14
+ | 'stretch'
15
+ | 'space-between'
16
+ | 'space-around'
17
+ | 'baseline';
18
+
19
+ export enum Attributes {
20
+ FxLayout = 'fxLayout',
21
+ FxFlex = 'fxFlex',
22
+ FxFlexFill = 'fxFlexFill',
23
+ FxLayoutAlign = 'fxLayoutAlign',
24
+ FxLayoutGap = 'fxLayoutGap'
25
+ }
26
+ /* TODO we need to update to typescript 4 */
27
+ // export type FxLayoutAlign = `${MainAxis} ${CrossAxis}`;
28
+
29
+ export const isAttribute = (attr: string): boolean | string =>
30
+ typeof attr === 'string' && (attr || attr === '');
31
+
32
+ export const setFxLayoutAlign = (element: HTMLElement) => {
33
+ const fxLayoutAlign = element.getAttribute(Attributes.FxLayoutAlign);
34
+ if (isAttribute(fxLayoutAlign)) {
35
+ const [mainAxis, crossAxis] = fxLayoutAlign.split(' ');
36
+ element.style['place-content'] = `${crossAxis} ${mainAxis}`;
37
+ element.style['align-items'] = crossAxis;
38
+ }
39
+ element.style['display'] = 'flex';
40
+ };
41
+
42
+ export const setChildrensFlexFill = (div: HTMLElement): void => {
43
+ const fxFlexFill = div.getAttribute(Attributes.FxFlexFill);
44
+ if (isAttribute(fxFlexFill)) {
45
+ div.style['margin'] = '0';
46
+ div.style['width'] = '100%';
47
+ div.style['height'] = '100%';
48
+ div.style['min-width'] = '100%';
49
+ div.style['min-height '] = '100%';
50
+ }
51
+ };
52
+
53
+ export const setChildrensFlex = (div: HTMLElement) => {
54
+ const fxFlex = div.getAttribute(Attributes.FxFlex);
55
+ if (isAttribute(fxFlex)) {
56
+ div.style['flex'] = '1 1 100%';
57
+ div.style['box-sizing'] = 'border-box';
58
+ if (fxFlex) {
59
+ div.style['max-width'] = fxFlex;
60
+ }
61
+ }
62
+ };
63
+
64
+ export const subscribeToAttributeChanges = (name: string) => (
65
+ fn: (element: HTMLElement) => void
66
+ ) => (element: HTMLElement) => {
67
+ fn(element);
68
+ return new MutationObserver(() => fn(element)).observe(element, {
69
+ attributeFilter: [name.toLocaleLowerCase()],
70
+ attributes: true
71
+ });
72
+ };
73
+
74
+ export const setFxLayout = (element: HTMLElement) => {
75
+ const layout = element.getAttribute(Attributes.FxLayout);
76
+ if (isAttribute(layout)) {
77
+ const splitted = layout.split(' ');
78
+ const [mainAxis, crossAxis] = splitted;
79
+ element.style['flex-flow'] =
80
+ splitted.length > 1 ? `${mainAxis} ${crossAxis}` : mainAxis;
81
+ element.style['box-sizing'] = 'flex';
82
+ element.style['display'] = 'flex';
83
+ }
84
+ };
85
+
86
+ export function recursion(div: HTMLElement) {
87
+ const fxFlex = div.getAttribute(Attributes.FxFlex);
88
+ const fxFlexFill = div.getAttribute(Attributes.FxFlexFill);
89
+ const fxLayout = div.getAttribute(Attributes.FxLayout);
90
+ const fxLayoutAlign = div.getAttribute(Attributes.FxLayoutAlign);
91
+ const fxLayoutGap = div.getAttribute(Attributes.FxLayoutGap);
92
+ if (isAttribute(fxFlex)) {
93
+ subscribeToAttributeChanges(Attributes.FxFlex)(setChildrensFlex)(div);
94
+ }
95
+
96
+ if (isAttribute(fxFlexFill)) {
97
+ subscribeToAttributeChanges(Attributes.FxFlexFill)(setChildrensFlexFill)(
98
+ div
99
+ );
100
+ }
101
+
102
+ if (isAttribute(fxLayout)) {
103
+ subscribeToAttributeChanges(Attributes.FxLayout)(setFxLayout)(div);
104
+ }
105
+
106
+ if (isAttribute(fxLayoutAlign)) {
107
+ subscribeToAttributeChanges(Attributes.FxLayoutAlign)(setFxLayoutAlign)(
108
+ div
109
+ );
110
+ }
111
+
112
+ if (isAttribute(fxLayoutGap)) {
113
+ const divs = [...div.children] as HTMLElement[];
114
+ for (const div of divs) {
115
+ div.style['margin'] = `0px ${fxLayoutGap} ${fxLayoutGap} 0px`;
116
+ div.style.flex = '1 1 25%';
117
+ }
118
+ }
119
+
120
+ const divs = [...div.children] as HTMLElement[];
121
+ for (const div of divs) {
122
+ recursion.call(this, div);
123
+ }
124
+ }
@@ -1,9 +0,0 @@
1
- export declare type FxLayout = 'row' | 'column' | 'row-reverse' | 'column-reverse';
2
- export declare type MainAxis = 'start' | 'center' | 'end' | 'space-around' | 'space-between' | 'space-evenly';
3
- export declare type CrossAxis = 'start' | 'center' | 'end' | 'stretch' | 'space-between' | 'space-around' | 'baseline';
4
- export declare const isAttribute: (attr: string) => boolean | string;
5
- export declare const setFxLayoutAlign: (element: HTMLElement) => (fxLayoutAlign?: string) => void;
6
- export declare const setChildrensFlexFill: (div: HTMLElement) => void;
7
- export declare const setChildrensFlex: (div: HTMLElement) => (fxFlex: string) => void;
8
- export declare const setFxLayout: (element: HTMLElement) => (fxLayout?: string) => void;
9
- export declare const recursion: (div: HTMLElement) => void;
package/dist/modifiers.js DELETED
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recursion = exports.setFxLayout = exports.setChildrensFlex = exports.setChildrensFlexFill = exports.setFxLayoutAlign = exports.isAttribute = void 0;
4
- /* TODO we need to update to typescript 4 */
5
- // export type FxLayoutAlign = `${MainAxis} ${CrossAxis}`;
6
- exports.isAttribute = (attr) => typeof attr === 'string' && (attr || attr === '');
7
- exports.setFxLayoutAlign = (element) => {
8
- return (fxLayoutAlign = '') => {
9
- const [mainAxis, crossAxis] = fxLayoutAlign.split(' ');
10
- element.style['place-content'] = `${crossAxis} ${mainAxis}`;
11
- element.style['align-items'] = crossAxis;
12
- element.style['display'] = 'flex';
13
- };
14
- };
15
- exports.setChildrensFlexFill = (div) => {
16
- div.style['margin'] = '0';
17
- div.style['width'] = '100%';
18
- div.style['height'] = '100%';
19
- div.style['min-width'] = '100%';
20
- div.style['min-height '] = '100%';
21
- };
22
- exports.setChildrensFlex = (div) => {
23
- return (fxFlex) => {
24
- div.style['flex'] = '1 1 100%';
25
- div.style['box-sizing'] = 'border-box';
26
- if (fxFlex) {
27
- div.style['max-width'] = fxFlex;
28
- }
29
- };
30
- };
31
- exports.setFxLayout = (element) => {
32
- return (fxLayout = '') => {
33
- // element.style['flex-direction'] = fxLayout;
34
- element.style['box-sizing'] = 'flex';
35
- element.style['display'] = 'flex';
36
- element.style['flex-flow'] = `${fxLayout} wrap`;
37
- };
38
- };
39
- exports.recursion = (div) => {
40
- const fxFlex = div.getAttribute('fxFlex');
41
- const fxFlexFill = div.getAttribute('fxFlexFill');
42
- const fxLayout = div.getAttribute('fxLayout');
43
- const fxLayoutAlign = div.getAttribute('fxLayoutAlign');
44
- const fxLayoutGap = div.getAttribute('fxLayoutGap');
45
- if (exports.isAttribute(fxFlex)) {
46
- exports.setChildrensFlex(div)(fxFlex);
47
- }
48
- if (exports.isAttribute(fxFlexFill)) {
49
- exports.setChildrensFlexFill(div);
50
- }
51
- if (exports.isAttribute(fxLayout)) {
52
- exports.setFxLayout(div)(fxLayout);
53
- }
54
- if (exports.isAttribute(fxLayoutAlign)) {
55
- exports.setFxLayoutAlign(div)(fxLayoutAlign);
56
- }
57
- if (exports.isAttribute(fxLayoutGap)) {
58
- const divs = [...div.children];
59
- for (const div of divs) {
60
- div.style['padding'] = `0px ${fxLayoutGap} ${fxLayoutGap} 0px`;
61
- div.style.flex = '1 1 25%';
62
- }
63
- }
64
- const divs = [...div.children];
65
- for (const div of divs) {
66
- exports.recursion(div);
67
- }
68
- };
69
- //# sourceMappingURL=modifiers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modifiers.js","sourceR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AG,CAAC,CAAC,aAAa,CAAC,CAAC;KACtC;IAED,IAAI,mBAAW,CAAC,WAAW,CAAC,EAAE;QAC5B,MAAM,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAkB,CAAC;QAChD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,OAAO,WAAW,IAAI,WAAW,MAAM,CAAC;YAC/D,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;SAC5B;KACF;IAED,MAAM,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAkB,CAAC;IAChD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,iBAAS,CAAC,GAAG,CAAC,CAAC;KAChB;AACH,CAAC,CAAC"}
package/src/modifiers.ts DELETED
@@ -1,95 +0,0 @@
1
- export type FxLayout = 'row' | 'column' | 'row-reverse' | 'column-reverse';
2
-
3
- export type MainAxis =
4
- | 'start'
5
- | 'center'
6
- | 'end'
7
- | 'space-around'
8
- | 'space-between'
9
- | 'space-evenly';
10
- export type CrossAxis =
11
- | 'start'
12
- | 'center'
13
- | 'end'
14
- | 'stretch'
15
- | 'space-between'
16
- | 'space-around'
17
- | 'baseline';
18
- /* TODO we need to update to typescript 4 */
19
- // export type FxLayoutAlign = `${MainAxis} ${CrossAxis}`;
20
-
21
- export const isAttribute = (attr: string): boolean | string =>
22
- typeof attr === 'string' && (attr || attr === '');
23
-
24
- export const setFxLayoutAlign = (element: HTMLElement) => {
25
- return (fxLayoutAlign = ''): void => {
26
- const [mainAxis, crossAxis] = fxLayoutAlign.split(' ');
27
- element.style['place-content'] = `${crossAxis} ${mainAxis}`;
28
- element.style['align-items'] = crossAxis;
29
- element.style['display'] = 'flex';
30
- };
31
- };
32
-
33
- export const setChildrensFlexFill = (div: HTMLElement): void => {
34
- div.style['margin'] = '0';
35
- div.style['width'] = '100%';
36
- div.style['height'] = '100%';
37
- div.style['min-width'] = '100%';
38
- div.style['min-height '] = '100%';
39
- };
40
-
41
- export const setChildrensFlex = (div: HTMLElement) => {
42
- return (fxFlex: string): void => {
43
- div.style['flex'] = '1 1 100%';
44
- div.style['box-sizing'] = 'border-box';
45
- if (fxFlex) {
46
- div.style['max-width'] = fxFlex;
47
- }
48
- };
49
- };
50
-
51
- export const setFxLayout = (element: HTMLElement) => {
52
- return (fxLayout = ''): void => {
53
- // element.style['flex-direction'] = fxLayout;
54
- element.style['box-sizing'] = 'flex';
55
- element.style['display'] = 'flex';
56
- element.style['flex-flow'] = `${fxLayout} wrap`;
57
- };
58
- };
59
-
60
- export const recursion = (div: HTMLElement): void => {
61
- const fxFlex = div.getAttribute('fxFlex');
62
- const fxFlexFill = div.getAttribute('fxFlexFill');
63
- const fxLayout = div.getAttribute('fxLayout');
64
- const fxLayoutAlign = div.getAttribute('fxLayoutAlign');
65
- const fxLayoutGap = div.getAttribute('fxLayoutGap');
66
-
67
- if (isAttribute(fxFlex)) {
68
- setChildrensFlex(div)(fxFlex);
69
- }
70
-
71
- if (isAttribute(fxFlexFill)) {
72
- setChildrensFlexFill(div);
73
- }
74
-
75
- if (isAttribute(fxLayout)) {
76
- setFxLayout(div)(fxLayout);
77
- }
78
-
79
- if (isAttribute(fxLayoutAlign)) {
80
- setFxLayoutAlign(div)(fxLayoutAlign);
81
- }
82
-
83
- if (isAttribute(fxLayoutGap)) {
84
- const divs = [...div.children] as HTMLElement[];
85
- for (const div of divs) {
86
- div.style['padding'] = `0px ${fxLayoutGap} ${fxLayoutGap} 0px`;
87
- div.style.flex = '1 1 25%';
88
- }
89
- }
90
-
91
- const divs = [...div.children] as HTMLElement[];
92
- for (const div of divs) {
93
- recursion(div);
94
- }
95
- };