Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from protonemedia/vue3
Browse files Browse the repository at this point in the history
Support for Vue 3
  • Loading branch information
pascalbaljet authored Apr 7, 2021
2 parents 86127d5 + 09d54a2 commit 6223570
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm install
- run: npm run test
- run: npm run test:2
- run: npm run test:3
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ We proudly support the community by developing Laravel packages and giving them

## Compatibility

* [Vue 2.6](https://vuejs.org/v2/guide/installation.html)
* [Vue 2.6](https://vuejs.org/v2/guide/installation.html) and [Vue 3](https://v3.vuejs.org/guide/installation.html)
* [Laravel 8](https://laravel.com/)
* [Inertia.js](https://inertiajs.com/)
* [Tailwind CSS v2](https://tailwindcss.com/) + [Forms plugin](https://github.com/tailwindlabs/tailwindcss-forms)
* PHP 7.4 + 8.0

## Roadmap

* Support for Vue 3
* Remove @tailwindcss/forms dependency
* Debounce delay for inputs
* Convert Table.vue styling to proper Tailwind syntax
Expand All @@ -44,7 +43,7 @@ We proudly support the community by developing Laravel packages and giving them

## Installation

You need to install both the server-side package as well as the client-side package. Note that this package is only compatible with Laravel 8, Vue 2.6 and requires the Tailwind Forms plugin.
You need to install both the server-side package as well as the client-side package. Note that this package is only compatible with Laravel 8, Vue 2.6 + 3.0 and requires the Tailwind Forms plugin.

### Server-side installation (Laravel)

Expand Down
4 changes: 0 additions & 4 deletions js/Components/ButtonWithDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ export default {
},
mounted() {
if (!this.$refs.button || !this.$refs.tooltip) {
return;
}
this.popper = createPopper(this.$refs.button, this.$refs.tooltip, {
placement: this.placement,
modifiers: [flip, preventOverflow],
Expand Down
35 changes: 24 additions & 11 deletions js/Components/OnClickOutside.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
<template>
<div>
<slot />
</div>
</template>

<script>
export default {
props: ["do"],
props: {
do: {
type: Function,
required: true,
},
},
data() {
return {
listener: null,
};
},
mounted() {
const listener = (e) => {
this.listener = (e) => {
if (e.target === this.$el || this.$el.contains(e.target)) {
return;
}
this.do();
};
document.addEventListener("click", listener);
document.addEventListener("touchstart", listener);
this.$once("hook:beforeDestroy", () => {
document.removeEventListener("click", listener);
document.removeEventListener("touchstart", listener);
});
document.addEventListener("click", this.listener);
document.addEventListener("touchstart", this.listener);
},
render() {
return this.$slots.default[0];
beforeUnmount() {
document.removeEventListener("click", this.listener);
document.removeEventListener("touchstart", this.listener);
},
};
</script>
8 changes: 7 additions & 1 deletion js/Components/TableSearchRows.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ export default {
},
focus(key) {
this.$refs[key][0].focus();
const keyRef = this.$refs[key];
if (keyRef.length === 1) {
return keyRef[0].focus();
}
keyRef.focus();
},
},
Expand Down
8 changes: 5 additions & 3 deletions js/InteractsWithQueryBuilder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default {
columns: this.getColumnsForQuery(this.queryBuilderProps.columns || {}),
};
return { queryBuilderData };
return { queryBuilderData, queryBuilderDataIteration: 0 };
},
methods: {
Expand Down Expand Up @@ -85,12 +85,14 @@ export default {
page = 1;
}
this.$set(this, "queryBuilderData", {
this.queryBuilderData = {
page,
sort: this.queryBuilderData.sort || "",
filter,
columns: this.getColumnsForQuery(data.columns || {}),
});
};
this.queryBuilderDataIteration++;
},
},
Expand Down
109 changes: 109 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"description": "Inertia.js Front-end Components for Spatie's Laravel Query Builder",
"main": "js/index.js",
"scripts": {
"test": "jest"
"test:2": "vue-demi-switch 2 && jest",
"test:3": "vue-demi-switch 3 vue3 && jest"
},
"author": "Pascal Baljet",
"license": "MIT",
"dependencies": {
"@popperjs/core": "^2.9.2",
"@vue/composition-api": "^1.0.0-rc.6",
"lodash-es": "^4.17.21",
"qs": "^6.10.1"
},
Expand All @@ -25,9 +27,20 @@
"expect": "^26.6.2",
"jest": "^26.6.3",
"vue": "^2.6.12",
"vue3": "npm:vue@3",
"vue-demi": "^0.7.4",
"vue-jest": "^3.0.7",
"vue-template-compiler": "^2.6.12"
},
"peerDependencies": {
"@vue/composition-api": "^1.0.0-rc.6",
"vue": "^2.6.12 || >=3.0.0"
},
"peerDependenciesMeta": {
"@vue/composition-api": {
"optional": true
}
},
"jest": {
"moduleFileExtensions": [
"js",
Expand Down

0 comments on commit 6223570

Please sign in to comment.