Skip to content

Commit 5e81c5e

Browse files
authored
Merge pull request #11 from socotecio/addVuetify3Example
Add vuetify3 example
2 parents 21cc4e5 + cedcf18 commit 5e81c5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+17236
-33047
lines changed

package-lock.json

+13,638-14,530
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/VDUSTypes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type VDUSConfiguration = {
2727
}
2828

2929
type VuetifySortArraysObject = {
30-
sortBy: Array<string>;
30+
sortBy: Array<string | { key: string; order: 'asc' | 'desc'; }>;
3131
sortDesc: Array<boolean>;
3232
}
3333

src/utils/helpers.ts

+36-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {VuetifySortArraysObject} from "./VDUSTypes";
2+
import { isVue2 } from 'vue-demi'
23

34
export const elementToArrayOfInt = (element: any): Array<number> => {
45
return ["number", "string"].includes(typeof element)
@@ -37,33 +38,49 @@ export const extractIntegerValue = (value: any, defaultValue = 0): number => {
3738
};
3839

3940
export const getSortsArrayFromOrdering = (ordering: Array<string>|null): VuetifySortArraysObject => {
41+
4042
if (!ordering) {
4143
return { sortBy: [], sortDesc: [] };
4244
}
43-
const sortBy: Array<string> = [];
45+
const sortBy: Array<string | { key: string; order: 'asc' | 'desc'; }> = [];
4446
const sortDesc: Array<boolean> = [];
4547

46-
ordering.forEach(orderItem => {
47-
let isDesc = false;
48-
if (orderItem.startsWith("-")) {
49-
orderItem = orderItem.replace("-", "");
50-
isDesc = true;
51-
}
52-
sortBy.push(orderItem);
53-
sortDesc.push(isDesc);
54-
});
48+
ordering.forEach(orderItem => {
49+
let isDesc = false;
50+
if (orderItem.startsWith("-")) {
51+
orderItem = orderItem.replace("-", "");
52+
isDesc = true;
53+
}
54+
if(isVue2) {
55+
sortBy.push(orderItem);
56+
sortDesc.push(isDesc);
57+
} else {
58+
sortBy.push({key: orderItem, order: isDesc ? "desc" : "asc"});
59+
}
60+
});
5561

5662
return { sortBy, sortDesc };
5763
}
5864

59-
export const getOrderingFromSortArray = (sortBy: Array<string>, sortDesc: Array<boolean>): Array<string> => {
60-
const ordering: Array<string> = [];
61-
sortBy.forEach((orderItem, index) => {
62-
let isDesc = true;
63-
if (sortDesc.length > index) {
64-
isDesc = sortDesc[index];
65-
}
66-
ordering.push(`${isDesc ? "-" : ""}${orderItem}`);
67-
});
65+
export const getOrderingFromSortArray = (sortBy: Array<string | { key: string; order: 'asc' | 'desc'; }>, sortDesc: Array<boolean>): Array<string> => {
66+
let ordering: Array<string> = [];
67+
if(isVue2) {
68+
(sortBy as string[]).forEach((orderItem: string, index: number) => {
69+
let isDesc = true;
70+
if (sortDesc.length > index) {
71+
isDesc = sortDesc[index];
72+
}
73+
ordering.push(`${isDesc ? "-" : ""}${orderItem}`);
74+
});
75+
} else {
76+
// Vue 3 scenario: sortBy is Array<{ key: string; order: 'asc' | 'desc' }>
77+
ordering = (sortBy as Array<{ key: string; order: 'asc' | 'desc' }>).reduce(
78+
(acc: string[], item) => {
79+
acc.push(`${item.order === 'desc' ? '-' : ''}${item.key}`);
80+
return acc; // Return the accumulator array, not push result
81+
},
82+
[]
83+
);
84+
}
6885
return ordering;
6986
}

tests/unit/helpers.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -119,30 +119,30 @@ describe('helpers.ts', () => {
119119
const element = ["ordering_field"];
120120
const returnValue = getSortsArrayFromOrdering(element);
121121

122-
expect(returnValue).toEqual({ sortBy: ["ordering_field"], sortDesc: [false] })
122+
expect(returnValue).toEqual({ sortBy: [{key: "ordering_field", order: "asc"}], sortDesc: [] })
123123
})
124124

125125
it("return correct VuetifySortArraysObject if negative ordering", () => {
126126
const element = ["-ordering_field"];
127127
const returnValue = getSortsArrayFromOrdering(element);
128128

129-
expect(returnValue).toEqual({ sortBy: ["ordering_field"], sortDesc: [true] })
129+
expect(returnValue).toEqual({ sortBy: [{key: "ordering_field", order: "desc"}], sortDesc: [] })
130130
})
131131
})
132132

