@nu-grid/nuxt 0.2.0 → 0.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.
- package/dist/module.json +1 -1
- package/dist/runtime/cell-types/date/index.d.ts +1 -1
- package/dist/runtime/cell-types/date/index.js +15 -1
- package/dist/runtime/cell-types/index.d.ts +2 -1
- package/dist/runtime/cell-types/index.js +3 -0
- package/dist/runtime/cell-types/number/NumberFilter.vue +1 -1
- package/dist/runtime/cell-types/percentage/PercentageEditor.d.vue.ts +15 -0
- package/dist/runtime/cell-types/percentage/PercentageEditor.vue +56 -0
- package/dist/runtime/cell-types/percentage/PercentageEditor.vue.d.ts +15 -0
- package/dist/runtime/cell-types/percentage/PercentageFilter.d.vue.ts +7 -0
- package/dist/runtime/cell-types/percentage/PercentageFilter.vue +79 -0
- package/dist/runtime/cell-types/percentage/PercentageFilter.vue.d.ts +7 -0
- package/dist/runtime/cell-types/percentage/index.d.ts +10 -0
- package/dist/runtime/cell-types/percentage/index.js +38 -0
- package/dist/runtime/components/NuGrid.d.vue.ts +8 -5
- package/dist/runtime/components/NuGrid.vue +41 -9
- package/dist/runtime/components/NuGrid.vue.d.ts +8 -5
- package/dist/runtime/components/_internal/NuGridBase.vue +128 -82
- package/dist/runtime/components/_internal/NuGridCellContent.vue +21 -1
- package/dist/runtime/components/_internal/NuGridColumnMenu.vue +2 -2
- package/dist/runtime/components/_internal/NuGridGroup.vue +22 -15
- package/dist/runtime/components/_internal/NuGridRow.vue +12 -4
- package/dist/runtime/components/_internal/NuGridSplitGroup.vue +22 -16
- package/dist/runtime/composables/_internal/column-flex-style.d.ts +22 -0
- package/dist/runtime/composables/_internal/column-flex-style.js +84 -0
- package/dist/runtime/composables/_internal/index.d.ts +1 -0
- package/dist/runtime/composables/_internal/index.js +1 -0
- package/dist/runtime/composables/_internal/useNuGridAddRow.js +5 -1
- package/dist/runtime/composables/_internal/useNuGridAutosize.d.ts +6 -3
- package/dist/runtime/composables/_internal/useNuGridAutosize.js +91 -9
- package/dist/runtime/composables/_internal/useNuGridCellEditing.js +3 -2
- package/dist/runtime/composables/_internal/useNuGridColumnResize.d.ts +17 -7
- package/dist/runtime/composables/_internal/useNuGridColumnResize.js +219 -8
- package/dist/runtime/composables/_internal/useNuGridCore.d.ts +1 -1
- package/dist/runtime/composables/_internal/useNuGridCore.js +16 -5
- package/dist/runtime/composables/_internal/useNuGridFocus.js +1 -1
- package/dist/runtime/composables/_internal/useNuGridRowSelection.js +1 -1
- package/dist/runtime/composables/_internal/useNuGridStatePersistence.d.ts +14 -1
- package/dist/runtime/composables/_internal/useNuGridStatePersistence.js +66 -3
- package/dist/runtime/composables/_internal/useNuGridUI.d.ts +116 -0
- package/dist/runtime/config/_internal/options-defaults.d.ts +3 -4
- package/dist/runtime/config/_internal/options-defaults.js +3 -4
- package/dist/runtime/config/_internal/prop-utils.d.ts +7 -1
- package/dist/runtime/config/_internal/prop-utils.js +20 -6
- package/dist/runtime/config/presets.js +2 -2
- package/dist/runtime/themes/nuGridTheme.d.ts +2 -0
- package/dist/runtime/themes/nuGridTheme.js +7 -4
- package/dist/runtime/themes/nuGridThemeCompact.d.ts +2 -0
- package/dist/runtime/themes/nuGridThemeCompact.js +7 -4
- package/dist/runtime/types/_internal/contexts/resize.d.ts +1 -0
- package/dist/runtime/types/_internal/contexts/ui-config.d.ts +4 -2
- package/dist/runtime/types/autosize.d.ts +4 -1
- package/dist/runtime/types/column.d.ts +41 -3
- package/dist/runtime/types/index.d.ts +2 -1
- package/dist/runtime/types/option-groups.d.ts +26 -8
- package/dist/runtime/types/props.d.ts +34 -9
- package/dist/runtime/types/resize.d.ts +2 -0
- package/dist/runtime/types/slots.d.ts +32 -0
- package/dist/runtime/types/slots.js +0 -0
- package/dist/runtime/types/tanstack-table.d.ts +3 -2
- package/dist/runtime/utils/index.d.ts +1 -0
- package/dist/runtime/utils/index.js +1 -0
- package/dist/runtime/utils/inferCellDataType.d.ts +27 -0
- package/dist/runtime/utils/inferCellDataType.js +91 -0
- package/package.json +1 -1
- package/dist/runtime/components/NuGridGroup.d.vue.ts +0 -20
- package/dist/runtime/components/NuGridGroup.vue +0 -650
- package/dist/runtime/components/NuGridGroup.vue.d.ts +0 -20
package/dist/module.json
CHANGED
|
@@ -9,5 +9,19 @@ export const dateCellType = {
|
|
|
9
9
|
component: DateFilter,
|
|
10
10
|
defaultOperator: "equals"
|
|
11
11
|
},
|
|
12
|
-
enableFiltering: true
|
|
12
|
+
enableFiltering: true,
|
|
13
|
+
formatter: (value, context) => {
|
|
14
|
+
if (value === null || value === void 0) return "";
|
|
15
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
16
|
+
if (Number.isNaN(date.getTime())) return String(value);
|
|
17
|
+
const locale = context.columnDef.locale || "en-US";
|
|
18
|
+
return date.toLocaleDateString(locale, {
|
|
19
|
+
year: "numeric",
|
|
20
|
+
month: "numeric",
|
|
21
|
+
day: "numeric"
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
defaultColumnDef: {
|
|
25
|
+
size: 100
|
|
26
|
+
}
|
|
13
27
|
};
|
|
@@ -5,6 +5,7 @@ import { currencyCellType } from './currency/index.js';
|
|
|
5
5
|
import { dateCellType } from './date/index.js';
|
|
6
6
|
import { lookupCellType } from './lookup/index.js';
|
|
7
7
|
import { numberCellType } from './number/index.js';
|
|
8
|
+
import { percentageCellType } from './percentage/index.js';
|
|
8
9
|
import { ratingCellType } from './rating/index.js';
|
|
9
10
|
import { selectionCellType } from './selection/index.js';
|
|
10
11
|
import { textareaCellType, textCellType } from './text/index.js';
|
|
@@ -13,5 +14,5 @@ import { textareaCellType, textCellType } from './text/index.js';
|
|
|
13
14
|
* These are automatically registered in the cell type registry
|
|
14
15
|
*/
|
|
15
16
|
export declare const builtInCellTypes: NuGridCellType[];
|
|
16
|
-
export { actionMenuCellType, booleanCellType, currencyCellType, dateCellType, lookupCellType, numberCellType, ratingCellType, selectionCellType, textareaCellType, textCellType, };
|
|
17
|
+
export { actionMenuCellType, booleanCellType, currencyCellType, dateCellType, lookupCellType, numberCellType, percentageCellType, ratingCellType, selectionCellType, textareaCellType, textCellType, };
|
|
17
18
|
export { TextareaEditor } from './text/index.js';
|
|
@@ -4,6 +4,7 @@ import { currencyCellType } from "./currency/index.js";
|
|
|
4
4
|
import { dateCellType } from "./date/index.js";
|
|
5
5
|
import { lookupCellType } from "./lookup/index.js";
|
|
6
6
|
import { numberCellType } from "./number/index.js";
|
|
7
|
+
import { percentageCellType } from "./percentage/index.js";
|
|
7
8
|
import { ratingCellType } from "./rating/index.js";
|
|
8
9
|
import { selectionCellType } from "./selection/index.js";
|
|
9
10
|
import { textareaCellType, textCellType } from "./text/index.js";
|
|
@@ -17,6 +18,7 @@ export const builtInCellTypes = [
|
|
|
17
18
|
actionMenuCellType,
|
|
18
19
|
ratingCellType,
|
|
19
20
|
currencyCellType,
|
|
21
|
+
percentageCellType,
|
|
20
22
|
lookupCellType
|
|
21
23
|
];
|
|
22
24
|
export {
|
|
@@ -26,6 +28,7 @@ export {
|
|
|
26
28
|
dateCellType,
|
|
27
29
|
lookupCellType,
|
|
28
30
|
numberCellType,
|
|
31
|
+
percentageCellType,
|
|
29
32
|
ratingCellType,
|
|
30
33
|
selectionCellType,
|
|
31
34
|
textareaCellType,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NuGridCellEditorProps } from '../../types/index.js';
|
|
2
|
+
type __VLS_Props = NuGridCellEditorProps;
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
4
|
+
"update:modelValue": (value: any) => any;
|
|
5
|
+
"update:isNavigating": (value: boolean) => any;
|
|
6
|
+
"stop-editing": (moveDirection?: "up" | "down" | "next" | "previous" | undefined) => any;
|
|
7
|
+
"cancel-editing": () => any;
|
|
8
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
|
+
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
10
|
+
"onUpdate:isNavigating"?: ((value: boolean) => any) | undefined;
|
|
11
|
+
"onStop-editing"?: ((moveDirection?: "up" | "down" | "next" | "previous" | undefined) => any) | undefined;
|
|
12
|
+
"onCancel-editing"?: (() => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
import { useNuGridCellEditor } from "../../composables";
|
|
4
|
+
defineOptions({ inheritAttrs: false });
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
modelValue: { type: null, required: true },
|
|
7
|
+
cell: { type: null, required: true },
|
|
8
|
+
row: { type: Object, required: true },
|
|
9
|
+
isNavigating: { type: Boolean, required: true },
|
|
10
|
+
shouldFocus: { type: Boolean, required: true },
|
|
11
|
+
validationError: { type: [String, null], required: false },
|
|
12
|
+
showValidationErrors: { type: String, required: false },
|
|
13
|
+
interactionRouter: { type: Object, required: false }
|
|
14
|
+
});
|
|
15
|
+
const emit = defineEmits(["update:modelValue", "stop-editing", "cancel-editing", "update:isNavigating"]);
|
|
16
|
+
const inputRef = ref(null);
|
|
17
|
+
const { handleKeydown, handleBlur } = useNuGridCellEditor(props, emit, inputRef);
|
|
18
|
+
const storageMode = computed(
|
|
19
|
+
() => props.cell?.column?.columnDef?.percentageStorage ?? "decimal"
|
|
20
|
+
);
|
|
21
|
+
const displayValue = computed(() => {
|
|
22
|
+
if (props.modelValue === null || props.modelValue === void 0) return "";
|
|
23
|
+
const numValue = Number(props.modelValue);
|
|
24
|
+
if (Number.isNaN(numValue)) return "";
|
|
25
|
+
return storageMode.value === "decimal" ? numValue * 100 : numValue;
|
|
26
|
+
});
|
|
27
|
+
const handleInput = (value) => {
|
|
28
|
+
if (value === "" || value === null || value === void 0) {
|
|
29
|
+
emit("update:modelValue", null);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const numValue = Number(value);
|
|
33
|
+
if (Number.isNaN(numValue)) {
|
|
34
|
+
emit("update:modelValue", null);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const storageValue = storageMode.value === "decimal" ? numValue / 100 : numValue;
|
|
38
|
+
emit("update:modelValue", storageValue);
|
|
39
|
+
};
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<div class="flex items-center w-full">
|
|
44
|
+
<UInput
|
|
45
|
+
ref="inputRef"
|
|
46
|
+
:model-value="displayValue"
|
|
47
|
+
type="number"
|
|
48
|
+
step="0.1"
|
|
49
|
+
class="w-full pl-0.5!"
|
|
50
|
+
@update:model-value="handleInput"
|
|
51
|
+
@blur="handleBlur"
|
|
52
|
+
@keydown="handleKeydown"
|
|
53
|
+
/>
|
|
54
|
+
<span class="ml-1 text-gray-500 dark:text-gray-400 shrink-0">%</span>
|
|
55
|
+
</div>
|
|
56
|
+
</template>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NuGridCellEditorProps } from '../../types/index.js';
|
|
2
|
+
type __VLS_Props = NuGridCellEditorProps;
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
4
|
+
"update:modelValue": (value: any) => any;
|
|
5
|
+
"update:isNavigating": (value: boolean) => any;
|
|
6
|
+
"stop-editing": (moveDirection?: "up" | "down" | "next" | "previous" | undefined) => any;
|
|
7
|
+
"cancel-editing": () => any;
|
|
8
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
|
+
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
10
|
+
"onUpdate:isNavigating"?: ((value: boolean) => any) | undefined;
|
|
11
|
+
"onStop-editing"?: ((moveDirection?: "up" | "down" | "next" | "previous" | undefined) => any) | undefined;
|
|
12
|
+
"onCancel-editing"?: (() => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NuGridFilterContext } from '../../types/cells.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
context: NuGridFilterContext;
|
|
4
|
+
}
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
context: { type: Object, required: true }
|
|
5
|
+
});
|
|
6
|
+
const filterValue = computed({
|
|
7
|
+
get: () => props.context.filterValue.value,
|
|
8
|
+
set: (value) => props.context.setFilterValue(value)
|
|
9
|
+
});
|
|
10
|
+
const operator = ref("equals");
|
|
11
|
+
const operators = [
|
|
12
|
+
{ value: "equals", label: "Equals" },
|
|
13
|
+
{ value: "greaterThan", label: "Greater than" },
|
|
14
|
+
{ value: "lessThan", label: "Less than" },
|
|
15
|
+
{ value: "greaterThanOrEqual", label: "Greater than or equal" },
|
|
16
|
+
{ value: "lessThanOrEqual", label: "Less than or equal" },
|
|
17
|
+
{ value: "between", label: "Between" }
|
|
18
|
+
];
|
|
19
|
+
const filterValue2 = ref(null);
|
|
20
|
+
function clearFilter() {
|
|
21
|
+
filterValue.value = null;
|
|
22
|
+
filterValue2.value = null;
|
|
23
|
+
props.context.clearFilter();
|
|
24
|
+
}
|
|
25
|
+
function toStorageValue(displayValue) {
|
|
26
|
+
if (displayValue === null || displayValue === "") return null;
|
|
27
|
+
const num = Number(displayValue);
|
|
28
|
+
if (Number.isNaN(num)) return null;
|
|
29
|
+
return num / 100;
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<div class="min-w-[200px] space-y-2 p-2">
|
|
35
|
+
<div class="flex items-center gap-2">
|
|
36
|
+
<USelect
|
|
37
|
+
v-model="operator"
|
|
38
|
+
:options="operators"
|
|
39
|
+
option-attribute="label"
|
|
40
|
+
value-attribute="value"
|
|
41
|
+
class="flex-1"
|
|
42
|
+
/>
|
|
43
|
+
<UButton
|
|
44
|
+
v-if="context.isFiltered"
|
|
45
|
+
icon="i-heroicons-x-mark"
|
|
46
|
+
size="xs"
|
|
47
|
+
color="neutral"
|
|
48
|
+
variant="ghost"
|
|
49
|
+
@click="clearFilter"
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
<div class="flex items-center gap-1">
|
|
53
|
+
<UInput
|
|
54
|
+
v-model="filterValue"
|
|
55
|
+
type="number"
|
|
56
|
+
placeholder="Value..."
|
|
57
|
+
autofocus
|
|
58
|
+
class="flex-1"
|
|
59
|
+
@update:model-value="context.setFilterValue(toStorageValue($event))"
|
|
60
|
+
/>
|
|
61
|
+
<span class="text-gray-500 dark:text-gray-400 shrink-0">%</span>
|
|
62
|
+
</div>
|
|
63
|
+
<div v-if="operator === 'between'" class="flex items-center gap-1">
|
|
64
|
+
<UInput
|
|
65
|
+
v-model="filterValue2"
|
|
66
|
+
type="number"
|
|
67
|
+
placeholder="To..."
|
|
68
|
+
class="flex-1"
|
|
69
|
+
@update:model-value="
|
|
70
|
+
context.setFilterValue({
|
|
71
|
+
from: toStorageValue(filterValue),
|
|
72
|
+
to: toStorageValue(filterValue2)
|
|
73
|
+
})
|
|
74
|
+
"
|
|
75
|
+
/>
|
|
76
|
+
<span class="text-gray-500 dark:text-gray-400 shrink-0">%</span>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</template>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NuGridFilterContext } from '../../types/cells.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
context: NuGridFilterContext;
|
|
4
|
+
}
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NuGridCellType } from '../../types/cells.js';
|
|
2
|
+
/**
|
|
3
|
+
* Percentage cell type
|
|
4
|
+
* Displays values as percentages with % suffix
|
|
5
|
+
*
|
|
6
|
+
* Storage modes (configurable via percentageStorage column option):
|
|
7
|
+
* - 'decimal' (default): Values stored as 0-1, displayed as 0-100%
|
|
8
|
+
* - 'percent': Values stored as 0-100, displayed as 0-100%
|
|
9
|
+
*/
|
|
10
|
+
export declare const percentageCellType: NuGridCellType;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import PercentageEditor from "./PercentageEditor.vue";
|
|
2
|
+
import PercentageFilter from "./PercentageFilter.vue";
|
|
3
|
+
export const percentageCellType = {
|
|
4
|
+
name: "percentage",
|
|
5
|
+
displayName: "Percentage",
|
|
6
|
+
description: "Percentage column with % formatting",
|
|
7
|
+
editor: PercentageEditor,
|
|
8
|
+
filter: {
|
|
9
|
+
component: PercentageFilter,
|
|
10
|
+
defaultOperator: "equals"
|
|
11
|
+
},
|
|
12
|
+
enableFiltering: true,
|
|
13
|
+
validation: (value) => {
|
|
14
|
+
if (value === null || value === void 0) {
|
|
15
|
+
return { valid: true };
|
|
16
|
+
}
|
|
17
|
+
const numValue = Number(value);
|
|
18
|
+
if (Number.isNaN(numValue)) {
|
|
19
|
+
return {
|
|
20
|
+
valid: false,
|
|
21
|
+
message: "Value must be a valid number"
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return { valid: true };
|
|
25
|
+
},
|
|
26
|
+
formatter: (value, context) => {
|
|
27
|
+
if (value === null || value === void 0) return "";
|
|
28
|
+
const numValue = Number(value);
|
|
29
|
+
if (Number.isNaN(numValue)) return String(value);
|
|
30
|
+
const storageMode = context.columnDef.percentageStorage ?? "decimal";
|
|
31
|
+
const displayValue = storageMode === "decimal" ? numValue * 100 : numValue;
|
|
32
|
+
const decimals = context.columnDef.percentageDecimals ?? 1;
|
|
33
|
+
return `${displayValue.toFixed(decimals)}%`;
|
|
34
|
+
},
|
|
35
|
+
defaultColumnDef: {
|
|
36
|
+
size: 100
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TableData, TableSlots } from '@nuxt/ui';
|
|
2
2
|
import type { ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingInfoState, ColumnSizingState, ExpandedState, GroupingState, PaginationState, RowPinningState, RowSelectionState, SortingState, VisibilityState } from '@tanstack/vue-table';
|
|
3
|
+
import type { Ref } from 'vue';
|
|
3
4
|
import type { NuGridStateSnapshot } from '../composables/_internal/useNuGridStatePersistence.js';
|
|
4
5
|
import type { NuGridAddRowState, NuGridCellClickEvent, NuGridCellEditingCancelledEvent, NuGridCellEditingStartedEvent, NuGridCellValueChangedEvent, NuGridExcelExportOptions, NuGridFilterChangedEvent, NuGridFocusedCellChangedEvent, NuGridFocusedRowChangedEvent, NuGridProps, NuGridRowClickEvent, NuGridSortChangedEvent } from '../types/index.js';
|
|
5
6
|
import type { RowDragEvent } from '../types/drag-drop.js';
|
|
@@ -12,7 +13,7 @@ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Await
|
|
|
12
13
|
columnPinning?: ColumnPinningState;
|
|
13
14
|
columnSizing?: ColumnSizingState;
|
|
14
15
|
columnSizingInfo?: ColumnSizingInfoState;
|
|
15
|
-
|
|
16
|
+
selectedRows?: RowSelectionState;
|
|
16
17
|
rowPinning?: RowPinningState;
|
|
17
18
|
sorting?: SortingState;
|
|
18
19
|
grouping?: GroupingState;
|
|
@@ -44,7 +45,7 @@ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Await
|
|
|
44
45
|
"onUpdate:columnPinning"?: ((value: ColumnPinningState) => any) | undefined;
|
|
45
46
|
"onUpdate:columnSizing"?: ((value: ColumnSizingState) => any) | undefined;
|
|
46
47
|
"onUpdate:columnSizingInfo"?: ((value: ColumnSizingInfoState) => any) | undefined;
|
|
47
|
-
"onUpdate:
|
|
48
|
+
"onUpdate:selectedRows"?: ((value: RowSelectionState) => any) | undefined;
|
|
48
49
|
"onUpdate:rowPinning"?: ((value: RowPinningState) => any) | undefined;
|
|
49
50
|
"onUpdate:sorting"?: ((value: SortingState) => any) | undefined;
|
|
50
51
|
"onUpdate:grouping"?: ((value: GroupingState) => any) | undefined;
|
|
@@ -56,12 +57,14 @@ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Await
|
|
|
56
57
|
} ? P : {});
|
|
57
58
|
expose: (exposed: import("vue").ShallowUnwrapRef<{
|
|
58
59
|
readonly $el: any;
|
|
59
|
-
tableRef:
|
|
60
|
+
tableRef: Ref<HTMLDivElement | null, HTMLDivElement | null>;
|
|
60
61
|
tableApi: import("@tanstack/table-core").Table<T>;
|
|
61
|
-
autoSizeColumns: (mode?: "
|
|
62
|
+
autoSizeColumns: (mode?: "content" | "fill") => void;
|
|
62
63
|
autoSizeColumn: (columnId: string) => void;
|
|
64
|
+
autosizeReady: Ref<boolean, boolean>;
|
|
63
65
|
getState: () => {};
|
|
64
66
|
setState: (_snapshot: NuGridStateSnapshot) => void;
|
|
67
|
+
clearState: () => void;
|
|
65
68
|
addRowState: import("vue").ComputedRef<NuGridAddRowState>;
|
|
66
69
|
excelExport: (filenameOrOptions?: string | NuGridExcelExportOptions, sheetName?: string) => Promise<void>;
|
|
67
70
|
getSelectedRows: <TRow = T>() => TRow[];
|
|
@@ -83,7 +86,7 @@ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Await
|
|
|
83
86
|
}>) => void;
|
|
84
87
|
attrs: any;
|
|
85
88
|
slots: TableSlots<T>;
|
|
86
|
-
emit: (((evt: "rowDragged", event: RowDragEvent<T>) => void) & ((evt: "cellEditingCancelled", event: NuGridCellEditingCancelledEvent<T>) => void) & ((evt: "cellEditingStarted", event: NuGridCellEditingStartedEvent<T>) => void) & ((evt: "stateChanged", state: NuGridStateSnapshot) => void) & ((evt: "filterChanged", event: NuGridFilterChangedEvent) => void) & ((evt: "sortChanged", event: NuGridSortChangedEvent) => void) & ((evt: "focusedRowChanged", event: NuGridFocusedRowChangedEvent<T>) => void) & ((evt: "focusedCellChanged", event: NuGridFocusedCellChangedEvent<T>) => void) & ((evt: "cellClicked", event: NuGridCellClickEvent<T>) => void) & ((evt: "rowClicked", event: NuGridRowClickEvent<T>) => void) & ((evt: "cellDoubleClicked", event: NuGridCellClickEvent<T>) => void) & ((evt: "rowDoubleClicked", event: NuGridRowClickEvent<T>) => void) & ((evt: "cellValueChanged", event: NuGridCellValueChangedEvent<T>) => void) & ((evt: "rowSelectionChanged", event: RowSelectionState) => void) & ((evt: "ready") => void) & ((evt: "rowAddRequested", row: T) => void) & ((evt: "addRowStateChanged", state: NuGridAddRowState) => void)) & (((evt: "update:globalFilter", value: string) => void) & ((evt: "update:columnFilters", value: ColumnFiltersState) => void) & ((evt: "update:columnOrder", value: ColumnOrderState) => void) & ((evt: "update:columnVisibility", value: VisibilityState) => void) & ((evt: "update:columnPinning", value: ColumnPinningState) => void) & ((evt: "update:columnSizing", value: ColumnSizingState) => void) & ((evt: "update:columnSizingInfo", value: ColumnSizingInfoState) => void) & ((evt: "update:
|
|
89
|
+
emit: (((evt: "rowDragged", event: RowDragEvent<T>) => void) & ((evt: "cellEditingCancelled", event: NuGridCellEditingCancelledEvent<T>) => void) & ((evt: "cellEditingStarted", event: NuGridCellEditingStartedEvent<T>) => void) & ((evt: "stateChanged", state: NuGridStateSnapshot) => void) & ((evt: "filterChanged", event: NuGridFilterChangedEvent) => void) & ((evt: "sortChanged", event: NuGridSortChangedEvent) => void) & ((evt: "focusedRowChanged", event: NuGridFocusedRowChangedEvent<T>) => void) & ((evt: "focusedCellChanged", event: NuGridFocusedCellChangedEvent<T>) => void) & ((evt: "cellClicked", event: NuGridCellClickEvent<T>) => void) & ((evt: "rowClicked", event: NuGridRowClickEvent<T>) => void) & ((evt: "cellDoubleClicked", event: NuGridCellClickEvent<T>) => void) & ((evt: "rowDoubleClicked", event: NuGridRowClickEvent<T>) => void) & ((evt: "cellValueChanged", event: NuGridCellValueChangedEvent<T>) => void) & ((evt: "rowSelectionChanged", event: RowSelectionState) => void) & ((evt: "ready") => void) & ((evt: "rowAddRequested", row: T) => void) & ((evt: "addRowStateChanged", state: NuGridAddRowState) => void)) & (((evt: "update:globalFilter", value: string) => void) & ((evt: "update:columnFilters", value: ColumnFiltersState) => void) & ((evt: "update:columnOrder", value: ColumnOrderState) => void) & ((evt: "update:columnVisibility", value: VisibilityState) => void) & ((evt: "update:columnPinning", value: ColumnPinningState) => void) & ((evt: "update:columnSizing", value: ColumnSizingState) => void) & ((evt: "update:columnSizingInfo", value: ColumnSizingInfoState) => void) & ((evt: "update:selectedRows", value: RowSelectionState) => void) & ((evt: "update:rowPinning", value: RowPinningState) => void) & ((evt: "update:sorting", value: SortingState) => void) & ((evt: "update:grouping", value: GroupingState) => void) & ((evt: "update:expanded", value: ExpandedState) => void) & ((evt: "update:pagination", value: PaginationState) => void) & ((evt: "update:focusedRowId", value: string | null) => void));
|
|
87
90
|
}>) => import("vue").VNode & {
|
|
88
91
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
89
92
|
};
|
|
@@ -43,9 +43,9 @@ const props = defineProps({
|
|
|
43
43
|
ui: { type: null, required: false },
|
|
44
44
|
preset: { type: String, required: false },
|
|
45
45
|
focus: { type: Object, required: false },
|
|
46
|
-
editing: { type: Object, required: false },
|
|
46
|
+
editing: { type: [Boolean, Object], required: false },
|
|
47
47
|
validation: { type: [Boolean, Object], required: false },
|
|
48
|
-
|
|
48
|
+
rowSelection: { type: [Boolean, String, Object], required: false },
|
|
49
49
|
actions: { type: [Boolean, Object], required: false },
|
|
50
50
|
columnDefaults: { type: Object, required: false },
|
|
51
51
|
layout: { type: Object, required: false },
|
|
@@ -57,7 +57,7 @@ const props = defineProps({
|
|
|
57
57
|
theme: { type: [String, Object], required: false },
|
|
58
58
|
virtualization: { type: [Boolean, Object], required: false },
|
|
59
59
|
cellTypes: { type: Array, required: false },
|
|
60
|
-
|
|
60
|
+
dataTypeInference: { type: Boolean, required: false },
|
|
61
61
|
rowDragOptions: { type: Object, required: false },
|
|
62
62
|
rowId: { type: [String, Function], required: false },
|
|
63
63
|
addNewRow: { type: [Boolean, Object], required: false },
|
|
@@ -143,7 +143,7 @@ const columnSizingState = defineModel("columnSizing", { type: Object, ...{ defau
|
|
|
143
143
|
const columnSizingInfoState = defineModel("columnSizingInfo", { type: Object, ...{
|
|
144
144
|
default: {}
|
|
145
145
|
} });
|
|
146
|
-
const rowSelectionState = defineModel("
|
|
146
|
+
const rowSelectionState = defineModel("selectedRows", { type: Object, ...{ default: {} } });
|
|
147
147
|
const rowPinningState = defineModel("rowPinning", { type: Object, ...{ default: {} } });
|
|
148
148
|
const sortingState = defineModel("sorting", { type: Array, ...{ default: [] } });
|
|
149
149
|
const groupingState = defineModel("grouping", { type: Array, ...{ default: [] } });
|
|
@@ -160,14 +160,18 @@ const initPaginationState = () => {
|
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
initPaginationState();
|
|
163
|
-
const rowSelectionModeRef = computed(
|
|
163
|
+
const rowSelectionModeRef = computed(
|
|
164
|
+
() => hasRowSlot.value ? false : props.rowSelection ?? false
|
|
165
|
+
);
|
|
164
166
|
const actionMenuRef = computed(() => props.actions ?? false);
|
|
167
|
+
const dataTypeInferenceRef = computed(() => props.dataTypeInference ?? true);
|
|
165
168
|
const { columns } = useNuGridColumns(
|
|
166
169
|
propsColumns,
|
|
167
170
|
data,
|
|
168
171
|
rowSelectionModeRef,
|
|
169
172
|
actionMenuRef,
|
|
170
|
-
columnVisibilityState
|
|
173
|
+
columnVisibilityState,
|
|
174
|
+
dataTypeInferenceRef
|
|
171
175
|
);
|
|
172
176
|
const { ui, checkboxTheme } = useNuGridUI(props);
|
|
173
177
|
const { hasFooter } = useNuGridFooter(columns);
|
|
@@ -250,6 +254,7 @@ watch(
|
|
|
250
254
|
);
|
|
251
255
|
const rows = orderedRows;
|
|
252
256
|
const stickyEnabled = computed(() => props.layout?.stickyHeaders ?? false);
|
|
257
|
+
const resizeMode = computed(() => props.layout?.resizeMode ?? "shift");
|
|
253
258
|
const {
|
|
254
259
|
virtualizer,
|
|
255
260
|
virtualizationEnabled,
|
|
@@ -266,7 +271,21 @@ const {
|
|
|
266
271
|
stickyEnabled,
|
|
267
272
|
hasFooter
|
|
268
273
|
});
|
|
269
|
-
const {
|
|
274
|
+
const {
|
|
275
|
+
handleResizeStart,
|
|
276
|
+
handleGroupResizeStart,
|
|
277
|
+
resizingGroupId,
|
|
278
|
+
resizingColumnId,
|
|
279
|
+
manuallyResizedColumns,
|
|
280
|
+
getContainerWidth,
|
|
281
|
+
getSizingAsRatios,
|
|
282
|
+
applySizingFromRatios
|
|
283
|
+
} = useNuGridColumnResize(props, tableApi, tableRef);
|
|
284
|
+
statePersistence.setResizeHelpers({
|
|
285
|
+
getContainerWidth,
|
|
286
|
+
getSizingAsRatios,
|
|
287
|
+
applySizingFromRatios
|
|
288
|
+
});
|
|
270
289
|
const dragFns = useNuGridColumnDragDrop(tableApi, states.columnOrderState, tableRef);
|
|
271
290
|
const rowDragOptions = computed(() => props.rowDragOptions || { enabled: false });
|
|
272
291
|
const rowDragFns = useNuGridRowDragDrop(
|
|
@@ -439,7 +458,8 @@ provide("nugrid-resize", {
|
|
|
439
458
|
handleResizeStart,
|
|
440
459
|
handleGroupResizeStart,
|
|
441
460
|
resizingGroupId,
|
|
442
|
-
resizingColumnId
|
|
461
|
+
resizingColumnId,
|
|
462
|
+
manuallyResizedColumns
|
|
443
463
|
});
|
|
444
464
|
provide("nugrid-virtualization", {
|
|
445
465
|
virtualizer,
|
|
@@ -470,7 +490,9 @@ provide("nugrid-ui-config", {
|
|
|
470
490
|
showColumnVisibility: computed(() => props.columnDefaults?.menu?.visibilityToggle ?? true),
|
|
471
491
|
columnMenuButton: computed(() => props.columnDefaults?.menu?.button),
|
|
472
492
|
wrapText: computed(() => props.columnDefaults?.wrapText ?? false),
|
|
473
|
-
checkboxTheme
|
|
493
|
+
checkboxTheme,
|
|
494
|
+
autoSizeMode: autosizeFns.autoSizeMode,
|
|
495
|
+
resizeMode
|
|
474
496
|
});
|
|
475
497
|
provide("nugrid-validation", {
|
|
476
498
|
// Expose validation error display settings so editors can inject without prop wiring
|
|
@@ -484,6 +506,10 @@ provide("nugrid-row-interactions", {
|
|
|
484
506
|
provide("nugrid-interaction-router", {
|
|
485
507
|
interactionRouter
|
|
486
508
|
});
|
|
509
|
+
const cellSlots = Object.fromEntries(
|
|
510
|
+
Object.entries(slots).filter(([name]) => name.endsWith("-cell"))
|
|
511
|
+
);
|
|
512
|
+
provide("nugrid-cell-slots", cellSlots);
|
|
487
513
|
provide(NUGRID_EVENTS_KEY, eventEmitter);
|
|
488
514
|
provide("nugrid-multi-row", {
|
|
489
515
|
enabled: computed(() => {
|
|
@@ -543,6 +569,7 @@ provide("nugrid-scroll-state", {
|
|
|
543
569
|
useNuGridFocusInit(props, focusFns, groupingFns?.navigableRows ?? rows);
|
|
544
570
|
onMounted(() => {
|
|
545
571
|
nextTick(() => {
|
|
572
|
+
statePersistence.applyPendingRatios();
|
|
546
573
|
emit("ready");
|
|
547
574
|
});
|
|
548
575
|
});
|
|
@@ -605,8 +632,13 @@ defineExpose({
|
|
|
605
632
|
tableApi,
|
|
606
633
|
autoSizeColumns: autosizeFns.autoSizeColumns,
|
|
607
634
|
autoSizeColumn: autosizeFns.autoSizeColumn,
|
|
635
|
+
autosizeReady: autosizeFns.autosizeReady,
|
|
608
636
|
getState: statePersistence.getState,
|
|
609
637
|
setState: statePersistence.setState,
|
|
638
|
+
clearState: () => {
|
|
639
|
+
statePersistence.clearState();
|
|
640
|
+
manuallyResizedColumns.value = /* @__PURE__ */ new Set();
|
|
641
|
+
},
|
|
610
642
|
addRowState,
|
|
611
643
|
excelExport,
|
|
612
644
|
getSelectedRows,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TableData, TableSlots } from '@nuxt/ui';
|
|
2
2
|
import type { ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingInfoState, ColumnSizingState, ExpandedState, GroupingState, PaginationState, RowPinningState, RowSelectionState, SortingState, VisibilityState } from '@tanstack/vue-table';
|
|
3
|
+
import type { Ref } from 'vue';
|
|
3
4
|
import type { NuGridStateSnapshot } from '../composables/_internal/useNuGridStatePersistence.js';
|
|
4
5
|
import type { NuGridAddRowState, NuGridCellClickEvent, NuGridCellEditingCancelledEvent, NuGridCellEditingStartedEvent, NuGridCellValueChangedEvent, NuGridExcelExportOptions, NuGridFilterChangedEvent, NuGridFocusedCellChangedEvent, NuGridFocusedRowChangedEvent, NuGridProps, NuGridRowClickEvent, NuGridSortChangedEvent } from '../types/index.js';
|
|
5
6
|
import type { RowDragEvent } from '../types/drag-drop.js';
|
|
@@ -12,7 +13,7 @@ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Await
|
|
|
12
13
|
columnPinning?: ColumnPinningState;
|
|
13
14
|
columnSizing?: ColumnSizingState;
|
|
14
15
|
columnSizingInfo?: ColumnSizingInfoState;
|
|
15
|
-
|
|
16
|
+
selectedRows?: RowSelectionState;
|
|
16
17
|
rowPinning?: RowPinningState;
|
|
17
18
|
sorting?: SortingState;
|
|
18
19
|
grouping?: GroupingState;
|
|
@@ -44,7 +45,7 @@ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Await
|
|
|
44
45
|
"onUpdate:columnPinning"?: ((value: ColumnPinningState) => any) | undefined;
|
|
45
46
|
"onUpdate:columnSizing"?: ((value: ColumnSizingState) => any) | undefined;
|
|
46
47
|
"onUpdate:columnSizingInfo"?: ((value: ColumnSizingInfoState) => any) | undefined;
|
|
47
|
-
"onUpdate:
|
|
48
|
+
"onUpdate:selectedRows"?: ((value: RowSelectionState) => any) | undefined;
|
|
48
49
|
"onUpdate:rowPinning"?: ((value: RowPinningState) => any) | undefined;
|
|
49
50
|
"onUpdate:sorting"?: ((value: SortingState) => any) | undefined;
|
|
50
51
|
"onUpdate:grouping"?: ((value: GroupingState) => any) | undefined;
|
|
@@ -56,12 +57,14 @@ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Await
|
|
|
56
57
|
} ? P : {});
|
|
57
58
|
expose: (exposed: import("vue").ShallowUnwrapRef<{
|
|
58
59
|
readonly $el: any;
|
|
59
|
-
tableRef:
|
|
60
|
+
tableRef: Ref<HTMLDivElement | null, HTMLDivElement | null>;
|
|
60
61
|
tableApi: import("@tanstack/table-core").Table<T>;
|
|
61
|
-
autoSizeColumns: (mode?: "
|
|
62
|
+
autoSizeColumns: (mode?: "content" | "fill") => void;
|
|
62
63
|
autoSizeColumn: (columnId: string) => void;
|
|
64
|
+
autosizeReady: Ref<boolean, boolean>;
|
|
63
65
|
getState: () => {};
|
|
64
66
|
setState: (_snapshot: NuGridStateSnapshot) => void;
|
|
67
|
+
clearState: () => void;
|
|
65
68
|
addRowState: import("vue").ComputedRef<NuGridAddRowState>;
|
|
66
69
|
excelExport: (filenameOrOptions?: string | NuGridExcelExportOptions, sheetName?: string) => Promise<void>;
|
|
67
70
|
getSelectedRows: <TRow = T>() => TRow[];
|
|
@@ -83,7 +86,7 @@ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Await
|
|
|
83
86
|
}>) => void;
|
|
84
87
|
attrs: any;
|
|
85
88
|
slots: TableSlots<T>;
|
|
86
|
-
emit: (((evt: "rowDragged", event: RowDragEvent<T>) => void) & ((evt: "cellEditingCancelled", event: NuGridCellEditingCancelledEvent<T>) => void) & ((evt: "cellEditingStarted", event: NuGridCellEditingStartedEvent<T>) => void) & ((evt: "stateChanged", state: NuGridStateSnapshot) => void) & ((evt: "filterChanged", event: NuGridFilterChangedEvent) => void) & ((evt: "sortChanged", event: NuGridSortChangedEvent) => void) & ((evt: "focusedRowChanged", event: NuGridFocusedRowChangedEvent<T>) => void) & ((evt: "focusedCellChanged", event: NuGridFocusedCellChangedEvent<T>) => void) & ((evt: "cellClicked", event: NuGridCellClickEvent<T>) => void) & ((evt: "rowClicked", event: NuGridRowClickEvent<T>) => void) & ((evt: "cellDoubleClicked", event: NuGridCellClickEvent<T>) => void) & ((evt: "rowDoubleClicked", event: NuGridRowClickEvent<T>) => void) & ((evt: "cellValueChanged", event: NuGridCellValueChangedEvent<T>) => void) & ((evt: "rowSelectionChanged", event: RowSelectionState) => void) & ((evt: "ready") => void) & ((evt: "rowAddRequested", row: T) => void) & ((evt: "addRowStateChanged", state: NuGridAddRowState) => void)) & (((evt: "update:globalFilter", value: string) => void) & ((evt: "update:columnFilters", value: ColumnFiltersState) => void) & ((evt: "update:columnOrder", value: ColumnOrderState) => void) & ((evt: "update:columnVisibility", value: VisibilityState) => void) & ((evt: "update:columnPinning", value: ColumnPinningState) => void) & ((evt: "update:columnSizing", value: ColumnSizingState) => void) & ((evt: "update:columnSizingInfo", value: ColumnSizingInfoState) => void) & ((evt: "update:
|
|
89
|
+
emit: (((evt: "rowDragged", event: RowDragEvent<T>) => void) & ((evt: "cellEditingCancelled", event: NuGridCellEditingCancelledEvent<T>) => void) & ((evt: "cellEditingStarted", event: NuGridCellEditingStartedEvent<T>) => void) & ((evt: "stateChanged", state: NuGridStateSnapshot) => void) & ((evt: "filterChanged", event: NuGridFilterChangedEvent) => void) & ((evt: "sortChanged", event: NuGridSortChangedEvent) => void) & ((evt: "focusedRowChanged", event: NuGridFocusedRowChangedEvent<T>) => void) & ((evt: "focusedCellChanged", event: NuGridFocusedCellChangedEvent<T>) => void) & ((evt: "cellClicked", event: NuGridCellClickEvent<T>) => void) & ((evt: "rowClicked", event: NuGridRowClickEvent<T>) => void) & ((evt: "cellDoubleClicked", event: NuGridCellClickEvent<T>) => void) & ((evt: "rowDoubleClicked", event: NuGridRowClickEvent<T>) => void) & ((evt: "cellValueChanged", event: NuGridCellValueChangedEvent<T>) => void) & ((evt: "rowSelectionChanged", event: RowSelectionState) => void) & ((evt: "ready") => void) & ((evt: "rowAddRequested", row: T) => void) & ((evt: "addRowStateChanged", state: NuGridAddRowState) => void)) & (((evt: "update:globalFilter", value: string) => void) & ((evt: "update:columnFilters", value: ColumnFiltersState) => void) & ((evt: "update:columnOrder", value: ColumnOrderState) => void) & ((evt: "update:columnVisibility", value: VisibilityState) => void) & ((evt: "update:columnPinning", value: ColumnPinningState) => void) & ((evt: "update:columnSizing", value: ColumnSizingState) => void) & ((evt: "update:columnSizingInfo", value: ColumnSizingInfoState) => void) & ((evt: "update:selectedRows", value: RowSelectionState) => void) & ((evt: "update:rowPinning", value: RowPinningState) => void) & ((evt: "update:sorting", value: SortingState) => void) & ((evt: "update:grouping", value: GroupingState) => void) & ((evt: "update:expanded", value: ExpandedState) => void) & ((evt: "update:pagination", value: PaginationState) => void) & ((evt: "update:focusedRowId", value: string | null) => void));
|
|
87
90
|
}>) => import("vue").VNode & {
|
|
88
91
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
89
92
|
};
|