Add app
2
.browserslistrc
Normal file
@@ -0,0 +1,2 @@
|
||||
> 1%
|
||||
last 2 versions
|
||||
9
.editorconfig
Normal file
@@ -0,0 +1,9 @@
|
||||
root=true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
46
.eslintrc.js
Normal file
@@ -0,0 +1,46 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
extends: [
|
||||
'plugin:vue/essential',
|
||||
'@vue/typescript/recommended',
|
||||
'@vue/prettier',
|
||||
'@vue/prettier/@typescript-eslint',
|
||||
],
|
||||
rules: {
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'prettier/prettier': ['error', { singleQuote: true }],
|
||||
'@typescript-eslint/camelcase': 0,
|
||||
'@typescript-eslint/no-use-before-define': 0,
|
||||
'@typescript-eslint/ban-ts-ignore': 0,
|
||||
'@typescript-eslint/no-explicit-any': 0,
|
||||
'comma-dangle': [
|
||||
'error',
|
||||
{
|
||||
arrays: 'always-multiline',
|
||||
exports: 'always-multiline',
|
||||
functions: 'never',
|
||||
imports: 'always-multiline',
|
||||
objects: 'always-multiline',
|
||||
},
|
||||
],
|
||||
},
|
||||
parserOptions: {
|
||||
parser: '@typescript-eslint/parser',
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['**/*.test.{js,ts}?(x)', '**/*.story.{js,ts}?(x)'],
|
||||
env: {
|
||||
jest: true,
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-empty-function': 0,
|
||||
'@typescript-eslint/no-non-null-assertion': 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
8
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: directus # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
custom: # Replace with a single custom sponsorship URL
|
||||
25
.github/issue_template.md
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
name: Issue Template
|
||||
about: General use template for all new issues
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
|
||||
Hi there!
|
||||
|
||||
Thanks for taking the time to notify the community of an issue or sharing your thoughts for a new feature.
|
||||
|
||||
Please be as detailed as possible so others know exactly what you're talking about.
|
||||
|
||||
For bugs, please include:
|
||||
• Version of Directus
|
||||
• Error message (if any)
|
||||
• Steps to reproduce
|
||||
|
||||
Thanks!
|
||||
|
||||
-->
|
||||
22
.gitignore
vendored
@@ -1,2 +1,22 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/dist
|
||||
storybook-static
|
||||
coverage
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Log files
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
.vscode
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
15
.jest/before-all.js
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
Object.defineProperty(window, 'matchMedia', {
|
||||
writable: true,
|
||||
value: jest.fn().mockImplementation(query => ({
|
||||
matches: false,
|
||||
media: query,
|
||||
onchange: null,
|
||||
addListener: jest.fn(), // deprecated
|
||||
removeListener: jest.fn(), // deprecated
|
||||
addEventListener: jest.fn(),
|
||||
removeEventListener: jest.fn(),
|
||||
dispatchEvent: jest.fn(),
|
||||
})),
|
||||
});
|
||||
|
||||
22
.jest/mount-composable.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import VueCompositionAPI from '@vue/composition-api';
|
||||
import { mount, createLocalVue } from '@vue/test-utils';
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(VueCompositionAPI);
|
||||
|
||||
export default function mountComposable(cb: () => any, mountOptions?: Parameters<typeof mount>[1]) {
|
||||
return mount(
|
||||
{
|
||||
setup() {
|
||||
return cb();
|
||||
},
|
||||
render(h) {
|
||||
return h('div');
|
||||
}
|
||||
},
|
||||
{
|
||||
localVue,
|
||||
...mountOptions
|
||||
}
|
||||
);
|
||||
};
|
||||
6
.prettierrc
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"htmlWhitespaceSensitivity": "ignore",
|
||||
"printWidth": 120,
|
||||
"singleQuote": true,
|
||||
"useTabs": true
|
||||
}
|
||||
5
.storybook/decorators/full-width.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default function fullWidth() {
|
||||
return {
|
||||
template: `<div style="max-width: 632px;"><story /></div>`,
|
||||
};
|
||||
}
|
||||
5
.storybook/decorators/half-width.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default function halfWidth() {
|
||||
return {
|
||||
template: `<div style="max-width: 300px;"><story /></div>`,
|
||||
};
|
||||
}
|
||||
5
.storybook/decorators/with-alt-colors.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default function withBackground() {
|
||||
return {
|
||||
template: `<div class="alt-colors" style="height: 100%; background-color: var(--background-color);"><story /></div>`
|
||||
}
|
||||
}
|
||||
5
.storybook/decorators/with-background.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default function withBackground() {
|
||||
return {
|
||||
template: `<div style="background-color: #dde3e6; height: 100%;"><story /></div>`
|
||||
}
|
||||
}
|
||||
5
.storybook/decorators/with-padding.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default function withPadding() {
|
||||
return {
|
||||
template: `<div style="padding: 24px; height: 100%;"><story /></div>`
|
||||
}
|
||||
}
|
||||
47
.storybook/main.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const path = require("path");
|
||||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
||||
|
||||
module.exports = {
|
||||
stories: ['../src/**/*.story.ts'],
|
||||
addons: [
|
||||
'@storybook/addon-notes/register',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-knobs',
|
||||
'@storybook/addon-viewport/register',
|
||||
'storybook-addon-themes'
|
||||
],
|
||||
webpackFinal: async (config, { configType }) => {
|
||||
config.resolve.alias = {
|
||||
...config.resolve.alias,
|
||||
'@': path.resolve(__dirname, '../src')
|
||||
};
|
||||
|
||||
config.module.rules.push({
|
||||
test: /\.scss$/,
|
||||
use: ['style-loader', 'css-loader', 'sass-loader'],
|
||||
include: path.resolve(__dirname, '../'),
|
||||
});
|
||||
|
||||
config.module.rules.push({
|
||||
test: /\.ts$/,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader'
|
||||
},
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
appendTsSuffixTo: [/\.vue$/],
|
||||
transpileOnly: true
|
||||
},
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
config.resolve.extensions.push('.ts', '.tsx');
|
||||
|
||||
// Return the altered config
|
||||
return config;
|
||||
}
|
||||
}
|
||||
11109
.storybook/mock-data/collections.json
Normal file
11527
.storybook/mock-data/fields.json
Normal file
228
.storybook/mock-data/relations.json
Normal file
@@ -0,0 +1,228 @@
|
||||
{
|
||||
"relations": [
|
||||
{
|
||||
"id": 15,
|
||||
"collection_many": "news",
|
||||
"field_many": "author",
|
||||
"collection_one": "staff",
|
||||
"field_one": "news",
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"collection_many": "interface_library",
|
||||
"field_many": "m2o",
|
||||
"collection_one": "news",
|
||||
"field_one": null,
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"collection_many": "interface_library_staff",
|
||||
"field_many": "interface_library_id",
|
||||
"collection_one": "interface_library",
|
||||
"field_one": "checkboxes_relational",
|
||||
"junction_field": "staff_id"
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"collection_many": "interface_library_staff",
|
||||
"field_many": "staff_id",
|
||||
"collection_one": "staff",
|
||||
"field_one": "interface_library",
|
||||
"junction_field": "interface_library_id"
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"collection_many": "interface_library_files",
|
||||
"field_many": "directus_files_id",
|
||||
"collection_one": "directus_files",
|
||||
"field_one": "interface_library",
|
||||
"junction_field": "interface_library_id"
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"collection_many": "interface_library_files",
|
||||
"field_many": "interface_library_id",
|
||||
"collection_one": "interface_library",
|
||||
"field_one": "files",
|
||||
"junction_field": "directus_files_id"
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"collection_many": "interface_library_news",
|
||||
"field_many": "interface_library_id",
|
||||
"collection_one": "interface_library",
|
||||
"field_one": "m2m",
|
||||
"junction_field": "news_id"
|
||||
},
|
||||
{
|
||||
"id": 22,
|
||||
"collection_many": "interface_library_news",
|
||||
"field_many": "news_id",
|
||||
"collection_one": "news",
|
||||
"field_one": "interface_library",
|
||||
"junction_field": "interface_library_id"
|
||||
},
|
||||
{
|
||||
"id": 23,
|
||||
"collection_many": "library_translations",
|
||||
"field_many": "library",
|
||||
"collection_one": "interface_library",
|
||||
"field_one": "translation",
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 24,
|
||||
"collection_many": "news",
|
||||
"field_many": "m2o",
|
||||
"collection_one": "interface_library",
|
||||
"field_one": "o2m",
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 25,
|
||||
"collection_many": "ticket_notes",
|
||||
"field_many": "ticket",
|
||||
"collection_one": "tickets",
|
||||
"field_one": "notes",
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 26,
|
||||
"collection_many": "customers",
|
||||
"field_many": "owner",
|
||||
"collection_one": "staff",
|
||||
"field_one": null,
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 27,
|
||||
"collection_many": "tickets",
|
||||
"field_many": "customer",
|
||||
"collection_one": "customers",
|
||||
"field_one": null,
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 28,
|
||||
"collection_many": "news_relations",
|
||||
"field_many": "news_id",
|
||||
"collection_one": "news",
|
||||
"field_one": "related_news",
|
||||
"junction_field": "related_id"
|
||||
},
|
||||
{
|
||||
"id": 29,
|
||||
"collection_many": "news_relations",
|
||||
"field_many": "related_id",
|
||||
"collection_one": "news",
|
||||
"field_one": "news",
|
||||
"junction_field": "news_id"
|
||||
},
|
||||
{
|
||||
"id": 53,
|
||||
"collection_many": "directus_activity",
|
||||
"field_many": "action_by",
|
||||
"collection_one": "directus_users",
|
||||
"field_one": null,
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 56,
|
||||
"collection_many": "directus_fields",
|
||||
"field_many": "collection",
|
||||
"collection_one": "directus_collections",
|
||||
"field_one": "fields",
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 57,
|
||||
"collection_many": "directus_files",
|
||||
"field_many": "uploaded_by",
|
||||
"collection_one": "directus_users",
|
||||
"field_one": null,
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 58,
|
||||
"collection_many": "directus_files",
|
||||
"field_many": "folder",
|
||||
"collection_one": "directus_folders",
|
||||
"field_one": null,
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 59,
|
||||
"collection_many": "directus_folders",
|
||||
"field_many": "parent_folder",
|
||||
"collection_one": "directus_folders",
|
||||
"field_one": null,
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 60,
|
||||
"collection_many": "directus_permissions",
|
||||
"field_many": "group",
|
||||
"collection_one": "directus_groups",
|
||||
"field_one": null,
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 61,
|
||||
"collection_many": "directus_revisions",
|
||||
"field_many": "activity",
|
||||
"collection_one": "directus_activity",
|
||||
"field_one": null,
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 62,
|
||||
"collection_many": "directus_users",
|
||||
"field_many": "role",
|
||||
"collection_one": "directus_roles",
|
||||
"field_one": "users",
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 63,
|
||||
"collection_many": "directus_users",
|
||||
"field_many": "avatar",
|
||||
"collection_one": "directus_files",
|
||||
"field_one": null,
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 64,
|
||||
"collection_many": "ticket_files",
|
||||
"field_many": "ticket",
|
||||
"collection_one": "tickets",
|
||||
"field_one": "attachments",
|
||||
"junction_field": "file"
|
||||
},
|
||||
{
|
||||
"id": 65,
|
||||
"collection_many": "ticket_files",
|
||||
"field_many": "file",
|
||||
"collection_one": "directus_files",
|
||||
"field_one": "tickets",
|
||||
"junction_field": "ticket"
|
||||
},
|
||||
{
|
||||
"id": 66,
|
||||
"collection_many": "directus_collection_presets",
|
||||
"field_many": "role",
|
||||
"collection_one": "directus_roles",
|
||||
"field_one": null,
|
||||
"junction_field": null
|
||||
},
|
||||
{
|
||||
"id": 67,
|
||||
"collection_many": "directus_collection_presets",
|
||||
"field_many": "user",
|
||||
"collection_one": "directus_users",
|
||||
"field_one": null,
|
||||
"junction_field": null
|
||||
}
|
||||
]
|
||||
}
|
||||
8
.storybook/preview-head.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<script defer>
|
||||
// This hack is needed to prevent Netlify from shouting at us for mixed http / https 🙄
|
||||
window.addEventListener('load', () => {
|
||||
const script = document.createElement('script');
|
||||
script.src = 'h' + 'tt' + 'p:' + '//localhost:8098';
|
||||
document.body.appendChild(script);
|
||||
});
|
||||
</script>
|
||||
24
.storybook/preview.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { addParameters } from '@storybook/vue';
|
||||
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';
|
||||
|
||||
import "../src/styles/main.scss";
|
||||
import "../src/plugins";
|
||||
import "../src/components/register";
|
||||
import "../src/directives/register";
|
||||
import "../src/interfaces/register";
|
||||
import "../src/displays/register";
|
||||
import "../src/views/register";
|
||||
import "../src/layouts/register";
|
||||
|
||||
addParameters({
|
||||
docs: {
|
||||
inlineStories: true
|
||||
},
|
||||
viewport: {
|
||||
viewports: INITIAL_VIEWPORTS
|
||||
},
|
||||
themes: [
|
||||
{ name: 'Light', class: ['private-view', 'light'], color: '#ffffff', default: true },
|
||||
{ name: 'Dark', class: ['private-view', 'dark'], color: '#263238' },
|
||||
]
|
||||
});
|
||||
39
.storybook/raw-value.vue
Normal file
@@ -0,0 +1,39 @@
|
||||
<template functional>
|
||||
<div class="raw-value">
|
||||
<div class="label">{{ props.label }}</div>
|
||||
<pre><slot /></pre>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from '@vue/composition-api';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
label: {
|
||||
type: String,
|
||||
default: 'Value:',
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.raw-value {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.label {
|
||||
margin-bottom: 4px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
pre {
|
||||
max-width: max-content;
|
||||
padding: 0.5rem;
|
||||
color: var(--foreground-normal);
|
||||
font-family: monospace;
|
||||
background-color: var(--background-subdued);
|
||||
border-radius: 8px;
|
||||
}
|
||||
</style>
|
||||
30
.stylelintrc.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"extends": [
|
||||
"stylelint-config-standard",
|
||||
"stylelint-config-rational-order",
|
||||
"stylelint-config-prettier"
|
||||
],
|
||||
"plugins": ["stylelint-order", "stylelint-scss"],
|
||||
"rules": {
|
||||
"indentation": "tab",
|
||||
"order/order": [
|
||||
"dollar-variables",
|
||||
"custom-properties",
|
||||
"declarations",
|
||||
"at-variables",
|
||||
"rules",
|
||||
"at-rules"
|
||||
],
|
||||
"at-rule-no-unknown": null,
|
||||
"scss/at-rule-no-unknown": true,
|
||||
"selector-pseudo-element-no-unknown": [
|
||||
true,
|
||||
{
|
||||
"ignorePseudoElements": ["v-deep"]
|
||||
}
|
||||
],
|
||||
"string-quotes": "single",
|
||||
"length-zero-no-unit": null,
|
||||
"no-descending-specificity": true
|
||||
}
|
||||
}
|
||||
76
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at info@directus.io. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
8
CONTRIBUTING.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Contributing
|
||||
|
||||
When contributing to this repository, please first discuss the change you wish to make via issue,
|
||||
email, or any other method with the owners of this repository before making a change.
|
||||
|
||||
Please note we have a [code of conduct](./CODE_OF_CONDUCT.md), please follow it in all your interactions with the project.
|
||||
|
||||
Learn more about contributing to the platform: https://docs.directus.io/getting-started/contributing.html#repositories
|
||||
674
LICENSE.md
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
57
README.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# app-next
|
||||
|
||||
[](https://coveralls.io/github/directus/app-next?branch=master)
|
||||
|
||||
|
||||
## Status: alpha
|
||||
|
||||
We're aiming to have the app codebase converted to TypeScript and fully unit test covered. This repo serves as a way for us to work on the bigger more foundational parts of the app codebase, without interferance of the legacy parts.
|
||||
|
||||
New components introduced in this repo will land in the current codebase where applicable. Bugfixes will continue to happen on the current codebase, until this version is fully done and merged.
|
||||
|
||||
**This version is in no way shape or form intended to be used in production environments.**
|
||||
|
||||
Once this codebase is complete enough to be used as main front-end, it will be moved to a branch on the main directus/app repo at which point it will be released as an beta / RC until confirmed ready.
|
||||
|
||||
## Goals
|
||||
|
||||
* Have everything in TypeScript
|
||||
* Have full test coverage
|
||||
* Have as much of the components in Storybook as possible
|
||||
* Rely on global state the least amount possible
|
||||
|
||||
## Contributing
|
||||
|
||||
If you want to help out in the new version, please open an issue to discuss what you would like to do _before_ opening a pull request. This makes sure we don't do overlapping work or work on something that's not intended to be in the app.
|
||||
|
||||
## Development
|
||||
|
||||
You need Node.js v10+ and Yarn.
|
||||
|
||||
After cloning the repo, run:
|
||||
|
||||
```
|
||||
$ yarn # install all dependencies of the project
|
||||
```
|
||||
|
||||
### Scripts
|
||||
|
||||
#### `yarn serve`
|
||||
|
||||
Bundles the app in dev mode and watches for changes.
|
||||
|
||||
Combine this with the `API_URL` environment variable to point it to a running API instance to debug fully:
|
||||
|
||||
```
|
||||
$ API_URL=https://local.api.com yarn serve
|
||||
```
|
||||
|
||||
#### `yarn storybook`
|
||||
|
||||
Fires up an instance of Storybook and watches for changes. Very useful to develop individual components in isolation.
|
||||
|
||||
#### `yarn test`
|
||||
|
||||
Runs all Jest tests in the app. Add the `--coverage` flag to see a print of what test coverage you've achieved.
|
||||
|
||||
Please aim for 100% coverage for newly added code.
|
||||
12
babel.config.js
Normal file
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
[
|
||||
'@vue/app',
|
||||
{
|
||||
targets: { esmodules: true },
|
||||
polyfills: [],
|
||||
},
|
||||
],
|
||||
],
|
||||
plugins: ['@babel/plugin-proposal-optional-chaining'],
|
||||
};
|
||||
5
crowdin.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
files:
|
||||
- source: /src/lang/en-US/*.json
|
||||
ignore:
|
||||
- /src/lang/en-US/date-format.json
|
||||
translation: /src/lang/%locale%/%original_file_name%
|
||||
22
jest.config.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const esModules = ['@popperjs/core'].join('|');
|
||||
|
||||
module.exports = {
|
||||
preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel',
|
||||
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
|
||||
coveragePathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/.jest/'],
|
||||
transformIgnorePatterns: [`/node_modules/(?!${esModules})`],
|
||||
setupFilesAfterEnv: ['<rootDir>/.jest/before-all.js'],
|
||||
restoreMocks: true,
|
||||
clearMocks: true,
|
||||
resetMocks: true,
|
||||
reporters: [
|
||||
'default',
|
||||
[
|
||||
'jest-sonar',
|
||||
{
|
||||
outputDirectory: 'coverage',
|
||||
outputName: 'sonar.xml',
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
24278
package-lock.json
generated
Normal file
140
package.json
Normal file
@@ -0,0 +1,140 @@
|
||||
{
|
||||
"name": "directus",
|
||||
"version": "9.0.0-alpha.3",
|
||||
"private": true,
|
||||
"description": "Directus is an Open-Source Headless CMS & API for Managing Custom Databases",
|
||||
"author": "Rijk van Zanten <rijk@rngr.org>",
|
||||
"scripts": {
|
||||
"dev": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"test": "vue-cli-service test:unit",
|
||||
"lint": "vue-cli-service lint",
|
||||
"lint:styles": "stylelint \"**/*.{vue,scss}\"",
|
||||
"fix": "prettier --write \"src/**/*.{js,vue,ts}\"",
|
||||
"fix:styles": "stylelint --fix \"**/*.{vue,scss}\"",
|
||||
"storybook": "start-storybook -p 6006",
|
||||
"build-storybook": "build-storybook"
|
||||
},
|
||||
"dependencies": {
|
||||
"@directus/format-title": "3.2.0",
|
||||
"@popperjs/core": "2.4.3",
|
||||
"@sindresorhus/slugify": "1.0.0",
|
||||
"@tinymce/tinymce-vue": "3.2.2",
|
||||
"@types/codemirror": "0.0.97",
|
||||
"@types/debug": "4.1.5",
|
||||
"@types/htmlhint": "0.9.1",
|
||||
"@types/js-yaml": "3.12.5",
|
||||
"@types/lodash": "4.14.158",
|
||||
"@types/mousetrap": "1.6.3",
|
||||
"@vue/composition-api": "0.6.7",
|
||||
"axios": "0.19.2",
|
||||
"base-64": "0.1.0",
|
||||
"bytes": "3.1.0",
|
||||
"codemirror": "5.56.0",
|
||||
"cropperjs": "1.5.7",
|
||||
"csslint": "1.0.5",
|
||||
"date-fns": "2.14.0",
|
||||
"diff": "4.0.2",
|
||||
"htmlhint": "0.14.1",
|
||||
"js-yaml": "3.14.0",
|
||||
"jshint": "2.11.1",
|
||||
"jsonlint": "1.6.3",
|
||||
"jsonlint-mod": "1.7.5",
|
||||
"lodash": "4.17.19",
|
||||
"marked": "1.1.1",
|
||||
"micromustache": "7.1.0",
|
||||
"mime-types": "2.1.27",
|
||||
"mousetrap": "1.6.5",
|
||||
"nanoid": "3.1.10",
|
||||
"pinia": "0.0.7",
|
||||
"portal-vue": "2.1.7",
|
||||
"resize-observer": "1.0.0",
|
||||
"semver": "7.3.2",
|
||||
"stylelint-config-prettier": "8.0.2",
|
||||
"tinymce": "5.4.1",
|
||||
"vue": "2.6.11",
|
||||
"vue-i18n": "8.18.2",
|
||||
"vue-router": "3.3.4",
|
||||
"vuedraggable": "2.23.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.10.5",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.10.4",
|
||||
"@storybook/addon-actions": "^5.3.19",
|
||||
"@storybook/addon-centered": "^5.3.19",
|
||||
"@storybook/addon-knobs": "^5.3.19",
|
||||
"@storybook/addon-links": "^5.3.19",
|
||||
"@storybook/addon-notes": "^5.3.19",
|
||||
"@storybook/addon-viewport": "^5.3.19",
|
||||
"@storybook/addons": "^5.3.19",
|
||||
"@storybook/core": "^5.3.19",
|
||||
"@storybook/vue": "^5.3.19",
|
||||
"@types/base-64": "^0.1.3",
|
||||
"@types/bytes": "^3.1.0",
|
||||
"@types/diff": "^4.0.2",
|
||||
"@types/jest": "^26.0.5",
|
||||
"@types/marked": "^1.1.0",
|
||||
"@types/mime-types": "^2.1.0",
|
||||
"@types/semver": "^7.3.1",
|
||||
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
||||
"@typescript-eslint/parser": "^2.34.0",
|
||||
"@typescript-eslint/typescript-estree": "^3.7.0",
|
||||
"@vue/cli-plugin-babel": "^4.4.6",
|
||||
"@vue/cli-plugin-eslint": "^4.4.6",
|
||||
"@vue/cli-plugin-router": "^4.4.5",
|
||||
"@vue/cli-plugin-typescript": "^4.4.6",
|
||||
"@vue/cli-plugin-unit-jest": "^4.4.6",
|
||||
"@vue/cli-plugin-vuex": "^4.4.6",
|
||||
"@vue/cli-service": "^4.4.6",
|
||||
"@vue/eslint-config-prettier": "^6.0.0",
|
||||
"@vue/eslint-config-typescript": "^5.0.2",
|
||||
"@vue/test-utils": "^1.0.3",
|
||||
"autoprefixer": "^9.8.5",
|
||||
"babel-loader": "^8.1.0",
|
||||
"babel-preset-vue": "^2.0.2",
|
||||
"css-loader": "^3.6.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-plugin-prettier": "^3.1.4",
|
||||
"eslint-plugin-vue": "^6.2.2",
|
||||
"html-loader": "^1.1.0",
|
||||
"jest-sonar": "^0.2.10",
|
||||
"lint-staged": "^10.2.11",
|
||||
"mockdate": "^3.0.2",
|
||||
"prettier": "^2.0.5",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
"react-is": "^16.13.1",
|
||||
"regenerator-runtime": "^0.13.7",
|
||||
"sass": "^1.26.10",
|
||||
"sass-loader": "^9.0.2",
|
||||
"storybook-addon-themes": "^5.4.1",
|
||||
"stylelint": "^13.6.1",
|
||||
"stylelint-config-rational-order": "^0.1.2",
|
||||
"stylelint-config-standard": "^20.0.0",
|
||||
"stylelint-order": "^4.1.0",
|
||||
"stylelint-scss": "^3.18.0",
|
||||
"typescript": "^3.9.7",
|
||||
"vue-cli-plugin-storybook": "^1.3.0",
|
||||
"vue-loader": "^15.9.3",
|
||||
"vue-template-compiler": "^2.6.10",
|
||||
"vuepress": "^1.5.2",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-assets-manifest": "^3.1.1",
|
||||
"webpack-merge": "^5.0.9"
|
||||
},
|
||||
"gitHooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,ts}": [
|
||||
"vue-cli-service lint"
|
||||
],
|
||||
"*.{css,scss}": [
|
||||
"stylelint --fix"
|
||||
],
|
||||
"*.vue": [
|
||||
"vue-cli-service lint",
|
||||
"stylelint --fix"
|
||||
]
|
||||
}
|
||||
}
|
||||
3
postcss.config.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
plugins: [require('autoprefixer')],
|
||||
};
|
||||
12
public/.htaccess
Normal file
@@ -0,0 +1,12 @@
|
||||
<ifModule mod_rewrite.c>
|
||||
|
||||
RewriteEngine on
|
||||
|
||||
# If file or directory exists behave normally
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
|
||||
# Otherwise use index.html (you might need to update path)
|
||||
RewriteRule ^.*$ /index.html [L,QSA]
|
||||
|
||||
</ifModule>
|
||||
BIN
public/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
public/img/icons/android-chrome-192x192.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
public/img/icons/android-chrome-512x512.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
public/img/icons/apple-touch-icon-152x152.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
public/img/icons/apple-touch-icon.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
9
public/img/icons/browserconfig.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<browserconfig>
|
||||
<msapplication>
|
||||
<tile>
|
||||
<square150x150logo src="/mstile-150x150.png"/>
|
||||
<TileColor>#263238</TileColor>
|
||||
</tile>
|
||||
</msapplication>
|
||||
</browserconfig>
|
||||
BIN
public/img/icons/favicon-16x16.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/img/icons/favicon-32x32.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
public/img/icons/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
public/img/icons/mstile-150x150.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
41
public/img/icons/safari-pinned-tab.svg
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="620.000000pt" height="620.000000pt" viewBox="0 0 620.000000 620.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
<metadata>
|
||||
Created by potrace 1.11, written by Peter Selinger 2001-2013
|
||||
</metadata>
|
||||
<g transform="translate(0.000000,620.000000) scale(0.100000,-0.100000)"
|
||||
fill="#000000" stroke="none">
|
||||
<path d="M2935 4909 c-38 -4 -90 -10 -115 -13 -83 -8 -150 -19 -150 -23 0 -10
|
||||
88 -134 134 -188 94 -110 218 -214 332 -276 41 -23 74 -43 74 -45 0 -10 -107
|
||||
8 -175 28 -73 21 -150 57 -199 91 -29 20 -30 20 -80 3 -28 -10 -80 -32 -116
|
||||
-48 l-65 -30 46 -42 c92 -83 257 -181 399 -235 194 -74 455 -95 675 -56 155
|
||||
29 350 110 478 201 49 35 66 43 50 22 -21 -26 -72 -217 -97 -364 -10 -57 -57
|
||||
-188 -88 -247 -54 -100 -153 -182 -245 -203 -45 -10 -191 -13 -226 -4 -18 4
|
||||
-57 13 -87 19 -30 7 -113 32 -185 56 -134 45 -289 93 -325 101 -110 24 -141
|
||||
30 -250 49 -47 7 -105 17 -130 20 -25 3 -61 7 -80 10 -19 2 -60 7 -90 10 -52
|
||||
6 -174 21 -250 31 -97 13 -254 60 -337 99 -127 62 -226 143 -327 267 l-38 48
|
||||
-30 -21 c-151 -108 -210 -296 -147 -466 31 -81 69 -131 141 -187 l33 -25 33
|
||||
39 c36 44 78 66 135 73 20 3 37 4 37 2 0 -1 -17 -14 -37 -27 -67 -45 -113 -99
|
||||
-153 -184 -22 -45 -40 -87 -40 -93 0 -5 -13 -52 -29 -103 -16 -51 -43 -151
|
||||
-60 -223 -48 -205 -85 -282 -167 -355 -64 -56 -222 -118 -302 -120 -13 0 -46
|
||||
-10 -73 -21 -72 -31 -101 -80 -170 -284 -87 -261 -139 -353 -295 -530 -58 -66
|
||||
-93 -103 -201 -216 l-45 -46 34 -32 c154 -148 332 -113 548 108 47 48 94 98
|
||||
105 112 10 13 75 95 143 181 122 157 184 219 232 233 14 4 30 11 35 15 19 15
|
||||
149 51 235 66 47 8 99 17 115 20 325 57 506 129 651 261 149 136 187 333 102
|
||||
532 -29 67 -14 61 36 -17 64 -98 82 -148 111 -307 4 -18 13 -20 84 -22 159 -3
|
||||
291 -52 719 -268 158 -79 323 -158 367 -176 94 -37 285 -91 285 -80 0 4 -11
|
||||
21 -25 37 -39 45 -131 242 -123 264 1 3 -3 14 -9 25 -15 28 -38 243 -25 230 2
|
||||
-2 16 -39 31 -82 47 -141 156 -289 287 -390 94 -72 245 -136 379 -161 17 -3
|
||||
80 -5 140 -6 121 0 215 16 372 65 199 61 302 72 421 44 126 -30 180 -67 323
|
||||
-222 124 -134 302 -133 405 2 l26 35 -30 65 c-104 222 -274 387 -513 499 -131
|
||||
61 -250 98 -494 152 -120 26 -227 55 -249 67 l-39 22 3 140 c3 233 13 314 50
|
||||
399 52 122 141 166 365 181 146 9 219 27 334 83 101 50 193 155 221 253 9 30
|
||||
5 35 -168 207 -187 187 -200 198 -377 332 -196 148 -460 296 -700 393 -103 42
|
||||
-335 122 -380 131 -11 3 -67 16 -125 30 -58 14 -146 32 -195 41 -50 8 -100 17
|
||||
-110 19 -11 2 -51 7 -90 11 -38 4 -79 10 -90 12 -36 8 -508 10 -580 2z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
19
public/img/icons/site.webmanifest
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "Directus",
|
||||
"short_name": "Directus",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/android-chrome-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/android-chrome-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
],
|
||||
"theme_color": "#263238",
|
||||
"background_color": "#263238",
|
||||
"display": "standalone"
|
||||
}
|
||||
18
public/index.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
||||
<link rel="shortcut icon" href="/favicon.ico">
|
||||
<link rel="manifest" href="/manifest.webmanifest" />
|
||||
<title>Directus</title>
|
||||
</head>
|
||||
<body class="auto">
|
||||
<noscript>
|
||||
<strong>We're sorry but Directus doesn't work without JavaScript enabled. Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
</body>
|
||||
</html>
|
||||
20
public/manifest.webmanifest
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "Directus",
|
||||
"short_name": "Directus",
|
||||
"icons": [
|
||||
{
|
||||
"src": "img/icons/android-chrome-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "img/icons/android-chrome-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
],
|
||||
"theme_color": "#263238",
|
||||
"background_color": "#263238",
|
||||
"display": "standalone",
|
||||
"start_url": "."
|
||||
}
|
||||
72
src/api.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
|
||||
import { useRequestsStore } from '@/stores/requests';
|
||||
import { LogoutReason, logout, refresh } from '@/auth';
|
||||
import getRootPath from '@/utils/get-root-path';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: getRootPath(),
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
interface RequestConfig extends AxiosRequestConfig {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface Response extends AxiosResponse {
|
||||
config: RequestConfig;
|
||||
}
|
||||
|
||||
export interface RequestError extends AxiosError {
|
||||
response: Response;
|
||||
}
|
||||
|
||||
export const onRequest = (config: AxiosRequestConfig) => {
|
||||
const requestsStore = useRequestsStore();
|
||||
const id = requestsStore.startRequest();
|
||||
|
||||
const requestConfig: RequestConfig = {
|
||||
id: id,
|
||||
...config,
|
||||
};
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export const onResponse = (response: AxiosResponse | Response) => {
|
||||
const requestsStore = useRequestsStore();
|
||||
const id = (response.config as RequestConfig).id;
|
||||
requestsStore.endRequest(id);
|
||||
return response;
|
||||
};
|
||||
|
||||
export const onError = async (error: RequestError) => {
|
||||
const requestsStore = useRequestsStore();
|
||||
const id = (error.response.config as RequestConfig).id;
|
||||
requestsStore.endRequest(id);
|
||||
|
||||
// If a request fails with the unauthorized error, it either means that your user doesn't have
|
||||
// access, or that your session doesn't exist / has expired.
|
||||
// In case of the second, we should force the app to logout completely and redirect to the login
|
||||
// view.
|
||||
/* istanbul ignore next */
|
||||
const status = error.response?.status;
|
||||
/* istanbul ignore next */
|
||||
const code = error.response?.data?.error?.code;
|
||||
|
||||
if (status === 401 && code === 'INVALID_CREDENTIALS' && error.response?.config?.url !== '/auth/refresh') {
|
||||
try {
|
||||
await refresh();
|
||||
|
||||
/** @todo retry failed request after successful refresh */
|
||||
} catch {
|
||||
logout({ reason: LogoutReason.ERROR_SESSION_EXPIRED });
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
};
|
||||
|
||||
api.interceptors.request.use(onRequest);
|
||||
api.interceptors.response.use(onResponse, onError);
|
||||
|
||||
export default api;
|
||||
117
src/app.vue
Normal file
@@ -0,0 +1,117 @@
|
||||
<template>
|
||||
<div id="app" :style="brandStyle">
|
||||
<transition name="fade">
|
||||
<div class="hydrating" v-if="hydrating">
|
||||
<v-progress-circular indeterminate />
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<router-view v-if="!hydrating && appAccess" />
|
||||
|
||||
<v-info v-else-if="appAccess === false" center :title="$t('no_app_access')" type="danger" icon="block">
|
||||
{{ $t('no_app_access_copy') }}
|
||||
|
||||
<template #append>
|
||||
<v-button to="/logout">Switch User</v-button>
|
||||
</template>
|
||||
</v-info>
|
||||
|
||||
<portal-target name="outlet" multiple />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, toRefs, watch, computed } from '@vue/composition-api';
|
||||
import { useAppStore } from '@/stores/app';
|
||||
import { useUserStore } from '@/stores/user';
|
||||
import { useSettingsStore } from '@/stores/settings';
|
||||
|
||||
import useWindowSize from '@/composables/use-window-size';
|
||||
import setFavicon from '@/utils/set-favicon';
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
const appStore = useAppStore();
|
||||
const userStore = useUserStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
|
||||
const { hydrating, drawerOpen } = toRefs(appStore.state);
|
||||
|
||||
const brandStyle = computed(() => {
|
||||
return {
|
||||
'--brand': settingsStore.state.settings?.project_color || 'var(--primary)',
|
||||
};
|
||||
});
|
||||
|
||||
watch(() => settingsStore.state.settings?.project_color, setFavicon);
|
||||
|
||||
const { width } = useWindowSize();
|
||||
|
||||
watch(
|
||||
width,
|
||||
(newWidth, oldWidth) => {
|
||||
if (newWidth === null || newWidth === 0) return;
|
||||
if (newWidth === oldWidth) return;
|
||||
|
||||
if (newWidth >= 1424) {
|
||||
if (drawerOpen.value === false) drawerOpen.value = true;
|
||||
} else {
|
||||
if (drawerOpen.value === true) drawerOpen.value = false;
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => userStore.state.currentUser,
|
||||
(newUser) => {
|
||||
document.body.classList.remove('dark');
|
||||
document.body.classList.remove('light');
|
||||
document.body.classList.remove('auto');
|
||||
|
||||
if (newUser !== undefined && newUser !== null) {
|
||||
document.body.classList.add(newUser.theme);
|
||||
} else {
|
||||
// Default to light mode
|
||||
document.body.classList.add('light');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const appAccess = computed(() => {
|
||||
if (!userStore.state.currentUser) return true;
|
||||
return userStore.state.currentUser?.role?.app_access;
|
||||
});
|
||||
|
||||
return { hydrating, brandStyle, appAccess };
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
#app {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.hydrating {
|
||||
position: fixed;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity var(--medium) var(--transition);
|
||||
}
|
||||
|
||||
.fade-enter,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
8
src/assets/avatar-placeholder.svg
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<path fill="#ECEFF1" d="M0 0h64v64H0z"/>
|
||||
<path d="M32 32c4.42 0 8-3.58 8-8s-3.58-8-8-8-8 3.58-8 8 3.58 8 8 8zm0 4c-5.34 0-16 2.68-16 8v4h32v-4c0-5.32-10.66-8-16-8z" fill="#B0BEC5" fill-rule="nonzero"/>
|
||||
<path d="M8 8h48v48H8z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 392 B |
BIN
src/assets/fonts/FiraCode-Regular.woff
Normal file
BIN
src/assets/fonts/FiraCode-Regular.woff2
Normal file
BIN
src/assets/fonts/Inter-Medium.woff
Normal file
BIN
src/assets/fonts/Inter-Medium.woff2
Normal file
BIN
src/assets/fonts/Inter-MediumItalic.woff
Normal file
BIN
src/assets/fonts/Inter-MediumItalic.woff2
Normal file
BIN
src/assets/fonts/Inter-Regular.woff
Normal file
BIN
src/assets/fonts/Inter-Regular.woff2
Normal file
BIN
src/assets/fonts/Inter-SemiBold.woff
Normal file
BIN
src/assets/fonts/Inter-SemiBold.woff2
Normal file
BIN
src/assets/fonts/material-icons-outline.woff2
Normal file
BIN
src/assets/fonts/material-icons.woff2
Normal file
BIN
src/assets/fonts/merriweather-bold.woff
Normal file
BIN
src/assets/fonts/merriweather-bold.woff2
Normal file
BIN
src/assets/fonts/merriweather-italic.woff
Normal file
BIN
src/assets/fonts/merriweather-italic.woff2
Normal file
BIN
src/assets/fonts/merriweather-light.woff
Normal file
BIN
src/assets/fonts/merriweather-light.woff2
Normal file
BIN
src/assets/fonts/merriweather-regular.woff
Normal file
BIN
src/assets/fonts/merriweather-regular.woff2
Normal file
3
src/assets/logo-dark.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="39">
|
||||
<path fill="#263238" fill-rule="evenodd" d="M51.166 24.51a4.636 4.636 0 0 1-.763-.246 1.751 1.751 0 0 1-.54-.368c.147-1.304 0-2.435.122-3.713.492-4.967 3.615-3.393 6.418-4.204 1.745-.492 3.491-1.5 3.934-3.566a36.074 36.074 0 0 0-6.393-5.876C46.347 1.128 36.414-1.036 27.39.464a13.635 13.635 0 0 0 5.968 5.532s-2.445 0-4.541-1.565c-.615.245-1.845.73-2.435 1.024 4.794 4.598 12.293 5.114 17.678.984-.025.049-.492.762-1.057 3.737-1.254 6.343-4.869 5.852-9.343 4.254-9.294-3.369-14.408-.246-19.055-6.639a4.29 4.29 0 0 0-2.189 3.737c0 1.598.886 2.95 2.164 3.688.698-.926 1.011-1.189 2.228-1.189-1.883 1.068-2.105 2-2.916 4.582-.984 3.123-.566 6.32-5.164 7.155-2.434.123-2.385 1.77-3.27 4.23C4.352 33.188 2.877 34.467 0 37.491c1.18 1.426 2.41 1.598 3.663 1.082 2.582-1.082 4.574-4.426 6.442-6.59 2.09-2.409 7.106-1.376 10.892-3.737 2.607-1.598 3.885-3.761 2.164-7.425a7.254 7.254 0 0 1 1.869 4.426c4.376-.566 10.228 4.77 15.563 5.655a9.53 9.53 0 0 1-1.303-2.188c-.615-1.476-.811-2.828-.688-4.008.491 2.926 3.442 6.688 8.187 7.032 1.205.098 2.533-.05 3.91-.467 1.647-.492 3.171-1.131 4.99-.787 1.353.246 2.607.934 3.394 2.09 1.18 1.72 3.761 2.09 4.917-.025-2.606-6.81-9.786-7.253-12.834-8.04z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
3
src/assets/logo.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="39">
|
||||
<path fill="#FFF" fill-rule="evenodd" d="M51.166 24.51a4.636 4.636 0 0 1-.763-.246 1.751 1.751 0 0 1-.54-.368c.147-1.304 0-2.435.122-3.713.492-4.967 3.615-3.393 6.418-4.204 1.745-.492 3.491-1.5 3.934-3.566a36.074 36.074 0 0 0-6.393-5.876C46.347 1.128 36.414-1.036 27.39.464a13.635 13.635 0 0 0 5.968 5.532s-2.445 0-4.541-1.565c-.615.245-1.845.73-2.435 1.024 4.794 4.598 12.293 5.114 17.678.984-.025.049-.492.762-1.057 3.737-1.254 6.343-4.869 5.852-9.343 4.254-9.294-3.369-14.408-.246-19.055-6.639a4.29 4.29 0 0 0-2.189 3.737c0 1.598.886 2.95 2.164 3.688.698-.926 1.011-1.189 2.228-1.189-1.883 1.068-2.105 2-2.916 4.582-.984 3.123-.566 6.32-5.164 7.155-2.434.123-2.385 1.77-3.27 4.23C4.352 33.188 2.877 34.467 0 37.491c1.18 1.426 2.41 1.598 3.663 1.082 2.582-1.082 4.574-4.426 6.442-6.59 2.09-2.409 7.106-1.376 10.892-3.737 2.607-1.598 3.885-3.761 2.164-7.425a7.254 7.254 0 0 1 1.869 4.426c4.376-.566 10.228 4.77 15.563 5.655a9.53 9.53 0 0 1-1.303-2.188c-.615-1.476-.811-2.828-.688-4.008.491 2.926 3.442 6.688 8.187 7.032 1.205.098 2.533-.05 3.91-.467 1.647-.492 3.171-1.131 4.99-.787 1.353.246 2.607.934 3.394 2.09 1.18 1.72 3.761 2.09 4.917-.025-2.606-6.81-9.786-7.253-12.834-8.04z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
3
src/assets/readme.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Assets
|
||||
|
||||
Static assets that are used in the app. Primarily used for logos and fonts.
|
||||
94
src/auth.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
import { RawLocation } from 'vue-router';
|
||||
import api from '@/api';
|
||||
import { hydrate, dehydrate } from '@/hydrate';
|
||||
import router from '@/router';
|
||||
import useAppStore from '@/stores/app';
|
||||
|
||||
export type LoginCredentials = {
|
||||
email: string;
|
||||
password: string;
|
||||
};
|
||||
|
||||
export async function login(credentials: LoginCredentials) {
|
||||
const appStore = useAppStore();
|
||||
|
||||
const response = await api.post(`/auth/login`, {
|
||||
...credentials,
|
||||
mode: 'cookie',
|
||||
});
|
||||
|
||||
const accessToken = response.data.data.access_token;
|
||||
|
||||
// Add the header to the API handler for every request
|
||||
api.defaults.headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
|
||||
// Refresh the token 10 seconds before the access token expires. This means the user will stay
|
||||
// logged in without any noticable hickups or delays
|
||||
setTimeout(() => refresh(), response.data.data.expires * 1000 + 10 * 1000);
|
||||
|
||||
appStore.state.authenticated = true;
|
||||
|
||||
await hydrate();
|
||||
}
|
||||
|
||||
export async function refresh({ navigate }: LogoutOptions = { navigate: true }) {
|
||||
const appStore = useAppStore();
|
||||
|
||||
try {
|
||||
const response = await api.post('/auth/refresh');
|
||||
|
||||
const accessToken = response.data.data.access_token;
|
||||
|
||||
// Add the header to the API handler for every request
|
||||
api.defaults.headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
|
||||
// Refresh the token 10 seconds before the access token expires. This means the user will stay
|
||||
// logged in without any noticable hickups or delays
|
||||
setTimeout(() => refresh(), response.data.data.expires * 1000 - 10 * 1000);
|
||||
appStore.state.authenticated = true;
|
||||
} catch (error) {
|
||||
await logout({ navigate, reason: LogoutReason.ERROR_SESSION_EXPIRED });
|
||||
}
|
||||
}
|
||||
|
||||
export enum LogoutReason {
|
||||
SIGN_OUT = 'SIGN_OUT',
|
||||
ERROR_SESSION_EXPIRED = 'ERROR_SESSION_EXPIRED',
|
||||
}
|
||||
|
||||
export type LogoutOptions = {
|
||||
navigate?: boolean;
|
||||
reason?: LogoutReason;
|
||||
};
|
||||
|
||||
/**
|
||||
* Everything that should happen when someone logs out, or is logged out through an external factor
|
||||
*/
|
||||
export async function logout(optionsRaw: LogoutOptions = {}) {
|
||||
const appStore = useAppStore();
|
||||
|
||||
const defaultOptions: Required<LogoutOptions> = {
|
||||
navigate: true,
|
||||
reason: LogoutReason.SIGN_OUT,
|
||||
};
|
||||
|
||||
const options = { ...defaultOptions, ...optionsRaw };
|
||||
|
||||
// Only if the user manually signed out should we kill the session by hitting the logout endpoint
|
||||
if (options.reason === LogoutReason.SIGN_OUT) {
|
||||
await api.post(`/auth/logout`);
|
||||
}
|
||||
|
||||
appStore.state.authenticated = false;
|
||||
|
||||
await dehydrate();
|
||||
|
||||
if (options.navigate === true) {
|
||||
const location: RawLocation = {
|
||||
path: `/login`,
|
||||
query: { reason: options.reason },
|
||||
};
|
||||
|
||||
router.push(location);
|
||||
}
|
||||
}
|
||||
19
src/components/readme.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Components
|
||||
|
||||
Components are custom elements that can reused in various other places.
|
||||
|
||||
## Storybook / Tests
|
||||
|
||||
Every component should have an entry in Storybook, and should have unit tests where appropriate.
|
||||
|
||||
## Naming
|
||||
|
||||
Components must always have a `-` in the name. This makes sure we don't run into any conflicts with HTML element names.
|
||||
|
||||
## Base Components
|
||||
|
||||
The core-most base-components are prefixed with `v-` (for example `v-icon` and `v-button`). These components can not rely on any global store.
|
||||
|
||||
## Private Components
|
||||
|
||||
Every now and again, it makes sense to split up a bigger component in smaller sub-parts for code maintainability and organization reasons. These "internal private components" are prefixed with a `_` and should never be used standalone.
|
||||
116
src/components/register.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import Vue from 'vue';
|
||||
|
||||
import VAvatar from './v-avatar/';
|
||||
import VBadge from './v-badge/';
|
||||
import VBreadcrumb from './v-breadcrumb';
|
||||
import VButton from './v-button/';
|
||||
import VCard, { VCardActions, VCardTitle, VCardSubtitle, VCardText } from './v-card';
|
||||
import VCheckbox from './v-checkbox/';
|
||||
import VChip from './v-chip/';
|
||||
import VDetail from './v-detail';
|
||||
import VDialog from './v-dialog';
|
||||
import VDivider from './v-divider';
|
||||
import VError from './v-error';
|
||||
import VFancySelect from './v-fancy-select';
|
||||
import VFieldTemplate from './v-field-template';
|
||||
import VForm from './v-form';
|
||||
import VHover from './v-hover/';
|
||||
import VIcon from './v-icon/';
|
||||
import VInfo from './v-info/';
|
||||
import VInput from './v-input/';
|
||||
import VItemGroup, { VItem } from './v-item-group';
|
||||
import VList, {
|
||||
VListGroup,
|
||||
VListItem,
|
||||
VListItemContent,
|
||||
VListItemHint,
|
||||
VListItemIcon,
|
||||
VListItemSubtitle,
|
||||
VListItemTitle,
|
||||
} from './v-list/';
|
||||
import VMenu from './v-menu/';
|
||||
import VModal from './v-modal/';
|
||||
import VNotice from './v-notice/';
|
||||
import VOverlay from './v-overlay/';
|
||||
import VPagination from './v-pagination/';
|
||||
import VProgressCircular from './v-progress/circular/';
|
||||
import VProgressLinear from './v-progress/linear/';
|
||||
import VRadio from './v-radio/';
|
||||
import VSelect from './v-select/';
|
||||
import VSheet from './v-sheet/';
|
||||
import VSkeletonLoader from './v-skeleton-loader/';
|
||||
import VSlider from './v-slider/';
|
||||
import VSwitch from './v-switch/';
|
||||
import VTable from './v-table/';
|
||||
import VTabs, { VTab, VTabsItems, VTabItem } from './v-tabs/';
|
||||
import VTextarea from './v-textarea';
|
||||
import VUpload from './v-upload';
|
||||
|
||||
Vue.component('v-avatar', VAvatar);
|
||||
Vue.component('v-badge', VBadge);
|
||||
Vue.component('v-breadcrumb', VBreadcrumb);
|
||||
Vue.component('v-button', VButton);
|
||||
Vue.component('v-card-actions', VCardActions);
|
||||
Vue.component('v-card-subtitle', VCardSubtitle);
|
||||
Vue.component('v-card-text', VCardText);
|
||||
Vue.component('v-card-title', VCardTitle);
|
||||
Vue.component('v-card', VCard);
|
||||
Vue.component('v-checkbox', VCheckbox);
|
||||
Vue.component('v-chip', VChip);
|
||||
Vue.component('v-detail', VDetail);
|
||||
Vue.component('v-dialog', VDialog);
|
||||
Vue.component('v-divider', VDivider);
|
||||
Vue.component('v-error', VError);
|
||||
Vue.component('v-fancy-select', VFancySelect);
|
||||
Vue.component('v-field-template', VFieldTemplate);
|
||||
Vue.component('v-form', VForm);
|
||||
Vue.component('v-hover', VHover);
|
||||
Vue.component('v-icon', VIcon);
|
||||
Vue.component('v-info', VInfo);
|
||||
Vue.component('v-input', VInput);
|
||||
Vue.component('v-item-group', VItemGroup);
|
||||
Vue.component('v-item', VItem);
|
||||
Vue.component('v-list-group', VListGroup);
|
||||
Vue.component('v-list-item-content', VListItemContent);
|
||||
Vue.component('v-list-item-hint', VListItemHint);
|
||||
Vue.component('v-list-item-icon', VListItemIcon);
|
||||
Vue.component('v-list-item-subtitle', VListItemSubtitle);
|
||||
Vue.component('v-list-item-title', VListItemTitle);
|
||||
Vue.component('v-list-item', VListItem);
|
||||
Vue.component('v-list', VList);
|
||||
Vue.component('v-menu', VMenu);
|
||||
Vue.component('v-modal', VModal);
|
||||
Vue.component('v-notice', VNotice);
|
||||
Vue.component('v-overlay', VOverlay);
|
||||
Vue.component('v-pagination', VPagination);
|
||||
Vue.component('v-progress-circular', VProgressCircular);
|
||||
Vue.component('v-progress-linear', VProgressLinear);
|
||||
Vue.component('v-radio', VRadio);
|
||||
Vue.component('v-select', VSelect);
|
||||
Vue.component('v-sheet', VSheet);
|
||||
Vue.component('v-skeleton-loader', VSkeletonLoader);
|
||||
Vue.component('v-slider', VSlider);
|
||||
Vue.component('v-switch', VSwitch);
|
||||
Vue.component('v-tab-item', VTabItem);
|
||||
Vue.component('v-tab', VTab);
|
||||
Vue.component('v-table', VTable);
|
||||
Vue.component('v-tabs-items', VTabsItems);
|
||||
Vue.component('v-tabs', VTabs);
|
||||
Vue.component('v-textarea', VTextarea);
|
||||
Vue.component('v-upload', VUpload);
|
||||
|
||||
import TransitionExpand from './transition/expand';
|
||||
|
||||
Vue.component('transition-expand', TransitionExpand);
|
||||
|
||||
import RenderDisplay from '@/views/private/components/render-display';
|
||||
import RenderTemplate from '@/views/private/components/render-template';
|
||||
import DrawerDetail from '@/views/private/components/drawer-detail/';
|
||||
import FilterDrawerDetail from '@/views/private/components/filter-drawer-detail';
|
||||
import UserPopover from '@/views/private/components/user-popover';
|
||||
|
||||
Vue.component('render-display', RenderDisplay);
|
||||
Vue.component('render-template', RenderTemplate);
|
||||
Vue.component('filter-drawer-detail', FilterDrawerDetail);
|
||||
Vue.component('drawer-detail', DrawerDetail);
|
||||
Vue.component('user-popover', UserPopover);
|
||||
4
src/components/transition/expand/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import TransitionExpand from './transition-expand.vue';
|
||||
|
||||
export { TransitionExpand };
|
||||
export default TransitionExpand;
|
||||
50
src/components/transition/expand/readme.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# `transition-expand`
|
||||
|
||||
Use around a `v-if` or `v-show` component to have it expand in and out of view.
|
||||
|
||||
## Usage
|
||||
|
||||
```html
|
||||
<template>
|
||||
<div>
|
||||
<v-button @click="toggle">Click me!</v-button>
|
||||
|
||||
<transition-expand>
|
||||
<div v-if="active">
|
||||
More content
|
||||
</div>
|
||||
</transition-expand>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref } from '@vue/composition-api';
|
||||
|
||||
export default defineComponent({
|
||||
setup(props) {
|
||||
const active = ref<boolean>(false);
|
||||
|
||||
return { active, toggle };
|
||||
|
||||
function toggle() { active.value = !active.value; };
|
||||
}
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
## Props
|
||||
| Prop | Description | Default |
|
||||
|-------------------------|----------------------------------------------------|---------|
|
||||
| `x-axis` | Expand on the horizontal instead vertical axis | `false` |
|
||||
| `expanded-parent-class` | Add a custom class to the element that is expanded | `''` |
|
||||
|
||||
## Slots
|
||||
| Slot | Description | Data |
|
||||
|-----------|-------------|------|
|
||||
| _default_ | | |
|
||||
|
||||
## Events
|
||||
n/a
|
||||
|
||||
## CSS Variables
|
||||
n/a
|
||||
@@ -0,0 +1,90 @@
|
||||
import capitalizeFirst from '@/utils/capitalize-first';
|
||||
|
||||
interface HTMLExpandElement extends HTMLElement {
|
||||
_parent?: (Node & ParentNode & HTMLElement) | null;
|
||||
_initialStyle: {
|
||||
transition: string;
|
||||
visibility: string;
|
||||
overflow: string;
|
||||
height?: string | null;
|
||||
width?: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
export default function (expandedParentClass = '', xAxis = false) {
|
||||
const sizeProperty = xAxis ? 'width' : ('height' as 'width' | 'height');
|
||||
const offsetProperty = `offset${capitalizeFirst(sizeProperty)}` as 'offsetHeight' | 'offsetWidth';
|
||||
|
||||
return {
|
||||
beforeEnter(el: HTMLExpandElement) {
|
||||
el._parent = el.parentNode as (Node & ParentNode & HTMLElement) | null;
|
||||
el._initialStyle = {
|
||||
transition: el.style.transition,
|
||||
visibility: el.style.visibility,
|
||||
overflow: el.style.overflow,
|
||||
[sizeProperty]: el.style[sizeProperty],
|
||||
};
|
||||
},
|
||||
|
||||
enter(el: HTMLExpandElement) {
|
||||
const initialStyle = el._initialStyle;
|
||||
const offset = `${el[offsetProperty]}px`;
|
||||
|
||||
el.style.setProperty('transition', 'none', 'important');
|
||||
el.style.visibility = 'hidden';
|
||||
el.style.visibility = initialStyle.visibility;
|
||||
el.style.overflow = 'hidden';
|
||||
el.style[sizeProperty] = '0';
|
||||
|
||||
void el.offsetHeight; // force reflow
|
||||
|
||||
el.style.transition =
|
||||
initialStyle.transition !== ''
|
||||
? initialStyle.transition
|
||||
: `${sizeProperty} var(--medium) var(--transition)`;
|
||||
|
||||
if (expandedParentClass && el._parent) {
|
||||
el._parent.classList.add(expandedParentClass);
|
||||
}
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
el.style[sizeProperty] = offset;
|
||||
});
|
||||
},
|
||||
|
||||
afterEnter: resetStyles,
|
||||
enterCancelled: resetStyles,
|
||||
|
||||
leave(el: HTMLExpandElement) {
|
||||
el._initialStyle = {
|
||||
transition: '',
|
||||
visibility: '',
|
||||
overflow: el.style.overflow,
|
||||
[sizeProperty]: el.style[sizeProperty],
|
||||
};
|
||||
|
||||
el.style.overflow = 'hidden';
|
||||
el.style[sizeProperty] = `${el[offsetProperty]}px`;
|
||||
void el.offsetHeight; // force reflow
|
||||
|
||||
requestAnimationFrame(() => (el.style[sizeProperty] = '0'));
|
||||
},
|
||||
|
||||
afterLeave,
|
||||
leaveCancelled: afterLeave,
|
||||
};
|
||||
|
||||
function afterLeave(el: HTMLExpandElement) {
|
||||
if (expandedParentClass && el._parent) {
|
||||
el._parent.classList.remove(expandedParentClass);
|
||||
}
|
||||
resetStyles(el);
|
||||
}
|
||||
|
||||
function resetStyles(el: HTMLExpandElement) {
|
||||
const size = el._initialStyle[sizeProperty];
|
||||
el.style.overflow = el._initialStyle.overflow;
|
||||
if (size != null) el.style[sizeProperty] = size;
|
||||
delete el._initialStyle;
|
||||
}
|
||||
}
|
||||
40
src/components/transition/expand/transition-expand.story.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import markdown from './readme.md';
|
||||
import { defineComponent, ref } from '@vue/composition-api';
|
||||
import TransitionExpand from './transition-expand.vue';
|
||||
import withPadding from '../../../../.storybook/decorators/with-padding';
|
||||
|
||||
export default {
|
||||
title: 'Transition / Expand',
|
||||
parameters: {
|
||||
notes: markdown,
|
||||
},
|
||||
decorators: [withPadding],
|
||||
};
|
||||
|
||||
export const basic = () =>
|
||||
defineComponent({
|
||||
components: { TransitionExpand },
|
||||
props: {},
|
||||
setup() {
|
||||
const active = ref(false);
|
||||
|
||||
return { active, toggle };
|
||||
|
||||
function toggle() {
|
||||
active.value = !active.value;
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div>
|
||||
<v-button @click="toggle">Click me!</v-button>
|
||||
|
||||
<transition-expand>
|
||||
<div v-if="active" style="margin-top: 50px">
|
||||
<v-sheet style="--v-sheet-padding: 24px; --v-sheet-background-color: var(--red-100);">
|
||||
<h1 class="type-title">Hello, world!</h1>
|
||||
</v-sheet>
|
||||
</div>
|
||||
</transition-expand>
|
||||
</div>
|
||||
`,
|
||||
});
|
||||
44
src/components/transition/expand/transition-expand.test.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { mount, createLocalVue } from '@vue/test-utils';
|
||||
import VueCompositionAPI, { defineComponent, ref } from '@vue/composition-api';
|
||||
import TransitionExpand from './transition-expand.vue';
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(VueCompositionAPI);
|
||||
|
||||
localVue.component('transition-expand', TransitionExpand);
|
||||
|
||||
const ExpandTestUtil = defineComponent({
|
||||
setup() {
|
||||
const active = ref<boolean>(false);
|
||||
const toggle = () => (active.value = !active.value);
|
||||
return { active, toggle };
|
||||
},
|
||||
template: `
|
||||
<div>
|
||||
<slot v-bind="{ active, toggle }" />
|
||||
</div>
|
||||
`,
|
||||
});
|
||||
|
||||
describe('Expand Transition', () => {
|
||||
it('Renders the provided markup in the default slot', async () => {
|
||||
const component = mount(ExpandTestUtil, {
|
||||
localVue,
|
||||
scopedSlots: {
|
||||
default: `
|
||||
<div slot-scope="foo">
|
||||
<button @click="foo.toggle"/>
|
||||
<transition-expand>
|
||||
<div v-show="foo.active" class="test"> Content </div>
|
||||
</transition-expand>
|
||||
</div>
|
||||
`,
|
||||
},
|
||||
});
|
||||
|
||||
expect(component.find('.test').isVisible()).toBe(false);
|
||||
component.find('button').trigger('click');
|
||||
await component.vm.$nextTick();
|
||||
expect(component.find('.test').isVisible()).toBe(true);
|
||||
});
|
||||
});
|
||||
27
src/components/transition/expand/transition-expand.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<transition name="expand-transition" mode="in-out" v-on="methods">
|
||||
<slot />
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from '@vue/composition-api';
|
||||
import ExpandMethods from './transition-expand-methods';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
xAxis: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
expandedParentClass: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const methods = ExpandMethods(props.expandedParentClass, props.xAxis);
|
||||
return { methods };
|
||||
},
|
||||
});
|
||||
</script>
|
||||
4
src/components/transition/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import TransitionExpand from './expand';
|
||||
|
||||
export { TransitionExpand };
|
||||
export default { TransitionExpand };
|
||||
7
src/components/transition/readme.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Transitions
|
||||
|
||||
Preset extensions of the Vue `transition` element.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [`Expand`](./expand)
|
||||
4
src/components/v-avatar/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import VAvatar from './v-avatar.vue';
|
||||
|
||||
export { VAvatar };
|
||||
export default VAvatar;
|
||||
41
src/components/v-avatar/readme.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Avatar
|
||||
|
||||
```html
|
||||
<v-avatar>RVZ</v-avatar>
|
||||
|
||||
<v-avatar>
|
||||
<img src="..." />
|
||||
</v-avatar>
|
||||
|
||||
<v-avatar>
|
||||
<v-icon name="person">
|
||||
</v-avatar>
|
||||
```
|
||||
|
||||
## Props
|
||||
|
||||
| Prop | Description | Default |
|
||||
|-----------|---------------------------|---------|
|
||||
| `size` | Size in px | -- |
|
||||
| `tile` | Render as a tile (square) | `false` |
|
||||
| `x-small` | Render extra small | `false` |
|
||||
| `small` | Render small | `false` |
|
||||
| `large` | Render large | `false` |
|
||||
| `x-large` | Render extra large | `false` |
|
||||
|
||||
## Slots
|
||||
|
||||
| Slot | Description | Data |
|
||||
|-----------|-------------|------|
|
||||
| _default_ | | -- |
|
||||
|
||||
## Events
|
||||
|
||||
n/a
|
||||
|
||||
## CSS Variables
|
||||
|
||||
| Variable | Default |
|
||||
|--------------------|-----------------------------|
|
||||
| `--v-avatar-color` | `--avatar-background-color` |
|
||||
| `--v-avatar-size` | -- |
|
||||
167
src/components/v-avatar/v-avatar.story.ts
Normal file
@@ -0,0 +1,167 @@
|
||||
import { withKnobs, text, boolean, number, color, optionsKnob as options } from '@storybook/addon-knobs';
|
||||
import Vue from 'vue';
|
||||
import VAvatar from './v-avatar.vue';
|
||||
import VIcon from '../v-icon/';
|
||||
import markdown from './readme.md';
|
||||
import withPadding from '../../../.storybook/decorators/with-padding';
|
||||
|
||||
Vue.component('v-avatar', VAvatar);
|
||||
Vue.component('v-icon', VIcon);
|
||||
|
||||
export default {
|
||||
title: 'Components / Avatar',
|
||||
component: VAvatar,
|
||||
decorators: [withKnobs, withPadding],
|
||||
parameters: {
|
||||
notes: markdown,
|
||||
},
|
||||
};
|
||||
|
||||
export const withText = () => ({
|
||||
props: {
|
||||
text: {
|
||||
default: text('Text', 'RVZ'),
|
||||
},
|
||||
tile: {
|
||||
default: boolean('Tile', false),
|
||||
},
|
||||
color: {
|
||||
default: color('Color', '#009688'),
|
||||
},
|
||||
size: {
|
||||
default: options(
|
||||
'Size',
|
||||
{
|
||||
'Extra Small': 'xSmall',
|
||||
Small: 'small',
|
||||
'(default)': 'default',
|
||||
Large: 'large',
|
||||
'Extra Large': 'xLarge',
|
||||
},
|
||||
'default',
|
||||
{
|
||||
display: 'select',
|
||||
}
|
||||
),
|
||||
},
|
||||
customSize: {
|
||||
default: number('Size (in px)', 0),
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<v-avatar
|
||||
:x-small="size === 'xSmall'"
|
||||
:small="size === 'small'"
|
||||
:large="size === 'large'"
|
||||
:x-large="size === 'xLarge'"
|
||||
:tile="tile"
|
||||
:style="{'--v-avatar-color': color }"
|
||||
:size="customSize"
|
||||
>{{ text }}</v-avatar>`,
|
||||
});
|
||||
|
||||
export const withImage = () => ({
|
||||
props: {
|
||||
tile: {
|
||||
default: boolean('Tile', false),
|
||||
},
|
||||
color: {
|
||||
default: color('Color', '#009688'),
|
||||
},
|
||||
size: {
|
||||
default: options(
|
||||
'Size',
|
||||
{
|
||||
'Extra Small': 'xSmall',
|
||||
Small: 'small',
|
||||
'(default)': 'default',
|
||||
Large: 'large',
|
||||
'Extra Large': 'xLarge',
|
||||
},
|
||||
'default',
|
||||
{
|
||||
display: 'select',
|
||||
}
|
||||
),
|
||||
},
|
||||
customSize: {
|
||||
default: number('Size (in px)', 0),
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<v-avatar
|
||||
:x-small="size === 'xSmall'"
|
||||
:small="size === 'small'"
|
||||
:large="size === 'large'"
|
||||
:x-large="size === 'xLarge'"
|
||||
:tile="tile"
|
||||
:style="{'--v-avatar-color': color }"
|
||||
:size="customSize"
|
||||
>
|
||||
<img src="https://randomuser.me/api/portraits/men/97.jpg" />
|
||||
</v-avatar>`,
|
||||
});
|
||||
|
||||
export const withIcon = () => ({
|
||||
props: {
|
||||
tile: {
|
||||
default: boolean('Tile', false),
|
||||
},
|
||||
color: {
|
||||
default: color('Color', '#009688'),
|
||||
},
|
||||
size: {
|
||||
default: options(
|
||||
'Size',
|
||||
{
|
||||
'Extra Small': 'xSmall',
|
||||
Small: 'small',
|
||||
'(default)': 'default',
|
||||
Large: 'large',
|
||||
'Extra Large': 'xLarge',
|
||||
},
|
||||
'default',
|
||||
{
|
||||
display: 'select',
|
||||
}
|
||||
),
|
||||
},
|
||||
customSize: {
|
||||
default: number('Size (in px)', 0),
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<v-avatar
|
||||
:x-small="size === 'xSmall'"
|
||||
:small="size === 'small'"
|
||||
:large="size === 'large'"
|
||||
:x-large="size === 'xLarge'"
|
||||
:tile="tile"
|
||||
:style="{'--v-avatar-color': color }"
|
||||
:size="customSize"
|
||||
>
|
||||
<v-icon name="person" :style="{'--v-icon-color': 'white'}" />
|
||||
</v-avatar>`,
|
||||
});
|
||||
|
||||
export const sizes = () => ({
|
||||
template: `
|
||||
<div style="display: flex; justify-content: space-around; align-items: center;">
|
||||
<v-avatar x-small>
|
||||
<img src="https://randomuser.me/api/portraits/men/97.jpg" />
|
||||
</v-avatar>
|
||||
<v-avatar small>
|
||||
<img src="https://randomuser.me/api/portraits/men/97.jpg" />
|
||||
</v-avatar>
|
||||
<v-avatar>
|
||||
<img src="https://randomuser.me/api/portraits/men/97.jpg" />
|
||||
</v-avatar>
|
||||
<v-avatar large>
|
||||
<img src="https://randomuser.me/api/portraits/men/97.jpg" />
|
||||
</v-avatar>
|
||||
<v-avatar x-large>
|
||||
<img src="https://randomuser.me/api/portraits/men/97.jpg" />
|
||||
</v-avatar>
|
||||
</div>
|
||||
`,
|
||||
});
|
||||
19
src/components/v-avatar/v-avatar.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { mount, createLocalVue, Wrapper } from '@vue/test-utils';
|
||||
import VueCompositionAPI from '@vue/composition-api';
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(VueCompositionAPI);
|
||||
|
||||
import VAvatar from './v-avatar.vue';
|
||||
|
||||
describe('Avatar', () => {
|
||||
let component: Wrapper<Vue>;
|
||||
|
||||
beforeEach(() => (component = mount(VAvatar, { localVue })));
|
||||
|
||||
it('Sets the tile class if tile prop is passed', async () => {
|
||||
component.setProps({ tile: true });
|
||||
await component.vm.$nextTick();
|
||||
expect(component.classes()).toContain('tile');
|
||||
});
|
||||
});
|
||||
82
src/components/v-avatar/v-avatar.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<div class="v-avatar" :class="[{ tile }, sizeClass]">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from '@vue/composition-api';
|
||||
import useSizeClass, { sizeProps } from '@/composables/size-class';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
size: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
tile: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
...sizeProps,
|
||||
},
|
||||
setup(props) {
|
||||
const sizeClass = useSizeClass(props);
|
||||
return { sizeClass };
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
--v-avatar-color: var(--background-normal);
|
||||
--v-avatar-size: 48px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.v-avatar {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: var(--v-avatar-size);
|
||||
height: var(--v-avatar-size);
|
||||
overflow: hidden;
|
||||
color: var(--foreground-subdued);
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
background-color: var(--v-avatar-color);
|
||||
border-radius: var(--border-radius);
|
||||
|
||||
&.tile {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
&.x-small {
|
||||
--v-avatar-size: 24px;
|
||||
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
&.small {
|
||||
--v-avatar-size: 36px;
|
||||
}
|
||||
|
||||
&.large {
|
||||
--v-avatar-size: 64px;
|
||||
}
|
||||
|
||||
&.x-large {
|
||||
--v-avatar-size: 80px;
|
||||
}
|
||||
|
||||
::v-deep {
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
4
src/components/v-badge/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import VBadge from './v-badge.vue';
|
||||
|
||||
export { VBadge };
|
||||
export default VBadge;
|
||||
44
src/components/v-badge/readme.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Badge
|
||||
|
||||
```html
|
||||
<v-badge value="2"><v-icon>ABC</v-icon></v-badge>
|
||||
```
|
||||
|
||||
## Colors
|
||||
|
||||
You can set the color, background color and boder color with the `--v-badge-color`, `--v-badge-background-color` and `--v-badge-border-color` css vars respectively:
|
||||
|
||||
```html
|
||||
<v-badge
|
||||
value="11"
|
||||
style="--v-badge-color: var(--red-500);"
|
||||
>
|
||||
<v-icon>ABC</v-icon>
|
||||
</v-badge>
|
||||
```
|
||||
|
||||
## Props
|
||||
| Prop | Description | Default |
|
||||
|------------|------------------------------------------------------------------------------|---------|
|
||||
| `value` | The value that will be displayed inside the badge Only 2 characters allowed) | `null` |
|
||||
| `dot` | Only will show a small dot without any content | `false` |
|
||||
| `bordered` | Shows a border arround the badge | `false` |
|
||||
| `left` | Aligns the badge on the left side | `false` |
|
||||
| `bottom` | Aligns the badge on the bottom side | `false` |
|
||||
| `icon` | Shows an icon instead of text | `null` |
|
||||
| `disabled` | Don't render the badge | `false` |
|
||||
|
||||
## Slots
|
||||
N/A
|
||||
|
||||
## Events
|
||||
N/A
|
||||
|
||||
## CSS Variables
|
||||
| Variable | Default |
|
||||
|------------------------------|--------------------------|
|
||||
| `--v-badge-color` | `var(--white)` |
|
||||
| `--v-badge-background-color` | `var(--danger)` |
|
||||
| `--v-badge-border-color` | `var(--background-page)` |
|
||||
| `--v-badge-offset-x` | `0px` |
|
||||
| `--v-badge-offset-y` | `0px` |
|
||||
169
src/components/v-badge/v-badge.story.ts
Normal file
@@ -0,0 +1,169 @@
|
||||
import { withKnobs, text, boolean, number } from '@storybook/addon-knobs';
|
||||
import Vue from 'vue';
|
||||
import VBadge from './v-badge.vue';
|
||||
import VIcon from '../v-icon/';
|
||||
import markdown from './readme.md';
|
||||
import withPadding from '../../../.storybook/decorators/with-padding';
|
||||
|
||||
Vue.component('v-badge', VBadge);
|
||||
Vue.component('v-icon', VIcon);
|
||||
|
||||
export default {
|
||||
title: 'Components / Badge',
|
||||
component: VBadge,
|
||||
decorators: [withKnobs, withPadding],
|
||||
parameters: {
|
||||
notes: markdown,
|
||||
},
|
||||
};
|
||||
|
||||
export const withButton = () => ({
|
||||
props: {
|
||||
value: {
|
||||
default: text('Text in badge', '3', 'Badge'),
|
||||
},
|
||||
dot: {
|
||||
default: boolean('Dot', false, 'Badge'),
|
||||
},
|
||||
left: {
|
||||
default: boolean('Left', false, 'Badge'),
|
||||
},
|
||||
bottom: {
|
||||
default: boolean('Bottom', false, 'Badge'),
|
||||
},
|
||||
offsetX: {
|
||||
default: number('Offset X', 0, undefined, 'Badge'),
|
||||
},
|
||||
offsetY: {
|
||||
default: number('Offset Y', 0, undefined, 'Badge'),
|
||||
},
|
||||
icon: {
|
||||
default: text('Icon', '', 'Badge'),
|
||||
},
|
||||
bordered: {
|
||||
default: boolean('Bordered', false, 'Badge'),
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<v-badge
|
||||
:value="value"
|
||||
:dot="dot"
|
||||
:left="left"
|
||||
:bottom="bottom"
|
||||
:icon="icon"
|
||||
:bordered="bordered"
|
||||
:style="{
|
||||
'--v-badge-offset-x': (offsetX + 'px'),
|
||||
'--v-badge-offset-y': (offsetY + 'px')
|
||||
}"
|
||||
>
|
||||
<v-button>Click me!</v-button>
|
||||
</v-badge>
|
||||
`,
|
||||
});
|
||||
|
||||
export const withText = () => ({
|
||||
props: {
|
||||
value: {
|
||||
default: text('Text in badge', '3', 'Badge'),
|
||||
},
|
||||
dot: {
|
||||
default: boolean('Dot', false, 'Badge'),
|
||||
},
|
||||
left: {
|
||||
default: boolean('Left', false, 'Badge'),
|
||||
},
|
||||
bottom: {
|
||||
default: boolean('Bottom', false, 'Badge'),
|
||||
},
|
||||
offsetX: {
|
||||
default: number('Offset X', 0, undefined, 'Badge'),
|
||||
},
|
||||
offsetY: {
|
||||
default: number('Offset Y', 0, undefined, 'Badge'),
|
||||
},
|
||||
icon: {
|
||||
default: text('Icon', '', 'Badge'),
|
||||
},
|
||||
bordered: {
|
||||
default: boolean('Bordered', false, 'Badge'),
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<v-badge
|
||||
:value="value"
|
||||
:dot="dot"
|
||||
:left="left"
|
||||
:bottom="bottom"
|
||||
:icon="icon"
|
||||
:bordered="bordered"
|
||||
:style="{
|
||||
'--v-badge-offset-x': (offsetX + 'px'),
|
||||
'--v-badge-offset-y': (offsetY + 'px')
|
||||
}"
|
||||
>
|
||||
Example text.
|
||||
</v-badge>
|
||||
`,
|
||||
});
|
||||
|
||||
export const withAvatar = () => ({
|
||||
props: {
|
||||
value: {
|
||||
default: text('Text in badge', '3', 'Badge'),
|
||||
},
|
||||
dot: {
|
||||
default: boolean('Dot', false, 'Badge'),
|
||||
},
|
||||
left: {
|
||||
default: boolean('Left', false, 'Badge'),
|
||||
},
|
||||
bottom: {
|
||||
default: boolean('Bottom', false, 'Badge'),
|
||||
},
|
||||
icon: {
|
||||
default: text('Icon', '', 'Badge'),
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<v-badge
|
||||
:value="value"
|
||||
:dot="dot"
|
||||
:left="left"
|
||||
:bottom="bottom"
|
||||
:icon="icon"
|
||||
:bordered="true"
|
||||
:style="{
|
||||
'--v-badge-offset-x': '3px',
|
||||
'--v-badge-offset-y': '3px'
|
||||
}"
|
||||
>
|
||||
<v-avatar>RVZ</v-avatar>
|
||||
</v-badge>
|
||||
`,
|
||||
});
|
||||
|
||||
export const colors = () => ({
|
||||
template: `
|
||||
<div>
|
||||
<v-badge
|
||||
style="--v-badge-color: var(--white);--v-badge-background-color: var(--red-500); margin-right: 20px"
|
||||
value="9+"
|
||||
>
|
||||
<v-button>Click me!</v-button>
|
||||
</v-badge>
|
||||
<v-badge
|
||||
style="--v-badge-color: var(--white);--v-badge-background-color: var(--green-500); margin-right: 20px"
|
||||
icon="spa"
|
||||
>
|
||||
<v-button>Click me!</v-button>
|
||||
</v-badge>
|
||||
<v-badge
|
||||
style="--v-badge-color: var(--white);--v-badge-background-color: var(--orange-500)"
|
||||
icon="notifications_active"
|
||||
>
|
||||
<v-button>Click me!</v-button>
|
||||
</v-badge>
|
||||
</div>
|
||||
`,
|
||||
});
|
||||
68
src/components/v-badge/v-badge.test.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { mount, createLocalVue, Wrapper } from '@vue/test-utils';
|
||||
import VueCompositionAPI from '@vue/composition-api';
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(VueCompositionAPI);
|
||||
localVue.component('v-icon', VIcon);
|
||||
|
||||
import VBadge from './v-badge.vue';
|
||||
import VIcon from '../v-icon/';
|
||||
|
||||
describe('Chip', () => {
|
||||
let component: Wrapper<Vue>;
|
||||
|
||||
beforeEach(() => {
|
||||
component = mount(VBadge, { localVue });
|
||||
});
|
||||
|
||||
it('Adds the dot prop to the badge', async () => {
|
||||
component.setProps({
|
||||
dot: true,
|
||||
});
|
||||
|
||||
await component.vm.$nextTick();
|
||||
|
||||
expect(component.find('.badge').classes()).toContain('dot');
|
||||
});
|
||||
|
||||
it('Adds the bordered prop to the badge', async () => {
|
||||
component.setProps({
|
||||
bordered: true,
|
||||
});
|
||||
|
||||
await component.vm.$nextTick();
|
||||
|
||||
expect(component.find('.badge').classes()).toContain('bordered');
|
||||
});
|
||||
|
||||
it('Display the badge on the left', async () => {
|
||||
component.setProps({
|
||||
left: true,
|
||||
});
|
||||
|
||||
await component.vm.$nextTick();
|
||||
|
||||
expect(component.find('.badge').classes()).toContain('left');
|
||||
});
|
||||
|
||||
it('Display the badge on the bottom', async () => {
|
||||
component.setProps({
|
||||
bottom: true,
|
||||
});
|
||||
|
||||
await component.vm.$nextTick();
|
||||
|
||||
expect(component.find('.badge').classes()).toContain('bottom');
|
||||
});
|
||||
|
||||
it('Checks if the icon exists and if the name matches', async () => {
|
||||
component.setProps({
|
||||
icon: 'add',
|
||||
});
|
||||
|
||||
await component.vm.$nextTick();
|
||||
|
||||
expect(component.find('.v-icon').exists()).toBe(true);
|
||||
expect(component.find('.v-icon').props().name).toBe('add');
|
||||
});
|
||||
});
|
||||
114
src/components/v-badge/v-badge.vue
Normal file
@@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<div class="v-badge" :class="{ dot, bordered }">
|
||||
<span v-if="!disabled" class="badge" :class="{ dot, bordered, left, bottom }">
|
||||
<v-icon v-if="icon" :name="icon" :color="color" x-small />
|
||||
<span v-else>{{ value }}</span>
|
||||
</span>
|
||||
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from '@vue/composition-api';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
value: {
|
||||
type: [String, Number],
|
||||
default: null,
|
||||
},
|
||||
dot: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
left: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
bottom: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
bordered: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
--v-badge-color: var(--white);
|
||||
--v-badge-background-color: var(--danger);
|
||||
--v-badge-border-color: var(--background-page);
|
||||
--v-badge-offset-x: 0px;
|
||||
--v-badge-offset-y: 0px;
|
||||
--v-badge-size: 16px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.v-badge {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
|
||||
&.bordered {
|
||||
--v-badge-size: 20px;
|
||||
}
|
||||
|
||||
&.dot {
|
||||
--v-badge-size: 8px;
|
||||
|
||||
&.bordered {
|
||||
--v-badge-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.badge {
|
||||
position: absolute;
|
||||
top: calc(var(--v-badge-size) / -2 + var(--v-badge-offset-y));
|
||||
right: calc(var(--v-badge-size) / -2 + var(--v-badge-offset-x));
|
||||
z-index: 1;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: max-content;
|
||||
min-width: var(--v-badge-size);
|
||||
height: var(--v-badge-size);
|
||||
padding: 0 5px;
|
||||
color: var(--v-badge-color);
|
||||
font-weight: 600;
|
||||
font-size: 11px;
|
||||
background-color: var(--v-badge-background-color);
|
||||
border-radius: calc(var(--v-badge-size) / 2);
|
||||
|
||||
&.left {
|
||||
right: unset;
|
||||
left: calc(var(--v-badge-size) / -2 + var(--v-badge-offset-x));
|
||||
}
|
||||
|
||||
&.bottom {
|
||||
top: unset;
|
||||
bottom: calc(var(--v-badge-size) / -2 + var(--v-badge-offset-y));
|
||||
}
|
||||
|
||||
&.dot * {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&.bordered {
|
||||
border: 2px solid var(--v-badge-border-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
4
src/components/v-breadcrumb/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import VBreadcrumb from './v-breadcrumb.vue';
|
||||
|
||||
export { VBreadcrumb };
|
||||
export default VBreadcrumb;
|
||||
28
src/components/v-breadcrumb/readme.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Breadcrumb
|
||||
|
||||
```html
|
||||
<v-breadcrumb :items="[{name: 'Collections', to: '/collections'}]" />
|
||||
```
|
||||
|
||||
## Props
|
||||
| Prop | Description | Default |
|
||||
|-----------------|-----------------------------------------------------------|---------|
|
||||
| `items` | An array of objects which information about each section | `[]` |
|
||||
| `items.name` | The name which will be displayed | `''` |
|
||||
| `items.to` | The reroute link | `''` |
|
||||
| `items.disabled`| If the router link should be clickable | `false` |
|
||||
| `items.icon` | Displays an icon with the given name in front of the name | `''` |
|
||||
|
||||
## Events
|
||||
n/a
|
||||
|
||||
## Slots
|
||||
n/a
|
||||
|
||||
## CSS Variables
|
||||
| Prop | Default |
|
||||
|---------------------------------|-------------------------------------|
|
||||
| `--v-breadcrumb-color` | `var(--foreground-subdued)` |
|
||||
| `--v-breadcrumb-color-hover` | `var(--foreground-normal)` |
|
||||
| `--v-breadcrumb-color-disabled` | `var(--foreground-subdued)` |
|
||||
| `--v-breadcrumb-divider-color` | `var(--foreground-subdued)` |
|
||||
35
src/components/v-breadcrumb/v-breadcrumb.story.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import Vue from 'vue';
|
||||
import markdown from './readme.md';
|
||||
import VIcon from '../v-icon/';
|
||||
import VBreadcrumb from './v-breadcrumb.vue';
|
||||
import withPadding from '../../../.storybook/decorators/with-padding';
|
||||
|
||||
import VueRouter from 'vue-router';
|
||||
|
||||
Vue.use(VueRouter);
|
||||
|
||||
const router = new VueRouter();
|
||||
|
||||
Vue.component('v-breadcrumb', VBreadcrumb);
|
||||
Vue.component('v-icon', VIcon);
|
||||
|
||||
export default {
|
||||
title: 'Components / Breadcrumb',
|
||||
component: VBreadcrumb,
|
||||
decorators: [withPadding],
|
||||
parameters: {
|
||||
notes: markdown,
|
||||
},
|
||||
};
|
||||
|
||||
export const example = () => ({
|
||||
router,
|
||||
template: `
|
||||
<v-breadcrumb :items="[
|
||||
{disabled: false, to: 'Test', name: 'Collections', icon: 'home'},
|
||||
{disabled: false, to: 'Test', name: 'Locations'},
|
||||
{disabled: false, to: 'Test', name: 'New York'},
|
||||
{disabled: true, to: 'Test', name: 'Berlin'}
|
||||
]"/>
|
||||
`,
|
||||
});
|
||||
77
src/components/v-breadcrumb/v-breadcrumb.test.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import VueCompositionAPI from '@vue/composition-api';
|
||||
import { mount, createLocalVue, Wrapper } from '@vue/test-utils';
|
||||
import VBreadcrumb from './v-breadcrumb.vue';
|
||||
import VIcon from '../v-icon/';
|
||||
|
||||
import VueRouter from 'vue-router';
|
||||
|
||||
const router = new VueRouter();
|
||||
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(VueCompositionAPI);
|
||||
localVue.component('v-icon', VIcon);
|
||||
localVue.use(VueRouter);
|
||||
|
||||
describe('Breadcrumb', () => {
|
||||
let component: Wrapper<Vue>;
|
||||
|
||||
beforeEach(() => {
|
||||
component = mount(VBreadcrumb, { localVue, router });
|
||||
jest.useFakeTimers();
|
||||
});
|
||||
|
||||
it('Renders the whole breadcrump', async () => {
|
||||
component.setProps({
|
||||
items: [
|
||||
{ name: 'A', to: 'linkA' },
|
||||
{ name: 'B', to: 'linkB' },
|
||||
{ name: 'C', to: 'linkC' },
|
||||
],
|
||||
});
|
||||
|
||||
await component.vm.$nextTick();
|
||||
|
||||
const sections = component.findAll('.section a.section-link');
|
||||
|
||||
expect(sections.at(0).text()).toBe('A');
|
||||
expect(sections.at(0).attributes().href).toContain('linkA');
|
||||
|
||||
expect(sections.at(1).text()).toBe('B');
|
||||
expect(sections.at(1).attributes().href).toContain('linkB');
|
||||
|
||||
expect(sections.at(2).text()).toBe('C');
|
||||
expect(sections.at(2).attributes().href).toContain('linkC');
|
||||
});
|
||||
|
||||
it('Renders breadcrumb with icon ', async () => {
|
||||
component.setProps({
|
||||
items: [
|
||||
{ name: 'A', to: 'linkA' },
|
||||
{ name: 'B', to: 'linkB', icon: 'home' },
|
||||
{ name: 'C', to: 'linkC', icon: 'add' },
|
||||
],
|
||||
});
|
||||
|
||||
await component.vm.$nextTick();
|
||||
|
||||
const sections = component.findAll('.section a.section-link');
|
||||
|
||||
expect(sections.at(0).find('.v-icon').exists()).toBe(false);
|
||||
expect(sections.at(1).find('.v-icon').text()).toBe('home');
|
||||
expect(sections.at(2).find('.v-icon').text()).toBe('add');
|
||||
});
|
||||
|
||||
it('Renders breadcrumb with disabled section ', async () => {
|
||||
component.setProps({
|
||||
items: [
|
||||
{ name: 'A', to: 'linkA' },
|
||||
{ name: 'B', to: 'linkB', disabled: true },
|
||||
{ name: 'C', to: 'linkC' },
|
||||
],
|
||||
});
|
||||
|
||||
await component.vm.$nextTick();
|
||||
|
||||
expect(component.findAll('.section').at(1).classes()).toContain('disabled');
|
||||
});
|
||||
});
|
||||
93
src/components/v-breadcrumb/v-breadcrumb.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<span class="v-breadcrumb">
|
||||
<span v-for="(item, index) in items" :key="item.name" class="section" :class="{ disabled: item.disabled }">
|
||||
<v-icon v-if="index > 0" name="chevron_right" small />
|
||||
<router-link v-if="!item.disabled" :to="item.to" class="section-link">
|
||||
<v-icon v-if="item.icon" :name="item.icon" small />
|
||||
{{ item.name }}
|
||||
</router-link>
|
||||
<span v-else class="section-link">
|
||||
<v-icon v-if="item.icon" :name="item.icon" />
|
||||
{{ item.name }}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, PropType } from '@vue/composition-api';
|
||||
|
||||
interface Breadcrumb {
|
||||
to: string;
|
||||
name: string;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
items: {
|
||||
type: Array as PropType<Breadcrumb[]>,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
setup() {
|
||||
return {};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
--v-breadcrumb-color: var(--foreground-subdued);
|
||||
--v-breadcrumb-color-hover: var(--foreground-normal);
|
||||
--v-breadcrumb-color-disabled: var(--foreground-subdued);
|
||||
--v-breadcrumb-divider-color: var(--foreground-subdued);
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.v-breadcrumb {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.section {
|
||||
display: contents;
|
||||
|
||||
.v-icon {
|
||||
--v-icon-color: var(--v-breadcrumb-divider-color);
|
||||
|
||||
margin: 0 4px;
|
||||
}
|
||||
|
||||
&-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
color: var(--v-breadcrumb-color);
|
||||
text-decoration: none;
|
||||
|
||||
.v-icon {
|
||||
--v-icon-color: var(--v-breadcrumb-color);
|
||||
|
||||
margin: 0 2px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: var(--v-breadcrumb-color-hover);
|
||||
|
||||
.v-icon {
|
||||
--v-icon-color: var(--v-breadcrumb-color-hover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
.section-link,
|
||||
.section-link:hover,
|
||||
.section-link .v-icon {
|
||||
color: var(--v-breadcrumb-color-disabled);
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
4
src/components/v-button-group/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import VButtonGroup from './v-button-group.vue';
|
||||
|
||||
export { VButtonGroup };
|
||||
export default VButtonGroup;
|
||||