@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,153 +1,153 @@
1
- <script lang="ts" setup>
2
- import { ref, withDefaults } from 'vue';
3
- import FormPad from "../../components/form/Pad.vue";
4
- import { useAlert } from "../../composables/alert";
5
- import { Mask } from "maska";
6
-
7
- interface Props {
8
- modelValue: number;
9
- decimal?: number;
10
- currency?: string;
11
- }
12
-
13
- const masksInput = new Mask({
14
- mask: "###-###-N",
15
- tokens: {
16
- N: { pattern: /[0-9]/, multiple: true }
17
- }
18
- });
19
-
20
- const alert = useAlert();
21
- const dialog = ref(false);
22
- const phone = ref();
23
- const typePhone = ref([]);
24
- const formPadTemplate = ref();
25
- const phoneNoField: any = ref(null);
26
- const objAddNew = ref({ phone: "", type: <any>[] });
27
-
28
- const listPhonesAll = ref([
29
- { "phone": "082745855410101", "type": ["default"] },
30
- { "phone": "0827196038", "type": null },
31
- { "phone": "0956458547", "type": ["post", "receipt"] }
32
- ]);
33
-
34
- const listPhonesType = ref([
35
- { "id": "default", "name": "ค่าเริ่มต้น" },
36
- { "id": "post", "name": "จัดส่งไปรษณีย์" },
37
- { "id": "receipt", "name": "จัดส่งใบเสร็จ (e-receipt)" }
38
- ]);
39
-
40
- const property = withDefaults(defineProps<Props>(), {
41
- modelValue: 0,
42
- decimal: 2,
43
- currency: "",
44
- });
45
-
46
- const focusOnTextField = () => {
47
- if (phoneNoField.value) {
48
- phoneNoField.value.focus();
49
- }
50
- };
51
-
52
- const mapTypeName = (id: string) => {
53
- const item = listPhonesType.value.find(entry => entry.id === id);
54
- return item ? item.name : undefined;
55
- };
56
-
57
- const mapPhoneCurrent = (phone: string) => {
58
- const item = listPhonesAll.value.find(entry => entry.phone === phone);
59
- return item ? item.phone : "";
60
- };
61
-
62
- const add = () => {
63
- if (formPadTemplate.value.isValid) {
64
- objAddNew.value.phone = phone.value.phone;
65
- objAddNew.value.type = typePhone.value.length === 0 ? ["default"] : typePhone.value;
66
-
67
- if (mapPhoneCurrent(objAddNew.value.phone) != "") {
68
- focusOnTextField();
69
- alert?.addAlert({ message: "เบอร์โทรศัพท์ซ้ำ กรุณาตรวจสอบ", alertType: 'error' });
70
- } else {
71
- dialog.value = false;
72
- listPhonesAll.value.push(objAddNew.value);
73
- }
74
- }
75
- };
76
-
77
- const registerPhone = () => {
78
- dialog.value = true;
79
- phone.value = "";
80
- typePhone.value = [];
81
- };
82
- </script>
83
-
84
- <template>
85
- <v-row class="ma-5">
86
- <v-col cols="4">
87
- <div>
88
- <v-card v-for="item in listPhonesAll" :key="item.phone"
89
- class="mt-1"
90
- variant="tonal"
91
- width="auto"
92
- :title="masksInput.masked(item.phone)"
93
- >
94
- <v-card-text class="pl-10">
95
- <v-chip color="primary" v-for="itemType in item.type">{{ mapTypeName(itemType) }}</v-chip>
96
- </v-card-text>
97
- <template v-slot:prepend>
98
- <v-icon icon="mdi mdi-phone"></v-icon>
99
- </template>
100
- <template v-slot:append>
101
- <v-icon icon="mdi mdi-pencil"></v-icon>
102
- </template>
103
- </v-card>
104
- </div>
105
- <div class="mt-1">
106
- <v-btn size="large" prepend-icon="mdi mdi-plus" color="primary" :block="true" @click="registerPhone">เพิ่มเบอร์โทรศัพท์ใหม่</v-btn>
107
- </div>
108
- </v-col>
109
- <v-col cols="4">
110
- </v-col>
111
- </v-row>
112
- <v-dialog v-model="dialog" width="550">
113
- <v-card title="เบอร์โทรศัพท์ใหม่">
114
- <template v-slot:prepend>
115
- <v-icon icon="mdi mdi-phone-plus"></v-icon>
116
- </template>
117
- <template v-slot:append>
118
- <v-icon icon="mdi mdi-close" @click="dialog = false"></v-icon>
119
- </template>
120
- <v-card-text>
121
- <form-pad ref="formPadTemplate" v-model="phone">
122
- <template v-slot:default="{ data, rules }">
123
- <v-text-field
124
- ref="phoneNoField"
125
- color="primary"
126
- label="เบอร์โทรศัพท์ (Phone Number)"
127
- variant="underlined"
128
- :rules="[rules.telephone('เบอร์โทรศัพท์ไม่ถูกต้อง'), rules.require()]"
129
- v-model="data.phone"
130
- :autofocus="true"
131
- ></v-text-field>
132
- </template>
133
- </form-pad>
134
- <v-chip-group
135
- v-model="typePhone"
136
- column
137
- multiple
138
- selected-class="text-primary"
139
- >
140
- <v-chip v-for="item in listPhonesType" :key="item.id" :value="item.id"
141
- filter
142
- variant="outlined"
143
- >
144
- {{ item.name }}
145
- </v-chip>
146
- </v-chip-group>
147
- </v-card-text>
148
- <v-card-actions>
149
- <v-btn color="primary" variant="flat" @click="add" :block="true">ยืนยัน</v-btn>
150
- </v-card-actions>
151
- </v-card>
152
- </v-dialog>
1
+ <script lang="ts" setup>
2
+ import { ref, withDefaults } from 'vue';
3
+ import FormPad from "../../components/form/Pad.vue";
4
+ import { useAlert } from "../../composables/alert";
5
+ import { Mask } from "maska";
6
+
7
+ interface Props {
8
+ modelValue: number;
9
+ decimal?: number;
10
+ currency?: string;
11
+ }
12
+
13
+ const masksInput = new Mask({
14
+ mask: "###-###-N",
15
+ tokens: {
16
+ N: { pattern: /[0-9]/, multiple: true }
17
+ }
18
+ });
19
+
20
+ const alert = useAlert();
21
+ const dialog = ref(false);
22
+ const phone = ref();
23
+ const typePhone = ref([]);
24
+ const formPadTemplate = ref();
25
+ const phoneNoField: any = ref(null);
26
+ const objAddNew = ref({ phone: "", type: <any>[] });
27
+
28
+ const listPhonesAll = ref([
29
+ { "phone": "082745855410101", "type": ["default"] },
30
+ { "phone": "0827196038", "type": null },
31
+ { "phone": "0956458547", "type": ["post", "receipt"] }
32
+ ]);
33
+
34
+ const listPhonesType = ref([
35
+ { "id": "default", "name": "ค่าเริ่มต้น" },
36
+ { "id": "post", "name": "จัดส่งไปรษณีย์" },
37
+ { "id": "receipt", "name": "จัดส่งใบเสร็จ (e-receipt)" }
38
+ ]);
39
+
40
+ const property = withDefaults(defineProps<Props>(), {
41
+ modelValue: 0,
42
+ decimal: 2,
43
+ currency: "",
44
+ });
45
+
46
+ const focusOnTextField = () => {
47
+ if (phoneNoField.value) {
48
+ phoneNoField.value.focus();
49
+ }
50
+ };
51
+
52
+ const mapTypeName = (id: string) => {
53
+ const item = listPhonesType.value.find(entry => entry.id === id);
54
+ return item ? item.name : undefined;
55
+ };
56
+
57
+ const mapPhoneCurrent = (phone: string) => {
58
+ const item = listPhonesAll.value.find(entry => entry.phone === phone);
59
+ return item ? item.phone : "";
60
+ };
61
+
62
+ const add = () => {
63
+ if (formPadTemplate.value.isValid) {
64
+ objAddNew.value.phone = phone.value.phone;
65
+ objAddNew.value.type = typePhone.value.length === 0 ? ["default"] : typePhone.value;
66
+
67
+ if (mapPhoneCurrent(objAddNew.value.phone) != "") {
68
+ focusOnTextField();
69
+ alert?.addAlert({ message: "เบอร์โทรศัพท์ซ้ำ กรุณาตรวจสอบ", alertType: 'error' });
70
+ } else {
71
+ dialog.value = false;
72
+ listPhonesAll.value.push(objAddNew.value);
73
+ }
74
+ }
75
+ };
76
+
77
+ const registerPhone = () => {
78
+ dialog.value = true;
79
+ phone.value = "";
80
+ typePhone.value = [];
81
+ };
82
+ </script>
83
+
84
+ <template>
85
+ <v-row class="ma-5">
86
+ <v-col cols="4">
87
+ <div>
88
+ <v-card v-for="item in listPhonesAll" :key="item.phone"
89
+ class="mt-1"
90
+ variant="tonal"
91
+ width="auto"
92
+ :title="masksInput.masked(item.phone)"
93
+ >
94
+ <v-card-text class="pl-10">
95
+ <v-chip color="primary" v-for="itemType in item.type">{{ mapTypeName(itemType) }}</v-chip>
96
+ </v-card-text>
97
+ <template v-slot:prepend>
98
+ <v-icon icon="mdi mdi-phone"></v-icon>
99
+ </template>
100
+ <template v-slot:append>
101
+ <v-icon icon="mdi mdi-pencil"></v-icon>
102
+ </template>
103
+ </v-card>
104
+ </div>
105
+ <div class="mt-1">
106
+ <v-btn size="large" prepend-icon="mdi mdi-plus" color="primary" :block="true" @click="registerPhone">เพิ่มเบอร์โทรศัพท์ใหม่</v-btn>
107
+ </div>
108
+ </v-col>
109
+ <v-col cols="4">
110
+ </v-col>
111
+ </v-row>
112
+ <v-dialog v-model="dialog" width="550">
113
+ <v-card title="เบอร์โทรศัพท์ใหม่">
114
+ <template v-slot:prepend>
115
+ <v-icon icon="mdi mdi-phone-plus"></v-icon>
116
+ </template>
117
+ <template v-slot:append>
118
+ <v-icon icon="mdi mdi-close" @click="dialog = false"></v-icon>
119
+ </template>
120
+ <v-card-text>
121
+ <form-pad ref="formPadTemplate" v-model="phone">
122
+ <template v-slot:default="{ data, rules }">
123
+ <v-text-field
124
+ ref="phoneNoField"
125
+ color="primary"
126
+ label="เบอร์โทรศัพท์ (Phone Number)"
127
+ variant="underlined"
128
+ :rules="[rules.telephone('เบอร์โทรศัพท์ไม่ถูกต้อง'), rules.require()]"
129
+ v-model="data.phone"
130
+ :autofocus="true"
131
+ ></v-text-field>
132
+ </template>
133
+ </form-pad>
134
+ <v-chip-group
135
+ v-model="typePhone"
136
+ column
137
+ multiple
138
+ selected-class="text-primary"
139
+ >
140
+ <v-chip v-for="item in listPhonesType" :key="item.id" :value="item.id"
141
+ filter
142
+ variant="outlined"
143
+ >
144
+ {{ item.name }}
145
+ </v-chip>
146
+ </v-chip-group>
147
+ </v-card-text>
148
+ <v-card-actions>
149
+ <v-btn color="primary" variant="flat" @click="add" :block="true">ยืนยัน</v-btn>
150
+ </v-card-actions>
151
+ </v-card>
152
+ </v-dialog>
153
153
  </template>
