@live-change/vue3-components 0.8.22 → 0.8.23
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.
- package/form/CommandForm.vue +10 -10
- package/form/DefinedForm.vue +18 -18
- package/index.js +1 -1
- package/logic/locale.js +140 -123
- package/package.json +3 -3
- package/view/RangeViewer.vue +21 -2
package/form/CommandForm.vue
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<defined-form
|
|
3
|
-
v-if="actionDefinition && (state
|
|
3
|
+
v-if="actionDefinition && (state === 'ready' || state === 'working')"
|
|
4
4
|
:tag="formTag"
|
|
5
5
|
@submit="handleSubmitEvent"
|
|
6
6
|
ref="defined"
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
v-slot="{ data }">
|
|
14
14
|
<slot v-bind="{ data, submit }"></slot>
|
|
15
15
|
</defined-form>
|
|
16
|
-
<slot v-if="state
|
|
16
|
+
<slot v-if="state === 'error'" name="error">
|
|
17
17
|
<div class="alert alert-danger" role="alert">error</div>
|
|
18
18
|
</slot>
|
|
19
|
-
<slot v-if="state
|
|
19
|
+
<slot v-if="state === 'done'" name="done">
|
|
20
20
|
<div class="alert alert-success" role="alert">success</div>
|
|
21
21
|
</slot>
|
|
22
22
|
</template>
|
|
@@ -94,14 +94,14 @@
|
|
|
94
94
|
if(this.serviceDefinitionSource) {
|
|
95
95
|
if(typeof this.servicesDefinitionSource == 'string') {
|
|
96
96
|
const definition = this.$api.serviceDefinitions.value
|
|
97
|
-
.find(service => service.name
|
|
97
|
+
.find(service => service.name === this.serviceDefinitionSource)
|
|
98
98
|
return definition
|
|
99
99
|
} else {
|
|
100
100
|
return this.serviceDefinitionSource
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
if(!this.$api.servicesDefinitions.value) return
|
|
104
|
-
const definition = this.$api.servicesDefinitions.value.find(service => service.name
|
|
104
|
+
const definition = this.$api.servicesDefinitions.value.find(service => service.name === this.service)
|
|
105
105
|
return definition
|
|
106
106
|
},
|
|
107
107
|
actionDefinition() {
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
removeValidator(name, validator) {
|
|
172
172
|
let validators = this.getNode(name).validators
|
|
173
173
|
let id = validators.indexOf(validator)
|
|
174
|
-
if(id
|
|
174
|
+
if(id === -1) throw new Error("validator not found")
|
|
175
175
|
validators.splice(id)
|
|
176
176
|
},
|
|
177
177
|
validateField(name) {
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
this.$refs.defined.scrollToError()
|
|
211
211
|
},
|
|
212
212
|
async submit(additionalParameters) {
|
|
213
|
-
if(!(this.state
|
|
213
|
+
if(!(this.state === 'ready' || this.state === 'error')) return
|
|
214
214
|
this.state = 'working'
|
|
215
215
|
this.workingTask = this.workingZone.started({ name: `service ${this.service} action ${this.action}` })
|
|
216
216
|
|
|
@@ -297,7 +297,7 @@
|
|
|
297
297
|
this.workingZone.failed(this.workingTask, error)
|
|
298
298
|
}
|
|
299
299
|
} else if(Array.isArray(this.ignoreError)) {
|
|
300
|
-
if(this.ignoreError.indexOf(error)
|
|
300
|
+
if(this.ignoreError.indexOf(error) !== -1) {
|
|
301
301
|
this.state = 'ready'
|
|
302
302
|
this.workingZone.finished(this.workingTask)
|
|
303
303
|
} else {
|
|
@@ -348,7 +348,7 @@
|
|
|
348
348
|
},
|
|
349
349
|
watch: {
|
|
350
350
|
actionDefinition(def) {
|
|
351
|
-
if(def && this.state
|
|
351
|
+
if(def && this.state === 'loading') {
|
|
352
352
|
this.state = 'ready'
|
|
353
353
|
if(this.loadingTask) {
|
|
354
354
|
this.loadingZone.finished(this.loadingTask)
|
|
@@ -357,7 +357,7 @@
|
|
|
357
357
|
}
|
|
358
358
|
},
|
|
359
359
|
loadingError(error) {
|
|
360
|
-
if(error && this.state
|
|
360
|
+
if(error && this.state === 'loading') {
|
|
361
361
|
this.state = 'loadingError'
|
|
362
362
|
if(this.loadingTask) {
|
|
363
363
|
this.loadingZone.failed(this.loadingTask, error)
|
package/form/DefinedForm.vue
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
8
|
<script>
|
|
9
|
-
import {
|
|
9
|
+
import { computed, watch } from 'vue'
|
|
10
10
|
import { getElementPositionInDocument } from '../utils/dom.mjs'
|
|
11
11
|
|
|
12
12
|
const errorSufix = 'Error'
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
case "Object" : defaultValue = {}; break;
|
|
79
79
|
case "Number" : defaultValue = 0; break;
|
|
80
80
|
case "Array" : defaultValue = []; break;
|
|
81
|
-
default: defaultValue =
|
|
81
|
+
default: defaultValue = undefined
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
this.setValue(initialValue ?? defaultValue)
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
return Promise.all(promises).then(results => {
|
|
102
102
|
for(let error of results) {
|
|
103
103
|
if(error) {
|
|
104
|
-
if(this.data[this.property+errorSufix]
|
|
104
|
+
if(this.data[this.property+errorSufix] === error) return error
|
|
105
105
|
this.setError(error)
|
|
106
106
|
return error
|
|
107
107
|
}
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
this.bindProperties(definition)
|
|
134
134
|
|
|
135
135
|
this.unwatch = watch(() => this.data[this.property], () => {
|
|
136
|
-
if(this.object
|
|
136
|
+
if(this.object !== this.data[this.property]) {
|
|
137
137
|
this.object = this.data[this.property]
|
|
138
138
|
console.log("OBJECT OBJECT CHANGE", this.property)
|
|
139
139
|
this.bindProperties(definition)
|
|
@@ -145,10 +145,10 @@
|
|
|
145
145
|
for(let propName in definition.properties) {
|
|
146
146
|
let propDefn = definition.properties[propName]
|
|
147
147
|
|
|
148
|
-
if(propDefn.type
|
|
148
|
+
if(propDefn.type === "Object") {
|
|
149
149
|
this.properties[propName] =
|
|
150
150
|
new FormObject(definition.properties[propName], this.component, this.object, propName)
|
|
151
|
-
} else if(propDefn.type
|
|
151
|
+
} else if(propDefn.type === 'Array') {
|
|
152
152
|
this.properties[propName] =
|
|
153
153
|
new FormArray(definition.properties[propName], this.component, this.object, propName)
|
|
154
154
|
} else {
|
|
@@ -263,10 +263,10 @@
|
|
|
263
263
|
const propDefn = JSON.parse(JSON.stringify(defn))
|
|
264
264
|
this.definition.properties[propName] = propDefn
|
|
265
265
|
const definition = this.definition
|
|
266
|
-
if(propDefn.type
|
|
266
|
+
if(propDefn.type === "Object") {
|
|
267
267
|
this.properties[propName] =
|
|
268
268
|
new FormObject(definition.properties[propName], this.component, this.object, propName)
|
|
269
|
-
} else if(propDefn.type
|
|
269
|
+
} else if(propDefn.type === 'Array') {
|
|
270
270
|
this.properties[propName] =
|
|
271
271
|
new FormArray(definition.properties[propName], this.component, this.object, propName)
|
|
272
272
|
} else {
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
this.object = this.data[this.property]
|
|
288
288
|
this.bindElements()
|
|
289
289
|
this.unwatch = watch(() => this.data[this.property], () => {
|
|
290
|
-
if(this.object
|
|
290
|
+
if(this.object !== this.data[this.property]) {
|
|
291
291
|
//console.log("ARRAY OBJECT CHANGE", this.property)
|
|
292
292
|
this.object = this.data[this.property]
|
|
293
293
|
this.elements = []
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
this.property = name
|
|
312
312
|
this.object = this.data[this.property]
|
|
313
313
|
this.unwatch = watch(() => this.data[this.property], () => {
|
|
314
|
-
if(this.object
|
|
314
|
+
if(this.object !== this.data[this.property]) {
|
|
315
315
|
//console.log("ARRAY OBJECT CHANGE", this.property)
|
|
316
316
|
this.object = this.data[this.property]
|
|
317
317
|
this.elements = []
|
|
@@ -327,9 +327,9 @@
|
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
newElement(index) {
|
|
330
|
-
if(this.elementDefinition.type
|
|
330
|
+
if(this.elementDefinition.type === "Object") {
|
|
331
331
|
return new FormObject(this.elementDefinition, this.component, this.object, index)
|
|
332
|
-
} else if(this.elementDefinition.type
|
|
332
|
+
} else if(this.elementDefinition.type === 'Array') {
|
|
333
333
|
return new FormArray(this.elementDefinition, this.component, this.object, index)
|
|
334
334
|
} else {
|
|
335
335
|
return new FormValue(this.elementDefinition, this.component, this.object, index)
|
|
@@ -355,7 +355,7 @@
|
|
|
355
355
|
check() {
|
|
356
356
|
console.log("ARRAY", this, JSON.stringify(this.data))
|
|
357
357
|
for(let i = 0; i < this.elements.length; i++) {
|
|
358
|
-
console.log("ELEMENT", i, this.elements[i].data[i]
|
|
358
|
+
console.log("ELEMENT", i, this.elements[i].data[i] === this.object[i])
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
|
|
@@ -421,7 +421,7 @@
|
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
setValue(value) {
|
|
424
|
-
if(value
|
|
424
|
+
if(value !== this.object) {
|
|
425
425
|
this.data[this.property] = value
|
|
426
426
|
this.object = value
|
|
427
427
|
this.elements = []
|
|
@@ -447,7 +447,7 @@
|
|
|
447
447
|
|
|
448
448
|
updateElementIndices() {
|
|
449
449
|
for(let i = 0; i < this.elements.length; i++) {
|
|
450
|
-
if(this.elements[i].property
|
|
450
|
+
if(this.elements[i].property !== i) {
|
|
451
451
|
this.elements[i].setProperty(i)
|
|
452
452
|
}
|
|
453
453
|
}
|
|
@@ -523,7 +523,7 @@
|
|
|
523
523
|
addBarrier: (propName, validator) => this.addBarrier(propName, validator),
|
|
524
524
|
removeBarrier: (propName, validator) => this.removeBarrier(propName, validator),
|
|
525
525
|
waitForFieldBarriers: (propName) => this.waitForFieldBarriers(propName),
|
|
526
|
-
waitForBarriers: (
|
|
526
|
+
waitForBarriers: () => this.waitForBarriers(),
|
|
527
527
|
|
|
528
528
|
addElementToArray: (propName, initialValue) => this.addElementToArray(propName, initialValue),
|
|
529
529
|
removeElementFromArray: (propName, index) => this.removeElementFromArray(propName, index),
|
|
@@ -615,7 +615,7 @@
|
|
|
615
615
|
removeValidator(name, validator) {
|
|
616
616
|
let validators = this.getNode(name).validators
|
|
617
617
|
let id = validators.indexOf(validator)
|
|
618
|
-
if(id
|
|
618
|
+
if(id === -1) throw new Error("validator not found")
|
|
619
619
|
validators.splice(id)
|
|
620
620
|
},
|
|
621
621
|
validateField(name, context) {
|
|
@@ -643,7 +643,7 @@
|
|
|
643
643
|
removeBarrier(name, barrier) {
|
|
644
644
|
let barriers = this.getNode(name).barriers
|
|
645
645
|
let id = barriers.indexOf(barrier)
|
|
646
|
-
if(id
|
|
646
|
+
if(id === -1) throw new Error("barrier not found")
|
|
647
647
|
barriers.splice(id)
|
|
648
648
|
},
|
|
649
649
|
|
package/index.js
CHANGED
|
@@ -22,5 +22,5 @@ import { analytics, useAnalytics, installRouterAnalytics, synchronized, synchron
|
|
|
22
22
|
export { analytics, useAnalytics, installRouterAnalytics, synchronized, synchronizedList }
|
|
23
23
|
|
|
24
24
|
export {
|
|
25
|
-
useLocale,
|
|
25
|
+
useLocale, Locale
|
|
26
26
|
} from './logic/locale'
|
package/logic/locale.js
CHANGED
|
@@ -2,106 +2,110 @@ import { useApi } from '@live-change/vue3-ssr'
|
|
|
2
2
|
import { ObservableValue } from '@live-change/dao'
|
|
3
3
|
import { ref, computed, onUnmounted, getCurrentInstance } from 'vue'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export class Locale {
|
|
6
|
+
constructor(context) {
|
|
7
|
+
this.localeObservable
|
|
8
|
+
this.localeRef = ref()
|
|
9
|
+
this.context = context ?? getCurrentInstance().appContext
|
|
10
|
+
this.api = useApi(context)
|
|
11
|
+
|
|
12
|
+
this.language = computed(() =>
|
|
13
|
+
this.localeRef.value?.language ?? this.localeRef.value?.capturedLanguage
|
|
14
|
+
?? (typeof navigator != 'undefined' && navigator.language)
|
|
15
|
+
)
|
|
16
|
+
this.currency = computed(() =>
|
|
17
|
+
nonEmptyObject(this.localeRef.value?.currency) ?? nonEmptyObject(this.localeRef.value?.capturedCurrency)
|
|
18
|
+
?? 'usd'
|
|
19
|
+
)
|
|
20
|
+
this.dateTime = computed(() =>
|
|
21
|
+
nonEmptyObject(this.localeRef.value?.dateTime) ?? nonEmptyObject(this.localeRef.value?.capturedDateTime)
|
|
22
|
+
?? new Intl.DateTimeFormat().resolvedOptions()
|
|
23
|
+
)
|
|
24
|
+
this.list = computed(() =>
|
|
25
|
+
nonEmptyObject(this.localeRef.value?.list) ?? nonEmptyObject(this.localeRef.value?.capturedList)
|
|
26
|
+
?? new Intl.ListFormat().resolvedOptions()
|
|
27
|
+
)
|
|
28
|
+
this.number = computed(() =>
|
|
29
|
+
nonEmptyObject(this.localeRef.value?.number) ?? nonEmptyObject(this.localeRef.value?.capturedNumber)
|
|
30
|
+
?? new Intl.NumberFormat().resolvedOptions()
|
|
31
|
+
)
|
|
32
|
+
this.plural = computed(() =>
|
|
33
|
+
nonEmptyObject(this.localeRef.value?.plural) ?? nonEmptyObject(this.localeRef.value?.capturedPlural)
|
|
34
|
+
?? new Intl.PluralRules().resolvedOptions()
|
|
35
|
+
)
|
|
36
|
+
this.relativeTime = computed(() =>
|
|
37
|
+
nonEmptyObject(this.localeRef.value?.relativeTime) ??
|
|
38
|
+
nonEmptyObject(this.localeRef.value?.capturedRelativeTime)
|
|
39
|
+
?? new Intl.RelativeTimeFormat().resolvedOptions()
|
|
40
|
+
)
|
|
41
|
+
this.timezoneOffset = computed(() => getTimeZoneOffset(new Date(), this.dateTime.value?.timeZone))
|
|
7
42
|
|
|
8
|
-
export async function getOtherOwnerLocale(owner, context) {
|
|
9
|
-
if(localeObservable) localeObservable.unbindProperty(localeRef, 'value')
|
|
10
|
-
context = context ?? getCurrentInstance().appContext
|
|
11
|
-
const api = useApi(context)
|
|
12
|
-
if(typeof window === 'undefined') {
|
|
13
|
-
const value = await api.get(api.views.localeSettings.localeSettings(owner))
|
|
14
|
-
localeObservable = new ObservableValue(value)
|
|
15
|
-
} else {
|
|
16
|
-
localeObservable = api.observable(api.views.localeSettings.localeSettings(owner))
|
|
17
43
|
}
|
|
18
|
-
localeObservable.bindProperty(localeRef, 'value')
|
|
19
|
-
localeObservable.wait()
|
|
20
|
-
return localeObservable.getValue()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function getLocale(context) {
|
|
24
|
-
context = context ?? getCurrentInstance().appContext
|
|
25
|
-
return (async () => {
|
|
26
|
-
await getLocaleObservable(context)
|
|
27
|
-
await localeObservable.wait()
|
|
28
|
-
return localeObservable.getValue()
|
|
29
|
-
})()
|
|
30
|
-
}
|
|
31
44
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return (async () => {
|
|
35
|
-
if(localeObservable) return localeObservable
|
|
36
|
-
const api = useApi(context)
|
|
45
|
+
async getOtherOwnerLocale(owner) {
|
|
46
|
+
if(this.localeObservable) this.localeObservable.unbindProperty(this.localeRef, 'value')
|
|
37
47
|
if(typeof window === 'undefined') {
|
|
38
|
-
const value = await api.get(api.views.localeSettings.
|
|
39
|
-
localeObservable = new ObservableValue(value)
|
|
48
|
+
const value = await this.api.get(this.api.views.localeSettings.localeSettings(owner))
|
|
49
|
+
this.localeObservable = new ObservableValue(value)
|
|
40
50
|
} else {
|
|
41
|
-
localeObservable = api.observable(api.views.localeSettings.
|
|
51
|
+
this.localeObservable = this.api.observable(this.api.views.localeSettings.localeSettings(owner))
|
|
42
52
|
}
|
|
43
|
-
localeObservable.bindProperty(localeRef, 'value')
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
53
|
+
this.localeObservable.bindProperty(this.localeRef, 'value')
|
|
54
|
+
this.localeObservable.wait()
|
|
55
|
+
return this.localeObservable.getValue()
|
|
56
|
+
}
|
|
47
57
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
await observable.wait()
|
|
56
|
-
return observable.getValue()
|
|
57
|
-
})()
|
|
58
|
-
}
|
|
58
|
+
async getLocale() {
|
|
59
|
+
return (async () => {
|
|
60
|
+
await this.getLocaleObservable()
|
|
61
|
+
await this.localeObservable.wait()
|
|
62
|
+
return this.localeObservable.getValue()
|
|
63
|
+
})()
|
|
64
|
+
}
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const capturedList = new Intl.ListFormat().resolvedOptions()
|
|
74
|
-
const capturedNumber = new Intl.NumberFormat().resolvedOptions()
|
|
75
|
-
const capturedPlural = new Intl.PluralRules().resolvedOptions()
|
|
76
|
-
const capturedRelativeTime = new Intl.RelativeTimeFormat().resolvedOptions()
|
|
77
|
-
|
|
78
|
-
const capturedLocaleSettings = {
|
|
79
|
-
capturedLanguage,
|
|
80
|
-
capturedDateTime,
|
|
81
|
-
capturedList,
|
|
82
|
-
capturedNumber,
|
|
83
|
-
capturedPlural,
|
|
84
|
-
capturedRelativeTime
|
|
85
|
-
}
|
|
66
|
+
async getLocaleObservable() {
|
|
67
|
+
return (async () => {
|
|
68
|
+
if(this.localeObservable) return this.localeObservable
|
|
69
|
+
if(typeof window === 'undefined') {
|
|
70
|
+
const value = await this.api.get(this.api.views.localeSettings.myLocaleSettings({}))
|
|
71
|
+
this.localeObservable = new ObservableValue(value)
|
|
72
|
+
} else {
|
|
73
|
+
this.localeObservable = this.api.observable(this.api.views.localeSettings.myLocaleSettings({}))
|
|
74
|
+
}
|
|
75
|
+
this.localeObservable.bindProperty(this.localeRef, 'value')
|
|
76
|
+
return this.localeObservable
|
|
77
|
+
})()
|
|
78
|
+
}
|
|
86
79
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
)
|
|
104
|
-
|
|
80
|
+
async watchLocale(callback) {
|
|
81
|
+
return (async () => {
|
|
82
|
+
const observable = await this.getLocaleObservable()
|
|
83
|
+
const observer = { set: callback }
|
|
84
|
+
observable.observe(observer)
|
|
85
|
+
onUnmounted(() => observable.unobserve(observer))
|
|
86
|
+
await observable.wait()
|
|
87
|
+
return observable.getValue()
|
|
88
|
+
})()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
updateLocale(localSettingsUpdate) {
|
|
92
|
+
return this.api.actions.localeSettings.setOrUpdateMyLocaleSettings(localSettingsUpdate)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async captureLocale() {
|
|
96
|
+
if(typeof navigator === 'undefined') return
|
|
97
|
+
return (async () => {
|
|
98
|
+
const localeSettings = await this.getLocale()
|
|
99
|
+
//console.log("LOCALE SETTINGS", JSON.stringify(localeSettings, null, ' '))
|
|
100
|
+
|
|
101
|
+
const capturedLanguage = navigator.language
|
|
102
|
+
const capturedDateTime = new Intl.DateTimeFormat().resolvedOptions()
|
|
103
|
+
const capturedList = new Intl.ListFormat().resolvedOptions()
|
|
104
|
+
const capturedNumber = new Intl.NumberFormat().resolvedOptions()
|
|
105
|
+
const capturedPlural = new Intl.PluralRules().resolvedOptions()
|
|
106
|
+
const capturedRelativeTime = new Intl.RelativeTimeFormat().resolvedOptions()
|
|
107
|
+
|
|
108
|
+
const capturedLocaleSettings = {
|
|
105
109
|
capturedLanguage,
|
|
106
110
|
capturedDateTime,
|
|
107
111
|
capturedList,
|
|
@@ -109,10 +113,42 @@ export function captureLocale(context) {
|
|
|
109
113
|
capturedPlural,
|
|
110
114
|
capturedRelativeTime
|
|
111
115
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
|
|
117
|
+
//console.log("CAPTURED LOCALE SETTINGS", JSON.stringify(capturedLocaleSettings, null, ' '))
|
|
118
|
+
|
|
119
|
+
/*console.log("language", localeSettings.capturedLanguage !== capturedLanguage)
|
|
120
|
+
console.log("dateTime", JSON.stringify(capturedDateTime) !== JSON.stringify(localeSettings.capturedDateTime))
|
|
121
|
+
console.log("list", JSON.stringify(capturedList) !== JSON.stringify(localeSettings.capturedList))
|
|
122
|
+
console.log("number", JSON.stringify(capturedNumber) !== JSON.stringify(localeSettings.capturedNumber))
|
|
123
|
+
console.log("plural", JSON.stringify(capturedPlural) !== JSON.stringify(localeSettings.capturedPlural))
|
|
124
|
+
console.log("relativeTime", JSON.stringify(capturedRelativeTime) !== JSON.stringify(localeSettings.capturedRelativeTime))
|
|
125
|
+
*/
|
|
126
|
+
if(!localeSettings
|
|
127
|
+
|| localeSettings.capturedLanguage !== capturedLanguage
|
|
128
|
+
|| JSON.stringify(localeSettings.capturedDateTime) !== JSON.stringify(capturedDateTime)
|
|
129
|
+
|| JSON.stringify(localeSettings.capturedList) !== JSON.stringify(capturedList)
|
|
130
|
+
|| JSON.stringify(localeSettings.capturedNumber) !== JSON.stringify(capturedNumber)
|
|
131
|
+
|| JSON.stringify(localeSettings.capturedPlural) !== JSON.stringify(capturedPlural)
|
|
132
|
+
|| JSON.stringify(localeSettings.capturedRelativeTime) !== JSON.stringify(capturedRelativeTime)
|
|
133
|
+
) {
|
|
134
|
+
const update = {
|
|
135
|
+
capturedLanguage,
|
|
136
|
+
capturedDateTime,
|
|
137
|
+
capturedList,
|
|
138
|
+
capturedNumber,
|
|
139
|
+
capturedPlural,
|
|
140
|
+
capturedRelativeTime
|
|
141
|
+
}
|
|
142
|
+
console.log("UPDATE LOCALE SETTINGS", update)
|
|
143
|
+
await this.updateLocale(update)
|
|
144
|
+
}
|
|
145
|
+
})()
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
localTime(date) {
|
|
149
|
+
return new Date(new Date(date).getTime() + this.timezoneOffset?.value)
|
|
150
|
+
}
|
|
151
|
+
|
|
116
152
|
}
|
|
117
153
|
|
|
118
154
|
function getTimeZoneOffset(d, tz) {
|
|
@@ -123,37 +159,18 @@ function getTimeZoneOffset(d, tz) {
|
|
|
123
159
|
return (t2 - t1) / 60 / 1000
|
|
124
160
|
}
|
|
125
161
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
?? new Intl.DateTimeFormat().resolvedOptions())
|
|
131
|
-
export const list = computed(() => localeRef.value?.list ?? localeRef.value?.capturedList
|
|
132
|
-
?? new Intl.ListFormat().resolvedOptions())
|
|
133
|
-
export const number = computed(() => localeRef.value?.number ?? localeRef.value?.capturedNumber
|
|
134
|
-
?? new Intl.NumberFormat().resolvedOptions())
|
|
135
|
-
export const plural = computed(() => localeRef.value?.plural ?? localeRef.value?.capturedPlural
|
|
136
|
-
?? new Intl.PluralRules().resolvedOptions())
|
|
137
|
-
export const relativeTime = computed(() => localeRef.value?.relativeTime ?? localeRef.value?.capturedRelativeTime
|
|
138
|
-
?? new Intl.RelativeTimeFormat().resolvedOptions())
|
|
139
|
-
|
|
140
|
-
export const timezoneOffset = computed(() => getTimeZoneOffset(new Date(), dateTime.value?.timeZone))
|
|
141
|
-
|
|
142
|
-
export function localTime(date) {
|
|
143
|
-
return new Date(new Date(date).getTime() + timezoneOffset?.value)
|
|
162
|
+
function nonEmptyObject(obj) { /// because command form can add empty objects on language change
|
|
163
|
+
if(!obj) return undefined
|
|
164
|
+
if(Object.keys(obj).length === 0) return undefined
|
|
165
|
+
return obj
|
|
144
166
|
}
|
|
145
167
|
|
|
168
|
+
|
|
146
169
|
export function useLocale(context) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
dateTime,
|
|
151
|
-
list,
|
|
152
|
-
number,
|
|
153
|
-
plural,
|
|
154
|
-
relativeTime,
|
|
155
|
-
timezoneOffset,
|
|
156
|
-
localTime
|
|
170
|
+
context = context ?? getCurrentInstance().appContext
|
|
171
|
+
if(!context.config.globalProperties.$locale) {
|
|
172
|
+
context.config.globalProperties.$locale = new Locale(context)
|
|
157
173
|
}
|
|
174
|
+
return context = context.config.globalProperties.$locale
|
|
158
175
|
}
|
|
159
176
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/vue3-components",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.23",
|
|
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-stack",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/vue3-ssr": "^0.8.
|
|
24
|
+
"@live-change/vue3-ssr": "^0.8.23",
|
|
25
25
|
"debug": "^4.3.4",
|
|
26
26
|
"mitt": "3.0.1",
|
|
27
27
|
"vue": "^3.4.19"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "581260523149a1e596f08e878b5f4fabeaba26ea"
|
|
30
30
|
}
|
package/view/RangeViewer.vue
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
<slot v-if="loadingTop" name="loadingTop"></slot>
|
|
17
17
|
|
|
18
|
+
<slot v-if="frozen && buckets?.changed" name="changedTop"></slot>
|
|
19
|
+
|
|
18
20
|
<template v-for="(bucket, bucketIndex) in buckets.buckets" :key="bucket.id">
|
|
19
21
|
|
|
20
22
|
<slot v-for="(item, itemIndex) in bucket.data" v-bind="{ item, bucket, itemIndex, bucketIndex }">
|
|
@@ -24,6 +26,8 @@
|
|
|
24
26
|
|
|
25
27
|
</template>
|
|
26
28
|
|
|
29
|
+
<slot v-if="frozen && buckets?.changed" name="changedBottom"></slot>
|
|
30
|
+
|
|
27
31
|
<slot v-if="loadingBottom" name="loadingBottom"></slot>
|
|
28
32
|
|
|
29
33
|
<scroll-border placement="bottom"
|
|
@@ -115,18 +119,23 @@
|
|
|
115
119
|
dropBottomDelay: {
|
|
116
120
|
type: Number,
|
|
117
121
|
default: 200
|
|
122
|
+
},
|
|
123
|
+
frozen: {
|
|
124
|
+
type: Boolean,
|
|
125
|
+
default: false
|
|
118
126
|
}
|
|
119
127
|
})
|
|
120
128
|
|
|
121
129
|
const {
|
|
122
130
|
pathFunction, bucketSize, initialPosition, softClose,
|
|
123
131
|
loadTopSensorSize, loadBottomSensorSize, dropTopSensorSize, dropBottomSensorSize,
|
|
124
|
-
loadTopDelay, loadBottomDelay, dropTopDelay, dropBottomDelay,
|
|
132
|
+
loadTopDelay, loadBottomDelay, dropTopDelay, dropBottomDelay, frozen
|
|
125
133
|
} = toRefs(props)
|
|
126
134
|
|
|
127
135
|
const emit = defineEmits([
|
|
128
136
|
'loadTop', 'loadBottom', 'loadedTop', 'loadedBottom',
|
|
129
|
-
'dropTop', 'dropBottom', 'droppedTop', 'droppedBottom'
|
|
137
|
+
'dropTop', 'dropBottom', 'droppedTop', 'droppedBottom',
|
|
138
|
+
'changed'
|
|
130
139
|
])
|
|
131
140
|
|
|
132
141
|
const loadingTop = ref(false)
|
|
@@ -162,6 +171,15 @@
|
|
|
162
171
|
throw new Error("Either buckets or pathFunction must be provided")
|
|
163
172
|
}
|
|
164
173
|
|
|
174
|
+
watch(() => frozen.value, (frozen) => {
|
|
175
|
+
if(frozen) buckets.value.freeze()
|
|
176
|
+
else buckets.value.unfreeze()
|
|
177
|
+
}, { immediate: true })
|
|
178
|
+
|
|
179
|
+
watch(() => buckets.value?.changed, () => {
|
|
180
|
+
emit('changed')
|
|
181
|
+
})
|
|
182
|
+
|
|
165
183
|
function canLoadBottom() {
|
|
166
184
|
return props.canLoadBottom && buckets.value.canLoadBottom()
|
|
167
185
|
}
|
|
@@ -221,6 +239,7 @@
|
|
|
221
239
|
return result
|
|
222
240
|
}
|
|
223
241
|
|
|
242
|
+
|
|
224
243
|
</script>
|
|
225
244
|
|
|
226
245
|
<style scoped>
|