react-select-media-devices-modal 0.0.12 → 1.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/README.md +62 -0
- package/dist/react-select-media-devices-modal.mjs +281 -165
- package/dist/react-select-media-devices-modal.umd.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/SelectMediaDevicesModal/index.d.ts +11 -10
- package/dist/types/SelectMediaDevicesPreviewModal/index.d.ts +11 -10
- package/dist/types/SelectMediaDevicesRecordingModal/index.d.ts +22 -0
- package/dist/types/components/button/index.d.ts +3 -2
- package/dist/types/components/deviceItem/index.d.ts +2 -1
- package/dist/types/components/deviceList/index.d.ts +2 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ A React component library for select media devices.
|
|
|
13
13
|
|
|
14
14
|
- Select audio input, audio output, and video input device.
|
|
15
15
|
- Show preview media stream get from selected device.
|
|
16
|
+
- Record sample audio stream and play.
|
|
16
17
|
|
|
17
18
|
## Demo
|
|
18
19
|
|
|
@@ -110,6 +111,49 @@ function App() {
|
|
|
110
111
|
export default App;
|
|
111
112
|
```
|
|
112
113
|
|
|
114
|
+
### SelectMediaDevicesRecordingModal
|
|
115
|
+
|
|
116
|
+
```jsx
|
|
117
|
+
import { useState } from 'react';
|
|
118
|
+
import { SelectMediaDevicesRecordingModal } from 'react-select-media-devices-modal';
|
|
119
|
+
|
|
120
|
+
function App() {
|
|
121
|
+
const [modalOpen, setModalOpen] = useState(false);
|
|
122
|
+
|
|
123
|
+
const handleDeviceSelected = (devices) => {
|
|
124
|
+
setModalOpen(false);
|
|
125
|
+
console.log(devices);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const handleDeviceSelectCanceled = () => {
|
|
129
|
+
setModalOpen(false);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<div>
|
|
134
|
+
<button onClick={() => setModalOpen((current) => !current)}>Select Device</button>
|
|
135
|
+
<SelectMediaDevicesRecordingModal
|
|
136
|
+
isSelectAudioInput
|
|
137
|
+
isSelectAudioOutput
|
|
138
|
+
isSelectVideoInput
|
|
139
|
+
open={modalOpen}
|
|
140
|
+
audioInputDeviceLabel="Audio input device"
|
|
141
|
+
audioOutputDeviceLabel="Audio output device"
|
|
142
|
+
videoInputDeviceLabel="Video input device"
|
|
143
|
+
confirmButtonText="Confirm"
|
|
144
|
+
cancelButtonText="Cancel"
|
|
145
|
+
recordingButtonText="Recording"
|
|
146
|
+
allowOutsideClick={false}
|
|
147
|
+
onDeviceSelected={handleDeviceSelected}
|
|
148
|
+
onDeviceSelectCanceled={handleDeviceSelectCanceled}
|
|
149
|
+
></SelectMediaDevicesRecordingModal>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export default App;
|
|
155
|
+
```
|
|
156
|
+
|
|
113
157
|
## Props
|
|
114
158
|
|
|
115
159
|
### `SelectMediaDevicesModalProps`
|
|
@@ -146,6 +190,24 @@ export default App;
|
|
|
146
190
|
| onDeviceSelected | `function` | `(devices: { audioInput?: MediaDeviceInfo; audioOutput?: MediaDeviceInfo; videoInput?: MediaDeviceInfo; }) => void` | Handler function called when devices are selected. |
|
|
147
191
|
| onDeviceSelectCanceled | `function` | `() => void` | Handler function called when selection canceled. |
|
|
148
192
|
|
|
193
|
+
### `SelectMediaDevicesRecordingModalProps`
|
|
194
|
+
|
|
195
|
+
| Name | Type | Default | Description |
|
|
196
|
+
| :--- | :--- | :------ | :---------- |
|
|
197
|
+
| isSelectAudioInput | `boolean` | `true` | Flag that select an audio input device or not. |
|
|
198
|
+
| isSelectAudioOutput | `boolean` | `true` | Flag that select an audio output device or not. |
|
|
199
|
+
| isSelectVideoInput | `boolean` | `true` | Flag that select a video input device or not. |
|
|
200
|
+
| open | `boolean` | `false` | Flag that open the modal or not. |
|
|
201
|
+
| audioInputDeviceLabel | `string` | `'audio input device'` | Label for list of audio input devices. |
|
|
202
|
+
| audioOutputDeviceLabel | `string` | `'audio output device'` | Label for list of audio output devices. |
|
|
203
|
+
| videoInputDeviceLabel | `string` | `'video input device'` | Label for list of video input devices. |
|
|
204
|
+
| confirmButtonText | `string` | `'Confirm'` | Label for the confirm button. |
|
|
205
|
+
| cancelButtonText | `string` | `'Cancel'` | Label for the cancel button. |
|
|
206
|
+
| recordingButtonText | `string` | `'Recording'` | Label for the recording button. |
|
|
207
|
+
| allowOutsideClick | `boolean` | `true` | Flag that cancel selection when clicking outside of the modal. |
|
|
208
|
+
| onDeviceSelected | `function` | `(devices: { audioInput?: MediaDeviceInfo; audioOutput?: MediaDeviceInfo; videoInput?: MediaDeviceInfo; }) => void` | Handler function called when devices are selected. |
|
|
209
|
+
| onDeviceSelectCanceled | `function` | `() => void` | Handler function called when selection canceled. |
|
|
210
|
+
|
|
149
211
|
## LICENSE
|
|
150
212
|
|
|
151
213
|
[MIT](https://github.com/kadoshita/react-select-media-devices-modal/blob/master/LICENSE)
|
|
@@ -1,209 +1,325 @@
|
|
|
1
|
-
import e, { useState as
|
|
2
|
-
const
|
|
3
|
-
background:
|
|
4
|
-
modal:
|
|
5
|
-
deviceLists:
|
|
6
|
-
buttons:
|
|
7
|
-
chancelButton:
|
|
8
|
-
confirmButton:
|
|
9
|
-
},
|
|
10
|
-
const [
|
|
11
|
-
return [
|
|
1
|
+
import e, { useState as u, useEffect as L, useRef as K, useMemo as U } from "react";
|
|
2
|
+
const oe = "_background_1djbv_1", ae = "_modal_1djbv_13", se = "_deviceLists_1djbv_20", de = "_buttons_1djbv_24", re = "_chancelButton_1djbv_31", ue = "_confirmButton_1djbv_33", F = {
|
|
3
|
+
background: oe,
|
|
4
|
+
modal: ae,
|
|
5
|
+
deviceLists: se,
|
|
6
|
+
buttons: de,
|
|
7
|
+
chancelButton: re,
|
|
8
|
+
confirmButton: ue
|
|
9
|
+
}, Q = () => {
|
|
10
|
+
const [o, a] = u([]);
|
|
11
|
+
return [o, () => {
|
|
12
12
|
(async () => {
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const c = await navigator.mediaDevices.getUserMedia({ audio: !0, video: !0 }), l = await navigator.mediaDevices.enumerateDevices();
|
|
14
|
+
a(l), c.getTracks().forEach((v) => v.stop());
|
|
15
15
|
})();
|
|
16
16
|
}];
|
|
17
|
-
},
|
|
18
|
-
deviceList:
|
|
19
|
-
select:
|
|
20
|
-
},
|
|
21
|
-
if (
|
|
17
|
+
}, le = ({ name: o, value: a }) => /* @__PURE__ */ e.createElement("option", { value: a }, o), ve = "_deviceList_1bfq1_1", me = "_select_1bfq1_5", W = {
|
|
18
|
+
deviceList: ve,
|
|
19
|
+
select: me
|
|
20
|
+
}, D = ({ devices: o, label: a, onChange: f }) => {
|
|
21
|
+
if (o === void 0)
|
|
22
22
|
return /* @__PURE__ */ e.createElement(e.Fragment, null);
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
return /* @__PURE__ */ e.createElement("div", { className:
|
|
27
|
-
},
|
|
28
|
-
button:
|
|
29
|
-
},
|
|
30
|
-
isSelectAudioInput:
|
|
31
|
-
isSelectAudioOutput:
|
|
32
|
-
isSelectVideoInput:
|
|
33
|
-
open:
|
|
34
|
-
audioInputDeviceLabel:
|
|
35
|
-
audioOutputDeviceLabel:
|
|
36
|
-
videoInputDeviceLabel:
|
|
37
|
-
confirmButtonText:
|
|
38
|
-
cancelButtonText:
|
|
39
|
-
allowOutsideClick:
|
|
40
|
-
onDeviceSelected:
|
|
41
|
-
onDeviceSelectCanceled:
|
|
23
|
+
const c = (v) => {
|
|
24
|
+
f(v.target.value);
|
|
25
|
+
}, l = `device-select-${a.toLowerCase().replace(/\s/g, "-")}`;
|
|
26
|
+
return /* @__PURE__ */ e.createElement("div", { className: W.deviceList }, /* @__PURE__ */ e.createElement("label", { htmlFor: l }, a), /* @__PURE__ */ e.createElement("select", { className: W.select, id: l, onChange: c }, o.map((v, O) => /* @__PURE__ */ e.createElement(le, { value: v.deviceId, name: v.label, key: O }))));
|
|
27
|
+
}, pe = "_button_keu24_1", fe = {
|
|
28
|
+
button: pe
|
|
29
|
+
}, y = ({ className: o, children: a, disabled: f, onClick: c }) => /* @__PURE__ */ e.createElement("button", { onClick: c, disabled: f, className: [fe.button, o].filter(Boolean).join(" ") }, a), Re = ({
|
|
30
|
+
isSelectAudioInput: o = !0,
|
|
31
|
+
isSelectAudioOutput: a = !0,
|
|
32
|
+
isSelectVideoInput: f = !0,
|
|
33
|
+
open: c,
|
|
34
|
+
audioInputDeviceLabel: l = "audio input device",
|
|
35
|
+
audioOutputDeviceLabel: v = "audio output device",
|
|
36
|
+
videoInputDeviceLabel: O = "video input device",
|
|
37
|
+
confirmButtonText: q = "Confirm",
|
|
38
|
+
cancelButtonText: G = "Cancel",
|
|
39
|
+
allowOutsideClick: S = !0,
|
|
40
|
+
onDeviceSelected: R,
|
|
41
|
+
onDeviceSelectCanceled: $
|
|
42
42
|
}) => {
|
|
43
|
-
const [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}, [
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
audioInput:
|
|
50
|
-
audioOutput:
|
|
51
|
-
videoInput:
|
|
43
|
+
const [r, g] = Q(), [M, k] = u(), [j, h] = u(), [A, P] = u(), B = r.filter((i) => i.kind === "audioinput"), C = r.filter((i) => i.kind === "audiooutput"), E = r.filter((i) => i.kind === "videoinput");
|
|
44
|
+
L(() => {
|
|
45
|
+
c && g();
|
|
46
|
+
}, [c]);
|
|
47
|
+
const w = () => {
|
|
48
|
+
R({
|
|
49
|
+
audioInput: M !== void 0 ? M : B[0],
|
|
50
|
+
audioOutput: j !== void 0 ? j : C[0],
|
|
51
|
+
videoInput: A !== void 0 ? A : E[0]
|
|
52
52
|
});
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
|
|
53
|
+
}, d = () => {
|
|
54
|
+
$();
|
|
55
|
+
}, s = (i) => {
|
|
56
|
+
k(B.find((_) => _.deviceId === i));
|
|
57
|
+
}, x = (i) => {
|
|
58
|
+
h(C.find((_) => _.deviceId === i));
|
|
59
|
+
}, z = (i) => {
|
|
60
|
+
P(E.find((_) => _.deviceId === i));
|
|
61
|
+
}, T = () => {
|
|
62
|
+
$();
|
|
63
63
|
};
|
|
64
|
-
return
|
|
64
|
+
return c ? /* @__PURE__ */ e.createElement("div", { className: F.background, ...S ? { onClick: T } : {} }, /* @__PURE__ */ e.createElement(
|
|
65
65
|
"div",
|
|
66
66
|
{
|
|
67
|
-
className:
|
|
68
|
-
...
|
|
69
|
-
onClick: (
|
|
67
|
+
className: F.modal,
|
|
68
|
+
...S ? {
|
|
69
|
+
onClick: (i) => i.stopPropagation()
|
|
70
70
|
} : {}
|
|
71
71
|
},
|
|
72
|
-
/* @__PURE__ */ e.createElement("div", { className:
|
|
73
|
-
|
|
72
|
+
/* @__PURE__ */ e.createElement("div", { className: F.deviceLists }, o && /* @__PURE__ */ e.createElement(
|
|
73
|
+
D,
|
|
74
74
|
{
|
|
75
|
-
label:
|
|
76
|
-
devices:
|
|
77
|
-
onChange:
|
|
75
|
+
label: l,
|
|
76
|
+
devices: B,
|
|
77
|
+
onChange: s
|
|
78
78
|
}
|
|
79
|
-
),
|
|
80
|
-
|
|
79
|
+
), a && /* @__PURE__ */ e.createElement(
|
|
80
|
+
D,
|
|
81
81
|
{
|
|
82
|
-
label:
|
|
83
|
-
devices:
|
|
84
|
-
onChange:
|
|
82
|
+
label: v,
|
|
83
|
+
devices: C,
|
|
84
|
+
onChange: x
|
|
85
85
|
}
|
|
86
|
-
),
|
|
87
|
-
|
|
86
|
+
), f && /* @__PURE__ */ e.createElement(
|
|
87
|
+
D,
|
|
88
88
|
{
|
|
89
|
-
label:
|
|
90
|
-
devices:
|
|
91
|
-
onChange:
|
|
89
|
+
label: O,
|
|
90
|
+
devices: E,
|
|
91
|
+
onChange: z
|
|
92
92
|
}
|
|
93
93
|
)),
|
|
94
|
-
/* @__PURE__ */ e.createElement("div", { className:
|
|
94
|
+
/* @__PURE__ */ e.createElement("div", { className: F.buttons }, /* @__PURE__ */ e.createElement(y, { className: F.cancelButton, onClick: d }, G), /* @__PURE__ */ e.createElement(y, { className: F.confirmButton, onClick: w }, q))
|
|
95
95
|
)) : /* @__PURE__ */ e.createElement(e.Fragment, null);
|
|
96
|
-
},
|
|
97
|
-
background:
|
|
98
|
-
modal:
|
|
99
|
-
deviceSelectContainer:
|
|
100
|
-
preview:
|
|
101
|
-
previewVideo:
|
|
102
|
-
deviceLists:
|
|
103
|
-
buttons:
|
|
104
|
-
chancelButton:
|
|
105
|
-
confirmButton:
|
|
106
|
-
},
|
|
107
|
-
const [
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
}, []), [
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
96
|
+
}, _e = "_background_kb025_1", ge = "_modal_kb025_13", be = "_deviceSelectContainer_kb025_19", ke = "_preview_kb025_31", he = "_previewVideo_kb025_39", Ce = "_deviceLists_kb025_44", Ee = "_buttons_kb025_50", Ie = "_chancelButton_kb025_57", De = "_confirmButton_kb025_59", I = {
|
|
97
|
+
background: _e,
|
|
98
|
+
modal: ge,
|
|
99
|
+
deviceSelectContainer: be,
|
|
100
|
+
preview: ke,
|
|
101
|
+
previewVideo: he,
|
|
102
|
+
deviceLists: Ce,
|
|
103
|
+
buttons: Ee,
|
|
104
|
+
chancelButton: Ie,
|
|
105
|
+
confirmButton: De
|
|
106
|
+
}, X = () => {
|
|
107
|
+
const [o, a] = u();
|
|
108
|
+
return L(() => () => {
|
|
109
|
+
o !== void 0 && o.getTracks().forEach((c) => c.stop());
|
|
110
|
+
}, []), [o, (c) => {
|
|
111
|
+
c.kind !== "audiooutput" && (async () => {
|
|
112
|
+
const l = await navigator.mediaDevices.getUserMedia(
|
|
113
|
+
c.kind === "audioinput" ? { video: !1, audio: { deviceId: c.deviceId } } : { video: { deviceId: c.deviceId }, audio: !1 }
|
|
114
114
|
);
|
|
115
|
-
|
|
115
|
+
a(l);
|
|
116
116
|
})();
|
|
117
117
|
}];
|
|
118
|
-
},
|
|
119
|
-
isSelectAudioInput:
|
|
120
|
-
isSelectAudioOutput:
|
|
121
|
-
isSelectVideoInput:
|
|
122
|
-
open:
|
|
123
|
-
audioInputDeviceLabel:
|
|
124
|
-
audioOutputDeviceLabel:
|
|
125
|
-
videoInputDeviceLabel:
|
|
126
|
-
confirmButtonText:
|
|
127
|
-
cancelButtonText:
|
|
128
|
-
allowOutsideClick:
|
|
129
|
-
onDeviceSelected:
|
|
130
|
-
onDeviceSelectCanceled:
|
|
118
|
+
}, Pe = ({
|
|
119
|
+
isSelectAudioInput: o = !0,
|
|
120
|
+
isSelectAudioOutput: a = !0,
|
|
121
|
+
isSelectVideoInput: f = !0,
|
|
122
|
+
open: c,
|
|
123
|
+
audioInputDeviceLabel: l = "audio input device",
|
|
124
|
+
audioOutputDeviceLabel: v = "audio output device",
|
|
125
|
+
videoInputDeviceLabel: O = "video input device",
|
|
126
|
+
confirmButtonText: q = "Confirm",
|
|
127
|
+
cancelButtonText: G = "Cancel",
|
|
128
|
+
allowOutsideClick: S = !0,
|
|
129
|
+
onDeviceSelected: R,
|
|
130
|
+
onDeviceSelectCanceled: $
|
|
131
131
|
}) => {
|
|
132
|
-
const [
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}, [
|
|
136
|
-
if (
|
|
132
|
+
const [r, g] = Q(), [M, k] = u(), [j, h] = u(), [A, P] = u(), [B, C] = X(), E = K(), w = U(() => r.filter((n) => n.kind === "audioinput"), [r]), d = U(() => r.filter((n) => n.kind === "audiooutput"), [r]), s = U(() => r.filter((n) => n.kind === "videoinput"), [r]);
|
|
133
|
+
L(() => {
|
|
134
|
+
c && g();
|
|
135
|
+
}, [c]), L(() => {
|
|
136
|
+
if (s.length < 1)
|
|
137
137
|
return;
|
|
138
|
-
const [
|
|
139
|
-
|
|
140
|
-
}, [
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
audioInput:
|
|
144
|
-
audioOutput:
|
|
145
|
-
videoInput:
|
|
138
|
+
const [n] = s;
|
|
139
|
+
C(n);
|
|
140
|
+
}, [s]);
|
|
141
|
+
const x = () => {
|
|
142
|
+
R({
|
|
143
|
+
audioInput: M !== void 0 ? M : w[0],
|
|
144
|
+
audioOutput: j !== void 0 ? j : d[0],
|
|
145
|
+
videoInput: A !== void 0 ? A : s[0]
|
|
146
146
|
});
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
},
|
|
154
|
-
const
|
|
155
|
-
|
|
147
|
+
}, z = () => {
|
|
148
|
+
$();
|
|
149
|
+
}, T = (n) => {
|
|
150
|
+
k(w.find((b) => b.deviceId === n));
|
|
151
|
+
}, i = (n) => {
|
|
152
|
+
h(d.find((b) => b.deviceId === n));
|
|
153
|
+
}, _ = (n) => {
|
|
154
|
+
const b = s.find((J) => J.deviceId === n);
|
|
155
|
+
P(b), C(b);
|
|
156
156
|
};
|
|
157
|
-
|
|
158
|
-
const { current:
|
|
159
|
-
|
|
160
|
-
}, [
|
|
161
|
-
const
|
|
162
|
-
|
|
157
|
+
L(() => {
|
|
158
|
+
const { current: n } = E;
|
|
159
|
+
n !== void 0 && (n.srcObject !== null && n.srcObject instanceof MediaStream && (n.srcObject.getTracks().forEach((b) => b.stop()), n.pause()), n.srcObject = B, n.play());
|
|
160
|
+
}, [B]);
|
|
161
|
+
const N = () => {
|
|
162
|
+
$();
|
|
163
163
|
};
|
|
164
|
-
return
|
|
164
|
+
return c ? /* @__PURE__ */ e.createElement("div", { className: I.background, ...S ? { onClick: N } : {} }, /* @__PURE__ */ e.createElement(
|
|
165
165
|
"div",
|
|
166
166
|
{
|
|
167
|
-
className:
|
|
168
|
-
...
|
|
169
|
-
onClick: (
|
|
167
|
+
className: I.modal,
|
|
168
|
+
...S ? {
|
|
169
|
+
onClick: (n) => n.stopPropagation()
|
|
170
170
|
} : {}
|
|
171
171
|
},
|
|
172
|
-
/* @__PURE__ */ e.createElement("div", { className:
|
|
173
|
-
|
|
172
|
+
/* @__PURE__ */ e.createElement("div", { className: I.deviceSelectContainer }, /* @__PURE__ */ e.createElement("div", { className: I.preview }, /* @__PURE__ */ e.createElement("video", { className: I.previewVideo, ref: E, autoPlay: !0, muted: !0, playsInline: !0 })), /* @__PURE__ */ e.createElement("div", { className: I.deviceLists }, o && /* @__PURE__ */ e.createElement(
|
|
173
|
+
D,
|
|
174
174
|
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
muted: !0,
|
|
179
|
-
playsInline: !0
|
|
175
|
+
label: l,
|
|
176
|
+
devices: w,
|
|
177
|
+
onChange: T
|
|
180
178
|
}
|
|
181
|
-
)
|
|
182
|
-
|
|
179
|
+
), a && /* @__PURE__ */ e.createElement(
|
|
180
|
+
D,
|
|
183
181
|
{
|
|
184
|
-
label:
|
|
185
|
-
devices:
|
|
186
|
-
onChange:
|
|
182
|
+
label: v,
|
|
183
|
+
devices: d,
|
|
184
|
+
onChange: i
|
|
187
185
|
}
|
|
188
|
-
),
|
|
189
|
-
|
|
186
|
+
), f && /* @__PURE__ */ e.createElement(
|
|
187
|
+
D,
|
|
190
188
|
{
|
|
191
|
-
label:
|
|
192
|
-
devices:
|
|
193
|
-
onChange:
|
|
189
|
+
label: O,
|
|
190
|
+
devices: s,
|
|
191
|
+
onChange: _
|
|
194
192
|
}
|
|
195
|
-
),
|
|
196
|
-
|
|
193
|
+
))),
|
|
194
|
+
/* @__PURE__ */ e.createElement("div", { className: I.buttons }, /* @__PURE__ */ e.createElement(y, { className: I.cancelButton, onClick: z }, G), /* @__PURE__ */ e.createElement(y, { className: I.confirmButton, onClick: x }, q))
|
|
195
|
+
)) : /* @__PURE__ */ e.createElement(e.Fragment, null);
|
|
196
|
+
}, Be = "_background_1s81f_1", we = "_modal_1s81f_13", Ne = "_deviceSelectContainer_1s81f_19", Le = "_preview_1s81f_31", Oe = "_previewVideo_1s81f_39", Se = "_previewAudio_1s81f_44", $e = "_deviceLists_1s81f_48", Me = "_buttons_1s81f_54", je = "_chancelButton_1s81f_61", Ae = "_confirmButton_1s81f_63", Ve = "_recordingButton_1s81f_67", p = {
|
|
197
|
+
background: Be,
|
|
198
|
+
modal: we,
|
|
199
|
+
deviceSelectContainer: Ne,
|
|
200
|
+
preview: Le,
|
|
201
|
+
previewVideo: Oe,
|
|
202
|
+
previewAudio: Se,
|
|
203
|
+
deviceLists: $e,
|
|
204
|
+
buttons: Me,
|
|
205
|
+
chancelButton: je,
|
|
206
|
+
confirmButton: Ae,
|
|
207
|
+
recordingButton: Ve
|
|
208
|
+
}, Te = ({
|
|
209
|
+
isSelectAudioInput: o = !0,
|
|
210
|
+
isSelectAudioOutput: a = !0,
|
|
211
|
+
isSelectVideoInput: f = !0,
|
|
212
|
+
open: c,
|
|
213
|
+
audioInputDeviceLabel: l = "audio input device",
|
|
214
|
+
audioOutputDeviceLabel: v = "audio output device",
|
|
215
|
+
videoInputDeviceLabel: O = "video input device",
|
|
216
|
+
confirmButtonText: q = "Confirm",
|
|
217
|
+
cancelButtonText: G = "Cancel",
|
|
218
|
+
recordingButtonText: S = "Recording",
|
|
219
|
+
allowOutsideClick: R = !0,
|
|
220
|
+
onDeviceSelected: $,
|
|
221
|
+
onDeviceSelectCanceled: r
|
|
222
|
+
}) => {
|
|
223
|
+
const [g, M] = Q(), [k, j] = u(), [h, A] = u(), [P, B] = u(), [C, E] = X(), w = K(), d = K(), [s, x] = u(), [z, T] = u(!1), i = U(() => g.filter((t) => t.kind === "audioinput"), [g]), _ = U(() => g.filter((t) => t.kind === "audiooutput"), [g]), N = U(() => g.filter((t) => t.kind === "videoinput"), [g]);
|
|
224
|
+
L(() => {
|
|
225
|
+
c && M();
|
|
226
|
+
}, [c]), L(() => {
|
|
227
|
+
if (N.length < 1)
|
|
228
|
+
return;
|
|
229
|
+
const [t] = N;
|
|
230
|
+
E(t);
|
|
231
|
+
}, [N]);
|
|
232
|
+
const n = () => {
|
|
233
|
+
!s || !d || (s.state === "recording" && (s.removeEventListener("dataavailable", () => {
|
|
234
|
+
}), s.removeEventListener("stop", () => {
|
|
235
|
+
}), s.stop(), s.stream.getTracks().forEach((t) => t.stop())), d.current.src = "", d.current.pause());
|
|
236
|
+
}, b = () => {
|
|
237
|
+
n(), $({
|
|
238
|
+
audioInput: k !== void 0 ? k : i[0],
|
|
239
|
+
audioOutput: h !== void 0 ? h : _[0],
|
|
240
|
+
videoInput: P !== void 0 ? P : N[0]
|
|
241
|
+
});
|
|
242
|
+
}, J = () => {
|
|
243
|
+
n(), r();
|
|
244
|
+
}, Y = (t) => {
|
|
245
|
+
j(i.find((m) => m.deviceId === t));
|
|
246
|
+
}, Z = async (t) => {
|
|
247
|
+
A(_.find((m) => m.deviceId === t)), await d.current.setSinkId(t);
|
|
248
|
+
}, ee = (t) => {
|
|
249
|
+
const m = N.find((V) => V.deviceId === t);
|
|
250
|
+
B(m), E(m);
|
|
251
|
+
}, te = async () => {
|
|
252
|
+
const t = await navigator.mediaDevices.getUserMedia({
|
|
253
|
+
audio: k && k.deviceId !== "" ? {
|
|
254
|
+
deviceId: k.deviceId
|
|
255
|
+
} : !0,
|
|
256
|
+
video: !1
|
|
257
|
+
});
|
|
258
|
+
let m = [];
|
|
259
|
+
const V = new MediaRecorder(t);
|
|
260
|
+
V.addEventListener("dataavailable", (H) => {
|
|
261
|
+
m.push(H.data);
|
|
262
|
+
}), V.addEventListener("stop", async (H) => {
|
|
263
|
+
if (T(!1), !d.current)
|
|
264
|
+
return;
|
|
265
|
+
const ce = new Blob(m, { type: "audio/ogg; codecs=opus" });
|
|
266
|
+
m = [];
|
|
267
|
+
const ie = URL.createObjectURL(ce);
|
|
268
|
+
d.current.src = ie, h && h.deviceId !== "" && await d.current.setSinkId(h.deviceId);
|
|
269
|
+
}), V.start(), x(V), T(!0), setTimeout(() => {
|
|
270
|
+
V.stop(), t.getTracks().forEach((H) => H.stop());
|
|
271
|
+
}, 5e3);
|
|
272
|
+
};
|
|
273
|
+
L(() => {
|
|
274
|
+
const { current: t } = w;
|
|
275
|
+
t && (t.srcObject !== null && t.srcObject instanceof MediaStream && (t.srcObject.getTracks().forEach((m) => m.stop()), t.pause()), t.srcObject = C, t.play());
|
|
276
|
+
}, [C]);
|
|
277
|
+
const ne = () => {
|
|
278
|
+
n(), r();
|
|
279
|
+
};
|
|
280
|
+
return c ? /* @__PURE__ */ e.createElement("div", { className: p.background, ...R ? { onClick: ne } : {} }, /* @__PURE__ */ e.createElement(
|
|
281
|
+
"div",
|
|
282
|
+
{
|
|
283
|
+
className: p.modal,
|
|
284
|
+
...R ? {
|
|
285
|
+
onClick: (t) => t.stopPropagation()
|
|
286
|
+
} : {}
|
|
287
|
+
},
|
|
288
|
+
/* @__PURE__ */ e.createElement("div", { className: p.deviceSelectContainer }, /* @__PURE__ */ e.createElement("div", { className: p.preview }, /* @__PURE__ */ e.createElement("video", { className: p.previewVideo, ref: w, autoPlay: !0, muted: !0, playsInline: !0 }), /* @__PURE__ */ e.createElement("audio", { className: p.previewAudio, ref: d, autoPlay: !0, playsInline: !0, controls: !0 })), /* @__PURE__ */ e.createElement("div", { className: p.deviceLists }, o && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
289
|
+
D,
|
|
197
290
|
{
|
|
198
|
-
label:
|
|
199
|
-
devices:
|
|
200
|
-
onChange:
|
|
291
|
+
label: l,
|
|
292
|
+
devices: i,
|
|
293
|
+
onChange: Y
|
|
294
|
+
}
|
|
295
|
+
), /* @__PURE__ */ e.createElement("div", { className: p.buttons }, /* @__PURE__ */ e.createElement(
|
|
296
|
+
y,
|
|
297
|
+
{
|
|
298
|
+
className: p.recordingButton,
|
|
299
|
+
onClick: te,
|
|
300
|
+
disabled: z
|
|
301
|
+
},
|
|
302
|
+
S
|
|
303
|
+
))), a && /* @__PURE__ */ e.createElement(
|
|
304
|
+
D,
|
|
305
|
+
{
|
|
306
|
+
label: v,
|
|
307
|
+
devices: _,
|
|
308
|
+
onChange: Z
|
|
309
|
+
}
|
|
310
|
+
), f && /* @__PURE__ */ e.createElement(
|
|
311
|
+
D,
|
|
312
|
+
{
|
|
313
|
+
label: O,
|
|
314
|
+
devices: N,
|
|
315
|
+
onChange: ee
|
|
201
316
|
}
|
|
202
317
|
))),
|
|
203
|
-
/* @__PURE__ */ e.createElement("div", { className:
|
|
318
|
+
/* @__PURE__ */ e.createElement("div", { className: p.buttons }, /* @__PURE__ */ e.createElement(y, { className: p.cancelButton, onClick: J }, G), /* @__PURE__ */ e.createElement(y, { className: p.confirmButton, onClick: b }, q))
|
|
204
319
|
)) : /* @__PURE__ */ e.createElement(e.Fragment, null);
|
|
205
320
|
};
|
|
206
321
|
export {
|
|
207
|
-
|
|
208
|
-
|
|
322
|
+
Re as SelectMediaDevicesModal,
|
|
323
|
+
Pe as SelectMediaDevicesPreviewModal,
|
|
324
|
+
Te as SelectMediaDevicesRecordingModal
|
|
209
325
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(g,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],e):(g=typeof globalThis<"u"?globalThis:g||self,e(g.ReactSelectMediaDevicesModal={},g.React))})(this,function(g,e){"use strict";const A={background:"_background_1djbv_1",modal:"_modal_1djbv_13",deviceLists:"_deviceLists_1djbv_20",buttons:"_buttons_1djbv_24",chancelButton:"_chancelButton_1djbv_31",confirmButton:"_confirmButton_1djbv_33"},H=()=>{const[c,s]=e.useState([]);return[c,()=>{(async()=>{const i=await navigator.mediaDevices.getUserMedia({audio:!0,video:!0}),l=await navigator.mediaDevices.enumerateDevices();s(l),i.getTracks().forEach(v=>v.stop())})()}]},W=({name:c,value:s})=>e.createElement("option",{value:s},c),K={deviceList:"_deviceList_1bfq1_1",select:"_select_1bfq1_5"},h=({devices:c,label:s,onChange:f})=>{if(c===void 0)return e.createElement(e.Fragment,null);const i=v=>{f(v.target.value)},l=`device-select-${s.toLowerCase().replace(/\s/g,"-")}`;return e.createElement("div",{className:K.deviceList},e.createElement("label",{htmlFor:l},s),e.createElement("select",{className:K.select,id:l,onChange:i},c.map((v,M)=>e.createElement(W,{value:v.deviceId,name:v.label,key:M}))))},X={button:"_button_keu24_1"},$=({className:c,children:s,disabled:f,onClick:i})=>e.createElement("button",{onClick:i,disabled:f,className:[X.button,c].filter(Boolean).join(" ")},s),Y=({isSelectAudioInput:c=!0,isSelectAudioOutput:s=!0,isSelectVideoInput:f=!0,open:i,audioInputDeviceLabel:l="audio input device",audioOutputDeviceLabel:v="audio output device",videoInputDeviceLabel:M="video input device",confirmButtonText:U="Confirm",cancelButtonText:q="Cancel",allowOutsideClick:N=!0,onDeviceSelected:P,onDeviceSelectCanceled:L})=>{const[a,_]=H(),[O,E]=e.useState(),[y,C]=e.useState(),[j,T]=e.useState(),S=a.filter(o=>o.kind==="audioinput"),D=a.filter(o=>o.kind==="audiooutput"),I=a.filter(o=>o.kind==="videoinput");e.useEffect(()=>{i&&_()},[i]);const B=()=>{P({audioInput:O!==void 0?O:S[0],audioOutput:y!==void 0?y:D[0],videoInput:j!==void 0?j:I[0]})},u=()=>{L()},d=o=>{E(S.find(p=>p.deviceId===o))},G=o=>{C(D.find(p=>p.deviceId===o))},x=o=>{T(I.find(p=>p.deviceId===o))},F=()=>{L()};return i?e.createElement("div",{className:A.background,...N?{onClick:F}:{}},e.createElement("div",{className:A.modal,...N?{onClick:o=>o.stopPropagation()}:{}},e.createElement("div",{className:A.deviceLists},c&&e.createElement(h,{label:l,devices:S,onChange:d}),s&&e.createElement(h,{label:v,devices:D,onChange:G}),f&&e.createElement(h,{label:M,devices:I,onChange:x})),e.createElement("div",{className:A.buttons},e.createElement($,{className:A.cancelButton,onClick:u},q),e.createElement($,{className:A.confirmButton,onClick:B},U)))):e.createElement(e.Fragment,null)},k={background:"_background_kb025_1",modal:"_modal_kb025_13",deviceSelectContainer:"_deviceSelectContainer_kb025_19",preview:"_preview_kb025_31",previewVideo:"_previewVideo_kb025_39",deviceLists:"_deviceLists_kb025_44",buttons:"_buttons_kb025_50",chancelButton:"_chancelButton_kb025_57",confirmButton:"_confirmButton_kb025_59"},Q=()=>{const[c,s]=e.useState();return e.useEffect(()=>()=>{c!==void 0&&c.getTracks().forEach(i=>i.stop())},[]),[c,i=>{i.kind!=="audiooutput"&&(async()=>{const l=await navigator.mediaDevices.getUserMedia(i.kind==="audioinput"?{video:!1,audio:{deviceId:i.deviceId}}:{video:{deviceId:i.deviceId},audio:!1});s(l)})()}]},Z=({isSelectAudioInput:c=!0,isSelectAudioOutput:s=!0,isSelectVideoInput:f=!0,open:i,audioInputDeviceLabel:l="audio input device",audioOutputDeviceLabel:v="audio output device",videoInputDeviceLabel:M="video input device",confirmButtonText:U="Confirm",cancelButtonText:q="Cancel",allowOutsideClick:N=!0,onDeviceSelected:P,onDeviceSelectCanceled:L})=>{const[a,_]=H(),[O,E]=e.useState(),[y,C]=e.useState(),[j,T]=e.useState(),[S,D]=Q(),I=e.useRef(),B=e.useMemo(()=>a.filter(n=>n.kind==="audioinput"),[a]),u=e.useMemo(()=>a.filter(n=>n.kind==="audiooutput"),[a]),d=e.useMemo(()=>a.filter(n=>n.kind==="videoinput"),[a]);e.useEffect(()=>{i&&_()},[i]),e.useEffect(()=>{if(d.length<1)return;const[n]=d;D(n)},[d]);const G=()=>{P({audioInput:O!==void 0?O:B[0],audioOutput:y!==void 0?y:u[0],videoInput:j!==void 0?j:d[0]})},x=()=>{L()},F=n=>{E(B.find(b=>b.deviceId===n))},o=n=>{C(u.find(b=>b.deviceId===n))},p=n=>{const b=d.find(J=>J.deviceId===n);T(b),D(b)};e.useEffect(()=>{const{current:n}=I;n!==void 0&&(n.srcObject!==null&&n.srcObject instanceof MediaStream&&(n.srcObject.getTracks().forEach(b=>b.stop()),n.pause()),n.srcObject=S,n.play())},[S]);const w=()=>{L()};return i?e.createElement("div",{className:k.background,...N?{onClick:w}:{}},e.createElement("div",{className:k.modal,...N?{onClick:n=>n.stopPropagation()}:{}},e.createElement("div",{className:k.deviceSelectContainer},e.createElement("div",{className:k.preview},e.createElement("video",{className:k.previewVideo,ref:I,autoPlay:!0,muted:!0,playsInline:!0})),e.createElement("div",{className:k.deviceLists},c&&e.createElement(h,{label:l,devices:B,onChange:F}),s&&e.createElement(h,{label:v,devices:u,onChange:o}),f&&e.createElement(h,{label:M,devices:d,onChange:p}))),e.createElement("div",{className:k.buttons},e.createElement($,{className:k.cancelButton,onClick:x},q),e.createElement($,{className:k.confirmButton,onClick:G},U)))):e.createElement(e.Fragment,null)},r={background:"_background_1s81f_1",modal:"_modal_1s81f_13",deviceSelectContainer:"_deviceSelectContainer_1s81f_19",preview:"_preview_1s81f_31",previewVideo:"_previewVideo_1s81f_39",previewAudio:"_previewAudio_1s81f_44",deviceLists:"_deviceLists_1s81f_48",buttons:"_buttons_1s81f_54",chancelButton:"_chancelButton_1s81f_61",confirmButton:"_confirmButton_1s81f_63",recordingButton:"_recordingButton_1s81f_67"},R=({isSelectAudioInput:c=!0,isSelectAudioOutput:s=!0,isSelectVideoInput:f=!0,open:i,audioInputDeviceLabel:l="audio input device",audioOutputDeviceLabel:v="audio output device",videoInputDeviceLabel:M="video input device",confirmButtonText:U="Confirm",cancelButtonText:q="Cancel",recordingButtonText:N="Recording",allowOutsideClick:P=!0,onDeviceSelected:L,onDeviceSelectCanceled:a})=>{const[_,O]=H(),[E,y]=e.useState(),[C,j]=e.useState(),[T,S]=e.useState(),[D,I]=Q(),B=e.useRef(),u=e.useRef(),[d,G]=e.useState(),[x,F]=e.useState(!1),o=e.useMemo(()=>_.filter(t=>t.kind==="audioinput"),[_]),p=e.useMemo(()=>_.filter(t=>t.kind==="audiooutput"),[_]),w=e.useMemo(()=>_.filter(t=>t.kind==="videoinput"),[_]);e.useEffect(()=>{i&&O()},[i]),e.useEffect(()=>{if(w.length<1)return;const[t]=w;I(t)},[w]);const n=()=>{!d||!u||(d.state==="recording"&&(d.removeEventListener("dataavailable",()=>{}),d.removeEventListener("stop",()=>{}),d.stop(),d.stream.getTracks().forEach(t=>t.stop())),u.current.src="",u.current.pause())},b=()=>{n(),L({audioInput:E!==void 0?E:o[0],audioOutput:C!==void 0?C:p[0],videoInput:T!==void 0?T:w[0]})},J=()=>{n(),a()},ee=t=>{y(o.find(m=>m.deviceId===t))},te=async t=>{j(p.find(m=>m.deviceId===t)),await u.current.setSinkId(t)},ne=t=>{const m=w.find(V=>V.deviceId===t);S(m),I(m)},ie=async()=>{const t=await navigator.mediaDevices.getUserMedia({audio:E&&E.deviceId!==""?{deviceId:E.deviceId}:!0,video:!1});let m=[];const V=new MediaRecorder(t);V.addEventListener("dataavailable",z=>{m.push(z.data)}),V.addEventListener("stop",async z=>{if(F(!1),!u.current)return;const ce=new Blob(m,{type:"audio/ogg; codecs=opus"});m=[];const se=URL.createObjectURL(ce);u.current.src=se,C&&C.deviceId!==""&&await u.current.setSinkId(C.deviceId)}),V.start(),G(V),F(!0),setTimeout(()=>{V.stop(),t.getTracks().forEach(z=>z.stop())},5e3)};e.useEffect(()=>{const{current:t}=B;t&&(t.srcObject!==null&&t.srcObject instanceof MediaStream&&(t.srcObject.getTracks().forEach(m=>m.stop()),t.pause()),t.srcObject=D,t.play())},[D]);const oe=()=>{n(),a()};return i?e.createElement("div",{className:r.background,...P?{onClick:oe}:{}},e.createElement("div",{className:r.modal,...P?{onClick:t=>t.stopPropagation()}:{}},e.createElement("div",{className:r.deviceSelectContainer},e.createElement("div",{className:r.preview},e.createElement("video",{className:r.previewVideo,ref:B,autoPlay:!0,muted:!0,playsInline:!0}),e.createElement("audio",{className:r.previewAudio,ref:u,autoPlay:!0,playsInline:!0,controls:!0})),e.createElement("div",{className:r.deviceLists},c&&e.createElement(e.Fragment,null,e.createElement(h,{label:l,devices:o,onChange:ee}),e.createElement("div",{className:r.buttons},e.createElement($,{className:r.recordingButton,onClick:ie,disabled:x},N))),s&&e.createElement(h,{label:v,devices:p,onChange:te}),f&&e.createElement(h,{label:M,devices:w,onChange:ne}))),e.createElement("div",{className:r.buttons},e.createElement($,{className:r.cancelButton,onClick:J},q),e.createElement($,{className:r.confirmButton,onClick:b},U)))):e.createElement(e.Fragment,null)};g.SelectMediaDevicesModal=Y,g.SelectMediaDevicesPreviewModal=Z,g.SelectMediaDevicesRecordingModal=R,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
._background_1djbv_1{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0000004d;display:flex;align-items:center;justify-content:center}._modal_1djbv_13{background:white;padding:16px;border-radius:8px;min-width:270px}._deviceLists_1djbv_20{display:grid}._buttons_1djbv_24{padding-top:16px;display:flex;align-items:center;justify-content:right}._confirmButton_1djbv_33{margin-left:4px}._deviceList_1bfq1_1{padding-top:8px}._select_1bfq1_5{margin-top:4px;border-radius:4px;height:32px;display:flex;align-items:center;justify-content:right;width:100%}._button_keu24_1{border-radius:4px;height:32px;padding-left:16px;padding-right:16px;background-color:#fff;border-width:1px}._background_kb025_1{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0000004d;display:flex;align-items:center;justify-content:center}._modal_kb025_13{background:white;padding:16px;border-radius:8px}._deviceSelectContainer_kb025_19{display:grid;grid-template-columns:50% 50%}@media (max-width: 640px){._deviceSelectContainer_kb025_19{display:grid;grid-template-columns:100%}}._preview_kb025_31{min-width:270px;min-height:180px;max-width:270px;max-height:180px;margin-right:4px}._previewVideo_kb025_39{width:270px;height:180px}._deviceLists_kb025_44{display:grid;min-width:270px;margin-left:8px}._buttons_kb025_50{padding-top:16px;display:flex;align-items:center;justify-content:right}._confirmButton_kb025_59{margin-left:4px}
|
|
1
|
+
._background_1djbv_1{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0000004d;display:flex;align-items:center;justify-content:center}._modal_1djbv_13{background:white;padding:16px;border-radius:8px;min-width:270px}._deviceLists_1djbv_20{display:grid}._buttons_1djbv_24{padding-top:16px;display:flex;align-items:center;justify-content:right}._confirmButton_1djbv_33{margin-left:4px}._deviceList_1bfq1_1{padding-top:8px}._select_1bfq1_5{margin-top:4px;border-radius:4px;height:32px;display:flex;align-items:center;justify-content:right;width:100%}._button_keu24_1{border-radius:4px;height:32px;padding-left:16px;padding-right:16px;background-color:#fff;border-width:1px}._background_kb025_1{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0000004d;display:flex;align-items:center;justify-content:center}._modal_kb025_13{background:white;padding:16px;border-radius:8px}._deviceSelectContainer_kb025_19{display:grid;grid-template-columns:50% 50%}@media (max-width: 640px){._deviceSelectContainer_kb025_19{display:grid;grid-template-columns:100%}}._preview_kb025_31{min-width:270px;min-height:180px;max-width:270px;max-height:180px;margin-right:4px}._previewVideo_kb025_39{width:270px;height:180px}._deviceLists_kb025_44{display:grid;min-width:270px;margin-left:8px}._buttons_kb025_50{padding-top:16px;display:flex;align-items:center;justify-content:right}._confirmButton_kb025_59{margin-left:4px}._background_1s81f_1{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#0000004d;display:flex;align-items:center;justify-content:center}._modal_1s81f_13{background:white;padding:16px;border-radius:8px}._deviceSelectContainer_1s81f_19{display:grid;grid-template-columns:50% 50%}@media (max-width: 640px){._deviceSelectContainer_1s81f_19{display:grid;grid-template-columns:100%}}._preview_1s81f_31{min-width:270px;min-height:180px;max-width:270px;max-height:180px;margin-right:4px}._previewVideo_1s81f_39{width:270px;height:180px}._previewAudio_1s81f_44{width:270px}._deviceLists_1s81f_48{display:grid;min-width:270px;margin-left:8px}._buttons_1s81f_54{padding-top:16px;display:flex;align-items:center;justify-content:right}._confirmButton_1s81f_63{margin-left:4px}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
interface SelectMediaDevicesModalProps {
|
|
2
|
-
isSelectAudioInput
|
|
3
|
-
isSelectAudioOutput
|
|
4
|
-
isSelectVideoInput
|
|
3
|
+
isSelectAudioInput?: boolean;
|
|
4
|
+
isSelectAudioOutput?: boolean;
|
|
5
|
+
isSelectVideoInput?: boolean;
|
|
5
6
|
open: boolean;
|
|
6
|
-
audioInputDeviceLabel
|
|
7
|
-
audioOutputDeviceLabel
|
|
8
|
-
videoInputDeviceLabel
|
|
9
|
-
confirmButtonText
|
|
10
|
-
cancelButtonText
|
|
11
|
-
allowOutsideClick
|
|
7
|
+
audioInputDeviceLabel?: string;
|
|
8
|
+
audioOutputDeviceLabel?: string;
|
|
9
|
+
videoInputDeviceLabel?: string;
|
|
10
|
+
confirmButtonText?: string;
|
|
11
|
+
cancelButtonText?: string;
|
|
12
|
+
allowOutsideClick?: boolean;
|
|
12
13
|
onDeviceSelected: (devices: {
|
|
13
14
|
audioInput?: MediaDeviceInfo;
|
|
14
15
|
audioOutput?: MediaDeviceInfo;
|
|
@@ -16,5 +17,5 @@ interface SelectMediaDevicesModalProps {
|
|
|
16
17
|
}) => void;
|
|
17
18
|
onDeviceSelectCanceled: () => void;
|
|
18
19
|
}
|
|
19
|
-
declare const SelectMediaDevicesModal: ({ isSelectAudioInput, isSelectAudioOutput, isSelectVideoInput, open, audioInputDeviceLabel, audioOutputDeviceLabel, videoInputDeviceLabel, confirmButtonText, cancelButtonText, allowOutsideClick, onDeviceSelected, onDeviceSelectCanceled, }: SelectMediaDevicesModalProps) => JSX.Element;
|
|
20
|
+
declare const SelectMediaDevicesModal: ({ isSelectAudioInput, isSelectAudioOutput, isSelectVideoInput, open, audioInputDeviceLabel, audioOutputDeviceLabel, videoInputDeviceLabel, confirmButtonText, cancelButtonText, allowOutsideClick, onDeviceSelected, onDeviceSelectCanceled, }: SelectMediaDevicesModalProps) => React.JSX.Element;
|
|
20
21
|
export default SelectMediaDevicesModal;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
interface SelectMediaDevicesPreviewModalProps {
|
|
2
|
-
isSelectAudioInput
|
|
3
|
-
isSelectAudioOutput
|
|
4
|
-
isSelectVideoInput
|
|
3
|
+
isSelectAudioInput?: boolean;
|
|
4
|
+
isSelectAudioOutput?: boolean;
|
|
5
|
+
isSelectVideoInput?: boolean;
|
|
5
6
|
open: boolean;
|
|
6
|
-
audioInputDeviceLabel
|
|
7
|
-
audioOutputDeviceLabel
|
|
8
|
-
videoInputDeviceLabel
|
|
9
|
-
confirmButtonText
|
|
10
|
-
cancelButtonText
|
|
11
|
-
allowOutsideClick
|
|
7
|
+
audioInputDeviceLabel?: string;
|
|
8
|
+
audioOutputDeviceLabel?: string;
|
|
9
|
+
videoInputDeviceLabel?: string;
|
|
10
|
+
confirmButtonText?: string;
|
|
11
|
+
cancelButtonText?: string;
|
|
12
|
+
allowOutsideClick?: boolean;
|
|
12
13
|
onDeviceSelected: (devices: {
|
|
13
14
|
audioInput?: MediaDeviceInfo;
|
|
14
15
|
audioOutput?: MediaDeviceInfo;
|
|
@@ -16,5 +17,5 @@ interface SelectMediaDevicesPreviewModalProps {
|
|
|
16
17
|
}) => void;
|
|
17
18
|
onDeviceSelectCanceled: () => void;
|
|
18
19
|
}
|
|
19
|
-
declare const SelectMediaDevicesPreviewModal: ({ isSelectAudioInput, isSelectAudioOutput, isSelectVideoInput, open, audioInputDeviceLabel, audioOutputDeviceLabel, videoInputDeviceLabel, confirmButtonText, cancelButtonText, allowOutsideClick, onDeviceSelected, onDeviceSelectCanceled, }: SelectMediaDevicesPreviewModalProps) => JSX.Element;
|
|
20
|
+
declare const SelectMediaDevicesPreviewModal: ({ isSelectAudioInput, isSelectAudioOutput, isSelectVideoInput, open, audioInputDeviceLabel, audioOutputDeviceLabel, videoInputDeviceLabel, confirmButtonText, cancelButtonText, allowOutsideClick, onDeviceSelected, onDeviceSelectCanceled, }: SelectMediaDevicesPreviewModalProps) => React.JSX.Element;
|
|
20
21
|
export default SelectMediaDevicesPreviewModal;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface SelectMediaDevicesRecordingModalProps {
|
|
3
|
+
isSelectAudioInput?: boolean;
|
|
4
|
+
isSelectAudioOutput?: boolean;
|
|
5
|
+
isSelectVideoInput?: boolean;
|
|
6
|
+
open: boolean;
|
|
7
|
+
audioInputDeviceLabel?: string;
|
|
8
|
+
audioOutputDeviceLabel?: string;
|
|
9
|
+
videoInputDeviceLabel?: string;
|
|
10
|
+
confirmButtonText?: string;
|
|
11
|
+
cancelButtonText?: string;
|
|
12
|
+
recordingButtonText?: string;
|
|
13
|
+
allowOutsideClick?: boolean;
|
|
14
|
+
onDeviceSelected: (devices: {
|
|
15
|
+
audioInput?: MediaDeviceInfo;
|
|
16
|
+
audioOutput?: MediaDeviceInfo;
|
|
17
|
+
videoInput?: MediaDeviceInfo;
|
|
18
|
+
}) => void;
|
|
19
|
+
onDeviceSelectCanceled: () => void;
|
|
20
|
+
}
|
|
21
|
+
declare const SelectMediaDevicesRecordingModal: ({ isSelectAudioInput, isSelectAudioOutput, isSelectVideoInput, open, audioInputDeviceLabel, audioOutputDeviceLabel, videoInputDeviceLabel, confirmButtonText, cancelButtonText, recordingButtonText, allowOutsideClick, onDeviceSelected, onDeviceSelectCanceled, }: SelectMediaDevicesRecordingModalProps) => React.JSX.Element;
|
|
22
|
+
export default SelectMediaDevicesRecordingModal;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
interface ButtonProps {
|
|
3
3
|
className?: string;
|
|
4
4
|
children: ReactNode;
|
|
5
|
+
disabled?: boolean;
|
|
5
6
|
onClick: () => void;
|
|
6
7
|
}
|
|
7
|
-
declare const Button: ({ className, children, onClick }: ButtonProps) => JSX.Element;
|
|
8
|
+
declare const Button: ({ className, children, disabled, onClick }: ButtonProps) => React.JSX.Element;
|
|
8
9
|
export default Button;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
interface DeviceItemProps {
|
|
2
3
|
name: string;
|
|
3
4
|
value: string;
|
|
4
5
|
}
|
|
5
|
-
declare const DeviceItem: ({ name, value }: DeviceItemProps) => JSX.Element;
|
|
6
|
+
declare const DeviceItem: ({ name, value }: DeviceItemProps) => React.JSX.Element;
|
|
6
7
|
export default DeviceItem;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
interface DeviceListProps {
|
|
2
3
|
devices: MediaDeviceInfo[];
|
|
3
4
|
label: string;
|
|
4
5
|
onChange: (deviceId: string) => void;
|
|
5
6
|
}
|
|
6
|
-
declare const DeviceList: ({ devices, label, onChange }: DeviceListProps) => JSX.Element;
|
|
7
|
+
declare const DeviceList: ({ devices, label, onChange }: DeviceListProps) => React.JSX.Element;
|
|
7
8
|
export default DeviceList;
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-select-media-devices-modal",
|
|
3
3
|
"description": "A React component library for select media devices",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -42,27 +42,27 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"react": "^18.2.0",
|
|
44
44
|
"react-dom": "^18.2.0",
|
|
45
|
-
"react-router-dom": "^6.
|
|
45
|
+
"react-router-dom": "^6.14.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@mdx-js/react": "^2.3.0",
|
|
49
|
-
"@playwright/test": "^1.
|
|
50
|
-
"@rollup/plugin-typescript": "^11.1.
|
|
49
|
+
"@playwright/test": "^1.35.1",
|
|
50
|
+
"@rollup/plugin-typescript": "^11.1.1",
|
|
51
51
|
"@testing-library/jest-dom": "^5.16.5",
|
|
52
52
|
"@testing-library/react": "^14.0.0",
|
|
53
53
|
"@testing-library/user-event": "^14.4.3",
|
|
54
|
-
"@types/node": "^
|
|
55
|
-
"@types/react": "^18.
|
|
56
|
-
"@vitejs/plugin-react": "^
|
|
57
|
-
"@vitest/coverage-c8": "^0.
|
|
58
|
-
"@vitest/ui": "^0.
|
|
59
|
-
"jsdom": "^
|
|
60
|
-
"playwright": "^1.
|
|
61
|
-
"rimraf": "^
|
|
54
|
+
"@types/node": "^20.3.1",
|
|
55
|
+
"@types/react": "^18.2.14",
|
|
56
|
+
"@vitejs/plugin-react": "^4.0.1",
|
|
57
|
+
"@vitest/coverage-c8": "^0.32.2",
|
|
58
|
+
"@vitest/ui": "^0.32.2",
|
|
59
|
+
"jsdom": "^22.1.0",
|
|
60
|
+
"playwright": "^1.35.1",
|
|
61
|
+
"rimraf": "^5.0.1",
|
|
62
62
|
"serve": "^14.2.0",
|
|
63
|
-
"vite": "^4.
|
|
64
|
-
"vite-pages-theme-doc": "^4.
|
|
65
|
-
"vite-plugin-react-pages": "^4.
|
|
66
|
-
"vitest": "^0.
|
|
63
|
+
"vite": "^4.3.9",
|
|
64
|
+
"vite-pages-theme-doc": "^4.1.5",
|
|
65
|
+
"vite-plugin-react-pages": "^4.1.3",
|
|
66
|
+
"vitest": "^0.32.2"
|
|
67
67
|
}
|
|
68
68
|
}
|