@finema/core 1.4.53 → 1.4.55

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 (53) hide show
  1. package/README.md +63 -63
  2. package/dist/module.d.mts +4 -4
  3. package/dist/module.d.ts +4 -4
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +1 -1
  6. package/dist/runtime/components/Alert.vue +49 -49
  7. package/dist/runtime/components/Avatar.vue +27 -27
  8. package/dist/runtime/components/Badge.vue +54 -54
  9. package/dist/runtime/components/Breadcrumb.vue +45 -45
  10. package/dist/runtime/components/Button/Group.vue +37 -37
  11. package/dist/runtime/components/Button/index.vue +77 -77
  12. package/dist/runtime/components/Card.vue +38 -38
  13. package/dist/runtime/components/Core.vue +13 -13
  14. package/dist/runtime/components/Dialog/index.vue +108 -108
  15. package/dist/runtime/components/Dropdown/index.vue +71 -71
  16. package/dist/runtime/components/Form/FieldWrapper.vue +23 -23
  17. package/dist/runtime/components/Form/Fields.vue +153 -153
  18. package/dist/runtime/components/Form/InputCheckbox/index.vue +21 -21
  19. package/dist/runtime/components/Form/InputDateTime/index.vue +52 -51
  20. package/dist/runtime/components/Form/InputRadio/index.vue +27 -27
  21. package/dist/runtime/components/Form/InputSelect/index.vue +36 -36
  22. package/dist/runtime/components/Form/InputStatic/index.vue +16 -16
  23. package/dist/runtime/components/Form/InputText/index.vue +54 -54
  24. package/dist/runtime/components/Form/InputTextarea/index.vue +25 -25
  25. package/dist/runtime/components/Form/InputToggle/index.vue +14 -14
  26. package/dist/runtime/components/Form/InputUploadDropzone/index.vue +157 -157
  27. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +241 -241
  28. package/dist/runtime/components/Form/InputUploadFileClassic/index.vue +101 -36
  29. package/dist/runtime/components/Form/InputUploadFileClassicAuto/index.vue +165 -165
  30. package/dist/runtime/components/Form/index.vue +6 -6
  31. package/dist/runtime/components/Icon.vue +23 -23
  32. package/dist/runtime/components/Image.vue +36 -36
  33. package/dist/runtime/components/Loader.vue +14 -14
  34. package/dist/runtime/components/Modal/index.vue +146 -146
  35. package/dist/runtime/components/SimplePagination.vue +96 -96
  36. package/dist/runtime/components/Slideover/index.vue +110 -110
  37. package/dist/runtime/components/Table/Base.vue +139 -133
  38. package/dist/runtime/components/Table/ColumnDate.vue +16 -16
  39. package/dist/runtime/components/Table/ColumnDateTime.vue +18 -18
  40. package/dist/runtime/components/Table/ColumnImage.vue +15 -13
  41. package/dist/runtime/components/Table/ColumnNumber.vue +14 -14
  42. package/dist/runtime/components/Table/ColumnText.vue +25 -0
  43. package/dist/runtime/components/Table/Simple.vue +64 -57
  44. package/dist/runtime/components/Table/index.vue +60 -59
  45. package/dist/runtime/components/Table/types.d.ts +8 -22
  46. package/dist/runtime/components/Table/types.mjs +0 -1
  47. package/dist/runtime/components/Tabs/index.vue +65 -65
  48. package/dist/runtime/composables/useForm.d.ts +2 -2
  49. package/dist/runtime/composables/useTable.d.ts +2 -2
  50. package/dist/runtime/composables/useTable.mjs +2 -4
  51. package/dist/runtime/types/utils.d.ts +29 -29
  52. package/dist/runtime/ui.css +32 -32
  53. package/package.json +89 -83