@@ -1,43 +1,43 @@
1
- <script lang="ts" setup>
2
- import {computed} from 'vue'
3
- import {VTextField} from 'vuetify/components/VTextField'
4
- import {type MaskaDetail, type MaskOptions, vMaska} from 'maska'
5
-
6
- export interface Props extends /* @vue-ignore */ InstanceType<typeof VTextField['$props']> {
7
- type: 'eReceipt' | 'telephone'
8
- }
9
-
10
- const props = defineProps<Props>()
11
- const emit = defineEmits<{
12
- (event: 'update:modelValue', value: string): void
13
- }>()
14
-
15
- const computedMaskOption = computed<MaskOptions>(() => {
16
- if (props.type == 'eReceipt') return { mask: '##-##-N', tokens: { N: { pattern: /\d/, multiple: true } } }
17
- if (props.type == 'telephone') return { mask: '###-###-####' }
18
- return {}
19
- })
20
-
21
- function onMaska(event: CustomEvent<MaskaDetail>) {
22
- emit('update:modelValue', event.detail.unmasked)
23
- }
24
- </script>
25
-
26
- <template>
27
- <v-text-field
28
- v-maska:[computedMaskOption]
29
- v-bind="$attrs"
30
- @maska="onMaska"
31
- >
32
- <template
33
- v-for="(_, name, index) in ($slots as {})"
34
- :key="index"
35
- #[name]="slotData"
36
- >
37
- <slot
38
- :name="name"
39
- v-bind="((slotData || {}) as object)"
40
- />
41
- </template>
42
- </v-text-field>
43
- </template>
1
+ <script lang="ts" setup>
2
+ import {computed} from 'vue'
3
+ import {VTextField} from 'vuetify/components/VTextField'
4
+ import {type MaskaDetail, type MaskOptions, vMaska} from 'maska'
5
+
6
+ export interface Props extends /* @vue-ignore */ InstanceType<typeof VTextField['$props']> {
7
+ type: 'eReceipt' | 'telephone'
8
+ }
9
+
10
+ const props = defineProps<Props>()
11
+ const emit = defineEmits<{
12
+ (event: 'update:modelValue', value: string): void
13
+ }>()
14
+
15
+ const computedMaskOption = computed<MaskOptions>(() => {
16
+ if (props.type == 'eReceipt') return { mask: '##-##-N', tokens: { N: { pattern: /\d/, multiple: true } } }
17
+ if (props.type == 'telephone') return { mask: '###-###-####' }
18
+ return {}
19
+ })
20
+
21
+ function onMaska(event: CustomEvent<MaskaDetail>) {
22
+ emit('update:modelValue', event.detail.unmasked)
23
+ }
24
+ </script>
25
+
26
+ <template>
27
+ <v-text-field
28
+ v-maska:[computedMaskOption]
29
+ v-bind="$attrs"
30
+ @maska="onMaska"
31
+ >
32
+ <template
33
+ v-for="(_, name, index) in ($slots as {})"
34
+ :key="index"
35
+ #[name]="slotData"
36
+ >
37
+ <slot
38
+ :name="name"
39
+ v-bind="((slotData || {}) as object)"
40
+ />
41
+ </template>
42
+ </v-text-field>
43
+ </template>
@@ -1,11 +1,11 @@
1
- export interface AlertItem {
2
- message: string
3
- statusCode?: number
4
- statusMessage?: string
5
- alertLocation?: string
6
- alertType?: 'error' | 'success' | 'warning' | 'info' | undefined
7
- alertIcon?: string
8
- alertDateTime?: number
9
- alertExpireIn?: number
10
- data?: object
11
- }
1
+ export interface AlertItem {
2
+ message: string
3
+ statusCode?: number
4
+ statusMessage?: string
5
+ alertLocation?: string
6
+ alertType?: 'error' | 'success' | 'warning' | 'info' | undefined
7
+ alertIcon?: string
8
+ alertDateTime?: number
9
+ alertExpireIn?: number
10
+ data?: object
11
+ }
@@ -1,4 +1,4 @@
1
- export interface FormDialogCallback {
2
- done: Function
3
- error: Function
4
- }
1
+ export interface FormDialogCallback {
2
+ done: Function
3
+ error: Function
4
+ }
@@ -1,23 +1,23 @@
1
- export interface graphqlVariable {
2
- name: string
3
- list?: boolean
4
- required?: boolean
5
- type?: string
6
- value?: any
7
- }
8
- export interface graphqlOperationObject<T, U> {
9
- variables?: graphqlVariable[]
10
- fields?: graphqlTypeObject
11
- operationType: 'Query' | 'Mutation'
12
- name: string
13
- call: (fields?: Array<string | Object>, variables?: U) => Promise<T>
14
- }
15
-
16
- export interface graphqlTypeObject {
17
- fields: string[]
18
- relations: graphqlVariable[]
19
- }
20
-
21
- export interface graphqlInputObject {
22
- variables: graphqlVariable[]
23
- }
1
+ export interface graphqlVariable {
2
+ name: string
3
+ list?: boolean
4
+ required?: boolean
5
+ type?: string
6
+ value?: any
7
+ }
8
+ export interface graphqlOperationObject<T, U> {
9
+ variables?: graphqlVariable[]
10
+ fields?: graphqlTypeObject
11
+ operationType: 'Query' | 'Mutation'
12
+ name: string
13
+ call: (fields?: Array<string | Object>, variables?: U) => Promise<T>
14
+ }
15
+
16
+ export interface graphqlTypeObject {
17
+ fields: string[]
18
+ relations: graphqlVariable[]
19
+ }
20
+
21
+ export interface graphqlInputObject {
22
+ variables: graphqlVariable[]
23
+ }
@@ -1,25 +1,25 @@
1
- declare module '#app' {
2
- interface PageMeta {
3
- menuItem?: MenuMeta
4
- }
5
- }
6
-
7
- declare global {
8
- interface MenuMeta {
9
- title: string
10
- icon: string
11
- role: string
12
- }
13
-
14
- interface MenuItem {
15
- title: string
16
- icon: string
17
- role: string
18
- link: any
19
- menuItems: Array<MenuItem>
20
- active: boolean
21
- name: string
22
- }
23
- }
24
-
25
- export { MenuMeta, MenuItem }
1
+ declare module '#app' {
2
+ interface PageMeta {
3
+ menuItem?: MenuMeta
4
+ }
5
+ }
6
+
7
+ declare global {
8
+ interface MenuMeta {
9
+ title: string
10
+ icon: string
11
+ role: string
12
+ }
13
+
14
+ interface MenuItem {
15
+ title: string
16
+ icon: string
17
+ role: string
18
+ link: any
19
+ menuItems: Array<MenuItem>
20
+ active: boolean
21
+ name: string
22
+ }
23
+ }
24
+
25
+ export { MenuMeta, MenuItem }
@@ -1,7 +1,7 @@
1
- declare module 'painterro';
2
- declare module '@zxing/browser'
3
- declare module 'vue-signature-pad'
4
- declare module 'accounting'
5
- declare module 'pdf-vue3'
6
- declare module 'prettier'
7
- declare module 'prettier/plugins/html'
1
+ declare module 'painterro';
2
+ declare module '@zxing/browser'
3
+ declare module 'vue-signature-pad'
4
+ declare module 'accounting'
5
+ declare module 'pdf-vue3'
6
+ declare module 'prettier'
7
+ declare module 'prettier/plugins/html'