@finema/core 1.4.24 → 1.4.26
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.d.mts +1 -0
- package/dist/module.d.ts +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Dialog/index.vue +13 -3
- package/dist/runtime/composables/useApp.mjs +3 -1
- package/dist/runtime/composables/useDialog.d.ts +1 -0
- package/dist/runtime/core.config.d.ts +1 -0
- package/dist/runtime/core.config.mjs +2 -1
- package/dist/runtime/types/config.d.ts +1 -1
- package/dist/runtime/ui.config/notification.d.ts +11 -0
- package/dist/runtime/ui.config/notification.mjs +9 -0
- package/dist/runtime/utils/ArrayHelper.d.ts +7 -0
- package/dist/runtime/utils/ArrayHelper.mjs +21 -0
- package/dist/runtime/utils/ArrayHelper.spec.d.ts +1 -0
- package/dist/runtime/utils/ArrayHelper.spec.mjs +112 -0
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -24,16 +24,19 @@
|
|
|
24
24
|
:color="getColor"
|
|
25
25
|
close-button=""
|
|
26
26
|
/>
|
|
27
|
-
<div :class="[
|
|
27
|
+
<div :class="[uiConfig.actionGroup.wrapper]">
|
|
28
28
|
<Button
|
|
29
29
|
v-if="dialog.meta?.isShowCancelBtn"
|
|
30
|
-
|
|
30
|
+
:color="uiConfig.actionGroup.cancelColor"
|
|
31
|
+
:variant="uiConfig.actionGroup.cancelVariant"
|
|
31
32
|
type="button"
|
|
32
33
|
@click="dialog.closeDialogCancel"
|
|
33
34
|
>
|
|
34
35
|
{{ dialog.meta?.cancelText || 'ยกเลิก' }}
|
|
35
36
|
</Button>
|
|
36
37
|
<Button
|
|
38
|
+
:color="uiConfig.actionGroup.confirmColor"
|
|
39
|
+
:variant="uiConfig.actionGroup.confirmVariant"
|
|
37
40
|
:class="[
|
|
38
41
|
{
|
|
39
42
|
'btn-success': dialog.meta?.type === DialogType.SUCCESS,
|
|
@@ -53,8 +56,11 @@
|
|
|
53
56
|
<script lang="tsx" setup>
|
|
54
57
|
import { DialogType, useDialog } from '#core/composables/useDialog'
|
|
55
58
|
import { computed } from 'vue'
|
|
59
|
+
import { useUiConfig } from '#core/composables/useConfig'
|
|
60
|
+
import { notification } from '#core/ui.config/notification'
|
|
56
61
|
|
|
57
62
|
const dialog = useDialog()
|
|
63
|
+
const uiConfig = useUiConfig<typeof notification>(notification, 'notification')
|
|
58
64
|
|
|
59
65
|
const getColor = computed(() => {
|
|
60
66
|
if (dialog.meta?.type === DialogType.SUCCESS) {
|
|
@@ -77,6 +83,10 @@ const getColor = computed(() => {
|
|
|
77
83
|
})
|
|
78
84
|
|
|
79
85
|
const getIcon = computed(() => {
|
|
86
|
+
if (dialog.meta?.isHideIcon) {
|
|
87
|
+
return ''
|
|
88
|
+
}
|
|
89
|
+
|
|
80
90
|
if (dialog.meta?.type === DialogType.SUCCESS) {
|
|
81
91
|
return 'i-heroicons-check-circle'
|
|
82
92
|
}
|
|
@@ -90,7 +100,7 @@ const getIcon = computed(() => {
|
|
|
90
100
|
}
|
|
91
101
|
|
|
92
102
|
if (dialog.meta?.type === DialogType.WARNING) {
|
|
93
|
-
return 'i-heroicons-
|
|
103
|
+
return 'i-heroicons-exclamation-circle'
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
return ''
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useSeoMeta } from "#imports";
|
|
1
|
+
import { useCoreConfig, useSeoMeta } from "#imports";
|
|
2
2
|
import { defineStore } from "pinia";
|
|
3
3
|
export const useApp = defineStore("_app", {
|
|
4
4
|
state: () => ({
|
|
@@ -16,8 +16,10 @@ export const useApp = defineStore("_app", {
|
|
|
16
16
|
this.sidebar = items;
|
|
17
17
|
},
|
|
18
18
|
defineSEO(payload) {
|
|
19
|
+
const coreConfig = useCoreConfig();
|
|
19
20
|
useSeoMeta({
|
|
20
21
|
title: payload.title,
|
|
22
|
+
titleTemplate: (title) => title ? `${title} | ${coreConfig.site_name}` : coreConfig.site_name,
|
|
21
23
|
ogTitle: payload.title,
|
|
22
24
|
description: payload.description,
|
|
23
25
|
ogDescription: payload.description,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type UIComponentList = 'modal' | 'slideover' | 'dropdown' | 'icon' | 'button' | 'buttonGroup' | 'tabs' | 'card' | 'breadcrumb' | 'badge' | 'input' | 'pagination';
|
|
1
|
+
export type UIComponentList = 'modal' | 'slideover' | 'dropdown' | 'icon' | 'button' | 'buttonGroup' | 'tabs' | 'card' | 'breadcrumb' | 'badge' | 'input' | 'pagination' | 'notification';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DeepPartial } from '#ui/types';
|
|
2
|
+
import type * as config from '#ui/ui.config';
|
|
3
|
+
export declare const notification: DeepPartial<(typeof config)['notification'] & {
|
|
4
|
+
actionGroup: {
|
|
5
|
+
wrapper: string;
|
|
6
|
+
cancelColor: string;
|
|
7
|
+
cancelVariant: string;
|
|
8
|
+
confirmColor: string;
|
|
9
|
+
confirmVariant: string;
|
|
10
|
+
};
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type IOption } from '../types/common';
|
|
2
|
+
export declare class ArrayHelper {
|
|
3
|
+
static toOptions(data: any[], valueAttr?: string, labelAttr?: string): IOption[];
|
|
4
|
+
static toArray<T>(value: any): Array<T | any>;
|
|
5
|
+
static isEmpty(value: any): boolean;
|
|
6
|
+
static create: (length: number) => any[];
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { _get } from "../utils/lodash.mjs";
|
|
2
|
+
export class ArrayHelper {
|
|
3
|
+
static toOptions(data, valueAttr = "id", labelAttr = "name") {
|
|
4
|
+
return ArrayHelper.toArray(data).map((item) => {
|
|
5
|
+
const value = _get(item, valueAttr, null);
|
|
6
|
+
return {
|
|
7
|
+
value: value || null,
|
|
8
|
+
label: _get(item, labelAttr, value)
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
static toArray(value) {
|
|
13
|
+
return Array.from(value || []);
|
|
14
|
+
}
|
|
15
|
+
static isEmpty(value) {
|
|
16
|
+
return ArrayHelper.toArray(value).length === 0;
|
|
17
|
+
}
|
|
18
|
+
static create = (length) => {
|
|
19
|
+
return Array(...Array(length));
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { describe, test, expect } from "vitest";
|
|
2
|
+
import { ArrayHelper } from "./ArrayHelper.mjs";
|
|
3
|
+
describe("ArrayHelper", () => {
|
|
4
|
+
test("toOptions default attr", () => {
|
|
5
|
+
const data = [
|
|
6
|
+
{
|
|
7
|
+
id: "1",
|
|
8
|
+
name: "long"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: "2",
|
|
12
|
+
name: "long2"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: "3",
|
|
16
|
+
name: "long3"
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
expect(ArrayHelper.toOptions(data)).toEqual([
|
|
20
|
+
{
|
|
21
|
+
value: "1",
|
|
22
|
+
label: "long"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: "2",
|
|
26
|
+
label: "long2"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: "3",
|
|
30
|
+
label: "long3"
|
|
31
|
+
}
|
|
32
|
+
]);
|
|
33
|
+
});
|
|
34
|
+
test("toOptions custom attr", () => {
|
|
35
|
+
const data = [
|
|
36
|
+
{
|
|
37
|
+
ide: "1",
|
|
38
|
+
wtf: "long"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
ide: "2",
|
|
42
|
+
wtf: "long2"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
ide: "3",
|
|
46
|
+
wtf: "long3"
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
expect(ArrayHelper.toOptions(data, "ide", "wtf")).toEqual([
|
|
50
|
+
{
|
|
51
|
+
value: "1",
|
|
52
|
+
label: "long"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
value: "2",
|
|
56
|
+
label: "long2"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
value: "3",
|
|
60
|
+
label: "long3"
|
|
61
|
+
}
|
|
62
|
+
]);
|
|
63
|
+
});
|
|
64
|
+
test("toOptions custom attr nested", () => {
|
|
65
|
+
const data = [
|
|
66
|
+
{
|
|
67
|
+
ide: "1",
|
|
68
|
+
wtf: {
|
|
69
|
+
ed: "long"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
ide: "2",
|
|
74
|
+
wtf: {
|
|
75
|
+
ed: "long2"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
ide: "3",
|
|
80
|
+
wtf: "eiei"
|
|
81
|
+
},
|
|
82
|
+
{}
|
|
83
|
+
];
|
|
84
|
+
expect(ArrayHelper.toOptions(data, "ide", "wtf.ed")).toEqual([
|
|
85
|
+
{
|
|
86
|
+
value: "1",
|
|
87
|
+
label: "long"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
value: "2",
|
|
91
|
+
label: "long2"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
value: "3",
|
|
95
|
+
label: "3"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
value: null,
|
|
99
|
+
label: null
|
|
100
|
+
}
|
|
101
|
+
]);
|
|
102
|
+
});
|
|
103
|
+
test("toArray", () => {
|
|
104
|
+
expect(ArrayHelper.toArray(null)).toEqual([]);
|
|
105
|
+
expect(ArrayHelper.toArray([])).toEqual([]);
|
|
106
|
+
expect(ArrayHelper.toArray("")).toEqual([]);
|
|
107
|
+
expect(ArrayHelper.toArray(false)).toEqual([]);
|
|
108
|
+
expect(ArrayHelper.toArray(true)).toEqual([]);
|
|
109
|
+
expect(ArrayHelper.toArray({})).toEqual([]);
|
|
110
|
+
expect(ArrayHelper.toArray([1, 2, 3])).toEqual([1, 2, 3]);
|
|
111
|
+
});
|
|
112
|
+
});
|