@antify/ui 2.2.0 → 2.2.3
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/components/AntAccordion.vue +25 -12
- package/dist/components/AntAccordionItem.vue +28 -13
- package/dist/components/AntAlert.vue +25 -15
- package/dist/components/AntCard.vue +26 -14
- package/dist/components/AntContent.vue +4 -4
- package/dist/components/AntDropdown.vue +41 -23
- package/dist/components/AntIcon.vue +18 -6
- package/dist/components/AntKeycap.vue +31 -16
- package/dist/components/AntListGroup.vue +13 -11
- package/dist/components/AntListGroupItem.vue +19 -9
- package/dist/components/AntModal.vue +26 -15
- package/dist/components/AntPagination.vue +28 -15
- package/dist/components/AntPopover.vue +74 -51
- package/dist/components/AntSkeleton.vue +8 -4
- package/dist/components/AntSpinner.vue +14 -6
- package/dist/components/AntTag.vue +25 -13
- package/dist/components/AntToast.vue +19 -11
- package/dist/components/AntToaster.vue +13 -5
- package/dist/components/AntTooltip.vue +78 -54
- package/dist/components/__stories/AntAccordion.stories.js +4 -4
- package/dist/components/__stories/AntAccordion.stories.mjs +50 -17
- package/dist/components/__stories/AntAlert.stories.mjs +18 -5
- package/dist/components/__stories/AntCard.stories.mjs +36 -10
- package/dist/components/__stories/AntContent.stories.mjs +14 -4
- package/dist/components/__stories/AntDropdown.stories.mjs +20 -4
- package/dist/components/__stories/AntIcon.stories.mjs +38 -12
- package/dist/components/__stories/AntKeycap.stories.mjs +35 -10
- package/dist/components/__stories/AntListGroup.stories.d.ts +1 -1
- package/dist/components/__stories/AntListGroup.stories.mjs +22 -4
- package/dist/components/__stories/AntListGroupItem.stories.mjs +27 -8
- package/dist/components/__stories/AntModal.stories.mjs +17 -4
- package/dist/components/__stories/AntPagination.stories.mjs +21 -6
- package/dist/components/__stories/AntPopover.stories.mjs +20 -4
- package/dist/components/__stories/AntSkeleton.stories.mjs +17 -5
- package/dist/components/__stories/AntSpinner.stories.mjs +33 -9
- package/dist/components/__stories/AntTag.stories.mjs +28 -8
- package/dist/components/__stories/AntToast.stories.mjs +19 -5
- package/dist/components/__stories/AntToaster.stories.d.ts +1 -1
- package/dist/components/__stories/AntToaster.stories.mjs +35 -9
- package/dist/components/__stories/AntTooltip.stories.js +1 -1
- package/dist/components/__stories/AntTooltip.stories.mjs +44 -13
- package/dist/components/buttons/AntActionButton.vue +38 -29
- package/dist/components/buttons/AntButton.vue +34 -13
- package/dist/components/buttons/AntCreateButton.vue +11 -4
- package/dist/components/buttons/AntDeleteButton.vue +11 -4
- package/dist/components/buttons/AntDuplicateButton.vue +11 -4
- package/dist/components/buttons/AntEditButton.vue +11 -4
- package/dist/components/buttons/AntSaveAndNewButton.vue +11 -4
- package/dist/components/buttons/AntSaveButton.vue +11 -4
- package/dist/components/buttons/__stories/AntActionButton.stories.mjs +35 -10
- package/dist/components/buttons/__stories/AntButton.stories.mjs +77 -23
- package/dist/components/buttons/__stories/AntCreateButton.stories.mjs +25 -7
- package/dist/components/buttons/__stories/AntDeleteButton.stories.mjs +25 -7
- package/dist/components/buttons/__stories/AntDuplicateButton.stories.mjs +25 -7
- package/dist/components/buttons/__stories/AntEditButton.stories.mjs +25 -7
- package/dist/components/buttons/__stories/AntSaveAndNewButton.stories.mjs +25 -7
- package/dist/components/buttons/__stories/AntSaveButton.stories.mjs +25 -7
- package/dist/components/crud/AntCrud.vue +6 -6
- package/dist/components/crud/AntCrudDetail.vue +8 -5
- package/dist/components/crud/AntCrudDetailActions.vue +14 -8
- package/dist/components/crud/AntCrudDetailNav.vue +21 -13
- package/dist/components/crud/AntCrudTableFilter.vue +29 -17
- package/dist/components/crud/AntCrudTableNav.vue +36 -22
- package/dist/components/crud/__stories/AntCrud.stories.mjs +17 -5
- package/dist/components/crud/__stories/AntCrudDetail.stories.mjs +11 -3
- package/dist/components/crud/__stories/AntCrudDetailActions.stories.mjs +10 -2
- package/dist/components/crud/__stories/AntCrudDetailNav.stories.mjs +11 -3
- package/dist/components/crud/__stories/AntCrudTableFilter.stories.mjs +17 -5
- package/dist/components/crud/__stories/AntCrudTableNav.stories.mjs +23 -7
- package/dist/components/dialogs/AntDeleteDialog.vue +13 -5
- package/dist/components/dialogs/AntDialog.vue +23 -13
- package/dist/components/dialogs/__stories/AndDeleteDialog.stories.mjs +12 -3
- package/dist/components/dialogs/__stories/AntDialog.stories.mjs +28 -7
- package/dist/components/forms/AntField.vue +18 -7
- package/dist/components/forms/AntFormGroup.vue +9 -5
- package/dist/components/forms/AntFormGroupLabel.vue +1 -1
- package/dist/components/forms/__stories/AntField.stories.mjs +37 -9
- package/dist/components/forms/__stories/AntFormGroup.stories.mjs +20 -5
- package/dist/components/forms/__stories/AntFormGroupLabel.stories.mjs +11 -3
- package/dist/components/index.d.ts +1 -1
- package/dist/components/inputs/AntCheckbox.vue +61 -36
- package/dist/components/inputs/AntCheckboxGroup.vue +40 -15
- package/dist/components/inputs/AntDateInput.vue +35 -12
- package/dist/components/inputs/AntNumberInput.vue +33 -12
- package/dist/components/inputs/AntPasswordInput.vue +32 -11
- package/dist/components/inputs/AntRadio.vue +57 -34
- package/dist/components/inputs/AntRadioGroup.vue +60 -35
- package/dist/components/inputs/AntRangeSlider.vue +31 -12
- package/dist/components/inputs/AntSearch.vue +19 -7
- package/dist/components/inputs/AntSelect.vue +107 -83
- package/dist/components/inputs/AntSwitch.vue +36 -18
- package/dist/components/inputs/AntSwitcher.vue +30 -15
- package/dist/components/inputs/AntTagInput.vue +91 -61
- package/dist/components/inputs/AntTextInput.vue +31 -11
- package/dist/components/inputs/AntTextarea.vue +53 -25
- package/dist/components/inputs/AntUnitInput.vue +33 -12
- package/dist/components/inputs/Elements/AntBaseInput.vue +47 -18
- package/dist/components/inputs/Elements/AntInputDescription.vue +16 -8
- package/dist/components/inputs/Elements/AntInputLabel.vue +13 -5
- package/dist/components/inputs/Elements/AntInputLimiter.vue +13 -5
- package/dist/components/inputs/Elements/AntSelectMenu.vue +65 -41
- package/dist/components/inputs/Elements/__stories/AntBaseInput.stories.mjs +104 -27
- package/dist/components/inputs/Elements/__stories/AntInputDescription.stories.mjs +33 -9
- package/dist/components/inputs/Elements/__stories/AntInputLabel.stories.mjs +34 -9
- package/dist/components/inputs/Elements/__stories/AntInputLimiter.stories.mjs +33 -9
- package/dist/components/inputs/Elements/index.d.ts +1 -1
- package/dist/components/inputs/__stories/AntCheckbox.stories.mjs +34 -9
- package/dist/components/inputs/__stories/AntCheckboxGroup.stories.mjs +45 -21
- package/dist/components/inputs/__stories/AntDateInput.stories.mjs +52 -14
- package/dist/components/inputs/__stories/AntNumberInput.stories.mjs +66 -17
- package/dist/components/inputs/__stories/AntPasswordInput.stories.mjs +51 -13
- package/dist/components/inputs/__stories/AntRadioGroup.stories.mjs +45 -12
- package/dist/components/inputs/__stories/AntRangeSlider.stories.mjs +16 -5
- package/dist/components/inputs/__stories/AntSearch.stories.mjs +41 -10
- package/dist/components/inputs/__stories/AntSelect.stories.mjs +59 -15
- package/dist/components/inputs/__stories/AntSwitch.stories.js +126 -102
- package/dist/components/inputs/__stories/AntSwitch.stories.mjs +162 -112
- package/dist/components/inputs/__stories/AntSwitcher.stories.mjs +38 -10
- package/dist/components/inputs/__stories/AntTagInput.stories.mjs +46 -12
- package/dist/components/inputs/__stories/AntTextInput.stories.mjs +59 -16
- package/dist/components/inputs/__stories/AntTextarea.stories.mjs +47 -13
- package/dist/components/inputs/__stories/AntUnitInput.stories.mjs +46 -12
- package/dist/components/layouts/AntNavLeftLayout.vue +12 -6
- package/dist/components/layouts/__stories/AntNavLeftLayout.stories.mjs +10 -2
- package/dist/components/navbar/AntNavbar.vue +7 -3
- package/dist/components/navbar/AntNavbarItem.vue +12 -6
- package/dist/components/navbar/__stories/AntNavbar.stories.mjs +59 -37
- package/dist/components/table/AntCollapsibleTableRowContent.vue +7 -5
- package/dist/components/table/AntTable.vue +227 -165
- package/dist/components/table/AntTableSkeleton.vue +126 -0
- package/dist/components/table/AntTableSortButton.vue +22 -13
- package/dist/components/table/AntTd.vue +21 -17
- package/dist/components/table/AntTh.vue +19 -12
- package/dist/components/table/__stories/AntTable.stories.js +132 -14
- package/dist/components/table/__stories/AntTable.stories.mjs +253 -31
- package/dist/components/table/__types/index.d.ts +0 -1
- package/dist/components/table/__types/index.js +0 -11
- package/dist/components/table/__types/index.mjs +0 -1
- package/dist/components/tabs/AntTabItem.vue +20 -8
- package/dist/components/tabs/AntTabs.vue +35 -21
- package/dist/components/tabs/__stories/AntTabItem.stories.mjs +23 -7
- package/dist/components/tabs/__stories/AntTabs.stories.mjs +45 -13
- package/dist/components/transitions/AntTransitionCollapseHeight.vue +1 -1
- package/dist/composables/useToaster.mjs +25 -7
- package/dist/index.css +1 -0
- package/dist/utils.mjs +3 -1
- package/package.json +23 -16
- package/dist/tailwind.config.d.ts +0 -3
- package/dist/tailwind.config.js +0 -198
- package/dist/tailwind.config.mjs +0 -189
|
@@ -1,56 +1,70 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
AntTableSize, AntTableSortDirection, type TableHeader,
|
|
4
|
+
} from './__types/TableHeader.types';
|
|
5
|
+
import {
|
|
6
|
+
computed, onMounted, ref, type Ref, watch,
|
|
7
|
+
} from 'vue';
|
|
8
|
+
import {
|
|
9
|
+
useVModel,
|
|
10
|
+
} from '@vueuse/core';
|
|
11
|
+
import {
|
|
12
|
+
Size, State,
|
|
13
|
+
} from '../../enums';
|
|
6
14
|
import AntTh from './AntTh.vue';
|
|
7
15
|
import AntTd from './AntTd.vue';
|
|
8
16
|
import AntSpinner from '../AntSpinner.vue';
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
import {
|
|
18
|
+
hasSlotContent,
|
|
19
|
+
} from '../../utils';
|
|
20
|
+
import AntCollapsibleTableRowContent from './AntCollapsibleTableRowContent.vue';
|
|
21
|
+
import {
|
|
22
|
+
CollapseStrategy,
|
|
23
|
+
} from '../../types';
|
|
24
|
+
import {
|
|
25
|
+
faAngleDown, faAngleUp,
|
|
26
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
27
|
+
import AntButton from '../buttons/AntButton.vue';
|
|
28
|
+
import AntIcon from '../AntIcon.vue';
|
|
29
|
+
import AntTableSkeleton from './AntTableSkeleton.vue';
|
|
16
30
|
|
|
17
|
-
defineOptions({
|
|
31
|
+
defineOptions({
|
|
32
|
+
inheritAttrs: false,
|
|
33
|
+
});
|
|
18
34
|
|
|
19
35
|
const emits = defineEmits([
|
|
20
36
|
'update:modelValue',
|
|
21
37
|
'update:skeleton',
|
|
22
38
|
'update:selectedRow',
|
|
23
39
|
'rowClick',
|
|
24
|
-
'updateSort'
|
|
40
|
+
'updateSort',
|
|
25
41
|
]);
|
|
26
42
|
// TODO:: add pagination prop and pagination to table
|
|
27
|
-
const props = withDefaults(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
43
|
+
const props = withDefaults(defineProps<{
|
|
44
|
+
selectedRow?: Record<string, unknown> | undefined;
|
|
45
|
+
headers: TableHeader[];
|
|
46
|
+
data: Record<string, unknown>[];
|
|
47
|
+
rowKey?: string;
|
|
48
|
+
loading?: boolean;
|
|
49
|
+
selectableRows?: boolean;
|
|
50
|
+
showLightVersion?: boolean;
|
|
51
|
+
size?: AntTableSize;
|
|
52
|
+
headerColor?: string;
|
|
53
|
+
emptyStateText?: string;
|
|
54
|
+
collapseStrategy?: CollapseStrategy;
|
|
55
|
+
expandedRows?: boolean;
|
|
56
|
+
}>(), {
|
|
57
|
+
rowKey: 'id',
|
|
58
|
+
loading: false,
|
|
59
|
+
selectableRows: false,
|
|
60
|
+
showLightVersion: false,
|
|
61
|
+
size: AntTableSize.md,
|
|
62
|
+
headerColor: 'bg-base-200',
|
|
63
|
+
emptyStateText: 'We couldn\'t find any entry',
|
|
64
|
+
collapseStrategy: CollapseStrategy.single,
|
|
65
|
+
expandedRows: false,
|
|
66
|
+
});
|
|
52
67
|
const slots = defineSlots();
|
|
53
|
-
|
|
54
68
|
const openItems = ref<number[]>([]);
|
|
55
69
|
const selected: Ref<Record<string, unknown> | undefined> = useVModel(props, 'selectedRow', emits);
|
|
56
70
|
const _loading: Ref<boolean> = useVModel(props, 'loading', emits);
|
|
@@ -65,11 +79,8 @@ const _headers = computed(() => {
|
|
|
65
79
|
return props.headers;
|
|
66
80
|
});
|
|
67
81
|
|
|
68
|
-
const maxColSpan = computed(() => _headers.value.length + (hasSlotContent(slots['rowFirstCell']) ? 1 : 0) + (hasSlotContent(slots['rowLastCell']) ? 1 : 0))
|
|
69
|
-
|
|
70
|
-
watch(() => props.showLightVersion, (val) => {
|
|
71
|
-
setTimeout(() => _showLightVersion.value = val, val ? 200 : 400);
|
|
72
|
-
});
|
|
82
|
+
const maxColSpan = computed(() => _headers.value.length + (hasSlotContent(slots['rowFirstCell']) ? 1 : 0) + (hasSlotContent(slots['rowLastCell']) ? 1 : 0));
|
|
83
|
+
const skeleton = computed(() => !props.data || props.data.length === 0 && _loading.value);
|
|
73
84
|
|
|
74
85
|
function sortTable(header: TableHeader, newDirection: AntTableSortDirection) {
|
|
75
86
|
// TODO:: Sorting is always done externally, here should only be a emit sort with header and direction.
|
|
@@ -96,9 +107,17 @@ function sortTable(header: TableHeader, newDirection: AntTableSortDirection) {
|
|
|
96
107
|
emits('updateSort', header, newDirection);
|
|
97
108
|
}
|
|
98
109
|
|
|
99
|
-
function
|
|
100
|
-
|
|
110
|
+
function getRowClasses(element: Record<string, unknown>, rowIndex: number) {
|
|
111
|
+
return {
|
|
112
|
+
'bg-primary-200 text-primary-200-font transition-colors': element === selected.value,
|
|
113
|
+
'bg-white text-for-white-bg-font': element !== selected.value && rowIndex % 2 === 0,
|
|
114
|
+
'bg-base-100 text-base-100-font': element !== selected.value && rowIndex % 2 !== 0,
|
|
115
|
+
'cursor-pointer': props.selectableRows,
|
|
116
|
+
'hover:bg-base-200': props.selectableRows && element !== selected.value,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
101
119
|
|
|
120
|
+
function rowClick(elem: Record<string, unknown>): void {
|
|
102
121
|
selected.value = elem;
|
|
103
122
|
|
|
104
123
|
emits('rowClick', elem);
|
|
@@ -108,161 +127,205 @@ function toggleRowContent(index: number) {
|
|
|
108
127
|
const isOpen = openItems.value.includes(index);
|
|
109
128
|
|
|
110
129
|
if (isOpen) {
|
|
111
|
-
openItems.value = props.collapseStrategy === CollapseStrategy.single
|
|
130
|
+
openItems.value = props.collapseStrategy === CollapseStrategy.single
|
|
112
131
|
? []
|
|
113
132
|
: openItems.value.filter(item => item !== index);
|
|
114
133
|
} else {
|
|
115
134
|
openItems.value = props.collapseStrategy === CollapseStrategy.single
|
|
116
|
-
? [
|
|
117
|
-
|
|
135
|
+
? [
|
|
136
|
+
index,
|
|
137
|
+
]
|
|
138
|
+
: [
|
|
139
|
+
...openItems.value,
|
|
140
|
+
index,
|
|
141
|
+
];
|
|
118
142
|
}
|
|
119
143
|
}
|
|
120
144
|
|
|
121
|
-
|
|
122
|
-
if (
|
|
123
|
-
|
|
145
|
+
function openRowsByDefault() {
|
|
146
|
+
if (props.expandedRows && props.data.length > 0) {
|
|
147
|
+
openItems.value = props.data.map((_, index) => index);
|
|
148
|
+
}
|
|
124
149
|
}
|
|
150
|
+
|
|
151
|
+
watch(() => props.showLightVersion, (val) => {
|
|
152
|
+
setTimeout(() => _showLightVersion.value = val, val ? 200 : 400);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
watch(() => props.data, (currVal, prevVal) => {
|
|
156
|
+
if (currVal.length > prevVal.length) {
|
|
157
|
+
// Add newest element to the list of open items so it is open by default
|
|
158
|
+
// Necessary when table content is changed dynamically
|
|
159
|
+
if (props.collapseStrategy === CollapseStrategy.single) {
|
|
160
|
+
openItems.value = [
|
|
161
|
+
currVal.length - 1,
|
|
162
|
+
];
|
|
163
|
+
} else {
|
|
164
|
+
openItems.value = [
|
|
165
|
+
...openItems.value,
|
|
166
|
+
currVal.length - 1,
|
|
167
|
+
];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
onMounted(() => {
|
|
173
|
+
openRowsByDefault();
|
|
174
|
+
});
|
|
125
175
|
</script>
|
|
126
176
|
|
|
127
177
|
<template>
|
|
128
178
|
<div
|
|
129
|
-
class="relative inline-block
|
|
179
|
+
class="relative inline-block w-full align-middle h-full"
|
|
130
180
|
data-e2e="table"
|
|
131
181
|
>
|
|
132
|
-
<div
|
|
182
|
+
<div
|
|
183
|
+
v-if="!skeleton"
|
|
184
|
+
class="overflow-hidden h-full overflow-x-auto overflow-y-auto"
|
|
185
|
+
>
|
|
133
186
|
<table
|
|
134
187
|
v-bind="$attrs"
|
|
135
188
|
class="min-w-full max-h-full relative"
|
|
136
189
|
:class="{'h-full': data.length === 0 && !_loading}"
|
|
137
190
|
>
|
|
138
|
-
<thead
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
<template v-for="(header, index) in _headers">
|
|
143
|
-
<AntTh
|
|
144
|
-
v-if="!_showLightVersion || (_showLightVersion && header.lightVersion)"
|
|
145
|
-
:key="`table-header-${header.identifier}-${index}`"
|
|
146
|
-
:header="header"
|
|
147
|
-
:size="size"
|
|
148
|
-
@sort="sortTable"
|
|
149
|
-
>
|
|
150
|
-
<template #headerContent>
|
|
151
|
-
<slot
|
|
152
|
-
name="headerContent"
|
|
153
|
-
v-bind="header"
|
|
154
|
-
/>
|
|
155
|
-
</template>
|
|
156
|
-
</AntTh>
|
|
157
|
-
</template>
|
|
158
|
-
|
|
159
|
-
<template v-if="!!$slots.afterRowContent">
|
|
160
|
-
<td/>
|
|
161
|
-
</template>
|
|
162
|
-
|
|
163
|
-
<slot name="headerLastCell"></slot>
|
|
164
|
-
</tr>
|
|
165
|
-
</thead>
|
|
166
|
-
|
|
167
|
-
<tbody class="bg-white relative">
|
|
168
|
-
<!-- TODO:: Add some kind of virtual list for very large tree data (or required pagination??) -->
|
|
169
|
-
<template
|
|
170
|
-
v-for="(elem, rowIndex) in data" :key="`table-row-${elem[rowKey]}-${rowIndex}`"
|
|
191
|
+
<thead
|
|
192
|
+
class="sticky top-0 z-10"
|
|
193
|
+
:class="headerColor"
|
|
171
194
|
>
|
|
172
|
-
<tr
|
|
173
|
-
|
|
174
|
-
:class="{
|
|
175
|
-
'bg-primary-200 text-primary-200-font transition-colors': elem === selected,
|
|
176
|
-
'bg-white text-for-white-bg-font': elem !== selected && rowIndex % 2 === 0,
|
|
177
|
-
'bg-base-100 text-base-100-font': elem !== selected && rowIndex % 2 !== 0,
|
|
178
|
-
'cursor-pointer': selectableRows,
|
|
179
|
-
'hover:bg-base-200': selectableRows && elem !== selected,
|
|
180
|
-
}"
|
|
181
|
-
>
|
|
182
|
-
<slot
|
|
183
|
-
name="rowFirstCell"
|
|
184
|
-
v-bind="{ elem }"
|
|
185
|
-
/>
|
|
195
|
+
<tr>
|
|
196
|
+
<slot name="headerFirstCell" />
|
|
186
197
|
|
|
187
|
-
<template v-for="(header,
|
|
188
|
-
<
|
|
198
|
+
<template v-for="(header, index) in _headers">
|
|
199
|
+
<AntTh
|
|
189
200
|
v-if="!_showLightVersion || (_showLightVersion && header.lightVersion)"
|
|
190
|
-
:key="`table-
|
|
201
|
+
:key="`table-header-${header.identifier}-${index}`"
|
|
191
202
|
:header="header"
|
|
192
|
-
:element="elem"
|
|
193
|
-
:align="header.align"
|
|
194
203
|
:size="size"
|
|
195
|
-
@
|
|
204
|
+
@sort="sortTable"
|
|
196
205
|
>
|
|
197
|
-
<template #
|
|
206
|
+
<template #headerContent>
|
|
198
207
|
<slot
|
|
199
|
-
name="
|
|
200
|
-
v-bind="
|
|
208
|
+
name="headerContent"
|
|
209
|
+
v-bind="header"
|
|
201
210
|
/>
|
|
202
211
|
</template>
|
|
203
|
-
|
|
204
|
-
<template #cellContent="props">
|
|
205
|
-
<slot
|
|
206
|
-
name="cellContent"
|
|
207
|
-
v-bind="{...props, colIndex, rowIndex}"
|
|
208
|
-
/>
|
|
209
|
-
</template>
|
|
210
|
-
|
|
211
|
-
<template #afterCellContent="props">
|
|
212
|
-
<slot
|
|
213
|
-
name="afterCellContent"
|
|
214
|
-
v-bind="{...props, colIndex, rowIndex}"
|
|
215
|
-
/>
|
|
216
|
-
</template>
|
|
217
|
-
</AntTd>
|
|
212
|
+
</AntTh>
|
|
218
213
|
</template>
|
|
219
214
|
|
|
220
215
|
<template v-if="!!$slots.afterRowContent">
|
|
221
|
-
<td
|
|
222
|
-
@click="(e) => rowClick(e, elem)">
|
|
223
|
-
<AntButton @click="toggleRowContent(rowIndex)" :size="Size.xs2">
|
|
224
|
-
<AntIcon :icon="openItems.includes(rowIndex) ? faAngleUp : faAngleDown"/>
|
|
225
|
-
</AntButton>
|
|
226
|
-
</td>
|
|
216
|
+
<td />
|
|
227
217
|
</template>
|
|
228
218
|
|
|
229
|
-
<slot
|
|
230
|
-
name="rowLastCell"
|
|
231
|
-
v-bind="{ elem }"
|
|
232
|
-
/>
|
|
219
|
+
<slot name="headerLastCell" />
|
|
233
220
|
</tr>
|
|
221
|
+
</thead>
|
|
222
|
+
|
|
223
|
+
<tbody class="bg-white relative">
|
|
224
|
+
<!-- TODO:: Add some kind of virtual list for very large tree data (or required pagination??) -->
|
|
225
|
+
<template
|
|
226
|
+
v-for="(elem, rowIndex) in data"
|
|
227
|
+
:key="`table-row-${elem[rowKey]}-${rowIndex}`"
|
|
228
|
+
>
|
|
229
|
+
<tr
|
|
230
|
+
:id="elem[rowKey] as string"
|
|
231
|
+
data-e2e="table-row"
|
|
232
|
+
:class="getRowClasses(elem, rowIndex)"
|
|
233
|
+
>
|
|
234
|
+
<slot
|
|
235
|
+
name="rowFirstCell"
|
|
236
|
+
v-bind="{ elem }"
|
|
237
|
+
/>
|
|
234
238
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
+
<template v-for="(header, colIndex) in _headers">
|
|
240
|
+
<AntTd
|
|
241
|
+
v-if="!_showLightVersion || (_showLightVersion && header.lightVersion)"
|
|
242
|
+
:key="`table-cell-${header.identifier}-${rowIndex}-${colIndex}`"
|
|
243
|
+
:data-e2e="`table-cell-${header.identifier}`"
|
|
244
|
+
:header="header"
|
|
245
|
+
:element="elem"
|
|
246
|
+
:align="header.align"
|
|
247
|
+
:size="size"
|
|
248
|
+
@click="rowClick(elem)"
|
|
239
249
|
>
|
|
240
|
-
<
|
|
241
|
-
|
|
242
|
-
|
|
250
|
+
<template #beforeCellContent="props">
|
|
251
|
+
<slot
|
|
252
|
+
name="beforeCellContent"
|
|
253
|
+
v-bind="{...props, colIndex, rowIndex}"
|
|
254
|
+
/>
|
|
255
|
+
</template>
|
|
256
|
+
|
|
257
|
+
<template #cellContent="props">
|
|
258
|
+
<slot
|
|
259
|
+
name="cellContent"
|
|
260
|
+
v-bind="{...props, colIndex, rowIndex}"
|
|
261
|
+
/>
|
|
262
|
+
</template>
|
|
263
|
+
|
|
264
|
+
<template #afterCellContent="props">
|
|
265
|
+
<slot
|
|
266
|
+
name="afterCellContent"
|
|
267
|
+
v-bind="{...props, colIndex, rowIndex}"
|
|
268
|
+
/>
|
|
269
|
+
</template>
|
|
270
|
+
</AntTd>
|
|
271
|
+
</template>
|
|
272
|
+
|
|
273
|
+
<template v-if="!!$slots.afterRowContent">
|
|
274
|
+
<td
|
|
275
|
+
class="whitespace-nowrap text-sm font-medium relative px-2 py-0 h-9 text-right"
|
|
276
|
+
@click="rowClick(elem)"
|
|
277
|
+
>
|
|
278
|
+
<AntButton
|
|
279
|
+
:size="Size.xs2"
|
|
280
|
+
@click="toggleRowContent(rowIndex)"
|
|
281
|
+
>
|
|
282
|
+
<AntIcon :icon="openItems.includes(rowIndex) ? faAngleUp : faAngleDown" />
|
|
283
|
+
</AntButton>
|
|
284
|
+
</td>
|
|
285
|
+
</template>
|
|
286
|
+
|
|
287
|
+
<slot
|
|
288
|
+
name="rowLastCell"
|
|
289
|
+
v-bind="{ elem }"
|
|
290
|
+
/>
|
|
243
291
|
</tr>
|
|
292
|
+
|
|
293
|
+
<template v-if="!!$slots.afterRowContent">
|
|
294
|
+
<tr data-e2e="table-after-row-content">
|
|
295
|
+
<td
|
|
296
|
+
:colspan="maxColSpan + 1"
|
|
297
|
+
class="p-0"
|
|
298
|
+
>
|
|
299
|
+
<AntCollapsibleTableRowContent :is-open="openItems.includes(rowIndex)">
|
|
300
|
+
<slot
|
|
301
|
+
name="afterRowContent"
|
|
302
|
+
v-bind="{ element: elem, rowIndex }"
|
|
303
|
+
/>
|
|
304
|
+
</AntCollapsibleTableRowContent>
|
|
305
|
+
</td>
|
|
306
|
+
</tr>
|
|
307
|
+
</template>
|
|
244
308
|
</template>
|
|
245
|
-
</template>
|
|
246
309
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
310
|
+
<tr v-if="data.length === 0 && !_loading">
|
|
311
|
+
<td
|
|
312
|
+
colspan="100"
|
|
313
|
+
class="w-full h-full py-2 text-center text-for-white-bg-font text-lg"
|
|
314
|
+
>
|
|
315
|
+
<slot name="emptyState">
|
|
316
|
+
<div class="flex items-center flex-col">
|
|
317
|
+
<span class="font-semibold">{{ emptyStateText }}</span>
|
|
318
|
+
</div>
|
|
319
|
+
</slot>
|
|
320
|
+
</td>
|
|
321
|
+
</tr>
|
|
259
322
|
</tbody>
|
|
260
323
|
</table>
|
|
261
324
|
</div>
|
|
262
325
|
|
|
263
326
|
<div
|
|
264
327
|
v-if="data.length > 0 && _loading"
|
|
265
|
-
class="absolute
|
|
328
|
+
class="absolute w-full top-0 bottom-0 bg-base-300/50 flex items-center justify-center z-10"
|
|
266
329
|
>
|
|
267
330
|
<AntSpinner
|
|
268
331
|
class="!w-24 !h-24"
|
|
@@ -270,14 +333,13 @@ if (!props.rowsCollapsed) {
|
|
|
270
333
|
/>
|
|
271
334
|
</div>
|
|
272
335
|
|
|
273
|
-
<
|
|
274
|
-
v-if="
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
</div>
|
|
336
|
+
<AntTableSkeleton
|
|
337
|
+
v-if="skeleton"
|
|
338
|
+
:headers="_headers"
|
|
339
|
+
:size="size"
|
|
340
|
+
:get-row-classes="getRowClasses"
|
|
341
|
+
:header-color="headerColor"
|
|
342
|
+
:show-light-version="_showLightVersion"
|
|
343
|
+
/>
|
|
282
344
|
</div>
|
|
283
345
|
</template>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
AntTableRowTypes, AntTableSize, type TableHeader,
|
|
4
|
+
} from './__types';
|
|
5
|
+
import AntTd from './AntTd.vue';
|
|
6
|
+
import AntTh from './AntTh.vue';
|
|
7
|
+
import AntSkeleton from '../AntSkeleton.vue';
|
|
8
|
+
|
|
9
|
+
withDefaults(defineProps<{
|
|
10
|
+
headers: TableHeader[];
|
|
11
|
+
getRowClasses: (element: Record<string, unknown>, rowIndex: number) => {};
|
|
12
|
+
size?: AntTableSize;
|
|
13
|
+
headerColor?: string;
|
|
14
|
+
showLightVersion?: boolean;
|
|
15
|
+
}>(), {
|
|
16
|
+
size: AntTableSize.md,
|
|
17
|
+
headerColor: 'bg-base-200',
|
|
18
|
+
showLightVersion: false,
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<div class="overflow-hidden h-full overflow-x-auto overflow-y-auto">
|
|
24
|
+
<table
|
|
25
|
+
class="min-w-full max-h-full relative"
|
|
26
|
+
>
|
|
27
|
+
<thead
|
|
28
|
+
class="sticky top-0 z-10"
|
|
29
|
+
:class="headerColor"
|
|
30
|
+
>
|
|
31
|
+
<tr>
|
|
32
|
+
<AntTh
|
|
33
|
+
v-for="colNum in [0,1,2]"
|
|
34
|
+
v-if="!showLightVersion || (showLightVersion && headers[0].lightVersion)"
|
|
35
|
+
:key="`table-header-col-0`"
|
|
36
|
+
:header="{
|
|
37
|
+
identifier: `th-${colNum}`,
|
|
38
|
+
type: AntTableRowTypes.slot
|
|
39
|
+
}"
|
|
40
|
+
:size="size"
|
|
41
|
+
>
|
|
42
|
+
<template #headerContent>
|
|
43
|
+
<span class="relative h-4 w-full max-w-24 rounded overflow-hidden">
|
|
44
|
+
<AntSkeleton
|
|
45
|
+
absolute
|
|
46
|
+
/>
|
|
47
|
+
</span>
|
|
48
|
+
</template>
|
|
49
|
+
</AntTh>
|
|
50
|
+
</tr>
|
|
51
|
+
</thead>
|
|
52
|
+
|
|
53
|
+
<tbody class="bg-white relative">
|
|
54
|
+
<tr
|
|
55
|
+
data-e2e="table-row"
|
|
56
|
+
:class="getRowClasses({'foo': 'bar'}, 0)"
|
|
57
|
+
>
|
|
58
|
+
<AntTd
|
|
59
|
+
v-for="colNum in [0,1,2]"
|
|
60
|
+
v-if="!showLightVersion || (showLightVersion && headers[0].lightVersion)"
|
|
61
|
+
:header="{
|
|
62
|
+
identifier: `th-${colNum}`,
|
|
63
|
+
type: AntTableRowTypes.slot
|
|
64
|
+
}"
|
|
65
|
+
:element="{'foo': 'bar'}"
|
|
66
|
+
:size="size"
|
|
67
|
+
>
|
|
68
|
+
<template #cellContent>
|
|
69
|
+
<span class="flex relative h-4 w-full max-w-36 rounded overflow-hidden">
|
|
70
|
+
<AntSkeleton
|
|
71
|
+
absolute
|
|
72
|
+
/>
|
|
73
|
+
</span>
|
|
74
|
+
</template>
|
|
75
|
+
</AntTd>
|
|
76
|
+
</tr>
|
|
77
|
+
<tr
|
|
78
|
+
data-e2e="table-row"
|
|
79
|
+
:class="getRowClasses({'foo': 'bar'}, 1)"
|
|
80
|
+
>
|
|
81
|
+
<AntTd
|
|
82
|
+
v-for="colNum in [0,1,2]"
|
|
83
|
+
v-if="!showLightVersion || (showLightVersion && headers[0].lightVersion)"
|
|
84
|
+
:header="{
|
|
85
|
+
identifier: `th-${colNum}`,
|
|
86
|
+
type: AntTableRowTypes.slot
|
|
87
|
+
}"
|
|
88
|
+
:element="{'foo': 'bar'}"
|
|
89
|
+
:size="size"
|
|
90
|
+
>
|
|
91
|
+
<template #cellContent>
|
|
92
|
+
<span class="flex relative h-4 w-full max-w-48 rounded overflow-hidden">
|
|
93
|
+
<AntSkeleton
|
|
94
|
+
absolute
|
|
95
|
+
/>
|
|
96
|
+
</span>
|
|
97
|
+
</template>
|
|
98
|
+
</AntTd>
|
|
99
|
+
</tr>
|
|
100
|
+
<tr
|
|
101
|
+
data-e2e="table-row"
|
|
102
|
+
:class="getRowClasses({'foo': 'bar'}, 2)"
|
|
103
|
+
>
|
|
104
|
+
<AntTd
|
|
105
|
+
v-for="colNum in [0,1,2]"
|
|
106
|
+
v-if="!showLightVersion || (showLightVersion && headers[0].lightVersion)"
|
|
107
|
+
:header="{
|
|
108
|
+
identifier: `th-${colNum}`,
|
|
109
|
+
type: AntTableRowTypes.slot
|
|
110
|
+
}"
|
|
111
|
+
:element="{'foo': 'bar'}"
|
|
112
|
+
:size="size"
|
|
113
|
+
>
|
|
114
|
+
<template #cellContent>
|
|
115
|
+
<span class="flex relative h-4 w-full max-w-28 rounded overflow-hidden">
|
|
116
|
+
<AntSkeleton
|
|
117
|
+
absolute
|
|
118
|
+
/>
|
|
119
|
+
</span>
|
|
120
|
+
</template>
|
|
121
|
+
</AntTd>
|
|
122
|
+
</tr>
|
|
123
|
+
</tbody>
|
|
124
|
+
</table>
|
|
125
|
+
</div>
|
|
126
|
+
</template>
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
faAngleDown, faAngleUp, faMinus,
|
|
5
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
6
|
+
import {
|
|
7
|
+
AntTableSize, AntTableSortDirection,
|
|
8
|
+
} from './__types/TableHeader.types';
|
|
5
9
|
import AntButton from '../buttons/AntButton.vue';
|
|
6
|
-
import {
|
|
7
|
-
|
|
10
|
+
import {
|
|
11
|
+
computed,
|
|
12
|
+
} from 'vue';
|
|
13
|
+
import {
|
|
14
|
+
Size,
|
|
15
|
+
} from '../../enums/Size.enum';
|
|
8
16
|
|
|
9
|
-
defineEmits([
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
defineEmits([
|
|
18
|
+
'sortClick',
|
|
19
|
+
]);
|
|
20
|
+
const props = withDefaults(defineProps<{
|
|
21
|
+
sortDirection?: AntTableSortDirection;
|
|
22
|
+
size?: AntTableSize;
|
|
23
|
+
}>(), {
|
|
24
|
+
sortDirection: AntTableSortDirection.neutral,
|
|
25
|
+
size: AntTableSize.md,
|
|
26
|
+
});
|
|
18
27
|
|
|
19
28
|
const buttonSize = computed(() => {
|
|
20
29
|
if (props.size === AntTableSize.lg) {
|