@domql/event 2.0.6 → 2.2.1

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 +37 -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,49 @@ 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
+ const { ref, state, on } = element
15
+ const { props } = ref
16
+ if (on && isFunction(on.initUpdate)) {
17
+ on.initUpdate(props, state, ref)
18
+ }
13
19
  }
14
20
 
15
- export const attachNode = (param, element, state) => {
16
- param(element, state)
21
+ // export const attachNode = (param, element, state) => {
22
+ // param(element, state)
23
+ // }
24
+
25
+ export const createState = (state, element) => {
26
+ const { on, ...el } = element
27
+ if (on && isFunction(on.createState)) {
28
+ on.createState(state, el)
29
+ }
17
30
  }
18
31
 
19
- export const stateCreated = (param, element, state) => {
20
- param(element, state)
32
+ export const updateStateInit = (changes, element) => {
33
+ const { state, on, ...el } = element
34
+ if (on && isFunction(on.updateStateInit)) {
35
+ on.updateStateInit(changes, state, el)
36
+ }
21
37
  }
22
38
 
23
- export const initStateUpdated = (param, element, state) => {
24
- param(element, state)
39
+ export const updateState = (changes, element) => {
40
+ const { state, on } = element
41
+ if (on && isFunction(on.updateState)) {
42
+ on.updateState(changes, state, element)
43
+ }
25
44
  }
26
45
 
27
- export const stateUpdated = (param, element, state) => {
28
- param(element, state)
46
+ export const propsUpdated = (element) => {
47
+ const { props, state, on } = element
48
+ if (on && isFunction(on.propsUpdated)) {
49
+ on.propsUpdated(props, state, element)
50
+ }
29
51
  }
30
52
 
31
- export const update = (param, element, state) => {
32
- param(element, state)
53
+ export const update = (params, element, state) => {
54
+ if (element.on && isFunction(element.on.update)) {
55
+ element.on.update(element, state)
56
+ }
57
+ return params
33
58
  }
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@domql/event",
3
- "version": "2.0.6",
3
+ "version": "2.2.1",
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": "88144a3105a3a0abd5f54f31659a37e494418dcb",
9
+ "dependencies": {
10
+ "@domql/utils": "latest"
11
+ },
12
+ "gitHead": "87a27f601df3c39a91dd199fb2068bb761f6ed4e",
10
13
  "source": "index.js"
11
14
  }