@ramathibodi/nuxt-commons 0.1.73 → 4.0.0
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/README.md +81 -55
- package/dist/module.json +4 -4
- package/dist/module.mjs +5 -4
- package/dist/runtime/bridges/authentication.d.ts +21 -0
- package/dist/runtime/bridges/authentication.js +20 -0
- package/dist/runtime/bridges/graphql.d.ts +17 -0
- package/dist/runtime/bridges/graphql.js +45 -0
- package/dist/runtime/components/Alert.d.vue.ts +3 -0
- package/dist/runtime/components/Alert.vue +17 -22
- package/dist/runtime/components/Alert.vue.d.ts +3 -0
- package/dist/runtime/components/BarcodeReader.d.vue.ts +9 -0
- package/dist/runtime/components/BarcodeReader.vue +56 -73
- package/dist/runtime/components/BarcodeReader.vue.d.ts +9 -0
- package/dist/runtime/components/ExportCSV.d.vue.ts +55 -0
- package/dist/runtime/components/ExportCSV.vue +39 -68
- package/dist/runtime/components/ExportCSV.vue.d.ts +55 -0
- package/dist/runtime/components/FileBtn.d.vue.ts +53 -0
- package/dist/runtime/components/FileBtn.vue +23 -38
- package/dist/runtime/components/FileBtn.vue.d.ts +53 -0
- package/dist/runtime/components/ImportCSV.d.vue.ts +52 -0
- package/dist/runtime/components/ImportCSV.vue +60 -99
- package/dist/runtime/components/ImportCSV.vue.d.ts +52 -0
- package/dist/runtime/components/MrzReader.d.vue.ts +19 -0
- package/dist/runtime/components/MrzReader.vue +128 -0
- package/dist/runtime/components/MrzReader.vue.d.ts +19 -0
- package/dist/runtime/components/SplitterPanel.d.vue.ts +15 -0
- package/dist/runtime/components/SplitterPanel.vue +18 -27
- package/dist/runtime/components/SplitterPanel.vue.d.ts +15 -0
- package/dist/runtime/components/TabsGroup.d.vue.ts +19 -0
- package/dist/runtime/components/TabsGroup.vue +8 -12
- package/dist/runtime/components/TabsGroup.vue.d.ts +19 -0
- package/dist/runtime/components/TextBarcode.d.vue.ts +12 -0
- package/dist/runtime/components/TextBarcode.vue +22 -33
- package/dist/runtime/components/TextBarcode.vue.d.ts +12 -0
- package/dist/runtime/components/device/IdCardButton.d.vue.ts +57 -0
- package/dist/runtime/components/device/IdCardButton.vue +30 -55
- package/dist/runtime/components/device/IdCardButton.vue.d.ts +57 -0
- package/dist/runtime/components/device/IdCardWebSocket.d.vue.ts +55 -0
- package/dist/runtime/components/device/IdCardWebSocket.vue +104 -153
- package/dist/runtime/components/device/IdCardWebSocket.vue.d.ts +55 -0
- package/dist/runtime/components/device/Scanner.d.vue.ts +66 -0
- package/dist/runtime/components/device/Scanner.vue +97 -166
- package/dist/runtime/components/device/Scanner.vue.d.ts +66 -0
- package/dist/runtime/components/dialog/Confirm.d.vue.ts +37 -0
- package/dist/runtime/components/dialog/Confirm.vue +30 -47
- package/dist/runtime/components/dialog/Confirm.vue.d.ts +37 -0
- package/dist/runtime/components/dialog/Host.d.vue.ts +9 -0
- package/dist/runtime/components/dialog/Host.vue +34 -53
- package/dist/runtime/components/dialog/Host.vue.d.ts +9 -0
- package/dist/runtime/components/dialog/Index.d.vue.ts +24 -0
- package/dist/runtime/components/dialog/Index.vue +20 -28
- package/dist/runtime/components/dialog/Index.vue.d.ts +24 -0
- package/dist/runtime/components/dialog/Loading.d.vue.ts +21 -0
- package/dist/runtime/components/dialog/Loading.vue +12 -17
- package/dist/runtime/components/dialog/Loading.vue.d.ts +21 -0
- package/dist/runtime/components/dialog/default/Confirm.d.vue.ts +40 -0
- package/dist/runtime/components/dialog/default/Confirm.vue +29 -50
- package/dist/runtime/components/dialog/default/Confirm.vue.d.ts +40 -0
- package/dist/runtime/components/dialog/default/Loading.d.vue.ts +23 -0
- package/dist/runtime/components/dialog/default/Loading.vue +12 -17
- package/dist/runtime/components/dialog/default/Loading.vue.d.ts +23 -0
- package/dist/runtime/components/dialog/default/Notify.d.vue.ts +23 -0
- package/dist/runtime/components/dialog/default/Notify.vue +19 -36
- package/dist/runtime/components/dialog/default/Notify.vue.d.ts +23 -0
- package/dist/runtime/components/dialog/default/Printing.d.vue.ts +21 -0
- package/dist/runtime/components/dialog/default/Printing.vue +13 -17
- package/dist/runtime/components/dialog/default/Printing.vue.d.ts +21 -0
- package/dist/runtime/components/dialog/default/VerifyUser.d.vue.ts +29 -0
- package/dist/runtime/components/dialog/default/VerifyUser.vue +44 -70
- package/dist/runtime/components/dialog/default/VerifyUser.vue.d.ts +29 -0
- package/dist/runtime/components/document/Form.d.vue.ts +9 -0
- package/dist/runtime/components/document/Form.vue +27 -34
- package/dist/runtime/components/document/Form.vue.d.ts +9 -0
- package/dist/runtime/components/document/TemplateBuilder.d.vue.ts +24 -0
- package/dist/runtime/components/document/TemplateBuilder.vue +154 -182
- package/dist/runtime/components/document/TemplateBuilder.vue.d.ts +24 -0
- package/dist/runtime/components/form/ActionPad.d.vue.ts +114 -0
- package/dist/runtime/components/form/ActionPad.vue +48 -73
- package/dist/runtime/components/form/ActionPad.vue.d.ts +114 -0
- package/dist/runtime/components/form/Birthdate.d.vue.ts +38 -0
- package/dist/runtime/components/form/Birthdate.vue +44 -64
- package/dist/runtime/components/form/Birthdate.vue.d.ts +38 -0
- package/dist/runtime/components/form/CheckboxGroup.d.vue.ts +41 -0
- package/dist/runtime/components/form/CheckboxGroup.vue +34 -52
- package/dist/runtime/components/form/CheckboxGroup.vue.d.ts +41 -0
- package/dist/runtime/components/form/CodeEditor.d.vue.ts +25 -0
- package/dist/runtime/components/form/CodeEditor.vue +18 -28
- package/dist/runtime/components/form/CodeEditor.vue.d.ts +25 -0
- package/dist/runtime/components/form/Date.d.vue.ts +86 -0
- package/dist/runtime/components/form/Date.vue +109 -150
- package/dist/runtime/components/form/Date.vue.d.ts +86 -0
- package/dist/runtime/components/form/DateTime.d.vue.ts +36 -0
- package/dist/runtime/components/form/DateTime.vue +94 -131
- package/dist/runtime/components/form/DateTime.vue.d.ts +36 -0
- package/dist/runtime/components/form/Dialog.d.vue.ts +69 -0
- package/dist/runtime/components/form/Dialog.vue +60 -84
- package/dist/runtime/components/form/Dialog.vue.d.ts +69 -0
- package/dist/runtime/components/form/EditPad.d.vue.ts +113 -0
- package/dist/runtime/components/form/EditPad.vue +49 -73
- package/dist/runtime/components/form/EditPad.vue.d.ts +113 -0
- package/dist/runtime/components/form/File.d.vue.ts +65 -0
- package/dist/runtime/components/form/File.vue +112 -174
- package/dist/runtime/components/form/File.vue.d.ts +65 -0
- package/dist/runtime/components/form/Hidden.d.vue.ts +12 -0
- package/dist/runtime/components/form/Hidden.vue +17 -22
- package/dist/runtime/components/form/Hidden.vue.d.ts +12 -0
- package/dist/runtime/components/form/Iterator.d.vue.ts +279 -0
- package/dist/runtime/components/form/Iterator.vue +162 -240
- package/dist/runtime/components/form/Iterator.vue.d.ts +279 -0
- package/dist/runtime/components/form/Login.d.vue.ts +32 -0
- package/dist/runtime/components/form/Login.vue +23 -43
- package/dist/runtime/components/form/Login.vue.d.ts +32 -0
- package/dist/runtime/components/form/Pad.d.vue.ts +674 -0
- package/dist/runtime/components/form/Pad.vue +166 -253
- package/dist/runtime/components/form/Pad.vue.d.ts +674 -0
- package/dist/runtime/components/form/SignPad.d.vue.ts +62 -0
- package/dist/runtime/components/form/SignPad.vue +80 -118
- package/dist/runtime/components/form/SignPad.vue.d.ts +62 -0
- package/dist/runtime/components/form/System.d.vue.ts +34 -0
- package/dist/runtime/components/form/System.vue +18 -24
- package/dist/runtime/components/form/System.vue.d.ts +34 -0
- package/dist/runtime/components/form/Table.d.vue.ts +221 -0
- package/dist/runtime/components/form/Table.vue +123 -170
- package/dist/runtime/components/form/Table.vue.d.ts +221 -0
- package/dist/runtime/components/form/TableData.d.vue.ts +102 -0
- package/dist/runtime/components/form/TableData.vue +109 -127
- package/dist/runtime/components/form/TableData.vue.d.ts +102 -0
- package/dist/runtime/components/form/Time.d.vue.ts +49 -0
- package/dist/runtime/components/form/Time.vue +64 -87
- package/dist/runtime/components/form/Time.vue.d.ts +49 -0
- package/dist/runtime/components/form/images/Capture.d.vue.ts +96 -0
- package/dist/runtime/components/form/images/Capture.vue +104 -139
- package/dist/runtime/components/form/images/Capture.vue.d.ts +96 -0
- package/dist/runtime/components/form/images/Edit.d.vue.ts +29 -0
- package/dist/runtime/components/form/images/Edit.vue +57 -69
- package/dist/runtime/components/form/images/Edit.vue.d.ts +29 -0
- package/dist/runtime/components/form/images/Field.d.vue.ts +27 -0
- package/dist/runtime/components/form/images/Field.vue +136 -194
- package/dist/runtime/components/form/images/Field.vue.d.ts +27 -0
- package/dist/runtime/components/form/images/Pad.d.vue.ts +13 -0
- package/dist/runtime/components/form/images/Pad.vue +23 -28
- package/dist/runtime/components/form/images/Pad.vue.d.ts +13 -0
- package/dist/runtime/components/label/Date.d.vue.ts +13 -0
- package/dist/runtime/components/label/Date.vue +13 -21
- package/dist/runtime/components/label/Date.vue.d.ts +13 -0
- package/dist/runtime/components/label/DateAgo.d.vue.ts +20 -0
- package/dist/runtime/components/label/DateAgo.vue +43 -67
- package/dist/runtime/components/label/DateAgo.vue.d.ts +20 -0
- package/dist/runtime/components/label/DateCount.d.vue.ts +22 -0
- package/dist/runtime/components/label/DateCount.vue +58 -97
- package/dist/runtime/components/label/DateCount.vue.d.ts +22 -0
- package/dist/runtime/components/label/Field.d.vue.ts +38 -0
- package/dist/runtime/components/label/Field.vue +18 -32
- package/dist/runtime/components/label/Field.vue.d.ts +38 -0
- package/dist/runtime/components/label/FormatMoney.d.vue.ts +12 -0
- package/dist/runtime/components/label/FormatMoney.vue +12 -20
- package/dist/runtime/components/label/FormatMoney.vue.d.ts +12 -0
- package/dist/runtime/components/label/Mask.d.vue.ts +10 -0
- package/dist/runtime/components/label/Mask.vue +21 -30
- package/dist/runtime/components/label/Mask.vue.d.ts +10 -0
- package/dist/runtime/components/label/Object.d.vue.ts +8 -0
- package/dist/runtime/components/label/Object.vue +10 -12
- package/dist/runtime/components/label/Object.vue.d.ts +8 -0
- package/dist/runtime/components/master/Autocomplete.d.vue.ts +70 -0
- package/dist/runtime/components/master/Autocomplete.vue +25 -26
- package/dist/runtime/components/master/Autocomplete.vue.d.ts +70 -0
- package/dist/runtime/components/master/Combobox.d.vue.ts +70 -0
- package/dist/runtime/components/master/Combobox.vue +26 -27
- package/dist/runtime/components/master/Combobox.vue.d.ts +70 -0
- package/dist/runtime/components/master/RadioGroup.d.vue.ts +51 -0
- package/dist/runtime/components/master/RadioGroup.vue +44 -47
- package/dist/runtime/components/master/RadioGroup.vue.d.ts +51 -0
- package/dist/runtime/components/master/Select.d.vue.ts +68 -0
- package/dist/runtime/components/master/Select.vue +25 -26
- package/dist/runtime/components/master/Select.vue.d.ts +68 -0
- package/dist/runtime/components/master/label.d.vue.ts +24 -0
- package/dist/runtime/components/master/label.vue +22 -34
- package/dist/runtime/components/master/label.vue.d.ts +24 -0
- package/dist/runtime/components/model/Autocomplete.d.vue.ts +82 -0
- package/dist/runtime/components/model/Autocomplete.vue +50 -37
- package/dist/runtime/components/model/Autocomplete.vue.d.ts +82 -0
- package/dist/runtime/components/model/Combobox.d.vue.ts +82 -0
- package/dist/runtime/components/model/Combobox.vue +51 -37
- package/dist/runtime/components/model/Combobox.vue.d.ts +82 -0
- package/dist/runtime/components/model/Pad.d.vue.ts +72 -0
- package/dist/runtime/components/model/Pad.vue +50 -53
- package/dist/runtime/components/model/Pad.vue.d.ts +72 -0
- package/dist/runtime/components/model/Select.d.vue.ts +72 -0
- package/dist/runtime/components/model/Select.vue +42 -32
- package/dist/runtime/components/model/Select.vue.d.ts +72 -0
- package/dist/runtime/components/model/Table.d.vue.ts +272 -0
- package/dist/runtime/components/model/Table.vue +121 -133
- package/dist/runtime/components/model/Table.vue.d.ts +272 -0
- package/dist/runtime/components/model/iterator.d.vue.ts +321 -0
- package/dist/runtime/components/model/iterator.vue +148 -175
- package/dist/runtime/components/model/iterator.vue.d.ts +321 -0
- package/dist/runtime/components/model/label.d.vue.ts +26 -0
- package/dist/runtime/components/model/label.vue +25 -35
- package/dist/runtime/components/model/label.vue.d.ts +26 -0
- package/dist/runtime/components/pdf/Print.d.vue.ts +17 -0
- package/dist/runtime/components/pdf/Print.vue +27 -38
- package/dist/runtime/components/pdf/Print.vue.d.ts +17 -0
- package/dist/runtime/components/pdf/View.d.vue.ts +52 -0
- package/dist/runtime/components/pdf/View.vue +58 -83
- package/dist/runtime/components/pdf/View.vue.d.ts +52 -0
- package/dist/runtime/composables/alert.d.ts +4 -0
- package/dist/runtime/composables/api.d.ts +4 -0
- package/dist/runtime/composables/api.js +4 -2
- package/dist/runtime/composables/assetFile.js +4 -2
- package/dist/runtime/composables/dialog.d.ts +1 -1
- package/dist/runtime/composables/document/template.js +3 -3
- package/dist/runtime/composables/document/templateFormHidden.d.ts +4 -0
- package/dist/runtime/composables/document/templateFormTable.js +1 -0
- package/dist/runtime/composables/graphql.d.ts +2 -2
- package/dist/runtime/composables/graphql.js +5 -5
- package/dist/runtime/composables/graphqlModel.d.ts +6 -6
- package/dist/runtime/composables/graphqlModelItem.d.ts +4 -4
- package/dist/runtime/composables/graphqlModelOperation.d.ts +6 -6
- package/dist/runtime/composables/graphqlModelOperation.js +2 -1
- package/dist/runtime/composables/graphqlOperation.js +5 -1
- package/dist/runtime/composables/hostAgentWs.d.ts +1 -1
- package/dist/runtime/composables/localStorageModel.d.ts +4 -0
- package/dist/runtime/composables/lookupList.d.ts +4 -0
- package/dist/runtime/composables/lookupListMaster.js +3 -3
- package/dist/runtime/composables/menu.d.ts +4 -0
- package/dist/runtime/composables/menu.js +2 -2
- package/dist/runtime/composables/useMrzReader.d.ts +48 -0
- package/dist/runtime/composables/useMrzReader.js +423 -0
- package/dist/runtime/composables/useTesseract.d.ts +16 -0
- package/dist/runtime/composables/useTesseract.js +45 -0
- package/dist/runtime/composables/userPermission.d.ts +1 -1
- package/dist/runtime/composables/utils/fuzzy.d.ts +2 -1
- package/dist/runtime/labs/Calendar.d.vue.ts +35 -0
- package/dist/runtime/labs/Calendar.vue +47 -75
- package/dist/runtime/labs/Calendar.vue.d.ts +35 -0
- package/dist/runtime/labs/form/EditMobile.d.vue.ts +12 -0
- package/dist/runtime/labs/form/EditMobile.vue +19 -36
- package/dist/runtime/labs/form/EditMobile.vue.d.ts +12 -0
- package/dist/runtime/labs/form/TextFieldMask.d.vue.ts +21 -0
- package/dist/runtime/labs/form/TextFieldMask.vue +19 -25
- package/dist/runtime/labs/form/TextFieldMask.vue.d.ts +21 -0
- package/dist/runtime/plugins/dialogManager.js +2 -2
- package/dist/runtime/plugins/permission.js +3 -3
- package/dist/runtime/types/bridge.d.ts +14 -0
- package/dist/runtime/utils/asset.d.ts +2 -0
- package/dist/runtime/utils/asset.js +49 -0
- package/dist/runtime/utils/datetime.js +1 -1
- package/dist/types.d.mts +2 -6
- package/package.json +79 -57
- package/scripts/ci-release.mjs +125 -0
- package/scripts/enrich-vue-docs-from-ai.mjs +197 -0
- package/scripts/generate-ai-summary.mjs +321 -0
- package/scripts/generate-composables-md.mjs +129 -0
- package/scripts/release-version.mjs +68 -0
- package/scripts/release.mjs +49 -0
- package/templates/public/tesseract/mrz.traineddata.gz +0 -0
- package/templates/public/tesseract/ocrb.traineddata.gz +0 -0
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -8
- package/dist/types.d.ts +0 -7
|
@@ -1,180 +1,145 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {computed,
|
|
3
|
-
import {useDevicesList, useUserMedia} from "@vueuse/core"
|
|
4
|
-
import {getBase64Strings
|
|
5
|
-
import {useAlert} from
|
|
6
|
-
import {VInput} from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
buttonText: "Add Photo",
|
|
27
|
-
maxWidth: 1024
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const alert = useAlert()
|
|
31
|
-
|
|
32
|
-
const imageData = defineModel<string>()
|
|
33
|
-
const inputRef = useTemplateRef<VInput>("inputRef")
|
|
34
|
-
|
|
35
|
-
const isLoading = ref<boolean>(false)
|
|
36
|
-
const isCaptured = computed(()=>!!imageData.value)
|
|
37
|
-
const isEditing = ref<boolean>(false)
|
|
38
|
-
|
|
39
|
-
const videoScreen = ref<HTMLVideoElement>()
|
|
40
|
-
|
|
41
|
-
const currentCameraId = ref<ConstrainDOMString | undefined>()
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, onBeforeUnmount, onMounted, ref, useTemplateRef, watchEffect } from "vue";
|
|
3
|
+
import { useDevicesList, useUserMedia } from "@vueuse/core";
|
|
4
|
+
import { getBase64Strings } from "exif-rotate-js";
|
|
5
|
+
import { useAlert } from "../../../composables/alert";
|
|
6
|
+
import { VInput } from "vuetify/components/VInput";
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
imageFormat: { type: String, required: false, default: "image/jpeg" },
|
|
9
|
+
autoStart: { type: Boolean, required: false, default: true },
|
|
10
|
+
fileOnly: { type: Boolean, required: false, default: false },
|
|
11
|
+
readonly: { type: Boolean, required: false, default: false },
|
|
12
|
+
disabled: { type: Boolean, required: false, default: false },
|
|
13
|
+
buttonText: { type: String, required: false, default: "Add Photo" },
|
|
14
|
+
maxHeight: { type: [String, Number], required: false },
|
|
15
|
+
maxWidth: { type: [String, Number], required: false, default: 1024 },
|
|
16
|
+
aspectRatio: { type: Number, required: false }
|
|
17
|
+
});
|
|
18
|
+
const alert = useAlert();
|
|
19
|
+
const imageData = defineModel({ type: String });
|
|
20
|
+
const inputRef = useTemplateRef("inputRef");
|
|
21
|
+
const isLoading = ref(false);
|
|
22
|
+
const isCaptured = computed(() => !!imageData.value);
|
|
23
|
+
const isEditing = ref(false);
|
|
24
|
+
const videoScreen = ref();
|
|
25
|
+
const currentCameraId = ref();
|
|
42
26
|
const { videoInputs: cameras } = useDevicesList({
|
|
43
27
|
requestPermissions: true,
|
|
44
28
|
constraints: { audio: false, video: true },
|
|
45
29
|
onUpdated() {
|
|
46
|
-
if (!cameras.value.find(camera => camera.deviceId === currentCameraId.value))
|
|
47
|
-
currentCameraId.value = cameras.value[0]?.deviceId
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
const hasCamera = computed(()=>{
|
|
51
|
-
|
|
30
|
+
if (!cameras.value.find((camera) => camera.deviceId === currentCameraId.value))
|
|
31
|
+
currentCameraId.value = cameras.value[0]?.deviceId;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const hasCamera = computed(() => {
|
|
35
|
+
return !!currentCameraId.value;
|
|
36
|
+
});
|
|
52
37
|
const { stream, start: cameraStart, stop: cameraStop, enabled: cameraEnabled } = useUserMedia({
|
|
53
|
-
constraints: { video: { deviceId: currentCameraId.value, width: {min: 1280}, aspectRatio: props.aspectRatio}}
|
|
54
|
-
})
|
|
55
|
-
|
|
38
|
+
constraints: { video: { deviceId: currentCameraId.value, width: { min: 1280 }, aspectRatio: props.aspectRatio } }
|
|
39
|
+
});
|
|
56
40
|
watchEffect(() => {
|
|
57
|
-
if (videoScreen.value) videoScreen.value.srcObject =
|
|
58
|
-
})
|
|
59
|
-
|
|
41
|
+
if (videoScreen.value) videoScreen.value.srcObject = stream.value ? stream.value : null;
|
|
42
|
+
});
|
|
60
43
|
function startCamera() {
|
|
61
|
-
imageData.value =
|
|
44
|
+
imageData.value = void 0;
|
|
62
45
|
if (!cameraEnabled.value) {
|
|
63
|
-
isLoading.value = true
|
|
64
|
-
cameraStart().finally(()=>{
|
|
65
|
-
isLoading.value = false
|
|
66
|
-
})
|
|
46
|
+
isLoading.value = true;
|
|
47
|
+
cameraStart().finally(() => {
|
|
48
|
+
isLoading.value = false;
|
|
49
|
+
});
|
|
67
50
|
}
|
|
68
51
|
}
|
|
69
|
-
|
|
70
52
|
function stopCamera() {
|
|
71
|
-
if (cameraEnabled.value) cameraStop()
|
|
53
|
+
if (cameraEnabled.value) cameraStop();
|
|
72
54
|
}
|
|
73
|
-
|
|
74
55
|
function captureImage() {
|
|
75
56
|
if (videoScreen.value) {
|
|
76
|
-
const canvas = document.createElement(
|
|
77
|
-
canvas.width = videoScreen.value.videoWidth
|
|
78
|
-
canvas.height = videoScreen.value.videoHeight
|
|
79
|
-
const context = canvas.getContext(
|
|
57
|
+
const canvas = document.createElement("canvas");
|
|
58
|
+
canvas.width = videoScreen.value.videoWidth;
|
|
59
|
+
canvas.height = videoScreen.value.videoHeight;
|
|
60
|
+
const context = canvas.getContext("2d");
|
|
80
61
|
if (context) {
|
|
81
|
-
context.drawImage(videoScreen.value, 0, 0, canvas.width, canvas.height)
|
|
82
|
-
isEditing.value = false
|
|
83
|
-
imageData.value = canvas.toDataURL(props.imageFormat)
|
|
84
|
-
stopCamera()
|
|
62
|
+
context.drawImage(videoScreen.value, 0, 0, canvas.width, canvas.height);
|
|
63
|
+
isEditing.value = false;
|
|
64
|
+
imageData.value = canvas.toDataURL(props.imageFormat);
|
|
65
|
+
stopCamera();
|
|
85
66
|
}
|
|
86
67
|
}
|
|
87
68
|
}
|
|
88
|
-
|
|
89
|
-
function captureImageFile(selectedFile: File | File[] | undefined) {
|
|
69
|
+
function captureImageFile(selectedFile) {
|
|
90
70
|
if (!selectedFile) {
|
|
91
|
-
alert?.addAlert({ message:
|
|
92
|
-
return
|
|
71
|
+
alert?.addAlert({ message: "No file selected.", alertType: "error" });
|
|
72
|
+
return;
|
|
93
73
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
stopCamera()
|
|
101
|
-
}).catch((e) => void e)
|
|
74
|
+
const scanImageSingleFile = Array.isArray(selectedFile) ? selectedFile[0] : selectedFile;
|
|
75
|
+
getBase64Strings([scanImageSingleFile], { maxSize: computedMaxSize.value, type: props.imageFormat, quality: 1 }).then((returnData) => {
|
|
76
|
+
isEditing.value = false;
|
|
77
|
+
imageData.value = returnData[0];
|
|
78
|
+
stopCamera();
|
|
79
|
+
}).catch((e) => void e);
|
|
102
80
|
}
|
|
103
|
-
|
|
104
81
|
onMounted(() => {
|
|
105
|
-
if (!isCaptured.value && props.autoStart && !props.fileOnly) startCamera()
|
|
106
|
-
})
|
|
107
|
-
|
|
82
|
+
if (!isCaptured.value && props.autoStart && !props.fileOnly) startCamera();
|
|
83
|
+
});
|
|
108
84
|
onBeforeUnmount(() => {
|
|
109
|
-
stopCamera()
|
|
110
|
-
})
|
|
111
|
-
|
|
85
|
+
stopCamera();
|
|
86
|
+
});
|
|
112
87
|
function reset() {
|
|
113
|
-
inputRef.value?.reset()
|
|
114
|
-
stopCamera()
|
|
115
|
-
if (props.autoStart && !props.fileOnly) startCamera()
|
|
88
|
+
inputRef.value?.reset();
|
|
89
|
+
stopCamera();
|
|
90
|
+
if (props.autoStart && !props.fileOnly) startCamera();
|
|
116
91
|
}
|
|
117
|
-
|
|
118
92
|
const computedMaxWidth = computed(() => {
|
|
119
|
-
if (typeof props.maxWidth ===
|
|
120
|
-
return `${props.maxWidth}px
|
|
93
|
+
if (typeof props.maxWidth === "number") {
|
|
94
|
+
return `${props.maxWidth}px`;
|
|
121
95
|
} else if (!isNaN(Number(props.maxWidth))) {
|
|
122
|
-
return `${props.maxWidth}px
|
|
96
|
+
return `${props.maxWidth}px`;
|
|
123
97
|
}
|
|
124
|
-
return props.maxWidth
|
|
125
|
-
})
|
|
126
|
-
|
|
98
|
+
return props.maxWidth;
|
|
99
|
+
});
|
|
127
100
|
const computedMaxHeight = computed(() => {
|
|
128
|
-
if (typeof props.maxHeight ===
|
|
129
|
-
return `${props.maxHeight}px
|
|
101
|
+
if (typeof props.maxHeight === "number") {
|
|
102
|
+
return `${props.maxHeight}px`;
|
|
130
103
|
} else if (!isNaN(Number(props.maxHeight))) {
|
|
131
|
-
return `${props.maxHeight}px
|
|
104
|
+
return `${props.maxHeight}px`;
|
|
132
105
|
}
|
|
133
|
-
return props.maxHeight
|
|
134
|
-
})
|
|
135
|
-
|
|
106
|
+
return props.maxHeight;
|
|
107
|
+
});
|
|
136
108
|
const computedMaxSize = computed(() => {
|
|
137
|
-
let tmpMaxHeight
|
|
138
|
-
let tmpMaxWidth
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
tmpMaxWidth = <number>props.maxWidth
|
|
109
|
+
let tmpMaxHeight = 1024;
|
|
110
|
+
let tmpMaxWidth = 1024;
|
|
111
|
+
if (typeof props.maxWidth === "number") {
|
|
112
|
+
tmpMaxWidth = props.maxWidth;
|
|
142
113
|
} else if (!isNaN(Number(props.maxWidth))) {
|
|
143
|
-
tmpMaxWidth = Number(props.maxWidth)
|
|
114
|
+
tmpMaxWidth = Number(props.maxWidth);
|
|
144
115
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
tmpMaxHeight = <number>props.maxHeight
|
|
116
|
+
if (typeof props.maxHeight === "number") {
|
|
117
|
+
tmpMaxHeight = props.maxHeight;
|
|
148
118
|
} else if (!isNaN(Number(props.maxHeight))) {
|
|
149
|
-
tmpMaxHeight = Number(props.maxHeight)
|
|
119
|
+
tmpMaxHeight = Number(props.maxHeight);
|
|
150
120
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
return inputRef.value?.
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
const errorMessages = computed(()=>{
|
|
162
|
-
return inputRef.value?.errorMessages
|
|
163
|
-
})
|
|
164
|
-
|
|
121
|
+
return tmpMaxWidth > tmpMaxHeight ? tmpMaxWidth : tmpMaxHeight;
|
|
122
|
+
});
|
|
123
|
+
const operation = ref({ startCamera, stopCamera, reset, captureImage, captureImageFile, isLoading, isCaptured, hasCamera });
|
|
124
|
+
const isValid = computed(() => {
|
|
125
|
+
return inputRef.value?.isValid;
|
|
126
|
+
});
|
|
127
|
+
const errorMessages = computed(() => {
|
|
128
|
+
return inputRef.value?.errorMessages;
|
|
129
|
+
});
|
|
165
130
|
defineExpose({
|
|
166
131
|
errorMessages,
|
|
167
132
|
isValid,
|
|
168
133
|
reset,
|
|
169
|
-
resetValidation
|
|
170
|
-
validate
|
|
134
|
+
resetValidation: () => inputRef.value?.resetValidation(),
|
|
135
|
+
validate: () => inputRef.value?.validate(),
|
|
171
136
|
operation
|
|
172
|
-
})
|
|
137
|
+
});
|
|
173
138
|
</script>
|
|
174
139
|
|
|
175
140
|
<template>
|
|
176
141
|
<v-input v-model="imageData" v-bind="$attrs" ref="inputRef">
|
|
177
|
-
<template #default="{isReadonly,isDisabled}">
|
|
142
|
+
<template #default="{ isReadonly, isDisabled }">
|
|
178
143
|
<v-container fluid class="ma-0 pa-0">
|
|
179
144
|
<v-card>
|
|
180
145
|
<v-card-text class="d-flex justify-center text-center" v-if="!isLoading && !isCaptured">
|
|
@@ -191,8 +156,8 @@ defineExpose({
|
|
|
191
156
|
</FileBtn>
|
|
192
157
|
</template>
|
|
193
158
|
<template v-else>
|
|
194
|
-
<div style="position: relative; display: inline-block; width: 100%;" :style="{maxWidth:computedMaxWidth,maxHeight:computedMaxHeight}">
|
|
195
|
-
<video autoplay ref="videoScreen" width="100%" :style="{maxWidth:computedMaxWidth,maxHeight:computedMaxHeight}"></video>
|
|
159
|
+
<div style="position: relative; display: inline-block; width: 100%;" :style="{ maxWidth: computedMaxWidth, maxHeight: computedMaxHeight }">
|
|
160
|
+
<video autoplay ref="videoScreen" width="100%" :style="{ maxWidth: computedMaxWidth, maxHeight: computedMaxHeight }"></video>
|
|
196
161
|
<div style="position: absolute; bottom: 10px; right: 10px; z-index: 2000;">
|
|
197
162
|
<FileBtn
|
|
198
163
|
accept="image/*"
|
|
@@ -206,18 +171,18 @@ defineExpose({
|
|
|
206
171
|
</template>
|
|
207
172
|
</v-card-text>
|
|
208
173
|
<v-card-text class="d-flex justify-center" v-if="isCaptured">
|
|
209
|
-
<div style="position: relative; display: inline-block; width: 100%;" :style="{maxWidth:computedMaxWidth,maxHeight:computedMaxHeight}" v-if="!isEditing">
|
|
174
|
+
<div style="position: relative; display: inline-block; width: 100%;" :style="{ maxWidth: computedMaxWidth, maxHeight: computedMaxHeight }" v-if="!isEditing">
|
|
210
175
|
<v-img :src="imageData" :max-height="maxHeight" :max-width="maxWidth" contain></v-img>
|
|
211
176
|
<div style="position: absolute; bottom: 10px; right: 10px; z-index: 2000;">
|
|
212
177
|
<v-btn
|
|
213
178
|
icon="mdi mdi-image-edit"
|
|
214
179
|
icon-only
|
|
215
|
-
@click="isEditing=true"
|
|
180
|
+
@click="isEditing = true"
|
|
216
181
|
:disabled="disabled || readonly || (isReadonly.value || isDisabled.value)"
|
|
217
182
|
/>
|
|
218
183
|
</div>
|
|
219
184
|
</div>
|
|
220
|
-
<form-images-edit v-model="imageData" :aspect-ratio="aspectRatio" :image-format="imageFormat" @update:model-value="isEditing=false" @close="isEditing=false" v-else></form-images-edit>
|
|
185
|
+
<form-images-edit v-model="imageData" :aspect-ratio="aspectRatio" :image-format="imageFormat" @update:model-value="isEditing = false" @close="isEditing = false" v-else></form-images-edit>
|
|
221
186
|
</v-card-text>
|
|
222
187
|
<v-card-text class="d-flex justify-center" v-if="isLoading">
|
|
223
188
|
<v-progress-circular indeterminate></v-progress-circular>
|
|
@@ -225,7 +190,7 @@ defineExpose({
|
|
|
225
190
|
<v-card-actions v-if="!readonly && (!fileOnly || isCaptured) && !isEditing && !(isReadonly.value || isDisabled.value)">
|
|
226
191
|
<slot name="actions" :operation="operation">
|
|
227
192
|
<v-spacer></v-spacer>
|
|
228
|
-
<v-btn color="primary" variant="flat" @click="startCamera" v-if="!cameraEnabled && hasCamera && !fileOnly" :disabled="disabled">{{
|
|
193
|
+
<v-btn color="primary" variant="flat" @click="startCamera" v-if="!cameraEnabled && hasCamera && !fileOnly" :disabled="disabled">{{ isCaptured ? "Retake" : "Start" }}</v-btn>
|
|
229
194
|
<v-btn color="primary" variant="flat" @click="captureImage" v-if="cameraEnabled" :disabled="disabled">Capture</v-btn>
|
|
230
195
|
<v-btn color="primary" variant="flat" @click="reset" :disabled="disabled">Reset</v-btn>
|
|
231
196
|
<v-spacer></v-spacer>
|
|
@@ -235,4 +200,4 @@ defineExpose({
|
|
|
235
200
|
</v-container>
|
|
236
201
|
</template>
|
|
237
202
|
</v-input>
|
|
238
|
-
</template>
|
|
203
|
+
</template>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type ImageFormat } from 'exif-rotate-js';
|
|
2
|
+
interface Props {
|
|
3
|
+
imageFormat?: ImageFormat;
|
|
4
|
+
autoStart?: boolean;
|
|
5
|
+
fileOnly?: boolean;
|
|
6
|
+
readonly?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
buttonText?: string;
|
|
9
|
+
maxHeight?: string | number;
|
|
10
|
+
maxWidth?: string | number;
|
|
11
|
+
aspectRatio?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Public props accepted by FormImagesCapture.
|
|
15
|
+
* Document each prop field with intent, defaults, and side effects for clear generated docs.
|
|
16
|
+
*/
|
|
17
|
+
type __VLS_Props = Props;
|
|
18
|
+
declare function startCamera(): void;
|
|
19
|
+
declare function stopCamera(): void;
|
|
20
|
+
declare function captureImage(): void;
|
|
21
|
+
declare function captureImageFile(selectedFile: File | File[] | undefined): void;
|
|
22
|
+
declare function reset(): void;
|
|
23
|
+
type __VLS_ModelProps = {
|
|
24
|
+
modelValue?: string;
|
|
25
|
+
};
|
|
26
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
27
|
+
declare var __VLS_92: {
|
|
28
|
+
operation: {
|
|
29
|
+
startCamera: typeof startCamera;
|
|
30
|
+
stopCamera: typeof stopCamera;
|
|
31
|
+
reset: typeof reset;
|
|
32
|
+
captureImage: typeof captureImage;
|
|
33
|
+
captureImageFile: typeof captureImageFile;
|
|
34
|
+
isLoading: boolean;
|
|
35
|
+
isCaptured: boolean;
|
|
36
|
+
hasCamera: boolean;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
type __VLS_Slots = {} & {
|
|
40
|
+
actions?: (props: typeof __VLS_92) => any;
|
|
41
|
+
};
|
|
42
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
43
|
+
errorMessages: import("vue").ComputedRef<(string & string[]) | (readonly string[] & string[]) | undefined>;
|
|
44
|
+
isValid: import("vue").ComputedRef<boolean | null | undefined>;
|
|
45
|
+
reset: typeof reset;
|
|
46
|
+
resetValidation: () => Promise<void> | undefined;
|
|
47
|
+
validate: () => Promise<string[]> | undefined;
|
|
48
|
+
operation: import("vue").Ref<{
|
|
49
|
+
startCamera: typeof startCamera;
|
|
50
|
+
stopCamera: typeof stopCamera;
|
|
51
|
+
reset: typeof reset;
|
|
52
|
+
captureImage: typeof captureImage;
|
|
53
|
+
captureImageFile: typeof captureImageFile;
|
|
54
|
+
isLoading: boolean;
|
|
55
|
+
isCaptured: boolean;
|
|
56
|
+
hasCamera: boolean;
|
|
57
|
+
}, {
|
|
58
|
+
startCamera: typeof startCamera;
|
|
59
|
+
stopCamera: typeof stopCamera;
|
|
60
|
+
reset: typeof reset;
|
|
61
|
+
captureImage: typeof captureImage;
|
|
62
|
+
captureImageFile: typeof captureImageFile;
|
|
63
|
+
isLoading: import("vue").Ref<boolean, boolean>;
|
|
64
|
+
isCaptured: import("vue").ComputedRef<boolean>;
|
|
65
|
+
hasCamera: import("vue").ComputedRef<boolean>;
|
|
66
|
+
} | {
|
|
67
|
+
startCamera: typeof startCamera;
|
|
68
|
+
stopCamera: typeof stopCamera;
|
|
69
|
+
reset: typeof reset;
|
|
70
|
+
captureImage: typeof captureImage;
|
|
71
|
+
captureImageFile: typeof captureImageFile;
|
|
72
|
+
isLoading: boolean;
|
|
73
|
+
isCaptured: boolean;
|
|
74
|
+
hasCamera: boolean;
|
|
75
|
+
}>;
|
|
76
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
77
|
+
"update:modelValue": (value: string | undefined) => any;
|
|
78
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
79
|
+
"onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
|
|
80
|
+
}>, {
|
|
81
|
+
disabled: boolean;
|
|
82
|
+
maxWidth: string | number;
|
|
83
|
+
readonly: boolean;
|
|
84
|
+
buttonText: string;
|
|
85
|
+
imageFormat: ImageFormat;
|
|
86
|
+
autoStart: boolean;
|
|
87
|
+
fileOnly: boolean;
|
|
88
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
89
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
90
|
+
declare const _default: typeof __VLS_export;
|
|
91
|
+
export default _default;
|
|
92
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
93
|
+
new (): {
|
|
94
|
+
$slots: S;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import 'cropperjs/dist/cropper.css';
|
|
2
|
+
import type { ImageFormat } from "exif-rotate-js";
|
|
3
|
+
interface Props {
|
|
4
|
+
imageFormat?: ImageFormat;
|
|
5
|
+
maxHeight?: string | number;
|
|
6
|
+
maxWidth?: string | number;
|
|
7
|
+
aspectRatio?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Public props accepted by FormImagesEdit.
|
|
11
|
+
* Document each prop field with intent, defaults, and side effects for clear generated docs.
|
|
12
|
+
*/
|
|
13
|
+
type __VLS_Props = Props;
|
|
14
|
+
type __VLS_ModelProps = {
|
|
15
|
+
modelValue?: string;
|
|
16
|
+
};
|
|
17
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
18
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
19
|
+
close: (...args: any[]) => void;
|
|
20
|
+
"update:modelValue": (value: string | undefined) => void;
|
|
21
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
22
|
+
"onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
|
|
23
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
24
|
+
}>, {
|
|
25
|
+
maxWidth: string | number;
|
|
26
|
+
imageFormat: ImageFormat;
|
|
27
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
export default _default;
|
|
@@ -1,87 +1,74 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {computed, ref} from
|
|
3
|
-
import Cropper from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
maxWidth: 1024
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
const imageData = defineModel<string>()
|
|
20
|
-
const emit = defineEmits(['close'])
|
|
21
|
-
|
|
22
|
-
const cropper = ref<Cropper>()
|
|
23
|
-
const imageRef = ref<HTMLImageElement>()
|
|
24
|
-
const dragMode = ref<string>("none")
|
|
25
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
import Cropper from "cropperjs";
|
|
4
|
+
import "cropperjs/dist/cropper.css";
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
imageFormat: { type: String, required: false, default: "image/jpeg" },
|
|
7
|
+
maxHeight: { type: [String, Number], required: false },
|
|
8
|
+
maxWidth: { type: [String, Number], required: false, default: 1024 },
|
|
9
|
+
aspectRatio: { type: Number, required: false }
|
|
10
|
+
});
|
|
11
|
+
const imageData = defineModel({ type: String });
|
|
12
|
+
const emit = defineEmits(["close"]);
|
|
13
|
+
const cropper = ref();
|
|
14
|
+
const imageRef = ref();
|
|
15
|
+
const dragMode = ref("none");
|
|
26
16
|
function loadCropper() {
|
|
27
|
-
if (cropper.value) cropper.value?.destroy()
|
|
17
|
+
if (cropper.value) cropper.value?.destroy();
|
|
28
18
|
if (imageRef.value) {
|
|
29
|
-
cropper.value = new Cropper(
|
|
19
|
+
cropper.value = new Cropper(imageRef.value, {
|
|
30
20
|
aspectRatio: props.aspectRatio,
|
|
31
|
-
autoCrop:false,
|
|
32
|
-
autoCropArea:1
|
|
33
|
-
})
|
|
21
|
+
autoCrop: false,
|
|
22
|
+
autoCropArea: 1
|
|
23
|
+
});
|
|
34
24
|
}
|
|
35
25
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const moveLeft = () => cropper.value?.move(-10, 0)
|
|
52
|
-
const moveRight = () => cropper.value?.move(10, 0)
|
|
26
|
+
const setDragMode = (mode) => {
|
|
27
|
+
cropper.value?.setDragMode(mode);
|
|
28
|
+
};
|
|
29
|
+
const rotateLeft90 = () => cropper.value?.rotate(-90);
|
|
30
|
+
const rotateLeft = () => cropper.value?.rotate(-5);
|
|
31
|
+
const rotateRight = () => cropper.value?.rotate(5);
|
|
32
|
+
const rotateRight90 = () => cropper.value?.rotate(90);
|
|
33
|
+
const flipHorizontal = () => cropper.value?.scaleX(cropper.value.getData().scaleX * -1);
|
|
34
|
+
const flipVertical = () => cropper.value?.scaleY(cropper.value.getData().scaleY * -1);
|
|
35
|
+
const zoomIn = () => cropper.value?.zoom(0.1);
|
|
36
|
+
const zoomOut = () => cropper.value?.zoom(-0.1);
|
|
37
|
+
const moveUp = () => cropper.value?.move(0, -10);
|
|
38
|
+
const moveDown = () => cropper.value?.move(0, 10);
|
|
39
|
+
const moveLeft = () => cropper.value?.move(-10, 0);
|
|
40
|
+
const moveRight = () => cropper.value?.move(10, 0);
|
|
53
41
|
const accept = () => {
|
|
54
|
-
const croppedCanvas = cropper.value?.getCroppedCanvas()
|
|
55
|
-
imageData.value = croppedCanvas?.toDataURL(props.imageFormat,1)
|
|
56
|
-
}
|
|
42
|
+
const croppedCanvas = cropper.value?.getCroppedCanvas();
|
|
43
|
+
imageData.value = croppedCanvas?.toDataURL(props.imageFormat, 1);
|
|
44
|
+
};
|
|
57
45
|
const close = () => {
|
|
58
|
-
emit(
|
|
59
|
-
}
|
|
46
|
+
emit("close");
|
|
47
|
+
};
|
|
60
48
|
const reset = () => {
|
|
61
|
-
cropper.value?.reset()
|
|
62
|
-
cropper.value?.clear()
|
|
63
|
-
}
|
|
64
|
-
|
|
49
|
+
cropper.value?.reset();
|
|
50
|
+
cropper.value?.clear();
|
|
51
|
+
};
|
|
65
52
|
const computedMaxWidth = computed(() => {
|
|
66
|
-
if (typeof props.maxWidth ===
|
|
67
|
-
return `${props.maxWidth}px
|
|
53
|
+
if (typeof props.maxWidth === "number") {
|
|
54
|
+
return `${props.maxWidth}px`;
|
|
68
55
|
} else if (!isNaN(Number(props.maxWidth))) {
|
|
69
|
-
return `${props.maxWidth}px
|
|
56
|
+
return `${props.maxWidth}px`;
|
|
70
57
|
}
|
|
71
|
-
return props.maxWidth
|
|
72
|
-
})
|
|
73
|
-
|
|
58
|
+
return props.maxWidth;
|
|
59
|
+
});
|
|
74
60
|
const computedMaxHeight = computed(() => {
|
|
75
|
-
if (typeof props.maxHeight ===
|
|
76
|
-
return `${props.maxHeight}px
|
|
61
|
+
if (typeof props.maxHeight === "number") {
|
|
62
|
+
return `${props.maxHeight}px`;
|
|
77
63
|
} else if (!isNaN(Number(props.maxHeight))) {
|
|
78
|
-
return `${props.maxHeight}px
|
|
64
|
+
return `${props.maxHeight}px`;
|
|
79
65
|
}
|
|
80
|
-
return props.maxHeight
|
|
81
|
-
})
|
|
66
|
+
return props.maxHeight;
|
|
67
|
+
});
|
|
82
68
|
</script>
|
|
69
|
+
|
|
83
70
|
<template>
|
|
84
|
-
<div :style="{maxWidth:computedMaxWidth,maxHeight:computedMaxHeight}">
|
|
71
|
+
<div :style="{ maxWidth: computedMaxWidth, maxHeight: computedMaxHeight }">
|
|
85
72
|
<v-card>
|
|
86
73
|
<v-toolbar color="primary" dark>
|
|
87
74
|
<v-btn-toggle v-model="dragMode" class="ml-1">
|
|
@@ -119,6 +106,7 @@ const computedMaxHeight = computed(() => {
|
|
|
119
106
|
</v-card>
|
|
120
107
|
</div>
|
|
121
108
|
</template>
|
|
109
|
+
|
|
122
110
|
<style>
|
|
123
111
|
.cropper-bg{background-repeat:repeat!important}
|
|
124
|
-
</style>
|
|
112
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import 'cropperjs/dist/cropper.css';
|
|
2
|
+
import type { ImageFormat } from "exif-rotate-js";
|
|
3
|
+
interface Props {
|
|
4
|
+
imageFormat?: ImageFormat;
|
|
5
|
+
maxHeight?: string | number;
|
|
6
|
+
maxWidth?: string | number;
|
|
7
|
+
aspectRatio?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Public props accepted by FormImagesEdit.
|
|
11
|
+
* Document each prop field with intent, defaults, and side effects for clear generated docs.
|
|
12
|
+
*/
|
|
13
|
+
type __VLS_Props = Props;
|
|
14
|
+
type __VLS_ModelProps = {
|
|
15
|
+
modelValue?: string;
|
|
16
|
+
};
|
|
17
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
18
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
19
|
+
close: (...args: any[]) => void;
|
|
20
|
+
"update:modelValue": (value: string | undefined) => void;
|
|
21
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
22
|
+
"onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
|
|
23
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
24
|
+
}>, {
|
|
25
|
+
maxWidth: string | number;
|
|
26
|
+
imageFormat: ImageFormat;
|
|
27
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Base64Image } from '../../../composables/assetFile.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
modelValue?: Base64Image[];
|
|
4
|
+
readonly?: boolean;
|
|
5
|
+
label?: string;
|
|
6
|
+
accept?: string;
|
|
7
|
+
autoHydrate?: boolean;
|
|
8
|
+
maxFileSize?: number;
|
|
9
|
+
}
|
|
10
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {
|
|
11
|
+
errorMessages: import("vue").ComputedRef<(string & string[]) | (readonly string[] & string[]) | undefined>;
|
|
12
|
+
isValid: import("vue").ComputedRef<boolean | null | undefined>;
|
|
13
|
+
reset: () => Promise<void> | undefined;
|
|
14
|
+
resetValidation: () => Promise<void> | undefined;
|
|
15
|
+
validate: () => Promise<string[]> | undefined;
|
|
16
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
17
|
+
"update:modelValue": (value: Base64Image[]) => any;
|
|
18
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
19
|
+
"onUpdate:modelValue"?: ((value: Base64Image[]) => any) | undefined;
|
|
20
|
+
}>, {
|
|
21
|
+
modelValue: Base64Image[];
|
|
22
|
+
accept: string;
|
|
23
|
+
autoHydrate: boolean;
|
|
24
|
+
maxFileSize: number;
|
|
25
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
26
|
+
declare const _default: typeof __VLS_export;
|
|
27
|
+
export default _default;
|