@finema/core 2.1.1 → 2.3.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.
Files changed (40) hide show
  1. package/README.md +79 -79
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +1 -1
  4. package/dist/runtime/components/App.vue +7 -7
  5. package/dist/runtime/components/DevToolsWindow/index.vue +95 -95
  6. package/dist/runtime/components/Dialog/index.vue +61 -50
  7. package/dist/runtime/components/Empty.vue +12 -12
  8. package/dist/runtime/components/FlexDeck/Base.vue +67 -67
  9. package/dist/runtime/components/FlexDeck/index.vue +33 -33
  10. package/dist/runtime/components/Form/FieldWrapper.vue +13 -13
  11. package/dist/runtime/components/Form/Fields.vue +13 -13
  12. package/dist/runtime/components/Form/InputCheckbox/index.vue +18 -18
  13. package/dist/runtime/components/Form/InputDateTime/index.vue +44 -44
  14. package/dist/runtime/components/Form/InputNumber/index.vue +20 -20
  15. package/dist/runtime/components/Form/InputSelect/index.vue +38 -38
  16. package/dist/runtime/components/Form/InputSelectMultiple/index.vue +43 -43
  17. package/dist/runtime/components/Form/InputText/index.vue +48 -48
  18. package/dist/runtime/components/Form/InputTextarea/index.vue +18 -18
  19. package/dist/runtime/components/Form/InputToggle/index.vue +17 -17
  20. package/dist/runtime/components/Form/index.vue +5 -5
  21. package/dist/runtime/components/Image.vue +28 -28
  22. package/dist/runtime/components/Loader.vue +10 -10
  23. package/dist/runtime/components/Log/index.vue +17 -17
  24. package/dist/runtime/components/Table/Base.vue +76 -76
  25. package/dist/runtime/components/Table/ColumnDate.vue +1 -1
  26. package/dist/runtime/components/Table/ColumnDateTime.vue +1 -1
  27. package/dist/runtime/components/Table/ColumnImage.vue +4 -4
  28. package/dist/runtime/components/Table/ColumnNumber.vue +1 -1
  29. package/dist/runtime/components/Table/ColumnText.vue +1 -1
  30. package/dist/runtime/components/Table/Simple.vue +21 -21
  31. package/dist/runtime/components/Table/index.vue +100 -100
  32. package/dist/runtime/helpers/apiPageHelper.js +2 -1
  33. package/dist/runtime/server/tsconfig.json +3 -3
  34. package/dist/runtime/types/common.d.ts +1 -1
  35. package/dist/runtime/utils/ArrayHelper.js +1 -1
  36. package/dist/runtime/utils/ObjectHelper.js +1 -2
  37. package/dist/runtime/utils/ParamHelper.js +1 -1
  38. package/dist/runtime/utils/lodash.d.ts +15 -0
  39. package/dist/runtime/utils/lodash.js +27 -0
  40. package/package.json +1 -1
@@ -1,116 +1,116 @@
1
1
  <template>
2
- <div>
3
- <div
4
- v-if="options.isEnabledSearch"
2
+ <div>
3
+ <div
4
+ v-if="options.isEnabledSearch"
5
5
  :class="theme.searchContainer({
6
6
  class: [ui?.searchContainer]
7
- })"
8
- >
9
- <Input
10
- v-model="q"
11
- icon="i-heroicons-magnifying-glass"
12
- :placeholder="options.searchPlaceholder || '\u0E04\u0E49\u0E19\u0E2B\u0E32....'"
13
- />
14
- </div>
15
- <div
16
- v-if="!options.isHideCaption || !options.isHideBottomPagination"
7
+ })"
8
+ >
9
+ <Input
10
+ v-model="q"
11
+ icon="i-heroicons-magnifying-glass"
12
+ :placeholder="options.searchPlaceholder || '\u0E04\u0E49\u0E19\u0E2B\u0E32....'"
13
+ />
14
+ </div>
15
+ <div
16
+ v-if="!options.isHideCaption || !options.isHideBottomPagination"
17
17
  :class="theme.captionContainer({
18
18
  class: [ui?.captionContainer]
19
- })"
20
- >
21
- <span
19
+ })"
20
+ >
21
+ <span
22
22
  :class="theme.captionBoldText({
23
23
  class: [ui?.captionBoldText]
24
- })"
25
- >
26
- ผลลัพธ์ทั้งหมด:</span>
27
- จำนวน
28
- <span
24
+ })"
25
+ >
26
+ ผลลัพธ์ทั้งหมด:</span>
27
+ จำนวน
28
+ <span
29
29
  :class="theme.captionBoldText({
