@ramathibodi/nuxt-commons 0.1.13 → 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 (59) 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 -199
  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 +231 -0
  28. package/dist/runtime/components/form/images/Edit.vue +117 -143
  29. package/dist/runtime/components/label/Date.vue +29 -29
  30. package/dist/runtime/components/label/Field.vue +42 -29
  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.d.ts +4 -1
  43. package/dist/runtime/composables/graphqlModel.mjs +5 -5
  44. package/dist/runtime/composables/graphqlModelOperation.mjs +7 -4
  45. package/dist/runtime/labs/Calendar.vue +99 -99
  46. package/dist/runtime/labs/form/EditMobile.vue +152 -152
  47. package/dist/runtime/labs/form/TextFieldMask.vue +43 -43
  48. package/dist/runtime/types/alert.d.ts +11 -11
  49. package/dist/runtime/types/formDialog.d.ts +4 -4
  50. package/dist/runtime/types/graphqlOperation.d.ts +23 -23
  51. package/dist/runtime/types/menu.d.ts +25 -25
  52. package/dist/runtime/types/modules.d.ts +7 -7
  53. package/package.json +120 -118
  54. package/scripts/postInstall.cjs +70 -70
  55. package/templates/.codegen/codegen.ts +32 -32
  56. package/templates/.codegen/plugin-schema-object.js +154 -154
  57. package/dist/runtime/components/Camera.vue +0 -129
  58. package/dist/runtime/components/form/images/CameraCrop.vue +0 -58
  59. package/dist/runtime/components/form/images/Preview.vue +0 -48
