This repository has been archived by the owner on Aug 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: (breaking change) re-implemented table component
- Loading branch information
1 parent
23a266a
commit 48cd6e0
Showing
45 changed files
with
1,317 additions
and
1,295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,51 @@ | ||
<template> | ||
<tr :aria-selected="String(selected_)" v-on="$listeners"> | ||
<template v-for="header in normalizedHeaders"> | ||
<fd-table-cell-fixed-provider | ||
:fixed="header.columnFixed" | ||
:key="header.id" | ||
> | ||
<slot :name="header.slotName" /> | ||
</fd-table-cell-fixed-provider> | ||
</template> | ||
</tr> | ||
</template> | ||
|
||
<script> | ||
import FdTableCellFixedProvider from "./fixed-provider.vue"; | ||
export default { | ||
name: "FdTableRow", | ||
components: { FdTableCellFixedProvider }, | ||
inject: { | ||
fdTableItemProvider: { | ||
default: { | ||
item: {}, | ||
selected: null | ||
} | ||
}, | ||
table: { default: null } | ||
}, | ||
props: { | ||
itemId: { | ||
type: String, | ||
default: null | ||
item: { | ||
type: Object, | ||
default: () => {} | ||
}, | ||
isSelected: { | ||
selected: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}, | ||
computed: { | ||
firstColumnFixed() { | ||
const table = this.table; | ||
return (table || false) && table.firstColumnFixed; | ||
} | ||
}, | ||
methods: { | ||
handleClick() { | ||
const table = this.table; | ||
const { itemId } = this; | ||
if (itemId == null || table == null) { | ||
return false; | ||
} | ||
table.toggleSelectionForItem(itemId); | ||
selected_() { | ||
const { selected, fdTableItemProvider } = this; | ||
return fdTableItemProvider.selected != null | ||
? fdTableItemProvider.selected | ||
: selected; | ||
}, | ||
normalizedHeaders() { | ||
return this.table.normalizedHeaders; | ||
} | ||
}, | ||
render(h) { | ||
const cells = this.$slots.default || []; | ||
cells.forEach((cell, index) => { | ||
const options = cell.componentOptions; | ||
if (options == null) { | ||
return; | ||
} | ||
const fixed = index === 0 && this.firstColumnFixed; | ||
const { propsData = {} } = options; | ||
options.propsData = { ...propsData, fixed }; | ||
}); | ||
return h( | ||
"tr", | ||
{ | ||
on: { | ||
...this.$listeners, | ||
"&click": this.handleClick // & = passive modifier | ||
}, | ||
attrs: { | ||
"aria-selected": this.isSelected | ||
} | ||
}, | ||
cells | ||
); | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script> | ||
export default { | ||
props: { | ||
fixed: { | ||
type: Boolean, | ||
required: true | ||
} | ||
}, | ||
provide() { | ||
return { | ||
fdTableFixedProvider: this.fdTableFixedProvider | ||
}; | ||
}, | ||
render() { | ||
const defaultSlot = this.$scopedSlots.default; | ||
if (defaultSlot == null) { | ||
return null; | ||
} | ||
return defaultSlot(); | ||
}, | ||
watch: { | ||
fixed(fixed) { | ||
this.fdTableFixedProvider.fixed = fixed; | ||
} | ||
}, | ||
data() { | ||
return { | ||
fdTableFixedProvider: { | ||
fixed: this.fixed | ||
} | ||
}; | ||
} | ||
}; | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script> | ||
export default { | ||
props: { | ||
item: { | ||
type: Object, | ||
required: true | ||
}, | ||
selected: { | ||
type: Boolean, | ||
require: true | ||
} | ||
}, | ||
provide() { | ||
return { | ||
fdTableItemProvider: this.fdTableItemProvider | ||
}; | ||
}, | ||
render() { | ||
return this.$scopedSlots.default(); | ||
}, | ||
watch: { | ||
selected(selected) { | ||
this.fdTableItemProvider.selected = selected; | ||
}, | ||
item(item) { | ||
this.fdTableItemProvider.item = item; | ||
} | ||
}, | ||
data() { | ||
return { | ||
fdTableItemProvider: { | ||
item: this.item, | ||
selected: this.selected | ||
} | ||
}; | ||
} | ||
}; | ||
</script> |
Oops, something went wrong.