@spectrum-web-components/grid 0.0.4-alpha.6 → 0.0.6
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 +1 -16
- package/package.json +5 -5
- package/src/Grid.d.ts +1 -1
- package/src/Grid.js +1 -1
- package/src/Grid.js.map +1 -1
- package/src/grid.css.js +1 -1
- package/src/grid.css.js.map +1 -1
- package/src/LitVirtualizer.d.ts +0 -2
- package/src/LitVirtualizer.js +0 -24
- package/src/LitVirtualizer.js.map +0 -1
package/custom-elements.json
CHANGED
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
],
|
|
156
156
|
"superclass": {
|
|
157
157
|
"name": "LitVirtualizer",
|
|
158
|
-
"
|
|
158
|
+
"package": "@lit-labs/virtualizer/LitVirtualizer.js"
|
|
159
159
|
},
|
|
160
160
|
"tagName": "sp-grid",
|
|
161
161
|
"customElement": true
|
|
@@ -371,21 +371,6 @@
|
|
|
371
371
|
}
|
|
372
372
|
]
|
|
373
373
|
},
|
|
374
|
-
{
|
|
375
|
-
"kind": "javascript-module",
|
|
376
|
-
"path": "src/LitVirtualizer.ts",
|
|
377
|
-
"declarations": [],
|
|
378
|
-
"exports": [
|
|
379
|
-
{
|
|
380
|
-
"kind": "js",
|
|
381
|
-
"name": "LitVirtualizer",
|
|
382
|
-
"declaration": {
|
|
383
|
-
"name": "LitVirtualizer",
|
|
384
|
-
"module": "src/LitVirtualizer.ts"
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
]
|
|
388
|
-
},
|
|
389
374
|
{
|
|
390
375
|
"kind": "javascript-module",
|
|
391
376
|
"path": "src/grid.css.ts",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/grid",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@lit-labs/observers": "^1.0.1",
|
|
48
|
-
"@lit-labs/virtualizer": "0.7.0-pre.
|
|
49
|
-
"@spectrum-web-components/base": "^0.5.
|
|
50
|
-
"@spectrum-web-components/reactive-controllers": "^0.2.
|
|
48
|
+
"@lit-labs/virtualizer": "0.7.0-pre.3",
|
|
49
|
+
"@spectrum-web-components/base": "^0.5.6",
|
|
50
|
+
"@spectrum-web-components/reactive-controllers": "^0.2.3",
|
|
51
51
|
"tslib": "^2.0.0"
|
|
52
52
|
},
|
|
53
53
|
"types": "./src/index.d.ts",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"sideEffects": [
|
|
56
56
|
"./sp-*.js"
|
|
57
57
|
],
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "32e049a0da090ffc1a54cfe3234be4d5efc73339"
|
|
59
59
|
}
|
package/src/Grid.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSResultArray, PropertyValues, TemplateResult } from '@spectrum-web-components/base';
|
|
2
|
-
import { LitVirtualizer } from '
|
|
2
|
+
import { LitVirtualizer } from '@lit-labs/virtualizer/LitVirtualizer.js';
|
|
3
3
|
import { GridController } from './GridController.js';
|
|
4
4
|
/**
|
|
5
5
|
* @element sp-grid
|
package/src/Grid.js
CHANGED
|
@@ -11,7 +11,7 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
import { __decorate } from "tslib";
|
|
13
13
|
import { property } from '@spectrum-web-components/base/src/decorators.js';
|
|
14
|
-
import { LitVirtualizer } from '
|
|
14
|
+
import { LitVirtualizer } from '@lit-labs/virtualizer/LitVirtualizer.js';
|
|
15
15
|
import { grid } from '@lit-labs/virtualizer/layouts/grid.js';
|
|
16
16
|
import styles from './grid.css.js';
|
|
17
17
|
import { GridController } from './GridController.js';
|
package/src/Grid.js.map
CHAN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ache 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 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 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 get renderItem(): (item: unknown, index: number) => TemplateResult {\n return super.renderItem;\n }\n\n set renderItem(\n fn: (item: unknown, index: number, selected: boolean) => TemplateResult\n ) {\n super.renderItem = (\n item: Record<string, unknown>,\n index: number\n ): TemplateResult => {\n const selected = this.selected.includes(item);\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 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 connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('change', this.handleChange, { capture: true });\n }\n\n disconnectedCallback(): void {\n this.removeEventListener('change', this.handleChange, {\n capture: true,\n });\n super.disconnectedCallback();\n }\n}\n"]}
|
package/src/grid.css.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
3
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
package/src/grid.css.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.css.js","sourceRoot":"","sources":["grid.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;CAEjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright
|
|
1
|
+
{"version":3,"file":"grid.css.js","sourceRoot":"","sources":["grid.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;CAEjB,CAAC;AACF,eAAe,MAAM,CAAC","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;"]}
|
package/src/LitVirtualizer.d.ts
DELETED
package/src/LitVirtualizer.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
// @lit-labs/virtualizer combines defining the LitVirtualizer class with defining `lit-virtualizer` in the global registry.
|
|
13
|
-
// Grid extends LitVirtualizer and doesn't need the tag, which can conflict with other uses of lit-virtualizer in the same document.
|
|
14
|
-
// This is a hack to keep lit-virtualizer from registering globally.
|
|
15
|
-
const oldDefine = customElements.define;
|
|
16
|
-
customElements.define = (name, constructor) => {
|
|
17
|
-
if (name === 'lit-virtualizer')
|
|
18
|
-
return;
|
|
19
|
-
oldDefine.call(customElements, name, constructor);
|
|
20
|
-
};
|
|
21
|
-
const { LitVirtualizer } = await import('@lit-labs/virtualizer');
|
|
22
|
-
customElements.define = oldDefine;
|
|
23
|
-
export { LitVirtualizer };
|
|
24
|
-
//# sourceMappingURL=LitVirtualizer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LitVirtualizer.js","sourceRoot":"","sources":["LitVirtualizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,2HAA2H;AAC3H,oIAAoI;AACpI,oEAAoE;AAEpE,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC;AACxC,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE;IAC1C,IAAI,IAAI,KAAK,iBAAiB;QAAE,OAAO;IACvC,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AACtD,CAAC,CAAC;AAEF,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAEjE,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,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\n// @lit-labs/virtualizer combines defining the LitVirtualizer class with defining `lit-virtualizer` in the global registry.\n// Grid extends LitVirtualizer and doesn't need the tag, which can conflict with other uses of lit-virtualizer in the same document.\n// This is a hack to keep lit-virtualizer from registering globally.\n\nconst oldDefine = customElements.define;\ncustomElements.define = (name, constructor) => {\n if (name === 'lit-virtualizer') return;\n oldDefine.call(customElements, name, constructor);\n};\n\nconst { LitVirtualizer } = await import('@lit-labs/virtualizer');\n\ncustomElements.define = oldDefine;\n\nexport { LitVirtualizer };\n"]}
|