@rhtml/modifiers 0.0.109 → 0.0.112

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 (42) hide show
  1. package/README.md +26 -0
  2. package/dist/animation/animate.css.d.ts +1 -0
  3. package/dist/animation/animate.css.js +3364 -0
  4. package/dist/animation/animate.css.js.map +1 -0
  5. package/dist/animation/animation.d.ts +16 -0
  6. package/dist/animation/animation.js +55 -0
  7. package/dist/animation/animation.js.map +1 -0
  8. package/dist/animation/index.d.ts +3 -0
  9. package/dist/animation/index.js +16 -0
  10. package/dist/animation/index.js.map +1 -0
  11. package/dist/animation/interfaces.d.ts +1 -0
  12. package/dist/animation/interfaces.js +3 -0
  13. package/dist/animation/interfaces.js.map +1 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +1 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/layout/flex-align.d.ts +6 -4
  18. package/dist/layout/flex-align.js +14 -1
  19. package/dist/layout/flex-align.js.map +1 -1
  20. package/dist/layout/flex.d.ts +6 -4
  21. package/dist/layout/flex.js +14 -1
  22. package/dist/layout/flex.js.map +1 -1
  23. package/dist/layout/layout-align.d.ts +6 -4
  24. package/dist/layout/layout-align.js +14 -1
  25. package/dist/layout/layout-align.js.map +1 -1
  26. package/dist/layout/layout-gap.d.ts +6 -4
  27. package/dist/layout/layout-gap.js +28 -3
  28. package/dist/layout/layout-gap.js.map +1 -1
  29. package/dist/layout/layout.d.ts +6 -4
  30. package/dist/layout/layout.js +19 -1
  31. package/dist/layout/layout.js.map +1 -1
  32. package/package.json +3 -3
  33. package/src/animation/animate.css.ts +3360 -0
  34. package/src/animation/animation.ts +56 -0
  35. package/src/animation/index.ts +3 -0
  36. package/src/animation/interfaces.ts +79 -0
  37. package/src/index.ts +1 -0
  38. package/src/layout/flex-align.ts +21 -4
  39. package/src/layout/flex.ts +21 -4
  40. package/src/layout/layout-align.ts +21 -4
  41. package/src/layout/layout-gap.ts +38 -6
  42. package/src/layout/layout.ts +27 -4
