@spectrum-web-components/grid 0.1.0 → 0.1.2
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 +52 -2
- 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 -1
- package/sp-grid.js.map +2 -2
- package/src/Grid.d.ts +3 -0
- package/src/Grid.dev.js +41 -6
- package/src/Grid.dev.js.map +2 -2
- package/src/Grid.js +3 -1
- package/src/Grid.js.map +3 -3
- package/src/GridController.d.ts +10 -5
- package/src/GridController.dev.js +44 -16
- package/src/GridController.dev.js.map +2 -2
- package/src/GridController.js +1 -1
- 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 -3
- 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 +138 -33
- package/stories/grid.stories.js.map +2 -2
- package/test/benchmark/basic-test.js +5 -1
- package/test/benchmark/basic-test.js.map +1 -1
- package/test/grid.test.js +245 -15
- package/test/grid.test.js.map +2 -2
package/src/GridController.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ResizeController as
|
|
1
|
+
"use strict";import{ResizeController as h}from"@lit-labs/observers/resize_controller.js";import{RovingTabindexController as d}from"@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";export class GridController{constructor(t,{elements:e,itemSize:i,gap:n,padding:s}){this._first=0;this._last=0;this.handleFocusin=t=>{const e=s=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{s()})})},i=()=>this.host.scrollToIndex(0),n=()=>{this.focus(),this.host.tabIndex=-1};t.target===this.host&&(this._first>0?e(()=>{i(),e(n)}):e(n))};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(i,n,s),this.resizeController=new h(this.host,{callback:o=>{o.forEach(r=>{this.measureDirectionLength(r.contentRect)})}}),this.rovingTabindexController=new d(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(){}get padding(){return this._padding()}_padding(){}focus(t){this.rovingTabindexController.focus(t)}applyLayout(t,e,i){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),typeof i=="string"?this._padding=()=>i:typeof i=="function"&&(this._padding=i)}update({elements:t,itemSize:e,gap:i,padding:n}){this.rovingTabindexController.update({elements:t}),this.applyLayout(e,i,n);const s=this.host.getBoundingClientRect();this.measureDirectionLength(s)}measureDirectionLength(t){const e=this.gap?parseFloat(this.gap):0,i=this.padding?parseFloat(this.padding):0,n=t.width-i*2,s=Math.floor((n-this.itemSize.width)/(e+this.itemSize.width))+1;this.rovingTabindexController.directionLength=Math.floor(s)}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)}}
|
|
2
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 get padding(): string | undefined {\n return this._padding();\n }\n\n /* c8 ignore next 3 */\n private _padding(): 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 padding,\n }: {\n elements: () => T[];\n itemSize: ItemSize | (() => ItemSize);\n gap?: string | (() => string);\n padding?: string | (() => string);\n }\n ) {\n this.host = host;\n this.host.addController(this);\n this.applyLayout(itemSize, gap, padding);\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 padding?: 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 /* c8 ignore next 2 */\n if (typeof padding === 'string') {\n this._padding = () => padding;\n } else if (typeof padding === 'function') {\n this._padding = padding;\n }\n }\n\n public update({\n elements,\n itemSize,\n gap,\n padding,\n }: {\n elements: () => T[];\n itemSize: ItemSize | (() => ItemSize);\n gap?: string | (() => string);\n padding?: string | (() => string);\n }): void {\n this.rovingTabindexController.update({ elements });\n this.applyLayout(itemSize, gap, padding);\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 const padding = this.padding ? parseFloat(this.padding) : 0;\n const contentBoxWidth = contentRect.width - padding * 2;\n // There is always one less gap per row than items.\n const directionLength =\n Math.floor(\n (contentBoxWidth - this.itemSize.width) /\n (gap + this.itemSize.width)\n ) + 1;\n this.rovingTabindexController.directionLength =\n Math.floor(directionLength);\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"],
|
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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", "padding", "event", "doCallbackAfterPaint", "cb", "scrollToFirst", "focusIntoGrid", "entries", "entry", "options", "contentRect", "contentBoxWidth", "directionLength"]
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import{css as t}from"@spectrum-web-components/base";const
|
|
2
|
-
:host{contain:strict;display:block;position:relative}
|
|
3
|
-
`;export default
|
|
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;
|
|
4
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*from"./Grid.js";
|
|
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,34 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
import { html } from "@spectrum-web-components/base";
|
|
3
|
+
import "@spectrum-web-components/grid/sp-grid.js";
|
|
4
|
+
import "@spectrum-web-components/action-bar/sp-action-bar.js";
|
|
5
|
+
import "@spectrum-web-components/card/sp-card.js";
|
|
6
|
+
import "@spectrum-web-components/checkbox/sp-checkbox.js";
|
|
7
|
+
import "@spectrum-web-components/action-button/sp-action-button.js";
|
|
8
|
+
import "@spectrum-web-components/action-group/sp-action-group.js";
|
|
9
|
+
import "@spectrum-web-components/icons-workflow/icons/sp-icon-edit.js";
|
|
10
|
+
import "@spectrum-web-components/icons-workflow/icons/sp-icon-more.js";
|
|
11
|
+
export default {
|
|
12
|
+
title: "Grid",
|
|
13
|
+
component: "sp-grid"
|
|
14
|
+
};
|
|
15
|
+
function generateItems(count) {
|
|
16
|
+
const items = [];
|
|
17
|
+
while (count) {
|
|
18
|
+
count -= 1;
|
|
19
|
+
items.unshift({ id: count });
|
|
20
|
+
}
|
|
21
|
+
return items;
|
|
22
|
+
}
|
|
23
|
+
export const Default = () => {
|
|
24
|
+
const items = generateItems(1e3);
|
|
25
|
+
const renderItem = (item, index, selected) => {
|
|
26
|
+
return html`
|
|
9
27
|
<sp-card
|
|
10
28
|
toggles
|
|
11
29
|
variant="quiet"
|
|
12
|
-
heading="Card Heading ${
|
|
30
|
+
heading="Card Heading ${item.id}"
|
|
13
31
|
subheading="JPG Photo"
|
|
14
32
|
style="contain: strict; padding: 1px;"
|
|
15
|
-
value="card-${
|
|
16
|
-
.selected=${
|
|
17
|
-
key=${
|
|
33
|
+
value="card-${item.id}"
|
|
34
|
+
.selected=${selected}
|
|
35
|
+
key=${index}
|
|
18
36
|
>
|
|
19
37
|
<img
|
|
20
38
|
alt=""
|
|
21
39
|
slot="preview"
|
|
22
|
-
src="https://picsum.photos/id/${
|
|
40
|
+
src="https://picsum.photos/id/${item.id}/200/300"
|
|
23
41
|
decoding="async"
|
|
24
42
|
/>
|
|
25
43
|
<div slot="description">10/15/18</div>
|
|
26
44
|
<div slot="footer">Footer</div>
|
|
27
45
|
</sp-card>
|
|
28
|
-
|
|
46
|
+
`;
|
|
47
|
+
};
|
|
48
|
+
const handleChange = (event) => {
|
|
49
|
+
const actionbar = document.querySelector("sp-action-bar");
|
|
50
|
+
const selected = document.querySelector(".selected");
|
|
51
|
+
const ids = document.querySelector(".ids");
|
|
52
|
+
actionbar.open = !!event.currentTarget.selected.length;
|
|
53
|
+
actionbar.style.setProperty(
|
|
54
|
+
"display",
|
|
55
|
+
!!event.currentTarget.selected.length ? "flex" : "none"
|
|
56
|
+
);
|
|
57
|
+
selected.textContent = "" + event.currentTarget.selected.length;
|
|
58
|
+
ids.textContent = "" + event.currentTarget.selected.map((selection) => selection.id).join(", ");
|
|
59
|
+
};
|
|
60
|
+
const handleActionBarChange = (event) => {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
const grid = document.querySelector("sp-grid");
|
|
63
|
+
const actionbar = document.querySelector("sp-action-bar");
|
|
64
|
+
actionbar.open = false;
|
|
65
|
+
grid.selected = [];
|
|
66
|
+
};
|
|
67
|
+
return html`
|
|
68
|
+
<h1>Random before content that is focusable</h1>
|
|
69
|
+
<input id="first-input" />
|
|
70
|
+
<sp-grid
|
|
71
|
+
@change=${handleChange}
|
|
72
|
+
.items=${items}
|
|
73
|
+
.focusableSelector=${"sp-card"}
|
|
74
|
+
.renderItem=${renderItem}
|
|
29
75
|
></sp-grid>
|
|
30
76
|
<sp-action-bar variant="fixed" style="display: none">
|
|
31
|
-
<sp-checkbox @click=${
|
|
77
|
+
<sp-checkbox @click=${handleActionBarChange} checked>
|
|
32
78
|
<span class="selected"></span>
|
|
33
79
|
Selected
|
|
34
80
|
<span class="ids"></span>
|
|
@@ -44,39 +90,69 @@ import{html as r}from"@spectrum-web-components/base";import"@spectrum-web-compon
|
|
|
44
90
|
</sp-action-bar>
|
|
45
91
|
<h2>Random after content that is focusable</h2>
|
|
46
92
|
<input id="last-input" />
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.focusableSelector=${"sp-card"}
|
|
54
|
-
.renderItem=${(e,t,n)=>r`
|
|
93
|
+
`;
|
|
94
|
+
};
|
|
95
|
+
export const sized = ({ gap, padding } = { gap: 10, padding: 10 }) => {
|
|
96
|
+
const items = generateItems(1e3);
|
|
97
|
+
const renderItem = (item, index, selected) => {
|
|
98
|
+
return html`
|
|
55
99
|
<sp-card
|
|
56
100
|
toggles
|
|
57
101
|
variant="quiet"
|
|
58
|
-
heading="Card Heading ${
|
|
102
|
+
heading="Card Heading ${item.id}"
|
|
59
103
|
subheading="JPG Photo"
|
|
60
104
|
style="contain: strict; padding: 1px;"
|
|
61
|
-
value="card-${
|
|
62
|
-
.selected=${
|
|
63
|
-
key=${
|
|
105
|
+
value="card-${item.id}"
|
|
106
|
+
.selected=${selected}
|
|
107
|
+
key=${index}
|
|
64
108
|
>
|
|
65
109
|
<img
|
|
66
110
|
alt=""
|
|
67
111
|
slot="preview"
|
|
68
|
-
src="https://picsum.photos/id/${
|
|
112
|
+
src="https://picsum.photos/id/${item.id}/200/300"
|
|
69
113
|
decoding="async"
|
|
70
114
|
/>
|
|
71
115
|
<div slot="description">10/15/18</div>
|
|
72
116
|
<div slot="footer">Footer</div>
|
|
73
117
|
</sp-card>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
118
|
+
`;
|
|
119
|
+
};
|
|
120
|
+
const handleChange = (event) => {
|
|
121
|
+
const actionbar = document.querySelector("sp-action-bar");
|
|
122
|
+
const selected = document.querySelector(".selected");
|
|
123
|
+
const ids = document.querySelector(".ids");
|
|
124
|
+
actionbar.open = !!event.currentTarget.selected.length;
|
|
125
|
+
actionbar.style.setProperty(
|
|
126
|
+
"display",
|
|
127
|
+
!!event.currentTarget.selected.length ? "flex" : "none"
|
|
128
|
+
);
|
|
129
|
+
selected.textContent = "" + event.currentTarget.selected.length;
|
|
130
|
+
ids.textContent = "" + event.currentTarget.selected.map((selection) => selection.id).join(", ");
|
|
131
|
+
};
|
|
132
|
+
const handleActionBarChange = (event) => {
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
const grid = document.querySelector("sp-grid");
|
|
135
|
+
const actionbar = document.querySelector("sp-action-bar");
|
|
136
|
+
actionbar.open = false;
|
|
137
|
+
grid.selected = [];
|
|
138
|
+
};
|
|
139
|
+
return html`
|
|
140
|
+
<h1>Random before content that is focusable</h1>
|
|
141
|
+
<input id="first-input" />
|
|
142
|
+
<sp-grid
|
|
143
|
+
@change=${handleChange}
|
|
144
|
+
.items=${items}
|
|
145
|
+
.focusableSelector=${"sp-card"}
|
|
146
|
+
.renderItem=${renderItem}
|
|
147
|
+
.itemSize=${{
|
|
148
|
+
width: 200,
|
|
149
|
+
height: 300
|
|
150
|
+
}}
|
|
151
|
+
.gap=${`${gap}px`}
|
|
152
|
+
.padding=${`${padding}px`}
|
|
77
153
|
></sp-grid>
|
|
78
154
|
<sp-action-bar variant="fixed" style="display: none">
|
|
79
|
-
<sp-checkbox @click=${
|
|
155
|
+
<sp-checkbox @click=${handleActionBarChange} checked>
|
|
80
156
|
<span class="selected"></span>
|
|
81
157
|
Selected
|
|
82
158
|
<span class="ids"></span>
|
|
@@ -92,5 +168,34 @@ import{html as r}from"@spectrum-web-components/base";import"@spectrum-web-compon
|
|
|
92
168
|
</sp-action-bar>
|
|
93
169
|
<h2>Random after content that is focusable</h2>
|
|
94
170
|
<input id="last-input" />
|
|
95
|
-
|
|
171
|
+
`;
|
|
172
|
+
};
|
|
173
|
+
sized.args = {
|
|
174
|
+
gap: 10,
|
|
175
|
+
padding: 10
|
|
176
|
+
};
|
|
177
|
+
sized.argTypes = {
|
|
178
|
+
gap: {
|
|
179
|
+
name: "gap",
|
|
180
|
+
type: { name: "number", required: false },
|
|
181
|
+
description: "Spacing between items.",
|
|
182
|
+
table: {
|
|
183
|
+
type: { summary: "number" }
|
|
184
|
+
},
|
|
185
|
+
control: {
|
|
186
|
+
type: "number"
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
padding: {
|
|
190
|
+
name: "padding",
|
|
191
|
+
type: { name: "number", required: false },
|
|
192
|
+
description: "Spacing around all items.",
|
|
193
|
+
table: {
|
|
194
|
+
type: { summary: "number" }
|
|
195
|
+
},
|
|
196
|
+
control: {
|
|
197
|
+
type: "number"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
};
|
|
96
201
|
//# sourceMappingURL=grid.stories.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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=${
|
|
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 { 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 = (\n { gap, padding } = { gap: 10, padding: 10 }\n): 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=${`${gap}px`}\n .padding=${`${padding}px`}\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\nsized.args = {\n gap: 10,\n padding: 10,\n};\n\nsized.argTypes = {\n gap: {\n name: 'gap',\n type: { name: 'number', required: false },\n description: 'Spacing between items.',\n table: {\n type: { summary: 'number' },\n },\n control: {\n type: 'number',\n },\n },\n padding: {\n name: 'padding',\n type: { name: 'number', required: false },\n description: 'Spacing around all items.',\n table: {\n type: { summary: 'number' },\n },\n control: {\n type: 'number',\n },\n },\n};\n"],
|
|
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,QAAg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AA;AAiBlC;AAEA,MAAM,OAAO;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AACb;AAEA,MAAM,WAAW;AAAA,EACb,KAAK;AAAA,IACD,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM;AAAA,IACxC,aAAa;AAAA,IACb,OAAO;AAAA,MACH,MAAM,EAAE,SAAS,SAAS;AAAA,IAC9B;AAAA,IACA,SAAS;AAAA,MACL,MAAM;AAAA,IACV;AAAA,EACJ;AAAA,EACA,SAAS;AAAA,IACL,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM;AAAA,IACxC,aAAa;AAAA,IACb,OAAO;AAAA,MACH,MAAM,EAAE,SAAS,SAAS;AAAA,IAC9B;AAAA,IACA,SAAS;AAAA,MACL,MAAM;AAAA,IACV;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
import "@spectrum-web-components/grid/sp-grid.js";
|
|
3
|
+
import { html } from "@spectrum-web-components/base";
|
|
4
|
+
import { measureFixtureCreation } from "../../../../test/benchmark/helpers.js";
|
|
5
|
+
measureFixtureCreation(html`
|
|
2
6
|
<sp-grid></sp-grid>
|
|
3
7
|
`);
|
|
4
8
|
//# sourceMappingURL=basic-test.js.map
|
|
@@ -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
|
}
|