sprintify-ui 0.8.58 → 0.8.59
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/sprintify-ui.es.js +16212 -16130
- package/dist/types/components/BaseDataIteratorSectionColumns.vue.d.ts +10 -0
- package/dist/types/components/BaseDataTable.vue.d.ts +18 -2
- package/dist/types/components/BaseDataTableTemplate.vue.d.ts +9 -0
- package/dist/types/components/BaseDraggable.vue.d.ts +2 -2
- package/dist/types/components/BaseMediaGallery.vue.d.ts +1 -1
- package/dist/types/components/BaseMediaGalleryItem.vue.d.ts +1 -1
- package/dist/types/components/BaseMediaLibrary.vue.d.ts +1 -1
- package/dist/types/components/BaseMediaList.vue.d.ts +1 -1
- package/dist/types/components/BaseMediaListItem.vue.d.ts +1 -1
- package/dist/types/components/BaseMediaPictures.vue.d.ts +1 -1
- package/dist/types/components/BaseMediaPicturesItem.vue.d.ts +1 -1
- package/dist/types/components/BaseTableColumn.vue.d.ts +0 -1
- package/dist/types/services/table/customKeyActions.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/BaseDataIteratorSectionColumns.vue +66 -20
- package/src/components/BaseDataTable.stories.js +1 -1
- package/src/components/BaseDataTable.vue +53 -5
- package/src/components/BaseDataTableTemplate.vue +101 -24
- package/src/components/BaseDraggable.vue +5 -5
- package/src/components/BaseTableColumn.vue +8 -9
- package/src/services/table/customKeyActions.ts +3 -0
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<BaseTableHead v-if="newColumns.length">
|
|
26
26
|
<BaseTableRow>
|
|
27
27
|
<BaseTableHeader
|
|
28
|
-
v-for="(column, index) in
|
|
28
|
+
v-for="(column, index) in visibleColumnsInternal"
|
|
29
29
|
:key="column.newKey + ':' + index + 'header'"
|
|
30
30
|
:style="column.style"
|
|
31
31
|
class="bg-slate-50"
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
v-bind="rowBindings(row, index)"
|
|
113
113
|
>
|
|
114
114
|
<BaseTableCell
|
|
115
|
-
v-for="(column, columnIndex) in
|
|
115
|
+
v-for="(column, columnIndex) in visibleColumnsInternal"
|
|
116
116
|
:key="column.newKey + index + ':' + columnIndex"
|
|
117
117
|
:class="[column.class, column.numeric ? 'tabular-nums' : '']"
|
|
118
118
|
:align="column.align"
|
|
@@ -209,6 +209,7 @@ import BaseTableBody from './BaseTableBody.vue';
|
|
|
209
209
|
import BaseTableRow from './BaseTableRow.vue';
|
|
210
210
|
import BaseTableCell from './BaseTableCell.vue';
|
|
211
211
|
import { RouteLocationRaw } from 'vue-router';
|
|
212
|
+
import { customKeyActions } from '@/services/table/customKeyActions';
|
|
212
213
|
|
|
213
214
|
const checkboxStyle =
|
|
214
215
|
'disabled:bg-slate-100 group-hover:shadow-md disabled:border-slate-300 disabled:cursor-not-allowed duration-300 cursor-pointer focus:ring-blue-300 border border-slate-300 shadow h-[18px] w-[18px] rounded';
|
|
@@ -235,6 +236,10 @@ const props = defineProps({
|
|
|
235
236
|
default: undefined,
|
|
236
237
|
type: Array as PropType<string[]>,
|
|
237
238
|
},
|
|
239
|
+
columnOrder: {
|
|
240
|
+
default: undefined,
|
|
241
|
+
type: Array as PropType<string[]>,
|
|
242
|
+
},
|
|
238
243
|
/** Allow row details */
|
|
239
244
|
detailed: {
|
|
240
245
|
default: false,
|
|
@@ -323,41 +328,85 @@ const lastCheckedRowIndex = ref<number | null>(null);
|
|
|
323
328
|
const currentSortColumn = ref<BaseTableColumnData | null>(null);
|
|
324
329
|
const isAsc = ref(true);
|
|
325
330
|
const defaultSlots = ref<BaseTableColumnData[]>([]);
|
|
326
|
-
const sequence = ref(1);
|
|
327
331
|
|
|
328
332
|
const slot = ref<HTMLElement | null>(null);
|
|
329
333
|
|
|
330
334
|
const newColumns = computed(() => {
|
|
331
|
-
|
|
335
|
+
const cols = defaultSlots.value;
|
|
336
|
+
|
|
337
|
+
if (props.columnOrder && props.columnOrder.length) {
|
|
338
|
+
|
|
339
|
+
const colOrder = props.columnOrder;
|
|
340
|
+
|
|
341
|
+
return cols
|
|
342
|
+
.sort((a, b) => {
|
|
343
|
+
|
|
344
|
+
// Always put actions column at the end
|
|
345
|
+
|
|
346
|
+
if (a.newKey === customKeyActions) {
|
|
347
|
+
return 1;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (b.newKey === customKeyActions) {
|
|
351
|
+
return -1;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// If not found, put it at the end
|
|
355
|
+
|
|
356
|
+
const existsA = colOrder.includes(a.newKey);
|
|
357
|
+
const existsB = colOrder.includes(b.newKey);
|
|
358
|
+
|
|
359
|
+
if (!existsA && !existsB) {
|
|
360
|
+
return 0;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (!existsA) {
|
|
364
|
+
return 1;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (!existsB) {
|
|
368
|
+
return -1;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Sort based on the order
|
|
372
|
+
|
|
373
|
+
return colOrder.indexOf(a.newKey) - colOrder.indexOf(b.newKey);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return cols;
|
|
332
378
|
});
|
|
333
379
|
|
|
334
|
-
|
|
380
|
+
|
|
381
|
+
const visibleColumnsInternal = computed(() => {
|
|
382
|
+
|
|
335
383
|
if (!newColumns.value) {
|
|
336
|
-
return
|
|
384
|
+
return [];
|
|
337
385
|
}
|
|
338
386
|
|
|
339
|
-
return newColumns.value
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
387
|
+
return newColumns.value
|
|
388
|
+
.filter((column: BaseTableColumnData) => {
|
|
389
|
+
if (column.toggle === false) {
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
343
392
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
393
|
+
if (!isArray(props.visibleColumns)) {
|
|
394
|
+
return true;
|
|
395
|
+
}
|
|
347
396
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
397
|
+
if (props.visibleColumns.includes(column.newKey)) {
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
351
400
|
|
|
352
|
-
|
|
353
|
-
|
|
401
|
+
return false;
|
|
402
|
+
});
|
|
354
403
|
});
|
|
355
404
|
|
|
356
405
|
/**
|
|
357
406
|
* Return total column count based if it's checkable or expanded
|
|
358
407
|
*/
|
|
359
408
|
const columnCount = computed(() => {
|
|
360
|
-
let count =
|
|
409
|
+
let count = visibleColumnsInternal.value.length;
|
|
361
410
|
count += props.checkable ? 1 : 0;
|
|
362
411
|
count += props.detailed ? 1 : 0;
|
|
363
412
|
|
|
@@ -689,10 +738,6 @@ function onCellClick(row: CollectionItem, index: number, column: BaseTableColumn
|
|
|
689
738
|
};
|
|
690
739
|
}
|
|
691
740
|
|
|
692
|
-
function nextSequence() {
|
|
693
|
-
return sequence.value++;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
741
|
let warningNoRowKeyFoundShown = false;
|
|
697
742
|
|
|
698
743
|
function getRowKey(row: Row): string {
|
|
@@ -735,10 +780,42 @@ function getRowKey(row: Row): string {
|
|
|
735
780
|
|
|
736
781
|
provide('addColumn', addColumn);
|
|
737
782
|
provide('removeColumn', removeColumn);
|
|
738
|
-
provide('nextSequence', nextSequence);
|
|
739
783
|
|
|
740
784
|
const baseTableRef = ref<InstanceType<typeof BaseTable> | null>(null);
|
|
741
785
|
|
|
786
|
+
|
|
787
|
+
/*
|
|
788
|
+
|--------------------------------------------------------------------------
|
|
789
|
+
| Checks
|
|
790
|
+
|--------------------------------------------------------------------------
|
|
791
|
+
*/
|
|
792
|
+
|
|
793
|
+
watch(
|
|
794
|
+
() => newColumns.value.map((item) => item.newKey),
|
|
795
|
+
(keys: string[]) => {
|
|
796
|
+
|
|
797
|
+
// check duplicates
|
|
798
|
+
|
|
799
|
+
const duplicates = keys.reduce((acc, key, index) => {
|
|
800
|
+
if (keys.indexOf(key) !== index && !acc.includes(key)) {
|
|
801
|
+
acc.push(key);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
return acc;
|
|
805
|
+
}, [] as string[]);
|
|
806
|
+
|
|
807
|
+
if (duplicates.length) {
|
|
808
|
+
throw new Error(`Duplicate BaseTableColumn keys found: ${duplicates.join(', ')}`);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
)
|
|
812
|
+
|
|
813
|
+
/*
|
|
814
|
+
|--------------------------------------------------------------------------
|
|
815
|
+
| Expose
|
|
816
|
+
|--------------------------------------------------------------------------
|
|
817
|
+
*/
|
|
818
|
+
|
|
742
819
|
defineExpose({
|
|
743
820
|
newColumns,
|
|
744
821
|
uncheckAll,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div ref="elementsRef">
|
|
3
3
|
<slot
|
|
4
4
|
v-for="(element, index) in modelValue"
|
|
5
|
-
:key="getKey(element
|
|
5
|
+
:key="getKey(element)"
|
|
6
6
|
name="item"
|
|
7
7
|
:element="element"
|
|
8
8
|
:index="index"
|
|
@@ -11,22 +11,22 @@
|
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
13
|
<script lang="ts" setup>
|
|
14
|
-
import { cloneDeep } from 'lodash';
|
|
14
|
+
import { cloneDeep, uniqueId } from 'lodash';
|
|
15
15
|
import Sortable from 'sortablejs';
|
|
16
16
|
|
|
17
17
|
const props = defineProps<{
|
|
18
18
|
modelValue: any[];
|
|
19
19
|
itemKey: string;
|
|
20
20
|
handle: string;
|
|
21
|
-
disabled
|
|
21
|
+
disabled?: boolean;
|
|
22
22
|
}>();
|
|
23
23
|
|
|
24
24
|
const emit = defineEmits(['update:modelValue']);
|
|
25
25
|
|
|
26
26
|
const elementsRef = ref<HTMLElement | null>(null);
|
|
27
27
|
|
|
28
|
-
function getKey(element: any
|
|
29
|
-
return element[props.itemKey] ??
|
|
28
|
+
function getKey(element: any) {
|
|
29
|
+
return element[props.itemKey] ?? uniqueId();
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
let sortable = null as Sortable | null;
|
|
@@ -89,12 +89,10 @@ export default defineComponent({
|
|
|
89
89
|
},
|
|
90
90
|
},
|
|
91
91
|
setup() {
|
|
92
|
-
const nextSequence = inject('nextSequence') as any;
|
|
93
92
|
const addColumn = inject('addColumn') as any;
|
|
94
93
|
const removeColumn = inject('removeColumn') as any;
|
|
95
94
|
|
|
96
95
|
return {
|
|
97
|
-
nextSequence,
|
|
98
96
|
addColumn,
|
|
99
97
|
removeColumn,
|
|
100
98
|
};
|
|
@@ -113,17 +111,18 @@ export default defineComponent({
|
|
|
113
111
|
},
|
|
114
112
|
},
|
|
115
113
|
created() {
|
|
116
|
-
if (this.toggle && !this.customKey) {
|
|
117
|
-
throw new Error(
|
|
118
|
-
'BaseTableColumn: customKey props is required when toggle props is true'
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
114
|
if (this.customKey) {
|
|
123
115
|
this.newKey = this.customKey + '';
|
|
116
|
+
} else if (this.field) {
|
|
117
|
+
this.newKey = this.field + '';
|
|
118
|
+
} else if (this.label) {
|
|
119
|
+
this.newKey = this.label + '';
|
|
124
120
|
} else {
|
|
125
|
-
|
|
121
|
+
throw new Error(
|
|
122
|
+
'BaseTableColumn: customKey or field prop is required'
|
|
123
|
+
);
|
|
126
124
|
}
|
|
125
|
+
|
|
127
126
|
this.addColumn(this);
|
|
128
127
|
},
|
|
129
128
|
beforeUnmount() {
|