133133
describe('getOrderingFromSortArray', () => {
134134

135135
it("return correct ordering if positive ordering", () => {
136-
const sortBy = ["ordering_field"];
137-
const sortDesc = [false];
136+
const sortBy: { key: string; order: 'asc' | 'desc'; }[] = [{key: "ordering_field", order: "asc"}];
137+
const sortDesc: boolean[] = [];
138138
const returnValue = getOrderingFromSortArray(sortBy, sortDesc);
139139

140140
expect(returnValue).toEqual(["ordering_field"])
141141
})
142142

143143
it("return correct ordering if negative ordering", () => {
144-
const sortBy = ["ordering_field"];
145-
const sortDesc = [true];
144+
const sortBy: { key: string; order: 'asc' | 'desc'; }[] = [{key: "ordering_field", order: "desc"}];
145+
const sortDesc: boolean[] = [];
146146
const returnValue = getOrderingFromSortArray(sortBy, sortDesc);
147147

148148
expect(returnValue).toEqual(["-ordering_field"])

vue3-example/.browserslistrc

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
> 1%
22
last 2 versions
33
not dead
4+
not ie 11

vue3-example/.editorconfig

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue}]
2+
charset = utf-8
3+
indent_size = 2
4+
indent_style = space
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true

vue3-example/.eslintrc.js

-21
This file was deleted.

vue3-example/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
node_modules
33
/dist
44

5-
65
# local env files
76
.env.local
87
.env.*.local

vue3-example/README.md

+74-17
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,81 @@
1-
# vue3-example
1+
# Vuetify (Default)
22

3-
## Project setup
4-
```
5-
npm install
6-
```
3+
This is the official scaffolding tool for Vuetify, designed to give you a head start in building your new Vuetify application. It sets up a base template with all the necessary configurations and standard directory structure, enabling you to begin development without the hassle of setting up the project from scratch.
74

8-
### Compiles and hot-reloads for development
9-
```
10-
npm run serve
11-
```
5+
## ❗️ Important Links
126

13-
### Compiles and minifies for production
14-
```
15-
npm run build
16-
```
7+
- 📄 [Docs](https://vuetifyjs.com/)
8+
- 🚨 [Issues](https://issues.vuetifyjs.com/)
9+
- 🏬 [Store](https://store.vuetifyjs.com/)
10+
- 🎮 [Playground](https://play.vuetifyjs.com/)
11+
- 💬 [Discord](https://community.vuetifyjs.com)
12+
13+
## 💿 Install
14+
15+
Set up your project using your preferred package manager. Use the corresponding command to install the dependencies:
16+
17+
| Package Manager | Command |
18+
|---------------------------------------------------------------|----------------|
19+
| [yarn](https://yarnpkg.com/getting-started) | `yarn install` |
20+
| [npm](https://docs.npmjs.com/cli/v7/commands/npm-install) | `npm install` |
21+
| [pnpm](https://pnpm.io/installation) | `pnpm install` |
22+
| [bun](https://bun.sh/#getting-started) | `bun install` |
23+
24+
After completing the installation, your environment is ready for Vuetify development.
25+
26+
## ✨ Features
27+
28+
- 🖼️ **Optimized Front-End Stack**: Leverage the latest Vue 3 and Vuetify 3 for a modern, reactive UI development experience. [Vue 3](https://v3.vuejs.org/) | [Vuetify 3](https://vuetifyjs.com/en/)
29+
- 🗃️ **State Management**: Integrated with [Pinia](https://pinia.vuejs.org/), the intuitive, modular state management solution for Vue.
30+
- 🚦 **Routing and Layouts**: Utilizes Vue Router for SPA navigation and vite-plugin-vue-layouts for organizing Vue file layouts. [Vue Router](https://router.vuejs.org/) | [vite-plugin-vue-layouts](https://github.com/JohnCampionJr/vite-plugin-vue-layouts)
31+
- 💻 **Enhanced Development Experience**: Benefit from TypeScript's static type checking and the ESLint plugin suite for Vue, ensuring code quality and consistency. [TypeScript](https://www.typescriptlang.org/) | [ESLint Plugin Vue](https://eslint.vuejs.org/)
32+
-**Next-Gen Tooling**: Powered by Vite, experience fast cold starts and instant HMR (Hot Module Replacement). [Vite](https://vitejs.dev/)
33+
- 🧩 **Automated Component Importing**: Streamline your workflow with unplugin-vue-components, automatically importing components as you use them. [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components)
34+
- 🛠️ **Strongly-Typed Vue**: Use vue-tsc for type-checking your Vue components, and enjoy a robust development experience. [vue-tsc](https://github.com/johnsoncodehk/volar/tree/master/packages/vue-tsc)
35+
36+
These features are curated to provide a seamless development experience from setup to deployment, ensuring that your Vuetify application is both powerful and maintainable.
37+
38+
## 💡 Usage
1739

18-
### Lints and fixes files
40+
This section covers how to start the development server and build your project for production.
41+
42+
### Starting the Development Server
43+
44+
To start the development server with hot-reload, run the following command. The server will be accessible at [http://localhost:3000](http://localhost:3000):
45+
46+
```bash
47+
yarn dev
1948
```
20-
npm run lint
49+
50+
(Repeat for npm, pnpm, and bun with respective commands.)
51+
52+
> Add NODE_OPTIONS='--no-warnings' to suppress the JSON import warnings that happen as part of the Vuetify import mapping. If you are on Node [v21.3.0](https://nodejs.org/en/blog/release/v21.3.0) or higher, you can change this to NODE_OPTIONS='--disable-warning=5401'. If you don't mind the warning, you can remove this from your package.json dev script.
53+
54+
### Building for Production
55+
56+
To build your project for production, use:
57+
58+
```bash
59+
yarn build
2160
```
2261

23-
### Customize configuration
24-
See [Configuration Reference](https://cli.vuejs.org/config/).
62+
(Repeat for npm, pnpm, and bun with respective commands.)
63+
64+
Once the build process is completed, your application will be ready for deployment in a production environment.
65+
66+
## 💪 Support Vuetify Development
67+
68+
This project is built with [Vuetify](https://vuetifyjs.com/en/), a UI Library with a comprehensive collection of Vue components. Vuetify is an MIT licensed Open Source project that has been made possible due to the generous contributions by our [sponsors and backers](https://vuetifyjs.com/introduction/sponsors-and-backers/). If you are interested in supporting this project, please consider:
69+
70+
- [Requesting Enterprise Support](https://support.vuetifyjs.com/)
71+
- [Sponsoring John on Github](https://github.com/users/johnleider/sponsorship)
72+
- [Sponsoring Kael on Github](https://github.com/users/kaelwd/sponsorship)
73+
- [Supporting the team on Open Collective](https://opencollective.com/vuetify)
74+
- [Becoming a sponsor on Patreon](https://www.patreon.com/vuetify)
75+
- [Becoming a subscriber on Tidelift](https://tidelift.com/subscription/npm/vuetify)
76+
- [Making a one-time donation with Paypal](https://paypal.me/vuetify)
77+
78+
## 📑 License
79+
[MIT](http://opensource.org/licenses/MIT)
80+
81+
Copyright (c) 2016-present Vuetify, LLC

vue3-example/babel.config.js

-5
This file was deleted.

vue3-example/components.d.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* eslint-disable */
2+
// @ts-nocheck
3+
// Generated by unplugin-vue-components
4+
// Read more: https://github.com/vuejs/core/pull/3399
5+
export {}
6+
7+
/* prettier-ignore */
8+
declare module 'vue' {
9+
export interface GlobalComponents {
10+
BaseOrdering: typeof import('./src/components/BaseOrdering.vue')['default']
11+
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
12+
RouterLink: typeof import('vue-router')['RouterLink']
13+
RouterView: typeof import('vue-router')['RouterView']
14+
SimpleDatatable: typeof import('./src/components/SimpleDatatable.vue')['default']
15+
VuetifyDatatable: typeof import('./src/components/VuetifyDatatable.vue')['default']
16+
}
17+
}

vue3-example/env.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="vite/client" />
2+
/// <reference types="unplugin-vue-router/client" />

vue3-example/eslint.config.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* .eslint.js
3+
*
4+
* ESLint configuration file.
5+
*/
6+
7+
import pluginVue from 'eslint-plugin-vue'
8+
import vueTsEslintConfig from '@vue/eslint-config-typescript'
9+
10+
export default [
11+
{
12+
name: 'app/files-to-lint',
13+
files: ['**/*.{ts,mts,tsx,vue}'],
14+
},
15+
16+
{
17+
name: 'app/files-to-ignore',
18+
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
19+
},
20+
21+
...pluginVue.configs['flat/recommended'],
22+
...vueTsEslintConfig(),
23+
24+
{
25+
rules: {
26+
"@typescript-eslint/no-explicit-any": "off",
27+
'@typescript-eslint/no-unused-expressions': [
28+
'error',
29+
{
30+
allowShortCircuit: true,
31+
allowTernary: true,
32+
},
33+
],
34+
'vue/multi-word-component-names': 'off',
35+
}
36+
}
37+
]

vue3-example/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<link rel="icon" href="/favicon.ico">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Welcome to Vuetify 3</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/main.ts"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)