@finema/core 1.4.120 → 1.4.122

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "1.4.120",
3
+ "version": "1.4.122",
4
4
  "configKey": "core",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.7.4"
package/dist/module.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineNuxtModule, createResolver, installModule, addPlugin, addComponentsDir, addImportsDir } from '@nuxt/kit';
2
2
 
3
3
  const name = "@finema/core";
4
- const version = "1.4.120";
4
+ const version = "1.4.122";
5
5
 
6
6
  const colors = {
7
7
  black: "#20243E",
@@ -1,18 +1,31 @@
1
1
  <template>
2
- <slot v-if="status.isLoading" name="loading-state">
3
- <div class="flex h-60 items-center justify-center">
4
- <Icon name="i-svg-spinners:180-ring-with-bg" class="text-primary size-8" />
5
- </div>
6
- </slot>
7
2
  <slot v-if="!status.isLoading && rawData.length === 0" name="empty-state">
8
3
  <div class="min-h-60">
9
4
  <p class="text-center text-sm italic">ไม่พบข้อมูล!</p>
10
5
  </div>
11
6
  </slot>
12
- <div v-if="status.isSuccess" :class="containerClass">
13
- <slot v-for="(row, index) in rawData" :key="index" :row="row" />
7
+
8
+ <div
9
+ v-if="pageOptions && isEnableInfiniteScroll && !isHideTopPagination"
10
+ class="mb-4 flex items-center justify-end"
11
+ >
12
+ <p class="text-xs text-gray-500">
13
+ ผลลัพธ์ {{ totalInnerRawData }} ของ {{ totalCountWithComma }} รายการ
14
+ </p>
14
15
  </div>
15
- <div v-if="pageOptions" class="mt-4 flex justify-between px-3">
16
+
17
+ <div :class="containerClass">
18
+ <slot v-for="(row, index) in innerRawData" :key="index" :row="row" />
19
+ <div ref="bottomEdgeElement" />
20
+ </div>
21
+
22
+ <slot v-if="status.isLoading" name="loading-state">
23
+ <div class="flex h-60 items-center justify-center">
24
+ <Icon name="i-svg-spinners:180-ring-with-bg" class="text-primary size-8" />
25
+ </div>
26
+ </slot>
27
+
28
+ <div v-if="pageOptions && !isEnableInfiniteScroll" class="mt-4 flex justify-between px-3">
16
29
  <p class="text-xs text-gray-500">
17
30
  ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
18
31
  </p>
@@ -33,8 +46,9 @@
33
46
 
34
47
  <script lang="ts" setup>
35
48
  import { computed, type PropType } from 'vue'
49
+ import { useElementVisibility } from '@vueuse/core'
36
50
  import { StringHelper } from '#core/utils/StringHelper'
37
- import { ref, watch } from '#imports'
51
+ import { ref, useWatchTrue, watch } from '#imports'
38
52
  import type { IFlexDeckOptions } from '#core/components/FlexDeck/types'
39
53
 
40
54
  const emits = defineEmits(['pageChange'])
@@ -56,15 +70,29 @@ const props = defineProps({
56
70
  type: Boolean as PropType<IFlexDeckOptions['isSimplePagination']>,
57
71
  default: false,
58
72
  },
73
+ isHideTopPagination: {
74
+ type: Boolean as PropType<IFlexDeckOptions['isHideTopPagination']>,
75
+ default: false,
76
+ },
59
77
  isHideBottomPagination: {
60
78
  type: Boolean as PropType<IFlexDeckOptions['isHideBottomPagination']>,
61
79
  default: false,
62
80
  },
81
+ isEnableInfiniteScroll: {
82
+ type: Boolean as PropType<IFlexDeckOptions['isEnableInfiniteScroll']>,
83
+ default: false,
84
+ },
63
85
  containerClass: { type: [String, Array, Object] },
64
86
  })
65
87
 
88
+ const bottomEdgeElement = ref<HTMLElement | null>(null)
89
+
66
90
  const page = ref(props.pageOptions?.currentPage || 1)
67
91
 
92
+ const innerRawData = ref<object[]>([])
93
+
94
+ const targetElement = useElementVisibility(bottomEdgeElement)
95
+
68
96
  const pageBetween = computed((): string => {
69
97
  const length = props.rawData?.length
70
98
 
@@ -84,7 +112,26 @@ const totalCountWithComma = computed((): string => {
84
112
  : StringHelper.withComma(props.pageOptions!.totalCount)
85
113
  })
86
114
 
115
+ const totalInnerRawData = computed((): number => {
116
+ return innerRawData.value?.length || 0
117
+ })
118
+
119
+ useWatchTrue(
120
+ () => props.status.isSuccess,
121
+ () => {
122
+ innerRawData.value = [...(innerRawData.value || []), ...props.rawData]
123
+ }
124
+ )
125
+
87
126
  watch(page, () => {
88
127
  emits('pageChange', page.value)
89
128
  })
129
+
130
+ watch(targetElement, (value) => {
131
+ if (props.status.isLoading || !props.isEnableInfiniteScroll) return
132
+
133
+ if (page.value < props.pageOptions!.totalPage && value) {
134
+ page.value++
135
+ }
136
+ })
90
137
  </script>
@@ -12,7 +12,9 @@
12
12
  :status="options.status"
13
13
  :page-options="options.pageOptions"
14
14
  :is-simple-pagination="isShowSimplePagination"
15
+ :is-hide-top-pagination="options.isHideTopPagination"
15
16
  :is-hide-bottom-pagination="options.isHideBottomPagination"
17
+ :is-enable-infinite-scroll="options.isEnableInfiniteScroll"
16
18
  :container-class="containerClass"
17
19
  @page-change="onPageChange"
18
20
  >
@@ -11,4 +11,5 @@ export interface IFlexDeckOptions<T = object> {
11
11
  isHideBottomPagination?: boolean;
12
12
  isHideTopPagination?: boolean;
13
13
  isSimplePagination?: boolean;
14
+ isEnableInfiniteScroll?: boolean;
14
15
  }
@@ -1,7 +1,24 @@
1
+ import type { NotificationAction, NotificationColor } from '#ui/types/notification';
2
+ import type { Avatar } from '#ui/types/avatar';
3
+ import type { Button } from '#ui/types/button';
4
+ export interface INotification {
5
+ id: string;
6
+ title: string;
7
+ description?: string;
8
+ icon?: string;
9
+ avatar?: Avatar;
10
+ closeButton?: Button;
11
+ timeout: number;
12
+ actions?: NotificationAction[];
13
+ click?: Function;
14
+ callback?: Function;
15
+ color?: NotificationColor;
16
+ ui?: any;
17
+ }
1
18
  export declare const useNotification: () => {
2
- info: (notification: UNotification) => void;
3
- success: (notification: UNotification) => void;
4
- warning: (notification: UNotification) => void;
5
- error: (notification: UNotification) => void;
19
+ info: (notification: Partial<INotification>) => void;
20
+ success: (notification: Partial<INotification>) => void;
21
+ warning: (notification: Partial<INotification>) => void;
22
+ error: (notification: Partial<INotification>) => void;
6
23
  remove: any;
7
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "1.4.120",
3
+ "version": "1.4.122",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",
@@ -88,5 +88,5 @@
88
88
  "workspaces": [
89
89
  "./*"
90
90
  ],
91
- "packageManager": "yarn@4.1.1"
91
+ "packageManager": "yarn@4.2.2"
92
92
  }