@finema/core 2.61.1 → 3.0.1

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": "2.61.1",
3
+ "version": "3.0.1",
4
4
  "configKey": "core",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
package/dist/module.mjs CHANGED
@@ -4,7 +4,7 @@ import * as lodash from 'lodash-es';
4
4
  import * as theme from '../dist/runtime/theme/index.js';
5
5
 
6
6
  const name = "@finema/core";
7
- const version = "2.61.1";
7
+ const version = "3.0.1";
8
8
 
9
9
  const nuxtAppOptions = {
10
10
  head: {
@@ -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
+ }>;
@@ -1,60 +1,60 @@
1
1
  <template>
2
- <FieldWrapper v-bind="wrapperProps">
3
- <Datepicker
4
- :model-value="value"
5
- :teleport="teleport"
6
- :disabled="wrapperProps.disabled"
7
- :cancel-text="appConfig.core?.locale === 'th' ? '\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01' : 'Cancel'"
8
- :select-text="appConfig.core?.locale === 'th' ? '\u0E15\u0E01\u0E25\u0E07' : 'Select'"
9
- :locale="appConfig.core?.locale"
10
- :format="appConfig.core?.month_format"
11
- month-picker
12
- :placeholder="wrapperProps.placeholder"
13
- :min-date="minDate"
14
- :max-date="maxDate"
15
- :required="wrapperProps.required"
16
- :clearable="true"
17
- :always-clearable="true"
18
- @update:model-value="onInput"
19
- >
20
- <template
21
- v-if="appConfig.core?.is_thai_year"
22
- #year="{ year }"
23
- >
24
- {{ year + 543 }}
25
- </template>
26
- <template
27
- v-if="appConfig.core?.is_thai_year"
28
- #year-overlay-value="{ value }"
29
- >
30
- {{ value + 543 }}
31
- </template>
32
- <template #dp-input>
33
- <Input
34
- :trailing-icon="!wrapperProps.required && value ? void 0 : 'i-heroicons-calendar-days'"
35
- type="text"
36
- :disabled="wrapperProps.disabled"
37
- :model-value="formatDisplay(value)"
38
- :placeholder="wrapperProps.placeholder"
39
- :readonly="true"
2
+ <FieldWrapper v-bind="wrapperProps">
3
+ <Datepicker
4
+ :model-value="value"
5
+ :teleport="teleport"
6
+ :disabled="wrapperProps.disabled"
7
+ :cancel-text="appConfig.core?.locale === 'th' ? '\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01' : 'Cancel'"
8
+ :select-text="appConfig.core?.locale === 'th' ? '\u0E15\u0E01\u0E25\u0E07' : 'Select'"
9
+ :locale="appConfig.core?.locale"
10
+ :format="appConfig.core?.month_format"
11
+ month-picker
12
+ :placeholder="wrapperProps.placeholder"
13
+ :min-date="minDate"
14
+ :max-date="maxDate"
15
+ :required="wrapperProps.required"
16
+ :clearable="true"
17
+ :always-clearable="true"
18
+ @update:model-value="onInput"
19
+ >
20
+ <template
21
+ v-if="appConfig.core?.locale === 'th' && appConfig.core?.is_thai_year"
22
+ #year="{ year }"
23
+ >
24
+ {{ year + 543 }}
25
+ </template>
26
+ <template
27
+ v-if="appConfig.core?.locale === 'th' && appConfig.core?.is_thai_year"
28
+ #year-overlay-value="{ value }"
29
+ >
30
+ {{ value + 543 }}
31
+ </template>
32
+ <template #dp-input>
33
+ <Input
34
+ :trailing-icon="!wrapperProps.required && value ? void 0 : 'i-heroicons-calendar-days'"
35
+ type="text"
36
+ :disabled="wrapperProps.disabled"
37
+ :model-value="formatDisplay(value)"
38
+ :placeholder="wrapperProps.placeholder"
39
+ :readonly="true"
40
40
  :ui="{
41
41
  base: 'cursor-pointer select-none',
42
42
  trailingIcon: 'cursor-pointer'
43
- }"
44
- />
45
- </template>
46
- <template #clear-icon="{ clear }">
47
- <Icon
48
- v-if="value && !wrapperProps.disabled && !wrapperProps.required"
49
- :name="clearIcon"
43
+ }"
44
+ />
45
+ </template>
46
+ <template #clear-icon="{ clear }">
47
+ <Icon
48
+ v-if="value && !wrapperProps.disabled && !wrapperProps.required"
49
+ :name="clearIcon"
50
50
  :class="theme.clearIcon({
51
51
  class: [ui?.clearIcon]
52
- })"
53
- @click.stop="clear"
54
- />
55
- </template>
56
- </Datepicker>
57
- </FieldWrapper>
52
+ })"
53
+ @click.stop="clear"
54
+ />
55
+ </template>
56
+ </Datepicker>
57
+ </FieldWrapper>
58
58
  </template>
59
59
 
60
60
  <script setup>
@@ -97,10 +97,10 @@ const formatDisplay = (date) => {
97
97
  if (!date) return "";
98
98
  let newDateStr = new Date(date.year, date.month);
99
99
  const options = {};
100
- if (appConfig.core?.is_thai_year) {
100
+ if (appConfig.core?.locale === "th" && appConfig.core?.is_thai_year) {
101
101
  newDateStr = addYears(newDateStr, 543);
102
102
  }
103
- if (appConfig.core?.is_thai_month) {
103
+ if (appConfig.core?.locale === "th" && appConfig.core?.is_thai_month) {
104
104
  options.locale = locales.th;
105
105
  }
106
106
  return format(newDateStr, appConfig.core?.month_format, options);
@@ -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-disabled="incrementDisabled"
12
- :decrement-disabled="decrementDisabled"
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
- incrementDisabled: { type: Boolean, required: false },
31
- decrementDisabled: { type: Boolean, required: false },
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 '#ui/components/InputNumber.vue';
2
+ import type { InputNumberProps } from '@nuxt/ui';
3
3
  export interface INumberFieldProps extends IFieldProps {
4
4
  orientation?: InputNumberProps['orientation'];
5
- incrementDisabled?: InputNumberProps['incrementDisabled'];
6
- decrementDisabled?: InputNumberProps['decrementDisabled'];
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 '#ui/components/SelectMenu.vue';
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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "2.61.1",
3
+ "version": "3.0.1",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",