@finema/core 2.1.1 → 2.2.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.
Files changed (40) 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/App.vue +7 -7
  5. package/dist/runtime/components/DevToolsWindow/index.vue +95 -95
  6. package/dist/runtime/components/Dialog/index.vue +45 -45
  7. package/dist/runtime/components/Empty.vue +12 -12
  8. package/dist/runtime/components/FlexDeck/Base.vue +67 -67
  9. package/dist/runtime/components/FlexDeck/index.vue +33 -33
  10. package/dist/runtime/components/Form/FieldWrapper.vue +13 -13
  11. package/dist/runtime/components/Form/Fields.vue +13 -13
  12. package/dist/runtime/components/Form/InputCheckbox/index.vue +18 -18
  13. package/dist/runtime/components/Form/InputDateTime/index.vue +44 -44
  14. package/dist/runtime/components/Form/InputNumber/index.vue +20 -20
  15. package/dist/runtime/components/Form/InputSelect/index.vue +38 -38
  16. package/dist/runtime/components/Form/InputSelectMultiple/index.vue +43 -43
  17. package/dist/runtime/components/Form/InputText/index.vue +48 -48
  18. package/dist/runtime/components/Form/InputTextarea/index.vue +18 -18
  19. package/dist/runtime/components/Form/InputToggle/index.vue +17 -17
  20. package/dist/runtime/components/Form/index.vue +5 -5
  21. package/dist/runtime/components/Image.vue +28 -28
  22. package/dist/runtime/components/Loader.vue +10 -10
  23. package/dist/runtime/components/Log/index.vue +17 -17
  24. package/dist/runtime/components/Table/Base.vue +76 -76
  25. package/dist/runtime/components/Table/ColumnDate.vue +1 -1
  26. package/dist/runtime/components/Table/ColumnDateTime.vue +1 -1
  27. package/dist/runtime/components/Table/ColumnImage.vue +4 -4
  28. package/dist/runtime/components/Table/ColumnNumber.vue +1 -1
  29. package/dist/runtime/components/Table/ColumnText.vue +1 -1
  30. package/dist/runtime/components/Table/Simple.vue +21 -21
  31. package/dist/runtime/components/Table/index.vue +100 -100
  32. package/dist/runtime/helpers/apiPageHelper.js +2 -1
  33. package/dist/runtime/server/tsconfig.json +3 -3
  34. package/dist/runtime/types/common.d.ts +1 -1
  35. package/dist/runtime/utils/ArrayHelper.js +1 -1
  36. package/dist/runtime/utils/ObjectHelper.js +1 -2
  37. package/dist/runtime/utils/ParamHelper.js +1 -1
  38. package/dist/runtime/utils/lodash.d.ts +15 -0
  39. package/dist/runtime/utils/lodash.js +27 -0
  40. package/package.json +2 -2
@@ -1,21 +1,21 @@
1
1
  <template>
2
- <FieldWrapper
3
- v-bind="wrapperProps"
4
- label=""
5
- description=""
6
- >
7
- <Switch
8
- :model-value="value"
9
- :disabled="wrapperProps.disabled"
10
- :name="name"
11
- :ui="ui"
12
- :label="label"
13
- :description="description"
14
- :loading="loading"
15
- :loading-icon="loadingIcon"
16
- @update:modelValue="onChange"
17
- />
18
- </FieldWrapper>
2
+ <FieldWrapper
3
+ v-bind="wrapperProps"
4
+ label=""
5
+ description=""
6
+ >
7
+ <Switch
8
+ :model-value="value"
9
+ :disabled="wrapperProps.disabled"
10
+ :name="name"
11
+ :ui="ui"
12
+ :label="label"
13
+ :description="description"
14
+ :loading="loading"
15
+ :loading-icon="loadingIcon"
16
+ @update:modelValue="onChange"
17
+ />
18
+ </FieldWrapper>
19
19
  </template>
20
20
 
21
21
  <script setup>
@@ -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,32 +1,32 @@
1
1
  <template>
2
- <UseImage v-bind="$props">
3
- <template #loading>
4
- <slot name="loading">
5
- <div
6
- class="w-full h-full flex justify-center items-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="w-full h-full flex justify-center items-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="w-full h-full flex justify-center items-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="w-full h-full flex justify-center items-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,18 +1,18 @@
1
1
  <template>
2
- <div
3
- v-if="loading"
2
+ <div
3
+ v-if="loading"
4
4
  :class="theme.base({
5
5
  class: [ui?.base, props.class]