30
30
  class: [ui?.captionBoldText]
31
- })"
32
- >{{ options.pageOptions?.totalCount || 0 }}</span>
33
- รายการ
34
- </div>
35
-
36
- <UTable
37
- v-bind="$attrs"
38
- :loading="options.status.isLoading"
39
- :data="options.rawData"
40
- :columns="options.columns"
41
- >
42
- <template #empty>
43
- <slot
44
- v-if="options.status.isLoading"
45
- name="loading"
46
- >
47
- <Loader
48
- :loading="true"
49
- />
50
- </slot>
51
- <slot
52
- v-else-if="options.status.isError"
53
- name="error"
54
- >
55
- <div
56
- class="text-error-400 text-2xl h-[200px] flex justify-center items-center"
57
- >
58
- {{ StringHelper.getError(options.status.errorData) }}
59
- </div>
60
- </slot>
61
-
62
- <slot
63
- v-else
64
- name="error"
65
- >
66
- <Empty />
67
- </slot>
68
- </template>
69
- <template
70
- v-for="column in options.columns.filter((item) => !!item.type)"
71
- #[`${column.accessorKey}-cell`]="{ row }"
72
- :key="column.accessorKey"
73
- >
74
- <component
75
- :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
76
- v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
77
- :value="transformValue(column, row)"
78
- :column="column"
79
- :row="row"
80
- />
81
- </template>
82
- <template
83
- v-for="(_, slotName) of $slots"
84
- #[slotName]="slotProps"
85
- >
86
- <slot
87
- :name="slotName"
88
- v-bind="slotProps || {}"
89
- />
90
- </template>
91
- </UTable>
92
-
93
- <div
31
+ })"
32
+ >{{ options.pageOptions?.totalCount || 0 }}</span>
33
+ รายการ
34
+ </div>
35
+
36
+ <UTable
37
+ v-bind="$attrs"
38
+ :loading="options.status.isLoading"
39
+ :data="options.rawData"
40
+ :columns="options.columns"
41
+ >
42
+ <template #empty>
43
+ <slot
44
+ v-if="options.status.isLoading"
45
+ name="loading"
46
+ >
47
+ <Loader
48
+ :loading="true"
49
+ />
50
+ </slot>
51
+ <slot
52
+ v-else-if="options.status.isError"
53
+ name="error"
54
+ >
55
+ <div
56
+ class="text-error-400 text-2xl h-[200px] flex justify-center items-center"
57
+ >
58
+ {{ StringHelper.getError(options.status.errorData) }}
59
+ </div>
60
+ </slot>
61
+
62
+ <slot
63
+ v-else
64
+ name="error"
65
+ >
66
+ <Empty />
67
+ </slot>
68
+ </template>
69
+ <template
70
+ v-for="column in options.columns.filter((item) => !!item.type)"
71
+ #[`${column.accessorKey}-cell`]="{ row }"
72
+ :key="column.accessorKey"
73
+ >
74
+ <component
75
+ :is="column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]"
76
+ v-if="column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]"
77
+ :value="transformValue(column, row)"
78
+ :column="column"
79
+ :row="row"
80
+ />
81
+ </template>
82
+ <template
83
+ v-for="(_, slotName) of $slots"
84
+ #[slotName]="slotProps"
85
+ >
86
+ <slot
87
+ :name="slotName"
88
+ v-bind="slotProps || {}"
89
+ />
90
+ </template>
91
+ </UTable>
92
+
93
+ <div
94
94
  :class="theme.paginationContainer({
95
95
  class: [ui?.paginationContainer]
96
- })"
97
- >
98
- <p
96
+ })"
97
+ >
98
+ <p
99
99
  :class="theme.paginationInfo({
100
100
  class: [ui?.paginationInfo]
101
- })"
102
- >
103
- ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
104
- </p>
105
- <Pagination
106
- v-model:page="page"
107
- :default-page="options.pageOptions?.currentPage || 1"
108
- :items-per-page="options.pageOptions.limit"
109
- :total="options.pageOptions.totalCount"
110
- @update:page="emits('pageChange', $event)"
111
- />
112
- </div>
113
- </div>
101
+ })"
102
+ >
103
+ ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
104
+ </p>
105
+ <Pagination
106
+ v-model:page="page"
107
+ :default-page="options.pageOptions?.currentPage || 1"
108
+ :items-per-page="options.pageOptions.limit"
109
+ :total="options.pageOptions.totalCount"
110
+ @update:page="emits('pageChange', $event)"
111
+ />
112
+ </div>
113
+ </div>
114
114
  </template>
115
115
 
116
116
  <script setup>
