@finema/core 1.4.83 → 1.4.84
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/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/FlexDeck/Base.vue +77 -0
- package/dist/runtime/components/FlexDeck/index.vue +59 -0
- package/dist/runtime/components/FlexDeck/types.d.ts +14 -0
- package/dist/runtime/components/FlexDeck/types.mjs +0 -0
- package/dist/runtime/components/SimplePagination.vue +2 -2
- package/dist/runtime/composables/useFlexDeck.d.ts +4 -0
- package/dist/runtime/composables/useFlexDeck.mjs +19 -0
- package/package.json +2 -7
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- TODO -->
|
|
3
|
+
<div v-if="pageOptions" class="mt-4 flex justify-between px-3">
|
|
4
|
+
<p class="text-xs text-gray-500">
|
|
5
|
+
ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
|
|
6
|
+
</p>
|
|
7
|
+
<UPagination
|
|
8
|
+
v-if="pageOptions.totalPage > 1 && !isSimplePagination && !isHideBottomPagination"
|
|
9
|
+
v-model="page"
|
|
10
|
+
:page-count="pageOptions.limit"
|
|
11
|
+
:total="pageOptions.totalCount"
|
|
12
|
+
/>
|
|
13
|
+
<SimplePagination
|
|
14
|
+
v-if="pageOptions.totalPage > 1 && isSimplePagination"
|
|
15
|
+
v-model="page"
|
|
16
|
+
:page-count="pageOptions.limit"
|
|
17
|
+
:total="pageOptions.totalCount"
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script lang="ts" setup>
|
|
23
|
+
import { computed, type PropType } from 'vue'
|
|
24
|
+
import { StringHelper } from '#core/utils/StringHelper'
|
|
25
|
+
import { ref, watch } from '#imports'
|
|
26
|
+
import type { IFlexDeckOptions } from '#core/components/FlexDeck/types'
|
|
27
|
+
|
|
28
|
+
const emits = defineEmits(['pageChange'])
|
|
29
|
+
|
|
30
|
+
const props = defineProps({
|
|
31
|
+
status: {
|
|
32
|
+
type: Object as PropType<IFlexDeckOptions['status']>,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
pageOptions: {
|
|
36
|
+
type: Object as PropType<IFlexDeckOptions['pageOptions']>,
|
|
37
|
+
required: false,
|
|
38
|
+
},
|
|
39
|
+
rawData: {
|
|
40
|
+
type: Array as PropType<IFlexDeckOptions['rawData']>,
|
|
41
|
+
required: true,
|
|
42
|
+
},
|
|
43
|
+
isSimplePagination: {
|
|
44
|
+
type: Boolean as PropType<IFlexDeckOptions['isSimplePagination']>,
|
|
45
|
+
default: false,
|
|
46
|
+
},
|
|
47
|
+
isHideBottomPagination: {
|
|
48
|
+
type: Boolean as PropType<IFlexDeckOptions['isHideBottomPagination']>,
|
|
49
|
+
default: false,
|
|
50
|
+
},
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const page = ref(props.pageOptions?.currentPage || 1)
|
|
54
|
+
|
|
55
|
+
const pageBetween = computed((): string => {
|
|
56
|
+
const length = props.rawData?.length
|
|
57
|
+
|
|
58
|
+
if (length === 0) {
|
|
59
|
+
return '0'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const start = (props.pageOptions!.currentPage - 1) * props.pageOptions!.limit + 1
|
|
63
|
+
const end = start + length - 1
|
|
64
|
+
|
|
65
|
+
return `${start} - ${end}`
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const totalCountWithComma = computed((): string => {
|
|
69
|
+
return !props.pageOptions!.totalCount
|
|
70
|
+
? '0'
|
|
71
|
+
: StringHelper.withComma(props.pageOptions!.totalCount)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
watch(page, () => {
|
|
75
|
+
emits('pageChange', page.value)
|
|
76
|
+
})
|
|
77
|
+
</script>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div v-if="options.isEnabledSearch" class="mb-4 flex justify-end">
|
|
4
|
+
<UInput
|
|
5
|
+
v-model="q"
|
|
6
|
+
icon="i-heroicons-magnifying-glass"
|
|
7
|
+
:placeholder="options.searchPlaceholder || 'ค้นหา...'"
|
|
8
|
+
/>
|
|
9
|
+
</div>
|
|
10
|
+
<Base
|
|
11
|
+
v-bind="$attrs"
|
|
12
|
+
:raw-data="options.rawData"
|
|
13
|
+
:status="options.status"
|
|
14
|
+
:page-options="options.pageOptions"
|
|
15
|
+
:is-simple-pagination="isShowSimplePagination"
|
|
16
|
+
:is-hide-bottom-pagination="options.isHideBottomPagination"
|
|
17
|
+
@page-change="onPageChange"
|
|
18
|
+
>
|
|
19
|
+
<template v-for="(_, slot) of $slots" #[slot]="slotProps">
|
|
20
|
+
<slot :name="slot" v-bind="slotProps || {}" />
|
|
21
|
+
</template>
|
|
22
|
+
</Base>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
<script lang="ts" setup>
|
|
26
|
+
import { type PropType } from 'vue'
|
|
27
|
+
import { _debounce, computed, ref, watch } from '#imports'
|
|
28
|
+
import { useCoreConfig } from '#core/composables/useConfig'
|
|
29
|
+
import Base from '#core/components/FlexDeck/Base.vue'
|
|
30
|
+
import type { IFlexDeckOptions } from '#core/components/FlexDeck/types'
|
|
31
|
+
|
|
32
|
+
const emits = defineEmits<{
|
|
33
|
+
(event: 'pageChange', page: number): void
|
|
34
|
+
(event: 'search', q: string): void
|
|
35
|
+
}>()
|
|
36
|
+
|
|
37
|
+
const props = defineProps({
|
|
38
|
+
options: { type: Object as PropType<IFlexDeckOptions>, required: true },
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const coreConfig = useCoreConfig()
|
|
42
|
+
|
|
43
|
+
const q = ref(props.options?.pageOptions.search ?? '')
|
|
44
|
+
|
|
45
|
+
const isShowSimplePagination = computed(
|
|
46
|
+
(): boolean => props.options.isSimplePagination ?? coreConfig.is_simple_pagination
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
watch(
|
|
50
|
+
q,
|
|
51
|
+
_debounce((value) => {
|
|
52
|
+
emits('search', value)
|
|
53
|
+
}, 500)
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const onPageChange = (page: number) => {
|
|
57
|
+
emits('pageChange', page)
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IPageOptions, IStatus } from '#core/types/lib';
|
|
2
|
+
export interface IFlexDeckOptions<T = object> {
|
|
3
|
+
rawData: T[];
|
|
4
|
+
primary: string;
|
|
5
|
+
status: IStatus;
|
|
6
|
+
pageOptions: IPageOptions;
|
|
7
|
+
isHideToolbar?: boolean;
|
|
8
|
+
isEnabledSearch?: boolean;
|
|
9
|
+
searchPlaceholder?: string;
|
|
10
|
+
isPreventRouteChange: boolean;
|
|
11
|
+
isHideBottomPagination?: boolean;
|
|
12
|
+
isHideTopPagination?: boolean;
|
|
13
|
+
isSimplePagination?: boolean;
|
|
14
|
+
}
|
|
File without changes
|
|
@@ -29,7 +29,7 @@ import { useUI, type PropType, toRef, computed } from '#imports'
|
|
|
29
29
|
import type { ButtonSize } from '#ui/types/button'
|
|
30
30
|
import type { Strategy } from '#ui/types'
|
|
31
31
|
|
|
32
|
-
const config = useUiConfig<typeof pagination>(pagination
|
|
32
|
+
const config = useUiConfig<typeof pagination>(pagination!, 'pagination')
|
|
33
33
|
|
|
34
34
|
const emits = defineEmits(['update:modelValue'])
|
|
35
35
|
|
|
@@ -52,7 +52,7 @@ const props = defineProps({
|
|
|
52
52
|
},
|
|
53
53
|
size: {
|
|
54
54
|
type: String as PropType<ButtonSize>,
|
|
55
|
-
default: () => pagination
|
|
55
|
+
default: () => pagination!.default?.size,
|
|
56
56
|
},
|
|
57
57
|
class: {
|
|
58
58
|
type: [String, Object, Array] as PropType<any>,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ComputedRef } from 'vue';
|
|
2
|
+
import type { IFlexDeckOptions } from '#core/components/FlexDeck/types';
|
|
3
|
+
export declare const createFlexDeckOptions: <T = object>(repo: IUsePageLoader<T>, options: IFlexDeckOptions<T>) => IFlexDeckOptions<T>;
|
|
4
|
+
export declare const useFlexDeck: <T = object>(options: IUseTable<T>) => ComputedRef<IFlexDeckOptions<T>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { computed, useCoreConfig } from "#imports";
|
|
2
|
+
import { get } from "@vueuse/core";
|
|
3
|
+
export const createFlexDeckOptions = (repo, options) => {
|
|
4
|
+
const config = useCoreConfig();
|
|
5
|
+
return {
|
|
6
|
+
rawData: get(repo.fetchItems),
|
|
7
|
+
pageOptions: get(repo.fetchOptions),
|
|
8
|
+
status: get(repo.fetchStatus),
|
|
9
|
+
primary: get(repo.fetchOptions).primary ?? config.default_primary_key,
|
|
10
|
+
isPreventRouteChange: false,
|
|
11
|
+
...options
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export const useFlexDeck = (options) => computed(() => {
|
|
15
|
+
return createFlexDeckOptions(
|
|
16
|
+
options.repo,
|
|
17
|
+
typeof options.options === "function" ? options.options() : options.options ?? {}
|
|
18
|
+
);
|
|
19
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finema/core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.84",
|
|
4
4
|
"repository": "https://gitlab.finema.co/finema/ui-kit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Finema Dev Core Team",
|
|
@@ -75,15 +75,10 @@
|
|
|
75
75
|
"stylelint-config-prettier-scss": "^1.0.0",
|
|
76
76
|
"stylelint-config-standard-scss": "^13.0.0",
|
|
77
77
|
"vitest": "^1.2.2",
|
|
78
|
-
"vue": "3.4.
|
|
78
|
+
"vue": "^3.4.21"
|
|
79
79
|
},
|
|
80
80
|
"lint-staged": {
|
|
81
81
|
"*.{ts,vue,tsx,js}": "eslint --fix --cache",
|
|
82
82
|
"*.{html,json}": "prettier --write"
|
|
83
|
-
},
|
|
84
|
-
"pnpm": {
|
|
85
|
-
"overrides": {
|
|
86
|
-
"vue": "3.4.8"
|
|
87
|
-
}
|
|
88
83
|
}
|
|
89
84
|
}
|