@@ -1,54 +1,54 @@
1
- <template>
2
- <FieldWrapper v-bind="wrapperProps">
3
- <UInput
4
- v-if="type === 'password'"
5
- v-model="value"
6
- :disabled="wrapperProps.isDisabled"
7
- :leading-icon="leadingIcon"
8
- :trailing-icon="trailingIcon"
9
- :name="name"
10
- :placeholder="wrapperProps.placeholder"
11
- :type="isShowPassword ? 'text' : 'password'"
12
- :autofocus="!!autoFocus"
13
- :icon="icon"
14
- :readonly="isReadonly"
15
- :ui="_deepMerge({}, ui, { icon: { trailing: { pointer: '' } } })"
16
- >
17
- <template #trailing>
18
- <UButton
19
- color="gray"
20
- variant="link"
21
- :icon="isShowPassword ? 'i-heroicons-eye' : 'i-heroicons-eye-slash'"
22
- :padded="false"
23
- @click="isShowPassword = !isShowPassword"
24
- />
25
- </template>
26
- </UInput>
27
- <UInput
28
- v-else
29
- v-model="value"
30
- :disabled="wrapperProps.isDisabled"
31
- :leading-icon="leadingIcon"
32
- :trailing-icon="trailingIcon"
33
- :name="name"
34
- :placeholder="wrapperProps.placeholder"
35
- :type="type || 'text'"
36
- :autofocus="!!autoFocus"
37
- :icon="icon"
38
- :readonly="isReadonly"
39
- :ui="ui"
40
- />
41
- </FieldWrapper>
42
- </template>
43
- <script lang="ts" setup>
44
- import { _deepMerge, ref } from '#imports'
45
- import { type ITextFieldProps } from '#core/components/Form/InputText/types'
46
- import { useFieldHOC } from '#core/composables/useForm'
47
- import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
48
-
49
- const props = withDefaults(defineProps<ITextFieldProps>(), {})
50
-
51
- const { value, wrapperProps } = useFieldHOC<string>(props)
52
-
53
- const isShowPassword = ref(false)
54
- </script>
1
+ <template>
2
+ <FieldWrapper v-bind="wrapperProps">
3
+ <UInput
4
+ v-if="type === 'password'"
5
+ v-model="value"
6
+ :disabled="wrapperProps.isDisabled"
7
+ :leading-icon="leadingIcon"
8
+ :trailing-icon="trailingIcon"
9
+ :name="name"
10
+ :placeholder="wrapperProps.placeholder"
11
+ :type="isShowPassword ? 'text' : 'password'"
12
+ :autofocus="!!autoFocus"
13
+ :icon="icon"
14
+ :readonly="isReadonly"
15
+ :ui="_deepMerge({}, ui, { icon: { trailing: { pointer: '' } } })"
16
+ >
17
+ <template #trailing>
18
+ <UButton
19
+ color="gray"
20
+ variant="link"
21
+ :icon="isShowPassword ? 'i-heroicons-eye' : 'i-heroicons-eye-slash'"
22
+ :padded="false"
23
+ @click="isShowPassword = !isShowPassword"
24
+ />
25
+ </template>
26
+ </UInput>
27
+ <UInput
28
+ v-else
29
+ v-model="value"
30
+ :disabled="wrapperProps.isDisabled"
31
+ :leading-icon="leadingIcon"
32
+ :trailing-icon="trailingIcon"
33
+ :name="name"
34
+ :placeholder="wrapperProps.placeholder"
35
+ :type="type || 'text'"
36
+ :autofocus="!!autoFocus"
37
+ :icon="icon"
38
+ :readonly="isReadonly"
39
+ :ui="ui"
40
+ />
41
+ </FieldWrapper>
42
+ </template>
43
+ <script lang="ts" setup>
44
+ import { _deepMerge, ref } from '#imports'
45
+ import { type ITextFieldProps } from '#core/components/Form/InputText/types'
46
+ import { useFieldHOC } from '#core/composables/useForm'
47
+ import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
48
+
49
+ const props = withDefaults(defineProps<ITextFieldProps>(), {})
50
+
51
+ const { value, wrapperProps } = useFieldHOC<string>(props)
52
+
53
+ const isShowPassword = ref(false)
54
+ </script>
@@ -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,157 +1,157 @@
1
- <template>
2
- <FieldWrapper v-bind="wrapperProps">
3
- <div
4
- ref="dropzoneRef"
5
- :class="[
6
- ui.base,
7
- {
8
- [ui.disabled]: isDisabled,
9
- [ui.background.default]: !isOverDropZone && !isDisabled,
10
- [ui.background.dragover]: isOverDropZone && !isDisabled,
11
- },
12
- ]"
13
- >
14
- <Icon
15
- v-if="selectedFile"
16
- :name="ui.default.closeIcon"
17
- :class="[ui.button.delete]"
18
- @click="handleDeleteFile"
19
- />
20
- <input
21
- ref="fileInputRef"
22
- type="file"
23
- class="hidden"
24
- :accept="acceptFile"
25
- :disabled="isDisabled"
26
- @change="handleChange"
27
- />
28
- <div :class="[ui.wrapper]">
29
- <div v-if="selectedFile" :class="[ui.preview.wrapper]">
30
- <div v-if="isImage(selectedFile)" :class="[ui.preview.image.wrapper]">
31
- <img :src="generateURL(selectedFile)" :class="[ui.preview.image.img]" alt="file" />
32
- </div>
33
- <Icon v-else :name="ui.default.filePreviewIcon" :class="[ui.preview.icon]" />
34
- <div :class="[ui.preview.filename]">
35
- <p class="truncate">{{ selectedFile.name }}</p>
36
- </div>
37
- <Badge size="xs" variant="outline" class="mt-1">
38
- {{ isSelectedFileUseMb ? `${selectedFileSizeMb} Mb` : `${selectedFileSizeKb} Kb` }}
39
- </Badge>
40
- </div>
41
- <div v-if="!selectedFile" :class="[ui.placeholderWrapper]">
42
- <Icon :name="ui.default.uploadIcon" :class="[ui.labelIcon]" />
43
- <div :class="[ui.labelWrapper]">
44
- <p class="text-primary cursor-pointer" @click="handleOpenFile">
45
- {{ selectFileLabel ?? 'คลิกเพื่อเลือกไฟล์' }}
46
- </p>
47
- <p>{{ selectFileSubLabel ?? 'หรือ ลากและวางที่นี่' }}</p>
48
- </div>
49
- <p v-if="placeholder" :class="[ui.placeholder]">{{ placeholder }}</p>
50
- </div>
51
- </div>
52
- </div>
53
- </FieldWrapper>
54
- </template>
55
-
56
- <script lang="ts" setup>
57
- import { useDropZone } from '@vueuse/core'
58
- import { type IUploadDropzoneProps } from './types'
59
- import { isImage, generateURL, checkMaxSize, checkFileType } from '#core/helpers/componentHelper'
60
- import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
61
- import { useFieldHOC } from '#core/composables/useForm'
62
- import { computed, ref, toRef, useUI, useUiConfig } from '#imports'
63
- import { uploadFileDropzone } from '#core/ui.config'
64
- import i18next from 'i18next'
65
-
66
- const config = useUiConfig<typeof uploadFileDropzone>(uploadFileDropzone, 'uploadFileDropzone')
67
-
68
- const props = withDefaults(defineProps<IUploadDropzoneProps>(), {})
69
- const emit = defineEmits(['change', 'delete'])
70
-
71
- const { wrapperProps, handleChange: onChange, setErrors, value } = useFieldHOC<File>(props)
72
-
73
- const { ui } = useUI('uploadFileDropzone', toRef(props, 'ui'), config)
74
-
75
- const fileInputRef = ref<HTMLInputElement>()
76
- const dropzoneRef = ref<HTMLDivElement>()
77
-
78
- const acceptFile = computed(() =>
79
- typeof props.accept === 'string' ? props.accept : props.accept?.join(',')
80
- )
81
-
82
- const acceptFileSizeKb = computed(() => props.maxSize)
83
- const acceptFileSizeMb = computed(() => ((acceptFileSizeKb.value ?? 0) / 1024).toFixed(2))
84
- const isAcceptFileUseMb = computed(() => acceptFileSizeKb.value && acceptFileSizeKb.value > 1024)
85
-
86
- const selectedFileSizeKb = computed(() => ((value?.value.size || 0) / 1000).toFixed(2))
87
- const selectedFileSizeMb = computed(() => ((value?.value.size || 0) / 1000 / 1000).toFixed(2))
88
- const isSelectedFileUseMb = computed(() => (value?.value.size || 0) / 1000 > 1024)
89
- const selectedFile = computed(() => value?.value)
90
-
91
- const onDrop = (files: File[] | null) => {
92
- if (props.isDisabled || files?.length === 0 || !files) return
93
-
94
- const file = files[0]
95
- const result = handleCheckFileCondition(file)
96
-
97
- if (result) {
98
- onChange(file)
99
- emit('change', file)
100
- }
101
- }
102
-
103
- const { isOverDropZone } = useDropZone(dropzoneRef as unknown as HTMLElement, {
104
- onDrop,
105
- })
106
-
107
- const handleChange = (e: Event) => {
108
- if (props.isDisabled) return
109
-
110
- const file = (e.target as HTMLInputElement).files?.[0]
111
- const result = handleCheckFileCondition(file)
112
-
113
- if (result && file) {
114
- onChange(file)
115
- value.value = file
116
- emit('change', file)
117
- }
118
- }
119
-
120
- const handleOpenFile = () => {
121
- fileInputRef.value?.click()
122
- }
123
-
124
- const handleDeleteFile = () => {
125
- fileInputRef.value?.value && (fileInputRef.value.value = '')
126
- onChange(undefined)
127
- emit('delete')
128
- }
129
-
130
- const handleCheckFileCondition = (file: File | undefined): boolean => {
131
- if (!file) return false
132
-
133
- const fileType = checkFileType(file, acceptFile.value ?? '')
134
-
135
- if (!fileType) {
136
- setErrors(i18next.t('custom:invalid_file_type'))
137
-
138
- return false
139
- }
140
-
141
- const maxSize = checkMaxSize(file, acceptFileSizeKb.value ?? 0)
142
-
143
- if (!maxSize) {
144
- if (isAcceptFileUseMb.value) {
145
- setErrors(i18next.t('custom:invalid_file_size_mb', { size: acceptFileSizeMb.value }))
146
- } else {
147
- setErrors(i18next.t('custom:invalid_file_size_kb', { size: acceptFileSizeKb.value }))
148
- }
149
-
150
- return false
151
- }
152
-
153
- setErrors('')
154
-
155
- return true
156
- }
157
- </script>
1
+ <template>
2
+ <FieldWrapper v-bind="wrapperProps">
3
+ <div
4
+ ref="dropzoneRef"
5
+ :class="[
6
+ ui.base,
7
+ {
8
+ [ui.disabled]: isDisabled,
9
+ [ui.background.default]: !isOverDropZone && !isDisabled,
10
+ [ui.background.dragover]: isOverDropZone && !isDisabled,
11
+ },
12
+ ]"
13
+ >
14
+ <Icon
15
+ v-if="selectedFile"
16
+ :name="ui.default.closeIcon"
17
+ :class="[ui.button.delete]"
18
+ @click="handleDeleteFile"
19
+ />
20
+ <input
21
+ ref="fileInputRef"
22
+ type="file"
23
+ class="hidden"
24
+ :accept="acceptFile"
25
+ :disabled="isDisabled"
26
+ @change="handleChange"
27
+ />
28
+ <div :class="[ui.wrapper]">
29
+ <div v-if="selectedFile" :class="[ui.preview.wrapper]">
30
+ <div v-if="isImage(selectedFile)" :class="[ui.preview.image.wrapper]">
31
+ <img :src="generateURL(selectedFile)" :class="[ui.preview.image.img]" alt="file" />
32
+ </div>
33
+ <Icon v-else :name="ui.default.filePreviewIcon" :class="[ui.preview.icon]" />
34
+ <div :class="[ui.preview.filename]">
35
+ <p class="truncate">{{ selectedFile.name }}</p>
36
+ </div>
37
+ <Badge size="xs" variant="outline" class="mt-1">
38
+ {{ isSelectedFileUseMb ? `${selectedFileSizeMb} Mb` : `${selectedFileSizeKb} Kb` }}
39
+ </Badge>
40
+ </div>
41
+ <div v-if="!selectedFile" :class="[ui.placeholderWrapper]">
42
+ <Icon :name="ui.default.uploadIcon" :class="[ui.labelIcon]" />
43
+ <div :class="[ui.labelWrapper]">
44
+ <p class="text-primary cursor-pointer" @click="handleOpenFile">
45
+ {{ selectFileLabel ?? 'คลิกเพื่อเลือกไฟล์' }}
46
+ </p>
47
+ <p>{{ selectFileSubLabel ?? 'หรือ ลากและวางที่นี่' }}</p>
48
+ </div>
49
+ <p v-if="placeholder" :class="[ui.placeholder]">{{ placeholder }}</p>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ </FieldWrapper>
54
+ </template>
55
+
56
+ <script lang="ts" setup>
57
+ import { useDropZone } from '@vueuse/core'
58
+ import { type IUploadDropzoneProps } from './types'
59
+ import { isImage, generateURL, checkMaxSize, checkFileType } from '#core/helpers/componentHelper'
60
+ import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
61
+ import { useFieldHOC } from '#core/composables/useForm'
62
+ import { computed, ref, toRef, useUI, useUiConfig } from '#imports'
63
+ import { uploadFileDropzone } from '#core/ui.config'
64
+ import i18next from 'i18next'
65
+
66
+ const config = useUiConfig<typeof uploadFileDropzone>(uploadFileDropzone, 'uploadFileDropzone')
67
+
68
+ const props = withDefaults(defineProps<IUploadDropzoneProps>(), {})
69
+ const emit = defineEmits(['change', 'delete'])
70
+
71
+ const { wrapperProps, handleChange: onChange, setErrors, value } = useFieldHOC<File>(props)
72
+
73
+ const { ui } = useUI('uploadFileDropzone', toRef(props, 'ui'), config)
74
+
75
+ const fileInputRef = ref<HTMLInputElement>()
76
+ const dropzoneRef = ref<HTMLDivElement>()
77
+
78
+ const acceptFile = computed(() =>
79
+ typeof props.accept === 'string' ? props.accept : props.accept?.join(',')
80
+ )
81
+
82
+ const acceptFileSizeKb = computed(() => props.maxSize)
83
+ const acceptFileSizeMb = computed(() => ((acceptFileSizeKb.value ?? 0) / 1024).toFixed(2))
84
+ const isAcceptFileUseMb = computed(() => acceptFileSizeKb.value && acceptFileSizeKb.value > 1024)
85
+
86
+ const selectedFileSizeKb = computed(() => ((value?.value.size || 0) / 1000).toFixed(2))
87
+ const selectedFileSizeMb = computed(() => ((value?.value.size || 0) / 1000 / 1000).toFixed(2))
88
+ const isSelectedFileUseMb = computed(() => (value?.value.size || 0) / 1000 > 1024)
89
+ const selectedFile = computed(() => value?.value)
90
+
91
+ const onDrop = (files: File[] | null) => {
92
+ if (props.isDisabled || files?.length === 0 || !files) return
93
+
94
+ const file = files[0]
95
+ const result = handleCheckFileCondition(file)
96
+
97
+ if (result) {
98
+ onChange(file)
99
+ emit('change', file)
100
+ }
101
+ }
102
+
103
+ const { isOverDropZone } = useDropZone(dropzoneRef as unknown as HTMLElement, {
104
+ onDrop,
105
+ })
106
+
107
+ const handleChange = (e: Event) => {
108
+ if (props.isDisabled) return
109
+
110
+ const file = (e.target as HTMLInputElement).files?.[0]
111
+ const result = handleCheckFileCondition(file)
112
+
113
+ if (result && file) {
114
+ onChange(file)
115
+ value.value = file
116
+ emit('change', file)
117
+ }
118
+ }
119
+
120
+ const handleOpenFile = () => {
121
+ fileInputRef.value?.click()
122
+ }
123
+
124
+ const handleDeleteFile = () => {
125
+ fileInputRef.value?.value && (fileInputRef.value.value = '')
126
+ onChange(undefined)
127
+ emit('delete')
128
+ }
129
+
130
+ const handleCheckFileCondition = (file: File | undefined): boolean => {
131
+ if (!file) return false
132
+
133
+ const fileType = checkFileType(file, acceptFile.value ?? '')
134
+
135
+ if (!fileType) {
136
+ setErrors(i18next.t('custom:invalid_file_type'))
137
+
138
+ return false
139
+ }
140
+
141
+ const maxSize = checkMaxSize(file, acceptFileSizeKb.value ?? 0)
142
+
143
+ if (!maxSize) {
144
+ if (isAcceptFileUseMb.value) {
145
+ setErrors(i18next.t('custom:invalid_file_size_mb', { size: acceptFileSizeMb.value }))
146
+ } else {
147
+ setErrors(i18next.t('custom:invalid_file_size_kb', { size: acceptFileSizeKb.value }))
148
+ }
149
+
150
+ return false
151
+ }
152
+
153
+ setErrors('')
154
+
155
+ return true
156
+ }
157
+ </script>