Skip to content

steverep/vaadin-web-components

 
 

Repository files navigation

Vaadin logo

Vaadin web components

Vaadin components is an evolving set of high-quality web components for business web applications.

Build Follow on Twitter Discord

Installation

Install the components that you need from npm:

npm install @vaadin/grid

Usage

Live demo →

Import the component's JavaScript module, use the component in your HTML, and control it with JavaScript:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Vaadin example</title>
  </head>
  <body>
    <!-- Use web components in your HTML like regular built-in elements. -->
    <vaadin-grid theme="row-dividers" column-reordering-allowed multi-sort>
      <vaadin-grid-selection-column auto-select frozen></vaadin-grid-selection-column>
      <vaadin-grid-sort-column width="9em" path="firstName"></vaadin-grid-sort-column>
      <vaadin-grid-sort-column width="9em" path="lastName"></vaadin-grid-sort-column>
      <vaadin-grid-column width="9em" path="address.city"></vaadin-grid-column>
    </vaadin-grid>

    <!-- Vaadin web components use standard JavaScript modules. -->
    <script type="module">
      // Importing the following modules registers <vaadin-grid> and its column
      // elements so that you can use them in this page.
      import '@vaadin/grid/vaadin-grid.js';
      import '@vaadin/grid/vaadin-grid-selection-column.js';
      import '@vaadin/grid/vaadin-grid-sort-column.js';

      // Use component's properties to populate data.
      const grid = document.querySelector('vaadin-grid');
      fetch('https://demo.vaadin.com/demo-data/1.0/people?count=200')
        .then((res) => res.json())
        .then((json) => (grid.items = json.result));
    </script>
  </body>
</html>

Serve your HTML with a development server that supports bare module specifiers, such as @web/dev-server:

npm i -g @web/dev-server
web-dev-server --node-resolve --open

Components

This project contains components for Vaadin 20+. Please see individual repositories for older Vaadin versions.

Core Components

The components below are licensed under the Apache License 2.0.

Component npm version (latest) npm version (next) Issues
<vaadin-accordion> npm version npm version Issues
<vaadin-app-layout> npm version npm version Issues
<vaadin-avatar> npm version npm version Issues
<vaadin-avatar-group> npm version npm version Issues
<vaadin-button> npm version npm version Issues
<vaadin-checkbox> npm version npm version Issues
<vaadin-checkbox-group> npm version npm version Issues
<vaadin-combo-box> npm version npm version Issues
<vaadin-confirm-dialog> npm version npm version Issues
<vaadin-context-menu> npm version npm version Issues
<vaadin-custom-field> npm version npm version Issues
<vaadin-date-picker> npm version npm version Issues
<vaadin-date-time-picker> npm version npm version Issues
<vaadin-details> npm version npm version Issues
<vaadin-dialog> npm version npm version Issues
<vaadin-email-field> npm version npm version Issues
<vaadin-form-layout> npm version npm version Issues
<vaadin-grid> npm version npm version Issues
<vaadin-horizontal-layout> npm version npm version Issues
<vaadin-icon> npm version npm version Issues
<vaadin-icons> npm version npm version Issues
<vaadin-integer-field> npm version npm version Issues
<vaadin-item> npm version npm version Issues
<vaadin-list-box> npm version npm version Issues
<vaadin-login> npm version npm version Issues
<vaadin-menu-bar> npm version npm version Issues
<vaadin-message-input> npm version npm version Issues
<vaadin-message-list> npm version npm version Issues
<vaadin-multi-select-combo-box> npm version npm version Issues
<vaadin-notification> npm version npm version Issues
<vaadin-number-field> npm version npm version Issues
<vaadin-password-field> npm version npm version Issues
<vaadin-progress-bar> npm version npm version Issues
<vaadin-radio-group> npm version npm version Issues
<vaadin-scroller> npm version npm version Issues
<vaadin-select> npm version npm version Issues
<vaadin-split-layout> npm version npm version Issues
<vaadin-tabs> npm version npm version Issues
<vaadin-tabsheet> npm version npm version Issues
<vaadin-text-area> npm version npm version Issues
<vaadin-text-field> npm version npm version Issues
<vaadin-time-picker> npm version npm version Issues
<vaadin-tooltip> npm version npm version Issues
<vaadin-upload> npm version npm version Issues
<vaadin-virtual-list> npm version npm version Issues

Pro Components

The components below are licensed under Vaadin Commercial License and Service Terms and available as part of the Vaadin Pro Subscription.

Component npm version (latest) npm version (next) Issues
<vaadin-board> npm version npm version Issues
<vaadin-charts> npm version npm version Issues
<vaadin-cookie-consent> npm version npm version Issues
<vaadin-crud> npm version npm version Issues
<vaadin-grid-pro> npm version npm version Issues
<vaadin-map> npm version npm version Issues
<vaadin-rich-text-editor> npm version npm version Issues

Browser support

Desktop:

  • Chrome (evergreen)
  • Firefox (evergreen)
  • Safari 14.1 or newer
  • Edge (Chromium, evergreen)

Mobile:

  • Chrome (evergreen) for Android (4.4 or newer)
  • Safari for iOS (14.5 or newer)

Documentation

Check out our design system documentation.

Examples

Are you looking for an example project to get started? Visit start.vaadin.com to create a Vaadin app.

Questions

For help and support questions, please use our community chat.

Big Thanks

Cross-browser Testing Platform and Open Source <3 Provided by Sauce Labs.

