@spectrum-web-components/grid 0.0.6 → 0.0.9-devmode.24

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.
@@ -1,39 +1,28 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import { html } from '@spectrum-web-components/base';
13
- import '../sp-grid.js';
14
- import '@spectrum-web-components/action-bar/sp-action-bar.js';
15
- import '@spectrum-web-components/card/sp-card.js';
16
- import '@spectrum-web-components/checkbox/sp-checkbox.js';
17
- import '@spectrum-web-components/action-button/sp-action-button.js';
18
- import '@spectrum-web-components/action-group/sp-action-group.js';
19
- import '@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js';
20
- import '@spectrum-web-components/icons-workflow/icons/sp-icon-more.js';
1
+ import { html } from "@spectrum-web-components/base";
2
+ import "@spectrum-web-components/grid/sp-grid.js";
3
+ import "@spectrum-web-components/action-bar/sp-action-bar.js";
4
+ import "@spectrum-web-components/card/sp-card.js";
5
+ import "@spectrum-web-components/checkbox/sp-checkbox.js";
6
+ import "@spectrum-web-components/action-button/sp-action-button.js";
7
+ import "@spectrum-web-components/action-group/sp-action-group.js";
8
+ import "@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js";
9
+ import "@spectrum-web-components/icons-workflow/icons/sp-icon-more.js";
21
10
  export default {
22
- title: 'Grid',
23
- component: 'sp-grid',
11
+ title: "Grid",
12
+ component: "sp-grid"
24
13
  };
25
14
  function generateItems(count) {
26
- const items = [];
27
- while (count) {
28
- count -= 1;
29
- items.unshift({ id: count });
30
- }
31
- return items;
15
+ const items = [];
16
+ while (count) {
17
+ count -= 1;
18
+ items.unshift({ id: count });
19
+ }
20
+ return items;
32
21
  }