6
- })"
7
- >
8
- <Icon
9
- :name="icon"
6
+ })"
7
+ >
8
+ <Icon
9
+ :name="icon"
10
10
  :class="[theme.icon({
11
11
  class: [ui?.icon]
12
- })]"
13
- />
14
- </div>
15
- <slot v-else />
12
+ })]"
13
+ />
14
+ </div>
15
+ <slot v-else />
16
16
  </template>
17
17
 
18
18
  <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,80 +1,80 @@
1
1
  <template>
2
- <div
3
- v-if="!isHideCaption || !isHideBottomPagination"
4
- class="mb-4 text-gray-500"
5
- >
6
- <span class="font-bold">ผลลัพธ์ทั้งหมด:</span>
7
- จำนวน
8
- <span class="font-bold">{{ pageOptions?.totalCount || 0 }}</span>
9
- รายการ
10
- </div>
11
- <UTable
12
- :loading="status.isLoading"
13
- :columns="uTableCompatibleColumns"
14
- :rows="rawData"
15
- v-bind="$attrs"
16
- >
17
- <template #loading-state>
18
- <div class="flex h-60 items-center justify-center">
19
- <Icon
20
- name="i-svg-spinners:180-ring-with-bg"
21
- class="text-primary size-8"
22
- />
23
- </div>
24
- </template>
25
- <template #empty-state>
26
- <Empty />
27
- </template>
28
- <template
29
- v-for="column in columns"
30
- #[`${column.accessorKey}-data`]="{ row }"
31
- :key="column.accessorKey"
32
- >
33
- <component
34
- :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : column.type ? columnTypeComponents[column.type] : void 0"
35
- v-if="column.type === COLUMN_TYPES.COMPONENT || column.type && columnTypeComponents[column.type]"
36
- :value="transformValue(column, row)"
37
- :column="column"
38
- :row="row"
39
- />
40
- <ColumnText
41
- v-else
42
- :value="transformValue(column, row)"
43
- :column="column"
44
- :row="row"
45
- />
46
- </template>
47
-
48
- <template
49
- v-for="(_, slotName) in $slots"
50
- #[slotName]="scope"
51
- >
52
- <slot
53
- :name="slotName"
54
- v-bind="scope"
55
- />
56
- </template>
57
- </UTable>
58
- <div
59
- v-if="pageOptions"
60
- class="mt-4 flex justify-between px-3"
61
- >
62
- <p class="text-sm text-gray-500">
63
- ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
64
- </p>
65
- <Pagination
66
- v-if="pageOptions.totalPage > 1 && !isSimplePagination && !isHideBottomPagination"
67
- v-model="page"
68
- :page-count="pageOptions.limit"
69
- :total="pageOptions.totalCount"
70
- />
71
- <SimplePagination
72
- v-if="pageOptions.totalPage > 1 && isSimplePagination"
73
- v-model="page"
74
- :page-count="pageOptions.limit"
75
- :total="pageOptions.totalCount"
76
- />
77
- </div>
2
+ <div
3
+ v-if="!isHideCaption || !isHideBottomPagination"
4
+ class="mb-4 text-gray-500"
5
+ >
6
+ <span class="font-bold">ผลลัพธ์ทั้งหมด:</span>
7
+ จำนวน
8
+ <span class="font-bold">{{ pageOptions?.totalCount || 0 }}</span>
9
+ รายการ
10
+ </div>
11
+ <UTable
12
+ :loading="status.isLoading"
13
+ :columns="uTableCompatibleColumns"
14
+ :rows="rawData"
15
+ v-bind="$attrs"
16
+ >
17
+ <template #loading-state>
18
+ <div class="flex h-60 items-center justify-center">
19
+ <Icon
20
+ name="i-svg-spinners:180-ring-with-bg"
21
+ class="text-primary size-8"
22
+ />
23
+ </div>
24
+ </template>
25
+ <template #empty-state>
26
+ <Empty />
27
+ </template>
28
+ <template
29
+ v-for="column in columns"
30
+ #[`${column.accessorKey}-data`]="{ row }"
31
+ :key="column.accessorKey"
32
+ >
33
+ <component
34
+ :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : column.type ? columnTypeComponents[column.type] : void 0"
35
+ v-if="column.type === COLUMN_TYPES.COMPONENT || column.type && columnTypeComponents[column.type]"
36
+ :value="transformValue(column, row)"
37
+ :column="column"
38
+ :row="row"
39
+ />
40
+ <ColumnText
41
+ v-else
42
+ :value="transformValue(column, row)"
43
+ :column="column"
44
+ :row="row"
45
+ />
46
+ </template>
47
+
48
+ <template
49
+ v-for="(_, slotName) in $slots"
50
+ #[slotName]="scope"
51
+ >
52
+ <slot
53
+ :name="slotName"
54
+ v-bind="scope"
55
+ />
56
+ </template>
57
+ </UTable>
58
+ <div
59
+ v-if="pageOptions"
60
+ class="mt-4 flex justify-between px-3"
61
+ >
62
+ <p class="text-sm text-gray-500">
63
+ ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
64
+ </p>
65
+ <Pagination
66
+ v-if="pageOptions.totalPage > 1 && !isSimplePagination && !isHideBottomPagination"
67
+ v-model="page"
68
+ :page-count="pageOptions.limit"
69
+ :total="pageOptions.totalCount"
70
+ />
71
+ <SimplePagination
72
+ v-if="pageOptions.totalPage > 1 && isSimplePagination"
73
+ v-model="page"
74
+ :page-count="pageOptions.limit"
75
+ :total="pageOptions.totalCount"
76
+ />
77
+ </div>
78
78
  </template>
