@live-change/vue3-components 0.2.31 → 0.2.33

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.
@@ -130,6 +130,18 @@
130
130
  this.object = this.data[this.property]
131
131
  this.properties = {}
132
132
 
133
+ this.bindProperties(definition)
134
+
135
+ this.unwatch = watch(() => this.data[this.property], () => {
136
+ if(this.object != this.data[this.property]) {
137
+ this.object = this.data[this.property]
138
+ console.log("OBJECT OBJECT CHANGE", this.property)
139
+ this.bindProperties(definition)
140
+ }
141
+ }, { deep: true })
142
+ }
143
+
144
+ bindProperties(definition) {
133
145
  for(let propName in definition.properties) {
134
146
  let propDefn = definition.properties[propName]
135
147
 
@@ -264,7 +276,6 @@
264
276
  this.properties[propName].reset(oldData)
265
277
  this.object[propName] = this.properties[propName].getValue()
266
278
  }
267
-
268
279
  }
269
280
 
270
281
  class FormArray extends FormValue {
@@ -274,22 +285,37 @@
274
285
  this.elements = []
275
286
  if(!this.data[this.property]) this.data[this.property] = []
276
287
  this.object = this.data[this.property]
288
+ this.bindElements()
277
289
  this.unwatch = watch(() => this.data[this.property], () => {
278
- this.object = this.data[this.property]
279
- while(this.elements.length > this.object.length) {
280
- this.elements.pop()
281
- }
282
- while(this.elements.length < this.object.length) {
283
- this.elements.push(this.newElement(this.elements.length))
290
+ if(this.object != this.data[this.property]) {
291
+ //console.log("ARRAY OBJECT CHANGE", this.property)
292
+ this.object = this.data[this.property]
293
+ this.elements = []
284
294
  }
295
+ this.bindElements()
296
+ //this.check()
285
297
  }, { deep: true })
286
298
  }
287
299
 
300
+ bindElements() {
301
+ while(this.elements.length > this.object.length) {
302
+ this.elements.pop()
303
+ }
304
+ while(this.elements.length < this.object.length) {
305
+ this.elements.push(this.newElement(this.elements.length))
306
+ }
307
+ }
308
+
288
309
  setProperty(name) {
289
310
  if(this.unwatch) this.unwatch()
290
311
  this.property = name
291
312
  this.object = this.data[this.property]
292
313
  this.unwatch = watch(() => this.data[this.property], () => {
314
+ if(this.object != this.data[this.property]) {
315
+ //console.log("ARRAY OBJECT CHANGE", this.property)
316
+ this.object = this.data[this.property]
317
+ this.elements = []
318
+ }
293
319
  this.object = this.data[this.property]
294
320
  while(this.elements.length > this.object.length) {
295
321
  this.elements.pop()
@@ -313,13 +339,24 @@
313
339
  reset(initialValue) {
314
340
  initialValue = initialValue || this.definition.defaultValue || []
315
341
  this.data[this.property] = new Array(initialValue.length)
316
- this.elements = this.data[this.property]
342
+ this.elements = new Array(this.object.length)
317
343
  for(let i = 0; i < initialValue.length; i++) {
318
- let n = this.newElement(this.elements.length)
344
+ let n = this.newElement(i)
319
345
  n.reset(initialValue[i])
320
346
  this.elements[i] = n
321
347
  }
322
348
  super.setValue(initialValue)
349
+ /* if(this.property == 'query') {
350
+ this.check()
351
+ this.object.bzz = 1
352
+ }*/
353
+ }
354
+
355
+ check() {
356
+ console.log("ARRAY", this, JSON.stringify(this.data))
357
+ for(let i = 0; i < this.elements.length; i++) {
358
+ console.log("ELEMENT", i, this.elements[i].data[i] == this.object[i])
359
+ }
323
360
  }
324
361
 
325
362
  afterError(initialValue) {
@@ -384,18 +421,28 @@
384
421
  }
385
422
 
386
423
  setValue(value) {
387
- this.data[this.property] = value
388
- if(!value) return;
389
- for(let i = 0; i < value.length; i++) {
390
- if(this.elements[i]) {
391
- this.elements[i].setValue(value[i])
392
- } else {
393
- let n = this.newElement()
424
+ if(value != this.object) {
425
+ this.data[this.property] = value
426
+ this.object = value
427
+ this.elements = []
428
+ if(!value) return;
429
+ for(let i = 0; i < value.length; i++) {
430
+ let n = this.newElement(i)
394
431
  n.reset(value[i])
395
432
  this.elements.push(n)
396
433
  }
434
+ } else {
435
+ for (let i = 0; i < value.length; i++) {
436
+ if (this.elements[i]) {
437
+ this.elements[i].setValue(value[i])
438
+ } else {
439
+ let n = this.newElement(i)
440
+ n.reset(value[i])
441
+ this.elements.push(n)
442
+ }
443
+ }
444
+ this.elements = this.elements.slice(0, value.length)
397
445
  }
398
- this.elements = this.elements.slice(0, value.length)
399
446
  }
400
447
 
401
448
  updateElementIndices() {
@@ -464,6 +511,8 @@
464
511
  getValue: () => this.formRoot.getValue(),
465
512
  reset: () => this.reset(),
466
513
 
514
+ getNode: (name) => this.getNode(name),
515
+
467
516
  addValidator: (propName, validator) => this.addValidator(propName, validator),
468
517
  removeValidator: (propName, validator) => this.addValidator(propName, validator),
469
518
  validateField: (propName) => this.validateField(propName),
@@ -477,7 +526,11 @@
477
526
  waitForBarriers: (propName) => this.waitForBarriers(),
478
527
 
479
528
  addElementToArray: (propName, initialValue) => this.addElementToArray(propName, initialValue),
480
- removeElementFromArray: (propName, index) => this.removeElementFromArray(propName, index)
529
+ removeElementFromArray: (propName, index) => this.removeElementFromArray(propName, index),
530
+
531
+ data: computed(() => this.data),
532
+ root: computed(() => this.formRoot),
533
+ state: computed(() => this.state),
481
534
  }
482
535
  }
483
536
  },
@@ -489,11 +542,6 @@
489
542
  formRoot: {}
490
543
  }
491
544
  },
492
- computed: {
493
- rootValue() {
494
- return this.formRoot && this.formRoot.value
495
- }
496
- },
497
545
  methods: {
498
546
  getNode(name) {
499
547
  let np = name.split('.')
@@ -620,6 +668,8 @@
620
668
  created() {
621
669
  this.initForm()
622
670
  this.state = 'ready'
671
+
672
+ globalThis.form = this
623
673
  },
624
674
  unmounted() {
625
675
  },
package/form/FormBind.vue CHANGED
@@ -22,7 +22,17 @@ export default {
22
22
  },
23
23
  value: {
24
24
  get() {
25
- return this.form.getFieldValue(this.name)
25
+ let np = this.name.split('.')
26
+ let data = this.form.data.value
27
+ for(let p of np) {
28
+ if(!p) continue
29
+ data = data[p]
30
+ }
31
+ return data
32
+ /* const node = this.form.getNode(this.name)
33
+ console.log("RECOMPUTE VALUE OF", this.name, node.data[node.property])
34
+ return node.data[node.property]
35
+ //return this.form.getFieldValue(this.name)*/
26
36
  },
27
37
  set(value) {
28
38
  const filtered = this.valueFilter(value)
@@ -8,6 +8,7 @@ function useAnalytics() {
8
8
 
9
9
  function installRouterAnalytics(router) {
10
10
  router.afterEach((to, from) => {
11
+ if(typeof window === 'undefined') return
11
12
  analytics.emit('pageView', { ...to })
12
13
  })
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/vue3-components",
3
- "version": "0.2.31",
3
+ "version": "0.2.33",
4
4
  "description": "Live Change Framework - vue components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,10 +21,10 @@
21
21
  },
22
22
  "homepage": "https://github.com/live-change/live-change-framework-vue3",
23
23
  "dependencies": {
24
- "@live-change/vue3-ssr": "^0.2.31",
24
+ "@live-change/vue3-ssr": "^0.2.33",
25
25
  "debug": "^4.3.4",
26
26
  "mitt": "3.0.0",
27
27
  "vue": "^3.2.47"
28
28
  },
29
- "gitHead": "5a36954b2ff7c5ec81fbbddb4d017d9127488540"
29
+ "gitHead": "cd48bb411965818bb6716798f9cc33af33dae96d"
30
30
  }
@@ -91,7 +91,7 @@
91
91
  }
92
92
  this.compute('started')
93
93
  },
94
- beforeDestroy() {
94
+ beforeUnmount() {
95
95
  if(this.resizeObserver) this.resizeObserver.disconnect()
96
96
  clearInterval(this.checkInt)
97
97
  window.removeEventListener('scroll', this.recomputeListenerScroll)