renusify 2.5.1 → 3.0.0
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 +208 -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 +140 -81
- 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 +87 -47
- 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 +72 -40
- 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 +323 -164
- 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 +83 -56
- package/components/form/timeInput/range.vue +116 -95
- 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 +249 -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 +1 -2
- package/components/infinite/index.vue +248 -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 +201 -91
- package/components/meta/meta.js +26 -3
- package/components/modal/index.vue +383 -158
- 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 +318 -156
- package/components/swiper/index.vue +254 -106
- package/components/table/crud/footer.vue +77 -53
- package/components/table/crud/header.vue +71 -72
- package/components/table/crud/index.vue +631 -401
- 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 +107 -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 +244 -0
- package/directive/sortable/index.js +274 -0
- package/directive/title/index.js +75 -0
- package/directive/touch/index.js +268 -0
- package/index.js +10 -8
- 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 +154 -175
- package/style/variables/color.scss +0 -12
- package/style/variables/utilities.scss +0 -180
- package/tools/helper.js +0 -8
- package/tools/icons.js +6 -1
- 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 -710
- 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 v-if="!autoSend" :class="$r.prefix+'form-creator'"
|
|
2
|
+
<div v-if="!autoSend" :class="$r.prefix+'form-creator'">
|
|
3
3
|
<r-container>
|
|
4
4
|
<h1 v-if="title" class="title-1">{{ title }}</h1>
|
|
5
5
|
<r-form ref="form" v-model="valid" @submit.prevent="save">
|
|
@@ -16,7 +16,17 @@
|
|
|
16
16
|
</r-col>
|
|
17
17
|
</template>
|
|
18
18
|
</r-row>
|
|
19
|
-
<
|
|
19
|
+
<template v-for="(item,i) in errors"
|
|
20
|
+
:key="i">
|
|
21
|
+
<div class="mb-2 br-md color-error d-flex">
|
|
22
|
+
<span>{{ $t(i) }}:</span>
|
|
23
|
+
<span class="flex-grow-1">
|
|
24
|
+
<div v-for="(er,k) in item" :key="k+'-'+i">
|
|
25
|
+
{{ $t(er) }}
|
|
26
|
+
</div>
|
|
27
|
+
</span>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
20
30
|
<div class="text-end my-12">
|
|
21
31
|
<r-btn @click.prevent="close"
|
|
22
32
|
class="color-error-text mx-1"
|
|
@@ -36,162 +46,318 @@
|
|
|
36
46
|
</div>
|
|
37
47
|
</template>
|
|
38
48
|
|
|
39
|
-
<script>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
49
|
+
<script setup>
|
|
50
|
+
import {ref, watch, onMounted, inject} from 'vue'
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @example // Advanced usage with mixed fields
|
|
54
|
+
* <template>
|
|
55
|
+
* <r-form-creator :url="url"
|
|
56
|
+
* :title="title"
|
|
57
|
+
* :auto-Send="autoSend"
|
|
58
|
+
* :redirect="redirect"
|
|
59
|
+
* :method="method"
|
|
60
|
+
* :options="options"
|
|
61
|
+
* v-model="modelValue"
|
|
62
|
+
* :headers="headers"
|
|
63
|
+
* @update:model-Value="log(`update:modelValue`,$event)"
|
|
64
|
+
* @ok="log(`ok`,$event)" ></r-form-creator>
|
|
65
|
+
* </template>
|
|
66
|
+
* <script>
|
|
67
|
+
* import { ref } from 'vue'
|
|
68
|
+
* const modelValue=ref(modelValue)
|
|
69
|
+
* const url=ref(null)
|
|
70
|
+
* const title=ref("Add form")
|
|
71
|
+
* const autoSend=ref(false)
|
|
72
|
+
* const method=ref("post")
|
|
73
|
+
* const headers=ref(null)
|
|
74
|
+
* const options=ref({
|
|
75
|
+
* name:{"type": "r-text-input","props":{"rules": ["required"]}},
|
|
76
|
+
* family:{"type": "r-text-input","props":{"rules": ["required"]}},
|
|
77
|
+
* age:{"type": "r-number-input",$if:[["$name","!=","$family"]],"props":{"rules": ["required","min:7","max:70"]}},
|
|
78
|
+
* phone:{"type": "r-mask-input",$if:[["$age",">",7],["$age","<=",60]],"props":{"rules": ["required"],"mask": "0NNN NNN NNNN"}},
|
|
79
|
+
* mix:{"type": "r-text-input","$bind":[["label","name"]]},
|
|
80
|
+
* })
|
|
81
|
+
* const log=(name,e)=>{
|
|
82
|
+
* console.log(name,e)
|
|
83
|
+
* }
|
|
84
|
+
* <//script>
|
|
85
|
+
* */
|
|
86
|
+
|
|
87
|
+
const props = defineProps({
|
|
88
|
+
/**
|
|
89
|
+
* API endpoint URL for form submission
|
|
90
|
+
* @type {String}
|
|
91
|
+
* @required
|
|
92
|
+
*/
|
|
93
|
+
url: {
|
|
94
|
+
required: true,
|
|
95
|
+
type: String
|
|
70
96
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
inputs: {}
|
|
80
|
-
}
|
|
97
|
+
/**
|
|
98
|
+
* Form title displayed in the UI
|
|
99
|
+
* @type {String}
|
|
100
|
+
* @default 'Add form'
|
|
101
|
+
*/
|
|
102
|
+
title: {
|
|
103
|
+
default: 'Add form',
|
|
104
|
+
type: String
|
|
81
105
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Whether to automatically submit the form on mount
|
|
108
|
+
* @type {Boolean}
|
|
109
|
+
* @default false
|
|
110
|
+
*/
|
|
111
|
+
autoSend: Boolean,
|
|
112
|
+
/**
|
|
113
|
+
* URL to redirect after successful submission
|
|
114
|
+
* @type {String}
|
|
115
|
+
*/
|
|
116
|
+
redirect: {
|
|
117
|
+
type: String
|
|
86
118
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
handler: function (n) {
|
|
97
|
-
this.$emit('update:modelValue', n)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
119
|
+
/**
|
|
120
|
+
* HTTP method for form submission
|
|
121
|
+
* @type {String}
|
|
122
|
+
* @default 'post'
|
|
123
|
+
* @values 'post', 'put', 'patch', 'delete'
|
|
124
|
+
*/
|
|
125
|
+
method: {
|
|
126
|
+
default: 'post',
|
|
127
|
+
type: String
|
|
100
128
|
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Form field configuration options
|
|
131
|
+
* @type {Object|Array}
|
|
132
|
+
* @description Defines form fields, validation rules, and conditional logic
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* options: {
|
|
136
|
+
* name:{"type": "r-text-input","props":{"rules": ["required"]}},
|
|
137
|
+
* family:{"type": "r-text-input","props":{"rules": ["required"]}},
|
|
138
|
+
* age:{"type": "r-number-input",$if:[["$name","!=","$family"]],"props":{"rules": ["required","min:7","max:70"]}},
|
|
139
|
+
* phone:{"type": "r-mask-input",$if:[["$age",">",7],["$age","<=",60]],"props":{"rules": ["required"],"mask": "0NNN NNN NNNN"}},
|
|
140
|
+
* mix:{"type": "r-text-input","$bind":[["label","name"]]},
|
|
141
|
+
* }
|
|
142
|
+
*/
|
|
143
|
+
options: {
|
|
144
|
+
required: false,
|
|
145
|
+
type: [Object, Array]
|
|
146
|
+
},
|
|
147
|
+
/**
|
|
148
|
+
* Form data model value
|
|
149
|
+
* @model
|
|
150
|
+
* @type {Object}
|
|
151
|
+
* @default () => ({})
|
|
152
|
+
*/
|
|
153
|
+
modelValue: {
|
|
154
|
+
default: () => ({}),
|
|
155
|
+
type: Object
|
|
156
|
+
},
|
|
157
|
+
/**
|
|
158
|
+
* Custom HTTP headers for the request
|
|
159
|
+
* @type {Object}
|
|
160
|
+
*/
|
|
161
|
+
headers: Object
|
|
162
|
+
})
|
|
104
163
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
164
|
+
const emit = defineEmits([
|
|
165
|
+
/**
|
|
166
|
+
* Emitted when form data changes
|
|
167
|
+
* @event update:modelValue
|
|
168
|
+
* @param {Object} data - Updated form data
|
|
169
|
+
*/
|
|
170
|
+
'update:modelValue',
|
|
111
171
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Emitted when form submission is successful
|
|
174
|
+
* @event ok
|
|
175
|
+
* @param {Boolean} success - Always true
|
|
176
|
+
*/
|
|
177
|
+
'ok'
|
|
178
|
+
])
|
|
179
|
+
|
|
180
|
+
// Dependency injection
|
|
181
|
+
const {$helper, $t, $r} = inject('renusify')
|
|
182
|
+
const $axios = inject('axios')
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Loading state for form submission
|
|
186
|
+
* @type {Ref<Boolean>}
|
|
187
|
+
*/
|
|
188
|
+
const loading = ref(false)
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Form validation state
|
|
192
|
+
* @type {Ref<Boolean>}
|
|
193
|
+
*/
|
|
194
|
+
const valid = ref(false)
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Server-side validation errors
|
|
198
|
+
* @type {Ref<Array>}
|
|
199
|
+
*/
|
|
200
|
+
const errors = ref([])
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Whether to show error alerts
|
|
204
|
+
* @type {Ref<Boolean>}
|
|
205
|
+
*/
|
|
206
|
+
const alertShow = ref(false)
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Reference to the form component instance
|
|
210
|
+
* @type {Ref<ComponentInstance|null>}
|
|
211
|
+
*/
|
|
212
|
+
const form = ref(null)
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Local copy of form data for editing
|
|
216
|
+
* @type {Ref<Object>}
|
|
217
|
+
*/
|
|
218
|
+
const editedItem = ref({...props.modelValue})
|
|
219
|
+
|
|
220
|
+
const iff = (data) => {
|
|
221
|
+
const get = (item, key) => {
|
|
222
|
+
if (key.toString().startsWith('$')) {
|
|
223
|
+
return $helper.ifHas(item, null, ...key.substring(1).split('.'))
|
|
224
|
+
}
|
|
225
|
+
return key
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if ('$if' in data) {
|
|
229
|
+
for (let i = 0; i < data['$if'].length; i++) {
|
|
230
|
+
const item = data['$if'][i]
|
|
231
|
+
let can = true
|
|
232
|
+
const one = get(editedItem.value, item[0])
|
|
233
|
+
const op = item[1]
|
|
234
|
+
const two = get(editedItem.value, item[2])
|
|
235
|
+
|
|
236
|
+
switch (op) {
|
|
237
|
+
case '===':
|
|
238
|
+
case '==':
|
|
239
|
+
can = one === two
|
|
240
|
+
break
|
|
241
|
+
case '>':
|
|
242
|
+
can = one > two
|
|
243
|
+
break
|
|
244
|
+
case '>=':
|
|
245
|
+
can = one >= two
|
|
246
|
+
break
|
|
247
|
+
case '<':
|
|
248
|
+
can = one < two
|
|
249
|
+
break
|
|
250
|
+
case '<=':
|
|
251
|
+
can = one <= two
|
|
252
|
+
break
|
|
253
|
+
case '!=':
|
|
254
|
+
can = one !== two
|
|
255
|
+
break
|
|
256
|
+
case 'in':
|
|
257
|
+
can = two && typeof two === 'object' ? two.includes(one) : false
|
|
258
|
+
break
|
|
259
|
+
default:
|
|
260
|
+
can = false
|
|
261
|
+
console.error(`operator '${op}' is not defined.(form creator)`)
|
|
145
262
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
let res = data['props'] ? data['props'] : {}
|
|
150
|
-
if (data['$bind']) {
|
|
151
|
-
data['$bind'].forEach((item) => {
|
|
152
|
-
res[item[0]] = this.editedItem[item[1]]
|
|
153
|
-
})
|
|
263
|
+
|
|
264
|
+
if (can === false) {
|
|
265
|
+
return false
|
|
154
266
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return true
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const getAttr = (data) => {
|
|
273
|
+
let res = data['props'] ? data['props'] : {}
|
|
274
|
+
if (data['$bind']) {
|
|
275
|
+
data['$bind'].forEach((item) => {
|
|
276
|
+
res[item[0]] = editedItem.value[item[1]]
|
|
277
|
+
})
|
|
278
|
+
}
|
|
279
|
+
return res
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Handles form submission success
|
|
284
|
+
* @method close
|
|
285
|
+
* @fires RFormCreator#ok
|
|
286
|
+
* @private
|
|
287
|
+
*/
|
|
288
|
+
const close = () => {
|
|
289
|
+
emit('ok', true)
|
|
290
|
+
alertShow.value = false
|
|
291
|
+
errors.value = []
|
|
292
|
+
loading.value = false
|
|
293
|
+
if (form.value) {
|
|
294
|
+
form.value.reset()
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Submits the form data to the server
|
|
300
|
+
* @method save
|
|
301
|
+
* @async
|
|
302
|
+
* @returns {Promise<void>}
|
|
303
|
+
* @private
|
|
304
|
+
*/
|
|
305
|
+
const save = () => {
|
|
306
|
+
// Validate form if not valid
|
|
307
|
+
if (!valid.value && form.value) {
|
|
308
|
+
form.value.validate()
|
|
309
|
+
const e = form.value.errorBag
|
|
310
|
+
for (let id in e) {
|
|
311
|
+
if (e[id]) {
|
|
312
|
+
// Scroll to first error field
|
|
313
|
+
document.getElementById(id)?.scrollIntoView({behavior: 'smooth'})
|
|
176
314
|
return
|
|
177
315
|
}
|
|
178
|
-
this.loading = true
|
|
179
|
-
this.$axios[this.method](this.url, this.editedItem, {headers: this.headers})
|
|
180
|
-
.then(() => {
|
|
181
|
-
this.close()
|
|
182
|
-
}, (error) => {
|
|
183
|
-
if (this.autoSend) {
|
|
184
|
-
this.close()
|
|
185
|
-
} else {
|
|
186
|
-
if (error.response.data.errors) {
|
|
187
|
-
this.errors = error.response.data.errors
|
|
188
|
-
this.alertShow = true
|
|
189
|
-
}
|
|
190
|
-
this.loading = false
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
})
|
|
194
316
|
}
|
|
317
|
+
return
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
loading.value = true
|
|
321
|
+
|
|
322
|
+
$axios[props.method](props.url, editedItem.value, {headers: props.headers})
|
|
323
|
+
.then(() => {
|
|
324
|
+
close()
|
|
325
|
+
})
|
|
326
|
+
.catch((error) => {
|
|
327
|
+
if (props.autoSend) {
|
|
328
|
+
close()
|
|
329
|
+
} else {
|
|
330
|
+
if (error.response?.data?.errors) {
|
|
331
|
+
errors.value = error.response.data.errors
|
|
332
|
+
alertShow.value = true
|
|
333
|
+
}
|
|
334
|
+
loading.value = false
|
|
335
|
+
}
|
|
336
|
+
})
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Watch for changes in modelValue prop
|
|
340
|
+
watch(() => props.modelValue, (newValue) => {
|
|
341
|
+
editedItem.value = {...newValue}
|
|
342
|
+
}, {deep: true})
|
|
343
|
+
|
|
344
|
+
// Watch for changes in editedItem and emit updates
|
|
345
|
+
watch(editedItem, (newValue) => {
|
|
346
|
+
emit('update:modelValue', {...newValue})
|
|
347
|
+
}, {deep: true})
|
|
348
|
+
|
|
349
|
+
// Auto-submit on mount if autoSend is enabled
|
|
350
|
+
onMounted(() => {
|
|
351
|
+
if (props.autoSend) {
|
|
352
|
+
save()
|
|
195
353
|
}
|
|
354
|
+
})
|
|
355
|
+
</script>
|
|
356
|
+
|
|
357
|
+
<style lang="scss">
|
|
358
|
+
@use "../../style" as *;
|
|
359
|
+
|
|
360
|
+
.#{$prefix}form-creator {
|
|
361
|
+
overflow: auto;
|
|
196
362
|
}
|
|
197
|
-
</
|
|
363
|
+
</style>
|
|
@@ -15,32 +15,48 @@
|
|
|
15
15
|
<div :class="`highlight-code highlight-lang-${lang}`" v-html='txt'></div>
|
|
16
16
|
</div>
|
|
17
17
|
</template>
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
<script setup>
|
|
20
|
+
import {ref, onMounted, inject} from 'vue'
|
|
21
|
+
import {useHighlight} from './useHighlight.js'
|
|
19
22
|
import './style.scss'
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
|
|
24
|
+
const props = defineProps({
|
|
25
|
+
/**
|
|
26
|
+
* Name or identifier for the code block
|
|
27
|
+
* Optional name for the code snippet, can be used for labeling or referencing
|
|
28
|
+
*/
|
|
29
|
+
name: String,
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* inline code content
|
|
33
|
+
*/
|
|
34
|
+
src: String,
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Whether to hide line numbers
|
|
38
|
+
*/
|
|
39
|
+
hideLineNumbers: Boolean,
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Programming language for syntax highlighting
|
|
43
|
+
*/
|
|
44
|
+
lang: {
|
|
45
|
+
type: String,
|
|
46
|
+
validator: function (value) {
|
|
47
|
+
return ['asm', 'bash', 'bf', 'c', 'css', 'csv', 'diff', 'docker', 'git', 'go', 'html', 'http', 'ini', 'java', 'js', 'jsdoc', 'json', 'log', 'lua', 'make', 'pl', 'plain', 'py', 'regex', 'rs', 'sql', 'todo', 'toml', 'ts', 'uri', 'xml', 'yaml'].includes(value)
|
|
39
48
|
}
|
|
40
|
-
},
|
|
41
|
-
async created() {
|
|
42
|
-
this.txt = await this.highlight(this.src, this.lang, this.hideLineNumbers);
|
|
43
49
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const $r = inject('$r')
|
|
53
|
+
const $helper = inject('$helper')
|
|
54
|
+
|
|
55
|
+
const {highlight} = useHighlight()
|
|
46
56
|
|
|
57
|
+
const txt = ref('')
|
|
58
|
+
|
|
59
|
+
onMounted(async () => {
|
|
60
|
+
txt.value = await highlight(props.src, props.lang, props.hideLineNumbers)
|
|
61
|
+
})
|
|
62
|
+
</script>
|