@@ -0,0 +1,56 @@
1
+ import {
2
+ Attribute,
3
+ CustomAttributeRegistry,
4
+ Input,
5
+ Modifier
6
+ } from '@rhtml/custom-attributes';
7
+
8
+ import { Animations } from './animate.css';
9
+ import { AnimationsType } from './interfaces';
10
+
11
+ interface Styles {
12
+ animationDelay: string;
13
+ }
14
+
15
+ @Modifier({
16
+ selector: 'animated',
17
+ registry(this: HTMLElement) {
18
+ return new CustomAttributeRegistry(this);
19
+ }
20
+ })
21
+ export class Animation extends Attribute<Styles> {
22
+ @Input({ observe: true })
23
+ delay: string;
24
+
25
+ value: AnimationsType;
26
+
27
+ OnInit() {
28
+ this.pushStylesToParent();
29
+ this.modify();
30
+ }
31
+
32
+ OnDestroy() {
33
+ this.element.classList.remove('animated', this.value);
34
+ this.setStyles({ animationDelay: null })(this.element);
35
+ }
36
+
37
+ OnUpdate() {
38
+ this.modify();
39
+ }
40
+
41
+ OnUpdateAttribute() {
42
+ this.modify();
43
+ }
44
+
45
+ private modify() {
46
+ this.element.classList.add('animated', this.value);
47
+ this.setStyles({ animationDelay: this.delay })(this.element);
48
+ }
49
+
50
+ private pushStylesToParent() {
51
+ const style = document.createElement('style');
52
+ style.innerHTML = Animations;
53
+ const root = this.parent.shadowRoot ?? this.parent;
54
+ root.prepend(style);
55
+ }
56
+ }
@@ -0,0 +1,3 @@
1
+ export * from './animate.css';
2
+ export * from './animation';
3
+ export * from './interfaces';
@@ -0,0 +1,79 @@
1
+ export type AnimationsType =
2
+ | 'slideOutDown'
3
+ | 'slideOutLeft'
4
+ | 'slideOutRight'
5
+ | 'slideOutUp'
6
+ | 'slideInUp'
7
+ | 'slideInRight'
8
+ | 'slideInLeft'
9
+ | 'slideInDown'
10
+ | 'zoomOutUp'
11
+ | 'zoomOutRight'
12
+ | 'zoomOutLeft'
13
+ | 'zoomOutDown'
14
+ | 'zoomOut'
15
+ | 'zoomInUp'
16
+ | 'zoomInRight'
17
+ | 'zoomInLeft'
18
+ | 'zoomInDown'
19
+ | 'zoomIn'
20
+ | 'rollOut'
21
+ | 'rollIn'
22
+ | 'jackInTheBox'
23
+ | 'hinge'
24
+ | 'rotateOutUpRight'
25
+ | 'rotateOutUpLeft'
26
+ | 'rotateOutDownRight'
27
+ | 'rotateOutDownLeft'
28
+ | 'rotateOut'
29
+ | 'rotateInUpRight'
30
+ | 'rotateInUpLeft'
31
+ | 'rotateInDownRight'
32
+ | 'rotateInDownLeft'
33
+ | 'rotateIn'
34
+ | 'lightSpeedOut'
35
+ | 'lightSpeedIn'
36
+ | 'flipOutY'
37
+ | 'flipOutX'
38
+ | 'flipInY'
39
+ | 'flipInX'
40
+ | 'flip'
41
+ | 'fadeOutUpBig'
42
+ | 'fadeOutUp'
43
+ | 'fadeOutRightBig'
44
+ | 'fadeOutRight'
45
+ | 'fadeOutLeftBig'
46
+ | 'fadeOutLeft'
47
+ | 'fadeOutDownBig'
48
+ | 'fadeOutDown'
49
+ | 'fadeOut'
50
+ | 'fadeInUpBig'
51
+ | 'fadeInUp'
52
+ | 'fadeInRightBig'
53
+ | 'fadeInRight'
54
+ | 'fadeInLeftBig'
55
+ | 'fadeInLeft'
56
+ | 'fadeInDownBig'
57
+ | 'fadeInDown'
58
+ | 'fadeIn'
59
+ | 'bounceOutUp'
60
+ | 'bounceOutRight'
61
+ | 'bounceOutLeft'
62
+ | 'bounceOutDown'
63
+ | 'bounceOut'
64
+ | 'bounceInUp'
65
+ | 'bounceInRight'
66
+ | 'bounceInLeft'
67
+ | 'bounceInDown'
68
+ | 'bounceIn'
69
+ | 'heartBeat'
70
+ | 'jello'
71
+ | 'wobble'
72
+ | 'tada'
73
+ | 'swing'
74
+ | 'headShake'
75
+ | 'shake'
76
+ | 'rubberBand'
77
+ | 'pulse'
78
+ | 'flash'
79
+ | 'bounce';
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './angular';
2
2
  export * from './layout';
3
+ export * from './animation';
@@ -1,4 +1,8 @@
1
- import { Attribute, Modifier } from '@rhtml/custom-attributes';
1
+ import {
2
+ EnterMediaQueryAttributes,
3
+ MediaQueryAttribute,
4
+ Modifier
5
+ } from '@rhtml/custom-attributes';
2
6
 
