@ramathibodi/nuxt-commons 0.1.14 → 0.1.15

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 +266 -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 +154 -154
@@ -1,84 +1,84 @@
1
- <script setup lang="ts">
2
- import {VSelect} from 'vuetify/components/VSelect'
3
- import {concat} from 'lodash-es'
4
- import {computed, ref, watch} from 'vue'
5
- import {useGraphQl} from '../../composables/graphql'
6
- import {useAlert} from '../../composables/alert'
7
-
8
- interface Props extends /* @vue-ignore */ InstanceType<typeof VSelect['$props']> {
9
- modelValue?: string
10
- groupKey: string
11
- fields?: string[]
12
- }
13
- const props = withDefaults(defineProps<Props>(), {
14
- lang: 'TH',
15
- })
16
-
17
- const emit = defineEmits(['update:modelValue'])
18
- const items = ref<Array<any>>([])
19
- const alert = useAlert()
20
- const selectedItem = ref<any>()
21
- function query() {
22
- const variables: Record<string, any> = { groupKey: { value: props.groupKey, required: true } }
23
- let fields: any[] = ['itemCode', 'itemValue', 'itemValueAlternative']
24
- if (props.fields) fields = concat(fields, props.fields)
25
-
26
- useGraphQl().queryPromise('masterItemByGroupKey', fields, variables).then((result: any) => {
27
- items.value = result
28
- }).catch((error) => {
29
- alert?.addAlert({
30
- message: `${error.message}`,
31
- alertType: 'error',
32
- })
33
- })
34
- }
35
-
36
- watch(() => props.groupKey, () => {
37
- query()
38
- }, { immediate: true })
39
-
40
- watch(selectedItem, (newValue) => {
41
- emit('update:modelValue', newValue)
42
- })
43
-
44
- const itemTitleField = computed(() => {
45
- if (props.lang == 'TH') return 'itemValue'
46
- else return 'itemValueAlternative'
47
- })
48
-
49
- query()
50
- </script>
51
-
52
- <template>
53
- <v-select
54
- v-model="selectedItem"
55
- :item-title="itemTitleField"
56
- :items="items"
57
- item-value="itemCode"
58
- >
59
- <template
60
- v-for="(_, name, index) in ($slots as {})"
61
- :key="index"
62
- #[name]="slotData"
63
- >
64
- <slot
65
- :name="name"
66
- v-bind="((slotData || {}) as object)"
67
- :operation="operation"
68
- />
69
- </template>
70
- <template
71
- v-if="!$slots.item"
72
- #item="{ props, item }"
73
- >
74
- <v-list-item
75
- v-bind="props"
76
- :title="item.raw.itemValue"
77
- />
78
- </template>
79
- </v-select>
80
- </template>
81
-
1
+ <script setup lang="ts">
2
+ import {VSelect} from 'vuetify/components/VSelect'
3
+ import {concat} from 'lodash-es'
4
+ import {computed, ref, watch} from 'vue'
5
+ import {useGraphQl} from '../../composables/graphql'
6
+ import {useAlert} from '../../composables/alert'
7
+
8
+ interface Props extends /* @vue-ignore */ InstanceType<typeof VSelect['$props']> {
9
+ modelValue?: string
10
+ groupKey: string
11
+ fields?: string[]
12
+ }
13
+ const props = withDefaults(defineProps<Props>(), {
14
+ lang: 'TH',
15
+ })
16
+
17
+ const emit = defineEmits(['update:modelValue'])
18
+ const items = ref<Array<any>>([])
19
+ const alert = useAlert()
20
+ const selectedItem = ref<any>()
21
+ function query() {
22
+ const variables: Record<string, any> = { groupKey: { value: props.groupKey, required: true } }
23
+ let fields: any[] = ['itemCode', 'itemValue', 'itemValueAlternative']
24
+ if (props.fields) fields = concat(fields, props.fields)
25
+
26
+ useGraphQl().queryPromise('masterItemByGroupKey', fields, variables).then((result: any) => {
27
+ items.value = result
28
+ }).catch((error) => {
29
+ alert?.addAlert({
30
+ message: `${error.message}`,
31
+ alertType: 'error',
32
+ })
33
+ })
34
+ }
35
+
36
+ watch(() => props.groupKey, () => {
37
+ query()
38
+ }, { immediate: true })
39
+
40
+ watch(selectedItem, (newValue) => {
41
+ emit('update:modelValue', newValue)
42
+ })
43
+
44
+ const itemTitleField = computed(() => {
45
+ if (props.lang == 'TH') return 'itemValue'
46
+ else return 'itemValueAlternative'
47
+ })
48
+
49
+ query()
50
+ </script>
51
+
52
+ <template>
53
+ <v-select
54
+ v-model="selectedItem"
55
+ :item-title="itemTitleField"
56
+ :items="items"
57
+ item-value="itemCode"
58
+ >
59
+ <template
60
+ v-for="(_, name, index) in ($slots as {})"
61
+ :key="index"
62
+ #[name]="slotData"
63
+ >
64
+ <slot
65
+ :name="name"
66
+ v-bind="((slotData || {}) as object)"
67
+ :operation="operation"
68
+ />
69
+ </template>
70
+ <template
71
+ v-if="!$slots.item"
72
+ #item="{ props, item }"
73
+ >
74
+ <v-list-item
75
+ v-bind="props"
76
+ :title="item.raw.itemValue"
77
+ />
78
+ </template>
79
+ </v-select>
80
+ </template>
81
+
82
82
  <style scoped>
