123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- // Utilities
- import { computed } from 'vue';
- import { getPropertyFromItem, propsFactory } from "../../../util/index.mjs"; // Types
- // Composables
- export const makeDataTableItemsProps = propsFactory({
- items: {
- type: Array,
- default: () => []
- },
- itemValue: {
- type: [String, Array, Function],
- default: 'id'
- },
- itemSelectable: {
- type: [String, Array, Function],
- default: null
- },
- rowProps: [Object, Function],
- cellProps: [Object, Function],
- returnObject: Boolean
- }, 'DataTable-items');
- export function transformItem(props, item, index, columns) {
- const value = props.returnObject ? item : getPropertyFromItem(item, props.itemValue);
- const selectable = getPropertyFromItem(item, props.itemSelectable, true);
- const itemColumns = columns.reduce((obj, column) => {
- if (column.key != null) obj[column.key] = getPropertyFromItem(item, column.value);
- return obj;
- }, {});
- return {
- type: 'item',
- key: props.returnObject ? getPropertyFromItem(item, props.itemValue) : value,
- index,
- value,
- selectable,
- columns: itemColumns,
- raw: item
- };
- }
- export function transformItems(props, items, columns) {
- return items.map((item, index) => transformItem(props, item, index, columns));
- }
- export function useDataTableItems(props, columns) {
- const items = computed(() => transformItems(props, props.items, columns.value));
- return {
- items
- };
- }
- //# sourceMappingURL=items.mjs.map
|