@digital-realty/ix-tile-picker 2.0.12 → 2.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/.editorconfig +29 -29
- package/LICENSE +20 -20
- package/README.md +68 -68
- package/dist/src/IxTilePicker.d.ts +36 -36
- package/dist/src/IxTilePicker.js +155 -155
- package/dist/src/IxTilePicker.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/ix-tile-picker-styles.d.ts +1 -1
- package/dist/src/ix-tile-picker-styles.js +224 -224
- package/dist/src/ix-tile-picker-styles.js.map +1 -1
- package/dist/src/ix-tile-picker.d.ts +1 -1
- package/dist/src/ix-tile-picker.js +2 -2
- package/dist/src/ix-tile-picker.js.map +1 -1
- package/dist/src/react/IxTilePicker.d.ts +2 -2
- package/dist/src/react/IxTilePicker.js +9 -9
- package/dist/src/react/IxTilePicker.js.map +1 -1
- package/dist/test/ix-tile-picker.test.d.ts +1 -1
- package/dist/test/ix-tile-picker.test.js +68 -68
- package/dist/test/ix-tile-picker.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +95 -94
- package/src/IxTilePicker.ts +162 -162
- package/src/index.ts +1 -1
- package/src/ix-tile-picker-styles.ts +225 -225
- package/src/ix-tile-picker.ts +3 -3
- package/src/react/IxTilePicker.ts +11 -11
- package/test/ix-tile-picker.test.ts +83 -83
- package/tsconfig.json +21 -21
- package/web-dev-server.config.mjs +27 -27
- package/web-test-runner.config.mjs +43 -41
- package/dist/56b173ab.js +0 -76
- package/dist/index.html +0 -1
- package/dist/sw.js +0 -2
- package/dist/sw.js.map +0 -1
- package/dist/workbox-1fb78e9e.js +0 -2
- package/dist/workbox-1fb78e9e.js.map +0 -1
package/.editorconfig
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# EditorConfig helps developers define and maintain consistent
|
|
2
|
-
# coding styles between different editors and IDEs
|
|
3
|
-
# editorconfig.org
|
|
4
|
-
|
|
5
|
-
root = true
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
[*]
|
|
9
|
-
|
|
10
|
-
# Change these settings to your own preference
|
|
11
|
-
indent_style = space
|
|
12
|
-
indent_size = 2
|
|
13
|
-
|
|
14
|
-
# We recommend you to keep these unchanged
|
|
15
|
-
end_of_line = lf
|
|
16
|
-
charset = utf-8
|
|
17
|
-
trim_trailing_whitespace = true
|
|
18
|
-
insert_final_newline = true
|
|
19
|
-
|
|
20
|
-
[*.md]
|
|
21
|
-
trim_trailing_whitespace = false
|
|
22
|
-
|
|
23
|
-
[*.json]
|
|
24
|
-
indent_size = 2
|
|
25
|
-
|
|
26
|
-
[*.{html,js,md}]
|
|
27
|
-
block_comment_start = /**
|
|
28
|
-
block_comment = *
|
|
29
|
-
block_comment_end = */
|
|
1
|
+
# EditorConfig helps developers define and maintain consistent
|
|
2
|
+
# coding styles between different editors and IDEs
|
|
3
|
+
# editorconfig.org
|
|
4
|
+
|
|
5
|
+
root = true
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
[*]
|
|
9
|
+
|
|
10
|
+
# Change these settings to your own preference
|
|
11
|
+
indent_style = space
|
|
12
|
+
indent_size = 2
|
|
13
|
+
|
|
14
|
+
# We recommend you to keep these unchanged
|
|
15
|
+
end_of_line = lf
|
|
16
|
+
charset = utf-8
|
|
17
|
+
trim_trailing_whitespace = true
|
|
18
|
+
insert_final_newline = true
|
|
19
|
+
|
|
20
|
+
[*.md]
|
|
21
|
+
trim_trailing_whitespace = false
|
|
22
|
+
|
|
23
|
+
[*.json]
|
|
24
|
+
indent_size = 2
|
|
25
|
+
|
|
26
|
+
[*.{html,js,md}]
|
|
27
|
+
block_comment_start = /**
|
|
28
|
+
block_comment = *
|
|
29
|
+
block_comment_end = */
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 ix-tile-picker
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 ix-tile-picker
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
# \<ix-tile-picker>
|
|
2
|
-
|
|
3
|
-
This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm i @digital-realty/ix-tile-picker
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```html
|
|
14
|
-
<script type="module">
|
|
15
|
-
import '@digital-realty/ix-tile-picker';
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
|
-
<ix-tile-picker></ix-tile-picker>
|
|
19
|
-
```
|
|
20
|
-
### In React
|
|
21
|
-
```html
|
|
22
|
-
<script type="module">
|
|
23
|
-
import { IxTilePicker } from '@digital-realty/ix-tile-picker/IxTilePicker'
|
|
24
|
-
</script>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Linting and formatting
|
|
28
|
-
|
|
29
|
-
To scan the project for linting and formatting errors, run
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm run lint
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
To automatically fix linting and formatting errors, run
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
npm run format
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Testing with Web Test Runner
|
|
42
|
-
|
|
43
|
-
To execute a single test run:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
npm run test
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
To run the tests in interactive watch mode run:
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npm run test:watch
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
## Tooling configs
|
|
57
|
-
|
|
58
|
-
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
59
|
-
|
|
60
|
-
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
61
|
-
|
|
62
|
-
## Local Demo with `web-dev-server`
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
npm start
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
To run a local development server that serves the basic demo located in `demo/index.html`
|
|
1
|
+
# \<ix-tile-picker>
|
|
2
|
+
|
|
3
|
+
This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @digital-realty/ix-tile-picker
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<script type="module">
|
|
15
|
+
import '@digital-realty/ix-tile-picker';
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<ix-tile-picker></ix-tile-picker>
|
|
19
|
+
```
|
|
20
|
+
### In React
|
|
21
|
+
```html
|
|
22
|
+
<script type="module">
|
|
23
|
+
import { IxTilePicker } from '@digital-realty/ix-tile-picker/IxTilePicker'
|
|
24
|
+
</script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Linting and formatting
|
|
28
|
+
|
|
29
|
+
To scan the project for linting and formatting errors, run
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run lint
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
To automatically fix linting and formatting errors, run
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm run format
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Testing with Web Test Runner
|
|
42
|
+
|
|
43
|
+
To execute a single test run:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm run test
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
To run the tests in interactive watch mode run:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm run test:watch
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Tooling configs
|
|
57
|
+
|
|
58
|
+
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
59
|
+
|
|
60
|
+
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
61
|
+
|
|
62
|
+
## Local Demo with `web-dev-server`
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm start
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
To run a local development server that serves the basic demo located in `demo/index.html`
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
import '@material/web/elevation/elevation.js';
|
|
3
|
-
import '@digital-realty/ix-search-bar';
|
|
4
|
-
export interface Item {
|
|
5
|
-
id?: string;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
hidden?: boolean;
|
|
8
|
-
disabledButtonText?: string;
|
|
9
|
-
company?: string;
|
|
10
|
-
cloudAccessId?: string;
|
|
11
|
-
usedBandwidth?: number;
|
|
12
|
-
totalBandwidth?: number;
|
|
13
|
-
}
|
|
14
|
-
type FilterResultsEvent = CustomEvent<{
|
|
15
|
-
items: Item[];
|
|
16
|
-
}>;
|
|
17
|
-
export declare class IxTilePicker extends LitElement {
|
|
18
|
-
static get styles(): import("lit").CSSResult[];
|
|
19
|
-
items: Array<Item>;
|
|
20
|
-
searchFields: Array<string>;
|
|
21
|
-
foundItems: Array<Item>;
|
|
22
|
-
onSelectTile: Function | undefined;
|
|
23
|
-
onResultsFound: Function | undefined;
|
|
24
|
-
disabledText: string;
|
|
25
|
-
selectedText: string;
|
|
26
|
-
chooseText: string;
|
|
27
|
-
value: string;
|
|
28
|
-
connectedCallback(): void;
|
|
29
|
-
filterTiles(results: FilterResultsEvent): void;
|
|
30
|
-
handleClick(e: Event): void;
|
|
31
|
-
getRadioButtonLabelText(item: Item): string;
|
|
32
|
-
getRadioButtonLabelClass(item: Item): import("lit-html/directive.js").DirectiveResult<typeof import("lit-html/directives/class-map.js").ClassMapDirective>;
|
|
33
|
-
renderRadioButtonLabel(item: Item): import("lit-html").TemplateResult<1>;
|
|
34
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
35
|
-
}
|
|
36
|
-
export {};
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import '@material/web/elevation/elevation.js';
|
|
3
|
+
import '@digital-realty/ix-search-bar';
|
|
4
|
+
export interface Item {
|
|
5
|
+
id?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
disabledButtonText?: string;
|
|
9
|
+
company?: string;
|
|
10
|
+
cloudAccessId?: string;
|
|
11
|
+
usedBandwidth?: number;
|
|
12
|
+
totalBandwidth?: number;
|
|
13
|
+
}
|
|
14
|
+
type FilterResultsEvent = CustomEvent<{
|
|
15
|
+
items: Item[];
|
|
16
|
+
}>;
|
|
17
|
+
export declare class IxTilePicker extends LitElement {
|
|
18
|
+
static get styles(): import("lit").CSSResult[];
|
|
19
|
+
items: Array<Item>;
|
|
20
|
+
searchFields: Array<string>;
|
|
21
|
+
foundItems: Array<Item>;
|
|
22
|
+
onSelectTile: Function | undefined;
|
|
23
|
+
onResultsFound: Function | undefined;
|
|
24
|
+
disabledText: string;
|
|
25
|
+
selectedText: string;
|
|
26
|
+
chooseText: string;
|
|
27
|
+
value: string;
|
|
28
|
+
connectedCallback(): void;
|
|
29
|
+
filterTiles(results: FilterResultsEvent): void;
|
|
30
|
+
handleClick(e: Event): void;
|
|
31
|
+
getRadioButtonLabelText(item: Item): string;
|
|
32
|
+
getRadioButtonLabelClass(item: Item): import("lit-html/directive.js").DirectiveResult<typeof import("lit-html/directives/class-map.js").ClassMapDirective>;
|
|
33
|
+
renderRadioButtonLabel(item: Item): import("lit-html").TemplateResult<1>;
|
|
34
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
package/dist/src/IxTilePicker.js
CHANGED
|
@@ -1,156 +1,156 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { html, LitElement, nothing } from 'lit';
|
|
3
|
-
import { property } from 'lit/decorators.js';
|
|
4
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
-
import { IxTilePickerStyles } from './ix-tile-picker-styles.js';
|
|
6
|
-
import '@material/web/elevation/elevation.js';
|
|
7
|
-
import '@digital-realty/ix-search-bar';
|
|
8
|
-
export class IxTilePicker extends LitElement {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.items = [];
|
|
12
|
-
this.searchFields = [];
|
|
13
|
-
this.foundItems = [];
|
|
14
|
-
this.onSelectTile = undefined;
|
|
15
|
-
this.onResultsFound = undefined;
|
|
16
|
-
this.disabledText = 'Disabled';
|
|
17
|
-
this.selectedText = 'Selected';
|
|
18
|
-
this.chooseText = 'Choose';
|
|
19
|
-
this.value = '';
|
|
20
|
-
}
|
|
21
|
-
static get styles() {
|
|
22
|
-
return [IxTilePickerStyles];
|
|
23
|
-
}
|
|
24
|
-
connectedCallback() {
|
|
25
|
-
super.connectedCallback();
|
|
26
|
-
this.foundItems = this.items;
|
|
27
|
-
}
|
|
28
|
-
filterTiles(results) {
|
|
29
|
-
this.foundItems = this.items.map((item) => {
|
|
30
|
-
var _a;
|
|
31
|
-
return ({
|
|
32
|
-
...item,
|
|
33
|
-
hidden: !((_a = results === null || results === void 0 ? void 0 : results.detail) === null || _a === void 0 ? void 0 : _a.items.includes(item)),
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
if (this.onResultsFound) {
|
|
37
|
-
this.onResultsFound(this.foundItems);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
handleClick(e) {
|
|
41
|
-
const { target } = e;
|
|
42
|
-
this.value = target.value || '';
|
|
43
|
-
if (this.onSelectTile) {
|
|
44
|
-
this.onSelectTile(this.value);
|
|
45
|
-
}
|
|
46
|
-
const foundItem = this.foundItems.find((item) => item.id === this.value);
|
|
47
|
-
if (foundItem) {
|
|
48
|
-
this.renderRadioButtonLabel(foundItem);
|
|
49
|
-
}
|
|
50
|
-
this.requestUpdate();
|
|
51
|
-
}
|
|
52
|
-
getRadioButtonLabelText(item) {
|
|
53
|
-
if (item.disabled)
|
|
54
|
-
return item.disabledButtonText || this.disabledText;
|
|
55
|
-
if (item.id === this.value)
|
|
56
|
-
return this.selectedText;
|
|
57
|
-
return this.chooseText;
|
|
58
|
-
}
|
|
59
|
-
getRadioButtonLabelClass(item) {
|
|
60
|
-
return classMap({
|
|
61
|
-
'-disabled': (item === null || item === void 0 ? void 0 : item.disabled) || false,
|
|
62
|
-
'-checked': item.id === this.value,
|
|
63
|
-
'-unselected': item.id !== this.value,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
renderRadioButtonLabel(item) {
|
|
67
|
-
return html `<label
|
|
68
|
-
for="tile-${item.id}"
|
|
69
|
-
class="tile-radio-btn__label ${this.getRadioButtonLabelClass(item)}"
|
|
70
|
-
aria-hidden="true"
|
|
71
|
-
>${this.getRadioButtonLabelText(item)}</label
|
|
72
|
-
>`;
|
|
73
|
-
}
|
|
74
|
-
render() {
|
|
75
|
-
return html `
|
|
76
|
-
<ix-search-bar
|
|
77
|
-
.items="${this.items}"
|
|
78
|
-
.searchFields="${this.searchFields}"
|
|
79
|
-
@onResultsFound="${this.filterTiles}"
|
|
80
|
-
></ix-search-bar>
|
|
81
|
-
|
|
82
|
-
<div class="tiles">
|
|
83
|
-
${this.foundItems.length
|
|
84
|
-
? this.foundItems.map((item, index) => html `
|
|
85
|
-
<div
|
|
86
|
-
class="tile surface ${classMap({
|
|
87
|
-
'-disabled': (item === null || item === void 0 ? void 0 : item.disabled) || false,
|
|
88
|
-
'-hidden': (item === null || item === void 0 ? void 0 : item.hidden) || false,
|
|
89
|
-
})}"
|
|
90
|
-
>
|
|
91
|
-
<md-elevation></md-elevation>
|
|
92
|
-
<header class="tile__header" aria-hidden="true">
|
|
93
|
-
<dl class="tile-heading" id="tileLabel${index}">
|
|
94
|
-
<dt class="tile-heading__label">
|
|
95
|
-
<slot name="label-${item.id}"></slot>
|
|
96
|
-
</dt>
|
|
97
|
-
<dd class="tile-heading__value">
|
|
98
|
-
<slot name="value-${item.id}"></slot>
|
|
99
|
-
</dd>
|
|
100
|
-
</dl>
|
|
101
|
-
</header>
|
|
102
|
-
|
|
103
|
-
<div
|
|
104
|
-
class="tile__body"
|
|
105
|
-
aria-hidden="true"
|
|
106
|
-
id="tileDescription${index}"
|
|
107
|
-
>
|
|
108
|
-
<slot name="body-${item.id}"></slot>
|
|
109
|
-
</div>
|
|
110
|
-
|
|
111
|
-
<span class="tile__footer -full-bleed tile-radio-btn">
|
|
112
|
-
<input
|
|
113
|
-
id="tile-${item.id}"
|
|
114
|
-
type="radio"
|
|
115
|
-
class="tile-radio-btn__input"
|
|
116
|
-
name="picked-tile"
|
|
117
|
-
aria-labelledby="tileLabel${index}"
|
|
118
|
-
aria-describedby="tileDescription${index}"
|
|
119
|
-
.value="${(item === null || item === void 0 ? void 0 : item.id) || ''}"
|
|
120
|
-
@click="${this.handleClick}"
|
|
121
|
-
?disabled="${item.disabled}"
|
|
122
|
-
/>
|
|
123
|
-
${this.renderRadioButtonLabel(item)}
|
|
124
|
-
</span>
|
|
125
|
-
</div>
|
|
126
|
-
`)
|
|
127
|
-
: nothing}
|
|
128
|
-
</div>
|
|
129
|
-
`;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
__decorate([
|
|
133
|
-
property({ type: Array })
|
|
134
|
-
], IxTilePicker.prototype, "items", void 0);
|
|
135
|
-
__decorate([
|
|
136
|
-
property({ type: Array })
|
|
137
|
-
], IxTilePicker.prototype, "searchFields", void 0);
|
|
138
|
-
__decorate([
|
|
139
|
-
property({ type: Array })
|
|
140
|
-
], IxTilePicker.prototype, "foundItems", void 0);
|
|
141
|
-
__decorate([
|
|
142
|
-
property({ attribute: false })
|
|
143
|
-
], IxTilePicker.prototype, "onSelectTile", void 0);
|
|
144
|
-
__decorate([
|
|
145
|
-
property({ attribute: false })
|
|
146
|
-
], IxTilePicker.prototype, "onResultsFound", void 0);
|
|
147
|
-
__decorate([
|
|
148
|
-
property()
|
|
149
|
-
], IxTilePicker.prototype, "disabledText", void 0);
|
|
150
|
-
__decorate([
|
|
151
|
-
property()
|
|
152
|
-
], IxTilePicker.prototype, "selectedText", void 0);
|
|
153
|
-
__decorate([
|
|
154
|
-
property()
|
|
155
|
-
], IxTilePicker.prototype, "chooseText", void 0);
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, LitElement, nothing } from 'lit';
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import { IxTilePickerStyles } from './ix-tile-picker-styles.js';
|
|
6
|
+
import '@material/web/elevation/elevation.js';
|
|
7
|
+
import '@digital-realty/ix-search-bar';
|
|
8
|
+
export class IxTilePicker extends LitElement {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.items = [];
|
|
12
|
+
this.searchFields = [];
|
|
13
|
+
this.foundItems = [];
|
|
14
|
+
this.onSelectTile = undefined;
|
|
15
|
+
this.onResultsFound = undefined;
|
|
16
|
+
this.disabledText = 'Disabled';
|
|
17
|
+
this.selectedText = 'Selected';
|
|
18
|
+
this.chooseText = 'Choose';
|
|
19
|
+
this.value = '';
|
|
20
|
+
}
|
|
21
|
+
static get styles() {
|
|
22
|
+
return [IxTilePickerStyles];
|
|
23
|
+
}
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
super.connectedCallback();
|
|
26
|
+
this.foundItems = this.items;
|
|
27
|
+
}
|
|
28
|
+
filterTiles(results) {
|
|
29
|
+
this.foundItems = this.items.map((item) => {
|
|
30
|
+
var _a;
|
|
31
|
+
return ({
|
|
32
|
+
...item,
|
|
33
|
+
hidden: !((_a = results === null || results === void 0 ? void 0 : results.detail) === null || _a === void 0 ? void 0 : _a.items.includes(item)),
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
if (this.onResultsFound) {
|
|
37
|
+
this.onResultsFound(this.foundItems);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
handleClick(e) {
|
|
41
|
+
const { target } = e;
|
|
42
|
+
this.value = target.value || '';
|
|
43
|
+
if (this.onSelectTile) {
|
|
44
|
+
this.onSelectTile(this.value);
|
|
45
|
+
}
|
|
46
|
+
const foundItem = this.foundItems.find((item) => item.id === this.value);
|
|
47
|
+
if (foundItem) {
|
|
48
|
+
this.renderRadioButtonLabel(foundItem);
|
|
49
|
+
}
|
|
50
|
+
this.requestUpdate();
|
|
51
|
+
}
|
|
52
|
+
getRadioButtonLabelText(item) {
|
|
53
|
+
if (item.disabled)
|
|
54
|
+
return item.disabledButtonText || this.disabledText;
|
|
55
|
+
if (item.id === this.value)
|
|
56
|
+
return this.selectedText;
|
|
57
|
+
return this.chooseText;
|
|
58
|
+
}
|
|
59
|
+
getRadioButtonLabelClass(item) {
|
|
60
|
+
return classMap({
|
|
61
|
+
'-disabled': (item === null || item === void 0 ? void 0 : item.disabled) || false,
|
|
62
|
+
'-checked': item.id === this.value,
|
|
63
|
+
'-unselected': item.id !== this.value,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
renderRadioButtonLabel(item) {
|
|
67
|
+
return html `<label
|
|
68
|
+
for="tile-${item.id}"
|
|
69
|
+
class="tile-radio-btn__label ${this.getRadioButtonLabelClass(item)}"
|
|
70
|
+
aria-hidden="true"
|
|
71
|
+
>${this.getRadioButtonLabelText(item)}</label
|
|
72
|
+
>`;
|
|
73
|
+
}
|
|
74
|
+
render() {
|
|
75
|
+
return html `
|
|
76
|
+
<ix-search-bar
|
|
77
|
+
.items="${this.items}"
|
|
78
|
+
.searchFields="${this.searchFields}"
|
|
79
|
+
@onResultsFound="${this.filterTiles}"
|
|
80
|
+
></ix-search-bar>
|
|
81
|
+
|
|
82
|
+
<div class="tiles">
|
|
83
|
+
${this.foundItems.length
|
|
84
|
+
? this.foundItems.map((item, index) => html `
|
|
85
|
+
<div
|
|
86
|
+
class="tile surface ${classMap({
|
|
87
|
+
'-disabled': (item === null || item === void 0 ? void 0 : item.disabled) || false,
|
|
88
|
+
'-hidden': (item === null || item === void 0 ? void 0 : item.hidden) || false,
|
|
89
|
+
})}"
|
|
90
|
+
>
|
|
91
|
+
<md-elevation></md-elevation>
|
|
92
|
+
<header class="tile__header" aria-hidden="true">
|
|
93
|
+
<dl class="tile-heading" id="tileLabel${index}">
|
|
94
|
+
<dt class="tile-heading__label">
|
|
95
|
+
<slot name="label-${item.id}"></slot>
|
|
96
|
+
</dt>
|
|
97
|
+
<dd class="tile-heading__value">
|
|
98
|
+
<slot name="value-${item.id}"></slot>
|
|
99
|
+
</dd>
|
|
100
|
+
</dl>
|
|
101
|
+
</header>
|
|
102
|
+
|
|
103
|
+
<div
|
|
104
|
+
class="tile__body"
|
|
105
|
+
aria-hidden="true"
|
|
106
|
+
id="tileDescription${index}"
|
|
107
|
+
>
|
|
108
|
+
<slot name="body-${item.id}"></slot>
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<span class="tile__footer -full-bleed tile-radio-btn">
|
|
112
|
+
<input
|
|
113
|
+
id="tile-${item.id}"
|
|
114
|
+
type="radio"
|
|
115
|
+
class="tile-radio-btn__input"
|
|
116
|
+
name="picked-tile"
|
|
117
|
+
aria-labelledby="tileLabel${index}"
|
|
118
|
+
aria-describedby="tileDescription${index}"
|
|
119
|
+
.value="${(item === null || item === void 0 ? void 0 : item.id) || ''}"
|
|
120
|
+
@click="${this.handleClick}"
|
|
121
|
+
?disabled="${item.disabled}"
|
|
122
|
+
/>
|
|
123
|
+
${this.renderRadioButtonLabel(item)}
|
|
124
|
+
</span>
|
|
125
|
+
</div>
|
|
126
|
+
`)
|
|
127
|
+
: nothing}
|
|
128
|
+
</div>
|
|
129
|
+
`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
__decorate([
|
|
133
|
+
property({ type: Array })
|
|
134
|
+
], IxTilePicker.prototype, "items", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
property({ type: Array })
|
|
137
|
+
], IxTilePicker.prototype, "searchFields", void 0);
|
|
138
|
+
__decorate([
|
|
139
|
+
property({ type: Array })
|
|
140
|
+
], IxTilePicker.prototype, "foundItems", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
property({ attribute: false })
|
|
143
|
+
], IxTilePicker.prototype, "onSelectTile", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
property({ attribute: false })
|
|
146
|
+
], IxTilePicker.prototype, "onResultsFound", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
property()
|
|
149
|
+
], IxTilePicker.prototype, "disabledText", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
property()
|
|
152
|
+
], IxTilePicker.prototype, "selectedText", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
property()
|
|
155
|
+
], IxTilePicker.prototype, "chooseText", void 0);
|
|
156
156
|
//# sourceMappingURL=IxTilePicker.js.map
|