@finema/core 2.32.2 → 2.34.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.d.mts CHANGED
@@ -5,6 +5,7 @@ declare const core: {
5
5
  default_primary_key: string;
6
6
  time_format: string;
7
7
  date_format: string;
8
+ month_format: string;
8
9
  date_time_format: string;
9
10
  date_format_system: string;
10
11
  date_time_format_system: string;
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "2.32.2",
3
+ "version": "2.34.0",
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.32.2";
7
+ const version = "2.34.0";
8
8
 
9
9
  const nuxtAppOptions = {
10
10
  head: {
@@ -52,9 +52,10 @@ const core = {
52
52
  limit_per_page: 30,
53
53
  default_primary_key: "id",
54
54
  time_format: "HH:mm",
55
- date_format: "dd-MM-yyyy",
56
- date_time_format: "dd-MM-yyyy HH:mm",
57
- date_format_system: "yyyy-MM-dd",
55
+ date_format: "dd-MMM-yyyy",
56
+ month_format: "MMM-yyyy",
57
+ date_time_format: "dd-MMM-yyyy HH:mm",
58
+ date_format_system: "yyyy-MMM-dd",
58
59
  date_time_format_system: "yyyy-MM-dd HH:mm",
59
60
  is_thai_year: false,
60
61
  is_thai_month: false,
@@ -33,6 +33,7 @@ import FormInputComponent from "./InputComponent/index.vue";
33
33
  import FormInputRadio from "./InputRadio/index.vue";
34
34
  import FormInputDateTime from "./InputDateTime/index.vue";
35
35
  import FormInputTime from "./InputTime/index.vue";
36
+ import FormInputMonth from "./InputMonth/index.vue";
36
37
  import FormInputDateTimeRange from "./InputDateTimeRange/index.vue";
37
38
  import FormInputUploadDropzoneAuto from "./InputUploadDropzoneAuto/index.vue";
38
39
  import FormInputUploadDropzone from "./InputUploadDropzone/index.vue";
@@ -118,6 +119,10 @@ const componentMap = {
118
119
  disabledTime: true
119
120
  }
120
121
  },
122
+ [INPUT_TYPES.MONTH]: {
123
+ component: FormInputMonth,
124
+ props: {}
125
+ },
121
126
  [INPUT_TYPES.DATE_RANGE]: {
122
127
  component: FormInputDateTimeRange,
123
128
  props: {
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <FieldWrapper v-bind="wrapperProps">
3
3
  <Datepicker
4
+ :teleport="true"
4
5
  :model-value="innerValue"
5
6
  :disabled="wrapperProps.disabled"
6
7
  cancel-text="ยกเลิก"
@@ -1,63 +1,64 @@
1
1
  <template>
2
- <FieldWrapper v-bind="wrapperProps">
3
- <Datepicker
4
- ref="datepicker"
5
- v-model="innerValueRef"
6
- :disabled="wrapperProps.disabled"
7
- cancel-text="ยกเลิก"
8
- select-text="เลือก"
9
- locale="th"
10
- :format="format"
11
- :enable-time-picker="!disabledTime"
12
- :placeholder="wrapperProps.placeholder"
13
- :min-date="minDate"
14
- :max-date="maxDate"
15
- :min-time="minTime"
16
- :max-time="maxTime"
17
- :start-time="startTime"
18
- :multi-calendars="!isDisabledMultiCalendar"
19
- :required="required"
20
- time-picker-inline
21
- range
22
- :flow="['calendar', 'time']"
23
- @update:model-value="onInput"
24
- >
25
- <template
26
- v-if="appConfig.core?.is_thai_year"
27
- #year="{ value }"
28
- >
29
- {{ value + 543 }}
30
- </template>
31
- <template
32
- v-if="appConfig.core?.is_thai_year"
33
- #year-overlay-value="{ value }"
34
- >
35
- {{ value + 543 }}
36
- </template>
37
- <template #dp-input="{ value: innerValue }">
38
- <Input
39
- :trailing-icon="innerValue ? void 0 : 'i-heroicons-calendar-days'"
40
- type="text"
41
- :model-value="innerValue"
42
- :placeholder="wrapperProps.placeholder"
43
- :readonly="true"
2
+ <FieldWrapper v-bind="wrapperProps">
3
+ <Datepicker
4
+ ref="datepicker"
5
+ v-model="innerValueRef"
6
+ :teleport="true"
7
+ :disabled="wrapperProps.disabled"
8
+ cancel-text="ยกเลิก"
9
+ select-text="เลือก"
10
+ locale="th"
11
+ :format="format"
12
+ :enable-time-picker="!disabledTime"
13
+ :placeholder="wrapperProps.placeholder"
14
+ :min-date="minDate"
15
+ :max-date="maxDate"
16
+ :min-time="minTime"
17
+ :max-time="maxTime"
18
+ :start-time="startTime"
19
+ :multi-calendars="!isDisabledMultiCalendar"
20
+ :required="required"
21
+ time-picker-inline
22
+ range
23
+ :flow="['calendar', 'time']"
24
+ @update:model-value="onInput"
25
+ >
26
+ <template
27
+ v-if="appConfig.core?.is_thai_year"
28
+ #year="{ value }"
29
+ >
30
+ {{ value + 543 }}
31
+ </template>
32
+ <template
33
+ v-if="appConfig.core?.is_thai_year"
34
+ #year-overlay-value="{ value }"
35
+ >
36
+ {{ value + 543 }}
37
+ </template>
38
+ <template #dp-input="{ value: innerValue }">
39
+ <Input
40
+ :trailing-icon="innerValue ? void 0 : 'i-heroicons-calendar-days'"
41
+ type="text"
42
+ :model-value="innerValue"
43
+ :placeholder="wrapperProps.placeholder"
44
+ :readonly="true"
44
45
  :ui="{
45
46
  base: 'cursor-pointer select-none',
46
47
  trailingIcon: 'cursor-pointer'
47
- }"
48
- />
49
- </template>
50
- <template #clear-icon="{ clear }">
51
- <Icon
52
- :name="clearIcon"
48
+ }"
49
+ />
50
+ </template>
51
+ <template #clear-icon="{ clear }">
52
+ <Icon
53
+ :name="clearIcon"
53
54
  :class="theme.clearIcon({
54
55
  class: [ui?.clearIcon]
55
- })"
56
- @click.stop="clear"
57
- />
58
- </template>
59
- </Datepicker>
60
- </FieldWrapper>
56
+ })"
57
+ @click.stop="clear"
58
+ />
59
+ </template>
60
+ </Datepicker>
61
+ </FieldWrapper>
61
62
  </template>