79
79
 
80
80
  <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,5 +1,5 @@
1
1
  <template>
2
- {{ getValue }}
2
+ {{ getValue }}
3
3
  </template>
4
4
 
5
5
  <script setup>
@@ -1,25 +1,25 @@
1
1
  <template>
2
- <Base
3
- v-bind="$attrs"
4
- :columns="options.columns"
5
- :raw-data="itemsByPage"
6
- :status="options.status"
7
- :page-options="pageOptions"
8
- :is-simple-pagination="isShowSimplePagination"
9
- :is-hide-bottom-pagination="options.isHideBottomPagination"
10
- :is-hide-caption="options.isHideCaption"
11
- @page-change="onPageChange"
12
- >
13
- <template
14
- v-for="(_, slot) of $slots"
15
- #[slot]="slotProps"
16
- >
17
- <slot
18
- :name="slot"
19
- v-bind="slotProps || {}"
20
- />
21
- </template>
22
- </Base>
2
+ <Base
3
+ v-bind="$attrs"
4
+ :columns="options.columns"
5
+ :raw-data="itemsByPage"
6
+ :status="options.status"
7
+ :page-options="pageOptions"
8
+ :is-simple-pagination="isShowSimplePagination"
9
+ :is-hide-bottom-pagination="options.isHideBottomPagination"
10
+ :is-hide-caption="options.isHideCaption"
11
+ @page-change="onPageChange"
12
+ >
13
+ <template
14
+ v-for="(_, slot) of $slots"
15
+ #[slot]="slotProps"
16
+ >
17
+ <slot
18
+ :name="slot"
19
+ v-bind="slotProps || {}"
20
+ />
21
+ </template>
22
+ </Base>
23
23
  </template>
24
24
 
25
25
  <script setup>
@@ -1,116 +1,116 @@
1
1
  <template>
2
- <div>
3
- <div
4
- v-if="options.isEnabledSearch"
2
+ <div>
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
- <div
16
- v-if="!options.isHideCaption || !options.isHideBottomPagination"
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
+ <div
16
+ v-if="!options.isHideCaption || !options.isHideBottomPagination"
17
17
  :class="theme.captionContainer({
18
18
  class: [ui?.captionContainer]
19
- })"
20
- >
21
- <span
19
+ })"
20
+ >
21
+ <span
22
22
  :class="theme.captionBoldText({
23
23
  class: [ui?.captionBoldText]
24
- })"
25
- >
26
- ผลลัพธ์ทั้งหมด:</span>
27
- จำนวน
28
- <span
24
+ })"
25
+ >
26
+ ผลลัพธ์ทั้งหมด:</span>
27
+ จำนวน
28
+ <span
29
29
  :class="theme.captionBoldText({
30
30
  class: [ui?.captionBoldText]
