react-select-media-devices-modal 0.0.12 → 1.0.0

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 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 m, useEffect as O, useRef as z, useMemo as T } from "react";
2
- const H = "_background_1djbv_1", J = "_modal_1djbv_13", K = "_deviceLists_1djbv_20", Q = "_buttons_1djbv_24", W = "_chancelButton_1djbv_31", X = "_confirmButton_1djbv_33", g = {
3
- background: H,
4
- modal: J,
5
- deviceLists: K,
6
- buttons: Q,
7
- chancelButton: W,
8
- confirmButton: X
9
- }, G = () => {
10
- const [i, o] = m([]);
11
- return [i, () => {
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 n = await navigator.mediaDevices.getUserMedia({ audio: !0, video: !0 }), a = await navigator.mediaDevices.enumerateDevices();
14
- o(a), n.getTracks().forEach((s) => s.stop());
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
- }, Y = ({ name: i, value: o }) => /* @__PURE__ */ e.createElement("option", { value: o }, i), Z = "_deviceList_1bfq1_1", ee = "_select_1bfq1_5", q = {
18
- deviceList: Z,
19
- select: ee
20
- }, k = ({ devices: i, label: o, onChange: u }) => {
21
- if (i === void 0)
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 n = (s) => {
24
- u(s.target.value);
25
- }, a = `device-select-${o.toLowerCase().replace(/\s/g, "-")}`;
26
- return /* @__PURE__ */ e.createElement("div", { className: q.deviceList }, /* @__PURE__ */ e.createElement("label", { htmlFor: a }, o), /* @__PURE__ */ e.createElement("select", { className: q.select, id: a, onChange: n }, i.map((s, h) => /* @__PURE__ */ e.createElement(Y, { value: s.deviceId, name: s.label, key: h }))));
27
- }, te = "_button_keu24_1", ne = {
28
- button: te
29
- }, S = ({ className: i, children: o, onClick: u }) => /* @__PURE__ */ e.createElement("button", { onClick: u, className: [ne.button, i].filter(Boolean).join(" ") }, o), pe = ({
30
- isSelectAudioInput: i = !0,
31
- isSelectAudioOutput: o = !0,
32
- isSelectVideoInput: u = !0,
33
- open: n,
34
- audioInputDeviceLabel: a = "audio input device",
35
- audioOutputDeviceLabel: s = "audio output device",
36
- videoInputDeviceLabel: h = "video input device",
37
- confirmButtonText: w = "Confirm",
38
- cancelButtonText: M = "Cancel",
39
- allowOutsideClick: C = !0,
40
- onDeviceSelected: j,
41
- onDeviceSelectCanceled: D
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 [d, $] = G(), [E, V] = m(), [I, A] = m(), [B, y] = m(), _ = d.filter((c) => c.kind === "audioinput"), b = d.filter((c) => c.kind === "audiooutput"), f = d.filter((c) => c.kind === "videoinput");
44
- O(() => {
45
- n && $();
46
- }, [n]);
47
- const N = () => {
48
- j({
49
- audioInput: E !== void 0 ? E : _[0],
50
- audioOutput: I !== void 0 ? I : b[0],
51
- videoInput: B !== void 0 ? B : f[0]
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
- }, L = () => {
54
- D();
55
- }, l = (c) => {
56
- V(_.find((p) => p.deviceId === c));
57
- }, P = (c) => {
58
- A(b.find((p) => p.deviceId === c));
59
- }, F = (c) => {
60
- y(f.find((p) => p.deviceId === c));
61
- }, R = () => {
62
- D();
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 n ? /* @__PURE__ */ e.createElement("div", { className: g.background, ...C ? { onClick: R } : {} }, /* @__PURE__ */ e.createElement(
64
+ return c ? /* @__PURE__ */ e.createElement("div", { className: F.background, ...S ? { onClick: T } : {} }, /* @__PURE__ */ e.createElement(
65
65
  "div",
66
66
  {
67
- className: g.modal,
68
- ...C ? {
69
- onClick: (c) => c.stopPropagation()
67
+ className: F.modal,
68
+ ...S ? {
69
+ onClick: (i) => i.stopPropagation()
70
70
  } : {}
71
71
  },
72
- /* @__PURE__ */ e.createElement("div", { className: g.deviceLists }, i && /* @__PURE__ */ e.createElement(
73
- k,
72
+ /* @__PURE__ */ e.createElement("div", { className: F.deviceLists }, o && /* @__PURE__ */ e.createElement(
73
+ D,
74
74
  {
75
- label: a,
76
- devices: _,
77
- onChange: l
75
+ label: l,
76
+ devices: B,
77
+ onChange: s
78
78
  }
79
- ), o && /* @__PURE__ */ e.createElement(
80
- k,
79
+ ), a && /* @__PURE__ */ e.createElement(
80
+ D,
81
81
  {
82
- label: s,
83
- devices: b,
84
- onChange: P
82
+ label: v,
83
+ devices: C,
84
+ onChange: x
85
85
  }
86
- ), u && /* @__PURE__ */ e.createElement(
87
- k,
86
+ ), f && /* @__PURE__ */ e.createElement(
87
+ D,
88
88
  {
89
- label: h,
90
- devices: f,
91
- onChange: F
89
+ label: O,
90
+ devices: E,
91
+ onChange: z
92
92
  }
93
93
  )),
94
- /* @__PURE__ */ e.createElement("div", { className: g.buttons }, /* @__PURE__ */ e.createElement(S, { className: g.cancelButton, onClick: L }, M), /* @__PURE__ */ e.createElement(S, { className: g.confirmButton, onClick: N }, w))
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
- }, ie = "_background_kb025_1", ce = "_modal_kb025_13", oe = "_deviceSelectContainer_kb025_19", ae = "_preview_kb025_31", se = "_previewVideo_kb025_39", de = "_deviceLists_kb025_44", ue = "_buttons_kb025_50", re = "_chancelButton_kb025_57", le = "_confirmButton_kb025_59", r = {
97
- background: ie,
98
- modal: ce,
99
- deviceSelectContainer: oe,
100
- preview: ae,
101
- previewVideo: se,
102
- deviceLists: de,
103
- buttons: ue,
104
- chancelButton: re,
105
- confirmButton: le
106
- }, ve = () => {
107
- const [i, o] = m();
108
- return O(() => () => {
109
- i !== void 0 && i.getTracks().forEach((n) => n.stop());
110
- }, []), [i, (n) => {
111
- n.kind !== "audiooutput" && (async () => {
112
- const a = await navigator.mediaDevices.getUserMedia(
113
- n.kind === "audioinput" ? { video: !1, audio: { deviceId: n.deviceId } } : { video: { deviceId: n.deviceId }, audio: !1 }
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
- o(a);
115
+ a(l);
116
116
  })();
117
117
  }];
118
- }, _e = ({
119
- isSelectAudioInput: i = !0,
120
- isSelectAudioOutput: o = !0,
121
- isSelectVideoInput: u = !0,
122
- open: n,
123
- audioInputDeviceLabel: a = "audio input device",
124
- audioOutputDeviceLabel: s = "audio output device",
125
- videoInputDeviceLabel: h = "video input device",
126
- confirmButtonText: w = "Confirm",
127
- cancelButtonText: M = "Cancel",
128
- allowOutsideClick: C = !0,
129
- onDeviceSelected: j,
130
- onDeviceSelectCanceled: D
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 [d, $] = G(), [E, V] = m(), [I, A] = m(), [B, y] = m(), [_, b] = ve(), f = z(), N = T(() => d.filter((t) => t.kind === "audioinput"), [d]), L = T(() => d.filter((t) => t.kind === "audiooutput"), [d]), l = T(() => d.filter((t) => t.kind === "videoinput"), [d]);
133
- O(() => {
134
- n && $();
135
- }, [n]), O(() => {
136
- if (l.length < 1)
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 [t] = l;
139
- b(t);
140
- }, [l]);
141
- const P = () => {
142
- j({
143
- audioInput: E !== void 0 ? E : N[0],
144
- audioOutput: I !== void 0 ? I : L[0],
145
- videoInput: B !== void 0 ? B : l[0]
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
- }, F = () => {
148
- D();
149
- }, R = (t) => {
150
- V(N.find((v) => v.deviceId === t));
151
- }, c = (t) => {
152
- A(L.find((v) => v.deviceId === t));
153
- }, p = (t) => {
154
- const v = l.find((x) => x.deviceId === t);
155
- y(v), b(v);
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
- O(() => {
158
- const { current: t } = f;
159
- t !== void 0 && (t.srcObject !== null && t.srcObject instanceof MediaStream && (t.srcObject.getTracks().forEach((v) => v.stop()), t.pause()), t.srcObject = _, t.play());
160
- }, [_]);
161
- const U = () => {
162
- D();
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 n ? /* @__PURE__ */ e.createElement("div", { className: r.background, ...C ? { onClick: U } : {} }, /* @__PURE__ */ e.createElement(
164
+ return c ? /* @__PURE__ */ e.createElement("div", { className: I.background, ...S ? { onClick: N } : {} }, /* @__PURE__ */ e.createElement(
165
165
  "div",
166
166
  {
167
- className: r.modal,
168
- ...C ? {
169
- onClick: (t) => t.stopPropagation()
167
+ className: I.modal,
168
+ ...S ? {
169
+ onClick: (n) => n.stopPropagation()
170
170
  } : {}
171
171
  },
172
- /* @__PURE__ */ e.createElement("div", { className: r.deviceSelectContainer }, /* @__PURE__ */ e.createElement("div", { className: r.preview }, /* @__PURE__ */ e.createElement(
173
- "video",
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
- className: r.previewVideo,
176
- ref: f,
177
- autoPlay: !0,
178
- muted: !0,
179
- playsInline: !0
175
+ label: l,
176
+ devices: w,
177
+ onChange: T
180
178
  }
181
- )), /* @__PURE__ */ e.createElement("div", { className: r.deviceLists }, i && /* @__PURE__ */ e.createElement(
182
- k,
179
+ ), a && /* @__PURE__ */ e.createElement(
180
+ D,
183
181
  {
184
- label: a,
185
- devices: N,
186
- onChange: R
182
+ label: v,
183
+ devices: d,
184
+ onChange: i
187
185
  }
188
- ), o && /* @__PURE__ */ e.createElement(
189
- k,
186
+ ), f && /* @__PURE__ */ e.createElement(
187
+ D,
190
188
  {
191
- label: s,
192
- devices: L,
193
- onChange: c
189
+ label: O,
190
+ devices: s,
191
+ onChange: _
194
192
  }
195
- ), u && /* @__PURE__ */ e.createElement(
196
- k,
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: h,
199
- devices: l,
200
- onChange: p
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: r.buttons }, /* @__PURE__ */ e.createElement(S, { className: r.cancelButton, onClick: F }, M), /* @__PURE__ */ e.createElement(S, { className: r.confirmButton, onClick: P }, w))
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
- pe as SelectMediaDevicesModal,
208
- _e as SelectMediaDevicesPreviewModal
322
+ Re as SelectMediaDevicesModal,
323
+ Pe as SelectMediaDevicesPreviewModal,
324
+ Te as SelectMediaDevicesRecordingModal
209
325
  };
@@ -1 +1 @@
1
- (function(l,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],e):(l=typeof globalThis<"u"?globalThis:l||self,e(l.ReactSelectMediaDevicesModal={},l.React))})(this,function(l,e){"use strict";const p={background:"_background_1djbv_1",modal:"_modal_1djbv_13",deviceLists:"_deviceLists_1djbv_20",buttons:"_buttons_1djbv_24",chancelButton:"_chancelButton_1djbv_31",confirmButton:"_confirmButton_1djbv_33"},F=()=>{const[i,c]=e.useState([]);return[i,()=>{(async()=>{const n=await navigator.mediaDevices.getUserMedia({audio:!0,video:!0}),s=await navigator.mediaDevices.enumerateDevices();c(s),n.getTracks().forEach(d=>d.stop())})()}]},G=({name:i,value:c})=>e.createElement("option",{value:c},i),q={deviceList:"_deviceList_1bfq1_1",select:"_select_1bfq1_5"},b=({devices:i,label:c,onChange:r})=>{if(i===void 0)return e.createElement(e.Fragment,null);const n=d=>{r(d.target.value)},s=`device-select-${c.toLowerCase().replace(/\s/g,"-")}`;return e.createElement("div",{className:q.deviceList},e.createElement("label",{htmlFor:s},c),e.createElement("select",{className:q.select,id:s,onChange:n},i.map((d,h)=>e.createElement(G,{value:d.deviceId,name:d.label,key:h}))))},U={button:"_button_keu24_1"},L=({className:i,children:c,onClick:r})=>e.createElement("button",{onClick:r,className:[U.button,i].filter(Boolean).join(" ")},c),x=({isSelectAudioInput:i=!0,isSelectAudioOutput:c=!0,isSelectVideoInput:r=!0,open:n,audioInputDeviceLabel:s="audio input device",audioOutputDeviceLabel:d="audio output device",videoInputDeviceLabel:h="video input device",confirmButtonText:N="Confirm",cancelButtonText:$="Cancel",allowOutsideClick:D=!0,onDeviceSelected:w,onDeviceSelectCanceled:C})=>{const[u,O]=F(),[E,j]=e.useState(),[I,y]=e.useState(),[S,V]=e.useState(),_=u.filter(o=>o.kind==="audioinput"),g=u.filter(o=>o.kind==="audiooutput"),k=u.filter(o=>o.kind==="videoinput");e.useEffect(()=>{n&&O()},[n]);const B=()=>{w({audioInput:E!==void 0?E:_[0],audioOutput:I!==void 0?I:g[0],videoInput:S!==void 0?S:k[0]})},M=()=>{C()},v=o=>{j(_.find(f=>f.deviceId===o))},A=o=>{y(g.find(f=>f.deviceId===o))},P=o=>{V(k.find(f=>f.deviceId===o))},T=()=>{C()};return n?e.createElement("div",{className:p.background,...D?{onClick:T}:{}},e.createElement("div",{className:p.modal,...D?{onClick:o=>o.stopPropagation()}:{}},e.createElement("div",{className:p.deviceLists},i&&e.createElement(b,{label:s,devices:_,onChange:v}),c&&e.createElement(b,{label:d,devices:g,onChange:A}),r&&e.createElement(b,{label:h,devices:k,onChange:P})),e.createElement("div",{className:p.buttons},e.createElement(L,{className:p.cancelButton,onClick:M},$),e.createElement(L,{className:p.confirmButton,onClick:B},N)))):e.createElement(e.Fragment,null)},a={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"},z=()=>{const[i,c]=e.useState();return e.useEffect(()=>()=>{i!==void 0&&i.getTracks().forEach(n=>n.stop())},[]),[i,n=>{n.kind!=="audiooutput"&&(async()=>{const s=await navigator.mediaDevices.getUserMedia(n.kind==="audioinput"?{video:!1,audio:{deviceId:n.deviceId}}:{video:{deviceId:n.deviceId},audio:!1});c(s)})()}]},H=({isSelectAudioInput:i=!0,isSelectAudioOutput:c=!0,isSelectVideoInput:r=!0,open:n,audioInputDeviceLabel:s="audio input device",audioOutputDeviceLabel:d="audio output device",videoInputDeviceLabel:h="video input device",confirmButtonText:N="Confirm",cancelButtonText:$="Cancel",allowOutsideClick:D=!0,onDeviceSelected:w,onDeviceSelectCanceled:C})=>{const[u,O]=F(),[E,j]=e.useState(),[I,y]=e.useState(),[S,V]=e.useState(),[_,g]=z(),k=e.useRef(),B=e.useMemo(()=>u.filter(t=>t.kind==="audioinput"),[u]),M=e.useMemo(()=>u.filter(t=>t.kind==="audiooutput"),[u]),v=e.useMemo(()=>u.filter(t=>t.kind==="videoinput"),[u]);e.useEffect(()=>{n&&O()},[n]),e.useEffect(()=>{if(v.length<1)return;const[t]=v;g(t)},[v]);const A=()=>{w({audioInput:E!==void 0?E:B[0],audioOutput:I!==void 0?I:M[0],videoInput:S!==void 0?S:v[0]})},P=()=>{C()},T=t=>{j(B.find(m=>m.deviceId===t))},o=t=>{y(M.find(m=>m.deviceId===t))},f=t=>{const m=v.find(K=>K.deviceId===t);V(m),g(m)};e.useEffect(()=>{const{current:t}=k;t!==void 0&&(t.srcObject!==null&&t.srcObject instanceof MediaStream&&(t.srcObject.getTracks().forEach(m=>m.stop()),t.pause()),t.srcObject=_,t.play())},[_]);const J=()=>{C()};return n?e.createElement("div",{className:a.background,...D?{onClick:J}:{}},e.createElement("div",{className:a.modal,...D?{onClick:t=>t.stopPropagation()}:{}},e.createElement("div",{className:a.deviceSelectContainer},e.createElement("div",{className:a.preview},e.createElement("video",{className:a.previewVideo,ref:k,autoPlay:!0,muted:!0,playsInline:!0})),e.createElement("div",{className:a.deviceLists},i&&e.createElement(b,{label:s,devices:B,onChange:T}),c&&e.createElement(b,{label:d,devices:M,onChange:o}),r&&e.createElement(b,{label:h,devices:v,onChange:f}))),e.createElement("div",{className:a.buttons},e.createElement(L,{className:a.cancelButton,onClick:P},$),e.createElement(L,{className:a.confirmButton,onClick:A},N)))):e.createElement(e.Fragment,null)};l.SelectMediaDevicesModal=x,l.SelectMediaDevicesPreviewModal=H,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
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: boolean;
3
- isSelectAudioOutput: boolean;
4
- isSelectVideoInput: boolean;
3
+ isSelectAudioInput?: boolean;
4
+ isSelectAudioOutput?: boolean;
5
+ isSelectVideoInput?: boolean;
5
6
  open: boolean;
6
- audioInputDeviceLabel: string;
7
- audioOutputDeviceLabel: string;
8
- videoInputDeviceLabel: string;
9
- confirmButtonText: string;
10
- cancelButtonText: string;
11
- allowOutsideClick: boolean;
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: boolean;
3
- isSelectAudioOutput: boolean;
4
- isSelectVideoInput: boolean;
3
+ isSelectAudioInput?: boolean;
4
+ isSelectAudioOutput?: boolean;
5
+ isSelectVideoInput?: boolean;
5
6
  open: boolean;
6
- audioInputDeviceLabel: string;
7
- audioOutputDeviceLabel: string;
8
- videoInputDeviceLabel: string;
9
- confirmButtonText: string;
10
- cancelButtonText: string;
11
- allowOutsideClick: boolean;
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;
@@ -1,2 +1,3 @@
1
1
  export { default as SelectMediaDevicesModal } from './SelectMediaDevicesModal';
2
2
  export { default as SelectMediaDevicesPreviewModal } from './SelectMediaDevicesPreviewModal';
3
+ export { default as SelectMediaDevicesRecordingModal } from './SelectMediaDevicesRecordingModal';
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": "0.0.12",
4
+ "version": "1.0.0",
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.10.0"
45
+ "react-router-dom": "^6.14.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@mdx-js/react": "^2.3.0",
49
- "@playwright/test": "^1.33.0",
50
- "@rollup/plugin-typescript": "^11.1.0",
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": "^18.15.11",
55
- "@types/react": "^18.0.33",
56
- "@vitejs/plugin-react": "^3.1.0",
57
- "@vitest/coverage-c8": "^0.30.1",
58
- "@vitest/ui": "^0.30.1",
59
- "jsdom": "^21.1.1",
60
- "playwright": "^1.33.0",
61
- "rimraf": "^4.4.1",
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.2.1",
64
- "vite-pages-theme-doc": "^4.0.0",
65
- "vite-plugin-react-pages": "^4.0.0",
66
- "vitest": "^0.30.1"
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
  }