@spectrum-web-components/grid 0.0.10-devmode2.0 → 0.1.1
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/custom-elements.json +11 -1
- package/package.json +4 -4
- package/sp-grid.dev.js +1 -0
- package/sp-grid.dev.js.map +1 -1
- package/sp-grid.js +1 -2
- package/sp-grid.js.map +2 -2
- package/src/Grid.d.ts +2 -0
- package/src/Grid.dev.js +31 -2
- package/src/Grid.dev.js.map +2 -2
- package/src/Grid.js +3 -105
- package/src/Grid.js.map +3 -3
- package/src/GridController.d.ts +4 -3
- package/src/GridController.dev.js +23 -11
- package/src/GridController.dev.js.map +2 -2
- package/src/GridController.js +1 -124
- package/src/GridController.js.map +3 -3
- package/src/grid.css.dev.js +2 -1
- package/src/grid.css.dev.js.map +2 -2
- package/src/grid.css.js +3 -5
- package/src/grid.css.js.map +3 -3
- package/src/index.dev.js +1 -0
- package/src/index.dev.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/stories/grid.stories.js +9 -2
- package/stories/grid.stories.js.map +1 -1
- package/test/benchmark/basic-test.js +1 -0
- package/test/benchmark/basic-test.js.map +1 -1
- package/test/grid.test.js +96 -26
- package/test/grid.test.js.map +2 -2
package/custom-elements.json
CHANGED
|
@@ -104,6 +104,16 @@
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"kind": "method",
|
|
110
|
+
"name": "createRenderRoot",
|
|
111
|
+
"privacy": "public",
|
|
112
|
+
"return": {
|
|
113
|
+
"type": {
|
|
114
|
+
"text": "this"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
107
117
|
}
|
|
108
118
|
],
|
|
109
119
|
"events": [
|
|
@@ -185,7 +195,7 @@
|
|
|
185
195
|
"kind": "field",
|
|
186
196
|
"name": "host",
|
|
187
197
|
"type": {
|
|
188
|
-
"text": "
|
|
198
|
+
"text": "Grid"
|
|
189
199
|
},
|
|
190
200
|
"default": "host"
|
|
191
201
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/grid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@lit-labs/observers": "^1.0.1",
|
|
66
66
|
"@lit-labs/virtualizer": "0.7.1",
|
|
67
|
-
"@spectrum-web-components/base": "^0.
|
|
68
|
-
"@spectrum-web-components/reactive-controllers": "^0.
|
|
67
|
+
"@spectrum-web-components/base": "^0.7.0",
|
|
68
|
+
"@spectrum-web-components/reactive-controllers": "^0.3.0",
|
|
69
69
|
"tslib": "^2.0.0"
|
|
70
70
|
},
|
|
71
71
|
"types": "./src/index.d.ts",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"./sp-*.js",
|
|
75
75
|
"./**/*.dev.js"
|
|
76
76
|
],
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "1cfea66c39440232b9982509573801b8e3a9f692"
|
|
78
78
|
}
|
package/sp-grid.dev.js
CHANGED
package/sp-grid.dev.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-grid.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { Grid } from './src/Grid.dev.js'\n\ncustomElements.define('sp-grid', Grid);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-grid': Grid;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAYA;
|
|
5
|
+
"mappings": ";AAYA,SAAS,YAAY;AAErB,eAAe,OAAO,WAAW,IAAI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/sp-grid.js
CHANGED
package/sp-grid.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-grid.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { Grid } from './src/Grid.js';\n\ncustomElements.define('sp-grid', Grid);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-grid': Grid;\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "aAYA,OAAS,QAAAA,MAAY,gBAErB,eAAe,OAAO,UAAWA,CAAI",
|
|
6
|
+
"names": ["Grid"]
|
|
7
7
|
}
|
package/src/Grid.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export declare class Grid extends LitVirtualizer {
|
|
|
20
20
|
selected: Record<string, unknown>[];
|
|
21
21
|
gridController: GridController<HTMLElement>;
|
|
22
22
|
protected handleChange(event: Event): void;
|
|
23
|
+
createRenderRoot(): this;
|
|
24
|
+
render(): TemplateResult;
|
|
23
25
|
protected update(changes: PropertyValues<this>): void;
|
|
24
26
|
connectedCallback(): void;
|
|
25
27
|
disconnectedCallback(): void;
|
package/src/Grid.dev.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -9,6 +10,11 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
9
10
|
__defProp(target, key, result);
|
|
10
11
|
return result;
|
|
11
12
|
};
|
|
13
|
+
import {
|
|
14
|
+
adoptStyles,
|
|
15
|
+
html,
|
|
16
|
+
render
|
|
17
|
+
} from "@spectrum-web-components/base";
|
|
12
18
|
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
13
19
|
import { LitVirtualizer } from "@lit-labs/virtualizer/LitVirtualizer.js";
|
|
14
20
|
import { grid } from "@lit-labs/virtualizer/layouts/grid.js";
|
|
@@ -38,7 +44,9 @@ export class Grid extends LitVirtualizer {
|
|
|
38
44
|
}
|
|
39
45
|
set renderItem(fn) {
|
|
40
46
|
super.renderItem = (item, index) => {
|
|
41
|
-
const selected = this.selected.includes(
|
|
47
|
+
const selected = this.selected.includes(
|
|
48
|
+
item
|
|
49
|
+
);
|
|
42
50
|
return fn(item, index, selected);
|
|
43
51
|
};
|
|
44
52
|
}
|
|
@@ -56,12 +64,30 @@ export class Grid extends LitVirtualizer {
|
|
|
56
64
|
}
|
|
57
65
|
this.selected = selected;
|
|
58
66
|
}
|
|
67
|
+
createRenderRoot() {
|
|
68
|
+
var _a;
|
|
69
|
+
const renderRoot = (_a = this.shadowRoot) != null ? _a : this.attachShadow(
|
|
70
|
+
this.constructor.shadowRootOptions
|
|
71
|
+
);
|
|
72
|
+
adoptStyles(
|
|
73
|
+
renderRoot,
|
|
74
|
+
this.constructor.elementStyles
|
|
75
|
+
);
|
|
76
|
+
return renderRoot;
|
|
77
|
+
}
|
|
78
|
+
render() {
|
|
79
|
+
return html`
|
|
80
|
+
<slot></slot>
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
59
83
|
update(changes) {
|
|
60
84
|
if (changes.has("itemSize") || changes.has("gap") || changes.has("focusableSelector")) {
|
|
61
85
|
this.updateComplete.then(() => {
|
|
62
86
|
this.gridController.update({
|
|
63
87
|
elements: () => [
|
|
64
|
-
...this.querySelectorAll(
|
|
88
|
+
...this.querySelectorAll(
|
|
89
|
+
this.focusableSelector
|
|
90
|
+
)
|
|
65
91
|
],
|
|
66
92
|
itemSize: () => this.itemSize,
|
|
67
93
|
gap: () => this.gap
|
|
@@ -75,6 +101,9 @@ export class Grid extends LitVirtualizer {
|
|
|
75
101
|
gap: this.gap
|
|
76
102
|
});
|
|
77
103
|
}
|
|
104
|
+
if (this.isConnected) {
|
|
105
|
+
render(super.render(), this);
|
|
106
|
+
}
|
|
78
107
|
super.update(changes);
|
|
79
108
|
}
|
|
80
109
|
connectedCallback() {
|
package/src/Grid.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Grid.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { LitVirtualizer } from '@lit-labs/virtualizer/LitVirtualizer.js';\nimport { grid } from '@lit-labs/virtualizer/layouts/grid.js';\nimport styles from './grid.css.js';\nimport { GridController } from './GridController.dev.js'\n\n/**\n * @element sp-grid\n *\n * @fires change - Announces that the value of `selected` has changed\n */\nexport class Grid extends LitVirtualizer {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String })\n public focusableSelector!: string;\n\n @property({ type: String })\n public gap: `${'0' | `${number}px`}` = '0';\n\n @property({ type: Array })\n public override items: Record<string, unknown>[] = [];\n\n @property({ type: Object })\n public itemSize: {\n width: number;\n height: number;\n } = {\n width: 200,\n height: 200,\n };\n\n /* c8 ignore next 3 */\n override get renderItem(): (\n item: unknown,\n index: number\n ) => TemplateResult {\n return super.renderItem;\n }\n\n override set renderItem(\n fn: (item: unknown, index: number, selected: boolean) => TemplateResult\n ) {\n super.renderItem = (item, index: number): TemplateResult => {\n const selected = this.selected.includes(\n item as Record<string, unknown>\n );\n return fn(item, index, selected);\n };\n }\n\n @property({ type: Array })\n public selected: Record<string, unknown>[] = [];\n\n gridController = new GridController<HTMLElement>(this, {\n elements: () => [],\n itemSize: () => this.itemSize,\n /* c8 ignore next 1 */\n gap: () => this.gap,\n });\n\n protected handleChange(event: Event): void {\n const target = event.target as HTMLElement;\n const value = this.items[\n parseFloat(target.getAttribute('key') || '')\n ] as Record<string, unknown>;\n const selected: Record<string, unknown>[] = [...this.selected];\n if (!selected.includes(value)) {\n selected.push(value);\n } else {\n const index = selected.indexOf(value);\n if (index > -1) {\n selected.splice(index, 1);\n }\n }\n this.selected = selected;\n }\n\n protected override update(changes: PropertyValues<this>): void {\n if (\n changes.has('itemSize') ||\n changes.has('gap') ||\n changes.has('focusableSelector')\n ) {\n this.updateComplete.then(() => {\n this.gridController.update({\n elements: () => [\n ...this.querySelectorAll<HTMLElement>(\n this.focusableSelector\n ),\n ],\n itemSize: () => this.itemSize,\n gap: () => this.gap,\n });\n });\n\n this.layout = grid({\n itemSize: {\n width: `${this.itemSize.width}px`,\n height: `${this.itemSize.height}px`,\n },\n gap: this.gap,\n });\n }\n\n super.update(changes);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('change', this.handleChange, { capture: true });\n }\n\n override disconnectedCallback(): void {\n this.removeEventListener('change', this.handleChange, {\n capture: true,\n });\n super.disconnectedCallback();\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n adoptStyles,\n CSSResultArray,\n html,\n PropertyValues,\n ReactiveElement,\n render,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { LitVirtualizer } from '@lit-labs/virtualizer/LitVirtualizer.js';\nimport { grid } from '@lit-labs/virtualizer/layouts/grid.js';\nimport styles from './grid.css.js';\nimport { GridController } from './GridController.dev.js'\n\n/**\n * @element sp-grid\n *\n * @fires change - Announces that the value of `selected` has changed\n */\nexport class Grid extends LitVirtualizer {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String })\n public focusableSelector!: string;\n\n @property({ type: String })\n public gap: `${'0' | `${number}px`}` = '0';\n\n @property({ type: Array })\n public override items: Record<string, unknown>[] = [];\n\n @property({ type: Object })\n public itemSize: {\n width: number;\n height: number;\n } = {\n width: 200,\n height: 200,\n };\n\n /* c8 ignore next 3 */\n override get renderItem(): (\n item: unknown,\n index: number\n ) => TemplateResult {\n return super.renderItem;\n }\n\n override set renderItem(\n fn: (item: unknown, index: number, selected: boolean) => TemplateResult\n ) {\n super.renderItem = (item, index: number): TemplateResult => {\n const selected = this.selected.includes(\n item as Record<string, unknown>\n );\n return fn(item, index, selected);\n };\n }\n\n @property({ type: Array })\n public selected: Record<string, unknown>[] = [];\n\n gridController = new GridController<HTMLElement>(this, {\n elements: () => [],\n itemSize: () => this.itemSize,\n /* c8 ignore next 1 */\n gap: () => this.gap,\n });\n\n protected handleChange(event: Event): void {\n const target = event.target as HTMLElement;\n const value = this.items[\n parseFloat(target.getAttribute('key') || '')\n ] as Record<string, unknown>;\n const selected: Record<string, unknown>[] = [...this.selected];\n if (!selected.includes(value)) {\n selected.push(value);\n } else {\n const index = selected.indexOf(value);\n if (index > -1) {\n selected.splice(index, 1);\n }\n }\n this.selected = selected;\n }\n\n public override createRenderRoot(): this {\n const renderRoot =\n this.shadowRoot ??\n this.attachShadow(\n (this.constructor as typeof ReactiveElement).shadowRootOptions\n );\n adoptStyles(\n renderRoot,\n (this.constructor as typeof ReactiveElement).elementStyles\n );\n return renderRoot as unknown as this;\n }\n\n public override render(): TemplateResult {\n return html`\n <slot></slot>\n `;\n }\n\n protected override update(changes: PropertyValues<this>): void {\n if (\n changes.has('itemSize') ||\n changes.has('gap') ||\n changes.has('focusableSelector')\n ) {\n this.updateComplete.then(() => {\n this.gridController.update({\n elements: () => [\n ...this.querySelectorAll<HTMLElement>(\n this.focusableSelector\n ),\n ],\n itemSize: () => this.itemSize,\n gap: () => this.gap,\n });\n });\n\n this.layout = grid({\n itemSize: {\n width: `${this.itemSize.width}px`,\n height: `${this.itemSize.height}px`,\n },\n gap: this.gap,\n });\n }\n\n if (this.isConnected) {\n render(super.render(), this);\n }\n super.update(changes);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('change', this.handleChange, { capture: true });\n }\n\n override disconnectedCallback(): void {\n this.removeEventListener('change', this.handleChange, {\n capture: true,\n });\n super.disconnectedCallback();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EACI;AAAA,EAEA;AAAA,EAGA;AAAA,OAEG;AACP,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AACrB,OAAO,YAAY;AACnB,SAAS,sBAAsB;AAOxB,aAAM,aAAa,eAAe;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
6
|
"names": []
|
|
7
7
|
}
|
package/src/Grid.js
CHANGED
|
@@ -1,106 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
-
if (decorator = decorators[i])
|
|
7
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result)
|
|
9
|
-
__defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
import { property } from "@spectrum-web-components/base/src/decorators.js";
|
|
13
|
-
import { LitVirtualizer } from "@lit-labs/virtualizer/LitVirtualizer.js";
|
|
14
|
-
import { grid } from "@lit-labs/virtualizer/layouts/grid.js";
|
|
15
|
-
import styles from "./grid.css.js";
|
|
16
|
-
import { GridController } from "./GridController.js";
|
|
17
|
-
export class Grid extends LitVirtualizer {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
this.gap = "0";
|
|
21
|
-
this.items = [];
|
|
22
|
-
this.itemSize = {
|
|
23
|
-
width: 200,
|
|
24
|
-
height: 200
|
|
25
|
-
};
|
|
26
|
-
this.selected = [];
|
|
27
|
-
this.gridController = new GridController(this, {
|
|
28
|
-
elements: () => [],
|
|
29
|
-
itemSize: () => this.itemSize,
|
|
30
|
-
gap: () => this.gap
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
static get styles() {
|
|
34
|
-
return [styles];
|
|
35
|
-
}
|
|
36
|
-
get renderItem() {
|
|
37
|
-
return super.renderItem;
|
|
38
|
-
}
|
|
39
|
-
set renderItem(fn) {
|
|
40
|
-
super.renderItem = (item, index) => {
|
|
41
|
-
const selected = this.selected.includes(item);
|
|
42
|
-
return fn(item, index, selected);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
handleChange(event) {
|
|
46
|
-
const target = event.target;
|
|
47
|
-
const value = this.items[parseFloat(target.getAttribute("key") || "")];
|
|
48
|
-
const selected = [...this.selected];
|
|
49
|
-
if (!selected.includes(value)) {
|
|
50
|
-
selected.push(value);
|
|
51
|
-
} else {
|
|
52
|
-
const index = selected.indexOf(value);
|
|
53
|
-
if (index > -1) {
|
|
54
|
-
selected.splice(index, 1);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
this.selected = selected;
|
|
58
|
-
}
|
|
59
|
-
update(changes) {
|
|
60
|
-
if (changes.has("itemSize") || changes.has("gap") || changes.has("focusableSelector")) {
|
|
61
|
-
this.updateComplete.then(() => {
|
|
62
|
-
this.gridController.update({
|
|
63
|
-
elements: () => [
|
|
64
|
-
...this.querySelectorAll(this.focusableSelector)
|
|
65
|
-
],
|
|
66
|
-
itemSize: () => this.itemSize,
|
|
67
|
-
gap: () => this.gap
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
this.layout = grid({
|
|
71
|
-
itemSize: {
|
|
72
|
-
width: `${this.itemSize.width}px`,
|
|
73
|
-
height: `${this.itemSize.height}px`
|
|
74
|
-
},
|
|
75
|
-
gap: this.gap
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
super.update(changes);
|
|
79
|
-
}
|
|
80
|
-
connectedCallback() {
|
|
81
|
-
super.connectedCallback();
|
|
82
|
-
this.addEventListener("change", this.handleChange, { capture: true });
|
|
83
|
-
}
|
|
84
|
-
disconnectedCallback() {
|
|
85
|
-
this.removeEventListener("change", this.handleChange, {
|
|
86
|
-
capture: true
|
|
87
|
-
});
|
|
88
|
-
super.disconnectedCallback();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
__decorateClass([
|
|
92
|
-
property({ type: String })
|
|
93
|
-
], Grid.prototype, "focusableSelector", 2);
|
|
94
|
-
__decorateClass([
|
|
95
|
-
property({ type: String })
|
|
96
|
-
], Grid.prototype, "gap", 2);
|
|
97
|
-
__decorateClass([
|
|
98
|
-
property({ type: Array })
|
|
99
|
-
], Grid.prototype, "items", 2);
|
|
100
|
-
__decorateClass([
|
|
101
|
-
property({ type: Object })
|
|
102
|
-
], Grid.prototype, "itemSize", 2);
|
|
103
|
-
__decorateClass([
|
|
104
|
-
property({ type: Array })
|
|
105
|
-
], Grid.prototype, "selected", 2);
|
|
1
|
+
"use strict";var d=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=(a,o,e,r)=>{for(var t=r>1?void 0:r?c(o,e):o,i=a.length-1,s;i>=0;i--)(s=a[i])&&(t=(r?s(o,e,t):s(t))||t);return r&&t&&d(o,e,t),t};import{adoptStyles as u,html as p,render as h}from"@spectrum-web-components/base";import{property as l}from"@spectrum-web-components/base/src/decorators.js";import{LitVirtualizer as m}from"@lit-labs/virtualizer/LitVirtualizer.js";import{grid as g}from"@lit-labs/virtualizer/layouts/grid.js";import b from"./grid.css.js";import{GridController as S}from"./GridController.js";export class Grid extends m{constructor(){super(...arguments);this.gap="0";this.items=[];this.itemSize={width:200,height:200};this.selected=[];this.gridController=new S(this,{elements:()=>[],itemSize:()=>this.itemSize,gap:()=>this.gap})}static get styles(){return[b]}get renderItem(){return super.renderItem}set renderItem(e){super.renderItem=(r,t)=>{const i=this.selected.includes(r);return e(r,t,i)}}handleChange(e){const r=e.target,t=this.items[parseFloat(r.getAttribute("key")||"")],i=[...this.selected];if(!i.includes(t))i.push(t);else{const s=i.indexOf(t);s>-1&&i.splice(s,1)}this.selected=i}createRenderRoot(){var r;const e=(r=this.shadowRoot)!=null?r:this.attachShadow(this.constructor.shadowRootOptions);return u(e,this.constructor.elementStyles),e}render(){return p`
|
|
2
|
+
<slot></slot>
|
|
3
|
+
`}update(e){(e.has("itemSize")||e.has("gap")||e.has("focusableSelector"))&&(this.updateComplete.then(()=>{this.gridController.update({elements:()=>[...this.querySelectorAll(this.focusableSelector)],itemSize:()=>this.itemSize,gap:()=>this.gap})}),this.layout=g({itemSize:{width:`${this.itemSize.width}px`,height:`${this.itemSize.height}px`},gap:this.gap})),this.isConnected&&h(super.render(),this),super.update(e)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",this.handleChange,{capture:!0})}disconnectedCallback(){this.removeEventListener("change",this.handleChange,{capture:!0}),super.disconnectedCallback()}}n([l({type:String})],Grid.prototype,"focusableSelector",2),n([l({type:String})],Grid.prototype,"gap",2),n([l({type:Array})],Grid.prototype,"items",2),n([l({type:Object})],Grid.prototype,"itemSize",2),n([l({type:Array})],Grid.prototype,"selected",2);
|
|
106
4
|
//# sourceMappingURL=Grid.js.map
|
package/src/Grid.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Grid.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { LitVirtualizer } from '@lit-labs/virtualizer/LitVirtualizer.js';\nimport { grid } from '@lit-labs/virtualizer/layouts/grid.js';\nimport styles from './grid.css.js';\nimport { GridController } from './GridController.js';\n\n/**\n * @element sp-grid\n *\n * @fires change - Announces that the value of `selected` has changed\n */\nexport class Grid extends LitVirtualizer {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String })\n public focusableSelector!: string;\n\n @property({ type: String })\n public gap: `${'0' | `${number}px`}` = '0';\n\n @property({ type: Array })\n public override items: Record<string, unknown>[] = [];\n\n @property({ type: Object })\n public itemSize: {\n width: number;\n height: number;\n } = {\n width: 200,\n height: 200,\n };\n\n /* c8 ignore next 3 */\n override get renderItem(): (\n item: unknown,\n index: number\n ) => TemplateResult {\n return super.renderItem;\n }\n\n override set renderItem(\n fn: (item: unknown, index: number, selected: boolean) => TemplateResult\n ) {\n super.renderItem = (item, index: number): TemplateResult => {\n const selected = this.selected.includes(\n item as Record<string, unknown>\n );\n return fn(item, index, selected);\n };\n }\n\n @property({ type: Array })\n public selected: Record<string, unknown>[] = [];\n\n gridController = new GridController<HTMLElement>(this, {\n elements: () => [],\n itemSize: () => this.itemSize,\n /* c8 ignore next 1 */\n gap: () => this.gap,\n });\n\n protected handleChange(event: Event): void {\n const target = event.target as HTMLElement;\n const value = this.items[\n parseFloat(target.getAttribute('key') || '')\n ] as Record<string, unknown>;\n const selected: Record<string, unknown>[] = [...this.selected];\n if (!selected.includes(value)) {\n selected.push(value);\n } else {\n const index = selected.indexOf(value);\n if (index > -1) {\n selected.splice(index, 1);\n }\n }\n this.selected = selected;\n }\n\n protected override update(changes: PropertyValues<this>): void {\n if (\n changes.has('itemSize') ||\n changes.has('gap') ||\n changes.has('focusableSelector')\n ) {\n this.updateComplete.then(() => {\n this.gridController.update({\n elements: () => [\n ...this.querySelectorAll<HTMLElement>(\n this.focusableSelector\n ),\n ],\n itemSize: () => this.itemSize,\n gap: () => this.gap,\n });\n });\n\n this.layout = grid({\n itemSize: {\n width: `${this.itemSize.width}px`,\n height: `${this.itemSize.height}px`,\n },\n gap: this.gap,\n });\n }\n\n super.update(changes);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('change', this.handleChange, { capture: true });\n }\n\n override disconnectedCallback(): void {\n this.removeEventListener('change', this.handleChange, {\n capture: true,\n });\n super.disconnectedCallback();\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n adoptStyles,\n CSSResultArray,\n html,\n PropertyValues,\n ReactiveElement,\n render,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { LitVirtualizer } from '@lit-labs/virtualizer/LitVirtualizer.js';\nimport { grid } from '@lit-labs/virtualizer/layouts/grid.js';\nimport styles from './grid.css.js';\nimport { GridController } from './GridController.js';\n\n/**\n * @element sp-grid\n *\n * @fires change - Announces that the value of `selected` has changed\n */\nexport class Grid extends LitVirtualizer {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: String })\n public focusableSelector!: string;\n\n @property({ type: String })\n public gap: `${'0' | `${number}px`}` = '0';\n\n @property({ type: Array })\n public override items: Record<string, unknown>[] = [];\n\n @property({ type: Object })\n public itemSize: {\n width: number;\n height: number;\n } = {\n width: 200,\n height: 200,\n };\n\n /* c8 ignore next 3 */\n override get renderItem(): (\n item: unknown,\n index: number\n ) => TemplateResult {\n return super.renderItem;\n }\n\n override set renderItem(\n fn: (item: unknown, index: number, selected: boolean) => TemplateResult\n ) {\n super.renderItem = (item, index: number): TemplateResult => {\n const selected = this.selected.includes(\n item as Record<string, unknown>\n );\n return fn(item, index, selected);\n };\n }\n\n @property({ type: Array })\n public selected: Record<string, unknown>[] = [];\n\n gridController = new GridController<HTMLElement>(this, {\n elements: () => [],\n itemSize: () => this.itemSize,\n /* c8 ignore next 1 */\n gap: () => this.gap,\n });\n\n protected handleChange(event: Event): void {\n const target = event.target as HTMLElement;\n const value = this.items[\n parseFloat(target.getAttribute('key') || '')\n ] as Record<string, unknown>;\n const selected: Record<string, unknown>[] = [...this.selected];\n if (!selected.includes(value)) {\n selected.push(value);\n } else {\n const index = selected.indexOf(value);\n if (index > -1) {\n selected.splice(index, 1);\n }\n }\n this.selected = selected;\n }\n\n public override createRenderRoot(): this {\n const renderRoot =\n this.shadowRoot ??\n this.attachShadow(\n (this.constructor as typeof ReactiveElement).shadowRootOptions\n );\n adoptStyles(\n renderRoot,\n (this.constructor as typeof ReactiveElement).elementStyles\n );\n return renderRoot as unknown as this;\n }\n\n public override render(): TemplateResult {\n return html`\n <slot></slot>\n `;\n }\n\n protected override update(changes: PropertyValues<this>): void {\n if (\n changes.has('itemSize') ||\n changes.has('gap') ||\n changes.has('focusableSelector')\n ) {\n this.updateComplete.then(() => {\n this.gridController.update({\n elements: () => [\n ...this.querySelectorAll<HTMLElement>(\n this.focusableSelector\n ),\n ],\n itemSize: () => this.itemSize,\n gap: () => this.gap,\n });\n });\n\n this.layout = grid({\n itemSize: {\n width: `${this.itemSize.width}px`,\n height: `${this.itemSize.height}px`,\n },\n gap: this.gap,\n });\n }\n\n if (this.isConnected) {\n render(super.render(), this);\n }\n super.update(changes);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('change', this.handleChange, { capture: true });\n }\n\n override disconnectedCallback(): void {\n this.removeEventListener('change', this.handleChange, {\n capture: true,\n });\n super.disconnectedCallback();\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAYA,OACI,eAAAA,EAEA,QAAAC,EAGA,UAAAC,MAEG,gCACP,OAAS,YAAAC,MAAgB,kDACzB,OAAS,kBAAAC,MAAsB,0CAC/B,OAAS,QAAAC,MAAY,wCACrB,OAAOC,MAAY,gBACnB,OAAS,kBAAAC,MAAsB,sBAOxB,aAAM,aAAaH,CAAe,CAAlC,kCASH,KAAO,IAAgC,IAGvC,KAAgB,MAAmC,CAAC,EAGpD,KAAO,SAGH,CACA,MAAO,IACP,OAAQ,GACZ,EAsBA,KAAO,SAAsC,CAAC,EAE9C,oBAAiB,IAAIG,EAA4B,KAAM,CACnD,SAAU,IAAM,CAAC,EACjB,S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,KAAK,SAAS,UAC7B,EACA,IAAK,KAAK,GACd,CAAC,GAGD,KAAK,aACLH,EAAO,MAAM,OAAO,EAAG,IAAI,EAE/B,MAAM,OAAOe,CAAO,CACxB,CAES,mBAA0B,CAC/B,MAAM,kBAAkB,EACxB,KAAK,iBAAiB,SAAU,KAAK,aAAc,CAAE,QAAS,EAAK,CAAC,CACxE,CAES,sBAA6B,CAClC,KAAK,oBAAoB,SAAU,KAAK,aAAc,CAClD,QAAS,EACb,CAAC,EACD,MAAM,qBAAqB,CAC/B,CACJ,CA9HWC,EAAA,CADNf,EAAS,CAAE,KAAM,MAAO,CAAC,GALjB,KAMF,iCAGAe,EAAA,CADNf,EAAS,CAAE,KAAM,MAAO,CAAC,GARjB,KASF,mBAGSe,EAAA,CADff,EAAS,CAAE,KAAM,KAAM,CAAC,GAXhB,KAYO,qBAGTe,EAAA,CADNf,EAAS,CAAE,KAAM,MAAO,CAAC,GAdjB,KAeF,wBA4BAe,EAAA,CADNf,EAAS,CAAE,KAAM,KAAM,CAAC,GA1ChB,KA2CF",
|
|
6
|
+
"names": ["adoptStyles", "html", "render", "property", "LitVirtualizer", "grid", "styles", "GridController", "fn", "item", "index", "selected", "event", "target", "value", "_a", "renderRoot", "changes", "__decorateClass"]
|
|
7
7
|
}
|
package/src/GridController.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import type { ReactiveController
|
|
1
|
+
import type { ReactiveController } from 'lit';
|
|
2
2
|
import { ResizeController } from '@lit-labs/observers/resize_controller.js';
|
|
3
3
|
import { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';
|
|
4
4
|
import { RangeChangedEvent, VisibilityChangedEvent } from '@lit-labs/virtualizer/Virtualizer.js';
|
|
5
|
+
import { Grid } from './Grid.js';
|
|
5
6
|
interface ItemSize {
|
|
6
7
|
width: number;
|
|
7
8
|
height: number;
|
|
8
9
|
}
|
|
9
10
|
export declare class GridController<T extends HTMLElement> implements ReactiveController {
|
|
10
|
-
host:
|
|
11
|
+
host: Grid;
|
|
11
12
|
resizeController: ResizeController;
|
|
12
13
|
rovingTabindexController: RovingTabindexController<T>;
|
|
13
14
|
get itemSize(): ItemSize;
|
|
@@ -16,7 +17,7 @@ export declare class GridController<T extends HTMLElement> implements ReactiveCo
|
|
|
16
17
|
get gap(): string | undefined;
|
|
17
18
|
private _gap;
|
|
18
19
|
_last: number;
|
|
19
|
-
constructor(host:
|
|
20
|
+
constructor(host: Grid, { elements, itemSize, gap, }: {
|
|
20
21
|
elements: () => T[];
|
|
21
22
|
itemSize: ItemSize | (() => ItemSize);
|
|
22
23
|
gap?: string | (() => string);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
import { ResizeController } from "@lit-labs/observers/resize_controller.js";
|
|
2
3
|
import { RovingTabindexController } from "@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";
|
|
3
4
|
export class GridController {
|
|
@@ -33,7 +34,7 @@ export class GridController {
|
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
36
|
this.handleFocusout = (event) => {
|
|
36
|
-
if (event.relatedTarget
|
|
37
|
+
if (!event.relatedTarget || !this.host.contains(event.relatedTarget)) {
|
|
37
38
|
this.host.tabIndex = 0;
|
|
38
39
|
}
|
|
39
40
|
};
|
|
@@ -54,14 +55,17 @@ export class GridController {
|
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
});
|
|
57
|
-
this.rovingTabindexController = new RovingTabindexController(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
this.rovingTabindexController = new RovingTabindexController(
|
|
59
|
+
this.host,
|
|
60
|
+
{
|
|
61
|
+
direction: "grid",
|
|
62
|
+
elements,
|
|
63
|
+
focusInIndex: () => {
|
|
64
|
+
const activeElement = this.host.getRootNode().activeElement;
|
|
65
|
+
return activeElement === this.host ? 0 : -1;
|
|
66
|
+
}
|
|
63
67
|
}
|
|
64
|
-
|
|
68
|
+
);
|
|
65
69
|
}
|
|
66
70
|
get itemSize() {
|
|
67
71
|
return this._itemSize();
|
|
@@ -105,11 +109,16 @@ export class GridController {
|
|
|
105
109
|
}
|
|
106
110
|
measureDirectionLength(contentRect) {
|
|
107
111
|
const gap = this.gap ? parseFloat(this.gap) : 0;
|
|
108
|
-
this.rovingTabindexController.directionLength = Math.floor(
|
|
112
|
+
this.rovingTabindexController.directionLength = Math.floor(
|
|
113
|
+
(contentRect.width - gap) / (this.itemSize.width + gap)
|
|
114
|
+
);
|
|
109
115
|
}
|
|
110
116
|
hostConnected() {
|
|
111
117
|
this.host.addEventListener("rangeChanged", this.handleRangeChanged);
|
|
112
|
-
this.host.addEventListener(
|
|
118
|
+
this.host.addEventListener(
|
|
119
|
+
"visibilityChanged",
|
|
120
|
+
this.handleVisibleChanged
|
|
121
|
+
);
|
|
113
122
|
this.host.addEventListener("focusin", this.handleFocusin);
|
|
114
123
|
this.host.addEventListener("focusout", this.handleFocusout);
|
|
115
124
|
this.host.tabIndex = 0;
|
|
@@ -117,7 +126,10 @@ export class GridController {
|
|
|
117
126
|
}
|
|
118
127
|
hostDisconnected() {
|
|
119
128
|
this.host.removeEventListener("rangeChanged", this.handleRangeChanged);
|
|
120
|
-
this.host.removeEventListener(
|
|
129
|
+
this.host.removeEventListener(
|
|
130
|
+
"visibilityChanged",
|
|
131
|
+
this.handleVisibleChanged
|
|
132
|
+
);
|
|
121
133
|
this.host.removeEventListener("focusin", this.handleFocusin);
|
|
122
134
|
this.host.removeEventListener("focusout", this.handleFocusout);
|
|
123
135
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["GridController.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { ReactiveController
|
|
5
|
-
"mappings": "AAaA;
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { ReactiveController } from 'lit';\n\nimport { ResizeController } from '@lit-labs/observers/resize_controller.js';\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\nimport {\n RangeChangedEvent,\n VisibilityChangedEvent,\n} from '@lit-labs/virtualizer/Virtualizer.js';\nimport { Grid } from './Grid.dev.js'\n\ninterface ItemSize {\n width: number;\n height: number;\n}\n\nexport class GridController<T extends HTMLElement>\n implements ReactiveController\n{\n host!: Grid;\n\n resizeController!: ResizeController;\n\n rovingTabindexController!: RovingTabindexController<T>;\n\n get itemSize(): ItemSize {\n return this._itemSize();\n }\n\n /* c8 ignore next 6 */\n private _itemSize(): ItemSize {\n return {\n width: 100,\n height: 100,\n };\n }\n\n // First visible element\n _first = 0;\n\n get gap(): string | undefined {\n return this._gap();\n }\n\n /* c8 ignore next 3 */\n private _gap(): string | undefined {\n return undefined;\n }\n\n // Last visible element\n _last = 0;\n\n constructor(\n host: Grid,\n {\n elements,\n itemSize,\n gap,\n }: {\n elements: () => T[];\n itemSize: ItemSize | (() => ItemSize);\n gap?: string | (() => string);\n }\n ) {\n this.host = host;\n this.host.addController(this);\n this.applyLayout(itemSize, gap);\n this.resizeController = new ResizeController(this.host, {\n callback: (entries: ResizeObserverEntry[]): void => {\n entries.forEach((entry) => {\n this.measureDirectionLength(entry.contentRect);\n });\n },\n });\n this.rovingTabindexController = new RovingTabindexController<T>(\n this.host,\n {\n direction: 'grid',\n elements,\n focusInIndex: () => {\n const activeElement = (this.host.getRootNode() as Document)\n .activeElement as HTMLElement;\n return activeElement === this.host ? 0 : -1;\n },\n }\n );\n }\n\n public focus(options?: FocusOptions): void {\n this.rovingTabindexController.focus(options);\n }\n\n protected applyLayout(\n itemSize: ItemSize | (() => ItemSize),\n gap?: string | (() => string)\n ): void {\n /* c8 ignore next 2 */\n if (typeof itemSize === 'object') {\n this._itemSize = () => itemSize;\n } else if (\n typeof itemSize === 'function' &&\n typeof itemSize() !== 'undefined'\n ) {\n this._itemSize = itemSize;\n }\n /* c8 ignore next 2 */\n if (typeof gap === 'string') {\n this._gap = () => gap;\n } else if (typeof gap === 'function') {\n this._gap = gap;\n }\n }\n\n public update({\n elements,\n itemSize,\n gap,\n }: {\n elements: () => T[];\n itemSize: ItemSize | (() => ItemSize);\n gap?: string | (() => string);\n }): void {\n this.rovingTabindexController.update({ elements });\n this.applyLayout(itemSize, gap);\n const contentRect = this.host.getBoundingClientRect();\n this.measureDirectionLength(contentRect);\n }\n\n protected measureDirectionLength(contentRect: DOMRect): void {\n const gap = this.gap ? parseFloat(this.gap) : 0;\n this.rovingTabindexController.directionLength = Math.floor(\n (contentRect.width - gap) / (this.itemSize.width + gap)\n );\n }\n\n protected handleFocusin = (event: FocusEvent): void => {\n const doCallbackAfterPaint = (cb: () => void): void => {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n cb();\n });\n });\n };\n const scrollToFirst = (): void => this.host.scrollToIndex(0);\n const focusIntoGrid = (): void => {\n this.focus();\n this.host.tabIndex = -1;\n };\n if ((event.target as HTMLElement) === this.host) {\n if (this._first > 0) {\n doCallbackAfterPaint(() => {\n scrollToFirst();\n doCallbackAfterPaint(focusIntoGrid);\n });\n } else {\n doCallbackAfterPaint(focusIntoGrid);\n }\n }\n };\n\n protected handleFocusout = (event: FocusEvent): void => {\n if (\n !event.relatedTarget ||\n !this.host.contains(event.relatedTarget as HTMLElement)\n ) {\n this.host.tabIndex = 0;\n }\n };\n\n protected handleRangeChanged = (event: RangeChangedEvent): void => {\n this.rovingTabindexController.clearElementCache(event.first);\n };\n\n protected handleVisibleChanged = (event: VisibilityChangedEvent): void => {\n this._first = event.first;\n this._last = event.last;\n };\n\n public hostConnected(): void {\n this.host.addEventListener('rangeChanged', this.handleRangeChanged);\n this.host.addEventListener(\n 'visibilityChanged',\n this.handleVisibleChanged\n );\n this.host.addEventListener('focusin', this.handleFocusin);\n this.host.addEventListener('focusout', this.handleFocusout);\n this.host.tabIndex = 0;\n this.host.style.setProperty('outline', 'none', 'important');\n }\n\n public hostDisconnected(): void {\n this.host.removeEventListener('rangeChanged', this.handleRangeChanged);\n this.host.removeEventListener(\n 'visibilityChanged',\n this.handleVisibleChanged\n );\n this.host.removeEventListener('focusin', this.handleFocusin);\n this.host.removeEventListener('focusout', this.handleFocusout);\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAaA,SAAS,wBAAwB;AACjC,SAAS,gCAAgC;AAYlC,aAAM,eAEb;AAAA,EAkCI,YACI,MACA;AAAA,IACI;AAAA,IACA;AAAA,IACA;AAAA,EACJ,GAKF;AAzBF,kBAAS;AAYT,iBAAQ;AAqFR,SAAU,gBAAgB,CAAC,UAA4B;AACnD,YAAM,uBAAuB,CAAC,OAAyB;AACnD,8BAAsB,MAAM;AACxB,gCAAsB,MAAM;AACxB,eAAG;AAAA,UACP,CAAC;AAAA,QACL,CAAC;AAAA,MACL;AACA,YAAM,gBAAgB,MAAY,KAAK,KAAK,cAAc,CAAC;AAC3D,YAAM,gBAAgB,MAAY;AAC9B,aAAK,MAAM;AACX,aAAK,KAAK,WAAW;AAAA,MACzB;AACA,UAAK,MAAM,WAA2B,KAAK,MAAM;AAC7C,YAAI,KAAK,SAAS,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MACA,KAAK;AAAA,IACT;AACA,SAAK,KAAK,oBAAoB,WAAW,KAAK,aAAa;AAC3D,SAAK,KAAK,oBAAoB,YAAY,KAAK,cAAc;AAAA,EACjE;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/GridController.js
CHANGED
|
@@ -1,125 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { RovingTabindexController } from "@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";
|
|
3
|
-
export class GridController {
|
|
4
|
-
constructor(host, {
|
|
5
|
-
elements,
|
|
6
|
-
itemSize,
|
|
7
|
-
gap
|
|
8
|
-
}) {
|
|
9
|
-
this._first = 0;
|
|
10
|
-
this._last = 0;
|
|
11
|
-
this.handleFocusin = (event) => {
|
|
12
|
-
const doCallbackAfterPaint = (cb) => {
|
|
13
|
-
requestAnimationFrame(() => {
|
|
14
|
-
requestAnimationFrame(() => {
|
|
15
|
-
cb();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
const scrollToFirst = () => this.host.scrollToIndex(0);
|
|
20
|
-
const focusIntoGrid = () => {
|
|
21
|
-
this.focus();
|
|
22
|
-
this.host.tabIndex = -1;
|
|
23
|
-
};
|
|
24
|
-
if (event.target === this.host) {
|
|
25
|
-
if (this._first > 0) {
|
|
26
|
-
doCallbackAfterPaint(() => {
|
|
27
|
-
scrollToFirst();
|
|
28
|
-
doCallbackAfterPaint(focusIntoGrid);
|
|
29
|
-
});
|
|
30
|
-
} else {
|
|
31
|
-
doCallbackAfterPaint(focusIntoGrid);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
this.handleFocusout = (event) => {
|
|
36
|
-
if (event.relatedTarget && !this.host.contains(event.relatedTarget)) {
|
|
37
|
-
this.host.tabIndex = 0;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
this.handleRangeChanged = (event) => {
|
|
41
|
-
this.rovingTabindexController.clearElementCache(event.first);
|
|
42
|
-
};
|
|
43
|
-
this.handleVisibleChanged = (event) => {
|
|
44
|
-
this._first = event.first;
|
|
45
|
-
this._last = event.last;
|
|
46
|
-
};
|
|
47
|
-
this.host = host;
|
|
48
|
-
this.host.addController(this);
|
|
49
|
-
this.applyLayout(itemSize, gap);
|
|
50
|
-
this.resizeController = new ResizeController(this.host, {
|
|
51
|
-
callback: (entries) => {
|
|
52
|
-
entries.forEach((entry) => {
|
|
53
|
-
this.measureDirectionLength(entry.contentRect);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
this.rovingTabindexController = new RovingTabindexController(this.host, {
|
|
58
|
-
direction: "grid",
|
|
59
|
-
elements,
|
|
60
|
-
focusInIndex: () => {
|
|
61
|
-
const activeElement = this.host.getRootNode().activeElement;
|
|
62
|
-
return activeElement === this.host ? 0 : -1;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
get itemSize() {
|
|
67
|
-
return this._itemSize();
|
|
68
|
-
}
|
|
69
|
-
_itemSize() {
|
|
70
|
-
return {
|
|
71
|
-
width: 100,
|
|
72
|
-
height: 100
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
get gap() {
|
|
76
|
-
return this._gap();
|
|
77
|
-
}
|
|
78
|
-
_gap() {
|
|
79
|
-
return void 0;
|
|
80
|
-
}
|
|
81
|
-
focus(options) {
|
|
82
|
-
this.rovingTabindexController.focus(options);
|
|
83
|
-
}
|
|
84
|
-
applyLayout(itemSize, gap) {
|
|
85
|
-
if (typeof itemSize === "object") {
|
|
86
|
-
this._itemSize = () => itemSize;
|
|
87
|
-
} else if (typeof itemSize === "function" && typeof itemSize() !== "undefined") {
|
|
88
|
-
this._itemSize = itemSize;
|
|
89
|
-
}
|
|
90
|
-
if (typeof gap === "string") {
|
|
91
|
-
this._gap = () => gap;
|
|
92
|
-
} else if (typeof gap === "function") {
|
|
93
|
-
this._gap = gap;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
update({
|
|
97
|
-
elements,
|
|
98
|
-
itemSize,
|
|
99
|
-
gap
|
|
100
|
-
}) {
|
|
101
|
-
this.rovingTabindexController.update({ elements });
|
|
102
|
-
this.applyLayout(itemSize, gap);
|
|
103
|
-
const contentRect = this.host.getBoundingClientRect();
|
|
104
|
-
this.measureDirectionLength(contentRect);
|
|
105
|
-
}
|
|
106
|
-
measureDirectionLength(contentRect) {
|
|
107
|
-
const gap = this.gap ? parseFloat(this.gap) : 0;
|
|
108
|
-
this.rovingTabindexController.directionLength = Math.floor((contentRect.width - gap) / (this.itemSize.width + gap));
|
|
109
|
-
}
|
|
110
|
-
hostConnected() {
|
|
111
|
-
this.host.addEventListener("rangeChanged", this.handleRangeChanged);
|
|
112
|
-
this.host.addEventListener("visibilityChanged", this.handleVisibleChanged);
|
|
113
|
-
this.host.addEventListener("focusin", this.handleFocusin);
|
|
114
|
-
this.host.addEventListener("focusout", this.handleFocusout);
|
|
115
|
-
this.host.tabIndex = 0;
|
|
116
|
-
this.host.style.setProperty("outline", "none", "important");
|
|
117
|
-
}
|
|
118
|
-
hostDisconnected() {
|
|
119
|
-
this.host.removeEventListener("rangeChanged", this.handleRangeChanged);
|
|
120
|
-
this.host.removeEventListener("visibilityChanged", this.handleVisibleChanged);
|
|
121
|
-
this.host.removeEventListener("focusin", this.handleFocusin);
|
|
122
|
-
this.host.removeEventListener("focusout", this.handleFocusout);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
1
|
+
"use strict";import{ResizeController as r}from"@lit-labs/observers/resize_controller.js";import{RovingTabindexController as h}from"@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";export class GridController{constructor(t,{elements:e,itemSize:n,gap:i}){this._first=0;this._last=0;this.handleFocusin=t=>{const e=o=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{o()})})},n=()=>this.host.scrollToIndex(0),i=()=>{this.focus(),this.host.tabIndex=-1};t.target===this.host&&(this._first>0?e(()=>{n(),e(i)}):e(i))};this.handleFocusout=t=>{(!t.relatedTarget||!this.host.contains(t.relatedTarget))&&(this.host.tabIndex=0)};this.handleRangeChanged=t=>{this.rovingTabindexController.clearElementCache(t.first)};this.handleVisibleChanged=t=>{this._first=t.first,this._last=t.last};this.host=t,this.host.addController(this),this.applyLayout(n,i),this.resizeController=new r(this.host,{callback:o=>{o.forEach(s=>{this.measureDirectionLength(s.contentRect)})}}),this.rovingTabindexController=new h(this.host,{direction:"grid",elements:e,focusInIndex:()=>this.host.getRootNode().activeElement===this.host?0:-1})}get itemSize(){return this._itemSize()}_itemSize(){return{width:100,height:100}}get gap(){return this._gap()}_gap(){}focus(t){this.rovingTabindexController.focus(t)}applyLayout(t,e){typeof t=="object"?this._itemSize=()=>t:typeof t=="function"&&typeof t()!="undefined"&&(this._itemSize=t),typeof e=="string"?this._gap=()=>e:typeof e=="function"&&(this._gap=e)}update({elements:t,itemSize:e,gap:n}){this.rovingTabindexController.update({elements:t}),this.applyLayout(e,n);const i=this.host.getBoundingClientRect();this.measureDirectionLength(i)}measureDirectionLength(t){const e=this.gap?parseFloat(this.gap):0;this.rovingTabindexController.directionLength=Math.floor((t.width-e)/(this.itemSize.width+e))}hostConnected(){this.host.addEventListener("rangeChanged",this.handleRangeChanged),this.host.addEventListener("visibilityChanged",this.handleVisibleChanged),this.host.addEventListener("focusin",this.handleFocusin),this.host.addEventListener("focusout",this.handleFocusout),this.host.tabIndex=0,this.host.style.setProperty("outline","none","important")}hostDisconnected(){this.host.removeEventListener("rangeChanged",this.handleRangeChanged),this.host.removeEventListener("visibilityChanged",this.handleVisibleChanged),this.host.removeEventListener("focusin",this.handleFocusin),this.host.removeEventListener("focusout",this.handleFocusout)}}
|
|
125
2
|
//# sourceMappingURL=GridController.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["GridController.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { ReactiveController
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport type { ReactiveController } from 'lit';\n\nimport { ResizeController } from '@lit-labs/observers/resize_controller.js';\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\nimport {\n RangeChangedEvent,\n VisibilityChangedEvent,\n} from '@lit-labs/virtualizer/Virtualizer.js';\nimport { Grid } from './Grid.js';\n\ninterface ItemSize {\n width: number;\n height: number;\n}\n\nexport class GridController<T extends HTMLElement>\n implements ReactiveController\n{\n host!: Grid;\n\n resizeController!: ResizeController;\n\n rovingTabindexController!: RovingTabindexController<T>;\n\n get itemSize(): ItemSize {\n return this._itemSize();\n }\n\n /* c8 ignore next 6 */\n private _itemSize(): ItemSize {\n return {\n width: 100,\n height: 100,\n };\n }\n\n // First visible element\n _first = 0;\n\n get gap(): string | undefined {\n return this._gap();\n }\n\n /* c8 ignore next 3 */\n private _gap(): string | undefined {\n return undefined;\n }\n\n // Last visible element\n _last = 0;\n\n constructor(\n host: Grid,\n {\n elements,\n itemSize,\n gap,\n }: {\n elements: () => T[];\n itemSize: ItemSize | (() => ItemSize);\n gap?: string | (() => string);\n }\n ) {\n this.host = host;\n this.host.addController(this);\n this.applyLayout(itemSize, gap);\n this.resizeController = new ResizeController(this.host, {\n callback: (entries: ResizeObserverEntry[]): void => {\n entries.forEach((entry) => {\n this.measureDirectionLength(entry.contentRect);\n });\n },\n });\n this.rovingTabindexController = new RovingTabindexController<T>(\n this.host,\n {\n direction: 'grid',\n elements,\n focusInIndex: () => {\n const activeElement = (this.host.getRootNode() as Document)\n .activeElement as HTMLElement;\n return activeElement === this.host ? 0 : -1;\n },\n }\n );\n }\n\n public focus(options?: FocusOptions): void {\n this.rovingTabindexController.focus(options);\n }\n\n protected applyLayout(\n itemSize: ItemSize | (() => ItemSize),\n gap?: string | (() => string)\n ): void {\n /* c8 ignore next 2 */\n if (typeof itemSize === 'object') {\n this._itemSize = () => itemSize;\n } else if (\n typeof itemSize === 'function' &&\n typeof itemSize() !== 'undefined'\n ) {\n this._itemSize = itemSize;\n }\n /* c8 ignore next 2 */\n if (typeof gap === 'string') {\n this._gap = () => gap;\n } else if (typeof gap === 'function') {\n this._gap = gap;\n }\n }\n\n public update({\n elements,\n itemSize,\n gap,\n }: {\n elements: () => T[];\n itemSize: ItemSize | (() => ItemSize);\n gap?: string | (() => string);\n }): void {\n this.rovingTabindexController.update({ elements });\n this.applyLayout(itemSize, gap);\n const contentRect = this.host.getBoundingClientRect();\n this.measureDirectionLength(contentRect);\n }\n\n protected measureDirectionLength(contentRect: DOMRect): void {\n const gap = this.gap ? parseFloat(this.gap) : 0;\n this.rovingTabindexController.directionLength = Math.floor(\n (contentRect.width - gap) / (this.itemSize.width + gap)\n );\n }\n\n protected handleFocusin = (event: FocusEvent): void => {\n const doCallbackAfterPaint = (cb: () => void): void => {\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n cb();\n });\n });\n };\n const scrollToFirst = (): void => this.host.scrollToIndex(0);\n const focusIntoGrid = (): void => {\n this.focus();\n this.host.tabIndex = -1;\n };\n if ((event.target as HTMLElement) === this.host) {\n if (this._first > 0) {\n doCallbackAfterPaint(() => {\n scrollToFirst();\n doCallbackAfterPaint(focusIntoGrid);\n });\n } else {\n doCallbackAfterPaint(focusIntoGrid);\n }\n }\n };\n\n protected handleFocusout = (event: FocusEvent): void => {\n if (\n !event.relatedTarget ||\n !this.host.contains(event.relatedTarget as HTMLElement)\n ) {\n this.host.tabIndex = 0;\n }\n };\n\n protected handleRangeChanged = (event: RangeChangedEvent): void => {\n this.rovingTabindexController.clearElementCache(event.first);\n };\n\n protected handleVisibleChanged = (event: VisibilityChangedEvent): void => {\n this._first = event.first;\n this._last = event.last;\n };\n\n public hostConnected(): void {\n this.host.addEventListener('rangeChanged', this.handleRangeChanged);\n this.host.addEventListener(\n 'visibilityChanged',\n this.handleVisibleChanged\n );\n this.host.addEventListener('focusin', this.handleFocusin);\n this.host.addEventListener('focusout', this.handleFocusout);\n this.host.tabIndex = 0;\n this.host.style.setProperty('outline', 'none', 'important');\n }\n\n public hostDisconnected(): void {\n this.host.removeEventListener('rangeChanged', this.handleRangeChanged);\n this.host.removeEventListener(\n 'visibilityChanged',\n this.handleVisibleChanged\n );\n this.host.removeEventListener('focusin', this.handleFocusin);\n this.host.removeEventListener('focusout', this.handleFocusout);\n }\n}\n"],
|
|
5
|
+
"mappings": "aAaA,OAAS,oBAAAA,MAAwB,2CACjC,OAAS,4BAAAC,MAAgC,sEAYlC,aAAM,cAEb,CAkCI,YACIC,EACA,CACI,SAAAC,EACA,SAAAC,EACA,IAAAC,CACJ,EAKF,CAzBF,YAAS,EAYT,WAAQ,EAqFR,KAAU,cAAiBC,GAA4B,CACnD,MAAMC,EAAwBC,GAAyB,CACnD,sBAAsB,IAAM,CACxB,sBAAsB,IAAM,CACxBA,EAAG,CACP,CAAC,CACL,CAAC,CACL,EACMC,EAAgB,IAAY,KAAK,KAAK,cAAc,CAAC,EACrDC,EAAgB,IAAY,CAC9B,KAAK,MAAM,EACX,KAAK,KAAK,SAAW,EACzB,EACKJ,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IAAMA,EACX,OAAOA,GAAQ,aACtB,KAAK,KAAOA,EAEpB,CAEO,OAAO,CACV,SAAAF,EACA,SAAAC,EACA,IAAAC,CACJ,EAIS,CACL,KAAK,yBAAyB,OAAO,CAAE,SAAAF,CAAS,CAAC,EACjD,KAAK,YAAYC,EAAUC,CAAG,EAC9B,MAAMS,EAAc,KAAK,KAAK,sBAAsB,EACpD,KAAK,uBAAuBA,CAAW,CAC3C,CAEU,uBAAuBA,EAA4B,CACzD,MAAMT,EAAM,KAAK,IAAM,WAAW,KAAK,GAAG,EAAI,EAC9C,KAAK,yBAAyB,gBAAkB,KAAK,OAChDS,EAAY,MAAQT,IAAQ,KAAK,SAAS,MAAQA,EACvD,CACJ,CA6CO,eAAsB,CACzB,KAAK,KAAK,iBAAiB,eAAgB,KAAK,kBAAkB,EAClE,KAAK,KAAK,iBACN,oBACA,KAAK,oBACT,EACA,KAAK,KAAK,iBAAiB,UAAW,KAAK,aAAa,EACxD,KAAK,KAAK,iBAAiB,WAAY,KAAK,cAAc,EAC1D,KAAK,KAAK,SAAW,EACrB,KAAK,KAAK,MAAM,YAAY,UAAW,OAAQ,WAAW,CAC9D,CAEO,kBAAyB,CAC5B,KAAK,KAAK,oBAAoB,eAAgB,KAAK,kBAAkB,EACrE,KAAK,KAAK,oBACN,oBACA,KAAK,oBACT,EACA,KAAK,KAAK,oBAAoB,UAAW,KAAK,aAAa,EAC3D,KAAK,KAAK,oBAAoB,WAAY,KAAK,cAAc,CACjE,CACJ",
|
|
6
|
+
"names": ["ResizeController", "RovingTabindexController", "host", "elements", "itemSize", "gap", "event", "doCallbackAfterPaint", "cb", "scrollToFirst", "focusIntoGrid", "entries", "entry", "options", "contentRect"]
|
|
7
7
|
}
|
package/src/grid.css.dev.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
import { css } from "@spectrum-web-components/base";
|
|
2
3
|
const styles = css`
|
|
3
|
-
:host{contain:strict;display:block;position:relative}
|
|
4
|
+
:host{contain:strict;display:block;pointer-events:none;position:relative}::slotted(*){pointer-events:all}
|
|
4
5
|
`;
|
|
5
6
|
export default styles;
|
|
6
7
|
//# sourceMappingURL=grid.css.dev.js.map
|
package/src/grid.css.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["grid.css.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{contain:strict;display:block;position:relative}\n`;\nexport default styles;"],
|
|
5
|
-
"mappings": "AAWA;
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{contain:strict;display:block;pointer-events:none;position:relative}::slotted(*){pointer-events:all}\n`;\nexport default styles;"],
|
|
5
|
+
"mappings": ";AAWA,SAAS,WAAW;AACpB,MAAM,SAAS;AAAA;AAAA;AAGf,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/grid.css.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`;
|
|
5
|
-
export default styles;
|
|
1
|
+
"use strict";import{css as t}from"@spectrum-web-components/base";const e=t`
|
|
2
|
+
:host{contain:strict;display:block;pointer-events:none;position:relative}::slotted(*){pointer-events:all}
|
|
3
|
+
`;export default e;
|
|
6
4
|
//# sourceMappingURL=grid.css.js.map
|
package/src/grid.css.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["grid.css.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{contain:strict;display:block;position:relative}\n`;\nexport default styles;"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{contain:strict;display:block;pointer-events:none;position:relative}::slotted(*){pointer-events:all}\n`;\nexport default styles;"],
|
|
5
|
+
"mappings": "aAWA,OAAS,OAAAA,MAAW,gCACpB,MAAMC,EAASD;AAAA;AAAA,EAGf,eAAeC",
|
|
6
|
+
"names": ["css", "styles"]
|
|
7
7
|
}
|
package/src/index.dev.js
CHANGED
package/src/index.dev.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nexport * from './Grid.dev.js'\n"],
|
|
5
|
-
"mappings": "AAYA;",
|
|
5
|
+
"mappings": ";AAYA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
"use strict";export*from"./Grid.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nexport * from './Grid.js';\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "aAYA,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/stories/grid.stories.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
import { html } from "@spectrum-web-components/base";
|
|
2
3
|
import "@spectrum-web-components/grid/sp-grid.js";
|
|
3
4
|
import "@spectrum-web-components/action-bar/sp-action-bar.js";
|
|
@@ -49,7 +50,10 @@ export const Default = () => {
|
|
|
49
50
|
const selected = document.querySelector(".selected");
|
|
50
51
|
const ids = document.querySelector(".ids");
|
|
51
52
|
actionbar.open = !!event.currentTarget.selected.length;
|
|
52
|
-
actionbar.style.setProperty(
|
|
53
|
+
actionbar.style.setProperty(
|
|
54
|
+
"display",
|
|
55
|
+
!!event.currentTarget.selected.length ? "flex" : "none"
|
|
56
|
+
);
|
|
53
57
|
selected.textContent = "" + event.currentTarget.selected.length;
|
|
54
58
|
ids.textContent = "" + event.currentTarget.selected.map((selection) => selection.id).join(", ");
|
|
55
59
|
};
|
|
@@ -118,7 +122,10 @@ export const sized = () => {
|
|
|
118
122
|
const selected = document.querySelector(".selected");
|
|
119
123
|
const ids = document.querySelector(".ids");
|
|
120
124
|
actionbar.open = !!event.currentTarget.selected.length;
|
|
121
|
-
actionbar.style.setProperty(
|
|
125
|
+
actionbar.style.setProperty(
|
|
126
|
+
"display",
|
|
127
|
+
!!event.currentTarget.selected.length ? "flex" : "none"
|
|
128
|
+
);
|
|
122
129
|
selected.textContent = "" + event.currentTarget.selected.length;
|
|
123
130
|
ids.textContent = "" + event.currentTarget.selected.map((selection) => selection.id).join(", ");
|
|
124
131
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["grid.stories.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { html, TemplateResult } from '@spectrum-web-components/base';\n\nimport '@spectrum-web-components/grid/sp-grid.js';\nimport '@spectrum-web-components/action-bar/sp-action-bar.js';\nimport '@spectrum-web-components/card/sp-card.js';\nimport '@spectrum-web-components/checkbox/sp-checkbox.js';\nimport '@spectrum-web-components/action-button/sp-action-button.js';\nimport '@spectrum-web-components/action-group/sp-action-group.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-more.js';\nimport type { ActionBar } from '@spectrum-web-components/action-bar';\nimport type { Grid } from '@spectrum-web-components/grid';\n\nexport default {\n title: 'Grid',\n component: 'sp-grid',\n};\n\ninterface Item extends Record<string, unknown> {\n id: number;\n}\n\nfunction generateItems(count: number): Item[] {\n const items: Item[] = [];\n while (count) {\n count -= 1;\n items.unshift({ id: count });\n }\n return items;\n}\n\nexport const Default = (): TemplateResult => {\n const items = generateItems(1000);\n\n const renderItem = (\n item: Item,\n index: number,\n selected: boolean\n ): TemplateResult => {\n return html`\n <sp-card\n toggles\n variant=\"quiet\"\n heading=\"Card Heading ${item.id}\"\n subheading=\"JPG Photo\"\n style=\"contain: strict; padding: 1px;\"\n value=\"card-${item.id}\"\n .selected=${selected}\n key=${index}\n >\n <img\n alt=\"\"\n slot=\"preview\"\n src=\"https://picsum.photos/id/${item.id}/200/300\"\n decoding=\"async\"\n />\n <div slot=\"description\">10/15/18</div>\n <div slot=\"footer\">Footer</div>\n </sp-card>\n `;\n };\n const handleChange = (event: Event & { currentTarget: Grid }): void => {\n const actionbar = document.querySelector('sp-action-bar') as ActionBar;\n const selected = document.querySelector('.selected') as HTMLElement;\n const ids = document.querySelector('.ids') as HTMLElement;\n actionbar.open = !!event.currentTarget.selected.length;\n actionbar.style.setProperty(\n 'display',\n !!event.currentTarget.selected.length ? 'flex' : 'none'\n );\n selected.textContent = '' + event.currentTarget.selected.length;\n ids.textContent =\n '' +\n event.currentTarget.selected\n .map((selection) => selection.id)\n .join(', ');\n };\n const handleActionBarChange = (event: Event): void => {\n event.preventDefault();\n const grid = document.querySelector('sp-grid') as Grid;\n const actionbar = document.querySelector('sp-action-bar') as ActionBar;\n actionbar.open = false;\n grid.selected = [];\n };\n return html`\n <h1>Random before content that is focusable</h1>\n <input id=\"first-input\" />\n <sp-grid\n @change=${handleChange}\n .items=${items}\n .focusableSelector=${'sp-card'}\n .renderItem=${renderItem}\n ></sp-grid>\n <sp-action-bar variant=\"fixed\" style=\"display: none\">\n <sp-checkbox @click=${handleActionBarChange} checked>\n <span class=\"selected\"></span>\n Selected\n <span class=\"ids\"></span>\n </sp-checkbox>\n <sp-action-group quiet>\n <sp-action-button>\n <sp-icon-edit slot=\"icon\" label=\"Edit\"></sp-icon-edit>\n </sp-action-button>\n <sp-action-button>\n <sp-icon-more slot=\"icon\" label=\"More\"></sp-icon-more>\n </sp-action-button>\n </sp-action-group>\n </sp-action-bar>\n <h2>Random after content that is focusable</h2>\n <input id=\"last-input\" />\n `;\n};\n\nexport const sized = (): TemplateResult => {\n const items = generateItems(1000);\n\n const renderItem = (\n item: Item,\n index: number,\n selected: boolean\n ): TemplateResult => {\n return html`\n <sp-card\n toggles\n variant=\"quiet\"\n heading=\"Card Heading ${item.id}\"\n subheading=\"JPG Photo\"\n style=\"contain: strict; padding: 1px;\"\n value=\"card-${item.id}\"\n .selected=${selected}\n key=${index}\n >\n <img\n alt=\"\"\n slot=\"preview\"\n src=\"https://picsum.photos/id/${item.id}/200/300\"\n decoding=\"async\"\n />\n <div slot=\"description\">10/15/18</div>\n <div slot=\"footer\">Footer</div>\n </sp-card>\n `;\n };\n const handleChange = (event: Event & { currentTarget: Grid }): void => {\n const actionbar = document.querySelector('sp-action-bar') as ActionBar;\n const selected = document.querySelector('.selected') as HTMLElement;\n const ids = document.querySelector('.ids') as HTMLElement;\n actionbar.open = !!event.currentTarget.selected.length;\n actionbar.style.setProperty(\n 'display',\n !!event.currentTarget.selected.length ? 'flex' : 'none'\n );\n selected.textContent = '' + event.currentTarget.selected.length;\n ids.textContent =\n '' +\n event.currentTarget.selected\n .map((selection) => selection.id)\n .join(', ');\n };\n const handleActionBarChange = (event: Event): void => {\n event.preventDefault();\n const grid = document.querySelector('sp-grid') as Grid;\n const actionbar = document.querySelector('sp-action-bar') as ActionBar;\n actionbar.open = false;\n grid.selected = [];\n };\n return html`\n <h1>Random before content that is focusable</h1>\n <input id=\"first-input\" />\n <sp-grid\n @change=${handleChange}\n .items=${items}\n .focusableSelector=${'sp-card'}\n .renderItem=${renderItem}\n .itemSize=${{\n width: 200,\n height: 300,\n }}\n .gap=${'10px'}\n ></sp-grid>\n <sp-action-bar variant=\"fixed\" style=\"display: none\">\n <sp-checkbox @click=${handleActionBarChange} checked>\n <span class=\"selected\"></span>\n Selected\n <span class=\"ids\"></span>\n </sp-checkbox>\n <sp-action-group quiet>\n <sp-action-button>\n <sp-icon-edit slot=\"icon\" label=\"Edit\"></sp-icon-edit>\n </sp-action-button>\n <sp-action-button>\n <sp-icon-more slot=\"icon\" label=\"More\"></sp-icon-more>\n </sp-action-button>\n </sp-action-group>\n </sp-action-bar>\n <h2>Random after content that is focusable</h2>\n <input id=\"last-input\" />\n `;\n};\n"],
|
|
5
|
-
"mappings": "AAYA;
|
|
5
|
+
"mappings": ";AAYA,SAAS,YAA4B;AAErC,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AAIP,eAAe;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AACf;AAMA,SAAS,cAAc,OAAuB;AAC1C,QAAM,QAAgB,CAAC;AACvB,SAAO,OAAO;AACV,aAAS;AACT,UAAM,QAAQ,EAAE,IAAI,MAAM,CAAC;AAAA,EAC/B;AACA,SAAO;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AAAA;AAAA,wCAIyB,KAAK;AAAA;AAAA;AAAA,8BAGf,KAAK;AAAA,4BACP;AAAA,sBACN;AAAA;AAAA;AAAA;AAAA;AAAA,oDAK8B,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOrD;AACA,QAAM,eAAe,CAAC,UAAiD;AACnE,UAAM,YAAY,SAAS,cAAc,eAAe;AACxD,UAAM,WAAW,SAAS,cAAc,WAAW;AACnD,UAAM,MAAM,SAAS,cAAc,MAAM;AACzC,cAAU,OAAO,CAAC,CAAC,MAAM,cAAc,SAAS;AAChD,cAAU,MAAM;AAAA,MACZ;AAAA,MACA,CAAC,CAAC,MAAM,cAAc,SAAS,SAAS,SAAS;AAAA,IACrD;AACA,aAAS,cAAc,KAAK,MAAM,cAAc,SAAS;AACzD,QAAI,cACA,KACA,MAAM,cAAc,SACf,IAAI,CAAC,cAAc,UAAU,EAAE,EAC/B,KAAK,IAAI;AAAA,EACtB;AACA,QAAM,wBAAwB,CAAC,UAAuB;AAClD,UAAM,eAAe;AACrB,UAAM,OAAO,SAAS,cAAc,SAAS;AAC7C,UAAM,YAAY,SAAS,cAAc,eAAe;AACxD,cAAU,OAAO;AACjB,SAAK,WAAW,CAAC;AAAA,EACrB;AACA,SAAO;AAAA;AAAA;AAAA;AAAA,sBAIW;AAAA,qBACD;AAAA,iCACY;AAAA,0BACP;AAAA,wBACF;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,EACZ;AAAA,mBACO;AAAA;AAAA;AAAA,kCAGe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBlC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["basic-test.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '@spectrum-web-components/grid/sp-grid.js';\nimport { html } from '@spectrum-web-components/base';\nimport { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';\n\nmeasureFixtureCreation(html`\n <sp-grid></sp-grid>\n`);\n"],
|
|
5
|
-
"mappings": "AAYA;
|
|
5
|
+
"mappings": ";AAYA,OAAO;AACP,SAAS,YAAY;AACrB,SAAS,8BAA8B;AAEvC,uBAAuB;AAAA;AAAA,CAEtB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/test/grid.test.js
CHANGED
|
@@ -1,37 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
import { elementUpdated, expect, fixture, nextFrame } from "@open-wc/testing";
|
|
2
3
|
import { html } from "@spectrum-web-components/base";
|
|
4
|
+
import "@spectrum-web-components/theme/sp-theme.js";
|
|
5
|
+
import "@spectrum-web-components/theme/scale-medium.js";
|
|
6
|
+
import "@spectrum-web-components/theme/theme-light.js";
|
|
3
7
|
import "@spectrum-web-components/grid/sp-grid.js";
|
|
4
8
|
import { Default } from "../stories/grid.stories.js";
|
|
5
|
-
import { sendKeys } from "@web/test-runner-commands";
|
|
9
|
+
import { sendKeys, sendMouse } from "@web/test-runner-commands";
|
|
6
10
|
import { testForLitDevWarnings } from "../../../test/testing-helpers.js";
|
|
7
11
|
describe("Grid", () => {
|
|
8
|
-
testForLitDevWarnings(
|
|
12
|
+
testForLitDevWarnings(
|
|
13
|
+
async () => await fixture(
|
|
14
|
+
html`
|
|
9
15
|
<div>${Default()}</div>
|
|
10
|
-
`
|
|
16
|
+
`
|
|
17
|
+
)
|
|
18
|
+
);
|
|
11
19
|
it("loads default grid accessibly", async () => {
|
|
12
|
-
const test = await fixture(
|
|
20
|
+
const test = await fixture(
|
|
21
|
+
html`
|
|
13
22
|
<div>${Default()}</div>
|
|
14
|
-
`
|
|
23
|
+
`
|
|
24
|
+
);
|
|
15
25
|
const el = test.querySelector("sp-grid");
|
|
16
26
|
await elementUpdated(el);
|
|
17
27
|
await expect(el).to.be.accessible();
|
|
18
28
|
});
|
|
19
29
|
it("accepts focus", async () => {
|
|
20
|
-
const test = await fixture(
|
|
30
|
+
const test = await fixture(
|
|
31
|
+
html`
|
|
21
32
|
<div>${Default()}</div>
|
|
22
|
-
`
|
|
33
|
+
`
|
|
34
|
+
);
|
|
23
35
|
const el = test.querySelector("sp-grid");
|
|
24
36
|
await elementUpdated(el);
|
|
25
37
|
expect(el.tabIndex).to.equal(0);
|
|
26
38
|
el.focus();
|
|
27
39
|
await nextFrame();
|
|
28
40
|
await nextFrame();
|
|
29
|
-
expect(
|
|
41
|
+
expect(
|
|
42
|
+
el.querySelector(el.focusableSelector) === document.activeElement
|
|
43
|
+
).to.be.true;
|
|
44
|
+
});
|
|
45
|
+
it("does not focus when clicking grid", async () => {
|
|
46
|
+
const test = await fixture(
|
|
47
|
+
html`
|
|
48
|
+
<sp-theme color="light" scale="medium">${Default()}</sp-theme>
|
|
49
|
+
`
|
|
50
|
+
);
|
|
51
|
+
const el = test.querySelector("sp-grid");
|
|
52
|
+
await elementUpdated(el);
|
|
53
|
+
expect(el.tabIndex).to.equal(0);
|
|
54
|
+
el.focus();
|
|
55
|
+
await nextFrame();
|
|
56
|
+
await nextFrame();
|
|
57
|
+
const firstItem = el.querySelector(el.focusableSelector);
|
|
58
|
+
expect(firstItem === document.activeElement).to.be.true;
|
|
59
|
+
const firstRect = firstItem == null ? void 0 : firstItem.getBoundingClientRect();
|
|
60
|
+
const position = [
|
|
61
|
+
Math.round(firstRect.x + firstRect.width + 2),
|
|
62
|
+
Math.round(firstRect.y + 2)
|
|
63
|
+
];
|
|
64
|
+
await sendMouse({
|
|
65
|
+
type: "click",
|
|
66
|
+
position
|
|
67
|
+
});
|
|
68
|
+
await nextFrame();
|
|
69
|
+
await nextFrame();
|
|
70
|
+
expect(
|
|
71
|
+
el.querySelector(el.focusableSelector) === document.activeElement
|
|
72
|
+
).to.be.false;
|
|
30
73
|
});
|
|
31
74
|
it("allows to tab in and out", async () => {
|
|
32
|
-
const test = await fixture(
|
|
75
|
+
const test = await fixture(
|
|
76
|
+
html`
|
|
33
77
|
<div>${Default()}</div>
|
|
34
|
-
`
|
|
78
|
+
`
|
|
79
|
+
);
|
|
35
80
|
const el = test.querySelector("sp-grid");
|
|
36
81
|
const firstInput = test.querySelector("#first-input");
|
|
37
82
|
const lastInput = test.querySelector("#last-input");
|
|
@@ -45,7 +90,9 @@ describe("Grid", () => {
|
|
|
45
90
|
});
|
|
46
91
|
await nextFrame();
|
|
47
92
|
await nextFrame();
|
|
48
|
-
expect(
|
|
93
|
+
expect(
|
|
94
|
+
el.querySelector(el.focusableSelector) === document.activeElement
|
|
95
|
+
).to.be.true;
|
|
49
96
|
expect(el.tabIndex).to.equal(-1);
|
|
50
97
|
await sendKeys({
|
|
51
98
|
press: "Tab"
|
|
@@ -62,13 +109,17 @@ describe("Grid", () => {
|
|
|
62
109
|
await nextFrame();
|
|
63
110
|
await nextFrame();
|
|
64
111
|
await nextFrame();
|
|
65
|
-
expect(
|
|
112
|
+
expect(
|
|
113
|
+
el.querySelector(el.focusableSelector) === document.activeElement
|
|
114
|
+
).to.be.true;
|
|
66
115
|
expect(el.tabIndex).to.equal(-1);
|
|
67
116
|
});
|
|
68
117
|
it("manages roving tabindex", async () => {
|
|
69
|
-
const test = await fixture(
|
|
118
|
+
const test = await fixture(
|
|
119
|
+
html`
|
|
70
120
|
<div>${Default()}</div>
|
|
71
|
-
`
|
|
121
|
+
`
|
|
122
|
+
);
|
|
72
123
|
const el = test.querySelector("sp-grid");
|
|
73
124
|
await elementUpdated(el);
|
|
74
125
|
expect(el.tabIndex).to.equal(0);
|
|
@@ -82,21 +133,27 @@ describe("Grid", () => {
|
|
|
82
133
|
await sendKeys({
|
|
83
134
|
press: "ArrowRight"
|
|
84
135
|
});
|
|
85
|
-
focused = el.querySelector(
|
|
136
|
+
focused = el.querySelector(
|
|
137
|
+
`${el.focusableSelector}:nth-child(2)`
|
|
138
|
+
);
|
|
86
139
|
await elementUpdated(focused);
|
|
87
140
|
expect(focused === document.activeElement).to.be.true;
|
|
88
141
|
expect(focused.focused).to.be.true;
|
|
89
142
|
await sendKeys({
|
|
90
143
|
press: "ArrowDown"
|
|
91
144
|
});
|
|
92
|
-
focused = el.querySelector(
|
|
145
|
+
focused = el.querySelector(
|
|
146
|
+
`${el.focusableSelector}:nth-child(5)`
|
|
147
|
+
);
|
|
93
148
|
await elementUpdated(focused);
|
|
94
149
|
expect(focused === document.activeElement).to.be.true;
|
|
95
150
|
expect(focused.focused).to.be.true;
|
|
96
151
|
await sendKeys({
|
|
97
152
|
press: "ArrowLeft"
|
|
98
153
|
});
|
|
99
|
-
focused = el.querySelector(
|
|
154
|
+
focused = el.querySelector(
|
|
155
|
+
`${el.focusableSelector}:nth-child(4)`
|
|
156
|
+
);
|
|
100
157
|
await elementUpdated(focused);
|
|
101
158
|
expect(focused === document.activeElement).to.be.true;
|
|
102
159
|
expect(focused.focused).to.be.true;
|
|
@@ -109,9 +166,11 @@ describe("Grid", () => {
|
|
|
109
166
|
expect(focused.focused).to.be.true;
|
|
110
167
|
});
|
|
111
168
|
it("manages selection", async () => {
|
|
112
|
-
const test = await fixture(
|
|
169
|
+
const test = await fixture(
|
|
170
|
+
html`
|
|
113
171
|
<div>${Default()}</div>
|
|
114
|
-
`
|
|
172
|
+
`
|
|
173
|
+
);
|
|
115
174
|
const el = test.querySelector("sp-grid");
|
|
116
175
|
await elementUpdated(el);
|
|
117
176
|
expect(el.tabIndex).to.equal(0);
|
|
@@ -125,7 +184,9 @@ describe("Grid", () => {
|
|
|
125
184
|
await sendKeys({
|
|
126
185
|
press: "ArrowRight"
|
|
127
186
|
});
|
|
128
|
-
focused = el.querySelector(
|
|
187
|
+
focused = el.querySelector(
|
|
188
|
+
`${el.focusableSelector}:nth-child(2)`
|
|
189
|
+
);
|
|
129
190
|
await elementUpdated(focused);
|
|
130
191
|
expect(focused === document.activeElement).to.be.true;
|
|
131
192
|
expect(focused.focused).to.be.true;
|
|
@@ -137,7 +198,9 @@ describe("Grid", () => {
|
|
|
137
198
|
await sendKeys({
|
|
138
199
|
press: "ArrowDown"
|
|
139
200
|
});
|
|
140
|
-
focused = el.querySelector(
|
|
201
|
+
focused = el.querySelector(
|
|
202
|
+
`${el.focusableSelector}:nth-child(5)`
|
|
203
|
+
);
|
|
141
204
|
await elementUpdated(focused);
|
|
142
205
|
expect(focused === document.activeElement).to.be.true;
|
|
143
206
|
expect(focused.focused).to.be.true;
|
|
@@ -149,7 +212,9 @@ describe("Grid", () => {
|
|
|
149
212
|
await sendKeys({
|
|
150
213
|
press: "ArrowUp"
|
|
151
214
|
});
|
|
152
|
-
focused = el.querySelector(
|
|
215
|
+
focused = el.querySelector(
|
|
216
|
+
`${el.focusableSelector}:nth-child(2)`
|
|
217
|
+
);
|
|
153
218
|
await elementUpdated(focused);
|
|
154
219
|
expect(focused === document.activeElement).to.be.true;
|
|
155
220
|
expect(focused.focused).to.be.true;
|
|
@@ -160,16 +225,21 @@ describe("Grid", () => {
|
|
|
160
225
|
expect(el.selected).to.deep.equal([{ id: 4 }]);
|
|
161
226
|
});
|
|
162
227
|
it("does not claim lit-virtualizer on the global registry", async () => {
|
|
163
|
-
const test = await fixture(
|
|
228
|
+
const test = await fixture(
|
|
229
|
+
html`
|
|
164
230
|
<div>${Default()}</div>
|
|
165
|
-
`
|
|
231
|
+
`
|
|
232
|
+
);
|
|
166
233
|
const el = test.querySelector("sp-grid");
|
|
167
234
|
await elementUpdated(el);
|
|
168
235
|
customElements.define("lit-virtualizer", class extends HTMLElement {
|
|
169
236
|
});
|
|
170
237
|
expect(() => {
|
|
171
|
-
customElements.define(
|
|
172
|
-
|
|
238
|
+
customElements.define(
|
|
239
|
+
"lit-virtualizer",
|
|
240
|
+
class extends HTMLElement {
|
|
241
|
+
}
|
|
242
|
+
);
|
|
173
243
|
}).to.throw();
|
|
174
244
|
});
|
|
175
245
|
});
|
package/test/grid.test.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["grid.test.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { elementUpdated, expect, fixture, nextFrame } from '@open-wc/testing';\nimport { html } from '@spectrum-web-components/base';\nimport { Card } from '@spectrum-web-components/card';\n\nimport '@spectrum-web-components/grid/sp-grid.js';\nimport { Grid } from '@spectrum-web-components/grid';\nimport { Default } from '../stories/grid.stories.js';\nimport { sendKeys } from '@web/test-runner-commands';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\ndescribe('Grid', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n )\n );\n it('loads default grid accessibly', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('accepts focus', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n\n await elementUpdated(el);\n\n expect(el.tabIndex).to.equal(0);\n\n el.focus();\n\n await nextFrame();\n await nextFrame();\n\n expect(\n el.querySelector(el.focusableSelector) === document.activeElement\n ).to.be.true;\n });\n it('allows to tab in and out', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n const firstInput = test.querySelector('#first-input') as HTMLElement;\n const lastInput = test.querySelector('#last-input') as HTMLElement;\n\n await elementUpdated(el);\n\n expect(el.tabIndex).to.equal(0);\n\n firstInput.focus();\n expect(firstInput === document.activeElement).to.be.true;\n expect(el.tabIndex).to.equal(0);\n\n await sendKeys({\n press: 'Tab',\n });\n\n await nextFrame();\n await nextFrame();\n\n expect(\n el.querySelector(el.focusableSelector) === document.activeElement\n ).to.be.true;\n expect(el.tabIndex).to.equal(-1);\n\n await sendKeys({\n press: 'Tab',\n });\n\n await nextFrame();\n await nextFrame();\n\n await elementUpdated(el);\n expect(lastInput === document.activeElement).to.be.true;\n expect(el.tabIndex).to.equal(0);\n\n await sendKeys({\n press: 'Shift+Tab',\n });\n\n await nextFrame();\n await nextFrame();\n await nextFrame();\n await nextFrame();\n\n expect(\n el.querySelector(el.focusableSelector) === document.activeElement\n ).to.be.true;\n expect(el.tabIndex).to.equal(-1);\n });\n it('manages roving tabindex', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n\n await elementUpdated(el);\n\n expect(el.tabIndex).to.equal(0);\n\n el.focus();\n\n await nextFrame();\n await nextFrame();\n\n let focused = el.querySelector(el.focusableSelector) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'ArrowRight',\n });\n\n focused = el.querySelector(\n `${el.focusableSelector}:nth-child(2)`\n ) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'ArrowDown',\n });\n\n focused = el.querySelector(\n `${el.focusableSelector}:nth-child(5)`\n ) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'ArrowLeft',\n });\n\n focused = el.querySelector(\n `${el.focusableSelector}:nth-child(4)`\n ) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'ArrowUp',\n });\n\n focused = el.querySelector(`${el.focusableSelector}`) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n });\n it('manages selection', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n\n await elementUpdated(el);\n\n expect(el.tabIndex).to.equal(0);\n\n el.focus();\n\n await nextFrame();\n await nextFrame();\n\n let focused = el.querySelector(el.focusableSelector) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'ArrowRight',\n });\n\n focused = el.querySelector(\n `${el.focusableSelector}:nth-child(2)`\n ) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'Space',\n });\n\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([{ id: 1 }]);\n\n await sendKeys({\n press: 'ArrowDown',\n });\n\n focused = el.querySelector(\n `${el.focusableSelector}:nth-child(5)`\n ) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'Space',\n });\n\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([{ id: 1 }, { id: 4 }]);\n\n await sendKeys({\n press: 'ArrowUp',\n });\n\n focused = el.querySelector(\n `${el.focusableSelector}:nth-child(2)`\n ) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'Space',\n });\n\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([{ id: 4 }]);\n });\n it('does not claim lit-virtualizer on the global registry', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n\n await elementUpdated(el);\n\n customElements.define('lit-virtualizer', class extends HTMLElement {});\n\n // make sure we also don't prevent *any* registration of lit-virtualizer\n expect(() => {\n customElements.define(\n 'lit-virtualizer',\n class extends HTMLElement {}\n );\n }).to.throw();\n });\n});\n"],
|
|
5
|
-
"mappings": "AAYA;
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { elementUpdated, expect, fixture, nextFrame } from '@open-wc/testing';\nimport { html } from '@spectrum-web-components/base';\nimport { Card } from '@spectrum-web-components/card';\n\nimport '@spectrum-web-components/theme/sp-theme.js';\nimport '@spectrum-web-components/theme/scale-medium.js';\nimport '@spectrum-web-components/theme/theme-light.js';\nimport '@spectrum-web-components/grid/sp-grid.js';\nimport { Grid } from '@spectrum-web-components/grid';\nimport { Default } from '../stories/grid.stories.js';\nimport { sendKeys, sendMouse } from '@web/test-runner-commands';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\ndescribe('Grid', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n )\n );\n it('loads default grid accessibly', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('accepts focus', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n\n await elementUpdated(el);\n\n expect(el.tabIndex).to.equal(0);\n\n el.focus();\n\n await nextFrame();\n await nextFrame();\n\n expect(\n el.querySelector(el.focusableSelector) === document.activeElement\n ).to.be.true;\n });\n it('does not focus when clicking grid', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <sp-theme color=\"light\" scale=\"medium\">${Default()}</sp-theme>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n\n await elementUpdated(el);\n\n expect(el.tabIndex).to.equal(0);\n\n el.focus();\n\n await nextFrame();\n await nextFrame();\n\n const firstItem = el.querySelector(el.focusableSelector) as HTMLElement;\n\n expect(firstItem === document.activeElement).to.be.true;\n\n const firstRect = firstItem?.getBoundingClientRect();\n const position = [\n Math.round(firstRect.x + firstRect.width + 2),\n Math.round(firstRect.y + 2),\n ] as [number, number];\n await sendMouse({\n type: 'click',\n position,\n });\n\n await nextFrame();\n await nextFrame();\n\n expect(\n el.querySelector(el.focusableSelector) === document.activeElement\n ).to.be.false;\n });\n it('allows to tab in and out', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n const firstInput = test.querySelector('#first-input') as HTMLElement;\n const lastInput = test.querySelector('#last-input') as HTMLElement;\n\n await elementUpdated(el);\n\n expect(el.tabIndex).to.equal(0);\n\n firstInput.focus();\n expect(firstInput === document.activeElement).to.be.true;\n expect(el.tabIndex).to.equal(0);\n\n await sendKeys({\n press: 'Tab',\n });\n\n await nextFrame();\n await nextFrame();\n\n expect(\n el.querySelector(el.focusableSelector) === document.activeElement\n ).to.be.true;\n expect(el.tabIndex).to.equal(-1);\n\n await sendKeys({\n press: 'Tab',\n });\n\n await nextFrame();\n await nextFrame();\n\n await elementUpdated(el);\n expect(lastInput === document.activeElement).to.be.true;\n expect(el.tabIndex).to.equal(0);\n\n await sendKeys({\n press: 'Shift+Tab',\n });\n\n await nextFrame();\n await nextFrame();\n await nextFrame();\n await nextFrame();\n\n expect(\n el.querySelector(el.focusableSelector) === document.activeElement\n ).to.be.true;\n expect(el.tabIndex).to.equal(-1);\n });\n it('manages roving tabindex', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n\n await elementUpdated(el);\n\n expect(el.tabIndex).to.equal(0);\n\n el.focus();\n\n await nextFrame();\n await nextFrame();\n\n let focused = el.querySelector(el.focusableSelector) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'ArrowRight',\n });\n\n focused = el.querySelector(\n `${el.focusableSelector}:nth-child(2)`\n ) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'ArrowDown',\n });\n\n focused = el.querySelector(\n `${el.focusableSelector}:nth-child(5)`\n ) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'ArrowLeft',\n });\n\n focused = el.querySelector(\n `${el.focusableSelector}:nth-child(4)`\n ) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'ArrowUp',\n });\n\n focused = el.querySelector(`${el.focusableSelector}`) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n });\n it('manages selection', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n\n await elementUpdated(el);\n\n expect(el.tabIndex).to.equal(0);\n\n el.focus();\n\n await nextFrame();\n await nextFrame();\n\n let focused = el.querySelector(el.focusableSelector) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'ArrowRight',\n });\n\n focused = el.querySelector(\n `${el.focusableSelector}:nth-child(2)`\n ) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'Space',\n });\n\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([{ id: 1 }]);\n\n await sendKeys({\n press: 'ArrowDown',\n });\n\n focused = el.querySelector(\n `${el.focusableSelector}:nth-child(5)`\n ) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'Space',\n });\n\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([{ id: 1 }, { id: 4 }]);\n\n await sendKeys({\n press: 'ArrowUp',\n });\n\n focused = el.querySelector(\n `${el.focusableSelector}:nth-child(2)`\n ) as Card;\n await elementUpdated(focused);\n expect(focused === document.activeElement).to.be.true;\n expect(focused.focused).to.be.true;\n\n await sendKeys({\n press: 'Space',\n });\n\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([{ id: 4 }]);\n });\n it('does not claim lit-virtualizer on the global registry', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>${Default()}</div>\n `\n );\n const el = test.querySelector('sp-grid') as Grid;\n\n await elementUpdated(el);\n\n customElements.define('lit-virtualizer', class extends HTMLElement {});\n\n // make sure we also don't prevent *any* registration of lit-virtualizer\n expect(() => {\n customElements.define(\n 'lit-virtualizer',\n class extends HTMLElement {}\n );\n }).to.throw();\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,gBAAgB,QAAQ,SAAS,iBAAiB;AAC3D,SAAS,YAAY;AAGrB,OAAO;AACP,OAAO;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