@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
|
@@ -4,6 +4,7 @@ import { createReusableTemplate } from "@vueuse/core";
|
|
|
4
4
|
import { Primitive } from "reka-ui";
|
|
5
5
|
import { computed, inject, toValue } from "vue";
|
|
6
6
|
import {
|
|
7
|
+
getFlexHeaderStyle,
|
|
7
8
|
getHeaderEffectivePinning,
|
|
8
9
|
getHeaderPinningStyle,
|
|
9
10
|
resolveStyleObject,
|
|
@@ -18,9 +19,9 @@ const props = defineProps({
|
|
|
18
19
|
ui: { type: null, required: false },
|
|
19
20
|
preset: { type: String, required: false },
|
|
20
21
|
focus: { type: Object, required: false },
|
|
21
|
-
editing: { type: Object, required: false },
|
|
22
|
+
editing: { type: [Boolean, Object], required: false },
|
|
22
23
|
validation: { type: [Boolean, Object], required: false },
|
|
23
|
-
|
|
24
|
+
rowSelection: { type: [Boolean, String, Object], required: false },
|
|
24
25
|
actions: { type: [Boolean, Object], required: false },
|
|
25
26
|
columnDefaults: { type: Object, required: false },
|
|
26
27
|
layout: { type: Object, required: false },
|
|
@@ -32,7 +33,7 @@ const props = defineProps({
|
|
|
32
33
|
theme: { type: [String, Object], required: false },
|
|
33
34
|
virtualization: { type: [Boolean, Object], required: false },
|
|
34
35
|
cellTypes: { type: Array, required: false },
|
|
35
|
-
|
|
36
|
+
dataTypeInference: { type: Boolean, required: false },
|
|
36
37
|
rowDragOptions: { type: Object, required: false },
|
|
37
38
|
rowId: { type: [String, Function], required: false },
|
|
38
39
|
addNewRow: { type: [Boolean, Object], required: false },
|
|
@@ -99,7 +100,13 @@ const rows = computed(() => {
|
|
|
99
100
|
return [...currentRows];
|
|
100
101
|
});
|
|
101
102
|
const { dragFns, rowDragOptions } = dragContext;
|
|
102
|
-
const {
|
|
103
|
+
const {
|
|
104
|
+
handleResizeStart,
|
|
105
|
+
handleGroupResizeStart,
|
|
106
|
+
resizingGroupId,
|
|
107
|
+
resizingColumnId,
|
|
108
|
+
manuallyResizedColumns
|
|
109
|
+
} = resizeContext;
|
|
103
110
|
const {
|
|
104
111
|
virtualizer,
|
|
105
112
|
virtualizationEnabled,
|
|
@@ -113,8 +120,24 @@ const {
|
|
|
113
120
|
sortIcons: gridSortIcons,
|
|
114
121
|
scrollbarClass,
|
|
115
122
|
scrollbarThemeClass,
|
|
116
|
-
scrollbarAttr
|
|
123
|
+
scrollbarAttr,
|
|
124
|
+
autoSizeMode,
|
|
125
|
+
resizeMode
|
|
117
126
|
} = uiConfigContext;
|
|
127
|
+
const useCssFlexDistribution = computed(() => autoSizeMode?.value === "fill");
|
|
128
|
+
const shouldUseFlexWidth = computed(() => {
|
|
129
|
+
if (!useCssFlexDistribution.value) return false;
|
|
130
|
+
if (resizeMode?.value === "shift") return true;
|
|
131
|
+
return manuallyResizedColumns.value.size === 0;
|
|
132
|
+
});
|
|
133
|
+
const flexStyleOptions = computed(() => ({
|
|
134
|
+
useCssFlexDistribution: useCssFlexDistribution.value,
|
|
135
|
+
manuallyResizedColumns: manuallyResizedColumns.value,
|
|
136
|
+
columnSizing: tableApi.getState().columnSizing
|
|
137
|
+
}));
|
|
138
|
+
function getStandardHeaderStyle(header) {
|
|
139
|
+
return getFlexHeaderStyle(header, flexStyleOptions.value);
|
|
140
|
+
}
|
|
118
141
|
const multiRowEnabled = computed(() => multiRowContext?.enabled.value ?? false);
|
|
119
142
|
const multiRowCount = computed(() => multiRowContext?.rowCount.value ?? 1);
|
|
120
143
|
const alignColumns = computed(() => multiRowContext?.alignColumns.value ?? false);
|
|
@@ -193,10 +216,22 @@ function getAlignedHeaderStyle(header, visualRowIndex, headerIndexInRow, totalHe
|
|
|
193
216
|
};
|
|
194
217
|
}
|
|
195
218
|
if (visualRowIndex === 0 || !alignColumns.value) {
|
|
219
|
+
const useCssFlexDistribution2 = autoSizeMode?.value === "fill";
|
|
220
|
+
const minSize = header.column.columnDef.minSize ?? 50;
|
|
221
|
+
const maxSize = header.column.columnDef.maxSize;
|
|
222
|
+
if (useCssFlexDistribution2) {
|
|
223
|
+
return {
|
|
224
|
+
flexGrow: 1,
|
|
225
|
+
flexShrink: 1,
|
|
226
|
+
flexBasis: 0,
|
|
227
|
+
minWidth: `${minSize}px`,
|
|
228
|
+
...maxSize && maxSize < Number.MAX_SAFE_INTEGER ? { maxWidth: `${maxSize}px` } : {}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
196
231
|
return {
|
|
197
232
|
flexGrow: 1,
|
|
198
233
|
flexBasis: `${header.getSize()}px`,
|
|
199
|
-
minWidth: `${
|
|
234
|
+
minWidth: `${minSize}px`
|
|
200
235
|
};
|
|
201
236
|
}
|
|
202
237
|
const row0Cols = row0Columns.value;
|
|
@@ -263,7 +298,7 @@ function getVirtualItemStyle(type, virtualRow) {
|
|
|
263
298
|
const useDynamicHeight = virtualizer.value.dynamicRowHeightsEnabled?.value ?? false;
|
|
264
299
|
const stickyTop = stickyOffsets.value.get(virtualRow.index);
|
|
265
300
|
const resolvedHeight = getVirtualItemHeight(virtualRow.index);
|
|
266
|
-
const width = totalTableWidth.value;
|
|
301
|
+
const width = shouldUseFlexWidth.value ? "100%" : totalTableWidth.value;
|
|
267
302
|
if (stickyEnabled.value && type === "column-headers") {
|
|
268
303
|
if (stickyTop !== void 0) {
|
|
269
304
|
return {
|
|
@@ -308,7 +343,10 @@ function getVirtualItemStyle(type, virtualRow) {
|
|
|
308
343
|
:data-scrollbars="scrollbarAttr"
|
|
309
344
|
>
|
|
310
345
|
<DefineTableTemplate>
|
|
311
|
-
<div
|
|
346
|
+
<div
|
|
347
|
+
ref="tableRef"
|
|
348
|
+
:class="ui.base({ class: [propsUi?.base, autoSizeMode === 'fill' && 'w-full'] })"
|
|
349
|
+
>
|
|
312
350
|
<div v-if="caption || !!slots.caption" :class="ui.caption({ class: [propsUi?.caption] })">
|
|
313
351
|
<slot name="caption">
|
|
314
352
|
{{ caption }}
|
|
@@ -423,39 +461,42 @@ function getVirtualItemStyle(type, virtualRow) {
|
|
|
423
461
|
:sort-icons="header.column.columnDef.sortIcons"
|
|
424
462
|
/>
|
|
425
463
|
</div>
|
|
426
|
-
|
|
427
|
-
|
|
464
|
+
<!-- Header controls wrapper - absolutely positioned to not affect column width -->
|
|
465
|
+
<div :class="ui.headerControls({ class: [propsUi?.headerControls] })">
|
|
466
|
+
<NuGridHeaderSortButton
|
|
467
|
+
v-if="
|
|
428
468
|
(header.column.columnDef.sortIcons?.position ?? gridSortIcons?.position ?? 'edge') === 'edge'
|
|
429
469
|
"
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
470
|
+
:header="header"
|
|
471
|
+
:sort-icons="header.column.columnDef.sortIcons"
|
|
472
|
+
/>
|
|
473
|
+
<NuGridColumnMenu :header="header" />
|
|
474
|
+
<div
|
|
475
|
+
v-if="header.column.getCanResize()"
|
|
476
|
+
:class="
|
|
437
477
|
ui.colResizeHandle({
|
|
438
478
|
class: [propsUi?.colResizeHandle],
|
|
439
479
|
colResizing: resizingColumnId === header.column.id || header.column.getIsResizing()
|
|
440
480
|
})
|
|
441
481
|
"
|
|
442
|
-
|
|
482
|
+
:data-col-resizing="
|
|
443
483
|
resizingColumnId === header.column.id || header.column.getIsResizing() ? 'true' : void 0
|
|
444
484
|
"
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
485
|
+
@mousedown="handleResizeStart($event, header)"
|
|
486
|
+
@touchstart.passive="handleResizeStart($event, header)"
|
|
487
|
+
>
|
|
488
|
+
<div
|
|
489
|
+
:class="
|
|
450
490
|
ui.colResizer({
|
|
451
491
|
class: [propsUi?.colResizer],
|
|
452
492
|
colResizing: resizingColumnId === header.column.id || header.column.getIsResizing()
|
|
453
493
|
})
|
|
454
494
|
"
|
|
455
|
-
|
|
495
|
+
:data-col-resizing="
|
|
456
496
|
resizingColumnId === header.column.id || header.column.getIsResizing() ? 'true' : void 0
|
|
457
497
|
"
|
|
458
|
-
|
|
498
|
+
/>
|
|
499
|
+
</div>
|
|
459
500
|
</div>
|
|
460
501
|
</div>
|
|
461
502
|
</div>
|
|
@@ -533,9 +574,7 @@ function getVirtualItemStyle(type, virtualRow) {
|
|
|
533
574
|
]"
|
|
534
575
|
:style="{
|
|
535
576
|
...resolveStyleObject(header.column.columnDef.meta?.style?.th, header),
|
|
536
|
-
|
|
537
|
-
minWidth: `${header.getSize()}px`,
|
|
538
|
-
maxWidth: `${header.getSize()}px`,
|
|
577
|
+
...getStandardHeaderStyle(header),
|
|
539
578
|
...getHeaderPinningStyle(header),
|
|
540
579
|
...header.colSpan > 1 ? { flexGrow: header.colSpan } : {},
|
|
541
580
|
...header.rowSpan > 1 ? { alignSelf: 'stretch' } : {}
|
|
@@ -617,39 +656,42 @@ function getVirtualItemStyle(type, virtualRow) {
|
|
|
617
656
|
:sort-icons="header.column.columnDef.sortIcons"
|
|
618
657
|
/>
|
|
619
658
|
</div>
|
|
620
|
-
|
|
621
|
-
|
|
659
|
+
<!-- Header controls wrapper - absolutely positioned to not affect column width -->
|
|
660
|
+
<div :class="ui.headerControls({ class: [propsUi?.headerControls] })">
|
|
661
|
+
<NuGridHeaderSortButton
|
|
662
|
+
v-if="
|
|
622
663
|
(header.column.columnDef.sortIcons?.position ?? gridSortIcons?.position ?? 'edge') === 'edge'
|
|
623
664
|
"
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
665
|
+
:header="header"
|
|
666
|
+
:sort-icons="header.column.columnDef.sortIcons"
|
|
667
|
+
/>
|
|
668
|
+
<NuGridColumnMenu :header="header" />
|
|
669
|
+
<div
|
|
670
|
+
v-if="header.column.getCanResize()"
|
|
671
|
+
:class="
|
|
631
672
|
ui.colResizeHandle({
|
|
632
673
|
class: [propsUi?.colResizeHandle],
|
|
633
674
|
colResizing: resizingColumnId === header.column.id || header.column.getIsResizing()
|
|
634
675
|
})
|
|
635
676
|
"
|
|
636
|
-
|
|
677
|
+
:data-col-resizing="
|
|
637
678
|
resizingColumnId === header.column.id || header.column.getIsResizing() ? 'true' : void 0
|
|
638
679
|
"
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
680
|
+
@mousedown="handleResizeStart($event, header)"
|
|
681
|
+
@touchstart.passive="handleResizeStart($event, header)"
|
|
682
|
+
>
|
|
683
|
+
<div
|
|
684
|
+
:class="
|
|
644
685
|
ui.colResizer({
|
|
645
686
|
class: [propsUi?.colResizer],
|
|
646
687
|
colResizing: resizingColumnId === header.column.id || header.column.getIsResizing()
|
|
647
688
|
})
|
|
648
689
|
"
|
|
649
|
-
|
|
690
|
+
:data-col-resizing="
|
|
650
691
|
resizingColumnId === header.column.id || header.column.getIsResizing() ? 'true' : void 0
|
|
651
692
|
"
|
|
652
|
-
|
|
693
|
+
/>
|
|
694
|
+
</div>
|
|
653
695
|
</div>
|
|
654
696
|
</div>
|
|
655
697
|
</template>
|
|
@@ -787,39 +829,42 @@ function getVirtualItemStyle(type, virtualRow) {
|
|
|
787
829
|
:sort-icons="header.column.columnDef.sortIcons"
|
|
788
830
|
/>
|
|
789
831
|
</div>
|
|
790
|
-
|
|
791
|
-
|
|
832
|
+
<!-- Header controls wrapper - absolutely positioned to not affect column width -->
|
|
833
|
+
<div :class="ui.headerControls({ class: [propsUi?.headerControls] })">
|
|
834
|
+
<NuGridHeaderSortButton
|
|
835
|
+
v-if="
|
|
792
836
|
(header.column.columnDef.sortIcons?.position ?? gridSortIcons?.position ?? 'edge') === 'edge'
|
|
793
837
|
"
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
838
|
+
:header="header"
|
|
839
|
+
:sort-icons="header.column.columnDef.sortIcons"
|
|
840
|
+
/>
|
|
841
|
+
<NuGridColumnMenu :header="header" />
|
|
842
|
+
<div
|
|
843
|
+
v-if="header.column.getCanResize()"
|
|
844
|
+
:class="
|
|
801
845
|
ui.colResizeHandle({
|
|
802
846
|
class: [propsUi?.colResizeHandle],
|
|
803
847
|
colResizing: resizingColumnId === header.column.id || header.column.getIsResizing()
|
|
804
848
|
})
|
|
805
849
|
"
|
|
806
|
-
|
|
850
|
+
:data-col-resizing="
|
|
807
851
|
resizingColumnId === header.column.id || header.column.getIsResizing() ? 'true' : void 0
|
|
808
852
|
"
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
853
|
+
@mousedown="handleResizeStart($event, header)"
|
|
854
|
+
@touchstart.passive="handleResizeStart($event, header)"
|
|
855
|
+
>
|
|
856
|
+
<div
|
|
857
|
+
:class="
|
|
814
858
|
ui.colResizer({
|
|
815
859
|
class: [propsUi?.colResizer],
|
|
816
860
|
colResizing: resizingColumnId === header.column.id || header.column.getIsResizing()
|
|
817
861
|
})
|
|
818
862
|
"
|
|
819
|
-
|
|
863
|
+
:data-col-resizing="
|
|
820
864
|
resizingColumnId === header.column.id || header.column.getIsResizing() ? 'true' : void 0
|
|
821
865
|
"
|
|
822
|
-
|
|
866
|
+
/>
|
|
867
|
+
</div>
|
|
823
868
|
</div>
|
|
824
869
|
</div>
|
|
825
870
|
</div>
|
|
@@ -887,9 +932,7 @@ function getVirtualItemStyle(type, virtualRow) {
|
|
|
887
932
|
]"
|
|
888
933
|
:style="{
|
|
889
934
|
...resolveStyleObject(header.column.columnDef.meta?.style?.th, header),
|
|
890
|
-
|
|
891
|
-
minWidth: `${header.getSize()}px`,
|
|
892
|
-
maxWidth: `${header.getSize()}px`,
|
|
935
|
+
...getStandardHeaderStyle(header),
|
|
893
936
|
...getHeaderPinningStyle(header),
|
|
894
937
|
...header.colSpan > 1 ? { flexGrow: header.colSpan } : {},
|
|
895
938
|
...header.rowSpan > 1 ? { alignSelf: 'stretch' } : {}
|
|
@@ -969,39 +1012,42 @@ function getVirtualItemStyle(type, virtualRow) {
|
|
|
969
1012
|
:sort-icons="header.column.columnDef.sortIcons"
|
|
970
1013
|
/>
|
|
971
1014
|
</div>
|
|
972
|
-
|
|
973
|
-
|
|
1015
|
+
<!-- Header controls wrapper - absolutely positioned to not affect column width -->
|
|
1016
|
+
<div :class="ui.headerControls({ class: [propsUi?.headerControls] })">
|
|
1017
|
+
<NuGridHeaderSortButton
|
|
1018
|
+
v-if="
|
|
974
1019
|
(header.column.columnDef.sortIcons?.position ?? gridSortIcons?.position ?? 'edge') === 'edge'
|
|
975
1020
|
"
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
1021
|
+
:header="header"
|
|
1022
|
+
:sort-icons="header.column.columnDef.sortIcons"
|
|
1023
|
+
/>
|
|
1024
|
+
<NuGridColumnMenu :header="header" />
|
|
1025
|
+
<div
|
|
1026
|
+
v-if="header.column.getCanResize()"
|
|
1027
|
+
:class="
|
|
983
1028
|
ui.colResizeHandle({
|
|
984
1029
|
class: [propsUi?.colResizeHandle],
|
|
985
1030
|
colResizing: resizingColumnId === header.column.id || header.column.getIsResizing()
|
|
986
1031
|
})
|
|
987
1032
|
"
|
|
988
|
-
|
|
1033
|
+
:data-col-resizing="
|
|
989
1034
|
resizingColumnId === header.column.id || header.column.getIsResizing() ? 'true' : void 0
|
|
990
1035
|
"
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1036
|
+
@mousedown="handleResizeStart($event, header)"
|
|
1037
|
+
@touchstart.passive="handleResizeStart($event, header)"
|
|
1038
|
+
>
|
|
1039
|
+
<div
|
|
1040
|
+
:class="
|
|
996
1041
|
ui.colResizer({
|
|
997
1042
|
class: [propsUi?.colResizer],
|
|
998
1043
|
colResizing: resizingColumnId === header.column.id || header.column.getIsResizing()
|
|
999
1044
|
})
|
|
1000
1045
|
"
|
|
1001
|
-
|
|
1046
|
+
:data-col-resizing="
|
|
1002
1047
|
resizingColumnId === header.column.id || header.column.getIsResizing() ? 'true' : void 0
|
|
1003
1048
|
"
|
|
1004
|
-
|
|
1049
|
+
/>
|
|
1050
|
+
</div>
|
|
1005
1051
|
</div>
|
|
1006
1052
|
</div>
|
|
1007
1053
|
</template>
|
|
@@ -8,6 +8,21 @@ const props = defineProps({
|
|
|
8
8
|
cellEditingFns: { type: Object, required: true }
|
|
9
9
|
});
|
|
10
10
|
const uiConfig = inject("nugrid-ui-config", null);
|
|
11
|
+
const cellSlots = inject("nugrid-cell-slots", null);
|
|
12
|
+
const cellSlot = computed(() => {
|
|
13
|
+
if (!cellSlots) return null;
|
|
14
|
+
const slotName = `${props.cell.column.id}-cell`;
|
|
15
|
+
return cellSlots[slotName] ?? null;
|
|
16
|
+
});
|
|
17
|
+
const cellSlotProps = computed(() => ({
|
|
18
|
+
cell: props.cell,
|
|
19
|
+
row: props.row,
|
|
20
|
+
column: props.cell.column,
|
|
21
|
+
cellIndex: props.cell.column.getIndex(),
|
|
22
|
+
value: props.cell.getValue(),
|
|
23
|
+
isEditing: props.cellEditingFns.isEditingCell(props.row, props.cell.column.id),
|
|
24
|
+
isInvalid: props.cellEditingFns.hasCellValidationError(props.row.id, props.cell.column.id)
|
|
25
|
+
}));
|
|
11
26
|
const wrapperRef = ref(null);
|
|
12
27
|
const capturedHeight = ref(null);
|
|
13
28
|
const addRowContext = inject("nugrid-add-row", null);
|
|
@@ -188,8 +203,13 @@ const editorContent = computed(() => {
|
|
|
188
203
|
</div>
|
|
189
204
|
<!-- Display mode: tooltip handled by grid-level event delegation -->
|
|
190
205
|
<div v-else ref="wrapperRef" :class="wrapperClass" :style="wrapperStyle">
|
|
206
|
+
<!-- Cell slot takes highest priority in display mode -->
|
|
207
|
+
<component :is="cellSlot" v-if="cellSlot" v-bind="cellSlotProps" />
|
|
191
208
|
<!-- Function-based renderer -->
|
|
192
|
-
<component
|
|
209
|
+
<component
|
|
210
|
+
:is="functionRendererResult"
|
|
211
|
+
v-else-if="shouldUsePluginRenderer && isRendererFunction"
|
|
212
|
+
/>
|
|
193
213
|
<!-- Component-based plugin renderer -->
|
|
194
214
|
<component
|
|
195
215
|
:is="pluginRendererComponent"
|
|
@@ -12,7 +12,7 @@ const uiConfigContext = inject("nugrid-ui-config");
|
|
|
12
12
|
if (!coreContext || !performanceContext || !uiConfigContext) {
|
|
13
13
|
throw new Error("NuGridColumnMenu must be used within a NuGrid component.");
|
|
14
14
|
}
|
|
15
|
-
const { tableApi } = coreContext;
|
|
15
|
+
const { tableApi, ui, propsUi } = coreContext;
|
|
16
16
|
const { allLeafColumns } = performanceContext;
|
|
17
17
|
const { getColumnMenuItems, showColumnVisibility, columnMenuButton } = uiConfigContext;
|
|
18
18
|
const pinColumn = (columnId, side) => {
|
|
@@ -354,7 +354,7 @@ const filterComponent = computed(() => {
|
|
|
354
354
|
<div
|
|
355
355
|
v-if="shouldShowMenu"
|
|
356
356
|
:class="[
|
|
357
|
-
|
|
357
|
+
ui.columnMenu({ class: [propsUi?.columnMenu] }),
|
|
358
358
|
menuOpen ? 'opacity-100' : 'opacity-0 group-hover:opacity-100 focus-within:opacity-100'
|
|
359
359
|
]"
|
|
360
360
|
>
|
|
@@ -5,6 +5,7 @@ import { Primitive } from "reka-ui";
|
|
|
5
5
|
import { upperFirst } from "scule";
|
|
6
6
|
import { computed, inject, ref, toValue } from "vue";
|
|
7
7
|
import {
|
|
8
|
+
getFlexHeaderStyle,
|
|
8
9
|
getHeaderEffectivePinning,
|
|
9
10
|
getHeaderPinningStyle,
|
|
10
11
|
resolveStyleObject,
|
|
@@ -21,9 +22,9 @@ const props = defineProps({
|
|
|
21
22
|
ui: { type: null, required: false },
|
|
22
23
|
preset: { type: String, required: false },
|
|
23
24
|
focus: { type: Object, required: false },
|
|
24
|
-
editing: { type: Object, required: false },
|
|
25
|
+
editing: { type: [Boolean, Object], required: false },
|
|
25
26
|
validation: { type: [Boolean, Object], required: false },
|
|
26
|
-
|
|
27
|
+
rowSelection: { type: [Boolean, String, Object], required: false },
|
|
27
28
|
actions: { type: [Boolean, Object], required: false },
|
|
28
29
|
columnDefaults: { type: Object, required: false },
|
|
29
30
|
layout: { type: Object, required: false },
|
|
@@ -35,7 +36,7 @@ const props = defineProps({
|
|
|
35
36
|
theme: { type: [String, Object], required: false },
|
|
36
37
|
virtualization: { type: [Boolean, Object], required: false },
|
|
37
38
|
cellTypes: { type: Array, required: false },
|
|
38
|
-
|
|
39
|
+
dataTypeInference: { type: Boolean, required: false },
|
|
39
40
|
rowDragOptions: { type: Object, required: false },
|
|
40
41
|
rowId: { type: [String, Function], required: false },
|
|
41
42
|
addNewRow: { type: [Boolean, Object], required: false },
|
|
@@ -97,7 +98,7 @@ if (!coreContext || !dragContext || !resizeContext || !virtualizationContext ||
|
|
|
97
98
|
}
|
|
98
99
|
const { tableRef, rootRef, tableApi, ui, hasFooter, propsUi } = coreContext;
|
|
99
100
|
const { dragFns, rowDragOptions } = dragContext;
|
|
100
|
-
const { handleGroupResizeStart, resizingGroupId, resizingColumnId } = resizeContext;
|
|
101
|
+
const { handleGroupResizeStart, resizingGroupId, resizingColumnId, manuallyResizedColumns } = resizeContext;
|
|
101
102
|
const { stickyEnabled } = virtualizationContext;
|
|
102
103
|
const { groupingFns } = groupingContext;
|
|
103
104
|
const { headerGroups, headerGroupsLength, footerGroups } = performanceContext;
|
|
@@ -105,9 +106,18 @@ const {
|
|
|
105
106
|
sortIcons: gridSortIcons,
|
|
106
107
|
scrollbarClass,
|
|
107
108
|
scrollbarThemeClass,
|
|
108
|
-
scrollbarAttr
|
|
109
|
+
scrollbarAttr,
|
|
110
|
+
autoSizeMode
|
|
109
111
|
} = uiConfigContext;
|
|
110
112
|
const { rowSelectionMode } = rowInteractionsContext;
|
|
113
|
+
const flexStyleOptions = computed(() => ({
|
|
114
|
+
useCssFlexDistribution: autoSizeMode?.value === "fill",
|
|
115
|
+
manuallyResizedColumns: manuallyResizedColumns.value,
|
|
116
|
+
columnSizing: tableApi.getState().columnSizing
|
|
117
|
+
}));
|
|
118
|
+
function getHeaderStyle(header) {
|
|
119
|
+
return getFlexHeaderStyle(header, flexStyleOptions.value);
|
|
120
|
+
}
|
|
111
121
|
const [DefineTableTemplate, ReuseNuGridTemplate] = createReusableTemplate({ inheritAttrs: false });
|
|
112
122
|
const [DefineGroupSubheaderTemplate, ReuseGroupSubheaderTemplate] = createReusableTemplate({ inheritAttrs: false });
|
|
113
123
|
const [DefineHeaderCellTemplate, ReuseHeaderCellTemplate] = createReusableTemplate({ inheritAttrs: false });
|
|
@@ -285,9 +295,7 @@ function measureElementRef(el) {
|
|
|
285
295
|
]"
|
|
286
296
|
:style="{
|
|
287
297
|
...resolveStyleObject(header.column.columnDef.meta?.style?.th, header),
|
|
288
|
-
|
|
289
|
-
minWidth: `${header.getSize()}px`,
|
|
290
|
-
maxWidth: `${header.getSize()}px`,
|
|
298
|
+
...getHeaderStyle(header),
|
|
291
299
|
...getHeaderPinningStyle(header),
|
|
292
300
|
...header.rowSpan > 1 ? { alignSelf: 'stretch' } : {}
|
|
293
301
|
}"
|
|
@@ -373,7 +381,10 @@ function measureElementRef(el) {
|
|
|
373
381
|
</DefineHeaderCellTemplate>
|
|
374
382
|
|
|
375
383
|
<DefineTableTemplate>
|
|
376
|
-
<div
|
|
384
|
+
<div
|
|
385
|
+
ref="tableRef"
|
|
386
|
+
:class="ui.base({ class: [propsUi?.base, autoSizeMode === 'fill' && 'w-full'] })"
|
|
387
|
+
>
|
|
377
388
|
<div v-if="caption || !!slots.caption" :class="ui.caption({ class: [propsUi?.caption] })">
|
|
378
389
|
<slot name="caption">
|
|
379
390
|
{{ caption }}
|
|
@@ -519,9 +530,7 @@ function measureElementRef(el) {
|
|
|
519
530
|
]"
|
|
520
531
|
:style="{
|
|
521
532
|
...resolveStyleObject(header.column.columnDef.meta?.style?.th, header),
|
|
522
|
-
|
|
523
|
-
minWidth: `${header.getSize()}px`,
|
|
524
|
-
maxWidth: `${header.getSize()}px`,
|
|
533
|
+
...getHeaderStyle(header),
|
|
525
534
|
...getHeaderPinningStyle(header),
|
|
526
535
|
...header.colSpan > 1 ? { flexGrow: header.colSpan } : {},
|
|
527
536
|
...header.rowSpan > 1 ? { alignSelf: 'stretch' } : {}
|
|
@@ -616,9 +625,7 @@ function measureElementRef(el) {
|
|
|
616
625
|
]"
|
|
617
626
|
:style="{
|
|
618
627
|
...resolveStyleObject(header.column.columnDef.meta?.style?.th, header),
|
|
619
|
-
|
|
620
|
-
minWidth: `${header.getSize()}px`,
|
|
621
|
-
maxWidth: `${header.getSize()}px`,
|
|
628
|
+
...getHeaderStyle(header),
|
|
622
629
|
...getHeaderPinningStyle(header),
|
|
623
630
|
...header.colSpan > 1 ? { flexGrow: header.colSpan } : {},
|
|
624
631
|
...header.rowSpan > 1 ? { alignSelf: 'stretch' } : {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, inject } from "vue";
|
|
3
|
-
import { resolveStyleObject, resolveValue } from "../../composables/_internal";
|
|
3
|
+
import { getFlexCellStyle, resolveStyleObject, resolveValue } from "../../composables/_internal";
|
|
4
4
|
import NuGridCellContent from "./NuGridCellContent.vue";
|
|
5
5
|
const props = defineProps({
|
|
6
6
|
row: { type: Object, required: true },
|
|
@@ -19,6 +19,8 @@ const interactionRouterContext = inject(
|
|
|
19
19
|
"nugrid-interaction-router"
|
|
20
20
|
);
|
|
21
21
|
const multiRowContext = inject("nugrid-multi-row");
|
|
22
|
+
const uiConfigContext = inject("nugrid-ui-config");
|
|
23
|
+
const resizeContext = inject("nugrid-resize");
|
|
22
24
|
if (!coreContext || !dragContext || !focusContext || !performanceContext || !rowInteractionsContext || !interactionRouterContext) {
|
|
23
25
|
throw new Error("NuGridRow must be used within a NuGrid component.");
|
|
24
26
|
}
|
|
@@ -29,6 +31,14 @@ const { getVisibleCells, shouldHaveBorder } = performanceContext;
|
|
|
29
31
|
const { rowInteractions } = rowInteractionsContext;
|
|
30
32
|
const { interactionRouter } = interactionRouterContext;
|
|
31
33
|
const { onRowSelect, onRowHover, onRowContextmenu } = rowInteractions;
|
|
34
|
+
const flexStyleOptions = computed(() => ({
|
|
35
|
+
useCssFlexDistribution: uiConfigContext?.autoSizeMode?.value === "fill",
|
|
36
|
+
manuallyResizedColumns: resizeContext?.manuallyResizedColumns.value ?? /* @__PURE__ */ new Set(),
|
|
37
|
+
columnSizing: tableApi.getState().columnSizing
|
|
38
|
+
}));
|
|
39
|
+
function getCellStyle(cell) {
|
|
40
|
+
return getFlexCellStyle(cell.column, flexStyleOptions.value);
|
|
41
|
+
}
|
|
32
42
|
const tdClassCache = /* @__PURE__ */ new Map();
|
|
33
43
|
function getTdCacheKey(variants) {
|
|
34
44
|
return `${variants.pinned ? 1 : 0}|${variants.hasLeftBorder ? 1 : 0}|${variants.hasRightBorder ? 1 : 0}|${variants.focusCell ? 1 : 0}|${variants.focusRow ? 1 : 0}|${variants.activeRow ? 1 : 0}|${variants.gridFocused ? 1 : 0}|${variants.rowInvalid ? 1 : 0}|${variants.customClass || ""}`;
|
|
@@ -619,9 +629,7 @@ function getMultiRowPinningStyle(cell, _visualRowCells) {
|
|
|
619
629
|
"
|
|
620
630
|
:style="{
|
|
621
631
|
...resolveStyleObject(cell.column.columnDef.meta?.style?.td, cell),
|
|
622
|
-
|
|
623
|
-
minWidth: `${cell.column.getSize()}px`,
|
|
624
|
-
maxWidth: `${cell.column.getSize()}px`,
|
|
632
|
+
...getCellStyle(cell),
|
|
625
633
|
...cell.column.getIsPinned() === 'left' ? { left: `${cell.column.getStart('left')}px` } : {},
|
|
626
634
|
...cell.column.getIsPinned() === 'right' ? { right: `${cell.column.getAfter('right')}px` } : {},
|
|
627
635
|
...resolveValue(cell.column.columnDef.meta?.colspan?.td, cell) ? { flexGrow: resolveValue(cell.column.columnDef.meta?.colspan?.td, cell) } : {}
|