62
63
 
63
64
  <script setup>
@@ -0,0 +1,105 @@
1
+ <template>
2
+ <FieldWrapper v-bind="wrapperProps">
3
+ <Datepicker
4
+ v-model="value"
5
+ :teleport="true"
6
+ :disabled="wrapperProps.disabled"
7
+ cancel-text="ยกเลิก"
8
+ select-text="เลือก"
9
+ locale="th"
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
+ >
19
+ <template
20
+ v-if="appConfig.core?.is_thai_year"
21
+ #year="{ year }"
22
+ >
23
+ {{ year + 543 }}
24
+ </template>
25
+ <template
26
+ v-if="appConfig.core?.is_thai_year"
27
+ #year-overlay-value="{ value }"
28
+ >
29
+ {{ value + 543 }}
30
+ </template>
31
+ <template #dp-input>
32
+ <Input
33
+ :trailing-icon="!wrapperProps.required && value ? void 0 : 'i-heroicons-calendar-days'"
34
+ type="text"
35
+ :disabled="wrapperProps.disabled"
36
+ :model-value="formatDisplay(value)"
37
+ :placeholder="wrapperProps.placeholder"
38
+ :readonly="true"
39
+ :ui="{
40
+ base: 'cursor-pointer select-none',
41
+ trailingIcon: 'cursor-pointer'
42
+ }"
43
+ />
44
+ </template>
45
+ <template #clear-icon="{ clear }">
46
+ <Icon
47
+ v-if="value && !wrapperProps.disabled && !wrapperProps.required"
48
+ :name="clearIcon"
49
+ :class="theme.clearIcon({
50
+ class: [ui?.clearIcon]
51
+ })"
52
+ @click.stop="clear"
53
+ />
54
+ </template>
55
+ </Datepicker>
56
+ </FieldWrapper>
57
+ </template>
58
+
59
+ <script setup>
60
+ import Datepicker from "@vuepic/vue-datepicker";
61
+ import FieldWrapper from "#core/components/Form/FieldWrapper.vue";
62
+ import { computed, useAppConfig, useFieldHOC, useUiConfig } from "#imports";
63
+ import "@vuepic/vue-datepicker/dist/main.css";
64
+ import { dateTimeTheme } from "#core/theme/dateTime";
65
+ import { format } from "date-fns-tz";
66
+ import * as locales from "date-fns/locale";
67
+ import { addYears } from "date-fns";
68
+ const props = defineProps({
69
+ clearIcon: { type: String, required: false, default: "ph:x-circle-fill" },
70
+ minDate: { type: [Date, String], required: false },
71
+ maxDate: { type: [Date, String], required: false },
72
+ form: { type: Object, required: false },
73
+ name: { type: String, required: true },
74
+ errorMessage: { type: String, required: false },
75
+ label: { type: null, required: false },
76
+ description: { type: String, required: false },
77
+ hint: { type: String, required: false },
78
+ rules: { type: null, required: false },
79
+ autoFocus: { type: Boolean, required: false },
80
+ placeholder: { type: String, required: false },
81
+ disabled: { type: Boolean, required: false },
82
+ readonly: { type: Boolean, required: false },
83
+ required: { type: Boolean, required: false },
84
+ help: { type: String, required: false },
85
+ ui: { type: null, required: false }
86
+ });
87
+ const appConfig = useAppConfig();
88
+ const theme = computed(() => useUiConfig(dateTimeTheme, "dateTime")());
89
+ const {
90
+ value,
91
+ wrapperProps
92
+ } = useFieldHOC(props);
93
+ const formatDisplay = (date) => {
94
+ if (!date) return "";
95
+ let newDateStr = new Date(date.year, date.month);
96
+ const options = {};
97
+ if (appConfig.core?.is_thai_year) {
98
+ newDateStr = addYears(newDateStr, 543);
99
+ }
100
+ if (appConfig.core?.is_thai_month) {
101
+ options.locale = locales.th;
102
+ }
103
+ return format(newDateStr, appConfig.core?.month_format, options);
104
+ };
105
+ </script>
@@ -0,0 +1,6 @@
1
+ import '@vuepic/vue-datepicker/dist/main.css';
2
+ import type { IMonthFieldProps } from '#core/components/Form/InputMonth/types';
3
+ declare const _default: import("vue").DefineComponent<IMonthFieldProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<IMonthFieldProps> & Readonly<{}>, {
4
+ clearIcon: string;
5
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import type { IFieldProps, IFormFieldBase, INPUT_TYPES } from '#core/components/Form/types';
2
+ export interface IMonthFieldProps extends IFieldProps {
3
+ clearIcon?: string;
4
+ minDate?: Date | string;
5
+ maxDate?: Date | string;
6
+ }
7
+ export type IMonthField = IFormFieldBase<INPUT_TYPES.MONTH, IMonthFieldProps, {
8
+ change: (value: string) => void;
9
+ }>;
@@ -13,6 +13,7 @@ import type { ISelectMultipleField } from '#core/components/Form/InputSelectMult
13
13
  import type { INumberField } from '#core/components/Form/InputNumber/types';
14
14
  import type { IDateTimeField } from '#core/components/Form/InputDateTime/date_time_field.types';
15
15
  import type { ITimeField } from '#core/components/Form/InputTime/types';
16
+ import type { IMonthField } from '#core/components/Form/InputMonth/types';
16
17
  import type { IRadioField } from '#core/components/Form/InputRadio/types';
17
18
  import type { IWYSIWYGField } from '#core/components/Form/InputWYSIWYG/types';
18
19
  import type { IComponentField } from '#core/components/Form/InputComponent/types';
@@ -32,6 +33,7 @@ export declare enum INPUT_TYPES {
32
33
  DATE_TIME = "DATE_TIME",
33
34
  TIME = "TIME",
34
35
  DATE = "DATE",
36
+ MONTH = "MONTH",
35
37
  DATE_RANGE = "DATE_RANGE",
36
38
  DATE_TIME_RANGE = "DATE_TIME_RANGE",
37
39
  UPLOAD_FILE_CLASSIC = "UPLOAD_FILE_CLASSIC",
@@ -70,7 +72,7 @@ export interface IFormFieldBase<I extends INPUT_TYPES, P extends IFieldProps, O>
70
72
  props: P;
71
73
  on?: O;
72
74
  }
73
- export type IFormField = ITextField | ISearchField | INumberField | ITextareaField | IToggleField | ISelectField | ICheckboxField | ISelectMultipleField | IRadioField | IDateTimeField | ITimeField | IDateTimeRangeField | IUploadDropzoneField | IUploadDropzoneAutoField | IWYSIWYGField | IComponentField | IFormFieldBase<INPUT_TYPES.COMPONENT, any, any>;
75
+ export type IFormField = ITextField | ISearchField | INumberField | ITextareaField | IToggleField | ISelectField | ICheckboxField | ISelectMultipleField | IRadioField | IDateTimeField | ITimeField | IMonthField | IDateTimeRangeField | IUploadDropzoneField | IUploadDropzoneAutoField | IWYSIWYGField | IComponentField | IFormFieldBase<INPUT_TYPES.COMPONENT, any, any>;
74
76
  export interface IFileValue {
75
77
  url: string;
76
78
  path?: string;
@@ -14,6 +14,7 @@ export var INPUT_TYPES = /* @__PURE__ */ ((INPUT_TYPES2) => {
14
14
  INPUT_TYPES2["DATE_TIME"] = "DATE_TIME";
15
15
  INPUT_TYPES2["TIME"] = "TIME";
16
16
  INPUT_TYPES2["DATE"] = "DATE";
17
+ INPUT_TYPES2["MONTH"] = "MONTH";
17
18
  INPUT_TYPES2["DATE_RANGE"] = "DATE_RANGE";
18
19
  INPUT_TYPES2["DATE_TIME_RANGE"] = "DATE_TIME_RANGE";
19
20
  INPUT_TYPES2["UPLOAD_FILE_CLASSIC"] = "UPLOAD_FILE_CLASSIC";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "2.32.2",
3
+ "version": "2.34.0",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",
@@ -93,4 +93,4 @@
93
93
  "lint-staged": {
94
94
  "*": "eslint --fix --quiet"
95
95
  }
96
- }
96
+ }