@rhtml/modifiers 0.0.95 → 0.0.98
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.
- package/README.md +43 -34
- package/dist/angular/if.d.ts +11 -0
- package/dist/angular/if.js +31 -0
- package/dist/angular/if.js.map +1 -0
- package/dist/angular/index.d.ts +2 -14
- package/dist/angular/index.js +3 -73
- package/dist/angular/index.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/layout/flex-align.d.ts +15 -0
- package/dist/layout/flex-align.js +32 -0
- package/dist/layout/flex-align.js.map +1 -0
- package/dist/layout/flex-fill.d.ts +20 -0
- package/dist/layout/flex-fill.js +44 -0
- package/dist/layout/flex-fill.js.map +1 -0
- package/dist/layout/flex-offset.d.ts +15 -0
- package/dist/layout/flex-offset.js +32 -0
- package/dist/layout/flex-offset.js.map +1 -0
- package/dist/layout/flex-order.d.ts +15 -0
- package/dist/layout/flex-order.js +32 -0
- package/dist/layout/flex-order.js.map +1 -0
- package/dist/layout/flex.d.ts +17 -0
- package/dist/layout/flex.js +36 -0
- package/dist/layout/flex.js.map +1 -0
- package/dist/layout/index.d.ts +10 -11
- package/dist/layout/index.js +28 -56
- package/dist/layout/index.js.map +1 -1
- package/dist/layout/layout-align.d.ts +17 -0
- package/dist/layout/layout-align.js +39 -0
- package/dist/layout/layout-align.js.map +1 -0
- package/dist/layout/layout-gap.d.ts +17 -0
- package/dist/layout/layout-gap.js +46 -0
- package/dist/layout/layout-gap.js.map +1 -0
- package/dist/layout/layout.d.ts +19 -0
- package/dist/layout/layout.js +43 -0
- package/dist/layout/layout.js.map +1 -0
- package/package.json +3 -2
- package/src/angular/if.ts +29 -0
- package/src/angular/index.ts +2 -81
- package/src/index.ts +0 -1
- package/src/layout/flex-align.ts +36 -0
- package/src/layout/flex-fill.ts +51 -0
- package/src/layout/flex-offset.ts +37 -0
- package/src/layout/flex-order.ts +37 -0
- package/src/layout/flex.ts +43 -0
- package/src/layout/index.ts +21 -60
- package/src/layout/layout-align.ts +46 -0
- package/src/layout/layout-gap.ts +54 -0
- package/src/layout/layout.ts +46 -0
- package/dist/helpers/index.d.ts +0 -2
- package/dist/helpers/index.js +0 -12
- package/dist/helpers/index.js.map +0 -1
- package/dist/layout/modifiers.d.ts +0 -23
- package/dist/layout/modifiers.js +0 -131
- package/dist/layout/modifiers.js.map +0 -1
- package/src/helpers/index.ts +0 -12
- package/src/layout/modifiers.ts +0 -167
package/src/layout/index.ts
CHANGED
|
@@ -1,60 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export class FlexLayout extends LitElement implements OnUpdateFirst, OnDestroy {
|
|
23
|
-
/* Keep in mind that `this` here is the parent component where modifier will be used */
|
|
24
|
-
public static modifier(template: TemplateResult): TemplateResult {
|
|
25
|
-
return html`
|
|
26
|
-
<flex-layout .parent=${this}>${template}</flex-layout>
|
|
27
|
-
`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@property()
|
|
31
|
-
public parent: LitElement;
|
|
32
|
-
|
|
33
|
-
@query('slot')
|
|
34
|
-
private container: HTMLSlotElement;
|
|
35
|
-
|
|
36
|
-
private observer: MutationObserver;
|
|
37
|
-
|
|
38
|
-
OnUpdateFirst() {
|
|
39
|
-
this.triggerChanges();
|
|
40
|
-
this.listenForTreeChanges();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
OnDestroy() {
|
|
44
|
-
this.observer.disconnect();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private listenForTreeChanges() {
|
|
48
|
-
this.observer = new MutationObserver(() => this.triggerChanges());
|
|
49
|
-
this.observer.observe(this.parent.shadowRoot, {
|
|
50
|
-
subtree: true,
|
|
51
|
-
childList: true
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private triggerChanges() {
|
|
56
|
-
for (const div of this.container.assignedElements()) {
|
|
57
|
-
recursion.call(this.parent, div);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
import { Flex } from './flex';
|
|
2
|
+
import { FlexAlign } from './flex-align';
|
|
3
|
+
import { FlexFill } from './flex-fill';
|
|
4
|
+
import { FlexOffset } from './flex-offset';
|
|
5
|
+
import { FlexOrder } from './flex-order';
|
|
6
|
+
import { Layout } from './layout';
|
|
7
|
+
import { LayoutAlign } from './layout-align';
|
|
8
|
+
import { LayoutGap } from './layout-gap';
|
|
9
|
+
|
|
10
|
+
export * from './layout';
|
|
11
|
+
|
|
12
|
+
export const FlexLayout = [
|
|
13
|
+
Layout,
|
|
14
|
+
LayoutAlign,
|
|
15
|
+
LayoutGap,
|
|
16
|
+
FlexFill,
|
|
17
|
+
Flex,
|
|
18
|
+
FlexAlign,
|
|
19
|
+
FlexOffset,
|
|
20
|
+
FlexOrder
|
|
21
|
+
];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Attribute } from '@rhtml/custom-attributes';
|
|
2
|
+
|
|
3
|
+
interface Styles {
|
|
4
|
+
'place-content': string;
|
|
5
|
+
'align-items': string;
|
|
6
|
+
display: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class LayoutAlign extends Attribute<Styles> {
|
|
10
|
+
static options(this: HTMLElement) {
|
|
11
|
+
return {
|
|
12
|
+
name: 'fxLayoutAlign'
|
|
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
|
+
'align-items': null,
|
|
31
|
+
'place-content': null,
|
|
32
|
+
display: null
|
|
33
|
+
})(this.element);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private modify() {
|
|
37
|
+
const [mainAxis, crossAxis] = this.value.split(' ');
|
|
38
|
+
this.setStyles({
|
|
39
|
+
'align-items': crossAxis ? crossAxis : mainAxis,
|
|
40
|
+
'place-content': crossAxis
|
|
41
|
+
? `${crossAxis} ${mainAxis}`
|
|
42
|
+
: `${mainAxis} ${mainAxis}`,
|
|
43
|
+
display: 'flex'
|
|
44
|
+
})(this.element);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Attribute } from '@rhtml/custom-attributes';
|
|
2
|
+
|
|
3
|
+
interface Styles {
|
|
4
|
+
margin: string;
|
|
5
|
+
flex: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class LayoutGap extends Attribute<Styles> {
|
|
9
|
+
static options(this: HTMLElement) {
|
|
10
|
+
return {
|
|
11
|
+
name: 'fxLayoutGap'
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private observer: MutationObserver;
|
|
16
|
+
|
|
17
|
+
OnInit() {
|
|
18
|
+
this.modify();
|
|
19
|
+
this.observer = new MutationObserver(() => this.modify());
|
|
20
|
+
this.observer.observe(this.element, {
|
|
21
|
+
childList: true,
|
|
22
|
+
subtree: true
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
OnDestroy() {
|
|
27
|
+
this.clean();
|
|
28
|
+
this.observer.disconnect();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
OnUpdate() {
|
|
32
|
+
this.modify();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private clean() {
|
|
36
|
+
const divs = [...this.element.children] as HTMLElement[];
|
|
37
|
+
for (const div of divs) {
|
|
38
|
+
this.setStyles({
|
|
39
|
+
flex: null,
|
|
40
|
+
margin: null
|
|
41
|
+
})(div);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private modify() {
|
|
46
|
+
const divs = this.element.children;
|
|
47
|
+
for (const div of divs) {
|
|
48
|
+
this.setStyles({
|
|
49
|
+
flex: '1 1 25%',
|
|
50
|
+
margin: `0px ${this.value} ${this.value} 0px`
|
|
51
|
+
})(div);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Attribute, CustomAttributeRegistry } from '@rhtml/custom-attributes';
|
|
2
|
+
|
|
3
|
+
interface Styles {
|
|
4
|
+
'flex-flow': string;
|
|
5
|
+
'box-sizing': string;
|
|
6
|
+
display: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class Layout extends Attribute<Styles> {
|
|
10
|
+
value = 'row';
|
|
11
|
+
static options(this: HTMLElement) {
|
|
12
|
+
return {
|
|
13
|
+
name: 'fxLayout',
|
|
14
|
+
registry: new CustomAttributeRegistry(this.shadowRoot)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
OnInit() {
|
|
19
|
+
this.modify();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
OnDestroy() {
|
|
23
|
+
this.clean();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
OnUpdate() {
|
|
27
|
+
this.modify();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private clean() {
|
|
31
|
+
this.setStyles({
|
|
32
|
+
'box-sizing': null,
|
|
33
|
+
'flex-flow': null,
|
|
34
|
+
display: null
|
|
35
|
+
})(this.element);
|
|
36
|
+
}
|
|
37
|
+
private modify() {
|
|
38
|
+
const splitted = this.value.split(' ');
|
|
39
|
+
const [mainAxis, crossAxis] = splitted;
|
|
40
|
+
this.setStyles({
|
|
41
|
+
'box-sizing': 'flex',
|
|
42
|
+
'flex-flow': splitted.length > 1 ? `${mainAxis} ${crossAxis}` : mainAxis,
|
|
43
|
+
display: 'flex'
|
|
44
|
+
})(this.element);
|
|
45
|
+
}
|
|
46
|
+
}
|
package/dist/helpers/index.d.ts
DELETED
package/dist/helpers/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,23 +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 enum Attributes {
|
|
5
|
-
FxLayout = "fxLayout",
|
|
6
|
-
FxFlex = "fxFlex",
|
|
7
|
-
FxFlexFill = "fxFlexFill",
|
|
8
|
-
FxLayoutAlign = "fxLayoutAlign",
|
|
9
|
-
FxLayoutGap = "fxLayoutGap",
|
|
10
|
-
FxFlexAlign = "fxFlexAlign",
|
|
11
|
-
FxFlexOffset = "fxFlexOffset",
|
|
12
|
-
FxFlexOrder = "fxFlexOrder"
|
|
13
|
-
}
|
|
14
|
-
export declare const isAttribute: (attr: string) => boolean | string;
|
|
15
|
-
export declare const setFxLayoutAlign: (element: HTMLElement) => void;
|
|
16
|
-
export declare const setChildrensFlexFill: (div: HTMLElement) => void;
|
|
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;
|
|
21
|
-
export declare const subscribeToAttributeChanges: (name: string) => (fn: (element: HTMLElement) => void) => (element: HTMLElement) => void;
|
|
22
|
-
export declare const setFxLayout: (element: HTMLElement) => void;
|
|
23
|
-
export declare function recursion(div: HTMLElement): void;
|
package/dist/layout/modifiers.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
-
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["FxFlexAlign"] = "fxFlexAlign";
|
|
12
|
-
Attributes["FxFlexOffset"] = "fxFlexOffset";
|
|
13
|
-
Attributes["FxFlexOrder"] = "fxFlexOrder";
|
|
14
|
-
})(Attributes = exports.Attributes || (exports.Attributes = {}));
|
|
15
|
-
/* TODO we need to update to typescript 4 */
|
|
16
|
-
// export type FxLayoutAlign = `${MainAxis} ${CrossAxis}`;
|
|
17
|
-
exports.isAttribute = (attr) => typeof attr === 'string' && (attr || attr === '');
|
|
18
|
-
exports.setFxLayoutAlign = (element) => {
|
|
19
|
-
const fxLayoutAlign = element.getAttribute(Attributes.FxLayoutAlign);
|
|
20
|
-
if (exports.isAttribute(fxLayoutAlign)) {
|
|
21
|
-
const [mainAxis, crossAxis] = fxLayoutAlign.split(' ');
|
|
22
|
-
element.style['place-content'] = crossAxis
|
|
23
|
-
? `${crossAxis} ${mainAxis}`
|
|
24
|
-
: `${mainAxis} ${mainAxis}`;
|
|
25
|
-
element.style['align-items'] = crossAxis ? crossAxis : mainAxis;
|
|
26
|
-
}
|
|
27
|
-
element.style['display'] = 'flex';
|
|
28
|
-
};
|
|
29
|
-
exports.setChildrensFlexFill = (div) => {
|
|
30
|
-
const fxFlexFill = div.getAttribute(Attributes.FxFlexFill);
|
|
31
|
-
if (exports.isAttribute(fxFlexFill)) {
|
|
32
|
-
div.style['margin'] = '0';
|
|
33
|
-
div.style['width'] = '100%';
|
|
34
|
-
div.style['height'] = '100%';
|
|
35
|
-
div.style['min-width'] = '100%';
|
|
36
|
-
div.style['min-height '] = '100%';
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
exports.setChildrensFlex = (div) => {
|
|
40
|
-
const fxFlex = div.getAttribute(Attributes.FxFlex);
|
|
41
|
-
if (exports.isAttribute(fxFlex)) {
|
|
42
|
-
div.style['flex'] = '1 1 100%';
|
|
43
|
-
div.style['box-sizing'] = 'border-box';
|
|
44
|
-
if (fxFlex) {
|
|
45
|
-
div.style['max-width'] = fxFlex;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
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
|
-
};
|
|
70
|
-
exports.subscribeToAttributeChanges = (name) => (fn) => (element) => {
|
|
71
|
-
fn(element);
|
|
72
|
-
return new MutationObserver(() => fn(element)).observe(element, {
|
|
73
|
-
attributeFilter: [name.toLocaleLowerCase()],
|
|
74
|
-
attributes: true
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
exports.setFxLayout = (element) => {
|
|
78
|
-
const layout = element.getAttribute(Attributes.FxLayout);
|
|
79
|
-
if (exports.isAttribute(layout)) {
|
|
80
|
-
const splitted = layout.split(' ');
|
|
81
|
-
const [mainAxis, crossAxis] = splitted;
|
|
82
|
-
element.style['flex-flow'] =
|
|
83
|
-
splitted.length > 1 ? `${mainAxis} ${crossAxis}` : mainAxis;
|
|
84
|
-
element.style['box-sizing'] = 'flex';
|
|
85
|
-
element.style['display'] = 'flex';
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
function recursion(div) {
|
|
89
|
-
const fxFlex = div.getAttribute(Attributes.FxFlex);
|
|
90
|
-
const fxFlexFill = div.getAttribute(Attributes.FxFlexFill);
|
|
91
|
-
const fxLayout = div.getAttribute(Attributes.FxLayout);
|
|
92
|
-
const fxLayoutAlign = div.getAttribute(Attributes.FxLayoutAlign);
|
|
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
|
-
}
|
|
106
|
-
if (exports.isAttribute(fxFlex)) {
|
|
107
|
-
exports.subscribeToAttributeChanges(Attributes.FxFlex)(exports.setChildrensFlex)(div);
|
|
108
|
-
}
|
|
109
|
-
if (exports.isAttribute(fxFlexFill)) {
|
|
110
|
-
exports.subscribeToAttributeChanges(Attributes.FxFlexFill)(exports.setChildrensFlexFill)(div);
|
|
111
|
-
}
|
|
112
|
-
if (exports.isAttribute(fxLayout)) {
|
|
113
|
-
exports.subscribeToAttributeChanges(Attributes.FxLayout)(exports.setFxLayout)(div);
|
|
114
|
-
}
|
|
115
|
-
if (exports.isAttribute(fxLayoutAlign)) {
|
|
116
|
-
exports.subscribeToAttributeChanges(Attributes.FxLayoutAlign)(exports.setFxLayoutAlign)(div);
|
|
117
|
-
}
|
|
118
|
-
if (exports.isAttribute(fxLayoutGap)) {
|
|
119
|
-
const divs = [...div.children];
|
|
120
|
-
for (const div of divs) {
|
|
121
|
-
div.style['margin'] = `0px ${fxLayoutGap} ${fxLayoutGap} 0px`;
|
|
122
|
-
div.style.flex = '1 1 25%';
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
const divs = [...div.children];
|
|
126
|
-
for (const div of divs) {
|
|
127
|
-
recursion.call(this, div);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
exports.recursion = recursion;
|
|
131
|
-
//# sourceMappingURL=modifiers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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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pE;IAED,IAAI,mBAAW,CAAC,aAAa,CAAC,EAAE;QAC9B,mCAA2B,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,wBAAgB,CAAC,CACrE,GAAG,CACJ,CAAC;KACH;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,QAAQ,CAAC,GAAG,OAAO,WAAW,IAAI,WAAW,MAAM,CAAC;YAC9D,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,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;KAC3B;AACH,CAAC;AArDD,8BAqDC"}
|
package/src/helpers/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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/layout/modifiers.ts
DELETED
|
@@ -1,167 +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
|
-
|
|
19
|
-
export enum Attributes {
|
|
20
|
-
FxLayout = 'fxLayout',
|
|
21
|
-
FxFlex = 'fxFlex',
|
|
22
|
-
FxFlexFill = 'fxFlexFill',
|
|
23
|
-
FxLayoutAlign = 'fxLayoutAlign',
|
|
24
|
-
FxLayoutGap = 'fxLayoutGap',
|
|
25
|
-
FxFlexAlign = 'fxFlexAlign',
|
|
26
|
-
FxFlexOffset = 'fxFlexOffset',
|
|
27
|
-
FxFlexOrder = 'fxFlexOrder'
|
|
28
|
-
}
|
|
29
|
-
/* TODO we need to update to typescript 4 */
|
|
30
|
-
// export type FxLayoutAlign = `${MainAxis} ${CrossAxis}`;
|
|
31
|
-
|
|
32
|
-
export const isAttribute = (attr: string): boolean | string =>
|
|
33
|
-
typeof attr === 'string' && (attr || attr === '');
|
|
34
|
-
|
|
35
|
-
export const setFxLayoutAlign = (element: HTMLElement) => {
|
|
36
|
-
const fxLayoutAlign = element.getAttribute(Attributes.FxLayoutAlign);
|
|
37
|
-
if (isAttribute(fxLayoutAlign)) {
|
|
38
|
-
const [mainAxis, crossAxis] = fxLayoutAlign.split(' ');
|
|
39
|
-
element.style['place-content'] = crossAxis
|
|
40
|
-
? `${crossAxis} ${mainAxis}`
|
|
41
|
-
: `${mainAxis} ${mainAxis}`;
|
|
42
|
-
element.style['align-items'] = crossAxis ? crossAxis : mainAxis;
|
|
43
|
-
}
|
|
44
|
-
element.style['display'] = 'flex';
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const setChildrensFlexFill = (div: HTMLElement): void => {
|
|
48
|
-
const fxFlexFill = div.getAttribute(Attributes.FxFlexFill);
|
|
49
|
-
if (isAttribute(fxFlexFill)) {
|
|
50
|
-
div.style['margin'] = '0';
|
|
51
|
-
div.style['width'] = '100%';
|
|
52
|
-
div.style['height'] = '100%';
|
|
53
|
-
div.style['min-width'] = '100%';
|
|
54
|
-
div.style['min-height '] = '100%';
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const setChildrensFlex = (div: HTMLElement) => {
|
|
59
|
-
const fxFlex = div.getAttribute(Attributes.FxFlex);
|
|
60
|
-
if (isAttribute(fxFlex)) {
|
|
61
|
-
div.style['flex'] = '1 1 100%';
|
|
62
|
-
div.style['box-sizing'] = 'border-box';
|
|
63
|
-
if (fxFlex) {
|
|
64
|
-
div.style['max-width'] = fxFlex;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
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
|
-
|
|
92
|
-
export const subscribeToAttributeChanges = (name: string) => (
|
|
93
|
-
fn: (element: HTMLElement) => void
|
|
94
|
-
) => (element: HTMLElement) => {
|
|
95
|
-
fn(element);
|
|
96
|
-
return new MutationObserver(() => fn(element)).observe(element, {
|
|
97
|
-
attributeFilter: [name.toLocaleLowerCase()],
|
|
98
|
-
attributes: true
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
export const setFxLayout = (element: HTMLElement) => {
|
|
103
|
-
const layout = element.getAttribute(Attributes.FxLayout);
|
|
104
|
-
if (isAttribute(layout)) {
|
|
105
|
-
const splitted = layout.split(' ');
|
|
106
|
-
const [mainAxis, crossAxis] = splitted;
|
|
107
|
-
element.style['flex-flow'] =
|
|
108
|
-
splitted.length > 1 ? `${mainAxis} ${crossAxis}` : mainAxis;
|
|
109
|
-
element.style['box-sizing'] = 'flex';
|
|
110
|
-
element.style['display'] = 'flex';
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export function recursion(div: HTMLElement) {
|
|
115
|
-
const fxFlex = div.getAttribute(Attributes.FxFlex);
|
|
116
|
-
const fxFlexFill = div.getAttribute(Attributes.FxFlexFill);
|
|
117
|
-
const fxLayout = div.getAttribute(Attributes.FxLayout);
|
|
118
|
-
const fxLayoutAlign = div.getAttribute(Attributes.FxLayoutAlign);
|
|
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
|
-
}
|
|
134
|
-
|
|
135
|
-
if (isAttribute(fxFlex)) {
|
|
136
|
-
subscribeToAttributeChanges(Attributes.FxFlex)(setChildrensFlex)(div);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (isAttribute(fxFlexFill)) {
|
|
140
|
-
subscribeToAttributeChanges(Attributes.FxFlexFill)(setChildrensFlexFill)(
|
|
141
|
-
div
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (isAttribute(fxLayout)) {
|
|
146
|
-
subscribeToAttributeChanges(Attributes.FxLayout)(setFxLayout)(div);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (isAttribute(fxLayoutAlign)) {
|
|
150
|
-
subscribeToAttributeChanges(Attributes.FxLayoutAlign)(setFxLayoutAlign)(
|
|
151
|
-
div
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (isAttribute(fxLayoutGap)) {
|
|
156
|
-
const divs = [...div.children] as HTMLElement[];
|
|
157
|
-
for (const div of divs) {
|
|
158
|
-
div.style['margin'] = `0px ${fxLayoutGap} ${fxLayoutGap} 0px`;
|
|
159
|
-
div.style.flex = '1 1 25%';
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const divs = [...div.children] as HTMLElement[];
|
|
164
|
-
for (const div of divs) {
|
|
165
|
-
recursion.call(this, div);
|
|
166
|
-
}
|
|
167
|
-
}
|