@finema/core 2.61.1 → 3.0.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.
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Form/Fields.vue +5 -0
- package/dist/runtime/components/Form/InputCurrency/index.d.vue.ts +13 -0
- package/dist/runtime/components/Form/InputCurrency/index.vue +119 -0
- package/dist/runtime/components/Form/InputCurrency/index.vue.d.ts +13 -0
- package/dist/runtime/components/Form/InputCurrency/types.d.ts +23 -0
- package/dist/runtime/components/Form/InputCurrency/types.js +0 -0
- package/dist/runtime/components/Form/InputNumber/index.d.vue.ts +2 -0
- package/dist/runtime/components/Form/InputNumber/index.vue +4 -4
- package/dist/runtime/components/Form/InputNumber/index.vue.d.ts +2 -0
- package/dist/runtime/components/Form/InputNumber/types.d.ts +3 -3
- package/dist/runtime/components/Form/InputSelect/types.d.ts +1 -1
- package/dist/runtime/components/Form/types.d.ts +3 -1
- package/dist/runtime/components/Form/types.js +1 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -25,6 +25,7 @@ import FormInputTextarea from "./InputTextarea/index.vue";
|
|
|
25
25
|
import FormInputText from "./InputText/index.vue";
|
|
26
26
|
import FormInputSearch from "./InputSearch/index.vue";
|
|
27
27
|
import FormInputNumber from "./InputNumber/index.vue";
|
|
28
|
+
import FormInputCurrency from "./InputCurrency/index.vue";
|
|
28
29
|
import FormInputToggle from "./InputToggle/index.vue";
|
|
29
30
|
import FormInputCheckbox from "./InputCheckbox/index.vue";
|
|
30
31
|
import FormInputSelect from "./InputSelect/index.vue";
|
|
@@ -89,6 +90,10 @@ const componentMap = {
|
|
|
89
90
|
props: {}
|
|
90
91
|
},
|
|
91
92
|
// Example: Map to FormInputText or a specific Number input if exists
|
|
93
|
+
[INPUT_TYPES.CURRENCY]: {
|
|
94
|
+
component: FormInputCurrency,
|
|
95
|
+
props: {}
|
|
96
|
+
},
|
|
92
97
|
[INPUT_TYPES.PASSWORD]: {
|
|
93
98
|
component: FormInputText,
|
|
94
99
|
props: {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ICurrencyFieldProps } from '#core/components/Form/InputCurrency/types';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<ICurrencyFieldProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
|
+
change: (...args: any[]) => void;
|
|
4
|
+
}, string, import("vue").PublicProps, Readonly<ICurrencyFieldProps> & Readonly<{
|
|
5
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
6
|
+
}>, {
|
|
7
|
+
step: number;
|
|
8
|
+
options: import("#core/components/Form/InputCurrency/types").SelectOption[];
|
|
9
|
+
disableWheelChange: boolean;
|
|
10
|
+
defaultCurrency: string;
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper
|
|
3
|
+
v-bind="wrapperProps"
|
|
4
|
+
:error-message="undefined"
|
|
5
|
+
>
|
|
6
|
+
<div
|
|
7
|
+
:class="['inline-flex w-full items-center -space-x-px rounded-lg ring-1', {
|
|
8
|
+
'ring-error': wrapperProps.errorMessage,
|
|
9
|
+
'ring-gray-300': !wrapperProps.errorMessage
|
|
10
|
+
}]"
|
|
11
|
+
>
|
|
12
|
+
<p class="pl-3 text-lg">
|
|
13
|
+
{{ currencySymbol }}
|
|
14
|
+
</p>
|
|
15
|
+
<InputNumber
|
|
16
|
+
:model-value="value.value"
|
|
17
|
+
:disabled="wrapperProps.disabled"
|
|
18
|
+
:name="name"
|
|
19
|
+
:placeholder="wrapperProps.placeholder"
|
|
20
|
+
:autofocus="!!autoFocus"
|
|
21
|
+
:readonly="readonly"
|
|
22
|
+
:min="min"
|
|
23
|
+
:max="max"
|
|
24
|
+
:step="step"
|
|
25
|
+
:format-options="formatOptions"
|
|
26
|
+
:increment="false"
|
|
27
|
+
:decrement="false"
|
|
28
|
+
variant="none"
|
|
29
|
+
@update:model-value="onAmountChange"
|
|
30
|
+
/>
|
|
31
|
+
<Select
|
|
32
|
+
:model-value="value.currency"
|
|
33
|
+
:items="options"
|
|
34
|
+
:disabled="wrapperProps.disabled"
|
|
35
|
+
value-key="value"
|
|
36
|
+
label-key="label"
|
|
37
|
+
variant="none"
|
|
38
|
+
size="xl"
|
|
39
|
+
class="cursor-pointer"
|
|
40
|
+
@update:model-value="onCurrencyChange"
|
|
41
|
+
>
|
|
42
|
+
<template #default="{ modelValue }">
|
|
43
|
+
{{ options.find((item) => item.value === modelValue)?.label || modelValue }}
|
|
44
|
+
</template>
|
|
45
|
+
</Select>
|
|
46
|
+
</div>
|
|
47
|
+
<p
|
|
48
|
+
v-if="wrapperProps.errorMessage"
|
|
49
|
+
class="text-error mt-2"
|
|
50
|
+
>
|
|
51
|
+
{{ wrapperProps.errorMessage }}
|
|
52
|
+
</p>
|
|
53
|
+
</FieldWrapper>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script setup>
|
|
57
|
+
import { computed } from "vue";
|
|
58
|
+
import FieldWrapper from "#core/components/Form/FieldWrapper.vue";
|
|
59
|
+
import { useFieldHOC } from "#core/composables/useForm";
|
|
60
|
+
const emits = defineEmits(["change"]);
|
|
61
|
+
const props = defineProps({
|
|
62
|
+
min: { type: Number, required: false },
|
|
63
|
+
max: { type: Number, required: false },
|
|
64
|
+
step: { type: Number, required: false, default: 0.01 },
|
|
65
|
+
options: { type: Array, required: false, default: () => [
|
|
66
|
+
{
|
|
67
|
+
value: "THB",
|
|
68
|
+
label: "THB",
|
|
69
|
+
symbol: "\u0E3F"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
value: "USD",
|
|
73
|
+
label: "USD",
|
|
74
|
+
symbol: "$"
|
|
75
|
+
}
|
|
76
|
+
] },
|
|
77
|
+
defaultCurrency: { type: String, required: false, default: "THB" },
|
|
78
|
+
formatOptions: { type: null, required: false },
|
|
79
|
+
disableWheelChange: { type: Boolean, required: false, default: false },
|
|
80
|
+
form: { type: Object, required: false },
|
|
81
|
+
name: { type: String, required: true },
|
|
82
|
+
errorMessage: { type: String, required: false },
|
|
83
|
+
label: { type: null, required: false },
|
|
84
|
+
description: { type: String, required: false },
|
|
85
|
+
hint: { type: String, required: false },
|
|
86
|
+
rules: { type: null, required: false },
|
|
87
|
+
autoFocus: { type: Boolean, required: false },
|
|
88
|
+
placeholder: { type: String, required: false },
|
|
89
|
+
disabled: { type: Boolean, required: false },
|
|
90
|
+
readonly: { type: Boolean, required: false },
|
|
91
|
+
required: { type: Boolean, required: false },
|
|
92
|
+
help: { type: String, required: false },
|
|
93
|
+
ui: { type: null, required: false }
|
|
94
|
+
});
|
|
95
|
+
const {
|
|
96
|
+
value,
|
|
97
|
+
wrapperProps,
|
|
98
|
+
handleChange
|
|
99
|
+
} = useFieldHOC(props);
|
|
100
|
+
const currencySymbol = computed(() => props.options.find((item) => item.value === value.value.currency)?.symbol);
|
|
101
|
+
const updateValue = (payload) => {
|
|
102
|
+
const newValue = {
|
|
103
|
+
...value.value,
|
|
104
|
+
...payload
|
|
105
|
+
};
|
|
106
|
+
handleChange(newValue);
|
|
107
|
+
emits("change", newValue);
|
|
108
|
+
};
|
|
109
|
+
const onAmountChange = (newAmount) => {
|
|
110
|
+
updateValue({
|
|
111
|
+
value: newAmount
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
const onCurrencyChange = (newCurrency) => {
|
|
115
|
+
updateValue({
|
|
116
|
+
currency: newCurrency
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ICurrencyFieldProps } from '#core/components/Form/InputCurrency/types';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<ICurrencyFieldProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
|
+
change: (...args: any[]) => void;
|
|
4
|
+
}, string, import("vue").PublicProps, Readonly<ICurrencyFieldProps> & Readonly<{
|
|
5
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
6
|
+
}>, {
|
|
7
|
+
step: number;
|
|
8
|
+
options: import("#core/components/Form/InputCurrency/types").SelectOption[];
|
|
9
|
+
disableWheelChange: boolean;
|
|
10
|
+
defaultCurrency: string;
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IFieldProps, IFormFieldBase, INPUT_TYPES } from '#core/components/Form/types';
|
|
2
|
+
import type { SelectMenuItem } from '@nuxt/ui';
|
|
3
|
+
export type SelectOption = SelectMenuItem & {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
symbol: string;
|
|
7
|
+
};
|
|
8
|
+
export interface ICurrencyValue {
|
|
9
|
+
value: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ICurrencyFieldProps extends IFieldProps {
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
step?: number;
|
|
16
|
+
options?: SelectOption[];
|
|
17
|
+
defaultCurrency?: string;
|
|
18
|
+
formatOptions?: Intl.NumberFormatOptions;
|
|
19
|
+
disableWheelChange?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export type ICurrencyField = IFormFieldBase<INPUT_TYPES.CURRENCY, ICurrencyFieldProps, {
|
|
22
|
+
change?: (value: ICurrencyValue) => void;
|
|
23
|
+
}>;
|
|
File without changes
|
|
@@ -5,6 +5,8 @@ declare const __VLS_export: import("vue").DefineComponent<INumberFieldProps, {},
|
|
|
5
5
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
6
6
|
}>, {
|
|
7
7
|
orientation: "horizontal" | "vertical";
|
|
8
|
+
increment: boolean | import("@nuxt/ui").ButtonProps;
|
|
9
|
+
decrement: boolean | import("@nuxt/ui").ButtonProps;
|
|
8
10
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
11
|
declare const _default: typeof __VLS_export;
|
|
10
12
|
export default _default;
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
:autofocus="!!autoFocus"
|
|
9
9
|
:readonly="readonly"
|
|
10
10
|
:orientation="orientation"
|
|
11
|
-
:increment
|
|
12
|
-
:decrement
|
|
11
|
+
:increment="increment"
|
|
12
|
+
:decrement="decrement"
|
|
13
13
|
:min="min"
|
|
14
14
|
:max="max"
|
|
15
15
|
:step="step"
|
|
@@ -27,8 +27,8 @@ import FieldWrapper from "#core/components/Form/FieldWrapper.vue";
|
|
|
27
27
|
const emits = defineEmits(["change"]);
|
|
28
28
|
const props = defineProps({
|
|
29
29
|
orientation: { type: String, required: false, default: "vertical" },
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
increment: { type: Boolean, required: false, skipCheck: true, default: false },
|
|
31
|
+
decrement: { type: Boolean, required: false, skipCheck: true, default: false },
|
|
32
32
|
min: { type: Number, required: false },
|
|
33
33
|
max: { type: Number, required: false },
|
|
34
34
|
step: { type: Number, required: false },
|
|
@@ -5,6 +5,8 @@ declare const __VLS_export: import("vue").DefineComponent<INumberFieldProps, {},
|
|
|
5
5
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
6
6
|
}>, {
|
|
7
7
|
orientation: "horizontal" | "vertical";
|
|
8
|
+
increment: boolean | import("@nuxt/ui").ButtonProps;
|
|
9
|
+
decrement: boolean | import("@nuxt/ui").ButtonProps;
|
|
8
10
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
11
|
declare const _default: typeof __VLS_export;
|
|
10
12
|
export default _default;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { IFieldProps, IFormFieldBase, INPUT_TYPES } from '#core/components/Form/types';
|
|
2
|
-
import type { InputNumberProps } from '
|
|
2
|
+
import type { InputNumberProps } from '@nuxt/ui';
|
|
3
3
|
export interface INumberFieldProps extends IFieldProps {
|
|
4
4
|
orientation?: InputNumberProps['orientation'];
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
increment?: InputNumberProps['increment'];
|
|
6
|
+
decrement?: InputNumberProps['decrement'];
|
|
7
7
|
min?: InputNumberProps['min'];
|
|
8
8
|
max?: InputNumberProps['max'];
|
|
9
9
|
step?: InputNumberProps['step'];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IFieldProps, IFormFieldBase, INPUT_TYPES } from '#core/components/Form/types';
|
|
2
|
-
import type { SelectMenuItem } from '
|
|
2
|
+
import type { SelectMenuItem } from '@nuxt/ui';
|
|
3
3
|
export type SelectOption = SelectMenuItem & {
|
|
4
4
|
label?: string;
|
|
5
5
|
value?: any;
|
|
@@ -18,10 +18,12 @@ import type { IRadioField } from '#core/components/Form/InputRadio/types';
|
|
|
18
18
|
import type { IWYSIWYGField } from '#core/components/Form/InputWYSIWYG/types';
|
|
19
19
|
import type { IComponentField } from '#core/components/Form/InputComponent/types';
|
|
20
20
|
import type { ITagsField } from '#core/components/Form/InputTags/types';
|
|
21
|
+
import type { ICurrencyField } from '#core/components/Form/InputCurrency/types';
|
|
21
22
|
export declare enum INPUT_TYPES {
|
|
22
23
|
TEXT = "TEXT",
|
|
23
24
|
SEARCH = "SEARCH",
|
|
24
25
|
NUMBER = "NUMBER",
|
|
26
|
+
CURRENCY = "CURRENCY",
|
|
25
27
|
TEXTAREA = "TEXTAREA",
|
|
26
28
|
PASSWORD = "PASSWORD",
|
|
27
29
|
EMAIL = "EMAIL",
|
|
@@ -73,7 +75,7 @@ export interface IFormFieldBase<I extends INPUT_TYPES, P extends IFieldProps, O>
|
|
|
73
75
|
props: P;
|
|
74
76
|
on?: O;
|
|
75
77
|
}
|
|
76
|
-
export type IFormField = ITextField | ISearchField | INumberField | ITextareaField | IToggleField | ISelectField | ICheckboxField | ISelectMultipleField | IRadioField | IDateTimeField | ITimeField | IMonthField | IDateTimeRangeField | IUploadDropzoneField | IUploadDropzoneAutoField | IWYSIWYGField | IComponentField | ITagsField | IFormFieldBase<INPUT_TYPES.COMPONENT, any, any>;
|
|
78
|
+
export type IFormField = ITextField | ISearchField | INumberField | ICurrencyField | ITextareaField | IToggleField | ISelectField | ICheckboxField | ISelectMultipleField | IRadioField | IDateTimeField | ITimeField | IMonthField | IDateTimeRangeField | IUploadDropzoneField | IUploadDropzoneAutoField | IWYSIWYGField | IComponentField | ITagsField | IFormFieldBase<INPUT_TYPES.COMPONENT, any, any>;
|
|
77
79
|
export interface IFileValue {
|
|
78
80
|
url: string;
|
|
79
81
|
path?: string;
|
|
@@ -2,6 +2,7 @@ export var INPUT_TYPES = /* @__PURE__ */ ((INPUT_TYPES2) => {
|
|
|
2
2
|
INPUT_TYPES2["TEXT"] = "TEXT";
|
|
3
3
|
INPUT_TYPES2["SEARCH"] = "SEARCH";
|
|
4
4
|
INPUT_TYPES2["NUMBER"] = "NUMBER";
|
|
5
|
+
INPUT_TYPES2["CURRENCY"] = "CURRENCY";
|
|
5
6
|
INPUT_TYPES2["TEXTAREA"] = "TEXTAREA";
|
|
6
7
|
INPUT_TYPES2["PASSWORD"] = "PASSWORD";
|
|
7
8
|
INPUT_TYPES2["EMAIL"] = "EMAIL";
|