2023-10-29 20:22:30 -04:00
|
|
|
import {LitElement, html} from './lit-all.min.js';
|
|
|
|
import * as tfrpc from '/static/tfrpc.js';
|
|
|
|
|
|
|
|
/*
|
2024-02-22 09:36:45 -05:00
|
|
|
** Provide a list of IDs, and this lets the user pick one.
|
|
|
|
*/
|
2023-10-29 20:22:30 -04:00
|
|
|
class TfIdentityPickerElement extends LitElement {
|
|
|
|
static get properties() {
|
|
|
|
return {
|
|
|
|
ids: {type: Array},
|
|
|
|
selected: {type: String},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.ids = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
changed(event) {
|
|
|
|
this.selected = event.srcElement.value;
|
2024-02-22 09:36:45 -05:00
|
|
|
this.dispatchEvent(
|
|
|
|
new Event('change', {
|
|
|
|
srcElement: this,
|
|
|
|
})
|
|
|
|
);
|
2023-10-29 20:22:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return html`
|
|
|
|
<select @change=${this.changed} style="max-width: 100%">
|
2024-02-22 09:36:45 -05:00
|
|
|
${(this.ids ?? []).map(
|
|
|
|
(id) =>
|
|
|
|
html`<option ?selected=${id == this.selected} value=${id}>
|
|
|
|
${id}
|
|
|
|
</option>`
|
|
|
|
)}
|
2023-10-29 20:22:30 -04:00
|
|
|
</select>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-22 09:36:45 -05:00
|
|
|
customElements.define('tf-id-picker', TfIdentityPickerElement);
|