@finema/core 3.15.2 → 3.16.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": "3.15.2",
3
+ "version": "3.16.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 = "3.15.2";
7
+ const version = "3.16.1";
8
8
 
9
9
  const nuxtAppOptions = {
10
10
  head: {
@@ -35,25 +35,31 @@
35
35
  })
36
36
  "
37
37
  >
38
- <component
39
- :is="selectedOption.component"
40
- v-if="componentPosition === 'leading' && selectedOption?.component"
41
- v-bind="selectedOption.componentProps"
42
- />
43
- <span
44
- :class="
38
+ <div class="flex items-center gap-x-2">
39
+ <component
40
+ :is="selectedOption.component"
41
+ v-if="
42
+ componentPosition === 'leading' && selectedOption?.component
43
+ "
44
+ v-bind="selectedOption.componentProps"
45
+ />
46
+ <span
47
+ :class="
45
48
  theme.selectedLabel({
46
49
  class: [ui?.selectedLabel]
47
50
  })
48
51
  "
49
- >
50
- {{ selectedOption?.label ?? modelValue }}
51
- </span>
52
- <component
53
- :is="selectedOption.component"
54
- v-if="componentPosition === 'trailing' && selectedOption?.component"
55
- v-bind="selectedOption.componentProps"
56
- />
52
+ >
53
+ {{ selectedOption?.label ?? modelValue }}
54
+ </span>
55
+ <component
56
+ :is="selectedOption.component"
57
+ v-if="
58
+ componentPosition === 'trailing' && selectedOption?.component
59
+ "
60
+ v-bind="selectedOption.componentProps"
61
+ />
62
+ </div>
57
63
  <Icon
58
64
  v-if="clearable"
59
65
  :name="clearIcon"
@@ -3,16 +3,18 @@ import { tableTheme } from '#core/theme/table';
3
3
  type __VLS_Props = {
4
4
  options: ITableOptions<any> & ISimpleTableOptions<any>;
5
5
  ui?: (typeof tableTheme)['slots'];
6
+ to?: string | ((row: any) => any);
7
+ target?: string | ((row: any) => string | undefined);
6
8
  };
7
- declare var __VLS_22: {}, __VLS_29: {}, __VLS_31: {}, __VLS_45: any, __VLS_46: any;
9
+ declare var __VLS_25: {}, __VLS_32: {}, __VLS_34: {}, __VLS_53: any, __VLS_54: any;
8
10
  type __VLS_Slots = {} & {
9
- [K in NonNullable<typeof __VLS_45>]?: (props: typeof __VLS_46) => any;
11
+ [K in NonNullable<typeof __VLS_53>]?: (props: typeof __VLS_54) => any;
10
12
  } & {
11
- loading?: (props: typeof __VLS_22) => any;
13
+ loading?: (props: typeof __VLS_25) => any;
12
14
  } & {
13
- error?: (props: typeof __VLS_29) => any;
15
+ error?: (props: typeof __VLS_32) => any;
14
16
  } & {
15
- error?: (props: typeof __VLS_31) => any;
17
+ error?: (props: typeof __VLS_34) => any;
16
18
  };
17
19
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, any, string, import("vue").PublicProps, any, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
20
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -23,6 +23,7 @@
23
23
  :data="options.rawData"
24
24
  v-bind="$attrs"
25
25
  :ui="ui"
26
+ @select="onSelect"
26
27
  >
27
28
  <template #loading>
28
29
  <Loader :loading="true" />
@@ -53,24 +54,45 @@
53
54
  </slot>
54
55
  </template>
55
56
  <template
56
- v-for="column in options.columns.filter((item) => !!item.type)"
57
+ v-for="column in options.columns"
57
58
  #[`${column.accessorKey}-cell`]="{ row }"
58
59
  :key="column.accessorKey"
59
60
  >
60
- <component
61
- :is="
61
+ <NuxtLink
62
+ v-if="to && column.accessorKey !== 'actions'"
63
+ :to="resolveTo(row.original)"
64
+ :target="resolveTarget(row.original)"
65
+ :rel="
66
+ resolveTarget(row.original) === '_blank' ? 'noopener noreferrer' : void 0
67
+ "
68
+ class="absolute inset-0"
69
+ tabindex="-1"
70
+ aria-hidden="true"
71
+ />
72
+ <div
73
+ :class="
74
+ to && column.accessorKey !== 'actions' ? 'pointer-events-none relative z-10' : 'relative z-10'
75
+ "
76
+ >
77
+ <component
78
+ :is="
62
79
  column.type === COLUMN_TYPES.COMPONENT ? column.component : columnTypeComponents[column.type]