31
- })"
32
- >{{ options.pageOptions?.totalCount || 0 }}</span>
33
- รายการ
34
- </div>
35
-
36
- <UTable
37
- v-bind="$attrs"
38
- :loading="options.status.isLoading"
39
- :data="options.rawData"
40
- :columns="options.columns"
41
- >
42
- <template #empty>
43
- <slot
44
- v-if="options.status.isLoading"
45
- name="loading"
46
- >
47
- <Loader
48
- :loading="true"
49
- />
50
- </slot>
51
- <slot
52
- v-else-if="options.status.isError"
53
- name="error"
54
- >
55
- <div
56
- class="text-error-400 text-2xl h-[200px] flex justify-center items-center"
57
- >
58
- {{ StringHelper.getError(options.status.errorData) }}
59
- </div>
60
- </slot>
61
-
62
- <slot
63
- v-else
64
- name="error"
65
- >
66
- <Empty />
67
- </slot>
68
- </template>
69
- <template
70
- v-for="column in options.columns.filter((item) => !!item.type)"
71
- #[`${column.accessorKey}-cell`]="{ row }"
72
- :key="column.accessorKey"
73
- >
74
- <component
75
- :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
76
- v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
77
- :value="transformValue(column, row)"
78
- :column="column"
79
- :row="row"
80
- />
81
- </template>
82
- <template
83
- v-for="(_, slotName) of $slots"
84
- #[slotName]="slotProps"
85
- >
86
- <slot
87
- :name="slotName"
88
- v-bind="slotProps || {}"
89
- />
90
- </template>
91
- </UTable>
92
-
93
- <div
31
+ })"
32
+ >{{ options.pageOptions?.totalCount || 0 }}</span>
33
+ รายการ
34
+ </div>
35
+
36
+ <UTable
37
+ v-bind="$attrs"
38
+ :loading="options.status.isLoading"
39
+ :data="options.rawData"
40
+ :columns="options.columns"
41
+ >
42
+ <template #empty>
43
+ <slot
44
+ v-if="options.status.isLoading"
45
+ name="loading"
46
+ >
47
+ <Loader
48
+ :loading="true"
49
+ />
50
+ </slot>
51
+ <slot
52
+ v-else-if="options.status.isError"
53
+ name="error"
54
+ >
55
+ <div
56
+ class="text-error-400 text-2xl h-[200px] flex justify-center items-center"
57
+ >
58
+ {{ StringHelper.getError(options.status.errorData) }}
59
+ </div>
60
+ </slot>
61
+
62
+ <slot
63
+ v-else
64
+ name="error"
65
+ >
66
+ <Empty />
67
+ </slot>
68
+ </template>
69
+ <template
70
+ v-for="column in options.columns.filter((item) => !!item.type)"
71
+ #[`${column.accessorKey}-cell`]="{ row }"
72
+ :key="column.accessorKey"
73
+ >
74
+ <component
75
+ :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
76
+ v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
77
+ :value="transformValue(column, row)"
78
+ :column="column"
79
+ :row="row"
80
+ />
81
+ </template>
82
+ <template
83
+ v-for="(_, slotName) of $slots"
84
+ #[slotName]="slotProps"
85
+ >
86
+ <slot
87
+ :name="slotName"
88
+ v-bind="slotProps || {}"
89
+ />
90
+ </template>
91
+ </UTable>
92
+
93
+ <div
94
94
  :class="theme.paginationContainer({
95
95
  class: [ui?.paginationContainer]
96
- })"
97
- >
98
- <p
96
+ })"
97
+ >
98
+ <p
99
99
  :class="theme.paginationInfo({
100
100
  class: [ui?.paginationInfo]
101
- })"
102
- >
103
- ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
104
- </p>
105
- <Pagination
106
- v-model:page="page"
107
- :default-page="options.pageOptions?.currentPage || 1"
108
- :items-per-page="options.pageOptions.limit"
109
- :total="options.pageOptions.totalCount"
110
- @update:page="emits('pageChange', $event)"
111
- />
112
- </div>
113
- </div>
101
+ })"
102
+ >
103
+ ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
104
+ </p>
105
+ <Pagination
106
+ v-model:page="page"
107
+ :default-page="options.pageOptions?.currentPage || 1"
108
+ :items-per-page="options.pageOptions.limit"
109
+ :total="options.pageOptions.totalCount"
110
+ @update:page="emits('pageChange', $event)"
111
+ />
112
+ </div>
113
+ </div>
114
114
  </template>
115
115
 
116
116
  <script setup>
@@ -1,4 +1,5 @@
1
1
  import { useCoreConfig } from "../composables/useConfig.js";
2
+ import { _get } from "../utils/lodash.js";
2
3
  import { bindParamsToUrl } from "./apiBaseHelper.js";
3
4
  import {
4
5
  checkExpiration,
@@ -6,7 +7,7 @@ import {
6
7
  prepareRequestOptions,
7
8
  updateLoaderState
8
9
  } from "./apiBaseHelper.js";
9
- import { _findIndex, _get, _shuffle } from "#imports";
10
+ import { _findIndex, _shuffle } from "#imports";
10
11
  export const apiAddHelper = async (state, onUpdateStatus, onUpdateOptions, onUpdateData, onUpdateItems, data, opts) => {
11
12
  onUpdateStatus(updateLoaderState.setLoading(state().status));
12
13
  onUpdateOptions({});