@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,217 +1,217 @@
1
- <script lang="ts" setup>
2
- /* eslint-disable @typescript-eslint/no-explicit-any,import/no-self-import */
3
- import {
4
- compile,
5
- computed,
6
- defineComponent,
7
- defineOptions,
8
- inject,
9
- onMounted,
10
- ref,
11
- shallowRef,
12
- watch,
13
- withDefaults
14
- } from 'vue'
15
- import {isObject} from 'lodash-es'
16
- import {watchDebounced} from '@vueuse/core'
17
- import {useRules} from '../../composables/utils/validation'
18
- import {useDocumentTemplate} from '../../composables/document/template'
19
- import FormPad from './Pad.vue'
20
-
21
- defineOptions({
22
- inheritAttrs: false,
23
- })
24
-
25
- interface Props {
26
- modelValue?: object
27
- template?: any
28
- templateScript?: string
29
- disabled?: boolean
30
- readonly?: boolean
31
- isolated?: boolean
32
- decoration?: object
33
- }
34
-
35
- const props = withDefaults(defineProps<Props>(), {
36
- disabled: false,
37
- readonly: false,
38
- isolated: false,
39
- decoration: () => { return {} },
40
- })
41
-
42
- const emit = defineEmits(['update:modelValue'])
43
-
44
- const disabled = ref(props.disabled)
45
- const readonly = ref(props.readonly)
46
- const decoration = ref(props.decoration)
47
-
48
- watch(() => props.disabled, (newValue) => {
49
- disabled.value = newValue
50
- })
51
-
52
- watch(() => props.readonly, (newValue) => {
53
- readonly.value = newValue
54
- })
55
-
56
- watch(() => props.decoration, (newValue) => {
57
- decoration.value = newValue
58
- }, { deep: true })
59
-
60
- const { rules } = useRules()
61
-
62
- const trimmedTemplate = ref<string>('')
63
-
64
- const vueFunctions = { ref, shallowRef, computed, watch, onMounted }
65
-
66
- const templateScriptFunction = computed(() => {
67
- let templateScript = props.templateScript?.trim() || 'return {}'
68
- const pattern = /^\s*[{[].*[}\]]\s*$/
69
- if (pattern.test(templateScript)) templateScript = 'return {}'
70
- return Function('props', 'ctx', ...Object.keys(vueFunctions), templateScript)
71
- })
72
-
73
- const formPad = ref()
74
- const formInjectKey = Symbol.for('vuetify:form')
75
- const formInjected = ref()
76
-
77
- const formData = ref<any>({})
78
-
79
- watch(formData, (newValue) => {
80
- emit('update:modelValue', newValue)
81
- }, { deep: true })
82
-
83
- watch(() => props.modelValue, (newValue) => {
84
- formData.value = isObject(newValue) ? newValue : {}
85
- }, { deep: true, immediate: true })
86
-
87
- const formComponent = shallowRef()
88
-
89
- function buildFormComponent() {
90
- if (!trimmedTemplate.value) return
91
- const originalConsoleError = console.warn
92
- console.warn = (error) => { throw new Error(error) } // eslint-disable-line
93
- try {
94
- const componentTemplate = '<form-pad ref="formPadTemplate" v-model="formComponentData" :disabled="disabled" :readonly="readonly" :decoration="decoration" :isolated="isolated"><template v-slot="{ data,isDisabled,isReadonly,rules,formProvided,decoration }">' + trimmedTemplate.value + '</template></form-pad>'
95
- compile(componentTemplate)
96
- formComponent.value = defineComponent({
97
- components: { FormPad },
98
- props: {
99
- modelValue: { type: Object, default: undefined },
100
- disabled: { type: Boolean, default: false },
101
- readonly: { type: Boolean, default: false },
102
- decoration: { type: Object, default: () => { return {} } },
103
- isolated: { type: Boolean, default: false },
104
- },
105
- emits: ['update:modelValue'],
106
- setup(props, ctx) {
107
- const formComponentData = ref<any>({})
108
- const formPadTemplate = ref<any>({})
109
- watch(formComponentData, (newValue) => {
110
- ctx.emit('update:modelValue', newValue)
111
- }, { deep: true })
112
- watch(() => props.modelValue, (newValue) => {
113
- formComponentData.value = isObject(newValue) ? newValue : {}
114
- }, { deep: true, immediate: true })
115
- const isValid = computed(() => formPadTemplate.value.isValid)
116
- return {
117
- formComponentData,
118
- formPadTemplate,
119
- reset: () => formPadTemplate.value.reset(),
120
- validate: () => formPadTemplate.value.validate(),
121
- resetValidate: () => formPadTemplate.value.resetValidate(),
122
- isValid,
123
- ...templateScriptFunction.value(props, ctx, ...Object.values(vueFunctions)),
124
- }
125
- },
126
- template: componentTemplate,
127
- })
128
- }
129
- catch (e) {
130
- formComponent.value = null
131
- console.error(e)
132
- }
133
- console.warn = originalConsoleError
134
- }
135
-
136
- function reset() {
137
- if (!formInjected.value) formPad.value.reset()
138
- else formInjected.value.items.forEach((item: any) => item.reset())
139
- }
140
-
141
- function validate() {
142
- if (!formInjected.value) formPad.value.validate()
143
- else formInjected.value.items.forEach((item: any) => item.validate())
144
- }
145
-
146
- function resetValidate() {
147
- if (!formInjected.value) formPad.value.resetValidate()
148
- else formInjected.value.items.forEach((item: any) => item.resetValidate())
149
- }
150
-
151
- const isValid = computed(() => {
152
- validate()
153
- return formInjected.value ? formInjected.value.isValid || false : formPad.value.isValid || false
154
- })
155
-
156
- onMounted(() => {
157
- if (!props.isolated) formInjected.value = inject(formInjectKey, false)
158
- buildFormComponent()
159
- })
160
-
161
- watchDebounced(() => props.template, (newValue) => {
162
- trimmedTemplate.value = useDocumentTemplate(newValue).trim() || ''
163
- buildFormComponent()
164
- }, { debounce: 500, maxWait: 5000, deep: true, immediate: true })
165
- watchDebounced(() => props.templateScript, buildFormComponent, { debounce: 500, maxWait: 5000 })
166
-
167
- defineExpose({
168
- isValid,
169
- disabled,
170
- readonly,
171
- reset,
172
- validate,
173
- resetValidate,
174
- })
175
- </script>
176
-
177
- <template>
178
- <v-form
179
- v-if="!formInjected && !trimmedTemplate"
180
- ref="formPad"
181
- :disabled="disabled"
182
- :readonly="readonly"
183
- :class="$attrs.class"
184
- >
185
- <template #default="formProvided">
186
- <slot
187
- :data="formData"
188
- :form-provided="formProvided"
189
- :is-disabled="disabled"
190
- :is-readonly="readonly"
191
- :rules="rules"
192
- :decoration="decoration"
193
- />
194
- </template>
195
- </v-form>
196
- <template v-if="formInjected && !trimmedTemplate">
197
- <slot
198
- :data="formData"
199
- :form-provided="formInjected"
200
- :is-disabled="disabled"
201
- :is-readonly="readonly"
202
- :rules="rules"
203
- :decoration="decoration"
204
- />
205
- </template>
206
- <component
207
- :is="formComponent"
208
- v-if="trimmedTemplate"
209
- ref="formPad"
210
- v-model="formData"
211
- :disabled="disabled"
212
- :readonly="readonly"
213
- :decoration="decoration"
214
- :isolated="isolated"
215
- :class="$attrs.class"
216
- />
217
- </template>
1
+ <script lang="ts" setup>
2
+ /* eslint-disable @typescript-eslint/no-explicit-any,import/no-self-import */
3
+ import {
4
+ compile,
5
+ computed,
6
+ defineComponent,
7
+ defineOptions,
8
+ inject,
9
+ onMounted,
10
+ ref,
11
+ shallowRef,
12
+ watch,
13
+ withDefaults
14
+ } from 'vue'
15
+ import {isObject} from 'lodash-es'
16
+ import {watchDebounced} from '@vueuse/core'
17
+ import {useRules} from '../../composables/utils/validation'
18
+ import {useDocumentTemplate} from '../../composables/document/template'
19
+ import FormPad from './Pad.vue'
20
+
21
+ defineOptions({
22
+ inheritAttrs: false,
23
+ })
24
+
25
+ interface Props {
26
+ modelValue?: object
27
+ template?: any
28
+ templateScript?: string
29
+ disabled?: boolean
30
+ readonly?: boolean
31
+ isolated?: boolean
32
+ decoration?: object
33
+ }
34
+
35
+ const props = withDefaults(defineProps<Props>(), {
36
+ disabled: false,
37
+ readonly: false,
38
+ isolated: false,
39
+ decoration: () => { return {} },
40
+ })
41
+
42
+ const emit = defineEmits(['update:modelValue'])
43
+
44
+ const disabled = ref(props.disabled)
45
+ const readonly = ref(props.readonly)
46
+ const decoration = ref(props.decoration)
47
+
48
+ watch(() => props.disabled, (newValue) => {
49
+ disabled.value = newValue
50
+ })
51
+
52
+ watch(() => props.readonly, (newValue) => {
53
+ readonly.value = newValue
54
+ })
55
+
56
+ watch(() => props.decoration, (newValue) => {
57
+ decoration.value = newValue
58
+ }, { deep: true })
59
+
60
+ const { rules } = useRules()
61
+
62
+ const trimmedTemplate = ref<string>('')
63
+
64
+ const vueFunctions = { ref, shallowRef, computed, watch, onMounted }
65
+
66
+ const templateScriptFunction = computed(() => {
67
+ let templateScript = props.templateScript?.trim() || 'return {}'
68
+ const pattern = /^\s*[{[].*[}\]]\s*$/
69
+ if (pattern.test(templateScript)) templateScript = 'return {}'
70
+ return Function('props', 'ctx', ...Object.keys(vueFunctions), templateScript)
71
+ })
72
+
73
+ const formPad = ref()
74
+ const formInjectKey = Symbol.for('vuetify:form')
75
+ const formInjected = ref()
76
+
77
+ const formData = ref<any>({})
78
+
79
+ watch(formData, (newValue) => {
80
+ emit('update:modelValue', newValue)
81
+ }, { deep: true })
82
+
83
+ watch(() => props.modelValue, (newValue) => {
84
+ formData.value = isObject(newValue) ? newValue : {}
85
+ }, { deep: true, immediate: true })
86
+
87
+ const formComponent = shallowRef()
88
+
89
+ function buildFormComponent() {
90
+ if (!trimmedTemplate.value) return
91
+ const originalConsoleError = console.warn
92
+ console.warn = (error) => { throw new Error(error) } // eslint-disable-line
93
+ try {
94
+ const componentTemplate = '<form-pad ref="formPadTemplate" v-model="formComponentData" :disabled="disabled" :readonly="readonly" :decoration="decoration" :isolated="isolated"><template v-slot="{ data,isDisabled,isReadonly,rules,formProvided,decoration }">' + trimmedTemplate.value + '</template></form-pad>'
95
+ compile(componentTemplate)
96
+ formComponent.value = defineComponent({
97
+ components: { FormPad },
98
+ props: {
99
+ modelValue: { type: Object, default: undefined },
100
+ disabled: { type: Boolean, default: false },
101
+ readonly: { type: Boolean, default: false },
102
+ decoration: { type: Object, default: () => { return {} } },
103
+ isolated: { type: Boolean, default: false },
104
+ },
105
+ emits: ['update:modelValue'],
106
+ setup(props, ctx) {
107
+ const formComponentData = ref<any>({})
108
+ const formPadTemplate = ref<any>({})
109
+ watch(formComponentData, (newValue) => {
110
+ ctx.emit('update:modelValue', newValue)
111
+ }, { deep: true })
112
+ watch(() => props.modelValue, (newValue) => {
113
+ formComponentData.value = isObject(newValue) ? newValue : {}
114
+ }, { deep: true, immediate: true })
115
+ const isValid = computed(() => formPadTemplate.value.isValid)
116
+ return {
117
+ formComponentData,
118
+ formPadTemplate,
119
+ reset: () => formPadTemplate.value.reset(),
120
+ validate: () => formPadTemplate.value.validate(),
121
+ resetValidate: () => formPadTemplate.value.resetValidate(),
122
+ isValid,
123
+ ...templateScriptFunction.value(props, ctx, ...Object.values(vueFunctions)),
124
+ }
125
+ },
126
+ template: componentTemplate,
127
+ })
128
+ }
129
+ catch (e) {
130
+ formComponent.value = null
131
+ console.error(e)
132
+ }
133
+ console.warn = originalConsoleError
134
+ }
135
+
136
+ function reset() {
137
+ if (!formInjected.value) formPad.value.reset()
138
+ else formInjected.value.items.forEach((item: any) => item.reset())
139
+ }
140
+
141
+ function validate() {
142
+ if (!formInjected.value) formPad.value.validate()
143
+ else formInjected.value.items.forEach((item: any) => item.validate())
144
+ }
145
+
146
+ function resetValidate() {
147
+ if (!formInjected.value) formPad.value.resetValidate()
148
+ else formInjected.value.items.forEach((item: any) => item.resetValidate())
149
+ }
150
+
151
+ const isValid = computed(() => {
152
+ validate()
153
+ return formInjected.value ? formInjected.value.isValid || false : formPad.value.isValid || false
154
+ })
155
+
156
+ onMounted(() => {
157
+ if (!props.isolated) formInjected.value = inject(formInjectKey, false)
158
+ buildFormComponent()
159
+ })
160
+
161
+ watchDebounced(() => props.template, (newValue) => {
162
+ trimmedTemplate.value = useDocumentTemplate(newValue).trim() || ''
163
+ buildFormComponent()
164
+ }, { debounce: 500, maxWait: 5000, deep: true, immediate: true })
165
+ watchDebounced(() => props.templateScript, buildFormComponent, { debounce: 500, maxWait: 5000 })
166
+
167
+ defineExpose({
168
+ isValid,
169
+ disabled,
170
+ readonly,
171
+ reset,
172
+ validate,
173
+ resetValidate,
174
+ })
175
+ </script>
176
+
177
+ <template>
178
+ <v-form
179
+ v-if="!formInjected && !trimmedTemplate"
180
+ ref="formPad"
181
+ :disabled="disabled"
182
+ :readonly="readonly"
183
+ :class="$attrs.class"
184
+ >
185
+ <template #default="formProvided">
186
+ <slot
187
+ :data="formData"
188
+ :form-provided="formProvided"
189
+ :is-disabled="disabled"
190
+ :is-readonly="readonly"
191
+ :rules="rules"
192
+ :decoration="decoration"
193
+ />
194
+ </template>
195
+ </v-form>
196
+ <template v-if="formInjected && !trimmedTemplate">
197
+ <slot
198
+ :data="formData"
199
+ :form-provided="formInjected"
200
+ :is-disabled="disabled"
201
+ :is-readonly="readonly"
202
+ :rules="rules"
203
+ :decoration="decoration"
204
+ />
205
+ </template>
206
+ <component
207
+ :is="formComponent"
208
+ v-if="trimmedTemplate"
209
+ ref="formPad"
210
+ v-model="formData"
211
+ :disabled="disabled"
212
+ :readonly="readonly"
213
+ :decoration="decoration"
214
+ :isolated="isolated"
215
+ :class="$attrs.class"
216
+ />
217
+ </template>