@corti/dictation-web 0.0.1
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 -0
- package/.eslintrc.json +16 -0
- package/.husky/pre-commit +1 -0
- package/.storybook/main.js +8 -0
- package/README.md +120 -0
- package/demo/index.html +98 -0
- package/dist/src/CortiDictation.d.ts +19 -0
- package/dist/src/CortiDictation.js +137 -0
- package/dist/src/CortiDictation.js.map +1 -0
- package/dist/src/DictationService.d.ts +13 -0
- package/dist/src/DictationService.js +70 -0
- package/dist/src/DictationService.js.map +1 -0
- package/dist/src/RecorderManager.d.ts +20 -0
- package/dist/src/RecorderManager.js +85 -0
- package/dist/src/RecorderManager.js.map +1 -0
- package/dist/src/audioRecorderManager.d.ts +17 -0
- package/dist/src/audioRecorderManager.js +78 -0
- package/dist/src/audioRecorderManager.js.map +1 -0
- package/dist/src/audioService.d.ts +6 -0
- package/dist/src/audioService.js +21 -0
- package/dist/src/audioService.js.map +1 -0
- package/dist/src/componentStyles.d.ts +1 -0
- package/dist/src/componentStyles.js +51 -0
- package/dist/src/componentStyles.js.map +1 -0
- package/dist/src/components/audio-visualiser.d.ts +12 -0
- package/dist/src/components/audio-visualiser.js +60 -0
- package/dist/src/components/audio-visualiser.js.map +1 -0
- package/dist/src/components/settings-menu.d.ts +15 -0
- package/dist/src/components/settings-menu.js +148 -0
- package/dist/src/components/settings-menu.js.map +1 -0
- package/dist/src/components/visualiser.d.ts +7 -0
- package/dist/src/components/visualiser.js +62 -0
- package/dist/src/components/visualiser.js.map +1 -0
- package/dist/src/constants.d.ts +3 -0
- package/dist/src/constants.js +9 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/corti-dictation.d.ts +1 -0
- package/dist/src/corti-dictation.js +3 -0
- package/dist/src/corti-dictation.js.map +1 -0
- package/dist/src/dictationService.d.ts +13 -0
- package/dist/src/dictationService.js +70 -0
- package/dist/src/dictationService.js.map +1 -0
- package/dist/src/icons/icons.d.ts +17 -0
- package/dist/src/icons/icons.js +153 -0
- package/dist/src/icons/icons.js.map +1 -0
- package/dist/src/icons/index.d.ts +0 -0
- package/dist/src/icons/index.js +2 -0
- package/dist/src/icons/index.js.map +1 -0
- package/dist/src/icons/micOn.d.ts +7 -0
- package/dist/src/icons/micOn.js +25 -0
- package/dist/src/icons/micOn.js.map +1 -0
- package/dist/src/index.d.ts +20 -0
- package/dist/src/index.js +147 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mediaRecorderService.d.ts +6 -0
- package/dist/src/mediaRecorderService.js +31 -0
- package/dist/src/mediaRecorderService.js.map +1 -0
- package/dist/src/mic-selector.d.ts +18 -0
- package/dist/src/mic-selector.js +131 -0
- package/dist/src/mic-selector.js.map +1 -0
- package/dist/src/settings-menu.d.ts +18 -0
- package/dist/src/settings-menu.js +131 -0
- package/dist/src/settings-menu.js.map +1 -0
- package/dist/src/settings-popover.d.ts +18 -0
- package/dist/src/settings-popover.js +131 -0
- package/dist/src/settings-popover.js.map +1 -0
- package/dist/src/settings.d.ts +18 -0
- package/dist/src/settings.js +131 -0
- package/dist/src/settings.js.map +1 -0
- package/dist/src/styles/ComponentStyles.d.ts +2 -0
- package/dist/src/styles/ComponentStyles.js +52 -0
- package/dist/src/styles/ComponentStyles.js.map +1 -0
- package/dist/src/styles/buttons.d.ts +2 -0
- package/dist/src/styles/buttons.js +58 -0
- package/dist/src/styles/buttons.js.map +1 -0
- package/dist/src/styles/callout.d.ts +2 -0
- package/dist/src/styles/callout.js +26 -0
- package/dist/src/styles/callout.js.map +1 -0
- package/dist/src/styles/select.d.ts +2 -0
- package/dist/src/styles/select.js +36 -0
- package/dist/src/styles/select.js.map +1 -0
- package/dist/src/styles/theme.d.ts +2 -0
- package/dist/src/styles/theme.js +74 -0
- package/dist/src/styles/theme.js.map +1 -0
- package/dist/src/types.d.ts +20 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +31 -0
- package/dist/src/utils.js +77 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/stories/index.stories.d.ts +33 -0
- package/dist/stories/index.stories.js +37 -0
- package/dist/stories/index.stories.js.map +1 -0
- package/dist/test/corti-dictation.test.d.ts +1 -0
- package/dist/test/corti-dictation.test.js +100 -0
- package/dist/test/corti-dictation.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/docs/DEV_README.md +80 -0
- package/package.json +92 -0
- package/src/DictationService.ts +99 -0
- package/src/RecorderManager.ts +114 -0
- package/src/audioService.ts +25 -0
- package/src/components/audio-visualiser.ts +56 -0
- package/src/components/settings-menu.ts +152 -0
- package/src/constants.ts +10 -0
- package/src/corti-dictation.ts +3 -0
- package/src/icons/icons.ts +141 -0
- package/src/icons/index.ts +0 -0
- package/src/index.ts +154 -0
- package/src/styles/ComponentStyles.ts +53 -0
- package/src/styles/buttons.ts +59 -0
- package/src/styles/callout.ts +27 -0
- package/src/styles/select.ts +37 -0
- package/src/styles/theme.ts +75 -0
- package/src/types.ts +28 -0
- package/src/utils.ts +83 -0
- package/stories/index.stories.ts +60 -0
- package/test/corti-dictation.test.ts +124 -0
- package/tsconfig.json +22 -0
- package/web-dev-server.config.js +27 -0
- package/web-test-runner.config.js +41 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
// mic-selector.ts
|
|
3
|
+
import { LitElement, html, css } from 'lit';
|
|
4
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
5
|
+
import ButtonStyles from './styles/buttons';
|
|
6
|
+
import SelectStyles from './styles/select';
|
|
7
|
+
let MicSelector = class MicSelector extends LitElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.devices = [];
|
|
11
|
+
this.selectedDevice = '';
|
|
12
|
+
}
|
|
13
|
+
_selectDevice(device) {
|
|
14
|
+
this.selectedDevice = device.deviceId;
|
|
15
|
+
this.dispatchEvent(new CustomEvent('recording-device-changed', {
|
|
16
|
+
detail: device,
|
|
17
|
+
bubbles: true,
|
|
18
|
+
composed: true,
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
return html `
|
|
23
|
+
<div class="mic-selector">
|
|
24
|
+
<button id="settings-popover-button" popovertarget="settings-popover">
|
|
25
|
+
<icon-settings></icon-settings>
|
|
26
|
+
</button>
|
|
27
|
+
<div id="settings-popover" popover>
|
|
28
|
+
<label id="device-select-label" for="device-select">
|
|
29
|
+
Recording Device
|
|
30
|
+
</label>
|
|
31
|
+
<select
|
|
32
|
+
id="device-select"
|
|
33
|
+
aria-labelledby="device-select-label"
|
|
34
|
+
@change=${(e) => {
|
|
35
|
+
const target = e.target;
|
|
36
|
+
const selectedDevice = this.devices.find(device => device.deviceId === target.value);
|
|
37
|
+
if (selectedDevice) {
|
|
38
|
+
this._selectDevice(selectedDevice);
|
|
39
|
+
}
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
${this.devices.map(device => html `
|
|
43
|
+
<option
|
|
44
|
+
value=${device.deviceId}
|
|
45
|
+
?selected=${this.selectedDevice === device.deviceId}
|
|
46
|
+
>
|
|
47
|
+
${device.label || 'Unknown Device'}
|
|
48
|
+
</option>
|
|
49
|
+
`)}
|
|
50
|
+
</select>
|
|
51
|
+
<!-- ${this.devices.map(device => html `
|
|
52
|
+
<div
|
|
53
|
+
class="dropdown-item ${this.selectedDevice === device.deviceId
|
|
54
|
+
? 'selected'
|
|
55
|
+
: ''}"
|
|
56
|
+
@click=${() => this._selectDevice(device)}
|
|
57
|
+
>
|
|
58
|
+
${device.label || 'Unknown Device'}
|
|
59
|
+
</div>
|
|
60
|
+
`)} -->
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
MicSelector.styles = [
|
|
67
|
+
css `
|
|
68
|
+
:host {
|
|
69
|
+
display: block;
|
|
70
|
+
font-family: var(--component-font-family);
|
|
71
|
+
}
|
|
72
|
+
.label {
|
|
73
|
+
font-size: 0.8rem;
|
|
74
|
+
color: var(--component-text-color);
|
|
75
|
+
margin-bottom: 4px;
|
|
76
|
+
}
|
|
77
|
+
/* Retain the anchor-name styling for this component */
|
|
78
|
+
#settings-popover-button {
|
|
79
|
+
anchor-name: --settings_popover_btn;
|
|
80
|
+
}
|
|
81
|
+
[popover] {
|
|
82
|
+
margin: 0;
|
|
83
|
+
padding: 16px;
|
|
84
|
+
border: 0;
|
|
85
|
+
background: var(--card-background);
|
|
86
|
+
border: 1px solid var(--card-border-color);
|
|
87
|
+
border-radius: var(--card-border-radius);
|
|
88
|
+
box-shadow: var(--card-box-shadow);
|
|
89
|
+
z-index: 1000;
|
|
90
|
+
max-width: 260px;
|
|
91
|
+
position-anchor: --settings_popover_btn;
|
|
92
|
+
position-area: bottom;
|
|
93
|
+
position-visibility: always;
|
|
94
|
+
/* inset: unset; */
|
|
95
|
+
transform: translateX(45%);
|
|
96
|
+
overflow-x: hidden;
|
|
97
|
+
}
|
|
98
|
+
.dropdown-item {
|
|
99
|
+
padding: 8px;
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
font-size: 0.9rem;
|
|
102
|
+
color: var(--component-text-color);
|
|
103
|
+
// allow only a single line of text and truncate the rest
|
|
104
|
+
width: 100%;
|
|
105
|
+
overflow: hidden;
|
|
106
|
+
text-overflow: ellipsis;
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
opacity: 0.8;
|
|
109
|
+
}
|
|
110
|
+
.dropdown-item:hover {
|
|
111
|
+
background: var(--action-plain-background-hover);
|
|
112
|
+
}
|
|
113
|
+
.dropdown-item.selected {
|
|
114
|
+
font-weight: bold;
|
|
115
|
+
opacity: 1;
|
|
116
|
+
}
|
|
117
|
+
`,
|
|
118
|
+
ButtonStyles,
|
|
119
|
+
SelectStyles,
|
|
120
|
+
];
|
|
121
|
+
__decorate([
|
|
122
|
+
property({ type: Array })
|
|
123
|
+
], MicSelector.prototype, "devices", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
property({ type: String })
|
|
126
|
+
], MicSelector.prototype, "selectedDevice", void 0);
|
|
127
|
+
MicSelector = __decorate([
|
|
128
|
+
customElement('mic-selector')
|
|
129
|
+
], MicSelector);
|
|
130
|
+
export { MicSelector };
|
|
131
|
+
//# sourceMappingURL=mic-selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mic-selector.js","sourceRoot":"","sources":["../../src/mic-selector.ts"],"names":[],"mappings":";AAAA,kBAAkB;AAClB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAQpC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAEL,YAAO,GAAa,EAAE,CAAC;QAGvB,mBAAc,GAAW,EAAE,CAAC;IAuH9B,CAAC;IA7DS,aAAa,CAAC,MAAc;QAClC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,0BAA0B,EAAE;YAC1C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;;;;;;sBAYO,CAAC,CAAQ,EAAE,EAAE;YACrB,MAAM,MAAM,GAAG,CAAC,CAAC,MAA2B,CAAC;YAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CACtC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,KAAK,CAC3C,CAAC;YACF,IAAI,cAAc,EAAE,CAAC;gBACnB,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;;cAEC,IAAI,CAAC,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA;;0BAEF,MAAM,CAAC,QAAQ;8BACX,IAAI,CAAC,cAAc,KAAK,MAAM,CAAC,QAAQ;;oBAEjD,MAAM,CAAC,KAAK,IAAI,gBAAgB;;eAErC,CACF;;iBAEI,IAAI,CAAC,OAAO,CAAC,GAAG,CACrB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA;;uCAEa,IAAI,CAAC,cAAc,KAAK,MAAM,CAAC,QAAQ;YAC5D,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,EAAE;yBACG,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;;kBAEvC,MAAM,CAAC,KAAK,IAAI,gBAAgB;;aAErC,CACF;;;KAGN,CAAC;IACJ,CAAC;;AApHM,kBAAM,GAAmB;IAC9B,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkDF;IACD,YAAY;IACZ,YAAY;CACb,AAtDY,CAsDX;AA3DF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;4CACH;AAGvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDACC;AALjB,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA4HvB","sourcesContent":["// mic-selector.ts\nimport { LitElement, html, css, TemplateResult, CSSResultGroup } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport ButtonStyles from './styles/buttons';\nimport SelectStyles from './styles/select';\n\ninterface Device {\n deviceId: string;\n label?: string;\n}\n\n@customElement('mic-selector')\nexport class MicSelector extends LitElement {\n @property({ type: Array })\n devices: Device[] = [];\n\n @property({ type: String })\n selectedDevice: string = '';\n\n static styles: CSSResultGroup = [\n css`\n :host {\n display: block;\n font-family: var(--component-font-family);\n }\n .label {\n font-size: 0.8rem;\n color: var(--component-text-color);\n margin-bottom: 4px;\n }\n /* Retain the anchor-name styling for this component */\n #settings-popover-button {\n anchor-name: --settings_popover_btn;\n }\n [popover] {\n margin: 0;\n padding: 16px;\n border: 0;\n background: var(--card-background);\n border: 1px solid var(--card-border-color);\n border-radius: var(--card-border-radius);\n box-shadow: var(--card-box-shadow);\n z-index: 1000;\n max-width: 260px;\n position-anchor: --settings_popover_btn;\n position-area: bottom;\n position-visibility: always;\n /* inset: unset; */\n transform: translateX(45%);\n overflow-x: hidden;\n }\n .dropdown-item {\n padding: 8px;\n cursor: pointer;\n font-size: 0.9rem;\n color: var(--component-text-color);\n // allow only a single line of text and truncate the rest\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n opacity: 0.8;\n }\n .dropdown-item:hover {\n background: var(--action-plain-background-hover);\n }\n .dropdown-item.selected {\n font-weight: bold;\n opacity: 1;\n }\n `,\n ButtonStyles,\n SelectStyles,\n ];\n\n private _selectDevice(device: Device): void {\n this.selectedDevice = device.deviceId;\n this.dispatchEvent(\n new CustomEvent('recording-device-changed', {\n detail: device,\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n render(): TemplateResult {\n return html`\n <div class=\"mic-selector\">\n <button id=\"settings-popover-button\" popovertarget=\"settings-popover\">\n <icon-settings></icon-settings>\n </button>\n <div id=\"settings-popover\" popover>\n <label id=\"device-select-label\" for=\"device-select\">\n Recording Device\n </label>\n <select\n id=\"device-select\"\n aria-labelledby=\"device-select-label\"\n @change=${(e: Event) => {\n const target = e.target as HTMLSelectElement;\n const selectedDevice = this.devices.find(\n device => device.deviceId === target.value,\n );\n if (selectedDevice) {\n this._selectDevice(selectedDevice);\n }\n }}\n >\n ${this.devices.map(\n device => html`\n <option\n value=${device.deviceId}\n ?selected=${this.selectedDevice === device.deviceId}\n >\n ${device.label || 'Unknown Device'}\n </option>\n `,\n )}\n </select>\n <!-- ${this.devices.map(\n device => html`\n <div\n class=\"dropdown-item ${this.selectedDevice === device.deviceId\n ? 'selected'\n : ''}\"\n @click=${() => this._selectDevice(device)}\n >\n ${device.label || 'Unknown Device'}\n </div>\n `,\n )} -->\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mic-selector': MicSelector;\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LitElement, TemplateResult, CSSResultGroup } from 'lit';
|
|
2
|
+
interface Device {
|
|
3
|
+
deviceId: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class MicSelector extends LitElement {
|
|
7
|
+
devices: Device[];
|
|
8
|
+
selectedDevice: string;
|
|
9
|
+
static styles: CSSResultGroup;
|
|
10
|
+
private _selectDevice;
|
|
11
|
+
render(): TemplateResult;
|
|
12
|
+
}
|
|
13
|
+
declare global {
|
|
14
|
+
interface HTMLElementTagNameMap {
|
|
15
|
+
'mic-selector': MicSelector;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
// mic-selector.ts
|
|
3
|
+
import { LitElement, html, css } from 'lit';
|
|
4
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
5
|
+
import ButtonStyles from './styles/buttons';
|
|
6
|
+
import SelectStyles from './styles/select';
|
|
7
|
+
let MicSelector = class MicSelector extends LitElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.devices = [];
|
|
11
|
+
this.selectedDevice = '';
|
|
12
|
+
}
|
|
13
|
+
_selectDevice(device) {
|
|
14
|
+
this.selectedDevice = device.deviceId;
|
|
15
|
+
this.dispatchEvent(new CustomEvent('recording-device-changed', {
|
|
16
|
+
detail: device,
|
|
17
|
+
bubbles: true,
|
|
18
|
+
composed: true,
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
return html `
|
|
23
|
+
<div class="mic-selector">
|
|
24
|
+
<button id="settings-popover-button" popovertarget="settings-popover">
|
|
25
|
+
<icon-settings></icon-settings>
|
|
26
|
+
</button>
|
|
27
|
+
<div id="settings-popover" popover>
|
|
28
|
+
<label id="device-select-label" for="device-select">
|
|
29
|
+
Recording Device
|
|
30
|
+
</label>
|
|
31
|
+
<select
|
|
32
|
+
id="device-select"
|
|
33
|
+
aria-labelledby="device-select-label"
|
|
34
|
+
@change=${(e) => {
|
|
35
|
+
const target = e.target;
|
|
36
|
+
const selectedDevice = this.devices.find(device => device.deviceId === target.value);
|
|
37
|
+
if (selectedDevice) {
|
|
38
|
+
this._selectDevice(selectedDevice);
|
|
39
|
+
}
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
${this.devices.map(device => html `
|
|
43
|
+
<option
|
|
44
|
+
value=${device.deviceId}
|
|
45
|
+
?selected=${this.selectedDevice === device.deviceId}
|
|
46
|
+
>
|
|
47
|
+
${device.label || 'Unknown Device'}
|
|
48
|
+
</option>
|
|
49
|
+
`)}
|
|
50
|
+
</select>
|
|
51
|
+
<!-- ${this.devices.map(device => html `
|
|
52
|
+
<div
|
|
53
|
+
class="dropdown-item ${this.selectedDevice === device.deviceId
|
|
54
|
+
? 'selected'
|
|
55
|
+
: ''}"
|
|
56
|
+
@click=${() => this._selectDevice(device)}
|
|
57
|
+
>
|
|
58
|
+
${device.label || 'Unknown Device'}
|
|
59
|
+
</div>
|
|
60
|
+
`)} -->
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
MicSelector.styles = [
|
|
67
|
+
css `
|
|
68
|
+
:host {
|
|
69
|
+
display: block;
|
|
70
|
+
font-family: var(--component-font-family);
|
|
71
|
+
}
|
|
72
|
+
.label {
|
|
73
|
+
font-size: 0.8rem;
|
|
74
|
+
color: var(--component-text-color);
|
|
75
|
+
margin-bottom: 4px;
|
|
76
|
+
}
|
|
77
|
+
/* Retain the anchor-name styling for this component */
|
|
78
|
+
#settings-popover-button {
|
|
79
|
+
anchor-name: --settings_popover_btn;
|
|
80
|
+
}
|
|
81
|
+
[popover] {
|
|
82
|
+
margin: 0;
|
|
83
|
+
padding: 16px;
|
|
84
|
+
border: 0;
|
|
85
|
+
background: var(--card-background);
|
|
86
|
+
border: 1px solid var(--card-border-color);
|
|
87
|
+
border-radius: var(--card-border-radius);
|
|
88
|
+
box-shadow: var(--card-box-shadow);
|
|
89
|
+
z-index: 1000;
|
|
90
|
+
max-width: 260px;
|
|
91
|
+
position-anchor: --settings_popover_btn;
|
|
92
|
+
position-area: bottom;
|
|
93
|
+
position-visibility: always;
|
|
94
|
+
/* inset: unset; */
|
|
95
|
+
transform: translateX(45%);
|
|
96
|
+
overflow-x: hidden;
|
|
97
|
+
}
|
|
98
|
+
.dropdown-item {
|
|
99
|
+
padding: 8px;
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
font-size: 0.9rem;
|
|
102
|
+
color: var(--component-text-color);
|
|
103
|
+
// allow only a single line of text and truncate the rest
|
|
104
|
+
width: 100%;
|
|
105
|
+
overflow: hidden;
|
|
106
|
+
text-overflow: ellipsis;
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
opacity: 0.8;
|
|
109
|
+
}
|
|
110
|
+
.dropdown-item:hover {
|
|
111
|
+
background: var(--action-plain-background-hover);
|
|
112
|
+
}
|
|
113
|
+
.dropdown-item.selected {
|
|
114
|
+
font-weight: bold;
|
|
115
|
+
opacity: 1;
|
|
116
|
+
}
|
|
117
|
+
`,
|
|
118
|
+
ButtonStyles,
|
|
119
|
+
SelectStyles,
|
|
120
|
+
];
|
|
121
|
+
__decorate([
|
|
122
|
+
property({ type: Array })
|
|
123
|
+
], MicSelector.prototype, "devices", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
property({ type: String })
|
|
126
|
+
], MicSelector.prototype, "selectedDevice", void 0);
|
|
127
|
+
MicSelector = __decorate([
|
|
128
|
+
customElement('mic-selector')
|
|
129
|
+
], MicSelector);
|
|
130
|
+
export { MicSelector };
|
|
131
|
+
//# sourceMappingURL=settings-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-menu.js","sourceRoot":"","sources":["../../src/settings-menu.ts"],"names":[],"mappings":";AAAA,kBAAkB;AAClB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAQpC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAEL,YAAO,GAAa,EAAE,CAAC;QAGvB,mBAAc,GAAW,EAAE,CAAC;IAuH9B,CAAC;IA7DS,aAAa,CAAC,MAAc;QAClC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,0BAA0B,EAAE;YAC1C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;;;;;;sBAYO,CAAC,CAAQ,EAAE,EAAE;YACrB,MAAM,MAAM,GAAG,CAAC,CAAC,MAA2B,CAAC;YAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CACtC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,KAAK,CAC3C,CAAC;YACF,IAAI,cAAc,EAAE,CAAC;gBACnB,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;;cAEC,IAAI,CAAC,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA;;0BAEF,MAAM,CAAC,QAAQ;8BACX,IAAI,CAAC,cAAc,KAAK,MAAM,CAAC,QAAQ;;oBAEjD,MAAM,CAAC,KAAK,IAAI,gBAAgB;;eAErC,CACF;;iBAEI,IAAI,CAAC,OAAO,CAAC,GAAG,CACrB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA;;uCAEa,IAAI,CAAC,cAAc,KAAK,MAAM,CAAC,QAAQ;YAC5D,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,EAAE;yBACG,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;;kBAEvC,MAAM,CAAC,KAAK,IAAI,gBAAgB;;aAErC,CACF;;;KAGN,CAAC;IACJ,CAAC;;AApHM,kBAAM,GAAmB;IAC9B,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkDF;IACD,YAAY;IACZ,YAAY;CACb,AAtDY,CAsDX;AA3DF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;4CACH;AAGvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDACC;AALjB,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA4HvB","sourcesContent":["// mic-selector.ts\nimport { LitElement, html, css, TemplateResult, CSSResultGroup } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport ButtonStyles from './styles/buttons';\nimport SelectStyles from './styles/select';\n\ninterface Device {\n deviceId: string;\n label?: string;\n}\n\n@customElement('mic-selector')\nexport class MicSelector extends LitElement {\n @property({ type: Array })\n devices: Device[] = [];\n\n @property({ type: String })\n selectedDevice: string = '';\n\n static styles: CSSResultGroup = [\n css`\n :host {\n display: block;\n font-family: var(--component-font-family);\n }\n .label {\n font-size: 0.8rem;\n color: var(--component-text-color);\n margin-bottom: 4px;\n }\n /* Retain the anchor-name styling for this component */\n #settings-popover-button {\n anchor-name: --settings_popover_btn;\n }\n [popover] {\n margin: 0;\n padding: 16px;\n border: 0;\n background: var(--card-background);\n border: 1px solid var(--card-border-color);\n border-radius: var(--card-border-radius);\n box-shadow: var(--card-box-shadow);\n z-index: 1000;\n max-width: 260px;\n position-anchor: --settings_popover_btn;\n position-area: bottom;\n position-visibility: always;\n /* inset: unset; */\n transform: translateX(45%);\n overflow-x: hidden;\n }\n .dropdown-item {\n padding: 8px;\n cursor: pointer;\n font-size: 0.9rem;\n color: var(--component-text-color);\n // allow only a single line of text and truncate the rest\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n opacity: 0.8;\n }\n .dropdown-item:hover {\n background: var(--action-plain-background-hover);\n }\n .dropdown-item.selected {\n font-weight: bold;\n opacity: 1;\n }\n `,\n ButtonStyles,\n SelectStyles,\n ];\n\n private _selectDevice(device: Device): void {\n this.selectedDevice = device.deviceId;\n this.dispatchEvent(\n new CustomEvent('recording-device-changed', {\n detail: device,\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n render(): TemplateResult {\n return html`\n <div class=\"mic-selector\">\n <button id=\"settings-popover-button\" popovertarget=\"settings-popover\">\n <icon-settings></icon-settings>\n </button>\n <div id=\"settings-popover\" popover>\n <label id=\"device-select-label\" for=\"device-select\">\n Recording Device\n </label>\n <select\n id=\"device-select\"\n aria-labelledby=\"device-select-label\"\n @change=${(e: Event) => {\n const target = e.target as HTMLSelectElement;\n const selectedDevice = this.devices.find(\n device => device.deviceId === target.value,\n );\n if (selectedDevice) {\n this._selectDevice(selectedDevice);\n }\n }}\n >\n ${this.devices.map(\n device => html`\n <option\n value=${device.deviceId}\n ?selected=${this.selectedDevice === device.deviceId}\n >\n ${device.label || 'Unknown Device'}\n </option>\n `,\n )}\n </select>\n <!-- ${this.devices.map(\n device => html`\n <div\n class=\"dropdown-item ${this.selectedDevice === device.deviceId\n ? 'selected'\n : ''}\"\n @click=${() => this._selectDevice(device)}\n >\n ${device.label || 'Unknown Device'}\n </div>\n `,\n )} -->\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mic-selector': MicSelector;\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LitElement, TemplateResult, CSSResultGroup } from 'lit';
|
|
2
|
+
interface Device {
|
|
3
|
+
deviceId: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class MicSelector extends LitElement {
|
|
7
|
+
devices: Device[];
|
|
8
|
+
selectedDevice: string;
|
|
9
|
+
static styles: CSSResultGroup;
|
|
10
|
+
private _selectDevice;
|
|
11
|
+
render(): TemplateResult;
|
|
12
|
+
}
|
|
13
|
+
declare global {
|
|
14
|
+
interface HTMLElementTagNameMap {
|
|
15
|
+
'mic-selector': MicSelector;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
// mic-selector.ts
|
|
3
|
+
import { LitElement, html, css } from 'lit';
|
|
4
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
5
|
+
import ButtonStyles from './styles/buttons';
|
|
6
|
+
import SelectStyles from './styles/select';
|
|
7
|
+
let MicSelector = class MicSelector extends LitElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.devices = [];
|
|
11
|
+
this.selectedDevice = '';
|
|
12
|
+
}
|
|
13
|
+
_selectDevice(device) {
|
|
14
|
+
this.selectedDevice = device.deviceId;
|
|
15
|
+
this.dispatchEvent(new CustomEvent('recording-device-changed', {
|
|
16
|
+
detail: device,
|
|
17
|
+
bubbles: true,
|
|
18
|
+
composed: true,
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
return html `
|
|
23
|
+
<div class="mic-selector">
|
|
24
|
+
<button id="settings-popover-button" popovertarget="settings-popover">
|
|
25
|
+
<icon-settings></icon-settings>
|
|
26
|
+
</button>
|
|
27
|
+
<div id="settings-popover" popover>
|
|
28
|
+
<label id="device-select-label" for="device-select">
|
|
29
|
+
Recording Device
|
|
30
|
+
</label>
|
|
31
|
+
<select
|
|
32
|
+
id="device-select"
|
|
33
|
+
aria-labelledby="device-select-label"
|
|
34
|
+
@change=${(e) => {
|
|
35
|
+
const target = e.target;
|
|
36
|
+
const selectedDevice = this.devices.find(device => device.deviceId === target.value);
|
|
37
|
+
if (selectedDevice) {
|
|
38
|
+
this._selectDevice(selectedDevice);
|
|
39
|
+
}
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
${this.devices.map(device => html `
|
|
43
|
+
<option
|
|
44
|
+
value=${device.deviceId}
|
|
45
|
+
?selected=${this.selectedDevice === device.deviceId}
|
|
46
|
+
>
|
|
47
|
+
${device.label || 'Unknown Device'}
|
|
48
|
+
</option>
|
|
49
|
+
`)}
|
|
50
|
+
</select>
|
|
51
|
+
<!-- ${this.devices.map(device => html `
|
|
52
|
+
<div
|
|
53
|
+
class="dropdown-item ${this.selectedDevice === device.deviceId
|
|
54
|
+
? 'selected'
|
|
55
|
+
: ''}"
|
|
56
|
+
@click=${() => this._selectDevice(device)}
|
|
57
|
+
>
|
|
58
|
+
${device.label || 'Unknown Device'}
|
|
59
|
+
</div>
|
|
60
|
+
`)} -->
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
MicSelector.styles = [
|
|
67
|
+
css `
|
|
68
|
+
:host {
|
|
69
|
+
display: block;
|
|
70
|
+
font-family: var(--component-font-family);
|
|
71
|
+
}
|
|
72
|
+
.label {
|
|
73
|
+
font-size: 0.8rem;
|
|
74
|
+
color: var(--component-text-color);
|
|
75
|
+
margin-bottom: 4px;
|
|
76
|
+
}
|
|
77
|
+
/* Retain the anchor-name styling for this component */
|
|
78
|
+
#settings-popover-button {
|
|
79
|
+
anchor-name: --settings_popover_btn;
|
|
80
|
+
}
|
|
81
|
+
[popover] {
|
|
82
|
+
margin: 0;
|
|
83
|
+
padding: 16px;
|
|
84
|
+
border: 0;
|
|
85
|
+
background: var(--card-background);
|
|
86
|
+
border: 1px solid var(--card-border-color);
|
|
87
|
+
border-radius: var(--card-border-radius);
|
|
88
|
+
box-shadow: var(--card-box-shadow);
|
|
89
|
+
z-index: 1000;
|
|
90
|
+
max-width: 260px;
|
|
91
|
+
position-anchor: --settings_popover_btn;
|
|
92
|
+
position-area: bottom;
|
|
93
|
+
position-visibility: always;
|
|
94
|
+
/* inset: unset; */
|
|
95
|
+
transform: translateX(45%);
|
|
96
|
+
overflow-x: hidden;
|
|
97
|
+
}
|
|
98
|
+
.dropdown-item {
|
|
99
|
+
padding: 8px;
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
font-size: 0.9rem;
|
|
102
|
+
color: var(--component-text-color);
|
|
103
|
+
// allow only a single line of text and truncate the rest
|
|
104
|
+
width: 100%;
|
|
105
|
+
overflow: hidden;
|
|
106
|
+
text-overflow: ellipsis;
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
opacity: 0.8;
|
|
109
|
+
}
|
|
110
|
+
.dropdown-item:hover {
|
|
111
|
+
background: var(--action-plain-background-hover);
|
|
112
|
+
}
|
|
113
|
+
.dropdown-item.selected {
|
|
114
|
+
font-weight: bold;
|
|
115
|
+
opacity: 1;
|
|
116
|
+
}
|
|
117
|
+
`,
|
|
118
|
+
ButtonStyles,
|
|
119
|
+
SelectStyles,
|
|
120
|
+
];
|
|
121
|
+
__decorate([
|
|
122
|
+
property({ type: Array })
|
|
123
|
+
], MicSelector.prototype, "devices", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
property({ type: String })
|
|
126
|
+
], MicSelector.prototype, "selectedDevice", void 0);
|
|
127
|
+
MicSelector = __decorate([
|
|
128
|
+
customElement('mic-selector')
|
|
129
|
+
], MicSelector);
|
|
130
|
+
export { MicSelector };
|
|
131
|
+
//# sourceMappingURL=settings-popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-popover.js","sourceRoot":"","sources":["../../src/settings-popover.ts"],"names":[],"mappings":";AAAA,kBAAkB;AAClB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAQpC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAEL,YAAO,GAAa,EAAE,CAAC;QAGvB,mBAAc,GAAW,EAAE,CAAC;IAuH9B,CAAC;IA7DS,aAAa,CAAC,MAAc;QAClC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,0BAA0B,EAAE;YAC1C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;;;;;;sBAYO,CAAC,CAAQ,EAAE,EAAE;YACrB,MAAM,MAAM,GAAG,CAAC,CAAC,MAA2B,CAAC;YAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CACtC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,KAAK,CAC3C,CAAC;YACF,IAAI,cAAc,EAAE,CAAC;gBACnB,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;;cAEC,IAAI,CAAC,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA;;0BAEF,MAAM,CAAC,QAAQ;8BACX,IAAI,CAAC,cAAc,KAAK,MAAM,CAAC,QAAQ;;oBAEjD,MAAM,CAAC,KAAK,IAAI,gBAAgB;;eAErC,CACF;;iBAEI,IAAI,CAAC,OAAO,CAAC,GAAG,CACrB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA;;uCAEa,IAAI,CAAC,cAAc,KAAK,MAAM,CAAC,QAAQ;YAC5D,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,EAAE;yBACG,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;;kBAEvC,MAAM,CAAC,KAAK,IAAI,gBAAgB;;aAErC,CACF;;;KAGN,CAAC;IACJ,CAAC;;AApHM,kBAAM,GAAmB;IAC9B,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkDF;IACD,YAAY;IACZ,YAAY;CACb,AAtDY,CAsDX;AA3DF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;4CACH;AAGvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDACC;AALjB,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA4HvB","sourcesContent":["// mic-selector.ts\nimport { LitElement, html, css, TemplateResult, CSSResultGroup } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport ButtonStyles from './styles/buttons';\nimport SelectStyles from './styles/select';\n\ninterface Device {\n deviceId: string;\n label?: string;\n}\n\n@customElement('mic-selector')\nexport class MicSelector extends LitElement {\n @property({ type: Array })\n devices: Device[] = [];\n\n @property({ type: String })\n selectedDevice: string = '';\n\n static styles: CSSResultGroup = [\n css`\n :host {\n display: block;\n font-family: var(--component-font-family);\n }\n .label {\n font-size: 0.8rem;\n color: var(--component-text-color);\n margin-bottom: 4px;\n }\n /* Retain the anchor-name styling for this component */\n #settings-popover-button {\n anchor-name: --settings_popover_btn;\n }\n [popover] {\n margin: 0;\n padding: 16px;\n border: 0;\n background: var(--card-background);\n border: 1px solid var(--card-border-color);\n border-radius: var(--card-border-radius);\n box-shadow: var(--card-box-shadow);\n z-index: 1000;\n max-width: 260px;\n position-anchor: --settings_popover_btn;\n position-area: bottom;\n position-visibility: always;\n /* inset: unset; */\n transform: translateX(45%);\n overflow-x: hidden;\n }\n .dropdown-item {\n padding: 8px;\n cursor: pointer;\n font-size: 0.9rem;\n color: var(--component-text-color);\n // allow only a single line of text and truncate the rest\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n opacity: 0.8;\n }\n .dropdown-item:hover {\n background: var(--action-plain-background-hover);\n }\n .dropdown-item.selected {\n font-weight: bold;\n opacity: 1;\n }\n `,\n ButtonStyles,\n SelectStyles,\n ];\n\n private _selectDevice(device: Device): void {\n this.selectedDevice = device.deviceId;\n this.dispatchEvent(\n new CustomEvent('recording-device-changed', {\n detail: device,\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n render(): TemplateResult {\n return html`\n <div class=\"mic-selector\">\n <button id=\"settings-popover-button\" popovertarget=\"settings-popover\">\n <icon-settings></icon-settings>\n </button>\n <div id=\"settings-popover\" popover>\n <label id=\"device-select-label\" for=\"device-select\">\n Recording Device\n </label>\n <select\n id=\"device-select\"\n aria-labelledby=\"device-select-label\"\n @change=${(e: Event) => {\n const target = e.target as HTMLSelectElement;\n const selectedDevice = this.devices.find(\n device => device.deviceId === target.value,\n );\n if (selectedDevice) {\n this._selectDevice(selectedDevice);\n }\n }}\n >\n ${this.devices.map(\n device => html`\n <option\n value=${device.deviceId}\n ?selected=${this.selectedDevice === device.deviceId}\n >\n ${device.label || 'Unknown Device'}\n </option>\n `,\n )}\n </select>\n <!-- ${this.devices.map(\n device => html`\n <div\n class=\"dropdown-item ${this.selectedDevice === device.deviceId\n ? 'selected'\n : ''}\"\n @click=${() => this._selectDevice(device)}\n >\n ${device.label || 'Unknown Device'}\n </div>\n `,\n )} -->\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mic-selector': MicSelector;\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LitElement, TemplateResult, CSSResultGroup } from 'lit';
|
|
2
|
+
interface Device {
|
|
3
|
+
deviceId: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class MicSelector extends LitElement {
|
|
7
|
+
devices: Device[];
|
|
8
|
+
selectedDevice: string;
|
|
9
|
+
static styles: CSSResultGroup;
|
|
10
|
+
private _selectDevice;
|
|
11
|
+
render(): TemplateResult;
|
|
12
|
+
}
|
|
13
|
+
declare global {
|
|
14
|
+
interface HTMLElementTagNameMap {
|
|
15
|
+
'mic-selector': MicSelector;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
// mic-selector.ts
|
|
3
|
+
import { LitElement, html, css } from 'lit';
|
|
4
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
5
|
+
import ButtonStyles from './styles/buttons';
|
|
6
|
+
import SelectStyles from './styles/select';
|
|
7
|
+
let MicSelector = class MicSelector extends LitElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.devices = [];
|
|
11
|
+
this.selectedDevice = '';
|
|
12
|
+
}
|
|
13
|
+
_selectDevice(device) {
|
|
14
|
+
this.selectedDevice = device.deviceId;
|
|
15
|
+
this.dispatchEvent(new CustomEvent('recording-device-changed', {
|
|
16
|
+
detail: device,
|
|
17
|
+
bubbles: true,
|
|
18
|
+
composed: true,
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
return html `
|
|
23
|
+
<div class="mic-selector">
|
|
24
|
+
<button id="settings-popover-button" popovertarget="settings-popover">
|
|
25
|
+
<icon-settings></icon-settings>
|
|
26
|
+
</button>
|
|
27
|
+
<div id="settings-popover" popover>
|
|
28
|
+
<label id="device-select-label" for="device-select">
|
|
29
|
+
Recording Device
|
|
30
|
+
</label>
|
|
31
|
+
<select
|
|
32
|
+
id="device-select"
|
|
33
|
+
aria-labelledby="device-select-label"
|
|
34
|
+
@change=${(e) => {
|
|
35
|
+
const target = e.target;
|
|
36
|
+
const selectedDevice = this.devices.find(device => device.deviceId === target.value);
|
|
37
|
+
if (selectedDevice) {
|
|
38
|
+
this._selectDevice(selectedDevice);
|
|
39
|
+
}
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
${this.devices.map(device => html `
|
|
43
|
+
<option
|
|
44
|
+
value=${device.deviceId}
|
|
45
|
+
?selected=${this.selectedDevice === device.deviceId}
|
|
46
|
+
>
|
|
47
|
+
${device.label || 'Unknown Device'}
|
|
48
|
+
</option>
|
|
49
|
+
`)}
|
|
50
|
+
</select>
|
|
51
|
+
<!-- ${this.devices.map(device => html `
|
|
52
|
+
<div
|
|
53
|
+
class="dropdown-item ${this.selectedDevice === device.deviceId
|
|
54
|
+
? 'selected'
|
|
55
|
+
: ''}"
|
|
56
|
+
@click=${() => this._selectDevice(device)}
|
|
57
|
+
>
|
|
58
|
+
${device.label || 'Unknown Device'}
|
|
59
|
+
</div>
|
|
60
|
+
`)} -->
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
MicSelector.styles = [
|
|
67
|
+
css `
|
|
68
|
+
:host {
|
|
69
|
+
display: block;
|
|
70
|
+
font-family: var(--component-font-family);
|
|
71
|
+
}
|
|
72
|
+
.label {
|
|
73
|
+
font-size: 0.8rem;
|
|
74
|
+
color: var(--component-text-color);
|
|
75
|
+
margin-bottom: 4px;
|
|
76
|
+
}
|
|
77
|
+
/* Retain the anchor-name styling for this component */
|
|
78
|
+
#settings-popover-button {
|
|
79
|
+
anchor-name: --settings_popover_btn;
|
|
80
|
+
}
|
|
81
|
+
[popover] {
|
|
82
|
+
margin: 0;
|
|
83
|
+
padding: 16px;
|
|
84
|
+
border: 0;
|
|
85
|
+
background: var(--card-background);
|
|
86
|
+
border: 1px solid var(--card-border-color);
|
|
87
|
+
border-radius: var(--card-border-radius);
|
|
88
|
+
box-shadow: var(--card-box-shadow);
|
|
89
|
+
z-index: 1000;
|
|
90
|
+
max-width: 260px;
|
|
91
|
+
position-anchor: --settings_popover_btn;
|
|
92
|
+
position-area: bottom;
|
|
93
|
+
position-visibility: always;
|
|
94
|
+
/* inset: unset; */
|
|
95
|
+
transform: translateX(45%);
|
|
96
|
+
overflow-x: hidden;
|
|
97
|
+
}
|
|
98
|
+
.dropdown-item {
|
|
99
|
+
padding: 8px;
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
font-size: 0.9rem;
|
|
102
|
+
color: var(--component-text-color);
|
|
103
|
+
// allow only a single line of text and truncate the rest
|
|
104
|
+
width: 100%;
|
|
105
|
+
overflow: hidden;
|
|
106
|
+
text-overflow: ellipsis;
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
opacity: 0.8;
|
|
109
|
+
}
|
|
110
|
+
.dropdown-item:hover {
|
|
111
|
+
background: var(--action-plain-background-hover);
|
|
112
|
+
}
|
|
113
|
+
.dropdown-item.selected {
|
|
114
|
+
font-weight: bold;
|
|
115
|
+
opacity: 1;
|
|
116
|
+
}
|
|
117
|
+
`,
|
|
118
|
+
ButtonStyles,
|
|
119
|
+
SelectStyles,
|
|
120
|
+
];
|
|
121
|
+
__decorate([
|
|
122
|
+
property({ type: Array })
|
|
123
|
+
], MicSelector.prototype, "devices", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
property({ type: String })
|
|
126
|
+
], MicSelector.prototype, "selectedDevice", void 0);
|
|
127
|
+
MicSelector = __decorate([
|
|
128
|
+
customElement('mic-selector')
|
|
129
|
+
], MicSelector);
|
|
130
|
+
export { MicSelector };
|
|
131
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/settings.ts"],"names":[],"mappings":";AAAA,kBAAkB;AAClB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAQpC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAEL,YAAO,GAAa,EAAE,CAAC;QAGvB,mBAAc,GAAW,EAAE,CAAC;IAuH9B,CAAC;IA7DS,aAAa,CAAC,MAAc;QAClC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,0BAA0B,EAAE;YAC1C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;;;;;;sBAYO,CAAC,CAAQ,EAAE,EAAE;YACrB,MAAM,MAAM,GAAG,CAAC,CAAC,MAA2B,CAAC;YAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CACtC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,KAAK,CAC3C,CAAC;YACF,IAAI,cAAc,EAAE,CAAC;gBACnB,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;;cAEC,IAAI,CAAC,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA;;0BAEF,MAAM,CAAC,QAAQ;8BACX,IAAI,CAAC,cAAc,KAAK,MAAM,CAAC,QAAQ;;oBAEjD,MAAM,CAAC,KAAK,IAAI,gBAAgB;;eAErC,CACF;;iBAEI,IAAI,CAAC,OAAO,CAAC,GAAG,CACrB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA;;uCAEa,IAAI,CAAC,cAAc,KAAK,MAAM,CAAC,QAAQ;YAC5D,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,EAAE;yBACG,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;;kBAEvC,MAAM,CAAC,KAAK,IAAI,gBAAgB;;aAErC,CACF;;;KAGN,CAAC;IACJ,CAAC;;AApHM,kBAAM,GAAmB;IAC9B,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkDF;IACD,YAAY;IACZ,YAAY;CACb,AAtDY,CAsDX;AA3DF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;4CACH;AAGvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDACC;AALjB,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA4HvB","sourcesContent":["// mic-selector.ts\nimport { LitElement, html, css, TemplateResult, CSSResultGroup } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport ButtonStyles from './styles/buttons';\nimport SelectStyles from './styles/select';\n\ninterface Device {\n deviceId: string;\n label?: string;\n}\n\n@customElement('mic-selector')\nexport class MicSelector extends LitElement {\n @property({ type: Array })\n devices: Device[] = [];\n\n @property({ type: String })\n selectedDevice: string = '';\n\n static styles: CSSResultGroup = [\n css`\n :host {\n display: block;\n font-family: var(--component-font-family);\n }\n .label {\n font-size: 0.8rem;\n color: var(--component-text-color);\n margin-bottom: 4px;\n }\n /* Retain the anchor-name styling for this component */\n #settings-popover-button {\n anchor-name: --settings_popover_btn;\n }\n [popover] {\n margin: 0;\n padding: 16px;\n border: 0;\n background: var(--card-background);\n border: 1px solid var(--card-border-color);\n border-radius: var(--card-border-radius);\n box-shadow: var(--card-box-shadow);\n z-index: 1000;\n max-width: 260px;\n position-anchor: --settings_popover_btn;\n position-area: bottom;\n position-visibility: always;\n /* inset: unset; */\n transform: translateX(45%);\n overflow-x: hidden;\n }\n .dropdown-item {\n padding: 8px;\n cursor: pointer;\n font-size: 0.9rem;\n color: var(--component-text-color);\n // allow only a single line of text and truncate the rest\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n opacity: 0.8;\n }\n .dropdown-item:hover {\n background: var(--action-plain-background-hover);\n }\n .dropdown-item.selected {\n font-weight: bold;\n opacity: 1;\n }\n `,\n ButtonStyles,\n SelectStyles,\n ];\n\n private _selectDevice(device: Device): void {\n this.selectedDevice = device.deviceId;\n this.dispatchEvent(\n new CustomEvent('recording-device-changed', {\n detail: device,\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n render(): TemplateResult {\n return html`\n <div class=\"mic-selector\">\n <button id=\"settings-popover-button\" popovertarget=\"settings-popover\">\n <icon-settings></icon-settings>\n </button>\n <div id=\"settings-popover\" popover>\n <label id=\"device-select-label\" for=\"device-select\">\n Recording Device\n </label>\n <select\n id=\"device-select\"\n aria-labelledby=\"device-select-label\"\n @change=${(e: Event) => {\n const target = e.target as HTMLSelectElement;\n const selectedDevice = this.devices.find(\n device => device.deviceId === target.value,\n );\n if (selectedDevice) {\n this._selectDevice(selectedDevice);\n }\n }}\n >\n ${this.devices.map(\n device => html`\n <option\n value=${device.deviceId}\n ?selected=${this.selectedDevice === device.deviceId}\n >\n ${device.label || 'Unknown Device'}\n </option>\n `,\n )}\n </select>\n <!-- ${this.devices.map(\n device => html`\n <div\n class=\"dropdown-item ${this.selectedDevice === device.deviceId\n ? 'selected'\n : ''}\"\n @click=${() => this._selectDevice(device)}\n >\n ${device.label || 'Unknown Device'}\n </div>\n `,\n )} -->\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mic-selector': MicSelector;\n }\n}\n"]}
|