@rhtml/modifiers 0.0.96 → 0.0.99

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.
Files changed (58) hide show
  1. package/README.md +43 -34
  2. package/dist/angular/if.d.ts +11 -0
  3. package/dist/angular/if.js +31 -0
  4. package/dist/angular/if.js.map +1 -0
  5. package/dist/angular/index.d.ts +2 -14
  6. package/dist/angular/index.js +3 -73
  7. package/dist/angular/index.js.map +1 -1
  8. package/dist/index.d.ts +0 -1
  9. package/dist/index.js +0 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/layout/flex-align.d.ts +15 -0
  12. package/dist/layout/flex-align.js +32 -0
  13. package/dist/layout/flex-align.js.map +1 -0
  14. package/dist/layout/flex-fill.d.ts +20 -0
  15. package/dist/layout/flex-fill.js +44 -0
  16. package/dist/layout/flex-fill.js.map +1 -0
  17. package/dist/layout/flex-offset.d.ts +15 -0
  18. package/dist/layout/flex-offset.js +32 -0
  19. package/dist/layout/flex-offset.js.map +1 -0
  20. package/dist/layout/flex-order.d.ts +15 -0
  21. package/dist/layout/flex-order.js +32 -0
  22. package/dist/layout/flex-order.js.map +1 -0
  23. package/dist/layout/flex.d.ts +17 -0
  24. package/dist/layout/flex.js +36 -0
  25. package/dist/layout/flex.js.map +1 -0
  26. package/dist/layout/index.d.ts +10 -11
  27. package/dist/layout/index.js +28 -56
  28. package/dist/layout/index.js.map +1 -1
  29. package/dist/layout/layout-align.d.ts +17 -0
  30. package/dist/layout/layout-align.js +39 -0
  31. package/dist/layout/layout-align.js.map +1 -0
  32. package/dist/layout/layout-gap.d.ts +17 -0
  33. package/dist/layout/layout-gap.js +46 -0
  34. package/dist/layout/layout-gap.js.map +1 -0
  35. package/dist/layout/layout.d.ts +19 -0
  36. package/dist/layout/layout.js +43 -0
  37. package/dist/layout/layout.js.map +1 -0
  38. package/package.json +3 -2
  39. package/src/angular/if.ts +29 -0
  40. package/src/angular/index.ts +2 -81
  41. package/src/index.ts +0 -1
  42. package/src/layout/flex-align.ts +36 -0
  43. package/src/layout/flex-fill.ts +51 -0
  44. package/src/layout/flex-offset.ts +37 -0
  45. package/src/layout/flex-order.ts +37 -0
  46. package/src/layout/flex.ts +43 -0
  47. package/src/layout/index.ts +21 -60
  48. package/src/layout/layout-align.ts +46 -0
  49. package/src/layout/layout-gap.ts +54 -0
  50. package/src/layout/layout.ts +46 -0
  51. package/dist/helpers/index.d.ts +0 -2
  52. package/dist/helpers/index.js +0 -12
  53. package/dist/helpers/index.js.map +0 -1
  54. package/dist/layout/modifiers.d.ts +0 -23
  55. package/dist/layout/modifiers.js +0 -131
  56. package/dist/layout/modifiers.js.map +0 -1
  57. package/src/helpers/index.ts +0 -12
  58. package/src/layout/modifiers.ts +0 -167
@@ -1,61 +1,33 @@
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;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
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);
10
11
  };
11
12
  Object.defineProperty(exports, "__esModule", { value: true });
12
13
  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
