Skip to content

Commit c3ea992

Browse files
committed
Upgrade to vue alpha.6
1 parent 9e37038 commit c3ea992

File tree

5 files changed

+41
-64
lines changed

5 files changed

+41
-64
lines changed

package-lock.json

+31-53
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"name": "vue-datagrid",
33
"version": "0.1.0",
44
"dependencies": {
5-
"vue": "^3.0.0-alpha.5"
5+
"vue": "^3.0.0-alpha.6"
66
},
77
"devDependencies": {
8-
"@vue/compiler-sfc": "^3.0.0-alpha.5",
8+
"@vue/compiler-sfc": "^3.0.0-alpha.6",
99
"css-loader": "^3.4.2",
1010
"ts-loader": "^6.2.1",
11-
"typescript": "^3.8.1-rc",
11+
"typescript": "^3.8.2",
1212
"vue-loader": "^16.0.0-alpha.3",
1313
"vue-style-loader": "^4.1.2",
1414
"webpack": "^4.41.6",

src/datagrid.vue

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
<thead>
77
<tr>
88
<th v-if='selected' class='dg-header'>
9-
<!-- FIXME: v-model='allSelected' when alpha.6 is published -->
10-
<input type='checkbox' :checked='allSelected' @change='allSelected = $event.target.checked' :indeterminate='allSelected === 1' />
9+
<input type='checkbox' v-model='allSelected' :indeterminate='allSelected == null' />
1110
</th>
1211
<th v-for='(c, i) of columns'
1312
:key='i'
@@ -40,7 +39,7 @@
4039
</template>
4140

4241
<script lang="ts">
43-
import { ref, watch } from 'vue';
42+
import { shallowRef as sref, watch } from 'vue';
4443
import { Column } from "./column";
4544
import { useSelection } from "./selection";
4645
import SortIndicator from './sort-indicator';
@@ -63,8 +62,8 @@ export default {
6362
},
6463
6564
setup(props: { columns?: Column[], data?: object[] | Promise<object[]>, selected?: Set<object> }) {
66-
const loading = ref(true);
67-
const data = ref([] as object[]);
65+
const loading = sref(true);
66+
const data = sref([] as object[]);
6867
const selection = useSelection(data, props.selected);
6968
const sorting = useSorting(data);
7069
const virtual = useVirtual(sorting.data);

src/selection.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export function useSelection(data: Ref<object[]>, selected?: Set<object>) {
1717
allSelected: computed({
1818
get() {
1919
return selected.size === 0 ? false :
20-
selected.size === data.value.length ? true : 1; // 1 is purposefully truthy (null or undefined is not)
20+
selected.size === data.value.length ? true : null;
2121
},
22-
set(value: boolean | 1) {
22+
set(value: boolean | null) {
2323
if (value)
2424
data.value.forEach(selected.add, selected);
2525
else

src/virtual.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function useVirtual(data: Ref<object[]>) {
3838
const length = data.value.length;
3939
const { buffer, height, rowHeight, scrollTop } = state;
4040
const index = state.index = Math.max((scrollTop / rowHeight | 0) - buffer, 0);
41-
const count = state.count = Math.min((height / rowHeight | 0) + 1 + buffer + buffer, data.value.length - index);
41+
const count = state.count = Math.min((height / rowHeight | 0) + 1 + buffer + buffer, length - index);
4242
state.topGap = index * rowHeight;
4343
state.bottomGap = (length - count - index) * rowHeight;
4444
});

0 commit comments

Comments
 (0)