@vaadin/grid-pro 22.0.0-alpha9 → 22.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,12 @@
1
- # <vaadin-grid-pro>
1
+ # @vaadin/grid-pro
2
2
 
3
- [Live Demo ↗](https://vaadin.com/components/vaadin-grid-pro/html-examples)
4
- |
5
- [API documentation ↗](https://vaadin.com/components/vaadin-grid-pro/html-api)
3
+ An extension of the `vaadin-grid` component that provides inline editing with full keyboard navigation.
6
4
 
7
- [<vaadin-grid-pro>](https://vaadin.com/components/vaadin-grid-pro) is a high quality data grid / data table Web Component with extended functionality, part of the [Vaadin components](https://vaadin.com/components).
5
+ > ℹ️  A commercial Vaadin [subscription](https://vaadin.com/pricing) is required to use Grid Pro in your project.
6
+
7
+ [Documentation + Live Demo ↗](https://vaadin.com/docs/latest/ds/components/grid-pro)
8
8
 
9
9
  [![npm version](https://badgen.net/npm/v/@vaadin/grid-pro)](https://www.npmjs.com/package/@vaadin/grid-pro)
10
- [![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/vaadinvaadin-grid-pro)
11
10
  [![Discord](https://img.shields.io/discord/732335336448852018?label=discord)](https://discord.gg/PHmkCKC)
12
11
 
13
12
  ```html
@@ -25,41 +24,48 @@
25
24
  </script>
26
25
  ```
27
26
 
28
- [<img src="https://raw.githubusercontent.com/vaadin/vaadin-grid-pro/master/screenshot.png" width="900" alt="Screenshot of vaadin-grid-pro">](https://vaadin.com/components/vaadin-grid-pro)
27
+ [<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/grid-pro/screenshot.png" width="900" alt="Screenshot of vaadin-grid-pro">](https://vaadin.com/docs/latest/ds/components/grid-pro)
29
28
 
30
29
  ## Installation
31
30
 
32
- Install `vaadin-grid-pro`:
31
+ Install the component:
33
32
 
34
33
  ```sh
35
- npm i @vaadin/vaadin-pro --save
34
+ npm i @vaadin/grid-pro
36
35
  ```
37
36
 
38
- Once installed, import it in your application:
37
+ Once installed, import the component in your application:
39
38
 
40
39
  ```js
41
- import '@vaadin/grid-pro/vaadin-grid-pro.js';
40
+ import '@vaadin/grid-pro';
41
+ import '@vaadin/grid-pro/vaadin-grid-pro-edit-column.js';
42
42
  ```
43
43
 
44
- ## Getting started
45
-
46
- Vaadin components use the Lumo theme by default.
47
-
48
- To use the Material theme, import the correspondent file from the `theme/material` folder.
44
+ ## Themes
49
45
 
50
- ## Entry points
46
+ Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/ds/customization/using-themes), Lumo and Material.
47
+ The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/grid-pro/vaadin-grid-pro.js) of the package uses the Lumo theme.
51
48
 
52
- - The component with the Lumo theme:
49
+ To use the Material theme, import the components from the `theme/material` folder:
53
50
 
54
- `theme/lumo/vaadin-grid-pro.js`
51
+ ```js
52
+ import '@vaadin/grid-pro/theme/material/vaadin-grid-pro.js';
53
+ import '@vaadin/grid-pro/theme/material/vaadin-grid-pro-edit-column.js';
54
+ ```
55
55
 
56
- - The component with the Material theme:
56
+ You can also import the Lumo version of the components explicitly:
57
57
 
58
- `theme/material/vaadin-grid-pro.js`
58
+ ```js
59
+ import '@vaadin/grid-pro/theme/lumo/vaadin-grid-pro.js';
60
+ import '@vaadin/grid-pro/theme/lumo/vaadin-grid-pro-edit-column.js';
61
+ ```
59
62
 
60
- - Alias for `theme/lumo/vaadin-grid-pro.js`:
63
+ Finally, you can import the un-themed components from the `src` folder to get a minimal starting point:
61
64
 
62
- `vaadin-grid-pro.js`
65
+ ```js
66
+ import '@vaadin/grid-pro/src/vaadin-grid-pro.js';
67
+ import '@vaadin/grid-pro/src/vaadin-grid-pro-edit-column.js';
68
+ ```
63
69
 
64
70
  ## Contributing
65
71
 
@@ -69,4 +75,5 @@ Read the [contributing guide](https://vaadin.com/docs/latest/guide/contributing/
69
75
 
70
76
  Commercial Vaadin Developer License 4.0 (CVDLv4). For license terms, see LICENSE.
71
77
 
72
- Vaadin collects development time usage statistics to improve this product. For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
78
+ Vaadin collects usage statistics at development time to improve this product.
79
+ For grid-pro and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/grid-pro",
3
- "version": "22.0.0-alpha9",
3
+ "version": "22.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,27 +32,28 @@
32
32
  "polymer"
33
33
  ],
34
34
  "dependencies": {
35
+ "@open-wc/dedupe-mixin": "^1.3.0",
35
36
  "@polymer/polymer": "^3.0.0",
36
- "@vaadin/checkbox": "22.0.0-alpha9",
37
- "@vaadin/component-base": "22.0.0-alpha9",
38
- "@vaadin/grid": "22.0.0-alpha9",
39
- "@vaadin/item": "22.0.0-alpha9",
40
- "@vaadin/list-box": "22.0.0-alpha9",
41
- "@vaadin/select": "22.0.0-alpha9",
42
- "@vaadin/text-field": "22.0.0-alpha9",
37
+ "@vaadin/checkbox": "^22.0.0",
38
+ "@vaadin/component-base": "^22.0.0",
39
+ "@vaadin/grid": "^22.0.0",
40
+ "@vaadin/item": "^22.0.0",
41
+ "@vaadin/list-box": "^22.0.0",
42
+ "@vaadin/select": "^22.0.0",
43
+ "@vaadin/text-field": "^22.0.0",
43
44
  "@vaadin/vaadin-license-checker": "^2.1.0",
44
- "@vaadin/vaadin-lumo-styles": "22.0.0-alpha9",
45
- "@vaadin/vaadin-material-styles": "22.0.0-alpha9",
46
- "@vaadin/vaadin-themable-mixin": "22.0.0-alpha9"
45
+ "@vaadin/vaadin-lumo-styles": "^22.0.0",
46
+ "@vaadin/vaadin-material-styles": "^22.0.0",
47
+ "@vaadin/vaadin-themable-mixin": "^22.0.0"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@esm-bundle/chai": "^4.3.4",
50
- "@vaadin/date-picker": "22.0.0-alpha9",
51
- "@vaadin/dialog": "22.0.0-alpha9",
52
- "@vaadin/polymer-legacy-adapter": "22.0.0-alpha9",
53
- "@vaadin/testing-helpers": "^0.3.0",
51
+ "@vaadin/date-picker": "^22.0.0",
52
+ "@vaadin/dialog": "^22.0.0",
53
+ "@vaadin/polymer-legacy-adapter": "^22.0.0",
54
+ "@vaadin/testing-helpers": "^0.3.2",
54
55
  "lit": "^2.0.0",
55
56
  "sinon": "^9.2.1"
56
57
  },
57
- "gitHead": "6e8c899dc65918f97e3c0acb2076122c4b2ef274"
58
+ "gitHead": "b668e9b1a975227fbe34beb70d1cd5b03dce2348"
58
59
  }
@@ -4,8 +4,8 @@
4
4
  * This program is available under Commercial Vaadin Developer License 4.0 (CVDLv4).
5
5
  * See <a href="https://vaadin.com/license/cvdl-4.0">the website</a> for the complete license.
6
6
  */
7
+ import { GridBodyRenderer, GridDefaultItem, GridItemModel } from '@vaadin/grid/src/vaadin-grid.js';
7
8
  import { GridColumn } from '@vaadin/grid/src/vaadin-grid-column.js';
8
- import { GridDefaultItem, GridBodyRenderer, GridItemModel } from '@vaadin/grid/src/vaadin-grid.js';
9
9
 
10
10
  export type GridProEditorType = 'text' | 'checkbox' | 'select' | 'custom';
11
11
 
@@ -70,15 +70,13 @@ declare class GridProEditColumn<TItem = GridDefaultItem> extends GridColumn<TIte
70
70
  */
71
71
  editorValuePath: string;
72
72
 
73
- _getEditorTagName(cell: HTMLElement): string;
73
+ protected _getEditorComponent(cell: HTMLElement): HTMLElement | null;
74
74
 
75
- _getEditorComponent(cell: HTMLElement): HTMLElement | null;
75
+ protected _getEditorValue(editor: HTMLElement): unknown | null;
76
76
 
77
- _getEditorValue(editor: HTMLElement): unknown | null;
77
+ protected _startCellEdit(cell: HTMLElement, model: GridItemModel<TItem>): void;
78
78
 
79
- _startCellEdit(cell: HTMLElement, model: GridItemModel<TItem>): void;
80
-
81
- _stopCellEdit(cell: HTMLElement, model: GridItemModel<TItem>): void;
79
+ protected _stopCellEdit(cell: HTMLElement, model: GridItemModel<TItem>): void;
82
80
  }
83
81
 
84
82
  declare global {
@@ -4,11 +4,11 @@
4
4
  * This program is available under Commercial Vaadin Developer License 4.0 (CVDLv4).
5
5
  * See <a href="https://vaadin.com/license/cvdl-4.0">the website</a> for the complete license.
6
6
  */
7
- import { get, set } from '@polymer/polymer/lib/utils/path.js';
8
- import { GridColumn } from '@vaadin/grid/src/vaadin-grid-column.js';
9
7
  import './vaadin-grid-pro-edit-checkbox.js';
10
8
  import './vaadin-grid-pro-edit-select.js';
11
9
  import './vaadin-grid-pro-edit-text-field.js';
10
+ import { get, set } from '@polymer/polymer/lib/utils/path.js';
11
+ import { GridColumn } from '@vaadin/grid/src/vaadin-grid-column.js';
12
12
 
13
13
  /**
14
14
  * `<vaadin-grid-pro-edit-column>` is a helper element for the `<vaadin-grid-pro>`
@@ -4,9 +4,9 @@
4
4
  * This program is available under Commercial Vaadin Developer License 4.0 (CVDLv4).
5
5
  * See <a href="https://vaadin.com/license/cvdl-4.0">the website</a> for the complete license.
6
6
  */
7
- import { Select } from '@vaadin/select/src/vaadin-select.js';
8
7
  import '@vaadin/item/src/vaadin-item.js';
9
8
  import '@vaadin/list-box/src/vaadin-list-box.js';
9
+ import { Select } from '@vaadin/select/src/vaadin-select.js';
10
10
 
11
11
  /**
12
12
  * An element used internally by `<vaadin-grid-pro>`. Not intended to be used separately.
@@ -44,9 +44,6 @@ class GridProEditSelect extends Select {
44
44
  super.ready();
45
45
 
46
46
  this.setAttribute('theme', 'grid-pro-editor');
47
-
48
- this.__boundOnKeyDown = this.__onOverlayKeyDown.bind(this);
49
- this._overlayElement.addEventListener('keydown', this.__boundOnKeyDown);
50
47
  }
51
48
 
52
49
  _onKeyDown(e) {
@@ -61,10 +58,25 @@ class GridProEditSelect extends Select {
61
58
  }
62
59
  }
63
60
 
64
- __onOverlayKeyDown(e) {
65
- if (e.keyCode === 9) {
66
- !this._grid.singleCellEdit && this._grid._switchEditCell(e);
61
+ /**
62
+ * Override list-box event listener inherited from `Select`:
63
+ * - Enter: set flag for moving to next row on value change,
64
+ * - Tab: switch to next cell when "singleCellEdit" is false.
65
+ * @param {!KeyboardEvent} event
66
+ * @protected
67
+ * @override
68
+ */
69
+ _onKeyDownInside(event) {
70
+ if (event.keyCode === 13) {
71
+ this._enterKeydown = event;
72
+ }
73
+
74
+ if (event.keyCode === 9) {
75
+ !this._grid.singleCellEdit && this._grid._switchEditCell(event);
67
76
  }
77
+
78
+ // Call `super` to close overlay on Tab.
79
+ super._onKeyDownInside(event);
68
80
  }
69
81
 
70
82
  _valueChanged(value, oldValue) {
@@ -100,13 +112,6 @@ class GridProEditSelect extends Select {
100
112
  listBox.appendChild(item);
101
113
  });
102
114
 
103
- // save the "keydown" event for Enter
104
- listBox.addEventListener('keydown', (e) => {
105
- if (e.keyCode === 13) {
106
- this._enterKeydown = e;
107
- }
108
- });
109
-
110
115
  root.appendChild(listBox);
111
116
  };
112
117
 
@@ -4,14 +4,13 @@
4
4
  * This program is available under Commercial Vaadin Developer License 4.0 (CVDLv4).
5
5
  * See <a href="https://vaadin.com/license/cvdl-4.0">the website</a> for the complete license.
6
6
  */
7
+ import { Constructor } from '@open-wc/dedupe-mixin';
7
8
 
8
- declare function InlineEditingMixin<T extends new (...args: any[]) => {}>(base: T): T & InlineEditingMixinConstructor;
9
+ export declare function InlineEditingMixin<T extends Constructor<HTMLElement>>(
10
+ base: T
11
+ ): T & Constructor<InlineEditingMixinClass>;
9
12
 
10
- interface InlineEditingMixinConstructor {
11
- new (...args: any[]): InlineEditingMixin;
12
- }
13
-
14
- interface InlineEditingMixin {
13
+ export declare class InlineEditingMixinClass {
15
14
  /**
16
15
  * When true, pressing Enter while in cell edit mode
17
16
  * will move focus to the editable cell in the next row
@@ -37,11 +36,7 @@ interface InlineEditingMixin {
37
36
  */
38
37
  editOnClick: boolean | null | undefined;
39
38
 
40
- _checkImports(): void;
39
+ protected _stopEdit(shouldCancel?: boolean, shouldRestoreFocus?: boolean): void;
41
40
 
42
- _stopEdit(shouldCancel?: boolean, shouldRestoreFocus?: boolean): void;
43
-
44
- _switchEditCell(e: KeyboardEvent): void;
41
+ protected _switchEditCell(e: KeyboardEvent): void;
45
42
  }
46
-
47
- export { InlineEditingMixin, InlineEditingMixinConstructor };
@@ -4,9 +4,8 @@
4
4
  * This program is available under Commercial Vaadin Developer License 4.0 (CVDLv4).
5
5
  * See <a href="https://vaadin.com/license/cvdl-4.0">the website</a> for the complete license.
6
6
  */
7
- import { GridDefaultItem, Grid, GridCustomEventMap } from '@vaadin/grid/src/vaadin-grid.js';
8
- import { InlineEditingMixin } from './vaadin-grid-pro-inline-editing-mixin.js';
9
-
7
+ import { Grid, GridCustomEventMap, GridDefaultItem } from '@vaadin/grid/src/vaadin-grid.js';
8
+ import { InlineEditingMixinClass } from './vaadin-grid-pro-inline-editing-mixin.js';
10
9
  export { GridProEditorType } from './vaadin-grid-pro-edit-column.js';
11
10
 
12
11
  /**
@@ -76,8 +75,6 @@ export interface GridProEventMap<TItem>
76
75
  * @fires {CustomEvent} selected-items-changed - Fired when the `selectedItems` property changes.
77
76
  */
78
77
  declare class GridPro<TItem = GridDefaultItem> extends Grid<TItem> {
79
- static _finalizeClass(): void;
80
-
81
78
  addEventListener<K extends keyof GridProEventMap<TItem>>(
82
79
  type: K,
83
80
  listener: (this: GridPro<TItem>, ev: GridProEventMap<TItem>[K]) => void,
@@ -91,7 +88,7 @@ declare class GridPro<TItem = GridDefaultItem> extends Grid<TItem> {
91
88
  ): void;
92
89
  }
93
90
 
94
- interface GridPro extends InlineEditingMixin {}
91
+ interface GridPro extends InlineEditingMixinClass {}
95
92
 
96
93
  declare global {
97
94
  interface HTMLElementTagNameMap {
@@ -4,9 +4,9 @@
4
4
  * This program is available under Commercial Vaadin Developer License 4.0 (CVDLv4).
5
5
  * See <a href="https://vaadin.com/license/cvdl-4.0">the website</a> for the complete license.
6
6
  */
7
+ import '@vaadin/vaadin-license-checker/vaadin-license-checker.js';
7
8
  import { Grid } from '@vaadin/grid/src/vaadin-grid.js';
8
9
  import { InlineEditingMixin } from './vaadin-grid-pro-inline-editing-mixin.js';
9
- import '@vaadin/vaadin-license-checker/vaadin-license-checker.js';
10
10
 
11
11
  /**
12
12
  *
@@ -1,6 +1,6 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
2
1
  import '@vaadin/vaadin-lumo-styles/spacing.js';
3
2
  import '@vaadin/vaadin-lumo-styles/typography.js';
3
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
4
4
  import { gridProEditor } from './vaadin-grid-pro-editor-styles.js';
5
5
 
6
6
  const gridProEditSelect = css`
@@ -1,4 +1,4 @@
1
- import { registerStyles } from '@vaadin/vaadin-themable-mixin/register-styles.js';
1
+ import { registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
2
2
  import { gridProEditor } from './vaadin-grid-pro-editor-styles.js';
3
3
 
4
4
  registerStyles('vaadin-grid-pro-edit-text-field', gridProEditor, {
@@ -1,7 +1,7 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
2
1
  import '@vaadin/vaadin-lumo-styles/color.js';
3
2
  import '@vaadin/vaadin-lumo-styles/spacing.js';
4
3
  import '@vaadin/vaadin-lumo-styles/typography.js';
4
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
5
5
 
6
6
  const gridProEditor = css`
7
7
  :host([theme~='grid-pro-editor']) {
@@ -1,5 +1,6 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
2
1
  import '@vaadin/vaadin-lumo-styles/color.js';
2
+ import '@vaadin/vaadin-lumo-styles/style.js';
3
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
3
4
 
4
5
  registerStyles(
5
6
  'vaadin-grid-pro',
@@ -14,6 +15,41 @@ registerStyles(
14
15
  pointer-events: none;
15
16
  box-shadow: inset 0 0 0 2px var(--lumo-primary-color-50pct);
16
17
  }
18
+
19
+ [part~='editable-cell'],
20
+ [part~='editable-cell'] ::slotted(vaadin-grid-cell-content) {
21
+ cursor: var(--lumo-clickable-cursor);
22
+ }
23
+
24
+ [part~='editable-cell']:hover,
25
+ [part~='editable-cell']:focus {
26
+ background-color: var(--lumo-contrast-5pct);
27
+ background-clip: padding-box;
28
+ }
29
+
30
+ /* Indicate editable cells */
31
+
32
+ :host([theme~='highlight-editable-cells']) [part~='editable-cell'] {
33
+ background-color: var(--lumo-contrast-5pct);
34
+ background-clip: border-box;
35
+ }
36
+
37
+ :host([theme~='highlight-editable-cells']) [part~='editable-cell']:hover,
38
+ :host([theme~='highlight-editable-cells']) [part~='editable-cell']:focus {
39
+ background-color: var(--lumo-contrast-10pct);
40
+ }
41
+
42
+ /* Indicate read-only cells */
43
+
44
+ :host([theme~='highlight-read-only-cells']) [part~='body-cell']:not([part~='editable-cell']) {
45
+ background-image: repeating-linear-gradient(
46
+ 135deg,
47
+ transparent,
48
+ transparent 6px,
49
+ var(--lumo-contrast-5pct) 6px,
50
+ var(--lumo-contrast-5pct) 14px
51
+ );
52
+ }
17
53
  `,
18
54
  { moduleId: 'lumo-grid-pro' }
19
55
  );
@@ -1,4 +1,4 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
1
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
2
2
  import { gridProEditor } from './vaadin-grid-pro-editor-styles.js';
3
3
 
4
4
  const gridProEditSelect = css`
@@ -1,4 +1,4 @@
1
- import { registerStyles } from '@vaadin/vaadin-themable-mixin/register-styles.js';
1
+ import { registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
2
2
  import { gridProEditor } from './vaadin-grid-pro-editor-styles.js';
3
3
 
4
4
  registerStyles('vaadin-grid-pro-edit-text-field', gridProEditor, {
@@ -1,4 +1,4 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
1
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
2
2
 
3
3
  const gridProEditor = css`
4
4
  :host([theme~='grid-pro-editor']) {
@@ -1,6 +1,6 @@
1
- import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js';
2
1
  import '@vaadin/vaadin-material-styles/color.js';
3
2
  import '@vaadin/grid/theme/material/vaadin-grid-styles.js';
3
+ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
4
4
 
5
5
  registerStyles(
6
6
  'vaadin-grid-pro',
@@ -8,6 +8,17 @@ registerStyles(
8
8
  :host([navigating]) [part~='cell']:active {
9
9
  box-shadow: inset 0 0 0 2px var(--material-primary-color);
10
10
  }
11
+
12
+ [part~='editable-cell'],
13
+ [part~='editable-cell'] ::slotted(vaadin-grid-cell-content) {
14
+ cursor: pointer;
15
+ }
16
+
17
+ [part~='row'] > [part~='editable-cell']:hover,
18
+ [part~='row'] > [part~='editable-cell']:focus {
19
+ background-color: var(--material-grid-pro-editable-cell-hover-background-color, rgba(0, 0, 0, 0.04));
20
+ background-clip: padding-box;
21
+ }
11
22
  `,
12
23
  { moduleId: 'material-grid-pro' }
13
24
  );