@ramathibodi/nuxt-commons 0.1.12 → 0.1.14
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.
- package/dist/module.json +1 -1
- package/dist/runtime/components/ExportCSV.vue +4 -4
- package/dist/runtime/components/FileBtn.vue +3 -3
- package/dist/runtime/components/ImportCSV.vue +1 -1
- package/dist/runtime/components/TabsGroup.vue +12 -8
- package/dist/runtime/components/form/Birthdate.vue +216 -0
- package/dist/runtime/components/form/CodeEditor.vue +3 -3
- package/dist/runtime/components/form/Dialog.vue +3 -2
- package/dist/runtime/components/form/Pad.vue +31 -9
- package/dist/runtime/components/form/Table.vue +5 -5
- package/dist/runtime/components/form/images/Capture.vue +231 -0
- package/dist/runtime/components/form/images/Edit.vue +95 -121
- package/dist/runtime/components/label/Field.vue +21 -8
- package/dist/runtime/components/master/Autocomplete.vue +7 -7
- package/dist/runtime/components/master/Combobox.vue +29 -25
- package/dist/runtime/components/master/RadioGroup.vue +40 -30
- package/dist/runtime/components/master/Select.vue +34 -23
- package/dist/runtime/components/model/Pad.vue +122 -0
- package/dist/runtime/components/model/Table.vue +126 -103
- package/dist/runtime/components/model/iterator.vue +312 -0
- package/dist/runtime/composables/graphql.mjs +1 -1
- package/dist/runtime/composables/graphqlModel.d.ts +7 -17
- package/dist/runtime/composables/graphqlModel.mjs +19 -89
- package/dist/runtime/composables/graphqlModelItem.d.ts +20 -0
- package/dist/runtime/composables/graphqlModelItem.mjs +103 -0
- package/dist/runtime/composables/graphqlModelOperation.d.ts +21 -0
- package/dist/runtime/composables/graphqlModelOperation.mjs +80 -0
- package/dist/runtime/composables/graphqlOperation.d.ts +2 -2
- package/dist/runtime/composables/graphqlOperation.mjs +9 -9
- package/dist/runtime/labs/form/TextFieldMask.vue +4 -4
- package/dist/runtime/types/formDialog.d.ts +3 -3
- package/dist/runtime/types/graphqlOperation.d.ts +14 -14
- package/package.json +5 -4
- package/scripts/postInstall.cjs +38 -35
- package/templates/.codegen/codegen.ts +8 -8
- package/templates/.codegen/plugin-schema-object.js +97 -97
- package/dist/runtime/components/Camera.vue +0 -129
- package/dist/runtime/components/form/images/CameraCrop.vue +0 -58
- package/dist/runtime/components/form/images/Preview.vue +0 -48
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { ref, onMounted, watchEffect } from 'vue'
|
|
3
|
-
import { useDevicesList, useUserMedia } from '@vueuse/core'
|
|
4
|
-
import { useAlert } from '../composables/alert'
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
modelValue?: string
|
|
8
|
-
}
|
|
9
|
-
const props = defineProps<Props>()
|
|
10
|
-
const emit = defineEmits(['update:modelValue', 'closeDialog'])
|
|
11
|
-
|
|
12
|
-
const alert = useAlert()
|
|
13
|
-
const videoRef = ref<HTMLVideoElement>()
|
|
14
|
-
const capturedPhoto = ref<string | null>(null)
|
|
15
|
-
const currentCameraId = ref<ConstrainDOMString | undefined>()
|
|
16
|
-
|
|
17
|
-
const { videoInputs: cameras } = useDevicesList({
|
|
18
|
-
requestPermissions: true,
|
|
19
|
-
constraints: { audio: false, video: true },
|
|
20
|
-
onUpdated() {
|
|
21
|
-
if (!cameras.value.find(camera => camera.deviceId === currentCameraId.value))
|
|
22
|
-
currentCameraId.value = cameras.value[0]?.deviceId
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
const { stream, enabled } = useUserMedia({
|
|
27
|
-
constraints: { video: { deviceId: currentCameraId.value } },
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
watchEffect(() => {
|
|
31
|
-
if (videoRef.value) (videoRef.value as HTMLVideoElement).srcObject = stream.value!
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
const captureImage = () => {
|
|
35
|
-
if (videoRef.value) {
|
|
36
|
-
const canvas = document.createElement('canvas')
|
|
37
|
-
canvas.width = (videoRef.value as HTMLVideoElement).videoWidth
|
|
38
|
-
canvas.height = (videoRef.value as HTMLVideoElement).videoHeight
|
|
39
|
-
const context = canvas.getContext('2d')
|
|
40
|
-
if (context) {
|
|
41
|
-
context.drawImage(videoRef.value as HTMLVideoElement, 0, 0, canvas.width, canvas.height)
|
|
42
|
-
capturedPhoto.value = canvas.toDataURL('image/jpeg')
|
|
43
|
-
|
|
44
|
-
enabled.value = false
|
|
45
|
-
emit('update:modelValue', capturedPhoto.value)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function loadImageFile(selectedFile: File | File[] | undefined) {
|
|
51
|
-
if (!selectedFile) {
|
|
52
|
-
alert?.addAlert({ message: 'No file selected.', alertType: 'error' })
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const reader = new FileReader()
|
|
57
|
-
reader.onload = (event) => {
|
|
58
|
-
capturedPhoto.value = event.target?.result as string
|
|
59
|
-
|
|
60
|
-
enabled.value = false
|
|
61
|
-
emit('update:modelValue', capturedPhoto.value)
|
|
62
|
-
}
|
|
63
|
-
const scanImageSingleFile: File = Array.isArray(selectedFile) ? selectedFile[0] : selectedFile
|
|
64
|
-
reader.readAsDataURL(scanImageSingleFile)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const openCamera = () => {
|
|
68
|
-
enabled.value = true
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const closeDialog = () => {
|
|
72
|
-
enabled.value = false
|
|
73
|
-
emit('closeDialog')
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
defineExpose({
|
|
77
|
-
openCamera,
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
onMounted(() => {
|
|
81
|
-
enabled.value = true
|
|
82
|
-
})
|
|
83
|
-
</script>
|
|
84
|
-
|
|
85
|
-
<template>
|
|
86
|
-
<v-card>
|
|
87
|
-
<v-card-title class="d-flex justify-end">
|
|
88
|
-
<v-btn
|
|
89
|
-
icon="fa:fa-solid fa-xmark"
|
|
90
|
-
variant="text"
|
|
91
|
-
@click="closeDialog"
|
|
92
|
-
/>
|
|
93
|
-
</v-card-title>
|
|
94
|
-
<v-card-text class="d-flex justify-center">
|
|
95
|
-
<video
|
|
96
|
-
ref="videoRef"
|
|
97
|
-
autoplay
|
|
98
|
-
style="max-width: 1024px"
|
|
99
|
-
/>
|
|
100
|
-
<div style="z-index: 2000; position: relative; bottom: -410px; left: -80px; height: 50px">
|
|
101
|
-
<FileBtn
|
|
102
|
-
accept="image/*"
|
|
103
|
-
icon="mdi mdi-image-plus"
|
|
104
|
-
icon-only
|
|
105
|
-
@update:model-value="loadImageFile"
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
</v-card-text>
|
|
109
|
-
<v-card-actions class="d-flex justify-center">
|
|
110
|
-
<v-btn
|
|
111
|
-
icon
|
|
112
|
-
size="x-large"
|
|
113
|
-
variant="tonal"
|
|
114
|
-
@click="captureImage()"
|
|
115
|
-
>
|
|
116
|
-
<v-icon
|
|
117
|
-
icon="fa:fa-solid fa-circle"
|
|
118
|
-
size="x-large"
|
|
119
|
-
/>
|
|
120
|
-
<v-tooltip
|
|
121
|
-
activator="parent"
|
|
122
|
-
location="top"
|
|
123
|
-
>
|
|
124
|
-
ถ่ายภาพ
|
|
125
|
-
</v-tooltip>
|
|
126
|
-
</v-btn>
|
|
127
|
-
</v-card-actions>
|
|
128
|
-
</v-card>
|
|
129
|
-
</template>
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { ref } from 'vue'
|
|
3
|
-
import { isUndefined } from 'lodash'
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
modelValue?: string
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const props = defineProps<Props>()
|
|
10
|
-
const emit = defineEmits(['update:modelValue', 'closeDialog', 'openCamera'])
|
|
11
|
-
|
|
12
|
-
const selectedImage = ref<string>()
|
|
13
|
-
const isDialogOpen = ref<boolean>(false)
|
|
14
|
-
const cameraRef = ref()
|
|
15
|
-
|
|
16
|
-
const handleAddImage = (image: string) => {
|
|
17
|
-
selectedImage.value = image
|
|
18
|
-
isDialogOpen.value = true
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const handleCloseDialog = () => {
|
|
22
|
-
isDialogOpen.value = false
|
|
23
|
-
emit('openCamera', true)
|
|
24
|
-
emit('closeDialog', false)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const handleCameraClose = (shouldClose: boolean, editStatus: string) => {
|
|
28
|
-
if (isUndefined(editStatus)) {
|
|
29
|
-
emit('closeDialog', shouldClose)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const handleImageEdit = (imageData: any) => {
|
|
34
|
-
emit('update:modelValue', imageData)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const handleOpenCamera = () => {
|
|
38
|
-
emit('openCamera', true)
|
|
39
|
-
isDialogOpen.value = false
|
|
40
|
-
cameraRef.value.openCamera()
|
|
41
|
-
}
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
<template>
|
|
45
|
-
<Camera
|
|
46
|
-
ref="cameraRef"
|
|
47
|
-
@update:model-value="handleAddImage"
|
|
48
|
-
@close-dialog="handleCameraClose"
|
|
49
|
-
/>
|
|
50
|
-
<v-dialog v-model="isDialogOpen">
|
|
51
|
-
<FormImagesEdit
|
|
52
|
-
v-model="selectedImage"
|
|
53
|
-
@update:model-value="handleImageEdit"
|
|
54
|
-
@close-dialog="handleCloseDialog"
|
|
55
|
-
@open-camera="handleOpenCamera"
|
|
56
|
-
/>
|
|
57
|
-
</v-dialog>
|
|
58
|
-
</template>
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
interface Props {
|
|
3
|
-
modelValue?: any
|
|
4
|
-
readonly?: boolean
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
8
|
-
readonly: false,
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
const emit = defineEmits([
|
|
12
|
-
'update:modelValue',
|
|
13
|
-
'closeDialogPreview',
|
|
14
|
-
'toPaint',
|
|
15
|
-
])
|
|
16
|
-
|
|
17
|
-
const editImage = () => {
|
|
18
|
-
emit('toPaint')
|
|
19
|
-
}
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
<template>
|
|
23
|
-
<v-card>
|
|
24
|
-
<v-toolbar>
|
|
25
|
-
<v-toolbar-title>Preview</v-toolbar-title>
|
|
26
|
-
<v-spacer />
|
|
27
|
-
<v-btn
|
|
28
|
-
v-if="!props.readonly"
|
|
29
|
-
icon="fa:fa-solid fa-pen"
|
|
30
|
-
variant="text"
|
|
31
|
-
@click="editImage"
|
|
32
|
-
/>
|
|
33
|
-
<v-btn
|
|
34
|
-
icon="fa:fa-solid fa-xmark"
|
|
35
|
-
variant="text"
|
|
36
|
-
@click="$emit('closeDialogPreview', false)"
|
|
37
|
-
/>
|
|
38
|
-
</v-toolbar>
|
|
39
|
-
<v-card-text>
|
|
40
|
-
<v-row>
|
|
41
|
-
<v-img
|
|
42
|
-
:src="modelValue.data"
|
|
43
|
-
height="70dvh"
|
|
44
|
-
/>
|
|
45
|
-
</v-row>
|
|
46
|
-
</v-card-text>
|
|
47
|
-
</v-card>
|
|
48
|
-
</template>
|