63
80
  "
64
- v-if="
81
+ v-if="
65
82
  column.type === COLUMN_TYPES.COMPONENT || columnTypeComponents[column.type]
66
83
  "
67
- :value="transformValue(column, row)"
68
- :column="column"
69
- :row="row"
70
- />
84
+ :value="transformValue(column, row)"
85
+ :column="column"
86
+ :row="row"
87
+ />
88
+ <template v-else>
89
+ {{ transformValue(column, row) }}
90
+ </template>
91
+ </div>
71
92
  </template>
72
93
  <template
73
94
  v-for="(_, slotName) of $slots"
95
+ :key="slotName"
74
96
  #[slotName]="slotProps"
75
97
  >
76
98
  <slot
@@ -113,10 +135,12 @@ import ColumnText from "#core/components/Table/ColumnText.vue";
113
135
  import UTable from "#ui/components/Table";
114
136
  import Pagination from "./Pagination.vue";
115
137
  import { tableTheme } from "#core/theme/table";
116
- const emits = defineEmits(["pageChange", "search"]);
138
+ const emits = defineEmits(["pageChange", "search", "select"]);
117
139
  const props = defineProps({
118
140
  options: { type: Object, required: true },
119
- ui: { type: null, required: false }
141
+ ui: { type: null, required: false },
142
+ to: { type: [String, Function], required: false },
143
+ target: { type: [String, Function], required: false }
120
144
  });
