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