Contributing

Read the contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.

Development

Setup the repo:

yarn

Environment variables

Setup the environment variables needed by the scripts below, by copying the .env.dist template file to .env:

cp .env.dist .env

and then configure the individual variable values in the newly created .env file.

Not all variables are necessary for all scripts, individual sections below will note which variables are required to run a command.

Unit tests

Run tests in Chrome:

yarn test

Run tests in Firefox:

yarn test:firefox

Run tests in WebKit:

yarn test:webkit

By default, tests will only run for changed packages. To run tests for all packages, use the --all flag:

yarn test --all

Run tests for single package:

yarn test --group upload

Debug tests for single package:

yarn debug --group upload

Run tests with code coverage:

yarn test --coverage

Visual tests

To run the visual tests, please make sure that the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are defined.

Run tests for Lumo:

yarn test:lumo

Run tests for Material:

yarn test:material

Update reference screenshots for Lumo:

yarn update:lumo

Update reference screenshots for Material:

yarn update:material

Update screenshots for single package:

yarn update:lumo --group vaadin-upload

Integration tests

Run integration tests that are in the separate integration folder:

yarn test:it

Generating icons

Re-generate SVG icon sets and icon fonts from individual SVG files for the packages that have them (e.g. vaadin-icons):

yarn icons

Making a major version bump

Create a branch for the current major

Checkout master and pull latest changes:

git checkout master && git pull

Create a new branch from master:

git checkout -b 24.0

Push a newly created branch:

git push origin 24.0

The newly created branch for the current major is protected by default. The rest of the changes to that branch should happen the usual way, through a PR.

Create another branch:

git checkout -b update-v24.0

Update wtr-utils.js as follows:

const isLockfileChanged = () => {
-  const log = execSync('git diff --name-only origin/master HEAD').toString();
+  const log = execSync('git diff --name-only origin/24.0 HEAD').toString();
  return log.split('\n').some((line) => line.includes('yarn.lock'));
};
const getChangedPackages = () => {
-  const output = execSync('./node_modules/.bin/lerna ls --since origin/master --json --loglevel silent');
+  const output = execSync('./node_modules/.bin/lerna ls --since origin/24.0 --json --loglevel silent');
  return JSON.parse(output.toString());
};

Create a PR to the version branch (example).

Update the version in master

Create a new branch from master:

git checkout master && git checkout -b bump-v24.1

Prepare a new version for the updateVersion script by running the following command:

export npm_config_bump=24.1.0-alpha0

Run the script to bump static version getters in ElementMixin, Lumo and Material:

node scripts/updateVersion.js

Mark the new version with Lerna:

lerna version 24.1.0-alpha0 --no-push --no-git-tag-version --force-publish --exact --yes

Commit all the changes:

git commit -a -m "chore: update master branch to Vaadin 24.1"

Create a PR to the master branch (example).

CI build updates

Add the new version branch to the CheckoutBranch parameter:

Using a local clone of the repo in Vaadin app

When using a Vaadin app, you can modify the frontend build tool config to resolve the web components modules from your local clone, instead of the versions downloaded from npm registry.

Using webpack

Modify the webpack.config.js in the root folder as follows:

module.exports = merge(
  {
    resolve: {
      modules: ['/path/to/web-components/node_modules', 'node_modules'],
    },
  },
  flowDefaults,
);
Using Vite

Modify the vite.config.ts in the root folder as follows:

import path from 'path';
import { PluginOption, UserConfigFn } from 'vite';
import { overrideVaadinConfig } from './vite.generated';

function useLocalWebComponents(webComponentsNodeModulesPath: string): PluginOption {
  return {
    name: 'use-local-web-components',
    enforce: 'pre',
    config(config) {
      config.server = config.server ?? {};
      config.server.fs = config.server.fs ?? {};
      config.server.fs.allow = config.server.fs.allow ?? [];
      config.server.fs.allow.push(webComponentsNodeModulesPath);
      config.server.watch = config.server.watch ?? {};
      config.server.watch.ignored = [`!${webComponentsNodeModulesPath}/**`];
    },
    resolveId(id) {
      if (/^(@polymer|@vaadin)/.test(id)) {
        return this.resolve(path.join(webComponentsNodeModulesPath, id));
      }
    },
  };
}

const customConfig: UserConfigFn = (env) => ({
  // Disable the Vite dependencies pre-bundling
  optimizeDeps: {
    disabled: true,
  },
  plugins: [useLocalWebComponents('/path/to/web-components/node_modules')],
});

export default overrideVaadinConfig(customConfig);

Note Make sure that the path you provide is an absolute one and that it points to the node_modules directory in the web components monorepo.

Then run the following command in the web components monorepo:

yarn

This will symlink the individual component packages into the node_modules folder.

After that you can start / restart your application and it should use the source code from the monorepo.

Fixing npm dist-tag

When maintaining two stable majors (e.g. 22.0.x and 23.0.x), it is important to maintain latest npm tag. For example, we release 22.0.7 after 23.0.1 but we still want to keep latest pointing to 23.0.1.

Use the following script on master branch to run npm dist-tag for all packages:

./scripts/fixDistTag.sh

LICENSE

For specific package(s), check the LICENSE file under the package folder.

About

A set of high-quality standards based web components for enterprise web applications. Part of Vaadin 20+

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 95.3%
  • HTML 3.0%
  • TypeScript 1.7%