121
145
  const columnTypeComponents = {
122
146
  [COLUMN_TYPES.NUMBER]: ColumnNumber,
@@ -128,7 +152,9 @@ const columnTypeComponents = {
128
152
  const theme = computed(() => useUiConfig(tableTheme, "table")());
129
153
  const config = useAppConfig();
130
154
  const page = ref(props.options.pageOptions?.currentPage || 1);
131
- const pageLimit = ref(props.options.pageOptions?.limit || config.core.limit_per_page);
155
+ const pageLimit = ref(
156
+ props.options.pageOptions?.limit || config.core.limit_per_page
157
+ );
132
158
  const uTableCompatibleColumns = computed(
133
159
  () => props.options.columns.map((col) => ({
134
160
  ...col,
@@ -137,9 +163,24 @@ const uTableCompatibleColumns = computed(
137
163
  }))
138
164
  );
139
165
  const transformValue = (column, row) => {
140
- return column.cell ? column.cell({
141
- row
142
- }) : row.getValue(column.accessorKey);
166
+ if (typeof column.cell === "function") {
167
+ return column.cell({
168
+ row
169
+ });
170
+ }
171
+ return row.getValue(column.accessorKey);
172
+ };
173
+ const resolveTo = (rowOriginal) => {
174
+ if (typeof props.to === "function") {
175
+ return props.to(rowOriginal);
176
+ }
177
+ return props.to;
178
+ };
179
+ const resolveTarget = (rowOriginal) => {
180
+ if (typeof props.target === "function") {
181
+ return props.target(rowOriginal);
182
+ }
183
+ return props.target;
143
184
  };
144
185
  useWatchChange(
145
186
  () => props.options.pageOptions?.currentPage,
@@ -151,6 +192,9 @@ const onPageChange = (newPage) => {
151
192
  page.value = newPage;
152
193
  emits("pageChange", newPage);
153
194
  };
195
+ const onSelect = (rows) => {
196
+ emits("select", rows);
197
+ };
154
198
  const changePageLimit = (limit) => {
155
199
  pageLimit.value = limit;
156
200
  props.options.repo.fetchPageChange(1, {
@@ -3,16 +3,18 @@ import { tableTheme } from '#core/theme/table';
3
3
  type __VLS_Props = {
4
4
  options: ITableOptions<any> & ISimpleTableOptions<any>;
5
5
  ui?: (typeof tableTheme)['slots'];
6
+ to?: string | ((row: any) => any);
7
+ target?: string | ((row: any) => string | undefined);
6
8
  };
7
- declare var __VLS_22: {}, __VLS_29: {}, __VLS_31: {}, __VLS_45: any, __VLS_46: any;
9
+ declare var __VLS_25: {}, __VLS_32: {}, __VLS_34: {}, __VLS_53: any, __VLS_54: any;
8
10
  type __VLS_Slots = {} & {
9
- [K in NonNullable<typeof __VLS_45>]?: (props: typeof __VLS_46) => any;
11
+ [K in NonNullable<typeof __VLS_53>]?: (props: typeof __VLS_54) => any;
10
12
  } & {
11
- loading?: (props: typeof __VLS_22) => any;
13
+ loading?: (props: typeof __VLS_25) => any;
12
14
  } & {
13
- error?: (props: typeof __VLS_29) => any;
15
+ error?: (props: typeof __VLS_32) => any;
14
16
  } & {
15
- error?: (props: typeof __VLS_31) => any;
17
+ error?: (props: typeof __VLS_34) => any;
16
18
  };
17
19
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, any, string, import("vue").PublicProps, any, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
20
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -12,10 +12,13 @@ type __VLS_Props = {
12
12
  left: string[];
13
13
  right: string[];
14
14
  };
15
+ to?: string | ((row: any) => any);
16
+ target?: string | ((row: any) => string | undefined);
15
17
  };
16
18
  type __VLS_Slots = Slot;
17
19
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
18
20
  search: (q: string) => any;
21
+ select: (rows: any[]) => any;
19
22
  pageChange: (page: number) => any;
20
23
  "update:columnPinning": (value: {
21
24
  left: string[];
@@ -23,6 +26,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
23
26
  }) => any;
24
27
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
25
28
  onSearch?: ((q: string) => any) | undefined;
29
+ onSelect?: ((rows: any[]) => any) | undefined;
26
30
  onPageChange?: ((page: number) => any) | undefined;
27
31
  "onUpdate:columnPinning"?: ((value: {
28
32
  left: string[];
@@ -17,10 +17,13 @@
17
17
  <Base
18
18
  v-bind="$attrs"
19
19
  :options="options"
20
- :ui="ui"
20
+ :ui="computedUi"
21
21
  :column-pinning="computedColumnPinning"
22
+ :to="to"
23
+ :target="target"
22
24
  @page-change="onPageChange"
23
25
  @search="emits('search', q)"
26
+ @select="emits('select', $event)"
24
27
  >
25
28
  <template
26
29
  v-for="(_, slot) of $slots"
@@ -40,7 +43,7 @@ import { computed } from "vue";
40
43
  import { _debounce, ref, useUiConfig, watch } from "#imports";
41
44
  import { tableTheme } from "#core/theme/table";
42
45
  import Base from "#core/components/Table/Base.vue";
43
- const emits = defineEmits(["pageChange", "search", "update:columnPinning"]);
46
+ const emits = defineEmits(["pageChange", "search", "select", "update:columnPinning"]);
44
47
  const props = defineProps({
45
48
  options: { type: Object, required: true },
46
49
  ui: { type: null, required: false },
@@ -48,12 +51,23 @@ const props = defineProps({
48
51
  columnPinning: { type: Object, required: false, default: () => ({
49
52
  left: [],
50
53
  right: []
51
- }) }
54
+ }) },
55
+ to: { type: [String, Function], required: false },
56
+ target: { type: [String, Function], required: false }
52
57
  });
53
58
  defineSlots();
54
59
  const tableContainer = ref();
55
60
  const q = ref(props.options?.pageOptions.search ?? "");
56
61
  const theme = computed(() => useUiConfig(tableTheme, "table")());
62
+ const computedUi = computed(() => {
63
+ if (!props.to) {
64
+ return props.ui;
65
+ }
66
+ return {
67
+ ...props.ui,
68
+ td: [props.ui?.td, "cursor-pointer", "relative"].filter(Boolean).join(" ")
69
+ };
70
+ });
57
71
  const computedColumnPinning = computed(() => {
58
72
  if (props.isPinAction) {
59
73
  const hasActionsColumn = props.options.columns.some(
@@ -12,10 +12,13 @@ type __VLS_Props = {
12
12
  left: string[];
13
13
  right: string[];
14
14
  };
15
+ to?: string | ((row: any) => any);
16
+ target?: string | ((row: any) => string | undefined);
15
17
  };
16
18
  type __VLS_Slots = Slot;
17
19
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
18
20
  search: (q: string) => any;
21
+ select: (rows: any[]) => any;
19
22
  pageChange: (page: number) => any;
20
23
  "update:columnPinning": (value: {
21
24
  left: string[];
@@ -23,6 +26,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
23
26
  }) => any;
24
27
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
25
28
  onSearch?: ((q: string) => any) | undefined;
29
+ onSelect?: ((rows: any[]) => any) | undefined;
26
30
  onPageChange?: ((page: number) => any) | undefined;
27
31
  "onUpdate:columnPinning"?: ((value: {
28
32
  left: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "3.15.2",
3
+ "version": "3.16.1",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",