83
83
 
84
- </style>
84
+ </style>
@@ -1,122 +1,122 @@
1
- <script lang="ts" setup>
2
- import { computed, ref, watchEffect } from 'vue'
3
- import { cloneDeep, isEqual } from 'lodash-es'
4
- import { type GraphqlModelItemProps, useGraphqlModelItem } from '../../composables/graphqlModelItem'
5
-
6
- defineOptions({
7
- inheritAttrs: false,
8
- })
9
-
10
- interface Props {
11
- title?: string
12
- initialData?: object
13
- saveCaption?: string
14
- cancelCaption?: string
15
- }
16
-
17
- const props = withDefaults(defineProps<Props & GraphqlModelItemProps>(), {
18
- saveCaption: 'บันทึก',
19
- cancelCaption: 'ยกเลิก',
20
- fields: () => ['*'],
21
- })
22
-
23
- const { item,
24
- canCreate, canUpdate,
25
- createItem, updateItem,
26
- reload, isLoading } = useGraphqlModelItem(props)
27
-
28
- const formPadRef = ref()
29
- const formData = ref<object>({})
30
-
31
- const canSave = computed(() => { return (canCreate.value && isCreating.value) || canUpdate.value })
32
-
33
- const isDataChange = computed(() => {
34
- return !((isCreating.value) ? isEqual(formData.value, createOriginalValue.value) : isEqual(formData.value, item.value))
35
- })
36
-
37
- const isCreating = computed(() => {
38
- return !item.value
39
- })
40
-
41
- const createOriginalValue = computed(() => {
42
- return Object.assign({}, props.initialData)
43
- })
44
-
45
- const loadFormData = () => {
46
- if (item.value) {
47
- formData.value = cloneDeep(item.value)
48
- }
49
- else {
50
- formData.value = Object.assign({}, props.initialData)
51
- }
52
- }
53
-
54
- watchEffect(loadFormData)
55
-
56
- function save() {
57
- if (formPadRef.value.isValid) {
58
- if (isCreating.value) createItem(formData.value)
59
- else updateItem(formData.value)
60
- }
61
- }
62
-
63
- function cancel() {
64
- formPadRef.value.reset()
65
- loadFormData()
66
- }
67
-
68
- defineExpose({ save, cancel, reload, item, isLoading })
69
- </script>
70
-
71
- <template>
72
- <VCard>
73
- <VToolbar>
74
- <VToolbarTitle>
75
- <slot name="title">
76
- {{ title }}
77
- <v-icon
78
- size="small"
79
- @click="reload"
80
- >
81
- mdi mdi-refresh
82
- </v-icon>
83
- </slot>
84
- </VToolbarTitle>
85
- </VToolbar>
86
- <VCardText>
87
- <form-pad
88
- ref="formPadRef"
89
- v-model="formData"
90
- isolated
91
- >
92
- <template #default="slotData">
93
- <slot
94
- v-bind="slotData"
95
- :is-creating="isCreating"
96
- :is-data-change="isDataChange"
97
- />
98
- </template>
99
- </form-pad>
100
- </VCardText>
101
- <VCardActions>
102
- <VSpacer />
103
- <VBtn
104
- color="primary"
105
- variant="flat"
106
- :loading="isLoading"
107
- :disabled="!isDataChange || !canSave"
108
- @click="save"
109
- >
110
- {{ saveCaption }}
111
- </VBtn>
112
- <VBtn
113
- color="error"
114
- variant="flat"
115
- :disabled="isLoading"
116
- @click="cancel"
117
- >
118
- {{ cancelCaption }}
119
- </VBtn>
120
- </VCardActions>
121
- </VCard>
122
- </template>
1
+ <script lang="ts" setup>
2
+ import { computed, ref, watchEffect } from 'vue'
3
+ import { cloneDeep, isEqual } from 'lodash-es'
4
+ import { type GraphqlModelItemProps, useGraphqlModelItem } from '../../composables/graphqlModelItem'
5
+
6
+ defineOptions({
7
+ inheritAttrs: false,
8
+ })
9
+
10
+ interface Props {
11
+ title?: string
12
+ initialData?: object
13
+ saveCaption?: string
14
+ cancelCaption?: string
15
+ }
16
+
17
+ const props = withDefaults(defineProps<Props & GraphqlModelItemProps>(), {
18
+ saveCaption: 'บันทึก',
19
+ cancelCaption: 'ยกเลิก',
20
+ fields: () => ['*'],
21
+ })
22
+
23
+ const { item,
24
+ canCreate, canUpdate,
25
+ createItem, updateItem,
26
+ reload, isLoading } = useGraphqlModelItem(props)
27
+
28
+ const formPadRef = ref()
29
+ const formData = ref<object>({})
30
+
31
+ const canSave = computed(() => { return (canCreate.value && isCreating.value) || canUpdate.value })
32
+
33
+ const isDataChange = computed(() => {
34
+ return !((isCreating.value) ? isEqual(formData.value, createOriginalValue.value) : isEqual(formData.value, item.value))
35
+ })
36
+
37
+ const isCreating = computed(() => {
38
+ return !item.value
39
+ })
40
+
41
+ const createOriginalValue = computed(() => {
42
+ return Object.assign({}, props.initialData)
43
+ })
44
+
45
+ const loadFormData = () => {
46
+ if (item.value) {
47
+ formData.value = cloneDeep(item.value)
48
+ }
49
+ else {
50
+ formData.value = Object.assign({}, props.initialData)
51
+ }
52
+ }
53
+
54
+ watchEffect(loadFormData)
55
+
56
+ function save() {
57
+ if (formPadRef.value.isValid) {
58
+ if (isCreating.value) createItem(formData.value)
59
+ else updateItem(formData.value)
60
+ }
61
+ }
62
+
63
+ function cancel() {
64
+ formPadRef.value.reset()
65
+ loadFormData()
66
+ }
67
+
68
+ defineExpose({ save, cancel, reload, item, isLoading })
69
+ </script>
70
+
71
+ <template>
72
+ <VCard>
73
+ <VToolbar>
74
+ <VToolbarTitle>
75
+ <slot name="title">
76
+ {{ title }}
77
+ <v-icon
78
+ size="small"
79
+ @click="reload"
80
+ >
81
+ mdi mdi-refresh
82
+ </v-icon>
83
+ </slot>
84
+ </VToolbarTitle>
85
+ </VToolbar>
86
+ <VCardText>
87
+ <form-pad
88
+ ref="formPadRef"
89
+ v-model="formData"
90
+ isolated
91
+ >
92
+ <template #default="slotData">
93
+ <slot
94
+ v-bind="slotData"
95
+ :is-creating="isCreating"
96
+ :is-data-change="isDataChange"
97
+ />
98
+ </template>
99
+ </form-pad>
100
+ </VCardText>
101
+ <VCardActions>
102
+ <VSpacer />
103
+ <VBtn
104
+ color="primary"
105
+ variant="flat"
106
+ :loading="isLoading"
107
+ :disabled="!isDataChange || !canSave"
108
+ @click="save"
109
+ >
110
+ {{ saveCaption }}
111
+ </VBtn>
112
+ <VBtn
113
+ color="error"
114
+ variant="flat"
115
+ :disabled="isLoading"
116
+ @click="cancel"
117
+ >
118
+ {{ cancelCaption }}
119
+ </VBtn>
120
+ </VCardActions>
121
+ </VCard>
122
+ </template>