@finema/core 2.22.0 → 2.23.1

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 (45) hide show
  1. package/README.md +79 -79
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +1 -1
  4. package/dist/runtime/components/Form/FieldWrapper.vue +13 -13
  5. package/dist/runtime/components/Form/Fields.vue +18 -14
  6. package/dist/runtime/components/Form/InputCheckbox/index.vue +18 -18
  7. package/dist/runtime/components/Form/InputNumber/index.vue +20 -20
  8. package/dist/runtime/components/Form/InputSelectMultiple/index.vue +43 -43
  9. package/dist/runtime/components/Form/InputText/index.vue +74 -74
  10. package/dist/runtime/components/Form/InputTextarea/index.vue +18 -18
  11. package/dist/runtime/components/Form/InputToggle/index.vue +17 -17
  12. package/dist/runtime/components/Form/InputUploadDropzone/index.vue +105 -0
  13. package/dist/runtime/components/Form/InputUploadDropzone/index.vue.d.ts +12 -0
  14. package/dist/runtime/components/Form/InputUploadDropzone/types.d.ts +11 -0
  15. package/dist/runtime/components/Form/InputUploadDropzone/types.js +0 -0
  16. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +6 -13
  17. package/dist/runtime/components/Form/{InputUploadDropzoneAuto → fileState}/EmptyState.vue +22 -22
  18. package/dist/runtime/components/Form/{InputUploadDropzoneAuto → fileState}/FailedState.vue +34 -34
  19. package/dist/runtime/components/Form/{InputUploadDropzoneAuto → fileState}/LoadingState.vue +25 -25
  20. package/dist/runtime/components/Form/{InputUploadDropzoneAuto → fileState}/PreviewModal.vue +23 -23
  21. package/dist/runtime/components/Form/{InputUploadDropzoneAuto → fileState}/SuccessState.vue +13 -6
  22. package/dist/runtime/components/Form/fileState/useFileState.d.ts +23 -0
  23. package/dist/runtime/components/Form/fileState/useFileState.js +154 -0
  24. package/dist/runtime/components/Form/{InputUploadDropzoneAuto → fileState}/useUploadState.d.ts +1 -1
  25. package/dist/runtime/components/Form/{InputUploadDropzoneAuto → fileState}/useUploadState.js +12 -13
  26. package/dist/runtime/components/Form/index.vue +5 -5
  27. package/dist/runtime/components/Form/types.d.ts +2 -1
  28. package/dist/runtime/components/Image.vue +28 -28
  29. package/dist/runtime/components/Log/index.vue +17 -17
  30. package/dist/runtime/components/Table/ColumnDate.vue +1 -1
  31. package/dist/runtime/components/Table/ColumnDateTime.vue +1 -1
  32. package/dist/runtime/components/Table/ColumnImage.vue +4 -4
  33. package/dist/runtime/components/Table/ColumnText.vue +1 -1
  34. package/dist/runtime/components/Table/index.vue +89 -89
  35. package/dist/runtime/composables/useFileIcon.d.ts +1 -0
  36. package/dist/runtime/composables/useFileIcon.js +9 -0
  37. package/dist/runtime/server/tsconfig.json +3 -3
  38. package/dist/runtime/theme/uploadFileDropzone.d.ts +4 -3
  39. package/dist/runtime/theme/uploadFileDropzone.js +4 -3
  40. package/package.json +2 -2
  41. /package/dist/runtime/components/Form/{InputUploadDropzoneAuto → fileState}/EmptyState.vue.d.ts +0 -0
  42. /package/dist/runtime/components/Form/{InputUploadDropzoneAuto → fileState}/FailedState.vue.d.ts +0 -0
  43. /package/dist/runtime/components/Form/{InputUploadDropzoneAuto → fileState}/LoadingState.vue.d.ts +0 -0
  44. /package/dist/runtime/components/Form/{InputUploadDropzoneAuto → fileState}/PreviewModal.vue.d.ts +0 -0
  45. /package/dist/runtime/components/Form/{InputUploadDropzoneAuto → fileState}/SuccessState.vue.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import type { TemplateRef } from 'vue';
2
- import type { IUploadDropzoneAutoProps } from './types.js';
2
+ import type { IUploadDropzoneAutoProps } from '../InputUploadDropzoneAuto/types.js';
3
3
  import type { IFileValue } from '#core/components/Form/types';