@@ -1,240 +1,242 @@
1
- <script lang="ts" setup>
2
- import {computed, nextTick, ref, useAttrs} from 'vue'
3
- import {VDataTable} from 'vuetify/components/VDataTable'
4
- import {omit} from 'lodash-es'
5
- import type {GraphqlModelProps} from '../../composables/graphqlModel'
6
- import {useGraphqlModel} from '../../composables/graphqlModel'
7
-
8
- defineOptions({
9
- inheritAttrs: false,
10
- })
11
-
12
- interface Props extends /* @vue-ignore */ InstanceType<typeof VDataTable['$props']> {
13
- title: string
14
- noDataText?: string
15
- dialogFullscreen?: boolean
16
- initialData?: Record<string, any>
17
- toolbarColor?: string
18
- importable?: boolean
19
- exportable?: boolean
20
- }
21
-
22
- const props = withDefaults(defineProps<Props & GraphqlModelProps>(), {
23
- noDataText: 'ไม่พบข้อมูล',
24
- dialogFullscreen: false,
25
- toolbarColor: 'primary',
26
- importable: true,
27
- exportable: true,
28
- modelKey: 'id',
29
- modelBy: undefined,
30
- fields: () => [],
31
- })
32
-
33
- const attrs = useAttrs()
34
- const plainAttrs = computed(() => {
35
- const returnAttrs = omit(attrs, ['modelValue', 'onUpdate:modelValue'])
36
- if (props.headers) returnAttrs['headers'] = props.headers
37
- return returnAttrs
38
- })
39
- const currentItem = ref<Record<string, any> | undefined>(undefined)
40
- const isDialogOpen = ref<boolean>(false)
41
-
42
- const { items, itemsLength,
43
- search,
44
- canServerPageable, canServerSearch, canCreate, canUpdate, canDelete,
45
- createItem, importItems, updateItem, deleteItem,
46
- loadItems, reload,
47
- isLoading } = useGraphqlModel(props)
48
-
49
- function openDialog(item?: object) {
50
- currentItem.value = item
51
- nextTick(() => {
52
- isDialogOpen.value = true
53
- })
54
- }
55
-
56
- const operation = ref({ openDialog, createItem, importItems, updateItem, deleteItem, reload, canServerPageable, canServerSearch, canCreate, canUpdate, canDelete })
57
-
58
- const computedInitialData = computed(() => {
59
- return Object.assign({}, props.initialData, props.modelBy)
60
- })
61
-
62
- defineExpose({ reload })
63
- </script>
64
-
65
- <template>
66
- <v-card>
67
- <slot
68
- name="header"
69
- :items="items"
70
- :search="search"
71
- :operation="operation"
72
- >
73
- <VToolbar :color="toolbarColor">
74
- <v-row
75
- justify="end"
76
- class="ma-1"
77
- dense
78
- no-gutters
79
- align="center"
80
- >
81
- <v-col cols="7">
82
- <VToolbarTitle class="pl-3">
83
- <slot
84
- name="title"
85
- :reload="reload"
86
- >
87
- {{ title }}
88
- <v-icon
89
- size="small"
90
- @click="reload"
91
- >
92
- mdi mdi-refresh
93
- </v-icon>
94
- </slot>
95
- </VToolbarTitle>
96
- </v-col>
97
- <v-col cols="5">
98
- <slot name="search">
99
- <VTextField
100
- v-model="search"
101
- class="justify-end w-100"
102
- density="compact"
103
- hide-details
104
- placeholder="ค้นหา"
105
- clearable
106
- variant="solo"
107
- />
108
- </slot>
109
- </v-col>
110
- </v-row>
111
-
112
- <VToolbarItems>
113
- <slot name="toolbarItems" />
114
- <ImportCSV
115
- v-if="props.importable"
116
- icon="mdi mdi-file-upload"
117
- variant="flat"
118
- @import="importItems"
119
- />
120
- <ExportCSV
121
- v-if="props.exportable && items.length"
122
- icon="mdi mdi-file-download"
123
- variant="flat"
124
- :file-name="title"
125
- :model-value="items"
126
- />
127
- <VBtn
128
- v-if="canCreate"
129
- :color="toolbarColor"
130
- prepend-icon="mdi mdi-plus"
131
- variant="flat"
132
- @click="openDialog()"
133
- >
134
- add
135
- </VBtn>
136
- </VToolbarItems>
137
- </VToolbar>
138
- </slot>
139
- <v-data-table-server
140
- v-if="canServerPageable"
141
- v-bind="plainAttrs"
142
- color="primary"
143
- :items="items"
144
- :items-length="itemsLength"
145
- :item-value="props.modelKey"
146
- :search="search"
147
- :loading="isLoading"
148
- @update:options="loadItems"
149
- >
150
- <!-- @ts-ignore -->
151
- <template
152
- v-for="(_, name, index) in ($slots as {})"
153
- :key="index"
154
- #[name]="slotData"
155
- >
156
- <slot
157
- :name="name"
158
- v-bind="(slotData as object)"
159
- :operation="operation"
160
- />
161
- </template>
162
- <template
163
- v-if="!$slots['item.action']"
164
- #item.action="{ item }"
165
- >
166
- <v-btn
167
- v-if="canUpdate"
168
- variant="flat"
169
- density="compact"
170
- icon="mdi mdi-note-edit"
171
- @click="openDialog(item)"
172
- />
173
- <v-btn
174
- v-if="canDelete"
175
- variant="flat"
176
- density="compact"
177
- icon="mdi mdi-delete"
178
- @click="deleteItem(item)"
179
- />
180
- </template>
181
- </v-data-table-server>
182
- <v-data-table
183
- v-else
184
- v-bind="plainAttrs"
185
- color="primary"
186
- :items="items"
187
- :item-value="props.modelKey"
188
- :search="search"
189
- :loading="isLoading"
190
- >
191
- <!-- @ts-ignore -->
192
- <template
193
- v-for="(_, name, index) in ($slots as {})"
194
- :key="index"
195
- #[name]="slotData"
196
- >
197
- <slot
198
- :name="name"
199
- v-bind="(slotData as object)"
200
- :operation="operation"
201
- />
202
- </template>
203
- <template
204
- v-if="!$slots['item.action']"
205
- #item.action="{ item }"
206
- >
207
- <v-btn
208
- v-if="canUpdate"
209
- variant="flat"
210
- density="compact"
211
- icon="mdi mdi-note-edit"
212
- @click="openDialog(item)"
213
- />
214
- <v-btn
215
- v-if="canDelete"
216
- variant="flat"
217
- density="compact"
218
- icon="mdi mdi-delete"
219
- @click="deleteItem(item)"
220
- />
221
- </template>
222
- </v-data-table>
223
- <FormDialog
224
- v-model="isDialogOpen"
225
- :title="title"
226
- :fullscreen="dialogFullscreen"
227
- :initial-data="computedInitialData"
228
- :form-data="currentItem"
229
- @create="createItem"
230
- @update="updateItem"
231
- >
232
- <template #default="slotData">
233
- <slot
234
- name="form"
235
- v-bind="slotData"
236
- />
237
- </template>
238
- </FormDialog>
239
- </v-card>
240
- </template>
1
+ <script lang="ts" setup>
2
+ import {computed, nextTick, ref, useAttrs} from 'vue'
3
+ import {VDataTable} from 'vuetify/components/VDataTable'
4
+ import {omit} from 'lodash-es'
5
+ import type {GraphqlModelProps} from '../../composables/graphqlModel'
6
+ import {useGraphqlModel} from '../../composables/graphqlModel'
7
+
8
+ defineOptions({
9
+ inheritAttrs: false,
10
+ })
11
+
12
+ interface Props extends /* @vue-ignore */ InstanceType<typeof VDataTable['$props']> {
13
+ title: string
14
+ noDataText?: string
15
+ dialogFullscreen?: boolean
16
+ initialData?: Record<string, any>
17
+ toolbarColor?: string
18
+ importable?: boolean
19
+ exportable?: boolean
20
+ }
21
+
22
+ const props = withDefaults(defineProps<Props & GraphqlModelProps>(), {
23
+ noDataText: 'ไม่พบข้อมูล',
24
+ dialogFullscreen: false,
25
+ toolbarColor: 'primary',
26
+ importable: true,
27
+ exportable: true,
28
+ modelKey: 'id',
29
+ modelBy: undefined,
30
+ fields: () => [],
31
+ })
32
+
33
+ const attrs = useAttrs()
34
+ const plainAttrs = computed(() => {
35
+ const returnAttrs = omit(attrs, ['modelValue', 'onUpdate:modelValue'])
36
+ if (props.headers) returnAttrs['headers'] = props.headers
37
+ return returnAttrs
38
+ })
39
+ const currentItem = ref<Record<string, any> | undefined>(undefined)
40
+ const isDialogOpen = ref<boolean>(false)
41
+
42
+ const { items, itemsLength,
43
+ search,
44
+ canServerPageable, canServerSearch, canCreate, canUpdate, canDelete,
45
+ createItem, importItems, updateItem, deleteItem,
46
+ loadItems, reload,
47
+ isLoading } = useGraphqlModel(props)
48
+
49
+ function openDialog(item?: object) {
50
+ currentItem.value = item
51
+ nextTick(() => {
52
+ isDialogOpen.value = true
53
+ })
54
+ }
55
+
56
+ const operation = ref({ openDialog, createItem, importItems, updateItem, deleteItem, reload, canServerPageable, canServerSearch, canCreate, canUpdate, canDelete })
57
+
58
+ const computedInitialData = computed(() => {
59
+ return Object.assign({}, props.initialData, props.modelBy)
60
+ })
61
+
62
+ defineExpose({ reload })
63
+ </script>
64
+
65
+ <template>
66
+ <v-card>
67
+ <slot
68
+ name="header"
69
+ :items="items"
70
+ :search="search"
71
+ :operation="operation"
72
+ >
73
+ <VToolbar :color="toolbarColor">
74
+ <v-row
75
+ justify="end"
76
+ class="ma-1"
77
+ dense
78
+ no-gutters
79
+ align="center"
80
+ >
81
+ <v-col cols="7">
82
+ <VToolbarTitle class="pl-3">
83
+ <slot
84
+ name="title"
85
+ :reload="reload"
86
+ >
87
+ {{ title }}
88
+ <v-icon
89
+ size="small"
90
+ @click="reload"
91
+ >
92
+ mdi mdi-refresh
93
+ </v-icon>
94
+ </slot>
95
+ </VToolbarTitle>
96
+ </v-col>
97
+ <v-col cols="5">
98
+ <slot name="search">
99
+ <VTextField
100
+ v-model="search"
101
+ class="justify-end w-100"
102
+ density="compact"
103
+ hide-details
104
+ placeholder="ค้นหา"
105
+ clearable
106
+ variant="solo"
107
+ />
108
+ </slot>
109
+ </v-col>
110
+ </v-row>
111
+
112
+ <VToolbarItems>
113
+ <slot name="toolbarItems" />
114
+ <ImportCSV
115
+ v-if="props.importable"
116
+ icon="mdi mdi-file-upload"
117
+ variant="flat"
118
+ @import="importItems"
119
+ :color="toolbarColor"
120
+ />
121
+ <ExportCSV
122
+ v-if="props.exportable && items.length"
123
+ icon="mdi mdi-file-download"
124
+ variant="flat"
125
+ :file-name="title"
126
+ :model-value="items"
127
+ :color="toolbarColor"
128
+ />
129
+ <VBtn
130
+ v-if="canCreate"
131
+ :color="toolbarColor"
132
+ prepend-icon="mdi mdi-plus"
133
+ variant="flat"
134
+ @click="openDialog()"
135
+ >
136
+ add
137
+ </VBtn>
138
+ </VToolbarItems>
139
+ </VToolbar>
140
+ </slot>
141
+ <v-data-table-server
142
+ v-if="canServerPageable"
143
+ v-bind="plainAttrs"
144
+ color="primary"
145
+ :items="items"
146
+ :items-length="itemsLength"
147
+ :item-value="props.modelKey"
148
+ :search="search"
149
+ :loading="isLoading"
150
+ @update:options="loadItems"
151
+ >
152
+ <!-- @ts-ignore -->
153
+ <template
154
+ v-for="(_, name, index) in ($slots as {})"
155
+ :key="index"
156
+ #[name]="slotData"
157
+ >
158
+ <slot
159
+ :name="name"
160
+ v-bind="((slotData || {}) as object)"
161
+ :operation="operation"
162
+ />
163
+ </template>
164
+ <template
165
+ v-if="!$slots['item.action']"
166
+ #item.action="{ item }"
167
+ >
168
+ <v-btn
169
+ v-if="canUpdate"
170
+ variant="flat"
171
+ density="compact"
172
+ icon="mdi mdi-note-edit"
173
+ @click="openDialog(item)"
174
+ />
175
+ <v-btn
176
+ v-if="canDelete"
177
+ variant="flat"
178
+ density="compact"
179
+ icon="mdi mdi-delete"
180
+ @click="deleteItem(item)"
181
+ />
182
+ </template>
183
+ </v-data-table-server>
184
+ <v-data-table
185
+ v-else
186
+ v-bind="plainAttrs"
187
+ color="primary"
188
+ :items="items"
189
+ :item-value="props.modelKey"
190
+ :search="search"
191
+ :loading="isLoading"
192
+ >
193
+ <!-- @ts-ignore -->
194
+ <template
195
+ v-for="(_, name, index) in ($slots as {})"
196
+ :key="index"
197
+ #[name]="slotData"
198
+ >
199
+ <slot
200
+ :name="name"
201
+ v-bind="((slotData || {}) as object)"
202
+ :operation="operation"
203
+ />
204
+ </template>
205
+ <template
206
+ v-if="!$slots['item.action']"
207
+ #item.action="{ item }"
208
+ >
209
+ <v-btn
210
+ v-if="canUpdate"
211
+ variant="flat"
212
+ density="compact"
213
+ icon="mdi mdi-note-edit"
214
+ @click="openDialog(item)"
215
+ />
216
+ <v-btn
217
+ v-if="canDelete"
218
+ variant="flat"
219
+ density="compact"
220
+ icon="mdi mdi-delete"
221
+ @click="deleteItem(item)"
222
+ />
223
+ </template>
224
+ </v-data-table>
225
+ <FormDialog
226
+ v-model="isDialogOpen"
227
+ :title="title"
228
+ :fullscreen="dialogFullscreen"
229
+ :initial-data="computedInitialData"
230
+ :form-data="currentItem"
231
+ @create="createItem"
232
+ @update="updateItem"
233
+ >
234
+ <template #default="slotData">
235
+ <slot
236
+ name="form"
237
+ v-bind="slotData"
238
+ />
239
+ </template>
240
+ </FormDialog>
241
+ </v-card>
242
+ </template>