33
22
  export const Default = () => {
34
- const items = generateItems(1000);
35
- const renderItem = (item, index, selected) => {
36
- return html `
23
+ const items = generateItems(1e3);
24
+ const renderItem = (item, index, selected) => {
25
+ return html`
37
26
  <sp-card
38
27
  toggles
39
28
  variant="quiet"
@@ -54,34 +43,30 @@ export const Default = () => {
54
43
  <div slot="footer">Footer</div>
55
44
  </sp-card>
56
45
  `;
57
- };
58
- const handleChange = (event) => {
59
- const actionbar = document.querySelector('sp-action-bar');
60
- const selected = document.querySelector('.selected');
61
- const ids = document.querySelector('.ids');
62
- actionbar.open = !!event.currentTarget.selected.length;
63
- actionbar.style.setProperty('display', !!event.currentTarget.selected.length ? 'flex' : 'none');
64
- selected.textContent = '' + event.currentTarget.selected.length;
65
- ids.textContent =
66
- '' +
67
- event.currentTarget.selected
68
- .map((selection) => selection.id)
69
- .join(', ');
70
- };
71
- const handleActionBarChange = (event) => {
72
- event.preventDefault();
73
- const grid = document.querySelector('sp-grid');
74
- const actionbar = document.querySelector('sp-action-bar');
75
- actionbar.open = false;
76
- grid.selected = [];
77
- };
78
- return html `
46
+ };
47
+ const handleChange = (event) => {
48
+ const actionbar = document.querySelector("sp-action-bar");
49
+ const selected = document.querySelector(".selected");
50
+ const ids = document.querySelector(".ids");
51
+ actionbar.open = !!event.currentTarget.selected.length;
52
+ actionbar.style.setProperty("display", !!event.currentTarget.selected.length ? "flex" : "none");
53
+ selected.textContent = "" + event.currentTarget.selected.length;
54
+ ids.textContent = "" + event.currentTarget.selected.map((selection) => selection.id).join(", ");
55
+ };
56
+ const handleActionBarChange = (event) => {
57
+ event.preventDefault();
58
+ const grid = document.querySelector("sp-grid");
59
+ const actionbar = document.querySelector("sp-action-bar");
60
+ actionbar.open = false;
61
+ grid.selected = [];
62
+ };
63
+ return html`
79
64
  <h1>Random before content that is focusable</h1>
80
65
  <input id="first-input" />
81
66
  <sp-grid
82
67
  @change=${handleChange}
83
68
  .items=${items}
84
- .focusableSelector=${'sp-card'}
69
+ .focusableSelector=${"sp-card"}
85
70
  .renderItem=${renderItem}
86
71
  ></sp-grid>
87
72
  <sp-action-bar variant="fixed" style="display: none">
@@ -104,9 +89,9 @@ export const Default = () => {
104
89
  `;
105
90
  };
106
91
  export const sized = () => {
107
- const items = generateItems(1000);
108
- const renderItem = (item, index, selected) => {
109
- return html `
92
+ const items = generateItems(1e3);
93
+ const renderItem = (item, index, selected) => {
94
+ return html`
110
95
  <sp-card
111
96
  toggles
112
97
  variant="quiet"
@@ -127,40 +112,36 @@ export const sized = () => {
127
112
  <div slot="footer">Footer</div>
128
113
  </sp-card>
129
114
  `;
130
- };
131
- const handleChange = (event) => {
132
- const actionbar = document.querySelector('sp-action-bar');
133
- const selected = document.querySelector('.selected');
134
- const ids = document.querySelector('.ids');
135
- actionbar.open = !!event.currentTarget.selected.length;
136
- actionbar.style.setProperty('display', !!event.currentTarget.selected.length ? 'flex' : 'none');
137
- selected.textContent = '' + event.currentTarget.selected.length;
138
- ids.textContent =
139
- '' +
140
- event.currentTarget.selected
141
- .map((selection) => selection.id)
142
- .join(', ');
143
- };
144
- const handleActionBarChange = (event) => {
145
- event.preventDefault();
146
- const grid = document.querySelector('sp-grid');
147
- const actionbar = document.querySelector('sp-action-bar');
148
- actionbar.open = false;
149
- grid.selected = [];
150
- };
151
- return html `
115
+ };
116
+ const handleChange = (event) => {
117
+ const actionbar = document.querySelector("sp-action-bar");
118
+ const selected = document.querySelector(".selected");
119
+ const ids = document.querySelector(".ids");
120
+ actionbar.open = !!event.currentTarget.selected.length;
121
+ actionbar.style.setProperty("display", !!event.currentTarget.selected.length ? "flex" : "none");
122
+ selected.textContent = "" + event.currentTarget.selected.length;
123
+ ids.textContent = "" + event.currentTarget.selected.map((selection) => selection.id).join(", ");
124
+ };
125
+ const handleActionBarChange = (event) => {
126
+ event.preventDefault();
127
+ const grid = document.querySelector("sp-grid");
128
+ const actionbar = document.querySelector("sp-action-bar");
129
+ actionbar.open = false;
130
+ grid.selected = [];
131
+ };
132
+ return html`
152
133
  <h1>Random before content that is focusable</h1>
153
134
  <input id="first-input" />
154
135
  <sp-grid
155
136
  @change=${handleChange}
156
137
  .items=${items}
157
- .focusableSelector=${'sp-card'}
138
+ .focusableSelector=${"sp-card"}
158
139
  .renderItem=${renderItem}
159
140
  .itemSize=${{
160
- width: 200,
161
- height: 300,
162
- }}
163
- .gap=${'10px'}
141
+ width: 200,
142
+ height: 300
143
+ }}
144
+ .gap=${"10px"}
164
145
  ></sp-grid>
165
146
  <sp-action-bar variant="fixed" style="display: none">
166
147
  <sp-checkbox @click=${handleActionBarChange} checked>
@@ -181,4 +162,4 @@ export const sized = () => {
181
162
  <input id="last-input" />
182
163
  `;
183
164
  };
184
- //# sourceMappingURL=grid.stories.js.map
165
+ //# sourceMappingURL=grid.stories.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"grid.stories.js","sourceRoot":"","sources":["grid.stories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AAErE,OAAO,eAAe,CAAC;AACvB,OAAO,sDAAsD,CAAC;AAC9D,OAAO,0CAA0C,CAAC;AAClD,OAAO,kDAAkD,CAAC;AAC1D,OAAO,4DAA4D,CAAC;AACpE,OAAO,0DAA0D,CAAC;AAClE,OAAO,+DAA+D,CAAC;AACvE,OAAO,+DAA+D,CAAC;AAIvE,eAAe;IACX,KAAK,EAAE,MAAM;IACb,SAAS,EAAE,SAAS;CACvB,CAAC;AAMF,SAAS,aAAa,CAAC,KAAa;IAChC,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,OAAO,KAAK,EAAE;QACV,KAAK,IAAI,CAAC,CAAC;QACX,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;KAChC;IACD,OAAO,KAAK,CAAC;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,CAAC,CAAC,CAAC,MAAM,CAC1D,CAAC;QACF,QAAQ,CAAC,WAAW,GAAG,EAAE,GAAG,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC;QAChE,GAAG,CAAC,WAAW;YACX,EAAE;gBACF,KAAK,CAAC,aAAa,CAAC,QAAQ;qBACvB,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;qBAChC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC,CAAC;IACF,MAAM,qBAAqB,GAAG,CAAC,KAAY,EAAQ,EAAE;QACjD,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAS,CAAC;QACvD,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAc,CAAC;QACvE,SAAS,CAAC,IAAI,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACvB,CAAC,CAAC;IACF,OAAO,IAAI,CAAA;;;;sBAIO,YAAY;qBACb,KAAK;iCACO,SAAS;0BAChB,UAAU;wBACZ;QACR,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;KACd;mBACM,MAAM;;;kCAGS,qBAAqB;;;;;;;;;;;;;;;;KAgBlD,CAAC;AACN,CAAC,CAAC","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 '../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 '..';\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"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["grid.stories.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 { 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;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA,eAAe;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AACf;AAMA,uBAAuB,OAAuB;AAC1C,QAAM,QAAgB,CAAC;AACvB,SAAO,OAAO;AACV,aAAS;AACT,UAAM,QAAQ,EAAE,IAAI,MAAM,CAAC;AAAA,EAC/B;AACA,SAAO;AACX;AAEO,aAAM,UAAU,MAAsB;AACzC,QAAM,QAAQ,cAAc,GAAI;AAEhC,QAAM,aAAa,CACf,MACA,OACA,aACiB;AACjB,WAAO;AAAA;AAAA;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,c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A,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
+ "names": []
7
+ }
@@ -1,18 +1,7 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import '@spectrum-web-components/grid/sp-grid.js';
13
- import { html } from '@spectrum-web-components/base';
14
- import { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';
15
- measureFixtureCreation(html `
1
+ import "@spectrum-web-components/grid/sp-grid.js";
2
+ import { html } from "@spectrum-web-components/base";
3
+ import { measureFixtureCreation } from "../../../../test/benchmark/helpers.js";
4
+ measureFixtureCreation(html`
16
5
  <sp-grid></sp-grid>
17
6
  `);
18
- //# sourceMappingURL=basic-test.js.map
7
+ //# sourceMappingURL=basic-test.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"basic-test.js","sourceRoot":"","sources":["basic-test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,0CAA0C,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,sBAAsB,CAAC,IAAI,CAAA;;CAE1B,CAAC,CAAC","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"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["basic-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 '@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;AACA;AACA;AAEA,uBAAuB;AAAA;AAAA,CAEtB;",
6
+ "names": []
7
+ }
package/test/grid.test.js CHANGED
@@ -1,184 +1,172 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import { elementUpdated, expect, fixture, nextFrame } from '@open-wc/testing';
13
- import { html } from '@spectrum-web-components/base';
14
- import '../sp-grid.js';
15
- import { Default } from '../stories/grid.stories.js';
16
- import { sendKeys } from '@web/test-runner-commands';
17
- describe('Grid', () => {
18
- it('loads default grid accessibly', async () => {
19
- const test = await fixture(html `
1
+ import { elementUpdated, expect, fixture, nextFrame } from "@open-wc/testing";
2
+ import { html } from "@spectrum-web-components/base";
3
+ import "@spectrum-web-components/grid/sp-grid.js";
4
+ import { Default } from "../stories/grid.stories.js";
5
+ import { sendKeys } from "@web/test-runner-commands";
6
+ describe("Grid", () => {
7
+ it("loads default grid accessibly", async () => {
8
+ const test = await fixture(html`
20
9
  <div>${Default()}</div>
21
10
  `);
22
- const el = test.querySelector('sp-grid');
23
- await elementUpdated(el);
24
- await expect(el).to.be.accessible();
25
- });
26
- it('accepts focus', async () => {
27
- const test = await fixture(html `
11
+ const el = test.querySelector("sp-grid");
12
+ await elementUpdated(el);
13
+ await expect(el).to.be.accessible();
14
+ });
15
+ it("accepts focus", async () => {
16
+ const test = await fixture(html`
28
17
  <div>${Default()}</div>
29
18
  `);
30
- const el = test.querySelector('sp-grid');
31
- await elementUpdated(el);
32
- expect(el.tabIndex).to.equal(0);
33
- el.focus();
34
- await nextFrame();
35
- await nextFrame();
36
- expect(el.querySelector(el.focusableSelector) === document.activeElement).to.be.true;
37
- });
38
- it('allows to tab in and out', async () => {
39
- const test = await fixture(html `
19
+ const el = test.querySelector("sp-grid");
20
+ await elementUpdated(el);
21
+ expect(el.tabIndex).to.equal(0);
22
+ el.focus();
23
+ await nextFrame();
24
+ await nextFrame();
25
+ expect(el.querySelector(el.focusableSelector) === document.activeElement).to.be.true;
26
+ });
27
+ it("allows to tab in and out", async () => {
28
+ const test = await fixture(html`
40
29
  <div>${Default()}</div>
41
30
  `);
42
- const el = test.querySelector('sp-grid');
43
- const firstInput = test.querySelector('#first-input');
44
- const lastInput = test.querySelector('#last-input');
45
- await elementUpdated(el);
46
- expect(el.tabIndex).to.equal(0);
47
- firstInput.focus();
48
- expect(firstInput === document.activeElement).to.be.true;
49
- expect(el.tabIndex).to.equal(0);
50
- await sendKeys({
51
- press: 'Tab',
52
- });
53
- await nextFrame();
54
- await nextFrame();
55
- expect(el.querySelector(el.focusableSelector) === document.activeElement).to.be.true;
56
- expect(el.tabIndex).to.equal(-1);
57
- await sendKeys({
58
- press: 'Tab',
59
- });
60
- await nextFrame();
61
- await nextFrame();
62
- await elementUpdated(el);
63
- expect(lastInput === document.activeElement).to.be.true;
64
- expect(el.tabIndex).to.equal(0);
65
- await sendKeys({
66
- press: 'Shift+Tab',
67
- });
68
- await nextFrame();
69
- await nextFrame();
70
- await nextFrame();
71
- await nextFrame();
72
- expect(el.querySelector(el.focusableSelector) === document.activeElement).to.be.true;
73
- expect(el.tabIndex).to.equal(-1);
31
+ const el = test.querySelector("sp-grid");
32
+ const firstInput = test.querySelector("#first-input");
33
+ const lastInput = test.querySelector("#last-input");
34
+ await elementUpdated(el);
35
+ expect(el.tabIndex).to.equal(0);
36
+ firstInput.focus();
37
+ expect(firstInput === document.activeElement).to.be.true;
38
+ expect(el.tabIndex).to.equal(0);
39
+ await sendKeys({
40
+ press: "Tab"
41
+ });
42
+ await nextFrame();
43
+ await nextFrame();
44
+ expect(el.querySelector(el.focusableSelector) === document.activeElement).to.be.true;
45
+ expect(el.tabIndex).to.equal(-1);
46
+ await sendKeys({
47
+ press: "Tab"
74
48
  });
75
- it('manages roving tabindex', async () => {
76
- const test = await fixture(html `
49
+ await nextFrame();
50
+ await nextFrame();
51
+ await elementUpdated(el);
52
+ expect(lastInput === document.activeElement).to.be.true;
53
+ expect(el.tabIndex).to.equal(0);
54
+ await sendKeys({
55
+ press: "Shift+Tab"
56
+ });
57
+ await nextFrame();
58
+ await nextFrame();
59
+ await nextFrame();
60
+ await nextFrame();
61
+ expect(el.querySelector(el.focusableSelector) === document.activeElement).to.be.true;
62
+ expect(el.tabIndex).to.equal(-1);
63
+ });
64
+ it("manages roving tabindex", async () => {
65
+ const test = await fixture(html`
77
66
  <div>${Default()}</div>
78
67
  `);
79
- const el = test.querySelector('sp-grid');
80
- await elementUpdated(el);
81
- expect(el.tabIndex).to.equal(0);
82
- el.focus();
83
- await nextFrame();
84
- await nextFrame();
85
- let focused = el.querySelector(el.focusableSelector);
86
- await elementUpdated(focused);
87
- expect(focused === document.activeElement).to.be.true;
88
- expect(focused.focused).to.be.true;
89
- await sendKeys({
90
- press: 'ArrowRight',
91
- });
92
- focused = el.querySelector(`${el.focusableSelector}:nth-child(2)`);
93
- await elementUpdated(focused);
94
- expect(focused === document.activeElement).to.be.true;
95
- expect(focused.focused).to.be.true;
96
- await sendKeys({
97
- press: 'ArrowDown',
98
- });
99
- focused = el.querySelector(`${el.focusableSelector}:nth-child(5)`);
100
- await elementUpdated(focused);
101
- expect(focused === document.activeElement).to.be.true;
102
- expect(focused.focused).to.be.true;
103
- await sendKeys({
104
- press: 'ArrowLeft',
105
- });
106
- focused = el.querySelector(`${el.focusableSelector}:nth-child(4)`);
107
- await elementUpdated(focused);
108
- expect(focused === document.activeElement).to.be.true;
109
- expect(focused.focused).to.be.true;
110
- await sendKeys({
111
- press: 'ArrowUp',
112
- });
113
- focused = el.querySelector(`${el.focusableSelector}`);
114
- await elementUpdated(focused);
115
- expect(focused === document.activeElement).to.be.true;
116
- expect(focused.focused).to.be.true;
68
+ const el = test.querySelector("sp-grid");
69
+ await elementUpdated(el);
70
+ expect(el.tabIndex).to.equal(0);
71
+ el.focus();
72
+ await nextFrame();
73
+ await nextFrame();
74
+ let focused = el.querySelector(el.focusableSelector);
75
+ await elementUpdated(focused);
76
+ expect(focused === document.activeElement).to.be.true;
77
+ expect(focused.focused).to.be.true;
78
+ await sendKeys({
79
+ press: "ArrowRight"
80
+ });
81
+ focused = el.querySelector(`${el.focusableSelector}:nth-child(2)`);
82
+ await elementUpdated(focused);
83
+ expect(focused === document.activeElement).to.be.true;
84
+ expect(focused.focused).to.be.true;
85
+ await sendKeys({
86
+ press: "ArrowDown"
87
+ });
88
+ focused = el.querySelector(`${el.focusableSelector}:nth-child(5)`);
89
+ await elementUpdated(focused);
90
+ expect(focused === document.activeElement).to.be.true;
91
+ expect(focused.focused).to.be.true;
92
+ await sendKeys({
93
+ press: "ArrowLeft"
117
94
  });
118
- it('manages selection', async () => {
119
- const test = await fixture(html `
95
+ focused = el.querySelector(`${el.focusableSelector}:nth-child(4)`);
96
+ await elementUpdated(focused);
97
+ expect(focused === document.activeElement).to.be.true;
98
+ expect(focused.focused).to.be.true;
99
+ await sendKeys({
100
+ press: "ArrowUp"
101
+ });
102
+ focused = el.querySelector(`${el.focusableSelector}`);
103
+ await elementUpdated(focused);
104
+ expect(focused === document.activeElement).to.be.true;
105
+ expect(focused.focused).to.be.true;
106
+ });
107
+ it("manages selection", async () => {
108
+ const test = await fixture(html`
120
109
  <div>${Default()}</div>
121
110
  `);
122
- const el = test.querySelector('sp-grid');
123
- await elementUpdated(el);
124
- expect(el.tabIndex).to.equal(0);
125
- el.focus();
126
- await nextFrame();
127
- await nextFrame();
128
- let focused = el.querySelector(el.focusableSelector);
129
- await elementUpdated(focused);
130
- expect(focused === document.activeElement).to.be.true;
131
- expect(focused.focused).to.be.true;
132
- await sendKeys({
133
- press: 'ArrowRight',
134
- });
135
- focused = el.querySelector(`${el.focusableSelector}:nth-child(2)`);
136
- await elementUpdated(focused);
137
- expect(focused === document.activeElement).to.be.true;
138
- expect(focused.focused).to.be.true;
139
- await sendKeys({
140
- press: 'Space',
141
- });
142
- await elementUpdated(el);
143
- expect(el.selected).to.deep.equal([{ id: 1 }]);
144
- await sendKeys({
145
- press: 'ArrowDown',
146
- });
147
- focused = el.querySelector(`${el.focusableSelector}:nth-child(5)`);
148
- await elementUpdated(focused);
149
- expect(focused === document.activeElement).to.be.true;
150
- expect(focused.focused).to.be.true;
151
- await sendKeys({
152
- press: 'Space',
153
- });
154
- await elementUpdated(el);
155
- expect(el.selected).to.deep.equal([{ id: 1 }, { id: 4 }]);
156
- await sendKeys({
157
- press: 'ArrowUp',
158
- });
159
- focused = el.querySelector(`${el.focusableSelector}:nth-child(2)`);
160
- await elementUpdated(focused);
161
- expect(focused === document.activeElement).to.be.true;
162
- expect(focused.focused).to.be.true;
163
- await sendKeys({
164
- press: 'Space',
165
- });
166
- await elementUpdated(el);
167
- expect(el.selected).to.deep.equal([{ id: 4 }]);
111
+ const el = test.querySelector("sp-grid");
112
+ await elementUpdated(el);
113
+ expect(el.tabIndex).to.equal(0);
114
+ el.focus();
115
+ await nextFrame();
116
+ await nextFrame();
117
+ let focused = el.querySelector(el.focusableSelector);
118
+ await elementUpdated(focused);
119
+ expect(focused === document.activeElement).to.be.true;
120
+ expect(focused.focused).to.be.true;
121
+ await sendKeys({
122
+ press: "ArrowRight"
123
+ });
124
+ focused = el.querySelector(`${el.focusableSelector}:nth-child(2)`);
125
+ await elementUpdated(focused);
126
+ expect(focused === document.activeElement).to.be.true;
127
+ expect(focused.focused).to.be.true;
128
+ await sendKeys({
129
+ press: "Space"
130
+ });
131
+ await elementUpdated(el);
132
+ expect(el.selected).to.deep.equal([{ id: 1 }]);
133
+ await sendKeys({
134
+ press: "ArrowDown"
135
+ });
136
+ focused = el.querySelector(`${el.focusableSelector}:nth-child(5)`);
137
+ await elementUpdated(focused);
138
+ expect(focused === document.activeElement).to.be.true;
139
+ expect(focused.focused).to.be.true;
140
+ await sendKeys({
141
+ press: "Space"
142
+ });
143
+ await elementUpdated(el);
144
+ expect(el.selected).to.deep.equal([{ id: 1 }, { id: 4 }]);
145
+ await sendKeys({
146
+ press: "ArrowUp"
147
+ });
148
+ focused = el.querySelector(`${el.focusableSelector}:nth-child(2)`);
149
+ await elementUpdated(focused);
150
+ expect(focused === document.activeElement).to.be.true;
151
+ expect(focused.focused).to.be.true;
152
+ await sendKeys({
153
+ press: "Space"
168
154
  });
169
- it('does not claim lit-virtualizer on the global registry', async () => {
170
- const test = await fixture(html `
155
+ await elementUpdated(el);
156
+ expect(el.selected).to.deep.equal([{ id: 4 }]);
157
+ });
158
+ it("does not claim lit-virtualizer on the global registry", async () => {
159
+ const test = await fixture(html`
171
160
  <div>${Default()}</div>
172
161
  `);
173
- const el = test.querySelector('sp-grid');
174
- await elementUpdated(el);
175
- customElements.define('lit-virtualizer', class extends HTMLElement {
176
- });
177
- // make sure we also don't prevent *any* registration of lit-virtualizer
178
- expect(() => {
179
- customElements.define('lit-virtualizer', class extends HTMLElement {
180
- });
181
- }).to.throw();
162
+ const el = test.querySelector("sp-grid");
163
+ await elementUpdated(el);
164
+ customElements.define("lit-virtualizer", class extends HTMLElement {
182
165
  });
166
+ expect(() => {
167
+ customElements.define("lit-virtualizer", class extends HTMLElement {
168
+ });
169
+ }).to.throw();
170
+ });
183
171
  });
184
- //# sourceMappingURL=grid.test.js.map
172
+ //# sourceMappingURL=grid.test.js.map