- /* Keep in mind that `this` here is the parent component where modifier will be used */
17
- static modifier(template) {
18
- return lit_html_1.html `
19
- <flex-layout .parent=${this}>${template}</flex-layout>
20
- `;
21
- }
22
- OnUpdateFirst() {
23
- this.triggerChanges();
24
- this.listenForTreeChanges();
25
- }
26
- OnDestroy() {
27
- this.observer.disconnect();
28
- }
29
- listenForTreeChanges() {
30
- this.observer = new MutationObserver(() => this.triggerChanges());
31
- this.observer.observe(this.parent.shadowRoot, {
32
- subtree: true,
33
- childList: true
34
- });
35
- }
36
- triggerChanges() {
37
- for (const div of this.container.assignedElements()) {
38
- modifiers_1.recursion.call(this.parent, div);
39
- }
40
- }
41
- };
42
- __decorate([
43
- lit_html_1.property(),
44
- __metadata("design:type", lit_html_1.LitElement)
45
- ], FlexLayout.prototype, "parent", void 0);
46
- __decorate([
47
- lit_html_1.query('slot'),
48
- __metadata("design:type", HTMLSlotElement)
49
- ], FlexLayout.prototype, "container", void 0);
50
- FlexLayout = __decorate([
51
- lit_html_1.Component({
52
- selector: 'flex-layout',
53
- template() {
54
- return lit_html_1.html `
55
- <slot></slot>
56
- `;
57
- }
58
- })
59
- ], FlexLayout);
60
- exports.FlexLayout = FlexLayout;
14
+ const flex_1 = require("./flex");
15
+ const flex_align_1 = require("./flex-align");
16
+ const flex_fill_1 = require("./flex-fill");
17
+ const flex_offset_1 = require("./flex-offset");
18
+ const flex_order_1 = require("./flex-order");
19
+ const layout_1 = require("./layout");
20
+ const layout_align_1 = require("./layout-align");
21
+ const layout_gap_1 = require("./layout-gap");
22
+ __exportStar(require("./layout"), exports);
23
+ exports.FlexLayout = [
24
+ layout_1.Layout,
25
+ layout_align_1.LayoutAlign,
26
+ layout_gap_1.LayoutGap,
27
+ flex_fill_1.FlexFill,
28
+ flex_1.Flex,
29
+ flex_align_1.FlexAlign,
30
+ flex_offset_1.FlexOffset,
31
+ flex_order_1.FlexOrder
32
+ ];
61
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/layout/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CASwB;AAExB,2CAAwC;AAUxC,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,qBAAU;IACxC,uFAAuF;IAChF,MAAM,CAAC,QAAQ,CAAC,QAAwB;QAC7C,OAAO,eAAI,CAAA;6BACc,IAAI,IAAI,QAAQ;KACxC,CAAC;IACJ,CAAC;IAUD,aAAa;QACX,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAED,SAAS;QACP,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;IAEO,oBAAoB;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QAClE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;YAC5C,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;IAEO,cAAc;QACpB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE;YACnD,qBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SAClC;IACH,CAAC;CACF,CAAA;AA7BC;IADC,mBAAQ,EAAE;8BACI,qBAAU;0CAAC;AAG1B;IADC,gBAAK,CAAC,MAAM,CAAC;8BACK,eAAe;6CAAC;AAZxB,UAAU;IARtB,oBAAS,CAAC;QACT,QAAQ,EAAE,aAAa;QACvB,QAAQ;YACN,OAAO,eAAI,CAAA;;KAEV,CAAC;QACJ,CAAC;KACF,CAAC;GACW,UAAU,CAsCtB;AAtCY,gCAAU"}
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"}
@@ -0,0 +1,17 @@
1
+ import { Attribute } from '@rhtml/custom-attributes';
2
+ interface Styles {
3
+ 'place-content': string;
4
+ 'align-items': string;
5
+ display: string;
6
+ }
7
+ export declare class LayoutAlign extends Attribute<Styles> {
8
+ static options(this: HTMLElement): {
9
+ name: string;
10
+ };
11
+ OnInit(): void;
12
+ OnDestroy(): void;
13
+ OnUpdate(): void;
14
+ private clean;
15
+ private modify;
16
+ }
17
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LayoutAlign = void 0;
4
+ const custom_attributes_1 = require("@rhtml/custom-attributes");
5
+ class LayoutAlign extends custom_attributes_1.Attribute {
6
+ static options() {
7
+ return {
8
+ name: 'fxLayoutAlign'
9
+ };
10
+ }
11
+ OnInit() {
12
+ this.modify();
13
+ }
14
+ OnDestroy() {
15
+ this.clean();
16
+ }
17
+ OnUpdate() {
18
+ this.modify();
19
+ }
20
+ clean() {
21
+ this.setStyles({
22
+ 'align-items': null,
23
+ 'place-content': null,
24
+ display: null
25
+ })(this.element);
26
+ }
27
+ modify() {
28
+ const [mainAxis, crossAxis] = this.value.split(' ');
29
+ this.setStyles({
30
+ 'align-items': crossAxis ? crossAxis : mainAxis,
31
+ 'place-content': crossAxis
32
+ ? `${crossAxis} ${mainAxis}`
33
+ : `${mainAxis} ${mainAxis}`,
34
+ display: 'flex'
35
+ })(this.element);
36
+ }
37
+ }
38
+ exports.LayoutAlign = LayoutAlign;
39
+ //# sourceMappingURL=layout-align.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-align.js","sourceRoot":"","sources":["../../src/layout/layout-align.ts"],"names":[],"mappings":";;;AAAA,gEAAqD;AAQrD,MAAa,WAAY,SAAQ,6BAAiB;IAChD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,IAAI,EAAE,eAAe;SACtB,CAAC;IACJ,CAAC;IAED,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,aAAa,EAAE,IAAI;YACnB,eAAe,EAAE,IAAI;YACrB,OAAO,EAAE,IAAI;SACd,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;IAEO,MAAM;QACZ,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpD,IAAI,CAAC,SAAS,CAAC;YACb,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;YAC/C,eAAe,EAAE,SAAS;gBACxB,CAAC,CAAC,GAAG,SAAS,IAAI,QAAQ,EAAE;gBAC5B,CAAC,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE;YAC7B,OAAO,EAAE,MAAM;SAChB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;CACF;AArCD,kCAqCC"}
@@ -0,0 +1,17 @@
1
+ import { Attribute } from '@rhtml/custom-attributes';
2
+ interface Styles {
3
+ margin: string;
4
+ flex: string;
5
+ }
6
+ export declare class LayoutGap extends Attribute<Styles> {
7
+ static options(this: HTMLElement): {
8
+ name: string;
9
+ };
10
+ private observer;
11
+ OnInit(): void;
12
+ OnDestroy(): void;
13
+ OnUpdate(): void;
14
+ private clean;
15
+ private modify;
16
+ }
17
+ export {};
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LayoutGap = void 0;
4
+ const custom_attributes_1 = require("@rhtml/custom-attributes");
5
+ class LayoutGap extends custom_attributes_1.Attribute {
6
+ static options() {
7
+ return {
8
+ name: 'fxLayoutGap'
9
+ };
10
+ }
11
+ OnInit() {
12
+ this.modify();
13
+ this.observer = new MutationObserver(() => this.modify());
14
+ this.observer.observe(this.element, {
15
+ childList: true,
16
+ subtree: true
17
+ });
18
+ }
19
+ OnDestroy() {
20
+ this.clean();
21
+ this.observer.disconnect();
22
+ }
23
+ OnUpdate() {
24
+ this.modify();
25
+ }
26
+ clean() {
27
+ const divs = [...this.element.children];
28
+ for (const div of divs) {
29
+ this.setStyles({
30
+ flex: null,
31
+ margin: null
32
+ })(div);
33
+ }
34
+ }
35
+ modify() {
36
+ const divs = this.element.children;
37
+ for (const div of divs) {
38
+ this.setStyles({
39
+ flex: '1 1 25%',
40
+ margin: `0px ${this.value} ${this.value} 0px`
41
+ })(div);
42
+ }
43
+ }
44
+ }
45
+ exports.LayoutGap = LayoutGap;
46
+ //# sourceMappingURL=layout-gap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-gap.js","sourceRoot":"","sources":["../../src/layout/layout-gap.ts"],"names":[],"mappings":";;;AAAA,gEAAqD;AAOrD,MAAa,SAAU,SAAQ,6BAAiB;IAC9C,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,IAAI,EAAE,aAAa;SACpB,CAAC;IACJ,CAAC;IAID,MAAM;QACJ,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE;YAClC,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;IACL,CAAC;IAED,SAAS;QACP,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAEO,KAAK;QACX,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAkB,CAAC;QACzD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,IAAI,CAAC,SAAS,CAAC;gBACb,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,IAAI;aACb,CAAC,CAAC,GAAG,CAAC,CAAC;SACT;IACH,CAAC;IAEO,MAAM;QACZ,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QACnC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,IAAI,CAAC,SAAS,CAAC;gBACb,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,OAAO,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,MAAM;aAC9C,CAAC,CAAC,GAAG,CAAC,CAAC;SACT;IACH,CAAC;CACF;AA9CD,8BA8CC"}
@@ -0,0 +1,19 @@
1
+ import { Attribute, CustomAttributeRegistry } from '@rhtml/custom-attributes';
2
+ interface Styles {
3
+ 'flex-flow': string;
4
+ 'box-sizing': string;
5
+ display: string;
6
+ }
7
+ export declare class Layout extends Attribute<Styles> {
8
+ value: string;
9
+ static options(this: HTMLElement): {
10
+ name: string;
11
+ registry: CustomAttributeRegistry;
12
+ };
13
+ OnInit(): void;
14
+ OnDestroy(): void;
15
+ OnUpdate(): void;
16
+ private clean;
17
+ private modify;
18
+ }
19
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Layout = void 0;
4
+ const custom_attributes_1 = require("@rhtml/custom-attributes");
5
+ class Layout extends custom_attributes_1.Attribute {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.value = 'row';
9
+ }
10
+ static options() {
11
+ return {
12
+ name: 'fxLayout',
13
+ registry: new custom_attributes_1.CustomAttributeRegistry(this.shadowRoot)
14
+ };
15
+ }
16
+ OnInit() {
17
+ this.modify();
18
+ }
19
+ OnDestroy() {
20
+ this.clean();
21
+ }
22
+ OnUpdate() {
23
+ this.modify();
24
+ }
25
+ clean() {
26
+ this.setStyles({
27
+ 'box-sizing': null,
28
+ 'flex-flow': null,
29
+ display: null
30
+ })(this.element);
31
+ }
32
+ modify() {
33
+ const splitted = this.value.split(' ');
34
+ const [mainAxis, crossAxis] = splitted;
35
+ this.setStyles({
36
+ 'box-sizing': 'flex',
37
+ 'flex-flow': splitted.length > 1 ? `${mainAxis} ${crossAxis}` : mainAxis,
38
+ display: 'flex'
39
+ })(this.element);
40
+ }
41
+ }
42
+ exports.Layout = Layout;
43
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/layout/layout.ts"],"names":[],"mappings":";;;AAAA,gEAA8E;AAQ9E,MAAa,MAAO,SAAQ,6BAAiB;IAA7C;;QACE,UAAK,GAAG,KAAK,CAAC;IAoChB,CAAC;IAnCC,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,IAAI,2CAAuB,CAAC,IAAI,CAAC,UAAU,CAAC;SACvD,CAAC;IACJ,CAAC;IAED,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;AArCD,wBAqCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhtml/modifiers",
3
- "version": "0.0.96",
3
+ "version": "0.0.99",
4
4
  "description": "Reactive HyperText Markup Language",
