@domql/event 2.0.5 → 2.2.0

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 (2) hide show
  1. package/on.js +38 -12
  2. package/package.json +5 -2
package/on.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ import { isFunction } from '@domql/utils'
4
+
3
5
  export const init = (param, element, state) => {
4
6
  param(element, state)
5
7
  }
@@ -8,26 +10,50 @@ export const render = (param, element, state) => {
8
10
  param(element, state)
9
11
  }
10
12
 
11
- export const initUpdate = (param, element, state) => {
12
- param(element, state)
13
+ export const initUpdate = (element) => {
14
+ console.log(element)
15
+ const { ref, state, on } = element
16
+ const { props } = ref
17
+ if (on && isFunction(on.initUpdate)) {
18
+ on.initUpdate(props, state, ref)
19
+ }
13
20
  }
14
21
 
15
- export const attachNode = (param, element, state) => {
16
- param(element, state)
22
+ // export const attachNode = (param, element, state) => {
23
+ // param(element, state)
24
+ // }
25
+
26
+ export const createState = (state, element) => {
27
+ const { on, ...el } = element
28
+ if (on && isFunction(on.createState)) {
29
+ on.createState(state, el)
30
+ }
17
31
  }
18
32
 
19
- export const stateCreated = (param, element, state) => {
20
- param(element, state)
33
+ export const updateStateInit = (changes, element) => {
34
+ const { state, on, ...el } = element
35
+ if (on && isFunction(on.updateStateInit)) {
36
+ on.updateStateInit(changes, state, el)
37
+ }
21
38
  }
22
39
 
23
- export const initStateUpdated = (param, element, state) => {
24
- param(element, state)
40
+ export const updateState = (changes, element) => {
41
+ const { state, on } = element
42
+ if (on && isFunction(on.updateState)) {
43
+ on.updateState(changes, state, element)
44
+ }
25
45
  }
26
46
 
27
- export const stateUpdated = (param, element, state) => {
28
- param(element, state)
47
+ export const propsUpdated = (element) => {
48
+ const { props, state, on } = element
49
+ if (on && isFunction(on.propsUpdated)) {
50
+ on.propsUpdated(props, state, element)
51
+ }
29
52
  }
30
53
 
31
- export const update = (param, element, state) => {
32
- param(element, state)
54
+ export const update = (params, element, state) => {
55
+ if (element.on && isFunction(element.on.update)) {
56
+ element.on.update(element, state)
57
+ }
58
+ return params
33
59
  }
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@domql/event",
3
- "version": "2.0.5",
3
+ "version": "2.2.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
7
7
  "vpatch": "npm version patch && npm publish --access public"
8
8
  },
9
- "gitHead": "50bbcf385b1164bb3f0c2eb7a4d7d1bc28ca7752",
9
+ "dependencies": {
10
+ "@domql/utils": "latest"
11
+ },
12
+ "gitHead": "ec7e77cec088dafc6b4a5d2893f72e3590a6761e",
10
13
  "source": "index.js"
11
14
  }