@finema/core 1.4.3 → 1.4.6

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
@@ -3,6 +3,9 @@ import * as _nuxt_schema from '@nuxt/schema';
3
3
  declare const core: {
4
4
  limit_per_page: number;
5
5
  default_primary_key: string;
6
+ date_format: string;
7
+ date_time_format: string;
8
+ time_format: string;
6
9
  };
7
10
 
8
11
  declare const config_core: typeof core;
package/dist/module.d.ts CHANGED
@@ -3,6 +3,9 @@ import * as _nuxt_schema from '@nuxt/schema';
3
3
  declare const core: {
4
4
  limit_per_page: number;
5
5
  default_primary_key: string;
6
+ date_format: string;
7
+ date_time_format: string;
8
+ time_format: string;
6
9
  };
7
10
 
8
11
  declare const config_core: typeof core;
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "1.4.3",
3
+ "version": "1.4.6",
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.3";
5
+ const version = "1.4.6";
6
6
 
7
7
  const colors = {
8
8
  black: "#20243E",
@@ -9,63 +9,63 @@
9
9
  v-on="option.on ?? {}"
10
10
  />
11
11
  <FormInputText
12
- v-if="option.type === INPUT_TYPES.TEXT"
12
+ v-else-if="option.type === INPUT_TYPES.TEXT"
13
13
  :form="form"
14
14
  v-bind="option.props"
15
15
  v-on="option.on ?? {}"
16
16
  />
17
17
  <FormInputText
18
- v-if="option.type === INPUT_TYPES.PASSWORD"
18
+ v-else-if="option.type === INPUT_TYPES.PASSWORD"
19
19
  type="password"
20
20
  :form="form"
21
21
  v-bind="option.props"
22
22
  v-on="option.on ?? {}"
23
23
  />
24
24
  <FormInputText
25
- v-if="option.type === INPUT_TYPES.EMAIL"
25
+ v-else-if="option.type === INPUT_TYPES.EMAIL"
26
26
  type="email"
27
27
  :form="form"
28
28
  v-bind="option.props"
29
29
  v-on="option.on ?? {}"
30
30
  />
31
31
  <FormInputTextarea
32
- v-if="option.type === INPUT_TYPES.TEXTAREA"
32
+ v-else-if="option.type === INPUT_TYPES.TEXTAREA"
33
33
  :form="form"
34
34
  v-bind="option.props"
35
35
  v-on="option.on ?? {}"
36
36
  />
37
37
  <FormInputToggle
38
- v-if="option.type === INPUT_TYPES.TOGGLE"
38
+ v-else-if="option.type === INPUT_TYPES.TOGGLE"
39
39
  :form="form"
40
40
  v-bind="option.props"
41
41
  v-on="option.on ?? {}"
42
42
  />
43
43
  <FormInputSelect
44
- v-if="option.type === INPUT_TYPES.SELECT"
44
+ v-else-if="option.type === INPUT_TYPES.SELECT"
45
45
  :form="form"
46
46
  v-bind="option.props"
47
47
  v-on="option.on ?? {}"
48
48
  />
49
49
  <FormInputRadio
50
- v-if="option.type === INPUT_TYPES.RADIO"
50
+ v-else-if="option.type === INPUT_TYPES.RADIO"
51
51
  :form="form"
52
52
  v-bind="option.props"
53
53
  v-on="option.on ?? {}"
54
54
  />
55
55
  <FormInputCheckbox
56
- v-if="option.type === INPUT_TYPES.CHECKBOX"
56
+ v-else-if="option.type === INPUT_TYPES.CHECKBOX"
57
57
  :form="form"
58
58
  v-bind="option.props"
59
59
  v-on="option.on ?? {}"
60
60
  />
61
61
  <FormInputDateTime
62
- v-if="option.type === INPUT_TYPES.DATE_TIME"
62
+ v-else-if="option.type === INPUT_TYPES.DATE_TIME"
63
63
  :form="form"
64
64
  v-bind="option.props"
65
65
  v-on="option.on ?? {}"
66
66
  />
67
67
  <FormInputDateTime
68
- v-if="option.type === INPUT_TYPES.DATE"
68
+ v-else-if="option.type === INPUT_TYPES.DATE"
69
69
  :form="form"
70
70
  v-bind="option.props"
71
71
  :disabled-time="true"
@@ -1,8 +1,16 @@
1
1
  import { type IFieldProps, type IFormFieldBase, type INPUT_TYPES } from '#core/components/Form/types';
2
+ export interface ITimeOption {
3
+ hours?: number | string;
4
+ minutes?: number | string;
5
+ seconds?: number | string;
6
+ }
2
7
  export interface IDateTimeFieldProps extends IFieldProps {
3
8
  disabledTime?: boolean;
4
9
  minDate?: Date | string;
5
10
  maxDate?: Date | string;
11
+ startTime?: ITimeOption;
12
+ minTime?: ITimeOption;
13
+ maxTime?: ITimeOption;
6
14
  }
7
15
  export type IDateTimeField = IFormFieldBase<INPUT_TYPES.DATE_TIME | INPUT_TYPES.DATE, IDateTimeFieldProps, {
8
16
  change: (value: string) => void;
@@ -11,13 +11,17 @@
11
11
  :format="format"
12
12
  :min-date="minDate"
13
13
  :max-date="maxDate"
14
+ :min-time="minTime"
15
+ :max-time="maxTime"
16
+ :start-time="startTime"
14
17
  :required="isRequired"
18
+ time-picker-inline
15
19
  >
16
- <template #dp-input="{ value }">
20
+ <template #dp-input="{ value: innerValue }">
17
21
  <UInput
18
22
  icon="i-heroicons-calendar-days"
19
23
  type="text"
20
- :value="value"
24
+ :value="innerValue"
21
25
  :placeholder="wrapperProps.placeholder"
22
26
  :readonly="true"
23
27
  input-class="cursor-pointer select-none"
@@ -2,7 +2,7 @@ import { mergeConfig } from "#ui/utils";
2
2
  import { core } from "#core/core.config";
3
3
  import appConfig from "#build/app.config";
4
4
  export const useCoreConfig = () => {
5
- return mergeConfig(appConfig.core.strategy, appConfig.core, core);
5
+ return mergeConfig("override", appConfig.core, core);
6
6
  };
7
7
  export const useUiConfig = (config, name) => {
8
8
  return mergeConfig(appConfig.ui.strategy, appConfig.ui[name], config);
@@ -1,4 +1,7 @@
1
1
  export declare const core: {
2
2
  limit_per_page: number;
3
3
  default_primary_key: string;
4
+ date_format: string;
5
+ date_time_format: string;
6
+ time_format: string;
4
7
  };
@@ -1,4 +1,7 @@
1
1
  export const core = {
2
2
  limit_per_page: 30,
3
- default_primary_key: "id"
3
+ default_primary_key: "id",
4
+ date_format: "yyyy-MM-dd",
5
+ date_time_format: "yyyy-MM-dd HH:mm",
6
+ time_format: "HH:mm"
4
7
  };
@@ -1,7 +1,8 @@
1
1
  import { addHours, format, formatISO, isDate, isValid, parse, subHours } from "date-fns";
2
- const dateFormat = "yyyy-MM-dd";
3
- const dateTimeFormat = "yyyy-MM-dd HH:mm";
4
- const timeFormat = "HH:mm";
2
+ import { useCoreConfig } from "#core/composables/useConfig";
3
+ const dateFormat = useCoreConfig().date_format;
4
+ const dateTimeFormat = useCoreConfig().date_time_format;
5
+ const timeFormat = useCoreConfig().time_format;
5
6
  export class TimeHelper {
6
7
  static toUTC = (time) => {
7
8
  if (!time) {
@@ -1,54 +1,63 @@
1
- import { test, assert } from "vitest";
1
+ import { assert, describe, it, vi } from "vitest";
2
2
  import { TimeHelper } from "./TimeHelper.mjs";
3
- test("toUTC should convert time to UTC format", () => {
4
- const inputTime = "2023-12-19 12:00";
5
- const expectedOutput = "2023-12-19 05:00";
6
- const result = TimeHelper.toUTC(inputTime);
7
- assert.equal(result, expectedOutput);
8
- });
9
- test("toLocal should convert time to local format", () => {
10
- const inputTime = "2023-12-19 12:00";
11
- const expectedOutput = "2023-12-19 19:00";
12
- const result = TimeHelper.toLocal(inputTime);
13
- assert.equal(result, expectedOutput);
14
- });
15
- test("getCurrentDate should return the current date in yyyy-MM-dd format", () => {
16
- const expectedOutputRegex = /^\d{4}-\d{2}-\d{2}$/;
17
- const result = TimeHelper.getCurrentDate();
18
- assert.match(result, expectedOutputRegex);
19
- });
20
- test("getDateFormTime should convert time to date format", () => {
21
- const inputTime = "2023-12-19 12:00";
22
- const expectedOutput = "2023-12-19";
23
- const result = TimeHelper.getDateFormTime(inputTime);
24
- assert.equal(result, expectedOutput);
25
- });
26
- test("getDateFormTimeWithLocal should convert time to date format with local time", () => {
27
- const inputTime = "2023-12-19 12:00";
28
- const expectedOutputRegex = /^\d{4}-\d{2}-\d{2}$/;
29
- const result = TimeHelper.getDateFormTimeWithLocal(inputTime);
30
- assert.match(result, expectedOutputRegex);
31
- });
32
- test("getISODateTimeFormTime should convert time to ISO date-time format", () => {
33
- const inputTime = "2023-12-19 14:30";
34
- const expectedOutput = "2023-12-19T14:30:00+07:00";
35
- const result = TimeHelper.getISODateTimeFormTime(inputTime);
36
- assert.equal(result, expectedOutput);
37
- });
38
- test("getDateTimeFormTime should convert time to date-time format", () => {
39
- const inputTime = "2023-12-19 12:00";
40
- const expectedOutputRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/;
41
- const result = TimeHelper.getDateTimeFormTime(inputTime);
42
- assert.match(result, expectedOutputRegex);
43
- });
44
- test("getTimeFormTime should convert time to time format", () => {
45
- const inputTime = "2023-12-19 12:00";
46
- const expectedOutputRegex = /^\d{2}:\d{2}$/;
47
- const result = TimeHelper.getTimeFormTime(inputTime);
48
- assert.match(result, expectedOutputRegex);
49
- });
50
- test("getCurrentDateTime should return the current date and time in yyyy-MM-dd HH:mm format", () => {
51
- const expectedOutputRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/;
52
- const result = TimeHelper.getCurrentDateTime();
53
- assert.match(result, expectedOutputRegex);
3
+ vi.mock("#core/composables/useConfig", () => ({
4
+ useCoreConfig: () => ({
5
+ date_format: "yyyy-MM-dd",
6
+ date_time_format: "yyyy-MM-dd HH:mm",
7
+ time_format: "HH:mm"
8
+ })
9
+ }));
10
+ describe("TimeHelper", async () => {
11
+ it("toUTC should convert time to UTC format", () => {
12
+ const inputTime = "2023-12-19 12:00";
13
+ const expectedOutput = "2023-12-19 05:00";
14
+ const result = TimeHelper.toUTC(inputTime);
15
+ assert.equal(result, expectedOutput);
16
+ });
17
+ it("toLocal should convert time to local format", () => {
18
+ const inputTime = "2023-12-19 12:00";
19
+ const expectedOutput = "2023-12-19 19:00";
20
+ const result = TimeHelper.toLocal(inputTime);
21
+ assert.equal(result, expectedOutput);
22
+ });
23
+ it("getCurrentDate should return the current date in yyyy-MM-dd format", () => {
24
+ const expectedOutputRegex = /^\d{4}-\d{2}-\d{2}$/;
25
+ const result = TimeHelper.getCurrentDate();
26
+ assert.match(result, expectedOutputRegex);
27
+ });
28
+ it("getDateFormTime should convert time to date format", () => {
29
+ const inputTime = "2023-12-19 12:00";
30
+ const expectedOutput = "2023-12-19";
31
+ const result = TimeHelper.getDateFormTime(inputTime);
32
+ assert.equal(result, expectedOutput);
33
+ });
34
+ it("getDateFormTimeWithLocal should convert time to date format with local time", () => {
35
+ const inputTime = "2023-12-19 12:00";
36
+ const expectedOutputRegex = /^\d{4}-\d{2}-\d{2}$/;
37
+ const result = TimeHelper.getDateFormTimeWithLocal(inputTime);
38
+ assert.match(result, expectedOutputRegex);
39
+ });
40
+ it("getISODateTimeFormTime should convert time to ISO date-time format", () => {
41
+ const inputTime = "2023-12-19 14:30";
42
+ const expectedOutput = "2023-12-19T14:30:00+07:00";
43
+ const result = TimeHelper.getISODateTimeFormTime(inputTime);
44
+ assert.equal(result, expectedOutput);
45
+ });
46
+ it("getDateTimeFormTime should convert time to date-time format", () => {
47
+ const inputTime = "2023-12-19 12:00";
48
+ const expectedOutputRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/;
49
+ const result = TimeHelper.getDateTimeFormTime(inputTime);
50
+ assert.match(result, expectedOutputRegex);
51
+ });
52
+ it("getTimeFormTime should convert time to time format", () => {
53
+ const inputTime = "2023-12-19 12:00";
54
+ const expectedOutputRegex = /^\d{2}:\d{2}$/;
55
+ const result = TimeHelper.getTimeFormTime(inputTime);
56
+ assert.match(result, expectedOutputRegex);
57
+ });
58
+ it("getCurrentDateTime should return the current date and time in yyyy-MM-dd HH:mm format", () => {
59
+ const expectedOutputRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/;
60
+ const result = TimeHelper.getCurrentDateTime();
61
+ assert.match(result, expectedOutputRegex);
62
+ });
54
63
  });
package/package.json CHANGED
@@ -1,79 +1,82 @@
1
- {
2
- "name": "@finema/core",
3
- "version": "1.4.3",
4
- "repository": "https://gitlab.finema.co/finema/ui-kit",
5
- "license": "MIT",
6
- "author": "Finema Dev Core Team",
7
- "type": "module",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/types.d.ts",
11
- "import": "./dist/module.mjs",
12
- "require": "./dist/module.cjs"
13
- }
14
- },
15
- "main": "./dist/module.cjs",
16
- "types": "./dist/types.d.ts",
17
- "files": [
18
- "dist"
19
- ],
20
- "engines": {
21
- "node": ">=18.0.0"
22
- },
23
- "scripts": {
24
- "prepack": "nuxt-module-build build",
25
- "dev": "nuxi dev playground",
26
- "dev:build": "nuxi build playground",
27
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
28
- "lint": "eslint .",
29
- "lint:fix": "eslint . --fix",
30
- "test": "vitest run",
31
- "test:watch": "vitest watch",
32
- "release": "release-it --ci",
33
- "prepare": "husky install"
34
- },
35
- "dependencies": {
36
- "@nuxt/kit": "^3.7.4",
37
- "@nuxt/ui": "^2.11.1",
38
- "@pinia/nuxt": "^0.5.1",
39
- "@vee-validate/nuxt": "^4.12.3",
40
- "@vee-validate/zod": "^4.12.3",
41
- "@vuepic/vue-datepicker": "^7.4.0",
42
- "axios": "^1.6.2",
43
- "date-fns": "^3.0.6",
44
- "i18next": "^23.7.11",
45
- "lodash-es": "^4.17.21",
46
- "nuxt-security": "^1.0.0",
47
- "pinia": "^2.1.7",
48
- "url-join": "^5.0.0",
49
- "zod": "^3.22.4",
50
- "zod-i18n-map": "^2.23.0"
51
- },
52
- "devDependencies": {
53
- "@finema/eslint-config": "^1.2.0",
54
- "@nuxt/devtools": "latest",
55
- "@nuxt/eslint-config": "^0.2.0",
56
- "@nuxt/module-builder": "^0.5.4",
57
- "@nuxt/schema": "^3.7.4",
58
- "@nuxt/test-utils": "^3.9.0",
59
- "@release-it/conventional-changelog": "^8.0.1",
60
- "@types/lodash-es": "^4.17.12",
61
- "@types/node": "^18.18.1",
62
- "changelogen": "^0.5.5",
63
- "eslint": "^8.56.0",
64
- "husky": "^8.0.3",
65
- "lint-staged": "^15.2.0",
66
- "nuxt": "^3.8.2",
67
- "prettier": "^3.1.1",
68
- "release-it": "^17.0.1",
69
- "sass": "^1.69.5",
70
- "stylelint": "^16.0.2",
71
- "stylelint-config-prettier-scss": "^1.0.0",
72
- "stylelint-config-standard-scss": "^12.0.0",
73
- "vitest": "^1.1.0"
74
- },
75
- "lint-staged": {
76
- "*.{ts,vue,tsx,js}": "eslint --fix",
77
- "*.{html,json}": "prettier --write"
78
- }
79
- }
1
+ {
2
+ "name": "@finema/core",
3
+ "version": "1.4.6",
4
+ "repository": "https://gitlab.finema.co/finema/ui-kit",
5
+ "license": "MIT",
6
+ "author": "Finema Dev Core Team",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/types.d.ts",
11
+ "import": "./dist/module.mjs",
12
+ "require": "./dist/module.cjs"
13
+ }
14
+ },
15
+ "main": "./dist/module.cjs",
16
+ "types": "./dist/types.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "engines": {
21
+ "node": ">=18.0.0"
22
+ },
23
+ "scripts": {
24
+ "prepack": "nuxt-module-build build",
25
+ "dev": "nuxi dev playground",
26
+ "dev:build": "nuxi build playground",
27
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
28
+ "lint": "eslint .",
29
+ "lint:fix": "eslint . --fix",
30
+ "test": "vitest run",
31
+ "test:watch": "vitest watch",
32
+ "release": "release-it --ci",
33
+ "prepare": "husky install"
34
+ },
35
+ "dependencies": {
36
+ "@nuxt/kit": "^3.7.4",
37
+ "@nuxt/ui": "^2.11.1",
38
+ "@pinia/nuxt": "^0.5.1",
39
+ "@vee-validate/nuxt": "^4.12.3",
40
+ "@vee-validate/zod": "^4.12.3",
41
+ "@vuepic/vue-datepicker": "^7.4.0",
42
+ "axios": "^1.6.2",
43
+ "date-fns": "^3.0.6",
44
+ "i18next": "^23.7.11",
45
+ "lodash-es": "^4.17.21",
46
+ "nuxt-security": "^1.0.0",
47
+ "pinia": "^2.1.7",
48
+ "url-join": "^5.0.0",
49
+ "zod": "^3.22.4",
50
+ "zod-i18n-map": "^2.23.0"
51
+ },
52
+ "devDependencies": {
53
+ "@finema/eslint-config": "^1.2.0",
54
+ "@nuxt/devtools": "latest",
55
+ "@nuxt/eslint-config": "^0.2.0",
56
+ "@nuxt/module-builder": "^0.5.4",
57
+ "@nuxt/schema": "^3.7.4",
58
+ "@nuxt/test-utils": "^3.9.0",
59
+ "@release-it/conventional-changelog": "^8.0.1",
60
+ "@types/lodash-es": "^4.17.12",
61
+ "@types/node": "^18.18.1",
62
+ "@vue/test-utils": "^2.4.3",
63
+ "changelogen": "^0.5.5",
64
+ "eslint": "^8.56.0",
65
+ "happy-dom": "^12.10.3",
66
+ "husky": "^8.0.3",
67
+ "lint-staged": "^15.2.0",
68
+ "nuxt": "^3.8.2",
69
+ "playwright-core": "^1.40.1",
70
+ "prettier": "^3.1.1",
71
+ "release-it": "^17.0.1",
72
+ "sass": "^1.69.5",
73
+ "stylelint": "^16.0.2",
74
+ "stylelint-config-prettier-scss": "^1.0.0",
75
+ "stylelint-config-standard-scss": "^12.0.0",
76
+ "vitest": "^1.1.0"
77
+ },
78
+ "lint-staged": {
79
+ "*.{ts,vue,tsx,js}": "eslint --fix",
80
+ "*.{html,json}": "prettier --write"
81
+ }
82
+ }