@finema/core 1.4.110 → 1.4.112

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 (58) hide show
  1. package/README.md +60 -60
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +6 -1
  4. package/dist/runtime/components/Alert.vue +48 -48
  5. package/dist/runtime/components/Avatar.vue +27 -27
  6. package/dist/runtime/components/Badge.vue +11 -11
  7. package/dist/runtime/components/Breadcrumb.vue +44 -44
  8. package/dist/runtime/components/Button/Group.vue +37 -37
  9. package/dist/runtime/components/Button/index.vue +75 -75
  10. package/dist/runtime/components/Card.vue +38 -38
  11. package/dist/runtime/components/Core.vue +13 -13
  12. package/dist/runtime/components/Dialog/index.vue +108 -108
  13. package/dist/runtime/components/Dropdown/index.vue +70 -70
  14. package/dist/runtime/components/FlexDeck/Base.vue +90 -90
  15. package/dist/runtime/components/FlexDeck/index.vue +66 -66
  16. package/dist/runtime/components/Form/FieldWrapper.vue +23 -23
  17. package/dist/runtime/components/Form/Fields.vue +222 -222
  18. package/dist/runtime/components/Form/InputCheckbox/index.vue +21 -21
  19. package/dist/runtime/components/Form/InputDateTime/index.vue +60 -60
  20. package/dist/runtime/components/Form/InputDateTimeRange/index.vue +83 -83
  21. package/dist/runtime/components/Form/InputNumber/index.vue +27 -27
  22. package/dist/runtime/components/Form/InputRadio/index.vue +27 -27
  23. package/dist/runtime/components/Form/InputSelect/index.vue +36 -36
  24. package/dist/runtime/components/Form/InputStatic/index.vue +16 -16
  25. package/dist/runtime/components/Form/InputTags/index.vue +134 -134
  26. package/dist/runtime/components/Form/InputText/index.vue +67 -67
  27. package/dist/runtime/components/Form/InputTextarea/index.vue +25 -25
  28. package/dist/runtime/components/Form/InputToggle/index.vue +14 -14
  29. package/dist/runtime/components/Form/InputUploadDropzone/index.vue +206 -206
  30. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +333 -333
  31. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/Item.vue +260 -260
  32. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue +140 -140
  33. package/dist/runtime/components/Form/InputUploadDropzoneImageAutoMultiple/index.vue +148 -148
  34. package/dist/runtime/components/Form/InputUploadDropzoneImageAutoMultiple/item.vue +179 -179
  35. package/dist/runtime/components/Form/InputUploadFileClassic/index.vue +95 -95
  36. package/dist/runtime/components/Form/InputUploadFileClassicAuto/index.vue +143 -143
  37. package/dist/runtime/components/Form/InputUploadImageAuto/index.vue +222 -222
  38. package/dist/runtime/components/Form/InputWYSIWYG/index.vue +55 -40
  39. package/dist/runtime/components/Form/index.vue +6 -6
  40. package/dist/runtime/components/Icon.vue +23 -23
  41. package/dist/runtime/components/Image.vue +36 -36
  42. package/dist/runtime/components/Loader.vue +27 -27
  43. package/dist/runtime/components/Modal/index.vue +146 -146
  44. package/dist/runtime/components/QRCode.vue +22 -22
  45. package/dist/runtime/components/SimplePagination.vue +96 -96
  46. package/dist/runtime/components/Slideover/index.vue +110 -110
  47. package/dist/runtime/components/Table/Base.vue +139 -139
  48. package/dist/runtime/components/Table/ColumnDate.vue +16 -16
  49. package/dist/runtime/components/Table/ColumnDateTime.vue +18 -18
  50. package/dist/runtime/components/Table/ColumnImage.vue +15 -15
  51. package/dist/runtime/components/Table/ColumnNumber.vue +14 -14
  52. package/dist/runtime/components/Table/ColumnText.vue +25 -25
  53. package/dist/runtime/components/Table/Simple.vue +69 -69
  54. package/dist/runtime/components/Table/index.vue +65 -65
  55. package/dist/runtime/components/Tabs/index.vue +64 -64
  56. package/dist/runtime/quill.plugin.d.ts +2 -0
  57. package/dist/runtime/quill.plugin.mjs +5 -0
  58. package/package.json +92 -92
