@live-change/vue3-components 0.9.198 → 0.9.200
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/README.md +123 -0
- package/logic/data.js +4 -2
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: @live-change/vue3-components
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## @live-change/vue3-components
|
|
6
|
+
|
|
7
|
+
Pakiet `@live-change/vue3-components` dostarcza **zestaw gotowych komponentów Vue 3** zintegrowanych z Live Change:
|
|
8
|
+
|
|
9
|
+
- komponenty **logiczne** (`logic/*`) – obserwacja danych, strefy ładowania i pracy, analityka
|
|
10
|
+
- komponenty **formularzy** (`form/*`) – `DefinedForm`, `CommandForm`, `FormBind`
|
|
11
|
+
- komponenty **widoków** (`view/*`) – `ScrollLoader`, `VisibleArea`, `RangeViewer`
|
|
12
|
+
|
|
13
|
+
W typowej aplikacji rejestrujesz komponenty globalnie:
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import { createApp } from 'vue'
|
|
17
|
+
import { registerComponents } from '@live-change/vue3-components'
|
|
18
|
+
import App from './App.vue'
|
|
19
|
+
|
|
20
|
+
const app = createApp(App)
|
|
21
|
+
|
|
22
|
+
registerComponents(app, {
|
|
23
|
+
// opcjonalne ustawienia, np. analytics
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
app.mount('#app')
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Komponenty logiczne
|
|
30
|
+
|
|
31
|
+
Najważniejsze komponenty i helpery:
|
|
32
|
+
|
|
33
|
+
- `Loading`, `LoadingZone`, `LoadingWorkingZone` – spójne wyświetlanie stanów ładowania
|
|
34
|
+
- `WorkingZone` – zarządzanie „pracami” (operacjami) i ich błędami
|
|
35
|
+
- `Observe` – reaktywne obserwowanie ścieżek DAO
|
|
36
|
+
- `analytics`, `useAnalytics`, `installRouterAnalytics` – prosty system zdarzeń analitycznych
|
|
37
|
+
- `synchronized`, `synchronizedList` – synchronizacja danych formularzy z widokami/akcjami
|
|
38
|
+
|
|
39
|
+
Przykład użycia `synchronized` (fragment z `speed-dating`):
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import { synchronized } from '@live-change/vue3-components'
|
|
43
|
+
import { usePath, live, useActions } from '@live-change/vue3-ssr'
|
|
44
|
+
|
|
45
|
+
const path = usePath()
|
|
46
|
+
const actions = useActions()
|
|
47
|
+
|
|
48
|
+
const eventPath = computed(() => path.speedDating.event({ event }))
|
|
49
|
+
const eventData = await live(eventPath)
|
|
50
|
+
|
|
51
|
+
const synchronizedEvent = synchronized({
|
|
52
|
+
source: eventData,
|
|
53
|
+
update: actions.speedDating.updateEvent,
|
|
54
|
+
identifiers: { event },
|
|
55
|
+
recursive: true,
|
|
56
|
+
autoSave: true,
|
|
57
|
+
debounce: 600
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const editable = synchronizedEvent.value
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Formularze: `DefinedForm`, `CommandForm`, `FormBind`
|
|
64
|
+
|
|
65
|
+
- **`DefinedForm`** – renderuje formularz na podstawie definicji (np. definicji akcji)
|
|
66
|
+
- **`CommandForm`** – integruje formularz bezpośrednio z akcją (wysyła komendę po submit)
|
|
67
|
+
- **`FormBind`** – wiąże formularz z metadanymi i walidacją
|
|
68
|
+
|
|
69
|
+
Przykład prostego formularza opartego o definicję akcji:
|
|
70
|
+
|
|
71
|
+
```vue
|
|
72
|
+
<DefinedForm
|
|
73
|
+
:definition="definition"
|
|
74
|
+
v-model="editable"
|
|
75
|
+
@submit="save"
|
|
76
|
+
/>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Widoki: `ScrollLoader`, `VisibleArea`, `RangeViewer`
|
|
80
|
+
|
|
81
|
+
Komponenty widoków są zintegrowane z DAO i `RangeBuckets`:
|
|
82
|
+
|
|
83
|
+
- **`ScrollLoader`** – ładowanie kolejnych stron danych przy przewijaniu
|
|
84
|
+
- **`VisibleArea`** – reagowanie na widoczność fragmentu DOM
|
|
85
|
+
- **`RangeViewer`** – prezentacja danych podzielonych na zakresy
|
|
86
|
+
|
|
87
|
+
Użycie `ScrollLoader` w typowym widoku listy:
|
|
88
|
+
|
|
89
|
+
```vue
|
|
90
|
+
<scroll-loader :loadMore="loadMore" :canLoadMore="canLoadMore">
|
|
91
|
+
<div v-for="item in items" :key="item.id">
|
|
92
|
+
{{ item.name }}
|
|
93
|
+
</div>
|
|
94
|
+
</scroll-loader>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Receptury z projektów
|
|
98
|
+
|
|
99
|
+
#### `speed-dating` – formularz edycji eventu
|
|
100
|
+
|
|
101
|
+
Plik `front/src/pages/events/[event]/edit.vue` pokazuje:
|
|
102
|
+
|
|
103
|
+
- pobranie definicji modelu z `vue3-ssr`
|
|
104
|
+
- użycie `synchronized` do auto-zapisu
|
|
105
|
+
- `AutoEditor` z `frontend-auto-form` do generowania formularza na bazie modelu
|
|
106
|
+
|
|
107
|
+
#### `speed-dating` – wizytówka użytkownika
|
|
108
|
+
|
|
109
|
+
Plik `front/src/components/profile/ProfileSettings.vue`:
|
|
110
|
+
|
|
111
|
+
- `synchronized` dla draftu wizytówki (`draft` service)
|
|
112
|
+
- `AutoField` do mapowania właściwości modelu na pola formularza
|
|
113
|
+
- integracja z PrimeVue i własnymi komponentami UI
|
|
114
|
+
|
|
115
|
+
#### `family-tree` – strefy ładowania i praca na danych
|
|
116
|
+
|
|
117
|
+
W `family-tree` komponenty z `@live-change/vue3-components` są użyte do:
|
|
118
|
+
|
|
119
|
+
- synchronizacji identyfikacji użytkownika z analityką
|
|
120
|
+
- emisji zdarzeń przez `analytics.emit(...)`
|
|
121
|
+
|
|
122
|
+
Te przykłady będą opisane szerzej w sekcji „receptur frontendu” w dokumentacji.
|
|
123
|
+
|
package/logic/data.js
CHANGED
|
@@ -33,7 +33,7 @@ export function defaultData(definition, otherSrc) {
|
|
|
33
33
|
|
|
34
34
|
export function validateData(definition, data, validationType = 'validation',
|
|
35
35
|
context = undefined, propName = '', props = data,
|
|
36
|
-
outputValidatorParams = false) {
|
|
36
|
+
outputValidatorParams = false, validatedProperties = undefined) {
|
|
37
37
|
context = context || getCurrentInstance().appContext
|
|
38
38
|
//console.log("VALIDATIE DATA", definition, data, validationType, context, propName, props)
|
|
39
39
|
if(!context) throw new Error("No context")
|
|
@@ -60,8 +60,10 @@ export function validateData(definition, data, validationType = 'validation',
|
|
|
60
60
|
if(definition.properties) {
|
|
61
61
|
const propertyErrors = {}
|
|
62
62
|
for(let name in definition.properties) {
|
|
63
|
+
const computedName = propName ? propName + '.' + name : name
|
|
64
|
+
if(validatedProperties && !validatedProperties.includes(computedName)) continue
|
|
63
65
|
const error = validateData(definition.properties[name], data?.[name], validationType, context,
|
|
64
|
-
|
|
66
|
+
computedName, props, outputValidatorParams)
|
|
65
67
|
if(error) {
|
|
66
68
|
if(error.propertyErrors) {
|
|
67
69
|
for(let internalName in error.propertyErrors) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/vue3-components",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.200",
|
|
4
4
|
"description": "Live Change Framework - vue components",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://github.com/live-change/live-change-stack",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/vue3-ssr": "^0.9.
|
|
24
|
+
"@live-change/vue3-ssr": "^0.9.200",
|
|
25
25
|
"debug": "^4.3.4",
|
|
26
26
|
"mitt": "3.0.1",
|
|
27
27
|
"vue": "^3.5.12",
|
|
28
28
|
"vue3-scroll-border": "0.1.7"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "a509834e600a546297faa7d1534b6f52e66d2e66"
|
|
31
31
|
}
|