4
4
  export declare enum UploadState {
5
5
  EMPTY = "empty",
@@ -1,12 +1,11 @@
1
1
  import { useDropZone, useFileDialog } from "@vueuse/core";
2
+ import { useWatchTrue } from "./../../../../../dist/runtime/composables/useWatch";
2
3
  import PreviewModal from "./PreviewModal.vue";
3
- import { computed, ref, useOverlay, watch } from "#imports";
4
+ import { computed, ref, useOverlay } from "#imports";
4
5
  import { useUploadLoader } from "#core/composables/useUpload";
5
6
  import { useFileAllocate, useFileProgress } from "#core/helpers/componentHelper";
6
7
  import { StringHelper } from "#core/utils/StringHelper";
7
8
  import { _get } from "#core/utils/lodash";
8
- const overlay = useOverlay();
9
- const previewModal = overlay.create(PreviewModal);
10
9
  export var UploadState = /* @__PURE__ */ ((UploadState2) => {
11
10
  UploadState2["EMPTY"] = "empty";
12
11
  UploadState2["UPLOADING"] = "uploading";
@@ -15,6 +14,8 @@ export var UploadState = /* @__PURE__ */ ((UploadState2) => {
15
14
  return UploadState2;
16
15
  })(UploadState || {});
17
16
  export const useUploadState = (props, emits, onChange, setErrors, value, acceptedFileTypes, wrapperProps, dropzoneRef) => {
17
+ const overlay = useOverlay();
18
+ const previewModal = overlay.create(PreviewModal);
18
19
  const selectedFile = ref();
19
20
  const fileAllocate = useFileAllocate(selectedFile, props);
20
21
  const {
@@ -73,7 +74,7 @@ export const useUploadState = (props, emits, onChange, setErrors, value, accepte
73
74
  selectedFile.value = file;
74
75
  emits("change", file);
75
76
  const formData = new FormData();
76
- formData.append(props.bodyKey || "file", file);
77
+ formData.append(props.bodyKey, file);
77
78
  upload.run({
78
79
  data: formData
79
80
  });
@@ -132,7 +133,7 @@ export const useUploadState = (props, emits, onChange, setErrors, value, accepte
132
133
  const handleRetryUpload = () => {
133
134
  if (selectedFile.value) {
134
135
  const formData = new FormData();
135
- formData.append(props.bodyKey || "file", selectedFile.value);
136
+ formData.append(props.bodyKey, selectedFile.value);
136
137
  upload.run(formData);
137
138
  }
138
139
  };
@@ -141,10 +142,10 @@ export const useUploadState = (props, emits, onChange, setErrors, value, accepte
141
142
  value: value.value
142
143
  });
143
144
  };
144
- watch(
145
+ useWatchTrue(
145
146
  () => upload.status.value.isSuccess,
146
- (isSuccess2) => {
147
- if (isSuccess2 && upload.data.value) {
147
+ () => {
148
+ if (upload.data.value) {
148
149
  const fileValue = {
149
150
  url: _get(upload.data.value, props.responseURL),
150
151
  path: _get(upload.data.value, props.responsePath),
@@ -156,12 +157,10 @@ export const useUploadState = (props, emits, onChange, setErrors, value, accepte
156
157
  }
157
158
  }
158
159
  );
159
- watch(
160
+ useWatchTrue(
160
161
  () => upload.status.value.isError,
161
- (isError2) => {
162
- if (isError2) {
163
- setErrors("\u0E1E\u0E1A\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14: " + StringHelper.getError(upload.status.value.errorData));
164
- }
162
+ () => {
163
+ setErrors("\u0E1E\u0E1A\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14: " + StringHelper.getError(upload.status.value.errorData));
165
164
  }
166
165
  );
167
166
  return {
@@ -1,5 +1,5 @@
1
- <template>
2
- <form class="form">
3
- <slot />
4
- </form>
5
- </template>
1
+ <template>
2
+ <form class="form">
3
+ <slot />
4
+ </form>
5
+ </template>
@@ -1,5 +1,6 @@
1
1
  import type { Component } from '@nuxt/schema';
2
2
  import type { FormContext } from 'vee-validate';
3
+ import type { IUploadDropzoneField } from './InputUploadDropzone/types.js';
3
4
  import type { IUploadDropzoneAutoField } from './InputUploadDropzoneAuto/types.js';
4
5
  import type { IDateTimeRangeField } from './InputDateTimeRange/date_range_time_field.types.js';
5
6
  import type { ITextField } from '#core/components/Form/InputText/types';
@@ -66,7 +67,7 @@ export interface IFormFieldBase<I extends INPUT_TYPES, P extends IFieldProps, O>
66
67
  props: P;
67
68
  on?: O;
68
69
  }
69
- export type IFormField = ITextField | ISearchField | INumberField | ITextareaField | IToggleField | ISelectField | ICheckboxField | ISelectMultipleField | IRadioField | IDateTimeField | IDateTimeRangeField | IUploadDropzoneAutoField | IWYSIWYGField | IFormFieldBase<INPUT_TYPES.COMPONENT, any, any>;
70
+ export type IFormField = ITextField | ISearchField | INumberField | ITextareaField | IToggleField | ISelectField | ICheckboxField | ISelectMultipleField | IRadioField | IDateTimeField | IDateTimeRangeField | IUploadDropzoneField | IUploadDropzoneAutoField | IWYSIWYGField | IFormFieldBase<INPUT_TYPES.COMPONENT, any, any>;
70
71
  export interface IFileValue {
71
72
  url: string;
72
73
  path?: string;
@@ -1,32 +1,32 @@
1
1
  <template>
2
- <UseImage v-bind="$props">
3
- <template #loading>
4
- <slot name="loading">
5
- <div
6
- class="flex h-full w-full items-center justify-center"
7
- >
8
- <Loader
9
- :loading="true"
10
- />
11
- </div>
12
- </slot>
13
- </template>
14
-
15
- <template #error>
16
- <slot name="error">
17
- <div
18
- class="flex h-full w-full items-center justify-center"
19
- >
20
- <p class="text-error-400">
21
- <Icon
22
- name="i-heroicons:exclamation-circle-solid"
23
- class="text-error-400 size-8"
24
- />
25
- </p>
26
- </div>
27
- </slot>
28
- </template>
29
- </UseImage>
2
+ <UseImage v-bind="$props">
3
+ <template #loading>
4
+ <slot name="loading">
5
+ <div
6
+ class="flex h-full w-full items-center justify-center"
7
+ >
8
+ <Loader
9
+ :loading="true"
10
+ />
11
+ </div>
12
+ </slot>
13
+ </template>
14
+
15
+ <template #error>
16
+ <slot name="error">
17
+ <div
18
+ class="flex h-full w-full items-center justify-center"
19
+ >
20
+ <p class="text-error-400">
21
+ <Icon
22
+ name="i-heroicons:exclamation-circle-solid"
23
+ class="text-error-400 size-8"
24
+ />
25
+ </p>
26
+ </div>
27
+ </slot>
28
+ </template>
29
+ </UseImage>
30
30
  </template>
31
31
 
32
32
  <script setup>
@@ -1,21 +1,21 @@
1
1
  <template>
2
- <DevOnly>
3
- <TeleportSafe
4
- to="#dev-logs"
5
- >
6
- <LogItem
7
- v-if="typeof data !== 'undefined'"
8
- :data="data"
9
- :title="title"
10
- />
11
- <LogItem
12
- v-for="(item, index) in dataItems"
13
- :key="index"
14
- :data="item"
15
- :title="`${title} #${index + 1}`"
16
- />
17
- </TeleportSafe>
18
- </DevOnly>
2
+ <DevOnly>
3
+ <TeleportSafe
4
+ to="#dev-logs"
5
+ >
6
+ <LogItem
7
+ v-if="typeof data !== 'undefined'"
8
+ :data="data"
9
+ :title="title"
10
+ />
11
+ <LogItem
12
+ v-for="(item, index) in dataItems"
13
+ :key="index"
14
+ :data="item"
15
+ :title="`${title} #${index + 1}`"
16
+ />
17
+ </TeleportSafe>
18
+ </DevOnly>
19
19
  </template>
20
20
 
21
21
  <script setup>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- {{ getValue || "-" }}
2
+ {{ getValue || "-" }}
3
3
  </template>
4
4
 
5
5
  <script setup>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- {{ getValue || "-" }}
2
+ {{ getValue || "-" }}
3
3
  </template>
4
4
 
5
5
  <script setup>
@@ -1,8 +1,8 @@
1
1
  <template>
2
- <Image
3
- class="h-12 rounded"
4
- :src="getValue"
5
- />
2
+ <Image
3
+ class="h-12 rounded"
4
+ :src="getValue"
5
+ />
6
6
  </template>
7
7
 
8
8
  <script setup>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- {{ getValue }}
2
+ {{ getValue }}
3
3
  </template>
4
4
 
5
5
  <script setup>
@@ -1,101 +1,101 @@
1
1
  <template>
2
- <div ref="tableContainer">
3
- <div
4
- v-if="options.isEnabledSearch"
2
+ <div ref="tableContainer">
3
+ <div
4
+ v-if="options.isEnabledSearch"
5
5
  :class="theme.searchContainer({
6
6
  class: [ui?.searchContainer]
7
- })"
8
- >
9
- <Input
10
- v-model="q"
11
- icon="i-heroicons-magnifying-glass"
12
- :placeholder="options.searchPlaceholder || '\u0E04\u0E49\u0E19\u0E2B\u0E32....'"
13
- />
14
- </div>
15
- <UTable
16
- v-bind="$attrs"
17
- :loading="options.status.isLoading"
18
- :data="options.rawData"
19
- :columns="options.columns"
20
- :ui="ui"
21
- >
22
- <template #empty>
23
- <slot
24
- v-if="options.status.isLoading"
25
- name="loading"
26
- >
27
- <Loader
28
- :loading="true"
29
- />
30
- </slot>
31
- <slot
32
- v-else-if="options.status.isError"
33
- name="error"
34
- >
35
- <div
7
+ })"
8
+ >
9
+ <Input
10
+ v-model="q"
11
+ icon="i-heroicons-magnifying-glass"
12
+ :placeholder="options.searchPlaceholder || '\u0E04\u0E49\u0E19\u0E2B\u0E32....'"
13
+ />
14
+ </div>
15
+ <UTable
16
+ v-bind="$attrs"
17
+ :loading="options.status.isLoading"
18
+ :data="options.rawData"
19
+ :columns="options.columns"
20
+ :ui="ui"
21
+ >
22
+ <template #empty>
23
+ <slot
24
+ v-if="options.status.isLoading"
25
+ name="loading"
26
+ >
27
+ <Loader
28
+ :loading="true"
29
+ />
30
+ </slot>
31
+ <slot
32
+ v-else-if="options.status.isError"
33
+ name="error"
34
+ >
35
+ <div
36
36
  class="
37
37
  text-error-400 flex h-[200px] items-center justify-center text-2xl
38
- "
39
- >
40
- {{ StringHelper.getError(options.status.errorData) }}
41
- </div>
42
- </slot>
43
-
44
- <slot
45
- v-else
46
- name="error"
47
- >
48
- <Empty />
49
- </slot>
50
- </template>
51
- <template
52
- v-for="column in options.columns.filter((item) => !!item.type)"
53
- #[`${column.accessorKey}-cell`]="{ row }"
54
- :key="column.accessorKey"
55
- >
56
- <component
57
- :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
58
- v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
59
- :value="transformValue(column, row)"
60
- :column="column"
61
- :row="row"
62
- />
63
- </template>
64
- <template
65
- v-for="(_, slotName) of $slots"
66
- #[slotName]="slotProps"
67
- >
68
- <slot
69
- :name="slotName"
70
- v-bind="slotProps || {}"
71
- />
72
- </template>
73
- </UTable>
74
-
75
- <div
76
- v-if="!options.isHidePagination"
38
+ "
39
+ >
40
+ {{ StringHelper.getError(options.status.errorData) }}
41
+ </div>
42
+ </slot>
43
+
44
+ <slot
45
+ v-else
46
+ name="error"
47
+ >
48
+ <Empty />
49
+ </slot>
50
+ </template>
51
+ <template
52
+ v-for="column in options.columns.filter((item) => !!item.type)"
53
+ #[`${column.accessorKey}-cell`]="{ row }"
54
+ :key="column.accessorKey"
55
+ >
56
+ <component
57
+ :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
58
+ v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
59
+ :value="transformValue(column, row)"
60
+ :column="column"
61
+ :row="row"
62
+ />
63
+ </template>
64
+ <template
65
+ v-for="(_, slotName) of $slots"
66
+ #[slotName]="slotProps"
67
+ >
68
+ <slot
69
+ :name="slotName"
70
+ v-bind="slotProps || {}"
71
+ />
72
+ </template>
73
+ </UTable>
74
+
75
+ <div
76
+ v-if="!options.isHidePagination"
77
77
  :class="theme.paginationContainer({
78
78
  class: [ui?.paginationContainer]
79
- })"
80
- >
81
- <p
79
+ })"
80
+ >
81
+ <p
82
82
  :class="theme.paginationInfo({
83
83
  class: [ui?.paginationInfo]
84
- })"
85
- >
86
- {{ pageBetween }} รายการ จากทั้งหมด {{ totalCountWithComma }} รายการ
87
- </p>
88
- <Pagination
89
- v-if="options.pageOptions.totalPage > 1"
90
- v-model:page="page"
91
- :default-page="options.pageOptions?.currentPage || 1"
92
- :items-per-page="options.pageOptions.limit"
93
- :total="options.pageOptions.totalCount"
94
- :to="options.isRouteChange ? to : void 0"
95
- @update:page="onPageChange"
96
- />
97
- </div>
98
- </div>
84
+ })"
85
+ >
86
+ {{ pageBetween }} รายการ จากทั้งหมด {{ totalCountWithComma }} รายการ
87
+ </p>
88
+ <Pagination
89
+ v-if="options.pageOptions.totalPage > 1"
90
+ v-model:page="page"
91
+ :default-page="options.pageOptions?.currentPage || 1"
92
+ :items-per-page="options.pageOptions.limit"
93
+ :total="options.pageOptions.totalCount"
94
+ :to="options.isRouteChange ? to : void 0"
95
+ @update:page="onPageChange"
96
+ />
97
+ </div>
98
+ </div>
99
99
  </template>
100
100
 
101
101
  <script setup>
@@ -0,0 +1 @@
1
+ export declare const getFileIcon: (file: File) => string;
@@ -0,0 +1,9 @@
1
+ import { isImage } from "../helpers/componentHelper.js";
2
+ import { useUiIconConfig } from "./useConfig.js";
3
+ export const getFileIcon = (file) => {
4
+ const icons = useUiIconConfig("uploadFileDropzone");
5
+ if (isImage(file)) {
6
+ return icons.placeholderImgIcon;
7
+ }
8
+ return icons.filePreviewIcon;
9
+ };
@@ -1,3 +1,3 @@
1
- {
2
- "extends": "../../../.nuxt/tsconfig.server.json",
3
- }
1
+ {
2
+ "extends": "../../../.nuxt/tsconfig.server.json",
3
+ }
@@ -25,9 +25,10 @@ export declare const uploadFileDropzoneTheme: {
25
25
  onLoadingTextWrapper: string;
26
26
  onLoadingLoadingIconClass: string;
27
27
  onPreviewWrapper: string;
28
- onPreviewPreviewImgWrapper: string;
29
- onPreviewPreviewImgClass: string;
30
- onPreviewPreviewFileClass: string;
28
+ onPreviewImgWrapper: string;
29
+ onPreviewImgClass: string;
30
+ onPreviewFileWrapper: string;
31
+ onPreviewFileClass: string;
31
32
  onPreviewTextWrapper: string;
32
33
  onFailedWrapper: string;
33
34
  onFailedFailedImgWrapper: string;
@@ -27,9 +27,10 @@ export const uploadFileDropzoneTheme = {
27
27
  onLoadingLoadingIconClass: "size-10 text-primary animate-spin",
28
28
  // Preview state
29
29
  onPreviewWrapper: "flex items-center space-x-4 rounded-md w-full",
30
- onPreviewPreviewImgWrapper: "flex-shrink-0 w-16 h-16 rounded-md overflow-hidden bg-gray-100",
31
- onPreviewPreviewImgClass: "w-full h-full object-cover",
32
- onPreviewPreviewFileClass: "size-8 text-gray-400 m-auto mt-4",
30
+ onPreviewImgWrapper: "flex-shrink-0 w-16 h-16 flex justify-center items-center rounded-md overflow-hidden bg-gray-100",
31
+ onPreviewImgClass: "w-full h-full object-cover",
32
+ onPreviewFileWrapper: "flex-shrink-0 w-16 h-16 flex justify-center items-center rounded-md overflow-hidden",
33
+ onPreviewFileClass: "size-8 text-gray-400 m-auto",
33
34
  onPreviewTextWrapper: "flex-1 min-w-0 flex items-center justify-between",
34
35
  // Failed state
35
36
  onFailedWrapper: "flex items-start space-x-4 w-full rounded-md",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "2.22.0",
3
+ "version": "2.23.1",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",
@@ -93,4 +93,4 @@
93
93
  "lint-staged": {
94
94
  "*": "eslint --fix --quiet"
95
95
  }
96
- }
96
+ }