renusify 2.5.2 → 3.0.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.
- package/components/app/index.vue +74 -22
- package/components/app/toast/index.vue +76 -71
- package/components/app/toast/toast.vue +62 -44
- package/components/avatar/index.vue +207 -84
- package/components/button/buttonConfirm.vue +53 -26
- package/components/button/buttonGroup.js +0 -2
- package/components/button/buttonGroup.vue +310 -62
- package/components/button/index.vue +584 -100
- package/components/calendar/index.js +0 -2
- package/components/calendar/index.vue +326 -262
- package/components/calendar/month.vue +64 -55
- package/components/calendar/year.vue +30 -25
- package/components/card/index.vue +139 -59
- package/components/codeEditor/highlightCss.vue +38 -39
- package/components/codeEditor/highlightHtml.vue +64 -64
- package/components/codeEditor/highlightJs.vue +37 -38
- package/components/codeEditor/index.vue +129 -79
- package/components/codeEditor/run.vue +225 -39
- package/components/codeEditor/useCodeFormatter.js +150 -0
- package/components/confirm/index.vue +139 -80
- package/components/container/col.vue +5 -4
- package/components/container/divider.vue +28 -19
- package/components/container/index.vue +34 -15
- package/components/container/row.vue +26 -9
- package/components/container/spacer.vue +2 -4
- package/components/container/style.scss +3 -0
- package/components/content/index.vue +49 -32
- package/components/cropper/index.vue +401 -244
- package/components/float/index.vue +542 -415
- package/components/form/addressInput/index.vue +184 -109
- package/components/form/camInput/index.vue +370 -244
- package/components/form/checkInput/index.vue +138 -71
- package/components/form/checkboxInput/index.vue +93 -49
- package/components/form/colorInput/Alpha.vue +81 -83
- package/components/form/colorInput/Hue.vue +91 -68
- package/components/form/colorInput/Preview.vue +43 -47
- package/components/form/colorInput/Saturation.vue +101 -86
- package/components/form/colorInput/index.vue +71 -39
- package/components/form/colorInput/picker.vue +111 -106
- package/components/form/colorInput/useColor.js +153 -0
- package/components/form/dateInput/index.vue +691 -356
- package/components/form/dateInput/month.vue +63 -54
- package/components/form/dateInput/year.vue +35 -25
- package/components/form/fileInput/index.js +0 -1
- package/components/form/fileInput/index.vue +263 -106
- package/components/form/fileInput/single.vue +332 -168
- package/components/form/groupInput/index.vue +199 -101
- package/components/form/index.vue +189 -83
- package/components/form/input/index.vue +416 -377
- package/components/form/jsonInput/JsonView.vue +54 -56
- package/components/form/jsonInput/index.vue +247 -165
- package/components/form/maskInput/index.vue +252 -132
- package/components/form/numberInput/index.js +0 -1
- package/components/form/numberInput/index.vue +226 -117
- package/components/form/passwordInput/index.js +2 -1
- package/components/form/passwordInput/index.vue +269 -102
- package/components/form/radioInput/index.vue +143 -72
- package/components/form/rangeInput/index.vue +280 -167
- package/components/form/ratingInput/index.vue +57 -57
- package/components/form/selectInput/index.js +1 -3
- package/components/form/selectInput/index.vue +584 -296
- package/components/form/switchInput/index.vue +73 -59
- package/components/form/telInput/index.js +0 -1
- package/components/form/telInput/index.vue +238 -135
- package/components/form/textArea/index.vue +72 -35
- package/components/form/textEditor/index.vue +739 -0
- package/components/form/{text-editor → textEditor}/style.scss +8 -16
- package/components/form/textInput/index.vue +54 -32
- package/components/form/timeInput/index.vue +82 -55
- package/components/form/timeInput/range.vue +115 -94
- package/components/form/timeInput/timepicker.vue +382 -449
- package/components/form/uniqueInput/index.vue +105 -48
- package/components/form/unitInput/index.vue +139 -84
- package/components/formCreator/index.js +0 -1
- package/components/formCreator/index.vue +314 -148
- package/components/highlight/index.vue +41 -25
- package/components/highlight/style.scss +2 -2
- package/components/highlight/{mixin.js → useHighlight.js} +181 -160
- package/components/icon/index.vue +79 -33
- package/components/img/index.vue +250 -147
- package/components/img/preview.vue +180 -198
- package/components/img/svgImg.vue +42 -39
- package/components/index.js +5 -20
- package/components/infinite/index.js +3 -3
- package/components/infinite/index.vue +290 -66
- package/components/map/index.vue +428 -261
- package/components/map/route.vue +794 -487
- package/components/map/select.vue +118 -58
- package/components/menu/index.vue +206 -94
- package/components/meta/meta.js +26 -3
- package/components/modal/index.vue +382 -156
- package/components/notify/index.vue +204 -86
- package/components/notify/notification.vue +38 -55
- package/components/progress/circle.vue +189 -70
- package/components/progress/line.vue +266 -46
- package/components/searchBox/index.js +1 -3
- package/components/searchBox/index.vue +194 -101
- package/components/skeleton/index.vue +45 -20
- package/components/slider/index.vue +319 -156
- package/components/swiper/index.vue +237 -108
- package/components/table/crud/footer.vue +77 -53
- package/components/table/crud/header.vue +71 -72
- package/components/table/crud/index.vue +629 -399
- package/components/table/index.vue +721 -278
- package/components/timeAgo/index.vue +145 -96
- package/components/tour/index.vue +338 -235
- package/components/tree/index.vue +235 -89
- package/components/tree/tree-element.vue +106 -106
- package/directive/animate/index.js +77 -0
- package/directive/clickOutSide/index.js +98 -0
- package/directive/drag/index.js +153 -0
- package/directive/index.js +11 -13
- package/directive/intersect/index.js +263 -0
- package/directive/mask/index.js +67 -0
- package/directive/parallax/index.js +78 -0
- package/directive/ripple/index.js +14 -0
- package/directive/scroll/index.js +272 -24
- package/directive/sortable/index.js +274 -0
- package/directive/title/index.js +75 -0
- package/directive/touch/index.js +268 -0
- package/index.js +11 -19
- package/package.json +5 -2
- package/plugins/validation/Validate.js +88 -79
- package/scripts/generate-docs.mjs +226 -0
- package/scripts/menu.mjs +240 -0
- package/scripts/parser.mjs +1086 -0
- package/style/_index.scss +7 -0
- package/style/app.scss +13 -65
- package/style/colors.scss +5 -22
- package/style/functions/index.scss +8 -0
- package/style/mixins/index.scss +17 -5
- package/style/variables/base.scss +155 -178
- package/style/variables/color.scss +0 -12
- package/style/variables/utilities.scss +0 -180
- package/tools/helper.js +0 -8
- package/tools/icons.js +7 -2
- package/tools/root.js +71 -0
- package/components/app/style.scss +0 -41
- package/components/app/toast/style.scss +0 -20
- package/components/avatar/style.scss +0 -32
- package/components/bar/bottomNav.js +0 -1
- package/components/bar/bottomNav.vue +0 -28
- package/components/bar/bottomNavigationCircle.js +0 -2
- package/components/bar/bottomNavigationCircle.vue +0 -99
- package/components/bar/scss/bottomNav.scss +0 -67
- package/components/bar/scss/toolbar.scss +0 -174
- package/components/bar/toolbar/index.js +0 -8
- package/components/bar/toolbar/index.vue +0 -35
- package/components/bar/toolbar/laptop.vue +0 -33
- package/components/bar/toolbar/menuChilds.vue +0 -41
- package/components/bar/toolbar/menuLaptop.vue +0 -41
- package/components/bar/toolbar/menuMob.vue +0 -39
- package/components/bar/toolbar/mixin.js +0 -43
- package/components/bar/toolbar/mobile.vue +0 -34
- package/components/breadcrumb/bredcrumbItem.vue +0 -39
- package/components/breadcrumb/index.js +0 -3
- package/components/breadcrumb/index.vue +0 -71
- package/components/breadcrumb/style.scss +0 -51
- package/components/button/style.scss +0 -411
- package/components/card/style.scss +0 -86
- package/components/chart/chart.js +0 -1
- package/components/chart/chart.vue +0 -69
- package/components/chart/worldMap.js +0 -2
- package/components/chart/worldMap.vue +0 -1112
- package/components/chat/MessageList.vue +0 -163
- package/components/chat/chatInput.vue +0 -150
- package/components/chat/chatMsg.vue +0 -276
- package/components/chat/index.js +0 -11
- package/components/chat/index.vue +0 -113
- package/components/chip/index.js +0 -3
- package/components/chip/index.vue +0 -77
- package/components/chip/style.scss +0 -199
- package/components/codeEditor/mixin.js +0 -145
- package/components/countdown/index.js +0 -1
- package/components/countdown/index.vue +0 -105
- package/components/form/colorInput/mixin.js +0 -132
- package/components/form/fileInput/file.js +0 -148
- package/components/form/telInput/assets/flags.png +0 -0
- package/components/form/telInput/assets/flags@2x.png +0 -0
- package/components/form/text-editor/index.vue +0 -705
- package/components/icon/style.scss +0 -17
- package/components/infinite/div.js +0 -6
- package/components/infinite/div.vue +0 -193
- package/components/infinite/page.js +0 -3
- package/components/infinite/page.vue +0 -105
- package/components/list/index.js +0 -3
- package/components/list/index.vue +0 -122
- package/components/list/style.scss +0 -66
- package/components/message/index.js +0 -4
- package/components/message/index.vue +0 -40
- package/components/modal/style.scss +0 -146
- package/components/nestable/NestableItem.vue +0 -307
- package/components/nestable/editable.js +0 -44
- package/components/nestable/index.js +0 -1
- package/components/nestable/index.vue +0 -226
- package/components/nestable/methods.js +0 -416
- package/components/progress/style.scss +0 -229
- package/components/table/style.scss +0 -338
- package/components/tabs/index.js +0 -3
- package/components/tabs/index.vue +0 -151
- package/components/timeline/index.js +0 -6
- package/components/timeline/index.vue +0 -76
- package/directive/resize/index.js +0 -30
- package/directive/skeleton/index.js +0 -27
- package/directive/skeleton/style.scss +0 -37
- package/plugins/request/Request.js +0 -68
- package/style/animation.scss +0 -94
- package/style/style.scss +0 -8
- package/tools/rootable.js +0 -75
- /package/components/form/{text-editor → textEditor}/index.js +0 -0
- /package/components/form/{text-editor → textEditor}/preview.js +0 -0
- /package/components/form/{text-editor → textEditor}/preview.vue +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :class="`${$r.prefix}json-view d-flex v-
|
|
2
|
+
<div :class="`${$r.prefix}json-view d-flex v-start flex-wrap`"
|
|
3
3
|
v-for="(value,key) in modelValue"
|
|
4
4
|
:key="key">
|
|
5
5
|
<div class="d-flex v-center me-1">
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<div v-if="typeof value==='object'" class="flex-grow-1 w-full ps-10">
|
|
12
12
|
<r-json-input :tile="tile"
|
|
13
13
|
:model-value="value"
|
|
14
|
-
@update:model-value="
|
|
14
|
+
@update:model-value="emitValue(key,$event)"
|
|
15
15
|
:disableAdd="disableAdd||template!==undefined"
|
|
16
16
|
:disableDel="disableDel||template!==undefined"
|
|
17
17
|
:translate="translate"
|
|
@@ -22,76 +22,74 @@
|
|
|
22
22
|
<r-text-input v-if="typeof value==='string'"
|
|
23
23
|
:tile="tile"
|
|
24
24
|
:label="!is_array?t(key):''"
|
|
25
|
-
:model-value="value" @update:model-value="
|
|
25
|
+
:model-value="value" @update:model-value="emitValue(key,$event)"></r-text-input>
|
|
26
26
|
<r-number-input v-else-if="typeof value==='number'"
|
|
27
27
|
:tile="tile"
|
|
28
28
|
:label="!is_array?t(key):''"
|
|
29
|
-
:model-value="value" @update:model-value="
|
|
29
|
+
:model-value="value" @update:model-value="emitValue(key,$event)"></r-number-input>
|
|
30
30
|
<r-switch-input v-else-if="typeof value==='boolean'"
|
|
31
31
|
:tile="tile"
|
|
32
32
|
:label="!is_array?t(key):''"
|
|
33
|
-
:model-value="value" @update:model-value="
|
|
33
|
+
:model-value="value" @update:model-value="emitValue(key,$event)"></r-switch-input>
|
|
34
34
|
|
|
35
35
|
</div>
|
|
36
36
|
|
|
37
37
|
</div>
|
|
38
38
|
</template>
|
|
39
|
-
<script>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
disableDel: Boolean,
|
|
47
|
-
tile: Boolean,
|
|
48
|
-
translate: Boolean
|
|
49
|
-
},
|
|
50
|
-
emits: ['update:modelValue'],
|
|
51
|
-
data() {
|
|
52
|
-
return {
|
|
53
|
-
time_id: null
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
computed: {
|
|
57
|
-
is_array() {
|
|
58
|
-
return Array.isArray(this.modelValue)
|
|
59
|
-
}
|
|
39
|
+
<script setup>
|
|
40
|
+
import {computed, inject} from 'vue'
|
|
41
|
+
|
|
42
|
+
const props = defineProps({
|
|
43
|
+
modelValue: {
|
|
44
|
+
type: Object,
|
|
45
|
+
default: () => ({})
|
|
60
46
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
47
|
+
template: Object,
|
|
48
|
+
disableAdd: Boolean,
|
|
49
|
+
disableDel: Boolean,
|
|
50
|
+
tile: Boolean,
|
|
51
|
+
translate: Boolean
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const emit = defineEmits(['update:modelValue'])
|
|
55
|
+
|
|
56
|
+
const {$t} = inject('renusify')
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
const is_array = computed(() => Array.isArray(props.modelValue))
|
|
60
|
+
|
|
61
|
+
const t = (key) => {
|
|
62
|
+
if (props.translate && $t) {
|
|
63
|
+
return $t(key)
|
|
64
|
+
}
|
|
65
|
+
return key
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const del = (key) => {
|
|
69
|
+
const newValue = JSON.parse(JSON.stringify(props.modelValue))
|
|
70
|
+
|
|
71
|
+
if (is_array.value) {
|
|
72
|
+
newValue.splice(key, 1)
|
|
73
|
+
} else {
|
|
74
|
+
delete newValue[key]
|
|
82
75
|
}
|
|
76
|
+
|
|
77
|
+
emit('update:modelValue', newValue)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const emitValue = (key, value) => {
|
|
81
|
+
const newValue = JSON.parse(JSON.stringify(props.modelValue))
|
|
82
|
+
|
|
83
|
+
newValue[key] = value
|
|
84
|
+
|
|
85
|
+
emit('update:modelValue', newValue)
|
|
83
86
|
}
|
|
87
|
+
|
|
84
88
|
</script>
|
|
85
89
|
<style lang="scss">
|
|
86
|
-
@use "../../../style
|
|
87
|
-
@use "../../../style/mixins";
|
|
90
|
+
@use "../../../style" as *;
|
|
88
91
|
|
|
89
|
-
.#{
|
|
90
|
-
|
|
91
|
-
border-right: 1px solid var(--color-sheet-low);
|
|
92
|
-
}
|
|
93
|
-
@include mixins.ltr() {
|
|
94
|
-
border-left: 1px solid var(--color-sheet-low);
|
|
95
|
-
}
|
|
92
|
+
.#{$prefix}json-view {
|
|
93
|
+
background-color: var(--color-sheet-container);
|
|
96
94
|
}
|
|
97
95
|
</style>
|
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<r-input :class="[`${$r.prefix}json-input`]"
|
|
3
|
+
:model-value="modelValue"
|
|
4
|
+
label-active>
|
|
3
5
|
<div class="d-flex v-center">
|
|
4
|
-
<r-btn v-if="!disableEditKey" class="
|
|
5
|
-
<div v-if="label">{{ label }}</div>
|
|
6
|
+
<r-btn v-if="!disableEditKey" class="my-1" icon size="sm" @click.prevent="modeForm=!modeForm">{ }</r-btn>
|
|
6
7
|
</div>
|
|
7
8
|
<div v-if="modeForm">
|
|
8
9
|
<json-view :model-value="modelValue"
|
|
9
|
-
@update:model-value="
|
|
10
|
+
@update:model-value="emitValue"
|
|
10
11
|
:template="template"
|
|
11
12
|
:disableAdd="disableAdd"
|
|
12
13
|
:disableDel="disableDel"
|
|
13
14
|
:translate="translate"
|
|
14
|
-
:tile="tile"
|
|
15
15
|
></json-view>
|
|
16
16
|
<r-btn
|
|
17
17
|
v-if="!show &&!disableAdd"
|
|
18
18
|
class="my-3 ms-1"
|
|
19
19
|
icon
|
|
20
|
-
size="
|
|
20
|
+
size="sm"
|
|
21
21
|
@click.prevent="open">
|
|
22
22
|
<r-icon v-html="$r.icons.plus"></r-icon>
|
|
23
23
|
</r-btn>
|
|
24
24
|
<div v-else-if="show" class="d-flex v-baseline flex-wrap">
|
|
25
|
+
<!-- Custom slot for add form with add function and info object -->
|
|
25
26
|
<slot :add="add" :info="info">
|
|
26
27
|
<r-text-input
|
|
27
28
|
v-if="!is_array"
|
|
28
29
|
v-model="info.key"
|
|
29
|
-
:
|
|
30
|
-
:tile="tile"
|
|
30
|
+
:placeholder="keyLabel||$t('key','renusify')"
|
|
31
31
|
class="w-30 pe-1"></r-text-input>
|
|
32
32
|
<div v-if="!valueType" class="w-20">
|
|
33
33
|
<r-select-input v-model="info.type"
|
|
34
34
|
:items="['text','number','boolean','json','array']"
|
|
35
|
-
:tile="tile"
|
|
36
35
|
:translate="translate"
|
|
37
36
|
class="me-1"
|
|
38
37
|
disableSearch
|
|
@@ -42,15 +41,15 @@
|
|
|
42
41
|
</div>
|
|
43
42
|
<r-text-input v-if="info.type==='text'"
|
|
44
43
|
v-model="info.value"
|
|
45
|
-
:
|
|
46
|
-
|
|
44
|
+
:placeholder="valueLabel||$t('value','renusify')"
|
|
45
|
+
></r-text-input>
|
|
47
46
|
<r-number-input v-else-if="info.type==='number'"
|
|
48
47
|
v-model="info.value"
|
|
49
|
-
:
|
|
48
|
+
:placeholder="valueLabel||$t('value','renusify')"></r-number-input>
|
|
50
49
|
<r-switch-input v-else-if="info.type==='boolean'"
|
|
51
50
|
v-model="info.value"
|
|
52
|
-
:label="valueLabel||$t('value','renusify')"
|
|
53
|
-
<r-btn
|
|
51
|
+
:label="valueLabel||$t('value','renusify')"></r-switch-input>
|
|
52
|
+
<r-btn class="ms-1 color-success" size="sm" @click.prevent="add">{{ $t('add', 'renusify') }}</r-btn>
|
|
54
53
|
</slot>
|
|
55
54
|
</div>
|
|
56
55
|
</div>
|
|
@@ -63,178 +62,261 @@
|
|
|
63
62
|
class="ltr w-full"
|
|
64
63
|
spellcheck="false"
|
|
65
64
|
:rows="modelValue?Object.keys(modelValue).length+5:5"
|
|
66
|
-
@keydown="setTab"
|
|
67
65
|
></textarea>
|
|
68
66
|
<div class="text-preview" v-html="code"></div>
|
|
69
67
|
</div>
|
|
70
|
-
</
|
|
68
|
+
</r-input>
|
|
71
69
|
</template>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
import
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
valueType: {
|
|
88
|
-
type: String,
|
|
89
|
-
validator: function (value) {
|
|
90
|
-
return ['text', 'number', 'boolean'].indexOf(value) !== -1
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
template: Object,
|
|
94
|
-
baseArray: Boolean,
|
|
95
|
-
disableAdd: Boolean,
|
|
96
|
-
tile: {type: Boolean, default: undefined},
|
|
97
|
-
disableEditKey: Boolean,
|
|
98
|
-
disableDel: Boolean,
|
|
99
|
-
translate: Boolean
|
|
70
|
+
|
|
71
|
+
<script setup>
|
|
72
|
+
import {computed, inject, onMounted, ref, watch} from 'vue'
|
|
73
|
+
import {useHighlight} from '../../highlight/useHighlight.js'
|
|
74
|
+
import JsonView from "./JsonView.vue"
|
|
75
|
+
|
|
76
|
+
const props = defineProps({
|
|
77
|
+
/**
|
|
78
|
+
* Label text for the key input field
|
|
79
|
+
* @type {String}
|
|
80
|
+
* @default 'key'
|
|
81
|
+
*/
|
|
82
|
+
keyLabel: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: 'key'
|
|
100
85
|
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
info: {}
|
|
110
|
-
}
|
|
86
|
+
/**
|
|
87
|
+
* Label text for the value input field
|
|
88
|
+
* @type {String}
|
|
89
|
+
* @default 'value'
|
|
90
|
+
*/
|
|
91
|
+
valueLabel: {
|
|
92
|
+
type: String,
|
|
93
|
+
default: 'value'
|
|
111
94
|
},
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
95
|
+
/**
|
|
96
|
+
* The JSON data model value (object or array)
|
|
97
|
+
* @type {Object|Array}
|
|
98
|
+
*/
|
|
99
|
+
modelValue: [Object, Array],
|
|
100
|
+
/**
|
|
101
|
+
* Fixed value type for all items when specified
|
|
102
|
+
* @type {String}
|
|
103
|
+
* @validator ['text', 'number', 'boolean']
|
|
104
|
+
*/
|
|
105
|
+
valueType: {
|
|
106
|
+
type: String,
|
|
107
|
+
validator: (value) => ['text', 'number', 'boolean'].includes(value)
|
|
116
108
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Template object for new items when adding
|
|
111
|
+
* @type {Object}
|
|
112
|
+
*/
|
|
113
|
+
template: Object,
|
|
114
|
+
/**
|
|
115
|
+
* Treat the model value as an array base
|
|
116
|
+
* @type {Boolean}
|
|
117
|
+
*/
|
|
118
|
+
baseArray: Boolean,
|
|
119
|
+
/**
|
|
120
|
+
* Disable the ability to add new items
|
|
121
|
+
* @type {Boolean}
|
|
122
|
+
*/
|
|
123
|
+
disableAdd: Boolean,
|
|
124
|
+
/**
|
|
125
|
+
* Disable the edit key toggle button
|
|
126
|
+
* @type {Boolean}
|
|
127
|
+
*/
|
|
128
|
+
disableEditKey: Boolean,
|
|
129
|
+
/**
|
|
130
|
+
* Disable the ability to delete items
|
|
131
|
+
* @type {Boolean}
|
|
132
|
+
*/
|
|
133
|
+
disableDel: Boolean,
|
|
134
|
+
/**
|
|
135
|
+
* Enable translation for UI texts
|
|
136
|
+
* @type {Boolean}
|
|
137
|
+
*/
|
|
138
|
+
translate: Boolean
|
|
139
|
+
})
|
|
130
140
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
141
|
+
const emit = defineEmits([
|
|
142
|
+
/**
|
|
143
|
+
* Emitted when the JSON data changes
|
|
144
|
+
* @param {Object|Array} value - The updated JSON data
|
|
145
|
+
*/
|
|
146
|
+
'update:modelValue'
|
|
147
|
+
])
|
|
148
|
+
|
|
149
|
+
const {highlight} = useHighlight()
|
|
150
|
+
|
|
151
|
+
const $t = inject('renusify').$t
|
|
152
|
+
|
|
153
|
+
// Reactive data
|
|
154
|
+
const lazyValue = ref('')
|
|
155
|
+
const modeForm = ref(true)
|
|
156
|
+
const error = ref(false)
|
|
157
|
+
const show = ref(false)
|
|
158
|
+
const code = ref('')
|
|
159
|
+
const info = ref({})
|
|
160
|
+
|
|
161
|
+
// Computed properties
|
|
162
|
+
/**
|
|
163
|
+
* Determines if the model value is an array
|
|
164
|
+
* @returns {Boolean} True if model is an array
|
|
165
|
+
*/
|
|
166
|
+
const is_array = computed(() => {
|
|
167
|
+
if (props.baseArray) {
|
|
168
|
+
return true
|
|
169
|
+
}
|
|
170
|
+
return Array.isArray(props.modelValue)
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
// Methods
|
|
174
|
+
/**
|
|
175
|
+
* Builds syntax-highlighted code from JSON
|
|
176
|
+
*/
|
|
177
|
+
const build_code = async () => {
|
|
178
|
+
try {
|
|
179
|
+
code.value = await highlight(lazyValue.value, 'json', true)
|
|
180
|
+
} catch (err) {
|
|
181
|
+
console.error('Error highlighting code:', err)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Opens the add form or applies template
|
|
187
|
+
*/
|
|
188
|
+
const open = () => {
|
|
189
|
+
if (props.template) {
|
|
190
|
+
let newValue = props.modelValue
|
|
191
|
+
|
|
192
|
+
if (!newValue) {
|
|
193
|
+
newValue = props.baseArray ? [] : {}
|
|
154
194
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (this.template) {
|
|
162
|
-
let d = this.modelValue
|
|
163
|
-
if (!d) {
|
|
164
|
-
d = []
|
|
165
|
-
}
|
|
166
|
-
d.push(Object.assign({}, {}, this.template))
|
|
167
|
-
this.$emit('update:modelValue', d)
|
|
168
|
-
} else {
|
|
169
|
-
if (this.valueType) {
|
|
170
|
-
this.info.type = this.valueType
|
|
171
|
-
}
|
|
172
|
-
this.show = true
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
emit(e) {
|
|
177
|
-
this.$emit('update:modelValue', e)
|
|
178
|
-
},
|
|
179
|
-
add() {
|
|
180
|
-
let d = this.modelValue
|
|
181
|
-
if (!d) {
|
|
182
|
-
if (this.baseArray) {
|
|
183
|
-
d = []
|
|
184
|
-
} else {
|
|
185
|
-
d = {}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
if (this.info.type === 'json') {
|
|
189
|
-
if (this.is_array) {
|
|
190
|
-
d.push({})
|
|
191
|
-
} else {
|
|
192
|
-
d[this.info.key] = {}
|
|
193
|
-
}
|
|
194
|
-
} else if (this.info.type === 'array') {
|
|
195
|
-
if (this.is_array) {
|
|
196
|
-
d.push([])
|
|
197
|
-
} else {
|
|
198
|
-
d[this.info.key] = []
|
|
199
|
-
}
|
|
200
|
-
} else {
|
|
201
|
-
if (this.is_array) {
|
|
202
|
-
d.push(this.info.value)
|
|
203
|
-
} else {
|
|
204
|
-
d[this.info.key] = this.info.value
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
this.show = false
|
|
208
|
-
this.info = {}
|
|
209
|
-
this.$emit('update:modelValue', d)
|
|
195
|
+
|
|
196
|
+
if (props.baseArray) {
|
|
197
|
+
const templateCopy = JSON.parse(JSON.stringify(props.template))
|
|
198
|
+
newValue.push(templateCopy)
|
|
199
|
+
} else {
|
|
200
|
+
newValue = JSON.parse(JSON.stringify(props.template))
|
|
210
201
|
}
|
|
202
|
+
|
|
203
|
+
emit('update:modelValue', newValue)
|
|
204
|
+
} else {
|
|
205
|
+
if (props.valueType) {
|
|
206
|
+
info.value.type = props.valueType
|
|
207
|
+
}
|
|
208
|
+
show.value = true
|
|
211
209
|
}
|
|
212
210
|
}
|
|
213
|
-
</script>
|
|
214
|
-
<style lang="scss">
|
|
215
|
-
@use "sass:map";
|
|
216
|
-
@use "../../../style/variables/base";
|
|
217
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Emits updated value from JsonView component
|
|
214
|
+
* @param {Object|Array} value - The updated JSON value
|
|
215
|
+
*/
|
|
216
|
+
const emitValue = (value) => {
|
|
217
|
+
emit('update:modelValue', value)
|
|
218
|
+
}
|
|
218
219
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
/**
|
|
221
|
+
* Adds a new item to the JSON data
|
|
222
|
+
*/
|
|
223
|
+
const add = () => {
|
|
224
|
+
let newValue = props.modelValue
|
|
222
225
|
|
|
223
|
-
|
|
224
|
-
|
|
226
|
+
if (!newValue) {
|
|
227
|
+
newValue = props.baseArray ? [] : {}
|
|
225
228
|
}
|
|
226
229
|
|
|
227
|
-
|
|
228
|
-
|
|
230
|
+
newValue = JSON.parse(JSON.stringify(newValue))
|
|
231
|
+
|
|
232
|
+
if (info.value.type === 'json') {
|
|
233
|
+
if (is_array.value) {
|
|
234
|
+
newValue.push({})
|
|
235
|
+
} else {
|
|
236
|
+
newValue[info.value.key] = {}
|
|
237
|
+
}
|
|
238
|
+
} else if (info.value.type === 'array') {
|
|
239
|
+
if (is_array.value) {
|
|
240
|
+
newValue.push([])
|
|
241
|
+
} else {
|
|
242
|
+
newValue[info.value.key] = []
|
|
243
|
+
}
|
|
244
|
+
} else {
|
|
245
|
+
if (is_array.value) {
|
|
246
|
+
newValue.push(info.value.value)
|
|
247
|
+
} else {
|
|
248
|
+
newValue[info.value.key] = info.value.value
|
|
249
|
+
}
|
|
229
250
|
}
|
|
230
251
|
|
|
231
|
-
.
|
|
232
|
-
|
|
252
|
+
show.value = false
|
|
253
|
+
info.value = {}
|
|
254
|
+
emit('update:modelValue', newValue)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Watchers
|
|
258
|
+
watch(modeForm, () => {
|
|
259
|
+
lazyValue.value = JSON.stringify(props.modelValue || {}, null, 4)
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
watch(() => props.modelValue, (newValue) => {
|
|
263
|
+
try {
|
|
264
|
+
error.value = false
|
|
265
|
+
|
|
266
|
+
if (lazyValue.value) {
|
|
267
|
+
const currentParsed = JSON.parse(lazyValue.value)
|
|
268
|
+
if (JSON.stringify(currentParsed) !== JSON.stringify(newValue)) {
|
|
269
|
+
lazyValue.value = JSON.stringify(newValue || {}, null, 4)
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
lazyValue.value = JSON.stringify(newValue || {}, null, 4)
|
|
273
|
+
}
|
|
274
|
+
} catch (er) {
|
|
275
|
+
error.value = true
|
|
276
|
+
console.error('Error parsing JSON:', er)
|
|
233
277
|
}
|
|
278
|
+
}, {deep: true})
|
|
234
279
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
280
|
+
watch(lazyValue, async (newValue) => {
|
|
281
|
+
try {
|
|
282
|
+
error.value = false
|
|
283
|
+
await build_code()
|
|
284
|
+
const parsed = JSON.parse(newValue)
|
|
285
|
+
emit('update:modelValue', parsed)
|
|
286
|
+
} catch (er) {
|
|
287
|
+
error.value = true
|
|
288
|
+
console.error('Error in lazyValue watch:', er)
|
|
289
|
+
}
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
// Lifecycle hooks
|
|
293
|
+
onMounted(async () => {
|
|
294
|
+
if (props.modelValue) {
|
|
295
|
+
try {
|
|
296
|
+
lazyValue.value = JSON.stringify(props.modelValue, null, 4)
|
|
297
|
+
await build_code()
|
|
298
|
+
} catch (err) {
|
|
299
|
+
console.error('Error initializing component:', err)
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
})
|
|
303
|
+
</script>
|
|
304
|
+
|
|
305
|
+
<style lang="scss">
|
|
306
|
+
@use "sass:map";
|
|
307
|
+
@use "../../../style/variables/base";
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
.#{base.$prefix}json-input {
|
|
311
|
+
> .input-control {
|
|
312
|
+
height: auto;
|
|
313
|
+
padding: 8px;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.input-holder {
|
|
317
|
+
.input-control {
|
|
318
|
+
background-color: var(--color-sheet-container-low);
|
|
319
|
+
}
|
|
238
320
|
}
|
|
239
321
|
|
|
240
322
|
.state-error {
|