@@ -1,4 +1,5 @@
1
1
  import { useCoreConfig } from "../composables/useConfig.js";
2
+ import { _get } from "../utils/lodash.js";
2
3
  import { bindParamsToUrl } from "./apiBaseHelper.js";
3
4
  import {
4
5
  checkExpiration,
@@ -6,7 +7,7 @@ import {
6
7
  prepareRequestOptions,
7
8
  updateLoaderState
8
9
  } from "./apiBaseHelper.js";
9
- import { _findIndex, _get, _shuffle } from "#imports";
10
+ import { _findIndex, _shuffle } from "#imports";
10
11
  export const apiAddHelper = async (state, onUpdateStatus, onUpdateOptions, onUpdateData, onUpdateItems, data, opts) => {
11
12
  onUpdateStatus(updateLoaderState.setLoading(state().status));
12
13
  onUpdateOptions({});
@@ -1,3 +1,3 @@
1
- {
2
- "extends": "../../../.nuxt/tsconfig.server.json",
3
- }
1
+ {
2
+ "extends": "../../../.nuxt/tsconfig.server.json",
3
+ }
@@ -3,7 +3,7 @@ export interface IError {
3
3
  message: any;
4
4
  }
5
5
  export interface IOption extends Record<string, any> {
6
- value: any;
6
+ value: any | null;
7
7
  label: string;
8
8
  }
9
9
  export interface IGetParams {
@@ -1,4 +1,4 @@
1
- import { get as _get } from "lodash";
1
+ import { _get } from "./lodash.js";
2
2
  export class ArrayHelper {
3
3
  static toOptions(data, valueAttr = "id", labelAttr = "name") {
4
4
  return ArrayHelper.toArray(data).map((item) => {
@@ -1,6 +1,5 @@
1
- import { get as _get } from "lodash";
2
1
  import { ParamHelper } from "./ParamHelper.js";
3
- import { _isEmpty } from "./lodash.js";
2
+ import { _isEmpty, _get } from "./lodash.js";
4
3
  export class ObjectHelper {
5
4
  static createOption(value, label = "") {
6
5
  return {
@@ -1,4 +1,4 @@
1
- import { get as _get } from "lodash";
1
+ import { _get } from "./lodash.js";
2
2
  export class ParamHelper {
3
3
  static getParams = (opts, reqOptions) => {
4
4
  if (opts.params) {
@@ -1 +1,16 @@
1
1
  export declare const _isEmpty: (value: any) => boolean;
2
+ /**
3
+ * Gets the value at path of object. If the resolved value is undefined,
4
+ * the defaultValue is returned in its place.
5
+ */
6
+ type PathKeys<T> = {
7
+ [K in keyof T]: T[K] extends object ? K extends string | number ? `${K}` | `${K}.${PathKeys<T[K]>}` : never : K extends string | number ? `${K}` : never;
8
+ }[keyof T];
9
+ interface GetFunction {
10
+ <T extends object, K extends PathKeys<T>>(object: T, path: K): any;
11
+ <T extends object, K extends PathKeys<T>, D>(object: T, path: K, defaultValue: D): D;
12
+ <T>(object: any, path: string | (string | number)[], defaultValue: T): T;
13
+ <T = any>(object: any, path: string | (string | number)[]): T | undefined;
14
+ }
15
+ export declare const _get: GetFunction;
16
+ export {};
@@ -10,3 +10,30 @@ export const _isEmpty = (value) => {
10
10
  }
11
11
  return false;
12
12
  };
13
+ export const _get = (object, path, defaultValue) => {
14
+ if (object == null) {
15
+ return defaultValue;
16
+ }
17
+ const pathArray = Array.isArray(path) ? path : stringToPath(path);
18
+ let current = object;
19
+ for (let i = 0; i < pathArray.length; i++) {
20
+ if (current == null) {
21
+ return defaultValue;
22
+ }
23
+ current = current[pathArray[i]];
24
+ }
25
+ return current === void 0 ? defaultValue : current;
26
+ };
27
+ const stringToPath = (path) => {
28
+ if (typeof path !== "string") {
29
+ return [path];
30
+ }
31
+ const normalizedPath = path.replace(/\[(\d+)\]/g, ".$1").replace(/\[['"]([^'"]*)['"]\]/g, ".$1").replace(/^\./, "");
32
+ if (normalizedPath === "") {
33
+ return [];
34
+ }
35
+ return normalizedPath.split(".").map((key) => {
36
+ const numKey = Number(key);
37
+ return !Number.isNaN(numKey) && key === numKey.toString() ? numKey : key;
38
+ });
39
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "2.1.1",
3
+ "version": "2.3.0",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",