@finema/core 1.4.22 → 1.4.23

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/README.md CHANGED
@@ -8,6 +8,9 @@
8
8
  - Useful composables
9
9
  - Security
10
10
 
11
+ ## Remark
12
+ - Temporary use resolutions for vue 3.3.13 instead of ^3.4.0 due to [this issue](https://github.com/nuxt/ui/issues/1171) and planned to be fixed in the next vue 3.5 version.
13
+
11
14
  ## Quick Setup
12
15
 
13
16
  1. Add `@finema/core` dependency to your project
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "1.4.22",
3
+ "version": "1.4.23",
4
4
  "configKey": "core",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.7.4"
package/dist/module.mjs CHANGED
@@ -2,7 +2,7 @@ import { defineNuxtModule, createResolver, installModule, addPlugin, addComponen
2
2
  import 'lodash-es';
3
3
 
4
4
  const name = "@finema/core";
5
- const version = "1.4.22";
5
+ const version = "1.4.23";
6
6
 
7
7
  const colors = {
8
8
  black: "#20243E",
@@ -89,6 +89,7 @@ const _deepMerge = (target, ...sources) => {
89
89
  const pagination = {
90
90
  wrapper: "flex items-center space-x-1",
91
91
  default: {
92
+ size: "sm",
92
93
  activeButton: {
93
94
  color: "primary",
94
95
  class: "rounded-md px-3"
@@ -111,11 +112,13 @@ const pagination = {
111
112
  prevButton: {
112
113
  color: "primary",
113
114
  variant: "ghost",
115
+ icon: "i-heroicons-chevron-left-20-solid",
114
116
  class: "rtl:[&_span:first-child]:rotate-180 rounded-md px-2 text-gray-500 hover:bg-primary-500 hover:text-white"
115
117
  },
116
118
  nextButton: {
117
119
  color: "primary",
118
120
  variant: "ghost",
121
+ icon: "i-heroicons-chevron-right-20-solid",
119
122
  class: "rtl:[&_span:last-child]:rotate-180 rounded-md px-2 text-gray-500 hover:bg-primary-500 hover:text-white"
120
123
  }
121
124
  }
@@ -1,6 +1,5 @@
1
1
  <template>
2
2
  <UDropdown
3
- v-if="renderOnMounted"
4
3
  v-bind="attrs"
5
4
  :class="$props.class"
6
5
  :items="items"
@@ -19,7 +18,7 @@
19
18
  </template>
20
19
 
21
20
  <script lang="ts" setup>
22
- import { type PropType, ref, onMounted, useUiConfig, useUI, toRef } from '#imports'
21
+ import { type PropType, useUiConfig, useUI, toRef } from '#imports'
23
22
  import { type DropdownItem } from '#ui/types'
24
23
  import type { Strategy } from '#core/types/utils'
25
24
  import { dropdown } from '#ui/ui.config'
@@ -68,14 +67,5 @@ const props = defineProps({
68
67
  },
69
68
  })
70
69
 
71
- const renderOnMounted = ref(false)
72
-
73
- onMounted(() => {
74
- renderOnMounted.value = true
75
- ui.value.item.avatar = {
76
- base: 'flex-shrink-0',
77
- } as any
78
- })
79
-
80
70
  const { ui, attrs } = useUI('dropdown', toRef(props, 'ui'), config, toRef(props, 'class'))
81
71
  </script>
@@ -1,4 +1,14 @@
1
1
  <template>
2
- <UIcon name="i-svg-spinners:180-ring-with-bg" class="text-primary text-4xl" dynamic />
2
+ <div v-if="isLoading" class="flex min-h-[200px] items-center justify-center">
3
+ <UIcon name="i-svg-spinners:180-ring-with-bg" class="text-primary text-4xl" dynamic />
4
+ </div>
5
+ <slot v-else />
3
6
  </template>
4
- <script lang="ts" setup></script>
7
+ <script lang="ts" setup>
8
+ defineProps({
9
+ isLoading: {
10
+ type: Boolean,
11
+ default: true,
12
+ },
13
+ })
14
+ </script>
@@ -0,0 +1,96 @@
1
+ <template>
2
+ <div>
3
+ <Button
4
+ :size="size"
5
+ :disabled="!canGoFirstOrPrev || disabled"
6
+ :class="[ui.base, ui.rounded]"
7
+ v-bind="{ ...((ui.default?.prevButton as object) || {}) }"
8
+ :ui="{ rounded: '' }"
9
+ aria-label="Prev"
10
+ @click="onClickPrev"
11
+ />
12
+
13
+ <Button
14
+ :size="size"
15
+ :disabled="!canGoLastOrNext || disabled"
16
+ :class="[ui.base, ui.rounded]"
17
+ v-bind="{ ...((ui.default?.nextButton as object) || {}) }"
18
+ :ui="{ rounded: '' }"
19
+ aria-label="Next"
20
+ @click="onClickNext"
21
+ />
22
+ </div>
23
+ </template>
24
+
25
+ <script lang="ts" setup>
26
+ import { useUiConfig } from '../composables/useConfig'
27
+ import { pagination } from '#core/ui.config'
28
+ import { type ButtonSize } from '#ui/types'
29
+ import { useUI, type PropType, toRef, computed } from '#imports'
30
+ import { type Strategy } from '../types/utils'
31
+
32
+ const config = useUiConfig<typeof pagination>(pagination, 'pagination')
33
+
34
+ const emits = defineEmits(['update:modelValue'])
35
+
36
+ const props = defineProps({
37
+ modelValue: {
38
+ type: Number,
39
+ required: true,
40
+ },
41
+ pageCount: {
42
+ type: Number,
43
+ default: 10,
44
+ },
45
+ total: {
46
+ type: Number,
47
+ required: true,
48
+ },
49
+ disabled: {
50
+ type: Boolean,
51
+ default: false,
52
+ },
53
+ size: {
54
+ type: String as PropType<ButtonSize>,
55
+ default: () => pagination.default?.size,
56
+ },
57
+ class: {
58
+ type: [String, Object, Array] as PropType<any>,
59
+ default: () => '',
60
+ },
61
+ ui: {
62
+ type: Object as PropType<Partial<typeof config> & { strategy?: Strategy }>,
63
+ default: () => ({}),
64
+ },
65
+ })
66
+
67
+ const { ui } = useUI('pagination', toRef(props, 'ui'), config, toRef(props, 'class'))
68
+
69
+ const currentPage = computed({
70
+ get() {
71
+ return props.modelValue
72
+ },
73
+ set(value: number) {
74
+ emits('update:modelValue', value)
75
+ },
76
+ })
77
+
78
+ const pages = computed(() =>
79
+ Array.from({ length: Math.ceil(props.total / props.pageCount) }, (_, i) => i + 1)
80
+ )
81
+
82
+ const canGoFirstOrPrev = computed(() => currentPage.value > 1)
83
+ const canGoLastOrNext = computed(() => currentPage.value < pages.value.length)
84
+
85
+ const onClickPrev = () => {
86
+ if (canGoFirstOrPrev.value) {
87
+ currentPage.value--
88
+ }
89
+ }
90
+
91
+ const onClickNext = () => {
92
+ if (canGoLastOrNext.value) {
93
+ currentPage.value++
94
+ }
95
+ }
96
+ </script>
@@ -52,7 +52,13 @@
52
52
  ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
53
53
  </p>
54
54
  <UPagination
55
- v-if="pageOptions.totalPage > 1"
55
+ v-if="pageOptions.totalPage > 1 && !isSimplePagination"
56
+ v-model="page"
57
+ :page-count="pageOptions.limit"
58
+ :total="pageOptions.totalCount"
59
+ />
60
+ <SimplePagination
61
+ v-if="pageOptions.totalPage > 1 && isSimplePagination"
56
62
  v-model="page"
57
63
  :page-count="pageOptions.limit"
58
64
  :total="pageOptions.totalCount"
@@ -88,6 +94,10 @@ const props = defineProps({
88
94
  type: Array as PropType<ITableOptions['rawData']>,
89
95
  required: true,
90
96
  },
97
+ isSimplePagination: {
98
+ type: Boolean as PropType<ITableOptions['isSimplePagination']>,
99
+ default: false,
100
+ },
91
101
  })
92
102
 
93
103
  const page = ref(props.pageOptions?.currentPage || 1)
@@ -13,6 +13,7 @@
13
13
  :raw-data="options.rawData"
14
14
  :status="options.status"
15
15
  :page-options="options.pageOptions"
16
+ :is-simple-pagination="options.isSimplePagination"
16
17
  @page-change="onPageChange"
17
18
  >
18
19
  <template v-for="(_, slot) of $slots" #[slot]="slotProps">
@@ -45,7 +45,8 @@ export interface ITableOptions<T = object> extends IBaseTableOptions<T> {
45
45
  deleteStatus?: IStatus;
46
46
  isHideBottomPagination?: boolean;
47
47
  isHideTopPagination?: boolean;
48
- isNotChangeRoute: boolean;
48
+ isSimplePagination?: boolean;
49
+ isPreventRouteChange: boolean;
49
50
  }
50
51
  export interface ISimpleTableOptions<T = object> extends IBaseTableOptions<T> {
51
52
  limit?: number;
@@ -1 +1 @@
1
- export type UIComponentList = 'modal' | 'slideover' | 'dropdown' | 'icon' | 'button' | 'buttonGroup' | 'tabs' | 'card' | 'breadcrumb' | 'badge' | 'input';
1
+ export type UIComponentList = 'modal' | 'slideover' | 'dropdown' | 'icon' | 'button' | 'buttonGroup' | 'tabs' | 'card' | 'breadcrumb' | 'badge' | 'input' | 'pagination';
@@ -1,3 +1,3 @@
1
1
  import type * as config from '#ui/ui.config';
2
2
  import type { DeepPartial } from '#ui/types';
3
- export declare const pagination: DeepPartial<(typeof config)['pagination']>;
3
+ export declare const pagination: DeepPartial<typeof config>['pagination'];
@@ -1,6 +1,7 @@
1
1
  export const pagination = {
2
2
  wrapper: "flex items-center space-x-1",
3
3
  default: {
4
+ size: "sm",
4
5
  activeButton: {
5
6
  color: "primary",
6
7
  class: "rounded-md px-3"
@@ -23,11 +24,13 @@ export const pagination = {
23
24
  prevButton: {
24
25
  color: "primary",
25
26
  variant: "ghost",
27
+ icon: "i-heroicons-chevron-left-20-solid",
26
28
  class: "rtl:[&_span:first-child]:rotate-180 rounded-md px-2 text-gray-500 hover:bg-primary-500 hover:text-white"
27
29
  },
28
30
  nextButton: {
29
31
  color: "primary",
30
32
  variant: "ghost",
33
+ icon: "i-heroicons-chevron-right-20-solid",
31
34
  class: "rtl:[&_span:last-child]:rotate-180 rounded-md px-2 text-gray-500 hover:bg-primary-500 hover:text-white"
32
35
  }
33
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "1.4.22",
3
+ "version": "1.4.23",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@nuxt/kit": "^3.7.4",
37
- "@nuxt/ui": "^2.12.0",
37
+ "@nuxt/ui": "^2.12.3",
38
38
  "@pinia/nuxt": "^0.5.1",
39
39
  "@vee-validate/nuxt": "^4.12.4",
40
40
  "@vee-validate/zod": "^4.12.4",
@@ -76,6 +76,9 @@
76
76
  "stylelint-config-standard-scss": "^13.0.0",
77
77
  "vitest": "^1.1.3"
78
78
  },
79
+ "resolutions": {
80
+ "vue": "3.3.13"
81
+ },
79
82
  "lint-staged": {
80
83
  "*.{ts,vue,tsx,js}": "eslint --fix --cache",
81
84
  "*.{html,json}": "prettier --write"