5
5
  "scripts": {
6
6
  "start": "npx parcel ./examples/index.html --out-dir build/examples",
@@ -16,7 +16,8 @@
16
16
  "url": "git@github.com:rhtml/rhtml.git"
17
17
  },
18
18
  "dependencies": {
19
- "@rxdi/lit-html": "^0.7.133"
19
+ "@rxdi/lit-html": "^0.7.133",
20
+ "@rhtml/custom-attributes": "0.0.99"
20
21
  },
21
22
  "devDependencies": {
22
23
  "eslint": "^6.7.2",
@@ -0,0 +1,29 @@
1
+ import { Attribute, CustomAttributeRegistry } from '@rhtml/custom-attributes';
2
+
3
+ export class IfOperator extends Attribute {
4
+ static options(this: HTMLElement) {
5
+ return {
6
+ name: 'ngIf',
7
+ registry: new CustomAttributeRegistry(this.shadowRoot)
8
+ };
9
+ }
10
+ OnInit() {
11
+ this.setColor();
12
+ }
13
+
14
+ OnDestroy() {
15
+ this.element.style.display = null;
16
+ }
17
+
18
+ OnUpdate() {
19
+ this.setColor();
20
+ }
21
+
22
+ setColor() {
23
+ if (this.value === 'true') {
24
+ this.element.style.display = null;
25
+ } else {
26
+ this.element.style.display = 'none';
27
+ }
28
+ }
29
+ }
@@ -1,82 +1,3 @@
1
- import {
2
- Component,
3
- html,
4
- LitElement,
5
- OnDestroy,
6
- OnUpdateFirst,
7
- property,
8
- query,
9
- TemplateResult
10
- } from '@rxdi/lit-html';
1
+ import { IfOperator } from './if';
11
2
 
12
- import { isAttribute, subscribeToAttributeChanges } from '../helpers';
13
-
14
- export enum Attributes {
15
- NgIf = 'ngIf'
16
- }
17
-
18
- function recursion(div: HTMLElement) {
19
- const ngIf = div.getAttribute(Attributes.NgIf);
20
-
21
- if (isAttribute(ngIf)) {
22
- subscribeToAttributeChanges(Attributes.NgIf)(
23
- element =>
24
- (element.style.display =
25
- element.getAttribute(Attributes.NgIf) === 'true' ? 'block' : 'none')
26
- )(div);
27
- }
28
-
29
- const divs = [...div.children] as HTMLElement[];
30
- for (const div of divs) {
31
- recursion.call(this, div);
32
- }
33
- }
34
-
35
- @Component({
36
- selector: 'angular-layout',
37
- template() {
38
- return html`
39
- <slot></slot>
40
- `;
41
- }
42
- })
43
- export class AngularLayout extends LitElement
44
- implements OnUpdateFirst, OnDestroy {
45
- /* Keep in mind that `this` here is the parent component where modifier will be used */
46
- public static modifier(template: TemplateResult): TemplateResult {
47
- return html`
48
- <angular-layout .parent=${this}>${template}</angular-layout>
49
- `;
50
- }
51
-
52
- @property()
53
- public parent: LitElement;
54
-
55
- @query('slot')
56
- private container: HTMLSlotElement;
57
-
58
- private observer: MutationObserver;
59
-
60
- OnUpdateFirst() {
61
- this.triggerChanges();
62
- this.listenForTreeChanges();
63
- }
64
-
65
- OnDestroy() {
66
- this.observer.disconnect();
67
- }
68
-
69
- private listenForTreeChanges() {
70
- this.observer = new MutationObserver(() => this.triggerChanges());
71
- this.observer.observe(this.parent.shadowRoot, {
72
- subtree: true,
73
- childList: true
74
- });
75
- }
76
-
77
- private triggerChanges() {
78
- for (const div of this.container.assignedElements()) {
79
- recursion.call(this.parent, div);
80
- }
81
- }
82
- }
3
+ export const AngularLayout = [IfOperator];
package/src/index.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from './angular';
2
- export * from './helpers';
3
2
  export * from './layout';
@@ -0,0 +1,36 @@
1
+ import { Attribute } from '@rhtml/custom-attributes';
2
+
3
+ interface Styles {
4
+ 'align-self': string;
5
+ }
6
+ export class FlexAlign extends Attribute<Styles> {
7
+ static options(this: HTMLElement) {
8
+ return {
9
+ name: 'fxFlexAlign'
10
+ };
11
+ }
12
+
13
+ OnInit() {
14
+ this.modify();
15
+ }
16
+
17
+ OnDestroy() {
18
+ this.clean();
19
+ }
20
+
21
+ OnUpdate() {
22
+ this.modify();
23
+ }
24
+
25
+ private clean() {
26
+ this.setStyles({
27
+ 'align-self': null
28
+ })(this.element);
29
+ }
30
+
31
+ private modify() {
32
+ this.setStyles({
33
+ 'align-self': this.value || null
34
+ })(this.element);
35
+ }
36
+ }
@@ -0,0 +1,51 @@
1
+ import { Attribute } from '@rhtml/custom-attributes';
2
+
3
+ interface Styles {
4
+ margin: string;
5
+ width: string;
6
+ height: string;
7
+ 'min-width': string;
8
+ 'min-height': string;
9
+ }
10
+
11
+ export class FlexFill extends Attribute<Styles> {
12
+ static options(this: HTMLElement) {
13
+ return {
14
+ name: 'fxFlexFill'
15
+ };
16
+ }
17
+
18
+ value = '100%';
19
+
20
+ OnInit() {
21
+ this.modify();
22
+ }
23
+
24
+ OnDestroy() {
25
+ this.clean();
26
+ }
27
+
28
+ OnUpdate() {
29
+ this.modify();
30
+ }
31
+
32
+ private clean() {
33
+ this.setStyles({
34
+ height: null,
35
+ margin: null,
36
+ 'min-height': null,
37
+ 'min-width': null,
38
+ width: null
39
+ })(this.element);
40
+ }
41
+
42
+ private modify() {
43
+ this.setStyles({
44
+ margin: '0',
45
+ height: this.value,
46
+ 'min-height': this.value,
47
+ 'min-width': this.value,
48
+ width: this.value
49
+ })(this.element);
50
+ }
51
+ }
@@ -0,0 +1,37 @@
1
+ import { Attribute } from '@rhtml/custom-attributes';
2
+
3
+ interface Styles {
4
+ 'margin-left': string;
5
+ }
6
+
7
+ export class FlexOffset extends Attribute<Styles> {
8
+ static options(this: HTMLElement) {
9
+ return {
10
+ name: 'fxFlexOffset'
11
+ };
12
+ }
13
+
14
+ OnInit() {
15
+ this.modify();
16
+ }
17
+
18
+ OnDestroy() {
19
+ this.clean();
20
+ }
21
+
22
+ OnUpdate() {
23
+ this.modify();
24
+ }
25
+
26
+ private clean() {
27
+ this.setStyles({
28
+ 'margin-left': null
29
+ })(this.element);
30
+ }
31
+
32
+ private modify() {
33
+ this.setStyles({
34
+ 'margin-left': this.value || null
35
+ })(this.element);
36
+ }
37
+ }
@@ -0,0 +1,37 @@
1
+ import { Attribute } from '@rhtml/custom-attributes';
2
+
3
+ interface Styles {
4
+ order: string;
5
+ }
6
+
7
+ export class FlexOrder extends Attribute<Styles> {
8
+ static options(this: HTMLElement) {
9
+ return {
10
+ name: 'fxFlexOrder'
11
+ };
12
+ }
13
+
14
+ OnInit() {
15
+ this.modify();
16
+ }
17
+
18
+ OnDestroy() {
19
+ this.clean();
20
+ }
21
+
22
+ OnUpdate() {
23
+ this.modify();
24
+ }
25
+
26
+ private clean() {
27
+ this.setStyles({
28
+ order: null
29
+ })(this.element);
30
+ }
31
+
32
+ private modify() {
33
+ this.setStyles({
34
+ order: this.value || null
35
+ })(this.element);
36
+ }
37
+ }
@@ -0,0 +1,43 @@
1
+ import { Attribute } from '@rhtml/custom-attributes';
2
+
3
+ interface Styles {
4
+ flex: string;
5
+ 'box-sizing': string;
6
+ 'max-width': string;
7
+ }
8
+
9
+ export class Flex extends Attribute<Styles> {
10
+ static options(this: HTMLElement) {
11
+ return {
12
+ name: 'fxFlex'
13
+ };
14
+ }
15
+
16
+ OnInit() {
17
+ this.modify();
18
+ }
19
+
20
+ OnDestroy() {
21
+ this.clean();
22
+ }
23
+
24
+ OnUpdate() {
25
+ this.modify();
26
+ }
27
+
28
+ private clean() {
29
+ this.setStyles({
30
+ 'box-sizing': null,
31
+ 'max-width': null,
32
+ flex: null
33
+ })(this.element);
34
+ }
35
+
36
+ private modify() {
37
+ this.setStyles({
38
+ 'box-sizing': 'border-box',
39
+ 'max-width': this.value || null,
40
+ flex: '1 1 100%'
41
+ })(this.element);
42
+ }
43
+ }