3
7
  interface Styles {
4
8
  alignSelf: string;
@@ -7,24 +11,37 @@ interface Styles {
7
11
  @Modifier({
8
12
  selector: 'fxFlexAlign'
9
13
  })
10
- export class FlexAlign extends Attribute<Styles> {
14
+ export class FlexAlign extends MediaQueryAttribute<Styles> {
11
15
  OnInit() {
12
16
  this.modify();
17
+ super.OnInit();
13
18
  }
14
19
 
15
20
  OnDestroy() {
16
21
  this.clean();
22
+ super.OnDestroy();
17
23
  }
18
24
 
19
25
  OnUpdate() {
20
26
  this.modify();
21
27
  }
22
28
 
23
- private clean() {
29
+ OnEnterMediaQuery([, attribute]: EnterMediaQueryAttributes) {
30
+ this.prevValue = this.value;
31
+ this.value = attribute.value ?? this.value;
32
+ this.modify();
33
+ }
34
+
35
+ OnExitMediaQuery() {
36
+ this.value = this.prevValue ?? this.value;
37
+ this.modify();
38
+ }
39
+
40
+ clean() {
24
41
  this.setStyles({ alignSelf: null })(this.element);
25
42
  }
26
43
 
27
- private modify() {
44
+ modify() {
28
45
  this.setStyles({ alignSelf: this.value || null })(this.element);
29
46
  }
30
47
  }
@@ -1,4 +1,8 @@
1
- import { Attribute, Modifier } from '@rhtml/custom-attributes';
1
+ import {
2
+ EnterMediaQueryAttributes,
3
+ MediaQueryAttribute,
4
+ Modifier
5
+ } from '@rhtml/custom-attributes';
2
6
 
3
7
  interface Styles {
4
8
  flex: string;
@@ -9,20 +13,33 @@ interface Styles {
9
13
  @Modifier({
10
14
  selector: 'fxFlex'
11
15
  })
12
- export class Flex extends Attribute<Styles> {
16
+ export class Flex extends MediaQueryAttribute<Styles> {
13
17
  OnInit() {
14
18
  this.modify();
19
+ super.OnInit();
15
20
  }
16
21
 
17
22
  OnDestroy() {
18
23
  this.clean();
24
+ super.OnDestroy();
19
25
  }
20
26
 
21
27
  OnUpdate() {
22
28
  this.modify();
23
29
  }
24
30
 
25
- private clean() {
31
+ OnEnterMediaQuery([, attribute]: EnterMediaQueryAttributes) {
32
+ this.prevValue = this.value;
33
+ this.value = attribute.value ?? this.value;
34
+ this.modify();
35
+ }
36
+
37
+ OnExitMediaQuery() {
38
+ this.value = this.prevValue ?? this.value;
39
+ this.modify();
40
+ }
41
+
42
+ clean() {
26
43
  this.setStyles({
27
44
  boxSizing: null,
28
45
  maxWidth: null,
@@ -30,7 +47,7 @@ export class Flex extends Attribute<Styles> {
30
47
  })(this.element);
31
48
  }
32
49
 
33
- private modify() {
50
+ modify() {
34
51
  this.setStyles({
35
52
  boxSizing: 'border-box',
36
53
  maxWidth: this.value || null,
@@ -1,4 +1,8 @@
1
- import { Attribute, Modifier } from '@rhtml/custom-attributes';
1
+ import {
2
+ EnterMediaQueryAttributes,
3
+ MediaQueryAttribute,
4
+ Modifier
5
+ } from '@rhtml/custom-attributes';
2
6
 
3
7
  interface Styles {
4
8
  placeContent: string;
@@ -9,20 +13,33 @@ interface Styles {
9
13
  @Modifier({
10
14
  selector: 'fxLayoutAlign'
11
15
  })
12
- export class LayoutAlign extends Attribute<Styles> {
16
+ export class LayoutAlign extends MediaQueryAttribute<Styles> {
13
17
  OnInit() {
14
18
  this.modify();
19
+ super.OnInit();
15
20
  }
16
21
 
17
22
  OnDestroy() {
18
23
  this.clean();
24
+ super.OnDestroy();
19
25
  }
20
26
 
21
27
  OnUpdate() {
22
28
  this.modify();
23
29
  }
24
30
 
25
- private clean() {
31
+ OnEnterMediaQuery([, attribute]: EnterMediaQueryAttributes) {
32
+ this.prevValue = this.value;
33
+ this.value = attribute.value ?? this.value;
34
+ this.modify();
35
+ }
36
+
37
+ OnExitMediaQuery() {
38
+ this.value = this.prevValue ?? this.value;
39
+ this.modify();
40
+ }
41
+
42
+ clean() {
26
43
  this.setStyles({
27
44
  alignItems: null,
28
45
  placeContent: null,
@@ -30,7 +47,7 @@ export class LayoutAlign extends Attribute<Styles> {
30
47
  })(this.element);
31
48
  }
32
49
 
33
- private modify() {
50
+ modify() {
34
51
  const [mainAxis, crossAxis] = this.value.split(' ');
35
52
  this.setStyles({
36
53
  alignItems: crossAxis ? crossAxis : mainAxis,
@@ -1,4 +1,9 @@
1
- import { Attribute, Modifier } from '@rhtml/custom-attributes';
1
+ import {
2
+ createFiltersFromSelector,
3
+ EnterMediaQueryAttributes,
4
+ MediaQueryAttribute,
5
+ Modifier
6
+ } from '@rhtml/custom-attributes';
2
7
 
3
8
  interface Styles {
4
9
  margin: string;
@@ -8,7 +13,7 @@ interface Styles {
8
13
  @Modifier({
9
14
  selector: 'fxLayoutGap'
10
15
  })
11
- export class LayoutGap extends Attribute<Styles> {
16
+ export class LayoutGap extends MediaQueryAttribute<Styles> {
12
17
  private observer: MutationObserver;
13
18
 
14
19
  OnInit() {
@@ -16,20 +21,39 @@ export class LayoutGap extends Attribute<Styles> {
16
21
  this.observer = new MutationObserver(() => this.modify());
17
22
  this.observer.observe(this.element, {
18
23
  childList: true,
19
- subtree: true
24
+ subtree: true,
25
+ attributes: true,
26
+ attributeFilter: createFiltersFromSelector('fxlayout')
20
27
  });
28
+ super.OnInit();
21
29
  }
22
30
 
23
31
  OnDestroy() {
24
32
  this.clean();
25
33
  this.observer.disconnect();
34
+ super.OnDestroy();
26
35
  }
27
36
 
28
37
  OnUpdate() {
29
38
  this.modify();
30
39
  }
31
40
 
32
- private clean() {
41
+ OnEnterMediaQuery([, attribute]: EnterMediaQueryAttributes) {
42
+ this.prevValue = this.value;
43
+ this.value = attribute.value ?? this.value;
44
+ this.modify();
45
+ }
46
+
47
+ OnExitMediaQuery() {
48
+ this.value = this.prevValue ?? this.value;
49
+ this.modify();
50
+ }
51
+
52
+ // OnElementAttributeChange() {
53
+
54
+ // }
55
+
56
+ clean() {
33
57
  const divs = [...this.element.children] as HTMLElement[];
34
58
  for (const div of divs) {
35
59
  this.setStyles({
@@ -39,12 +63,20 @@ export class LayoutGap extends Attribute<Styles> {
39
63
  }
40
64
  }
41
65
 
42
- private modify() {
66
+ modify() {
67
+ const layout = this.element.getAttribute('fxlayout');
68
+ let margin = `0px ${this.value} ${this.value} 0px`;
69
+ if (layout === 'row') {
70
+ margin = `0px ${this.value} 0px 0px`;
71
+ }
72
+ if (layout === 'column') {
73
+ margin = `0px 0px ${this.value} 0px`;
74
+ }
43
75
  const divs = this.element.children;
44
76
  for (const div of divs) {
45
77
  this.setStyles({
46
78
  flex: '1 1 25%',
47
- margin: `0px ${this.value} ${this.value} 0px`
79
+ margin
48
80
  })(div);
49
81
  }
50
82
  }
@@ -1,4 +1,8 @@
1
- import { Attribute, Modifier } from '@rhtml/custom-attributes';
1
+ import {
2
+ EnterMediaQueryAttributes,
3
+ MediaQueryAttribute,
4
+ Modifier
5
+ } from '@rhtml/custom-attributes';
2
6
 
3
7
  interface Styles {
4
8
  flexFlow: string;
@@ -9,29 +13,48 @@ interface Styles {
9
13
  @Modifier({
10
14
  selector: 'fxLayout'
11
15
  })
12
- export class Layout extends Attribute<Styles> {
16
+ export class Layout extends MediaQueryAttribute<Styles> {
13
17
  value = 'row';
14
18
 
15
19
  OnInit() {
16
20
  this.modify();
21
+ super.OnInit();
17
22
  }
18
23
 
19
24
  OnDestroy() {
20
25
  this.clean();
26
+ super.OnDestroy();
21
27
  }
22
28
 
23
29
  OnUpdate() {
24
30
  this.modify();
25
31
  }
26
32
 
27
- private clean() {
33
+ OnEnterMediaQuery([, attribute]: EnterMediaQueryAttributes) {
34
+ this.prevValue = this.value;
35
+ this.value = attribute.value ?? this.value;
36
+ this.modify();
37
+ this.element.setAttribute('fxlayout', this.value);
38
+ }
39
+
40
+ OnExitMediaQuery() {
41
+ this.value = this.prevValue ?? this.value;
42
+ this.modify();
43
+ this.element.setAttribute('fxlayout', this.value);
44
+ }
45
+
46
+ clean() {
28
47
  this.setStyles({
29
48
  boxSizing: null,
30
49
  flexFlow: null,
31
50
  display: null
32
51
  })(this.element);
33
52
  }
34
- private modify() {
53
+
54
+ modify() {
55
+ if (!this.value) {
56
+ return;
57
+ }
35
58
  const splitted = this.value.split(' ');
36
59
  const [mainAxis, crossAxis] = splitted;
37
60
  this.setStyles({