@finema/core 1.4.33 → 1.4.35
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 +63 -63
- package/dist/module.d.mts +4 -4
- package/dist/module.d.ts +4 -4
- package/dist/module.json +1 -1
- package/dist/module.mjs +7 -5
- package/dist/runtime/components/Alert.vue +49 -49
- package/dist/runtime/components/Avatar.vue +27 -27
- package/dist/runtime/components/Badge.vue +54 -54
- package/dist/runtime/components/Breadcrumb.vue +45 -45
- package/dist/runtime/components/Button/Group.vue +37 -37
- package/dist/runtime/components/Button/index.vue +77 -77
- package/dist/runtime/components/Card.vue +38 -38
- package/dist/runtime/components/Core.vue +13 -13
- package/dist/runtime/components/Dialog/index.vue +108 -108
- package/dist/runtime/components/Dropdown/index.vue +71 -71
- package/dist/runtime/components/Form/FieldWrapper.vue +23 -23
- package/dist/runtime/components/Form/Fields.vue +136 -136
- package/dist/runtime/components/Form/InputCheckbox/index.vue +21 -21
- package/dist/runtime/components/Form/InputDateTime/index.vue +51 -51
- package/dist/runtime/components/Form/InputRadio/index.vue +27 -27
- package/dist/runtime/components/Form/InputSelect/index.vue +37 -37
- package/dist/runtime/components/Form/InputStatic/index.vue +16 -16
- package/dist/runtime/components/Form/InputText/index.vue +27 -27
- package/dist/runtime/components/Form/InputTextarea/index.vue +25 -25
- package/dist/runtime/components/Form/InputToggle/index.vue +14 -14
- package/dist/runtime/components/Form/InputUploadFileClassic/index.vue +36 -36
- package/dist/runtime/components/Form/InputUploadFileClassicAuto/index.vue +152 -152
- package/dist/runtime/components/Form/index.vue +6 -6
- package/dist/runtime/components/Icon.vue +23 -23
- package/dist/runtime/components/Image.vue +36 -36
- package/dist/runtime/components/Loader.vue +14 -14
- package/dist/runtime/components/Modal/index.vue +146 -146
- package/dist/runtime/components/SimplePagination.vue +96 -96
- package/dist/runtime/components/Slideover/index.vue +110 -110
- package/dist/runtime/components/Table/Base.vue +132 -127
- package/dist/runtime/components/Table/ColumnDate.vue +16 -16
- package/dist/runtime/components/Table/ColumnDateTime.vue +30 -30
- package/dist/runtime/components/Table/ColumnImage.vue +13 -13
- package/dist/runtime/components/Table/ColumnNumber.vue +14 -14
- package/dist/runtime/components/Table/Simple.vue +57 -57
- package/dist/runtime/components/Table/index.vue +52 -52
- package/dist/runtime/components/Tabs/index.vue +65 -65
- package/dist/runtime/lib/Requester.d.ts +2 -0
- package/dist/runtime/lib/Requester.mjs +3 -0
- package/dist/runtime/types/utils.d.ts +29 -29
- package/dist/runtime/ui.config/breadcrumb.mjs +1 -1
- package/dist/runtime/ui.config/button.mjs +1 -1
- package/dist/runtime/ui.config/table.mjs +1 -2
- package/dist/runtime/ui.css +32 -32
- package/package.json +86 -86
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
-
<UTextarea
|
|
4
|
-
v-model="value"
|
|
5
|
-
:disabled="wrapperProps.isDisabled"
|
|
6
|
-
:name="name"
|
|
7
|
-
:resize="resize"
|
|
8
|
-
:placeholder="wrapperProps.placeholder"
|
|
9
|
-
:autofocus="!!autoFocus"
|
|
10
|
-
:autoresize="autoresize"
|
|
11
|
-
:rows="rows"
|
|
12
|
-
:readonly="isReadonly"
|
|
13
|
-
:ui="ui"
|
|
14
|
-
/>
|
|
15
|
-
</FieldWrapper>
|
|
16
|
-
</template>
|
|
17
|
-
<script lang="ts" setup>
|
|
18
|
-
import { useFieldHOC } from '#core/composables/useForm'
|
|
19
|
-
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
20
|
-
import { type ITextareaFieldProps } from '#core/components/Form/InputTextarea/types'
|
|
21
|
-
|
|
22
|
-
const props = withDefaults(defineProps<ITextareaFieldProps>(), {})
|
|
23
|
-
|
|
24
|
-
const { value, wrapperProps } = useFieldHOC<string>(props)
|
|
25
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
+
<UTextarea
|
|
4
|
+
v-model="value"
|
|
5
|
+
:disabled="wrapperProps.isDisabled"
|
|
6
|
+
:name="name"
|
|
7
|
+
:resize="resize"
|
|
8
|
+
:placeholder="wrapperProps.placeholder"
|
|
9
|
+
:autofocus="!!autoFocus"
|
|
10
|
+
:autoresize="autoresize"
|
|
11
|
+
:rows="rows"
|
|
12
|
+
:readonly="isReadonly"
|
|
13
|
+
:ui="ui"
|
|
14
|
+
/>
|
|
15
|
+
</FieldWrapper>
|
|
16
|
+
</template>
|
|
17
|
+
<script lang="ts" setup>
|
|
18
|
+
import { useFieldHOC } from '#core/composables/useForm'
|
|
19
|
+
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
20
|
+
import { type ITextareaFieldProps } from '#core/components/Form/InputTextarea/types'
|
|
21
|
+
|
|
22
|
+
const props = withDefaults(defineProps<ITextareaFieldProps>(), {})
|
|
23
|
+
|
|
24
|
+
const { value, wrapperProps } = useFieldHOC<string>(props)
|
|
25
|
+
</script>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
-
<UToggle v-model="value" :disabled="wrapperProps.isDisabled" :name="name" :ui="ui" />
|
|
4
|
-
</FieldWrapper>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script lang="ts" setup>
|
|
8
|
-
import { useFieldHOC } from '#core/composables/useForm'
|
|
9
|
-
import { type IToggleFieldProps } from '#core/components/Form/InputToggle/types'
|
|
10
|
-
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
11
|
-
|
|
12
|
-
const props = withDefaults(defineProps<IToggleFieldProps>(), {})
|
|
13
|
-
const { value, wrapperProps } = useFieldHOC<boolean>(props)
|
|
14
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
+
<UToggle v-model="value" :disabled="wrapperProps.isDisabled" :name="name" :ui="ui" />
|
|
4
|
+
</FieldWrapper>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { useFieldHOC } from '#core/composables/useForm'
|
|
9
|
+
import { type IToggleFieldProps } from '#core/components/Form/InputToggle/types'
|
|
10
|
+
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
11
|
+
|
|
12
|
+
const props = withDefaults(defineProps<IToggleFieldProps>(), {})
|
|
13
|
+
const { value, wrapperProps } = useFieldHOC<boolean>(props)
|
|
14
|
+
</script>
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
-
<UInput
|
|
4
|
-
type="file"
|
|
5
|
-
trailing
|
|
6
|
-
:loading-icon="loadingIcon"
|
|
7
|
-
:icon="icon"
|
|
8
|
-
:leading-icon="leadingIcon"
|
|
9
|
-
:trailing-icon="trailingIcon"
|
|
10
|
-
:disabled="wrapperProps.isDisabled"
|
|
11
|
-
:name="name"
|
|
12
|
-
:placeholder="wrapperProps.placeholder"
|
|
13
|
-
:autofocus="!!autoFocus"
|
|
14
|
-
:readonly="isReadonly"
|
|
15
|
-
:accept="accept"
|
|
16
|
-
:ui="ui"
|
|
17
|
-
@change="handleChange"
|
|
18
|
-
/>
|
|
19
|
-
</FieldWrapper>
|
|
20
|
-
</template>
|
|
21
|
-
<script lang="ts" setup>
|
|
22
|
-
import { useFieldHOC } from '#core/composables/useForm'
|
|
23
|
-
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
24
|
-
import { type IUploadFileClassicFieldProps } from '#core/components/Form/InputUploadFileClassic/types'
|
|
25
|
-
|
|
26
|
-
const props = withDefaults(defineProps<IUploadFileClassicFieldProps>(), {})
|
|
27
|
-
|
|
28
|
-
const { value, wrapperProps } = useFieldHOC<File | undefined>(props)
|
|
29
|
-
|
|
30
|
-
const emits = defineEmits(['change'])
|
|
31
|
-
|
|
32
|
-
const handleChange = (e: Event) => {
|
|
33
|
-
value.value = (e.target as HTMLInputElement).files?.[0]
|
|
34
|
-
emits('change', e)
|
|
35
|
-
}
|
|
36
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
+
<UInput
|
|
4
|
+
type="file"
|
|
5
|
+
trailing
|
|
6
|
+
:loading-icon="loadingIcon"
|
|
7
|
+
:icon="icon"
|
|
8
|
+
:leading-icon="leadingIcon"
|
|
9
|
+
:trailing-icon="trailingIcon"
|
|
10
|
+
:disabled="wrapperProps.isDisabled"
|
|
11
|
+
:name="name"
|
|
12
|
+
:placeholder="wrapperProps.placeholder"
|
|
13
|
+
:autofocus="!!autoFocus"
|
|
14
|
+
:readonly="isReadonly"
|
|
15
|
+
:accept="accept"
|
|
16
|
+
:ui="ui"
|
|
17
|
+
@change="handleChange"
|
|
18
|
+
/>
|
|
19
|
+
</FieldWrapper>
|
|
20
|
+
</template>
|
|
21
|
+
<script lang="ts" setup>
|
|
22
|
+
import { useFieldHOC } from '#core/composables/useForm'
|
|
23
|
+
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
24
|
+
import { type IUploadFileClassicFieldProps } from '#core/components/Form/InputUploadFileClassic/types'
|
|
25
|
+
|
|
26
|
+
const props = withDefaults(defineProps<IUploadFileClassicFieldProps>(), {})
|
|
27
|
+
|
|
28
|
+
const { value, wrapperProps } = useFieldHOC<File | undefined>(props)
|
|
29
|
+
|
|
30
|
+
const emits = defineEmits(['change'])
|
|
31
|
+
|
|
32
|
+
const handleChange = (e: Event) => {
|
|
33
|
+
value.value = (e.target as HTMLInputElement).files?.[0]
|
|
34
|
+
emits('change', e)
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
-
<div :class="[ui.base]">
|
|
4
|
-
<input
|
|
5
|
-
ref="fileInput"
|
|
6
|
-
type="file"
|
|
7
|
-
class="hidden"
|
|
8
|
-
:accept="acceptFile"
|
|
9
|
-
:required="isRequired"
|
|
10
|
-
:disabled="isDisabled"
|
|
11
|
-
@change="handleChange"
|
|
12
|
-
/>
|
|
13
|
-
<div :class="[ui.wrapper]">
|
|
14
|
-
<div :class="[ui.selectFileBox]">
|
|
15
|
-
<Button size="2xs" @click="handleOpenFile">{{ selectFileLabel || 'Choose File' }}</Button>
|
|
16
|
-
<p :class="ui.placeholder">
|
|
17
|
-
{{ selectedFile?.name ?? placeholder ?? 'No file chosen' }}
|
|
18
|
-
</p>
|
|
19
|
-
<Badge v-if="selectedFile" size="xs" variant="outline"> {{ selectedFileSize }} MB </Badge>
|
|
20
|
-
</div>
|
|
21
|
-
<div v-if="selectedFile">
|
|
22
|
-
<Icon
|
|
23
|
-
v-if="upload.status.value.isSuccess"
|
|
24
|
-
name="heroicons:check-circle-20-solid"
|
|
25
|
-
class="text-success"
|
|
26
|
-
/>
|
|
27
|
-
<Icon
|
|
28
|
-
v-if="upload.status.value.isError"
|
|
29
|
-
name="heroicons:x-circle-20-solid"
|
|
30
|
-
class="text-danger"
|
|
31
|
-
/>
|
|
32
|
-
<Icon
|
|
33
|
-
v-if="upload.status.value.isLoading"
|
|
34
|
-
name="i-svg-spinners:180-ring-with-bg"
|
|
35
|
-
class="text-primary"
|
|
36
|
-
/>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
<img v-if="imagePreviewURL && value" :src="imagePreviewURL" alt="" :class="ui.previewURL" />
|
|
41
|
-
</FieldWrapper>
|
|
42
|
-
</template>
|
|
43
|
-
|
|
44
|
-
<script lang="tsx" setup>
|
|
45
|
-
import { computed, ref, StringHelper, toRef, useUI, useUiConfig, useWatchTrue } from '#imports'
|
|
46
|
-
import { type IUploadFileProps } from './types'
|
|
47
|
-
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
48
|
-
import { useFieldHOC } from '#core/composables/useForm'
|
|
49
|
-
import { type IUploadRequest, useUploadLoader } from '#core/composables/useUpload'
|
|
50
|
-
import { uploadFileInputClassicAuto } from '#core/ui.config'
|
|
51
|
-
import i18next from 'i18next'
|
|
52
|
-
|
|
53
|
-
const config = useUiConfig<typeof uploadFileInputClassicAuto>(
|
|
54
|
-
uploadFileInputClassicAuto,
|
|
55
|
-
'uploadFileInputClassicAuto'
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
const emits = defineEmits(['success'])
|
|
59
|
-
const props = withDefaults(defineProps<IUploadFileProps>(), {})
|
|
60
|
-
|
|
61
|
-
const { wrapperProps, setErrors, value } = useFieldHOC<string>(props)
|
|
62
|
-
|
|
63
|
-
const request: IUploadRequest = {
|
|
64
|
-
pathURL: props.uploadPathURL,
|
|
65
|
-
requestOptions: props.requestOptions,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const upload = useUploadLoader(request)
|
|
69
|
-
|
|
70
|
-
const fileInput = ref<HTMLInputElement>()
|
|
71
|
-
const selectedFile = ref<File | undefined>()
|
|
72
|
-
const percent = ref<number>(0)
|
|
73
|
-
|
|
74
|
-
const selectedFileSize = computed(() => ((selectedFile.value?.size || 0) / 1000 / 1000).toFixed(2))
|
|
75
|
-
const acceptFileSize = computed(() => props.maxSize)
|
|
76
|
-
const acceptFileSizeMb = computed(() => ((acceptFileSize.value || 0) / 1024).toFixed(2))
|
|
77
|
-
const acceptFile = computed(() =>
|
|
78
|
-
typeof props.accept === 'string' ? props.accept : props.accept?.join(',')
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
const { ui } = useUI('uploadFileInputClassicAuto', toRef(props, 'ui'), config)
|
|
82
|
-
|
|
83
|
-
const handleOpenFile = () => {
|
|
84
|
-
fileInput.value?.click()
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const handleChange = (e: Event) => {
|
|
88
|
-
const file = (e.target as HTMLInputElement).files?.[0]
|
|
89
|
-
const result = handleCheckFileCondition(file)
|
|
90
|
-
|
|
91
|
-
if (result && file) {
|
|
92
|
-
selectedFile.value = file
|
|
93
|
-
const formData = new FormData()
|
|
94
|
-
|
|
95
|
-
formData.append(props.bodyKey || 'file', file)
|
|
96
|
-
upload.run(formData, { data: { onUploadProgress, onDownloadProgress } })
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const handleCheckFileCondition = (file: File | undefined): boolean => {
|
|
101
|
-
if (!file) return false
|
|
102
|
-
|
|
103
|
-
const maxSize = checkMaxSize(file)
|
|
104
|
-
|
|
105
|
-
if (!maxSize) {
|
|
106
|
-
setErrors(i18next.t('custom:invalid_file_size', { size: acceptFileSizeMb.value }))
|
|
107
|
-
|
|
108
|
-
return false
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
setErrors('')
|
|
112
|
-
|
|
113
|
-
return true
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const checkMaxSize = (file: File): boolean => {
|
|
117
|
-
if (acceptFileSize.value) {
|
|
118
|
-
return file.size / 1000 <= acceptFileSize.value
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return true
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const onUploadProgress = (progressEvent: ProgressEvent) => {
|
|
125
|
-
percent.value = (Math.floor((progressEvent.loaded * 100) / progressEvent.total) || 0) * 0.8
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const onDownloadProgress = (progressEvent: ProgressEvent) => {
|
|
129
|
-
if (progressEvent.total === 0) {
|
|
130
|
-
percent.value = 100
|
|
131
|
-
|
|
132
|
-
return
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
percent.value = (Math.floor((progressEvent.loaded * 100) / progressEvent.total) || 0) * 0.2 + 80
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
useWatchTrue(
|
|
139
|
-
() => upload.status.value.isSuccess,
|
|
140
|
-
() => {
|
|
141
|
-
value.value = upload.data.value[props.responseKey || 'url']
|
|
142
|
-
emits('success', upload.data.value)
|
|
143
|
-
}
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
useWatchTrue(
|
|
147
|
-
() => upload.status.value.isError,
|
|
148
|
-
() => {
|
|
149
|
-
setErrors(StringHelper.getError(upload.status.value.errorData))
|
|
150
|
-
}
|
|
151
|
-
)
|
|
152
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
+
<div :class="[ui.base]">
|
|
4
|
+
<input
|
|
5
|
+
ref="fileInput"
|
|
6
|
+
type="file"
|
|
7
|
+
class="hidden"
|
|
8
|
+
:accept="acceptFile"
|
|
9
|
+
:required="isRequired"
|
|
10
|
+
:disabled="isDisabled"
|
|
11
|
+
@change="handleChange"
|
|
12
|
+
/>
|
|
13
|
+
<div :class="[ui.wrapper]">
|
|
14
|
+
<div :class="[ui.selectFileBox]">
|
|
15
|
+
<Button size="2xs" @click="handleOpenFile">{{ selectFileLabel || 'Choose File' }}</Button>
|
|
16
|
+
<p :class="ui.placeholder">
|
|
17
|
+
{{ selectedFile?.name ?? placeholder ?? 'No file chosen' }}
|
|
18
|
+
</p>
|
|
19
|
+
<Badge v-if="selectedFile" size="xs" variant="outline"> {{ selectedFileSize }} MB </Badge>
|
|
20
|
+
</div>
|
|
21
|
+
<div v-if="selectedFile">
|
|
22
|
+
<Icon
|
|
23
|
+
v-if="upload.status.value.isSuccess"
|
|
24
|
+
name="heroicons:check-circle-20-solid"
|
|
25
|
+
class="text-success"
|
|
26
|
+
/>
|
|
27
|
+
<Icon
|
|
28
|
+
v-if="upload.status.value.isError"
|
|
29
|
+
name="heroicons:x-circle-20-solid"
|
|
30
|
+
class="text-danger"
|
|
31
|
+
/>
|
|
32
|
+
<Icon
|
|
33
|
+
v-if="upload.status.value.isLoading"
|
|
34
|
+
name="i-svg-spinners:180-ring-with-bg"
|
|
35
|
+
class="text-primary"
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
<img v-if="imagePreviewURL && value" :src="imagePreviewURL" alt="" :class="ui.previewURL" />
|
|
41
|
+
</FieldWrapper>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script lang="tsx" setup>
|
|
45
|
+
import { computed, ref, StringHelper, toRef, useUI, useUiConfig, useWatchTrue } from '#imports'
|
|
46
|
+
import { type IUploadFileProps } from './types'
|
|
47
|
+
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
48
|
+
import { useFieldHOC } from '#core/composables/useForm'
|
|
49
|
+
import { type IUploadRequest, useUploadLoader } from '#core/composables/useUpload'
|
|
50
|
+
import { uploadFileInputClassicAuto } from '#core/ui.config'
|
|
51
|
+
import i18next from 'i18next'
|
|
52
|
+
|
|
53
|
+
const config = useUiConfig<typeof uploadFileInputClassicAuto>(
|
|
54
|
+
uploadFileInputClassicAuto,
|
|
55
|
+
'uploadFileInputClassicAuto'
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
const emits = defineEmits(['success'])
|
|
59
|
+
const props = withDefaults(defineProps<IUploadFileProps>(), {})
|
|
60
|
+
|
|
61
|
+
const { wrapperProps, setErrors, value } = useFieldHOC<string>(props)
|
|
62
|
+
|
|
63
|
+
const request: IUploadRequest = {
|
|
64
|
+
pathURL: props.uploadPathURL,
|
|
65
|
+
requestOptions: props.requestOptions,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const upload = useUploadLoader(request)
|
|
69
|
+
|
|
70
|
+
const fileInput = ref<HTMLInputElement>()
|
|
71
|
+
const selectedFile = ref<File | undefined>()
|
|
72
|
+
const percent = ref<number>(0)
|
|
73
|
+
|
|
74
|
+
const selectedFileSize = computed(() => ((selectedFile.value?.size || 0) / 1000 / 1000).toFixed(2))
|
|
75
|
+
const acceptFileSize = computed(() => props.maxSize)
|
|
76
|
+
const acceptFileSizeMb = computed(() => ((acceptFileSize.value || 0) / 1024).toFixed(2))
|
|
77
|
+
const acceptFile = computed(() =>
|
|
78
|
+
typeof props.accept === 'string' ? props.accept : props.accept?.join(',')
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
const { ui } = useUI('uploadFileInputClassicAuto', toRef(props, 'ui'), config)
|
|
82
|
+
|
|
83
|
+
const handleOpenFile = () => {
|
|
84
|
+
fileInput.value?.click()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const handleChange = (e: Event) => {
|
|
88
|
+
const file = (e.target as HTMLInputElement).files?.[0]
|
|
89
|
+
const result = handleCheckFileCondition(file)
|
|
90
|
+
|
|
91
|
+
if (result && file) {
|
|
92
|
+
selectedFile.value = file
|
|
93
|
+
const formData = new FormData()
|
|
94
|
+
|
|
95
|
+
formData.append(props.bodyKey || 'file', file)
|
|
96
|
+
upload.run(formData, { data: { onUploadProgress, onDownloadProgress } })
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const handleCheckFileCondition = (file: File | undefined): boolean => {
|
|
101
|
+
if (!file) return false
|
|
102
|
+
|
|
103
|
+
const maxSize = checkMaxSize(file)
|
|
104
|
+
|
|
105
|
+
if (!maxSize) {
|
|
106
|
+
setErrors(i18next.t('custom:invalid_file_size', { size: acceptFileSizeMb.value }))
|
|
107
|
+
|
|
108
|
+
return false
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
setErrors('')
|
|
112
|
+
|
|
113
|
+
return true
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const checkMaxSize = (file: File): boolean => {
|
|
117
|
+
if (acceptFileSize.value) {
|
|
118
|
+
return file.size / 1000 <= acceptFileSize.value
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return true
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const onUploadProgress = (progressEvent: ProgressEvent) => {
|
|
125
|
+
percent.value = (Math.floor((progressEvent.loaded * 100) / progressEvent.total) || 0) * 0.8
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const onDownloadProgress = (progressEvent: ProgressEvent) => {
|
|
129
|
+
if (progressEvent.total === 0) {
|
|
130
|
+
percent.value = 100
|
|
131
|
+
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
percent.value = (Math.floor((progressEvent.loaded * 100) / progressEvent.total) || 0) * 0.2 + 80
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
useWatchTrue(
|
|
139
|
+
() => upload.status.value.isSuccess,
|
|
140
|
+
() => {
|
|
141
|
+
value.value = upload.data.value[props.responseKey || 'url']
|
|
142
|
+
emits('success', upload.data.value)
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
useWatchTrue(
|
|
147
|
+
() => upload.status.value.isError,
|
|
148
|
+
() => {
|
|
149
|
+
setErrors(StringHelper.getError(upload.status.value.errorData))
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<form class="form">
|
|
3
|
-
<slot />
|
|
4
|
-
</form>
|
|
5
|
-
</template>
|
|
6
|
-
<script lang="ts" setup></script>
|
|
1
|
+
<template>
|
|
2
|
+
<form class="form">
|
|
3
|
+
<slot />
|
|
4
|
+
</form>
|
|
5
|
+
</template>
|
|
6
|
+
<script lang="ts" setup></script>
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<UIcon :name="name" :dynamic="dynamicValue" />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script lang="ts" setup>
|
|
6
|
-
import { computed, useUiConfig } from '#imports'
|
|
7
|
-
import { icon } from '#core/ui.config'
|
|
8
|
-
|
|
9
|
-
const props = defineProps({
|
|
10
|
-
name: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: true,
|
|
13
|
-
},
|
|
14
|
-
dynamic: {
|
|
15
|
-
type: Boolean,
|
|
16
|
-
default: false,
|
|
17
|
-
},
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const config = useUiConfig<typeof icon>(icon, 'icon')
|
|
21
|
-
|
|
22
|
-
const dynamicValue = computed(() => props.dynamic || config.dynamic)
|
|
23
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<UIcon :name="name" :dynamic="dynamicValue" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script lang="ts" setup>
|
|
6
|
+
import { computed, useUiConfig } from '#imports'
|
|
7
|
+
import { icon } from '#core/ui.config'
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
name: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
dynamic: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: false,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const config = useUiConfig<typeof icon>(icon, 'icon')
|
|
21
|
+
|
|
22
|
+
const dynamicValue = computed(() => props.dynamic || config.dynamic)
|
|
23
|
+
</script>
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<img :src="getSrc" />
|
|
3
|
-
</template>
|
|
4
|
-
<script lang="ts" setup>
|
|
5
|
-
import { useImage } from '@vueuse/core'
|
|
6
|
-
import { computed } from 'vue'
|
|
7
|
-
|
|
8
|
-
const props = defineProps({
|
|
9
|
-
src: {
|
|
10
|
-
type: String,
|
|
11
|
-
required: true,
|
|
12
|
-
},
|
|
13
|
-
loadingSrc: {
|
|
14
|
-
type: String,
|
|
15
|
-
default: '',
|
|
16
|
-
},
|
|
17
|
-
errorSrc: {
|
|
18
|
-
type: String,
|
|
19
|
-
default: '',
|
|
20
|
-
},
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const { isLoading, error } = useImage({ src: props.src })
|
|
24
|
-
|
|
25
|
-
const getSrc = computed(() => {
|
|
26
|
-
if (isLoading.value) {
|
|
27
|
-
return props.loadingSrc
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (error.value) {
|
|
31
|
-
return props.errorSrc
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return props.src
|
|
35
|
-
})
|
|
36
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<img :src="getSrc" />
|
|
3
|
+
</template>
|
|
4
|
+
<script lang="ts" setup>
|
|
5
|
+
import { useImage } from '@vueuse/core'
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
src: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
loadingSrc: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: '',
|
|
16
|
+
},
|
|
17
|
+
errorSrc: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: '',
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const { isLoading, error } = useImage({ src: props.src })
|
|
24
|
+
|
|
25
|
+
const getSrc = computed(() => {
|
|
26
|
+
if (isLoading.value) {
|
|
27
|
+
return props.loadingSrc
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (error.value) {
|
|
31
|
+
return props.errorSrc
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return props.src
|
|
35
|
+
})
|
|
36
|
+
</script>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div v-if="isLoading" class="flex min-h-[200px] items-center justify-center">
|
|
3
|
-
<UIcon name="i-svg-spinners:180-ring-with-bg" class="text-primary text-4xl" dynamic />
|
|
4
|
-
</div>
|
|
5
|
-
<slot v-else />
|
|
6
|
-
</template>
|
|
7
|
-
<script lang="ts" setup>
|
|
8
|
-
defineProps({
|
|
9
|
-
isLoading: {
|
|
10
|
-
type: Boolean,
|
|
11
|
-
default: true,
|
|
12
|
-
},
|
|
13
|
-
})
|
|
14
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="isLoading" class="flex min-h-[200px] items-center justify-center">
|
|
3
|
+
<UIcon name="i-svg-spinners:180-ring-with-bg" class="text-primary text-4xl" dynamic />
|
|
4
|
+
</div>
|
|
5
|
+
<slot v-else />
|
|
6
|
+
</template>
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
defineProps({
|
|
9
|
+
isLoading: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: true,
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
</script>
|