playbook_ui 14.5.0.pre.alpha.javascriptassets3939 → 14.5.0.pre.alpha.psych4support3941

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2ca4e8e8c3df9cdee7d02f68c3a611611053345876eb602efcdb91a16b4b076
4
- data.tar.gz: fb337ad2f116c3f991969c8e59c06ba697828ae5af32cde1c01cb49bf06b6ee6
3
+ metadata.gz: 68369e36929721ec45f47ea96b446fb8724945893b925fd1763963d14f79179e
4
+ data.tar.gz: cfe0ca500c66348ff8376677f689382862a58c42b55f857f9fcb01f4f91c347d
5
5
  SHA512:
6
- metadata.gz: c833f8f4d32140a79a374f9d2b2b642fff7341defb6fc781122288238ba851c62281797eb4307ad9859c3a5004fd756c37e25dea8aa73434ac0dc6952b345fe9
7
- data.tar.gz: 468fdf29ec022656bedceb21a0f7e165aee5de1d469ebd541e09a0587a642f91dbee263fe8c7932b5cd06fa9cac6f73efd4852edeab71757d93f1ffd561638f2
6
+ metadata.gz: 72b405313fb0b71c456795c7531e6bcd000858195acfd693fb929fb8e1ec14badce9e096f80d1beeafe1c67eeb3b1ddedf3ed1f0b2048ed4cc4b59ec8229a122
7
+ data.tar.gz: ff4bc17405a8c2ecd4a7d74c6f8f75e6e0fe194f3232ba67552e42d6c3c202976a008d0d6f58de059aff99f351c90b2b4ba9865d44c86f1451a8f44f541ea5df
@@ -1,34 +1,47 @@
1
+ // eslint-disable-next-line
2
+ // @ts-nocheck
3
+ import PbEnhancedElement from "./index"
4
+
1
5
  export default class ElementObserver {
2
- constructor(matchDelegate, target = document) {
6
+ matchDelegate: PbEnhancedElement
7
+ target: Document
8
+ _mutationObserver: MutationObserver
9
+
10
+ constructor(matchDelegate: PbEnhancedElement, target = document) {
3
11
  this.matchDelegate = matchDelegate
4
12
  this.target = target
5
13
  }
6
14
 
7
- start() {
15
+ get mutationObserver(): MutationObserver {
16
+ return this._mutationObserver =
17
+ this._mutationObserver || new MutationObserver((mutationList) => this.processMutationList(mutationList))
18
+ }
19
+
20
+ start(): void {
8
21
  this.mutationObserver.observe(this.target, { attributes: true, childList: true, subtree: true })
9
22
  this.catchup()
10
23
  }
11
24
 
12
- stop() {
25
+ stop(): void {
13
26
  this.mutationObserverdisconnect()
14
27
  }
15
28
 
16
- catchup() {
17
- this.handleAdditions(this.matchDelegate.matches(this.target))
29
+ catchup(): void {
30
+ this.handleAdditions(this.matchDelegate.matches(this.target as unknown as Element))
18
31
  }
19
32
 
20
- processMutationList(mutationList) {
33
+ processMutationList(mutationList: Array<MutationRecord>): void {
21
34
  for (const mutation of mutationList) {
22
35
  if (mutation.type == 'attributes') {
23
- this.processAttributeChange(mutation.target)
36
+ this.processAttributeChange(mutation.target as Element)
24
37
  } else if (mutation.type == 'childList') {
25
- this.processRemovedNodes(Array.from(mutation.removedNodes))
26
- this.processAddedNodes(Array.from(mutation.addedNodes))
38
+ this.processRemovedNodes(Array.from(mutation.removedNodes) as Array<Element>)
39
+ this.processAddedNodes(Array.from(mutation.addedNodes) as Array<Element>)
27
40
  }
28
41
  }
29
42
  }
30
43
 
31
- processAttributeChange(node) {
44
+ processAttributeChange(node: Element): void | Array<Element> {
32
45
  if (node.nodeType !== Node.ELEMENT_NODE) return
33
46
 
34
47
  const matches = this.matchDelegate.matches(node)
@@ -38,30 +51,25 @@ export default class ElementObserver {
38
51
  this.handleAdditions(matches)
39
52
  }
40
53
 
41
- processRemovedNodes(nodes) {
54
+ processRemovedNodes(nodes: Array<Element>): void {
42
55
  for (const node of nodes) {
43
56
  if (node.nodeType !== Node.ELEMENT_NODE) continue
44
57
  this.handleRemovals(this.matchDelegate.matches(node))
45
58
  }
46
59
  }
47
60
 
48
- processAddedNodes(nodes) {
61
+ processAddedNodes(nodes: Array<Element>): void {
49
62
  for (const node of nodes) {
50
63
  if (node.nodeType !== Node.ELEMENT_NODE) continue
51
64
  this.handleAdditions(this.matchDelegate.matches(node))
52
65
  }
53
66
  }
54
67
 
55
- handleRemovals(elements) {
68
+ handleRemovals(elements: Array<Element>): void {
56
69
  for (const element of elements) this.matchDelegate.removeMatch(element)
57
70
  }
58
71
 
59
- handleAdditions(elements) {
72
+ handleAdditions(elements: Array<Element>): void {
60
73
  for (const element of elements) this.matchDelegate.addMatch(element)
61
74
  }
62
-
63
- get mutationObserver() {
64
- return this._mutationObserver =
65
- this._mutationObserver || new MutationObserver((mutationList) => this.processMutationList(mutationList))
66
- }
67
75
  }
@@ -1,21 +1,31 @@
1
- import ElementObserver from './element_observer.js'
1
+ // eslint-disable-next-line
2
+ // @ts-nocheck
3
+ import ElementObserver from './element_observer'
2
4
 
3
5
  export default class PbEnhancedElement {
4
- static get elements() {
6
+ static _elements: Map<Element, PbEnhancedElement>
7
+ static _observer: ElementObserver
8
+ element: Element
9
+
10
+ constructor(element?: Element) {
11
+ this.element = element
12
+ }
13
+
14
+ static get elements(): Map<Element, PbEnhancedElement> {
5
15
  return this._elements = (this._elements || new Map)
6
16
  }
7
17
 
8
- static get observer() {
18
+ static get observer(): ElementObserver {
9
19
  return this._observer = (this._observer || new ElementObserver(this))
10
20
  }
11
21
 
12
- static get selector() {
22
+ static get selector(): string {
13
23
  // eslint-disable-next-line no-console
14
24
  console.warn('Define a static property for selector or redefine the matches function in a subclass.', this)
15
25
  return null
16
26
  }
17
27
 
18
- static matches(node) {
28
+ static matches(node: Element): Array<Element> {
19
29
  if (!this.selector) return []
20
30
 
21
31
  const matches = []
@@ -25,7 +35,7 @@ export default class PbEnhancedElement {
25
35
  return (matches)
26
36
  }
27
37
 
28
- static addMatch(element) {
38
+ static addMatch(element: Element): void {
29
39
  if (element._pbEnhanced || this.elements.has(element)) return
30
40
 
31
41
  const enhansedElement = new this(element)
@@ -34,7 +44,7 @@ export default class PbEnhancedElement {
34
44
  element._pbEnhanced = enhansedElement
35
45
  }
36
46
 
37
- static removeMatch(element) {
47
+ static removeMatch(element: Element): void {
38
48
  if (!this.elements.has(element)) return
39
49
 
40
50
  const enhansedElement = this.elements.get(element)
@@ -42,22 +52,19 @@ export default class PbEnhancedElement {
42
52
  this.elements.delete(element)
43
53
  }
44
54
 
45
- static start() {
55
+ static start(): void {
46
56
  this.observer.start()
47
57
  }
48
58
 
49
- static stop() {
59
+ static stop(): void {
50
60
  this.mutationObserver.stop()
51
61
  }
52
62
 
53
- constructor(element) {
54
- this.element = element
55
- }
56
-
57
- connect() {
63
+ connect(): void {
58
64
  // eslint-disable-next-line no-console
59
65
  console.warn('Redefine the connect function in a subclass.', this)
60
66
  }
61
67
 
62
- disconnect() { }
68
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
69
+ disconnect(): void {}
63
70
  }