@@ -1,143 +1,143 @@
1
- <template>
2
- <FieldWrapper v-bind="wrapperProps">
3
- <div :class="[ui.base]">
4
- <input
5
- ref="fileInput"
6
- type="file"
7
- class="hidden"
8
- :name="name"
9
- :accept="fileAllocate.acceptFile.value"
10
- :disabled="isDisabled"
11
- @change="handleChange"
12
- />
13
- <div :class="[ui.wrapper]">
14
- <div :class="[ui.selectFileBox]">
15
- <Button size="2xs" @click="handleOpenFile">{{ selectFileLabel }}</Button>
16
- <p :class="ui.placeholder">
17
- {{ selectedFile?.name ?? placeholder ?? 'ยังไม่ได้เลือกไฟล์' }}
18
- </p>
19
- <Badge v-if="selectedFile" size="xs" variant="outline">
20
- {{
21
- fileAllocate.isSelectedFileUseMb.value
22
- ? `${fileAllocate.selectedFileSizeMb.value} MB`
23
- : `${fileAllocate.selectedFileSizeKb.value} KB`
24
- }}
25
- </Badge>
26
- </div>
27
- <div v-if="selectedFile">
28
- <Icon
29
- v-if="upload.status.value.isSuccess"
30
- name="heroicons:check-circle-20-solid"
31
- class="text-success"
32
- />
33
- <Icon
34
- v-if="upload.status.value.isError"
35
- name="heroicons:x-circle-20-solid"
36
- class="text-danger"
37
- />
38
- <Icon
39
- v-if="upload.status.value.isLoading"
40
- name="i-svg-spinners:180-ring-with-bg"
41
- class="text-primary"
42
- />
43
- </div>
44
- </div>
45
- </div>
46
- <img v-if="imagePreviewURL && value" :src="imagePreviewURL" alt="" :class="ui.previewURL" />
47
- </FieldWrapper>
48
- </template>
49
-
50
- <script lang="tsx" setup>
51
- import { _get, ref, StringHelper, toRef, useUI, useUiConfig, useWatchTrue } from '#imports'
52
- import { type IUploadFileProps } from './types'
53
- import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
54
- import { useFieldHOC } from '#core/composables/useForm'
55
- import { type IUploadRequest, useUploadLoader } from '#core/composables/useUpload'
56
- import { uploadFileInputClassicAuto } from '#core/ui.config'
57
- import i18next from 'i18next'
58
- import { checkMaxSize, useFileAllocate, useFileProgress } from '#core/helpers/componentHelper'
59
-
60
- const config = useUiConfig<typeof uploadFileInputClassicAuto>(
61
- uploadFileInputClassicAuto,
62
- 'uploadFileInputClassicAuto'
63
- )
64
-
65
- const emits = defineEmits(['success'])
66
- const props = withDefaults(defineProps<IUploadFileProps>(), {
67
- bodyKey: 'file',
68
- responseKey: 'url',
69
- selectFileLabel: 'เลือกไฟล์',
70
- })
71
-
72
- const { wrapperProps, setErrors, value } = useFieldHOC<string>(props)
73
-
74
- const request: IUploadRequest = {
75
- pathURL: props.uploadPathURL,
76
- requestOptions: props.requestOptions,
77
- }
78
-
79
- const upload = useUploadLoader(request)
80
-
81
- const fileInput = ref<HTMLInputElement>()
82
- const selectedFile = ref<File | undefined>()
83
-
84
- const fileAllocate = useFileAllocate(selectedFile, props)
85
- const { onUploadProgress, onDownloadProgress, percent } = useFileProgress()
86
- const { ui } = useUI('uploadFileInputClassicAuto', toRef(props, 'ui'), config)
87
-
88
- const handleOpenFile = () => {
89
- fileInput.value?.click()
90
- }
91
-
92
- const handleChange = (e: Event) => {
93
- const file = (e.target as HTMLInputElement).files?.[0]
94
- const result = handleCheckFileCondition(file)
95
-
96
- if (result && file) {
97
- selectedFile.value = file
98
- const formData = new FormData()
99
-
100
- formData.append(props.bodyKey, file)
101
- upload.run(formData, { data: { onUploadProgress, onDownloadProgress } })
102
- }
103
- }
104
-
105
- const handleCheckFileCondition = (file: File | undefined): boolean => {
106
- if (!file) return false
107
-
108
- const maxSize = checkMaxSize(file, fileAllocate.acceptFileSizeKb.value)
109
-
110
- if (!maxSize) {
111
- if (fileAllocate.isAcceptFileUseMb.value) {
112
- setErrors(
113
- i18next.t('custom:invalid_file_size_mb', { size: fileAllocate.acceptFileSizeMb.value })
114
- )
115
- } else {
116
- setErrors(
117
- i18next.t('custom:invalid_file_size_kb', { size: fileAllocate.acceptFileSizeKb.value })
118
- )
119
- }
120
-
121
- return false
122
- }
123
-
124
- setErrors('')
125
-
126
- return true
127
- }
128
-
129
- useWatchTrue(
130
- () => upload.status.value.isSuccess,
131
- () => {
132
- value.value = _get(upload.data.value, props.responseKey)
133
- emits('success', upload.data.value)
134
- }
135
- )
136
-
137
- useWatchTrue(
138
- () => upload.status.value.isError,
139
- () => {
140
- setErrors(StringHelper.getError(upload.status.value.errorData))
141
- }
142
- )
143
- </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
+ :name="name"
9
+ :accept="fileAllocate.acceptFile.value"
10
+ :disabled="isDisabled"
11
+ @change="handleChange"
12
+ />
13
+ <div :class="[ui.wrapper]">
14
+ <div :class="[ui.selectFileBox]">
15
+ <Button size="2xs" @click="handleOpenFile">{{ selectFileLabel }}</Button>
16
+ <p :class="ui.placeholder">
17
+ {{ selectedFile?.name ?? placeholder ?? 'ยังไม่ได้เลือกไฟล์' }}
18
+ </p>
19
+ <Badge v-if="selectedFile" size="xs" variant="outline">
20
+ {{
21
+ fileAllocate.isSelectedFileUseMb.value
22
+ ? `${fileAllocate.selectedFileSizeMb.value} MB`
23
+ : `${fileAllocate.selectedFileSizeKb.value} KB`
24
+ }}
25
+ </Badge>
26
+ </div>
27
+ <div v-if="selectedFile">
28
+ <Icon
29
+ v-if="upload.status.value.isSuccess"
30
+ name="heroicons:check-circle-20-solid"
31
+ class="text-success"
32
+ />
33
+ <Icon
34
+ v-if="upload.status.value.isError"
35
+ name="heroicons:x-circle-20-solid"
36
+ class="text-danger"
37
+ />
38
+ <Icon
39
+ v-if="upload.status.value.isLoading"
40
+ name="i-svg-spinners:180-ring-with-bg"
41
+ class="text-primary"
42
+ />
43
+ </div>
44
+ </div>
45
+ </div>
46
+ <img v-if="imagePreviewURL && value" :src="imagePreviewURL" alt="" :class="ui.previewURL" />
47
+ </FieldWrapper>
48
+ </template>
49
+
50
+ <script lang="tsx" setup>
51
+ import { _get, ref, StringHelper, toRef, useUI, useUiConfig, useWatchTrue } from '#imports'
52
+ import { type IUploadFileProps } from './types'
53
+ import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
54
+ import { useFieldHOC } from '#core/composables/useForm'
55
+ import { type IUploadRequest, useUploadLoader } from '#core/composables/useUpload'
56
+ import { uploadFileInputClassicAuto } from '#core/ui.config'
57
+ import i18next from 'i18next'
58
+ import { checkMaxSize, useFileAllocate, useFileProgress } from '#core/helpers/componentHelper'
59
+
60
+ const config = useUiConfig<typeof uploadFileInputClassicAuto>(
61
+ uploadFileInputClassicAuto,
62
+ 'uploadFileInputClassicAuto'
63
+ )
64
+
65
+ const emits = defineEmits(['success'])
66
+ const props = withDefaults(defineProps<IUploadFileProps>(), {
67
+ bodyKey: 'file',
68
+ responseKey: 'url',
69
+ selectFileLabel: 'เลือกไฟล์',
70
+ })
71
+
72
+ const { wrapperProps, setErrors, value } = useFieldHOC<string>(props)
73
+
74
+ const request: IUploadRequest = {
75
+ pathURL: props.uploadPathURL,
76
+ requestOptions: props.requestOptions,
77
+ }
78
+
79
+ const upload = useUploadLoader(request)
80
+
81
+ const fileInput = ref<HTMLInputElement>()
82
+ const selectedFile = ref<File | undefined>()
83
+
84
+ const fileAllocate = useFileAllocate(selectedFile, props)
85
+ const { onUploadProgress, onDownloadProgress, percent } = useFileProgress()
86
+ const { ui } = useUI('uploadFileInputClassicAuto', toRef(props, 'ui'), config)
87
+
88
+ const handleOpenFile = () => {
89
+ fileInput.value?.click()
90
+ }
91
+
92
+ const handleChange = (e: Event) => {
93
+ const file = (e.target as HTMLInputElement).files?.[0]
94
+ const result = handleCheckFileCondition(file)
95
+
96
+ if (result && file) {
97
+ selectedFile.value = file
98
+ const formData = new FormData()
99
+
100
+ formData.append(props.bodyKey, file)
101
+ upload.run(formData, { data: { onUploadProgress, onDownloadProgress } })
102
+ }
103
+ }
104
+
105
+ const handleCheckFileCondition = (file: File | undefined): boolean => {
106
+ if (!file) return false
107
+
108
+ const maxSize = checkMaxSize(file, fileAllocate.acceptFileSizeKb.value)
109
+
110
+ if (!maxSize) {
111
+ if (fileAllocate.isAcceptFileUseMb.value) {
112
+ setErrors(
113
+ i18next.t('custom:invalid_file_size_mb', { size: fileAllocate.acceptFileSizeMb.value })
114
+ )
115
+ } else {
116
+ setErrors(
117
+ i18next.t('custom:invalid_file_size_kb', { size: fileAllocate.acceptFileSizeKb.value })
118
+ )
119
+ }
120
+
121
+ return false
122
+ }
123
+
124
+ setErrors('')
125
+
126
+ return true
127
+ }
128
+
129
+ useWatchTrue(
130
+ () => upload.status.value.isSuccess,
131
+ () => {
132
+ value.value = _get(upload.data.value, props.responseKey)
133
+ emits('success', upload.data.value)
134
+ }
135
+ )
136
+
137
+ useWatchTrue(
138
+ () => upload.status.value.isError,
139
+ () => {
140
+ setErrors(StringHelper.getError(upload.status.value.errorData))
141
+ }
142
+ )
143
+ </script>