@ramathibodi/nuxt-commons 0.1.14 → 0.1.16
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 +96 -96
- package/dist/module.json +1 -1
- package/dist/runtime/components/Alert.vue +53 -53
- package/dist/runtime/components/BarcodeReader.vue +98 -98
- package/dist/runtime/components/ExportCSV.vue +55 -55
- package/dist/runtime/components/FileBtn.vue +62 -62
- package/dist/runtime/components/ImportCSV.vue +64 -64
- package/dist/runtime/components/SplitterPanel.vue +59 -59
- package/dist/runtime/components/TabsGroup.vue +32 -32
- package/dist/runtime/components/TextBarcode.vue +52 -52
- package/dist/runtime/components/dialog/Confirm.vue +100 -100
- package/dist/runtime/components/dialog/Index.vue +72 -72
- package/dist/runtime/components/dialog/Loading.vue +39 -39
- package/dist/runtime/components/document/TemplateBuilder.vue +203 -216
- package/dist/runtime/components/form/Birthdate.vue +216 -216
- package/dist/runtime/components/form/CodeEditor.vue +37 -37
- package/dist/runtime/components/form/Date.vue +163 -163
- package/dist/runtime/components/form/DateTime.vue +107 -107
- package/dist/runtime/components/form/Dialog.vue +138 -138
- package/dist/runtime/components/form/File.vue +187 -187
- package/dist/runtime/components/form/Hidden.vue +32 -32
- package/dist/runtime/components/form/Login.vue +131 -131
- package/dist/runtime/components/form/Pad.vue +217 -217
- package/dist/runtime/components/form/SignPad.vue +186 -186
- package/dist/runtime/components/form/Table.vue +294 -266
- package/dist/runtime/components/form/Time.vue +158 -158
- package/dist/runtime/components/form/images/Capture.vue +230 -230
- package/dist/runtime/components/form/images/Edit.vue +114 -114
- package/dist/runtime/components/label/Date.vue +29 -29
- package/dist/runtime/components/label/Field.vue +42 -42
- package/dist/runtime/components/label/FormatMoney.vue +29 -29
- package/dist/runtime/components/label/Mask.vue +38 -38
- package/dist/runtime/components/master/Autocomplete.vue +159 -159
- package/dist/runtime/components/master/Combobox.vue +84 -84
- package/dist/runtime/components/master/RadioGroup.vue +78 -78
- package/dist/runtime/components/master/Select.vue +82 -82
- package/dist/runtime/components/model/Pad.vue +122 -122
- package/dist/runtime/components/model/Table.vue +242 -240
- package/dist/runtime/components/model/iterator.vue +312 -312
- package/dist/runtime/components/pdf/Print.vue +63 -63
- package/dist/runtime/components/pdf/View.vue +104 -104
- package/dist/runtime/composables/graphqlModel.mjs +1 -1
- package/dist/runtime/labs/Calendar.vue +99 -99
- package/dist/runtime/labs/form/EditMobile.vue +152 -152
- package/dist/runtime/labs/form/TextFieldMask.vue +43 -43
- package/dist/runtime/types/alert.d.ts +11 -11
- package/dist/runtime/types/formDialog.d.ts +4 -4
- package/dist/runtime/types/graphqlOperation.d.ts +23 -23
- package/dist/runtime/types/menu.d.ts +25 -25
- package/dist/runtime/types/modules.d.ts +7 -7
- package/package.json +120 -119
- package/scripts/postInstall.cjs +70 -70
- package/templates/.codegen/codegen.ts +32 -32
- package/templates/.codegen/plugin-schema-object.js +161 -154
|
@@ -1,216 +1,203 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
import * as prettier from 'prettier'
|
|
4
|
-
import prettierPluginHtml from 'prettier/plugins/html'
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
title: 'Input
|
|
31
|
-
key: '
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
title: '
|
|
35
|
-
key: '
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
title: '
|
|
39
|
-
key: '
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
title: '
|
|
43
|
-
key: '
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (!isAdvanceMode.value)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
/>
|
|
163
|
-
</v-col>
|
|
164
|
-
<v-col v-if="data.inputType!='
|
|
165
|
-
<v-text-field
|
|
166
|
-
v-model="data.
|
|
167
|
-
label="
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
<template v-if="props.item.inputOptions">
|
|
205
|
-
<b>Input Options :</b> {{ props.item.inputOptions }}<br>
|
|
206
|
-
</template>
|
|
207
|
-
<template v-if="props.item.inputAttributes">
|
|
208
|
-
<b>Input Attributes :</b> {{ props.item.inputAttributes }}<br>
|
|
209
|
-
</template>
|
|
210
|
-
</template>
|
|
211
|
-
</FormTable>
|
|
212
|
-
<FormCodeEditor
|
|
213
|
-
v-else
|
|
214
|
-
v-model="templateAdvanceCode"
|
|
215
|
-
/>
|
|
216
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import {computed, ref, watch} from 'vue'
|
|
3
|
+
import * as prettier from 'prettier'
|
|
4
|
+
import prettierPluginHtml from 'prettier/plugins/html'
|
|
5
|
+
import {useDocumentTemplate, validationRulesRegex} from '../../composables/document/template'
|
|
6
|
+
|
|
7
|
+
const emit = defineEmits(['update:modelValue'])
|
|
8
|
+
const modelValue = defineModel<string>()
|
|
9
|
+
|
|
10
|
+
const isAdvanceMode = computed(() => {
|
|
11
|
+
return modelValue.value && !isValidJsonArrayOfObjects(modelValue.value)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const templateItems = ref<Record<string, any>>([])
|
|
15
|
+
|
|
16
|
+
const headers = ref([
|
|
17
|
+
{ title: '',
|
|
18
|
+
key: 'operation',
|
|
19
|
+
width: '120px',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: 'Input Type',
|
|
23
|
+
key: 'inputType',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
title: 'Width',
|
|
27
|
+
key: 'width',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
title: 'Input Label',
|
|
31
|
+
key: 'inputLabel',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
title: 'Variable Name',
|
|
35
|
+
key: 'variableName',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
title: 'Configuration',
|
|
39
|
+
key: 'configuration',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: 'Action',
|
|
43
|
+
key: 'action',
|
|
44
|
+
width: '120px',
|
|
45
|
+
},
|
|
46
|
+
])
|
|
47
|
+
|
|
48
|
+
function isValidJsonArrayOfObjects(str: string | undefined) {
|
|
49
|
+
try {
|
|
50
|
+
const parsed = JSON.parse(str as string)
|
|
51
|
+
return Array.isArray(parsed) && parsed.every(item => typeof item === 'object' && item !== null && !Array.isArray(item))
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
watch(templateItems, (newValue) => {
|
|
59
|
+
if (!isAdvanceMode.value) modelValue.value = JSON.stringify(newValue)
|
|
60
|
+
}, { deep: true })
|
|
61
|
+
|
|
62
|
+
watch(modelValue, (newValue) => {
|
|
63
|
+
if (isValidJsonArrayOfObjects(newValue)) templateItems.value = JSON.parse(newValue as string)
|
|
64
|
+
}, { deep: true, immediate: true })
|
|
65
|
+
|
|
66
|
+
async function convertToAdvanceMode() {
|
|
67
|
+
if (!isAdvanceMode.value) {
|
|
68
|
+
modelValue.value = await prettier.format(useDocumentTemplate(templateItems.value).replaceAll('>', '>\n'), { parser: 'html', plugins: [prettierPluginHtml] })
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const inputTypeChoice = ref(['VTextField', 'VTextarea', 'VSelect', 'VAutocomplete', 'FormDate', 'FormTime', 'FormDateTime', 'VCombobox', 'VRadio', 'VRadioInline', 'VCheckbox', 'VSwitch', 'MasterAutocomplete', 'Header', 'Separator', 'CustomCode'])
|
|
73
|
+
const requireOption = ref(['VSelect', 'VAutocomplete', 'VCombobox', 'VRadio', 'VRadioInline', 'MasterAutocomplete'])
|
|
74
|
+
const notRequireVariable = ref(['Header', 'Separator', 'CustomCode'])
|
|
75
|
+
const notRequireLabel = ref(['Separator', 'CustomCode'])
|
|
76
|
+
|
|
77
|
+
const choiceOption = ref(['VSelect', 'VRadio', 'VRadioInline'])
|
|
78
|
+
|
|
79
|
+
const ruleOptions = (inputType: string) => (value: any) => {
|
|
80
|
+
if (choiceOption.value.includes(inputType) && !(/^[^'",]+(,[^'",]+)*$/.test(value))) return 'Invalid options format'
|
|
81
|
+
|
|
82
|
+
return true
|
|
83
|
+
}
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<template>
|
|
87
|
+
<FormTable
|
|
88
|
+
v-if="!isAdvanceMode"
|
|
89
|
+
v-model="templateItems"
|
|
90
|
+
:headers="headers"
|
|
91
|
+
title="Document Template"
|
|
92
|
+
>
|
|
93
|
+
<template #toolbarItems>
|
|
94
|
+
<VBtn
|
|
95
|
+
color="primary"
|
|
96
|
+
variant="flat"
|
|
97
|
+
@click="convertToAdvanceMode()"
|
|
98
|
+
>
|
|
99
|
+
Convert To Advance
|
|
100
|
+
</VBtn>
|
|
101
|
+
</template>
|
|
102
|
+
<template #form="{ data, rules }">
|
|
103
|
+
<v-container fluid>
|
|
104
|
+
<v-row dense>
|
|
105
|
+
<v-col cols="3">
|
|
106
|
+
<v-combobox
|
|
107
|
+
v-model="data.inputType"
|
|
108
|
+
label="Input Type"
|
|
109
|
+
:items="inputTypeChoice"
|
|
110
|
+
:rules="[rules.require()]"
|
|
111
|
+
/>
|
|
112
|
+
</v-col>
|
|
113
|
+
<v-col
|
|
114
|
+
v-if="data.inputType!='Separator'"
|
|
115
|
+
cols="1"
|
|
116
|
+
>
|
|
117
|
+
<v-text-field
|
|
118
|
+
v-model="data.width"
|
|
119
|
+
label="Width"
|
|
120
|
+
:rules="[rules.require()]"
|
|
121
|
+
type="number"
|
|
122
|
+
/>
|
|
123
|
+
</v-col>
|
|
124
|
+
<v-col cols="4">
|
|
125
|
+
<v-text-field
|
|
126
|
+
v-if="!notRequireLabel.includes(data.inputType)"
|
|
127
|
+
v-model="data.inputLabel"
|
|
128
|
+
label="Input Label"
|
|
129
|
+
:rules="[rules.require()]"
|
|
130
|
+
/>
|
|
131
|
+
</v-col>
|
|
132
|
+
<v-col cols="4">
|
|
133
|
+
<v-text-field
|
|
134
|
+
v-if="!notRequireVariable.includes(data.inputType)"
|
|
135
|
+
v-model="data.variableName"
|
|
136
|
+
label="Variable Name"
|
|
137
|
+
:rules="[rules.require()]"
|
|
138
|
+
/>
|
|
139
|
+
</v-col>
|
|
140
|
+
<v-col
|
|
141
|
+
v-if="data.inputType!='CustomCode'"
|
|
142
|
+
cols="12"
|
|
143
|
+
>
|
|
144
|
+
<v-textarea
|
|
145
|
+
v-model="data.inputOptions"
|
|
146
|
+
label="Input Options"
|
|
147
|
+
auto-grow
|
|
148
|
+
:rules="[rules.requireIf(requireOption.includes(data.inputType)), ruleOptions(data.inputType)]"
|
|
149
|
+
/>
|
|
150
|
+
</v-col>
|
|
151
|
+
<v-col v-if="data.inputType!='CustomCode'">
|
|
152
|
+
<v-text-field
|
|
153
|
+
v-model="data.validationRules"
|
|
154
|
+
label="Validation Rules"
|
|
155
|
+
:rules="[rules.regex(validationRulesRegex)]"
|
|
156
|
+
/>
|
|
157
|
+
</v-col>
|
|
158
|
+
<v-col v-if="data.inputType!='CustomCode'">
|
|
159
|
+
<v-text-field
|
|
160
|
+
v-model="data.inputAttributes"
|
|
161
|
+
label="Input Attributes"
|
|
162
|
+
/>
|
|
163
|
+
</v-col>
|
|
164
|
+
<v-col v-if="data.inputType!='Separator'">
|
|
165
|
+
<v-text-field
|
|
166
|
+
v-model="data.columnAttributes"
|
|
167
|
+
label="Column Attributes"
|
|
168
|
+
/>
|
|
169
|
+
</v-col>
|
|
170
|
+
<v-col
|
|
171
|
+
v-if="data.inputType=='CustomCode'"
|
|
172
|
+
cols="12"
|
|
173
|
+
>
|
|
174
|
+
<FormCodeEditor
|
|
175
|
+
v-model="data.inputCustomCode"
|
|
176
|
+
label="Custom Code"
|
|
177
|
+
:rules="[rules.require()]"
|
|
178
|
+
/>
|
|
179
|
+
</v-col>
|
|
180
|
+
</v-row>
|
|
181
|
+
</v-container>
|
|
182
|
+
</template>
|
|
183
|
+
<template #item.configuration="props">
|
|
184
|
+
<template v-if="props.item.inputType=='CustomCode'">
|
|
185
|
+
<b>Custom Code :</b><br>
|
|
186
|
+
<span style="white-space: pre-line">{{ props.item.inputCustomCode }}</span>
|
|
187
|
+
</template>
|
|
188
|
+
<template v-if="props.item.validationRules">
|
|
189
|
+
<b>Validation Rules :</b> {{ props.item.validationRules }}<br>
|
|
190
|
+
</template>
|
|
191
|
+
<template v-if="props.item.inputOptions">
|
|
192
|
+
<b>Input Options :</b> {{ props.item.inputOptions }}<br>
|
|
193
|
+
</template>
|
|
194
|
+
<template v-if="props.item.inputAttributes">
|
|
195
|
+
<b>Input Attributes :</b> {{ props.item.inputAttributes }}<br>
|
|
196
|
+
</template>
|
|
197
|
+
</template>
|
|
198
|
+
</FormTable>
|
|
199
|
+
<FormCodeEditor
|
|
200
|
+
v-else
|
|
201
|
+
v-model="modelValue"
|
|
202
|
+
/>
|
|
203
|
+
</template>
|