@mixd-id/web-scaffold 0.1.230406273 → 0.1.230406275
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/LICENSE +1 -0
- package/package.json +2 -1
- package/src/components/List.vue +28 -13
- package/src/components/Modal.vue +7 -1
- package/src/components/Textbox.vue +4 -1
- package/src/index.js +14 -5
- package/src/utils/preset-selector.mjs +21 -2
- package/src/widgets/WebComponentSelector.vue +4 -2
- package/src/widgets/WebPageBuilder.vue +27 -28
- package/src/widgets/WebPageSelector.vue +12 -4
package/LICENSE
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mixd-id/web-scaffold",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.230406275",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite serve",
|
|
7
7
|
"build": "vite build",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
".": "./src/index.js",
|
|
13
13
|
"./themes/default": "./src/themes/default/index.js",
|
|
14
14
|
"./components/*": "./src/components/*",
|
|
15
|
+
"./widgets/*": "./src/widgets/*",
|
|
15
16
|
"./mixin/component": "./src/mixin/component.js",
|
|
16
17
|
"./mixin/edit-mode": "./src/mixin/edit-mode.js",
|
|
17
18
|
"./middleware/http/trim-string": "./src/middleware/http/trim-string.js",
|
package/src/components/List.vue
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="flex flex-col">
|
|
3
|
+
|
|
3
4
|
<div v-if="readyState === 1"
|
|
4
5
|
class="flex-1 flex flex-row">
|
|
5
6
|
|
|
@@ -147,7 +148,7 @@ export default{
|
|
|
147
148
|
props: {
|
|
148
149
|
config: {
|
|
149
150
|
type: Object,
|
|
150
|
-
default: {}
|
|
151
|
+
default: { columns:[], presets:[{}] }
|
|
151
152
|
},
|
|
152
153
|
presetKey: String,
|
|
153
154
|
subscribeKey: String,
|
|
@@ -239,7 +240,7 @@ export default{
|
|
|
239
240
|
this.preset.columns.push(...columns)
|
|
240
241
|
}
|
|
241
242
|
|
|
242
|
-
this.data
|
|
243
|
+
Object.assign(this.data, data ?? {})
|
|
243
244
|
|
|
244
245
|
this.$emit('after-load')
|
|
245
246
|
})
|
|
@@ -271,22 +272,32 @@ export default{
|
|
|
271
272
|
},
|
|
272
273
|
|
|
273
274
|
loadPreset(){
|
|
274
|
-
if(this.
|
|
275
|
-
if(
|
|
275
|
+
if(!('reset' in this.$route.query)){
|
|
276
|
+
if(this.presetKey){
|
|
276
277
|
return this.socket.send('user.preset', { key:this.presetKey })
|
|
277
278
|
.then(config => {
|
|
278
279
|
Object.assign(this.config, config)
|
|
279
280
|
})
|
|
280
281
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
return new Promise(resolve => resolve())
|
|
283
|
+
}
|
|
284
|
+
else{
|
|
285
|
+
return new Promise((resolve) => {
|
|
286
|
+
this.savePreset()
|
|
287
|
+
|
|
288
|
+
const query = {}
|
|
289
|
+
for(let key in this.$route.query){
|
|
290
|
+
if(key !== 'reset')
|
|
291
|
+
query[key] = this.$route.query[key]
|
|
292
|
+
}
|
|
293
|
+
this.$router.replace({
|
|
294
|
+
...this.$route,
|
|
295
|
+
query
|
|
286
296
|
})
|
|
287
|
-
|
|
297
|
+
|
|
298
|
+
resolve()
|
|
299
|
+
})
|
|
288
300
|
}
|
|
289
|
-
return new Promise(resolve => resolve())
|
|
290
301
|
},
|
|
291
302
|
|
|
292
303
|
resize1(w){
|
|
@@ -366,11 +377,15 @@ export default{
|
|
|
366
377
|
})
|
|
367
378
|
.then(({ items:nextItems }) => {
|
|
368
379
|
nextItems.forEach(item => this.$util.unshift(this.data.items, item, { highlight: true }))
|
|
369
|
-
|
|
380
|
+
|
|
381
|
+
const key = nextItems[0] && nextItems[0].uid ? 'uid' : 'id'
|
|
382
|
+
const destroyedItems = items.filter(_ => !nextItems.find(i => i[key] === _[key]))
|
|
370
383
|
this.$util.remove(this.data.items, destroyedItems)
|
|
371
384
|
})
|
|
372
385
|
break
|
|
373
386
|
}
|
|
387
|
+
|
|
388
|
+
this.$emit('signal', event, items)
|
|
374
389
|
},
|
|
375
390
|
|
|
376
391
|
resize(){
|
|
@@ -382,7 +397,7 @@ export default{
|
|
|
382
397
|
|
|
383
398
|
components: {PresetBar, PresetSelector, VirtualGrid, VirtualTable},
|
|
384
399
|
|
|
385
|
-
emits: [ 'after-load', 'open-preset' ],
|
|
400
|
+
emits: [ 'after-load', 'open-preset', 'signal' ],
|
|
386
401
|
|
|
387
402
|
inject: [ 'socket', 'toast' ],
|
|
388
403
|
|
package/src/components/Modal.vue
CHANGED
|
@@ -124,9 +124,15 @@ export default{
|
|
|
124
124
|
|
|
125
125
|
close(){
|
|
126
126
|
if(this.hash){
|
|
127
|
+
|
|
128
|
+
const hash = this.$route.hash
|
|
129
|
+
.split('#')
|
|
130
|
+
.filter(_ => _.length > 0 && !_.startsWith(this.hash.substring(1)))
|
|
131
|
+
.join('#')
|
|
132
|
+
|
|
127
133
|
this.$router.replace({
|
|
128
134
|
...this.$route,
|
|
129
|
-
hash
|
|
135
|
+
hash
|
|
130
136
|
})
|
|
131
137
|
}
|
|
132
138
|
else{
|
package/src/index.js
CHANGED
|
@@ -188,9 +188,12 @@ const util = {
|
|
|
188
188
|
window.addEventListener('mouseup', onMouseUp)
|
|
189
189
|
},
|
|
190
190
|
|
|
191
|
-
push: (arr, items, opt = {
|
|
191
|
+
push: (arr, items, opt = {}) => {
|
|
192
192
|
if(!Array.isArray(arr)) return
|
|
193
193
|
if(!Array.isArray(items)) items = [ items ]
|
|
194
|
+
if(!opt.key){
|
|
195
|
+
opt.key = items[0] && items[0].uid ? 'uid' : 'id'
|
|
196
|
+
}
|
|
194
197
|
|
|
195
198
|
for(let item of items){
|
|
196
199
|
if(!item) continue
|
|
@@ -205,16 +208,19 @@ const util = {
|
|
|
205
208
|
}
|
|
206
209
|
},
|
|
207
210
|
|
|
208
|
-
remove: (arr,
|
|
211
|
+
remove: (arr, items, opt = {}) => {
|
|
209
212
|
if(!Array.isArray(arr)) return
|
|
210
|
-
if(!Array.isArray(
|
|
213
|
+
if(!Array.isArray(items)) items = [ items ]
|
|
214
|
+
if(!opt.key){
|
|
215
|
+
opt.key = items[0] && items[0].uid ? 'uid' : 'id'
|
|
216
|
+
}
|
|
211
217
|
|
|
212
|
-
|
|
218
|
+
items = groupBy(items, opt.key)
|
|
213
219
|
|
|
214
220
|
for(let i = arr.length - 1 ; i >= 0 ; i--){
|
|
215
221
|
if(!arr[i]) continue
|
|
216
222
|
|
|
217
|
-
if(arr[i][opt.key] in
|
|
223
|
+
if(arr[i][opt.key] in items){
|
|
218
224
|
arr.splice(i, 1)
|
|
219
225
|
}
|
|
220
226
|
}
|
|
@@ -222,6 +228,9 @@ const util = {
|
|
|
222
228
|
|
|
223
229
|
unshift: (arr, item, opt = {}) => {
|
|
224
230
|
if(!Array.isArray(arr)) return
|
|
231
|
+
if(!opt.key){
|
|
232
|
+
opt.key = item && item.uid ? 'uid' : 'id'
|
|
233
|
+
}
|
|
225
234
|
|
|
226
235
|
opt = Object.assign({ key:"id", highlight:false }, opt)
|
|
227
236
|
|
|
@@ -20,10 +20,11 @@ const sortsFn = function(a, b, sorts, index){
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const pickColumns = function(columns, keys){
|
|
23
|
+
if(!Array.isArray(columns)) return keys
|
|
23
24
|
|
|
24
25
|
const picked = []
|
|
25
26
|
|
|
26
|
-
const groupedColumns =
|
|
27
|
+
const groupedColumns = columns
|
|
27
28
|
.reduce((acc, column) => {
|
|
28
29
|
acc[column.key] = column
|
|
29
30
|
return acc
|
|
@@ -39,7 +40,25 @@ const pickColumns = function(columns, keys){
|
|
|
39
40
|
return picked
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
const setupConfig = (config) => {
|
|
44
|
+
|
|
45
|
+
if(Array.isArray(config.presets)){
|
|
46
|
+
for(let idx in config.presets){
|
|
47
|
+
if(!Array.isArray(config.presets[idx].columns)){
|
|
48
|
+
config.presets[idx].columns = []
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if(config.presets[idx].columns[0] && typeof config.presets[idx].columns[0] === 'string'){
|
|
52
|
+
config.presets[idx].columns = pickColumns(config.columns ?? [], config.presets[idx].columns)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return config
|
|
58
|
+
}
|
|
59
|
+
|
|
42
60
|
export {
|
|
43
61
|
sortsFn,
|
|
44
|
-
pickColumns
|
|
62
|
+
pickColumns,
|
|
63
|
+
setupConfig
|
|
45
64
|
}
|
|
@@ -110,8 +110,10 @@ export default{
|
|
|
110
110
|
if(!this.componentSrc) return
|
|
111
111
|
|
|
112
112
|
this.socketEmit2(this.componentSrc, { type: 2 })
|
|
113
|
-
.then((
|
|
114
|
-
|
|
113
|
+
.then((res) => {
|
|
114
|
+
const { items } = res ?? {}
|
|
115
|
+
|
|
116
|
+
this.extraComponents = (items ?? []).map(_ => {
|
|
115
117
|
return {
|
|
116
118
|
..._.data,
|
|
117
119
|
name: _.name,
|
|
@@ -86,23 +86,13 @@
|
|
|
86
86
|
|
|
87
87
|
<div class="flex-1 flex flex-col overflow-y-auto">
|
|
88
88
|
|
|
89
|
-
<div class="flex flex-col items-center
|
|
90
|
-
<Tabs
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
<svg width="14" height="14" class="fill-text pointer-events-none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 40c118.621 0 216 96.075 216 216 0 119.291-96.61 216-216 216-119.244 0-216-96.562-216-216 0-119.203 96.602-216 216-216m0-32C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm-36 344h12V232h-12c-6.627 0-12-5.373-12-12v-8c0-6.627 5.373-12 12-12h48c6.627 0 12 5.373 12 12v140h12c6.627 0 12 5.373 12 12v8c0 6.627-5.373 12-12 12h-72c-6.627 0-12-5.373-12-12v-8c0-6.627 5.373-12 12-12zm36-240c-17.673 0-32 14.327-32 32s14.327 32 32 32 32-14.327 32-32-14.327-32-32-32z"/></svg>
|
|
94
|
-
</div>
|
|
95
|
-
<div v-else-if="item.value === 2" v-tooltip="'Components'" class="p-1 px-2">
|
|
96
|
-
<svg width="14" height="14" class="fill-text pointer-events-none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M512 256.01c0-9.98-5.81-18.94-14.77-22.81l-99.74-43.27 99.7-43.26c9-3.89 14.81-12.84 14.81-22.81s-5.81-18.92-14.77-22.79L271.94 3.33c-10.1-4.44-21.71-4.45-31.87-.02L14.81 101.06C5.81 104.95 0 113.9 0 123.87s5.81 18.92 14.77 22.79l99.73 43.28-99.7 43.26C5.81 237.08 0 246.03 0 256.01c0 9.97 5.81 18.92 14.77 22.79l99.72 43.26-99.69 43.25C5.81 369.21 0 378.16 0 388.14c0 9.97 5.81 18.92 14.77 22.79l225.32 97.76a40.066 40.066 0 0 0 15.9 3.31c5.42 0 10.84-1.1 15.9-3.31l225.29-97.74c9-3.89 14.81-12.84 14.81-22.81 0-9.98-5.81-18.94-14.77-22.81l-99.72-43.26 99.69-43.25c9-3.89 14.81-12.84 14.81-22.81zM45.23 123.87l208.03-90.26.03-.02c1.74-.71 3.65-.76 5.45.02l208.03 90.26-208.03 90.27c-1.81.77-3.74.77-5.48 0L45.23 123.87zm421.54 264.27L258.74 478.4c-1.81.77-3.74.77-5.48 0L45.23 388.13l110.76-48.06 84.11 36.49a40.066 40.066 0 0 0 15.9 3.31c5.42 0 10.84-1.1 15.9-3.31l84.11-36.49 110.76 48.07zm-208.03-41.87c-1.81.77-3.74.77-5.48 0L45.23 256 156 207.94l84.1 36.5a40.066 40.066 0 0 0 15.9 3.31c5.42 0 10.84-1.1 15.9-3.31l84.1-36.49 110.77 48.07-208.03 90.25z"/></svg>
|
|
97
|
-
</div>
|
|
98
|
-
<div v-else-if="item.value === 3" v-tooltip="'Datasource'" class="p-1 px-2">
|
|
99
|
-
<svg width="14" height="14" class="fill-text pointer-events-none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M224 32c106 0 192 28.75 192 64v32c0 35.25-86 64-192 64S32 163.25 32 128V96c0-35.25 86-64 192-64m192 149.5V224c0 35.25-86 64-192 64S32 259.25 32 224v-42.5c41.25 29 116.75 42.5 192 42.5s150.749-13.5 192-42.5m0 96V320c0 35.25-86 64-192 64S32 355.25 32 320v-42.5c41.25 29 116.75 42.5 192 42.5s150.749-13.5 192-42.5m0 96V416c0 35.25-86 64-192 64S32 451.25 32 416v-42.5c41.25 29 116.75 42.5 192 42.5s150.749-13.5 192-42.5M224 0C145.858 0 0 18.801 0 96v320c0 77.338 146.096 96 224 96 78.142 0 224-18.801 224-96V96c0-77.338-146.096-96-224-96z"/></svg>
|
|
100
|
-
</div>
|
|
101
|
-
</template>
|
|
102
|
-
</Tabs>
|
|
89
|
+
<div class="flex flex-col items-center border-b-[1px] border-text-100" @click="currentArea = 'header'">
|
|
90
|
+
<Tabs :items="tabItems"
|
|
91
|
+
class="pt-1"
|
|
92
|
+
v-model="store.tabIndex" />
|
|
103
93
|
</div>
|
|
104
94
|
|
|
105
|
-
<div v-if="store.tabIndex === 1" class="flex-1 overflow-y-auto flex flex-col gap-4
|
|
95
|
+
<div v-if="store.tabIndex === 1" class="flex-1 overflow-y-auto flex flex-col gap-4 p-6" @click="currentArea = 'pageinfo'">
|
|
106
96
|
|
|
107
97
|
<div class="flex flex-row gap-4" v-if="!page.isSystem">
|
|
108
98
|
<div class="flex flex-col gap-1">
|
|
@@ -205,7 +195,7 @@
|
|
|
205
195
|
|
|
206
196
|
</div>
|
|
207
197
|
|
|
208
|
-
<div v-else-if="store.tabIndex === 2" class="flex-1 overflow-y-auto
|
|
198
|
+
<div v-else-if="store.tabIndex === 2" class="flex-1 overflow-y-auto p-6 flex flex-col gap-6">
|
|
209
199
|
|
|
210
200
|
<div>
|
|
211
201
|
<div class="flex flex-row gap-2" @click="currentArea = 'layout'">
|
|
@@ -353,7 +343,7 @@
|
|
|
353
343
|
|
|
354
344
|
</div>
|
|
355
345
|
|
|
356
|
-
<div v-else-if="store.tabIndex === 3" class="flex-1" @click="currentArea = 'datasource'">
|
|
346
|
+
<div v-else-if="store.tabIndex === 3" class="flex-1 overflow-y-auto p-6" @click="currentArea = 'datasource'">
|
|
357
347
|
|
|
358
348
|
<div class="p-6 flex flex-col gap-2" v-if="Array.isArray(page.datasource) && page.datasource.length > 0">
|
|
359
349
|
<div v-for="(ds, index) in page.datasource"
|
|
@@ -652,6 +642,16 @@ export default{
|
|
|
652
642
|
}
|
|
653
643
|
},
|
|
654
644
|
|
|
645
|
+
src:{
|
|
646
|
+
type: [ String, Array ],
|
|
647
|
+
default: 'page.open'
|
|
648
|
+
},
|
|
649
|
+
|
|
650
|
+
saveSrc:{
|
|
651
|
+
type: [ String, Array ],
|
|
652
|
+
default: 'page.save'
|
|
653
|
+
},
|
|
654
|
+
|
|
655
655
|
/**
|
|
656
656
|
* @param {Object} config
|
|
657
657
|
* @param {String} config.method
|
|
@@ -901,12 +901,11 @@ export default{
|
|
|
901
901
|
},
|
|
902
902
|
|
|
903
903
|
async load(){
|
|
904
|
-
return this.socketEmit2(
|
|
904
|
+
return this.socketEmit2(this.src, { uid:this.$route.params.uid })
|
|
905
905
|
.then(({ page, layouts, host }) => {
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
this.
|
|
909
|
-
this.host = host
|
|
906
|
+
if(page) this.page = page
|
|
907
|
+
if(layouts) this.layouts = layouts
|
|
908
|
+
if(host) this.host = host
|
|
910
909
|
|
|
911
910
|
this.prevData = {
|
|
912
911
|
page: JSON.stringify(this.page),
|
|
@@ -1267,7 +1266,7 @@ export default{
|
|
|
1267
1266
|
createInstances(){
|
|
1268
1267
|
if(!this.page.instances || typeof this.page.instances !== 'object' || Array.isArray(this.page.instances))
|
|
1269
1268
|
this.page.instances = {}
|
|
1270
|
-
this.page.instances.components = this.page.components.map((_) => this.createComponentInstance(_)).filter(_=>_)
|
|
1269
|
+
this.page.instances.components = (this.page.components ?? []).map((_) => this.createComponentInstance(_)).filter(_=>_)
|
|
1271
1270
|
|
|
1272
1271
|
if(this.layout){
|
|
1273
1272
|
if(!this.layout.instances || typeof this.layout.instances !== 'object' || Array.isArray(this.layout.instances))
|
|
@@ -1283,7 +1282,7 @@ export default{
|
|
|
1283
1282
|
this.createInstances()
|
|
1284
1283
|
|
|
1285
1284
|
this.$refs.saveBtn.setState(2)
|
|
1286
|
-
this.socketEmit2(
|
|
1285
|
+
this.socketEmit2(this.saveSrc, { ...this.page, layout:this.layout })
|
|
1287
1286
|
.then((_) => {
|
|
1288
1287
|
this.prevData = {
|
|
1289
1288
|
page: JSON.stringify(this.page),
|
|
@@ -1348,15 +1347,15 @@ export default{
|
|
|
1348
1347
|
|
|
1349
1348
|
if(this.$refs.iframe){
|
|
1350
1349
|
|
|
1351
|
-
const headers = this.layout && this.layout.headers ?
|
|
1350
|
+
const headers = this.layout && Array.isArray(this.layout.headers) ?
|
|
1352
1351
|
this.layout.headers.map((_) => this.createComponentInstance(_)).filter(_=>_) :
|
|
1353
1352
|
null
|
|
1354
1353
|
|
|
1355
|
-
const footers = this.layout && this.layout.footers ?
|
|
1354
|
+
const footers = this.layout && Array.isArray(this.layout.footers) ?
|
|
1356
1355
|
this.layout.footers.map((_) => this.createComponentInstance(_)).filter(_=>_) :
|
|
1357
1356
|
null
|
|
1358
1357
|
|
|
1359
|
-
const components = this.page.components.map((_) => this.createComponentInstance(_)).filter(_=>_)
|
|
1358
|
+
const components = (this.page.components ?? []).map((_) => this.createComponentInstance(_)).filter(_=>_)
|
|
1360
1359
|
|
|
1361
1360
|
const stylesheet = this.layout ? this.createStyleSheet(this.layout.styles) : ''
|
|
1362
1361
|
|
|
@@ -1514,7 +1513,7 @@ export default{
|
|
|
1514
1513
|
|
|
1515
1514
|
layout(){
|
|
1516
1515
|
if(this.page){
|
|
1517
|
-
return this.layouts.find((_) => _.id === parseInt(this.page.layoutId))
|
|
1516
|
+
return (this.layouts ?? []).find((_) => _.id === parseInt(this.page.layoutId))
|
|
1518
1517
|
}
|
|
1519
1518
|
},
|
|
1520
1519
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<Modal @show="load">
|
|
2
|
+
<Modal @show="load" :hash="hash">
|
|
3
3
|
<template v-slot:head>
|
|
4
4
|
<div class="relative p-6">
|
|
5
5
|
<h3>{{ $t('Choose Template:') }}</h3>
|
|
@@ -71,6 +71,11 @@ export default{
|
|
|
71
71
|
default: 'page.create'
|
|
72
72
|
},
|
|
73
73
|
|
|
74
|
+
hash: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: '#selector'
|
|
77
|
+
},
|
|
78
|
+
|
|
74
79
|
templateSrc: String,
|
|
75
80
|
|
|
76
81
|
templates: Array,
|
|
@@ -99,9 +104,12 @@ export default{
|
|
|
99
104
|
load(){
|
|
100
105
|
if(this.templateSrc){
|
|
101
106
|
this.socketEmit2(this.templateSrc, { type:1 })
|
|
102
|
-
.then((
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
.then((res) => {
|
|
108
|
+
if(res){
|
|
109
|
+
const { items:[] } = res ?? {}
|
|
110
|
+
this.selectedGroup = items[0] ? items[0].group : this.selectedGroup
|
|
111
|
+
this._templates = items
|
|
112
|
+
}
|
|
105
113
|
})
|
|
106
114
|
}
|
|
107
115
|
},
|