@progress/kendo-react-buttons 11.3.1 → 11.4.0-develop.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Button.js +1 -1
- package/Button.mjs +61 -48
- package/README.md +26 -2
- package/SpeechToTextButton/SpeechToTextButton.js +8 -0
- package/SpeechToTextButton/SpeechToTextButton.mjs +133 -0
- package/dist/cdn/js/kendo-react-buttons.js +1 -1
- package/index.d.mts +168 -52
- package/index.d.ts +168 -52
- package/index.js +1 -1
- package/index.mjs +12 -10
- package/messages/index.js +8 -0
- package/messages/index.mjs +16 -0
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +6 -5
package/Button.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react"),l=require("prop-types"),e=require("@progress/kendo-react-common");function F(n){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const o in n)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(n,o);Object.defineProperty(r,o,s.get?s:{enumerable:!0,get:()=>n[o]})}}return r.default=n,Object.freeze(r)}const t=F(W);function G({imageUrl:n,name:r,iconClass:o,svgIcon:s,imageAlt:u,buttonClasses:i,iconSize:c}){return n?t.createElement("img",{role:"presentation",className:e.classNames(e.uButton.icon({c:i})),alt:u,src:n}):r||s?t.createElement(e.IconWrap,{className:e.classNames(e.uButton.icon({c:i})),name:r,icon:s,size:c}):o?t.createElement("span",{role:"presentation",className:e.classNames(e.uButton.icon({c:i}),o)}):null}const p=t.forwardRef((n,r)=>{const{children:o,togglable:s,dir:u,disabled:i,selected:c,icon:b,iconClass:v,svgIcon:y,imageUrl:N,imageAlt:M,className:P,startIcon:h,endIcon:B,onClick:C,size:S=g.size,rounded:k=g.rounded,fillMode:z=g.fillMode,themeColor:T=g.themeColor,ariaPressed:j,iconSize:A,...w}=n,q=()=>{s&&c===void 0&&(d.current=!a,O(!a))},U=f=>{q(),C&&C.call(void 0,f)},d=t.useRef(void 0),E=t.useRef(null),[a,O]=t.useState(s===!0&&c===!0),_=y!==void 0||b!==void 0||v!==void 0||N!==void 0,x=o!==void 0,D=e.useUnstyled(),R=n.unstyled||D,m=R&&R.uButton;t.useImperativeHandle(r,()=>({element:E.current,selected:d.current!==void 0?d.current:a})),t.useMemo(()=>{s&&c!==void 0&&c!==a&&O(c)},[s,c]),t.useEffect(()=>{d.current=void 0},[a]);const H=G({name:b,svgIcon:y,iconClass:v,imageUrl:N,imageAlt:M,buttonClasses:m,iconSize:A}),I=f=>t.cloneElement(f,{className:e.classNames(e.uButton.icon({c:m}),f.props.className)}),K=t.useMemo(()=>s?a:j||void 0,[]);return t.createElement("button",{ref:E,"aria-pressed":K,...w,dir:u,disabled:i,onClick:U,className:e.classNames(e.uButton.wrapper({c:m,isRtl:u==="rtl",selected:a,disabled:i,size:S,fillMode:z,rounded:k,themeColor:T,iconButton:!x&&_}),P)},h&&I(h),H,o&&t.createElement("span",{className:e.classNames(e.uButton.text({c:m}))},o),B&&I(B))}),g={togglable:!1,size:"medium",rounded:"medium",fillMode:"solid",themeColor:"base"};p.displayName="KendoReactButton";p.propTypes={children:l.node,selected:l.bool,togglable:l.bool,icon:l.string,svgIcon:e.svgIconPropType,iconClass:l.string,imageUrl:l.string,imageAlt:l.string,size:l.oneOf([null,"small","medium","large"]),rounded:l.oneOf([null,"small","medium","large","full"]),fillMode:l.oneOf([null,"flat","link","outline","solid","clear"]),themeColor:l.oneOf([null,"base","primary","secondary","tertiary","info","success","warning","error","dark","light","inverse"])};exports.Button=p;
|
package/Button.mjs
CHANGED
|
@@ -7,88 +7,101 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as e from "react";
|
|
9
9
|
import t from "prop-types";
|
|
10
|
-
import { useUnstyled as
|
|
11
|
-
function
|
|
10
|
+
import { useUnstyled as G, classNames as c, uButton as i, svgIconPropType as J, IconWrap as L } from "@progress/kendo-react-common";
|
|
11
|
+
function Q({ imageUrl: a, name: d, iconClass: s, svgIcon: n, imageAlt: u, buttonClasses: r, iconSize: o }) {
|
|
12
12
|
return a ? /* @__PURE__ */ e.createElement(
|
|
13
13
|
"img",
|
|
14
14
|
{
|
|
15
15
|
role: "presentation",
|
|
16
|
-
className: c(i.icon({ c:
|
|
16
|
+
className: c(i.icon({ c: r })),
|
|
17
17
|
alt: u,
|
|
18
18
|
src: a
|
|
19
19
|
}
|
|
20
|
-
) : d || n ? /* @__PURE__ */ e.createElement(
|
|
20
|
+
) : d || n ? /* @__PURE__ */ e.createElement(
|
|
21
|
+
L,
|
|
22
|
+
{
|
|
23
|
+
className: c(i.icon({ c: r })),
|
|
24
|
+
name: d,
|
|
25
|
+
icon: n,
|
|
26
|
+
size: o
|
|
27
|
+
}
|
|
28
|
+
) : s ? /* @__PURE__ */ e.createElement("span", { role: "presentation", className: c(i.icon({ c: r }), s) }) : null;
|
|
21
29
|
}
|
|
22
|
-
const
|
|
30
|
+
const k = e.forwardRef((a, d) => {
|
|
23
31
|
const {
|
|
24
|
-
children:
|
|
32
|
+
children: s,
|
|
25
33
|
togglable: n,
|
|
26
34
|
dir: u,
|
|
27
|
-
disabled:
|
|
28
|
-
selected:
|
|
35
|
+
disabled: r,
|
|
36
|
+
selected: o,
|
|
29
37
|
icon: v,
|
|
30
38
|
iconClass: h,
|
|
31
39
|
svgIcon: y,
|
|
32
40
|
imageUrl: b,
|
|
33
|
-
imageAlt:
|
|
34
|
-
className:
|
|
41
|
+
imageAlt: A,
|
|
42
|
+
className: B,
|
|
35
43
|
startIcon: C,
|
|
36
44
|
endIcon: E,
|
|
37
45
|
onClick: N,
|
|
38
|
-
size:
|
|
39
|
-
rounded:
|
|
40
|
-
fillMode:
|
|
41
|
-
themeColor:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
},
|
|
46
|
+
size: P = g.size,
|
|
47
|
+
rounded: O = g.rounded,
|
|
48
|
+
fillMode: S = g.fillMode,
|
|
49
|
+
themeColor: T = g.themeColor,
|
|
50
|
+
ariaPressed: w,
|
|
51
|
+
iconSize: x,
|
|
52
|
+
...U
|
|
53
|
+
} = a, H = () => {
|
|
54
|
+
n && o === void 0 && (m.current = !l, R(!l));
|
|
55
|
+
}, K = (p) => {
|
|
56
|
+
H(), N && N.call(void 0, p);
|
|
57
|
+
}, m = e.useRef(void 0), I = e.useRef(null), [l, R] = e.useState(n === !0 && o === !0), W = y !== void 0 || v !== void 0 || h !== void 0 || b !== void 0, j = s !== void 0, q = G(), z = a.unstyled || q, f = z && z.uButton;
|
|
48
58
|
e.useImperativeHandle(d, () => ({
|
|
49
59
|
element: I.current,
|
|
50
|
-
selected: m.current !== void 0 ? m.current :
|
|
60
|
+
selected: m.current !== void 0 ? m.current : l
|
|
51
61
|
})), e.useMemo(() => {
|
|
52
|
-
n &&
|
|
53
|
-
}, [n,
|
|
62
|
+
n && o !== void 0 && o !== l && R(o);
|
|
63
|
+
}, [n, o]), e.useEffect(() => {
|
|
54
64
|
m.current = void 0;
|
|
55
|
-
}, [
|
|
56
|
-
const
|
|
65
|
+
}, [l]);
|
|
66
|
+
const D = Q({
|
|
57
67
|
name: v,
|
|
58
68
|
svgIcon: y,
|
|
59
69
|
iconClass: h,
|
|
60
70
|
imageUrl: b,
|
|
61
|
-
imageAlt:
|
|
62
|
-
buttonClasses: f
|
|
63
|
-
|
|
71
|
+
imageAlt: A,
|
|
72
|
+
buttonClasses: f,
|
|
73
|
+
iconSize: x
|
|
74
|
+
}), M = (p) => e.cloneElement(p, {
|
|
75
|
+
className: c(i.icon({ c: f }), p.props.className)
|
|
76
|
+
}), F = e.useMemo(() => n ? l : w || void 0, []);
|
|
64
77
|
return /* @__PURE__ */ e.createElement(
|
|
65
78
|
"button",
|
|
66
79
|
{
|
|
67
80
|
ref: I,
|
|
68
|
-
"aria-pressed":
|
|
69
|
-
...
|
|
81
|
+
"aria-pressed": F,
|
|
82
|
+
...U,
|
|
70
83
|
dir: u,
|
|
71
|
-
disabled:
|
|
72
|
-
onClick:
|
|
84
|
+
disabled: r,
|
|
85
|
+
onClick: K,
|
|
73
86
|
className: c(
|
|
74
87
|
i.wrapper({
|
|
75
88
|
c: f,
|
|
76
89
|
isRtl: u === "rtl",
|
|
77
|
-
selected:
|
|
78
|
-
disabled:
|
|
79
|
-
size:
|
|
80
|
-
fillMode:
|
|
81
|
-
rounded:
|
|
82
|
-
themeColor:
|
|
83
|
-
iconButton: !
|
|
90
|
+
selected: l,
|
|
91
|
+
disabled: r,
|
|
92
|
+
size: P,
|
|
93
|
+
fillMode: S,
|
|
94
|
+
rounded: O,
|
|
95
|
+
themeColor: T,
|
|
96
|
+
iconButton: !j && W
|
|
84
97
|
}),
|
|
85
|
-
|
|
98
|
+
B
|
|
86
99
|
)
|
|
87
100
|
},
|
|
88
|
-
C &&
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
E &&
|
|
101
|
+
C && M(C),
|
|
102
|
+
D,
|
|
103
|
+
s && /* @__PURE__ */ e.createElement("span", { className: c(i.text({ c: f })) }, s),
|
|
104
|
+
E && M(E)
|
|
92
105
|
);
|
|
93
106
|
}), g = {
|
|
94
107
|
togglable: !1,
|
|
@@ -97,13 +110,13 @@ const M = e.forwardRef((a, d) => {
|
|
|
97
110
|
fillMode: "solid",
|
|
98
111
|
themeColor: "base"
|
|
99
112
|
};
|
|
100
|
-
|
|
101
|
-
|
|
113
|
+
k.displayName = "KendoReactButton";
|
|
114
|
+
k.propTypes = {
|
|
102
115
|
children: t.node,
|
|
103
116
|
selected: t.bool,
|
|
104
117
|
togglable: t.bool,
|
|
105
118
|
icon: t.string,
|
|
106
|
-
svgIcon:
|
|
119
|
+
svgIcon: J,
|
|
107
120
|
iconClass: t.string,
|
|
108
121
|
imageUrl: t.string,
|
|
109
122
|
imageAlt: t.string,
|
|
@@ -127,5 +140,5 @@ M.propTypes = {
|
|
|
127
140
|
])
|
|
128
141
|
};
|
|
129
142
|
export {
|
|
130
|
-
|
|
143
|
+
k as Button
|
|
131
144
|
};
|
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ What's in this package:
|
|
|
30
30
|
- [React ChipList component (free)](#react-chiplist-component)
|
|
31
31
|
- [React DropDownButton component (premium)](#react-dropdownbutton-component)
|
|
32
32
|
- [React FloatingActionButton component (free)](#react-floatingactionbutton-component)
|
|
33
|
+
- [React SpeechToTextButton component (premium)](#react-speechtotextbutton-component)
|
|
33
34
|
- [React SplitButton component (premium)](#react-splitbutton-component)
|
|
34
35
|
- [React Toolbar component (free)](#react-toolbar-component)
|
|
35
36
|
|
|
@@ -192,6 +193,28 @@ import { FloatingActionButton } from '@progress/kendo-react-buttons';
|
|
|
192
193
|
<FloatingActionButton text={'FloatingActionButtonLabel'} />
|
|
193
194
|
```
|
|
194
195
|
|
|
196
|
+
## React SpeechToTextButton Component
|
|
197
|
+
|
|
198
|
+
> This is a KendoReact **premium component** and requires a commercial license or an active trial license.
|
|
199
|
+
|
|
200
|
+
[The KendoReact SpeechToTextButton component](https://www.telerik.com/kendo-react-ui/components/buttons/speechtotextbutton/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-buttons) is a component for converting spoken input into text using speech recognition.
|
|
201
|
+
|
|
202
|
+
Key features:
|
|
203
|
+
|
|
204
|
+
- [Speech configurations](https://www.telerik.com/kendo-react-ui/components/buttons/speechtotextbutton/speech-configs)—The KendoReact SpeechToTextButton provides various configuration options for controlling speech recognition settings.
|
|
205
|
+
- [Appearance](https://www.telerik.com/kendo-react-ui/components/buttons/speechtotextbutton/appearance)—The KendoReact SpeechToTextButton provides the ability to customize its appearance.
|
|
206
|
+
- [Integration](https://www.telerik.com/kendo-react-ui/components/buttons/speechtotextbutton/integration)—The KendoReact SpeechToTextButton can be seamlessly integrated with other KendoReact components or with external speech recognition services.
|
|
207
|
+
|
|
208
|
+
How to use a simple text SpeechToTextButton component in your apps:
|
|
209
|
+
|
|
210
|
+
```tsx
|
|
211
|
+
import { SpeechToTextButton } from '@progress/kendo-react-buttons';
|
|
212
|
+
...
|
|
213
|
+
<SpeechToTextButton>
|
|
214
|
+
Button label
|
|
215
|
+
</SpeechToTextButton>
|
|
216
|
+
```
|
|
217
|
+
|
|
195
218
|
## React SplitButton Component
|
|
196
219
|
|
|
197
220
|
> This is a KendoReact **premium component** and requires a commercial license or an active trial license.
|
|
@@ -214,7 +237,7 @@ import { SplitButton, SplitButtonItem } from '@progress/kendo-react-buttons';
|
|
|
214
237
|
</SplitButton>
|
|
215
238
|
```
|
|
216
239
|
|
|
217
|
-
How to use the
|
|
240
|
+
How to use the SplitButtonComponent with simple data binding:
|
|
218
241
|
|
|
219
242
|
```tsx
|
|
220
243
|
import { SplitButton } from '@progress/kendo-react-buttons';
|
|
@@ -279,7 +302,8 @@ High-level component overview pages
|
|
|
279
302
|
- [React Chip Component](https://www.telerik.com/kendo-react-ui/chip)
|
|
280
303
|
- [React ChipList Component](https://www.telerik.com/kendo-react-ui/chiplist)
|
|
281
304
|
- [React DropDownButton Component](https://www.telerik.com/kendo-react-ui/dropdownbutton)
|
|
282
|
-
- [React
|
|
305
|
+
- [React FloatingActionButton Component](https://www.telerik.com/kendo-react-ui/floatingactionbutton)
|
|
306
|
+
- [React SpeechToTextButton Component](https://www.telerik.com/kendo-react-ui/speechtotextbutton)
|
|
283
307
|
- [React SplitButton Component](https://www.telerik.com/kendo-react-ui/splitbutton)
|
|
284
308
|
- [React Toolbar Component](https://www.telerik.com/kendo-react-ui/toolbar)
|
|
285
309
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),$=require("@progress/kendo-webspeech-common"),ee=require("../Button.js"),p=require("@progress/kendo-react-common"),A=require("@progress/kendo-svg-icons"),c=require("../messages/index.js"),te=require("@progress/kendo-react-intl"),ne=require("../package-metadata.js"),q=e.forwardRef((a,M)=>{const B=!p.validatePackage(ne.packageMetadata,{component:"SpeechToTextButton"}),S=te.useLocalization(),{fillMode:E="solid",rounded:z="medium",size:H="medium",themeColor:L="base",ariaLabel:d,svgIcon:k,disabled:N,iconSize:O="medium",title:f,className:F,id:P,style:W,lang:v="en-US",continuous:b=!1,interimResults:T=!1,maxAlternatives:R=1,integrationMode:w="webSpeech",onStart:m,onResult:l,onEnd:g,onError:o,...K}=a,s=e.useRef(null),n=e.useRef(!1),[i,u]=e.useState(!1),r=w!=="none",U=e.useCallback(async()=>{n.current=!0,u(!0),m&&await m()},[m]),j=e.useCallback(async()=>{n.current=!1,u(!1),g&&await g()},[g]),D=e.useCallback(t=>{const x=t.results,I=x[x.length-1],_=Array.from(I).map(y=>({transcript:y.transcript,confidence:y.confidence}));l==null||l({isFinal:I.isFinal,alternatives:_})},[l]),G=e.useCallback(t=>{u(!1),n.current=!1,o==null||o({errorMessage:t.error})},[o]),J=()=>{var t;if(typeof window!="undefined"&&!("webkitSpeechRecognition"in window||"SpeechRecognition"in window)){o&&o({errorMessage:"Speech Recognition API is not supported in this browser."});return}(t=s.current)!=null&&t.isActive()&&s.current.stop(),s.current=new $.KendoSpeechRecognition({lang:v,continuous:b,interimResults:T,maxAlternatives:R,events:{start:U,end:j,result:D,error:G}})},C=e.useCallback(()=>{var t;!n.current&&r&&((t=s.current)==null||t.start())},[r]),h=e.useCallback(()=>{var t;n.current&&r&&((t=s.current)==null||t.stop())},[r]),Q=e.useCallback(()=>{var t;n.current&&r&&((t=s.current)==null||t.abort(),n.current=!1,u(!1))},[r]),V=()=>n.current;e.useImperativeHandle(M,()=>({start:C,stop:h,abort:Q,isActive:V})),e.useEffect(()=>(J(),()=>{n.current&&h()}),[v,b,T,R,w]);const X=()=>{i?h():C()},Y=a.icon!==void 0||a.iconClass!==void 0||a.imageUrl!==void 0,Z=e.useMemo(()=>i?A.stopSmIcon:k||A.microphoneOutlineIcon,[i,k]);return e.createElement(e.Fragment,null,e.createElement(ee.Button,{id:P,className:p.classNames({"k-speech-to-text-button":!0,"k-listening":i},F),style:W,svgIcon:Y?void 0:Z,iconSize:O,fillMode:E,rounded:z,size:H,themeColor:L,"aria-label":d!=null?d:S.toLanguageString(c.speechToTextAriaLabel,c.messages[c.speechToTextAriaLabel]),"aria-pressed":i,disabled:N,title:f!=null?f:S.toLanguageString(c.speechToTextTitle,c.messages[c.speechToTextTitle]),onClick:X,...K},a.children),B&&e.createElement(p.WatermarkOverlay,null))});q.displayName="KendoSpeechToTextButton";exports.SpeechToTextButton=q;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import e from "react";
|
|
9
|
+
import { KendoSpeechRecognition as Z } from "@progress/kendo-webspeech-common";
|
|
10
|
+
import { Button as $ } from "../Button.mjs";
|
|
11
|
+
import { validatePackage as ee, classNames as te, WatermarkOverlay as ne } from "@progress/kendo-react-common";
|
|
12
|
+
import { stopSmIcon as re, microphoneOutlineIcon as oe } from "@progress/kendo-svg-icons";
|
|
13
|
+
import { speechToTextAriaLabel as x, messages as A, speechToTextTitle as y } from "../messages/index.mjs";
|
|
14
|
+
import { useLocalization as se } from "@progress/kendo-react-intl";
|
|
15
|
+
import { packageMetadata as ae } from "../package-metadata.mjs";
|
|
16
|
+
const ie = e.forwardRef((a, E) => {
|
|
17
|
+
const M = !ee(ae, { component: "SpeechToTextButton" }), g = se(), {
|
|
18
|
+
fillMode: z = "solid",
|
|
19
|
+
rounded: H = "medium",
|
|
20
|
+
size: B = "medium",
|
|
21
|
+
themeColor: L = "base",
|
|
22
|
+
ariaLabel: u,
|
|
23
|
+
svgIcon: h,
|
|
24
|
+
disabled: N,
|
|
25
|
+
iconSize: F = "medium",
|
|
26
|
+
title: f,
|
|
27
|
+
className: O,
|
|
28
|
+
id: K,
|
|
29
|
+
style: P,
|
|
30
|
+
lang: v = "en-US",
|
|
31
|
+
continuous: S = !1,
|
|
32
|
+
interimResults: b = !1,
|
|
33
|
+
maxAlternatives: k = 1,
|
|
34
|
+
integrationMode: w = "webSpeech",
|
|
35
|
+
onStart: m,
|
|
36
|
+
onResult: c,
|
|
37
|
+
onEnd: d,
|
|
38
|
+
onError: r,
|
|
39
|
+
...U
|
|
40
|
+
} = a, o = e.useRef(null), n = e.useRef(!1), [i, l] = e.useState(!1), s = w !== "none", W = e.useCallback(async () => {
|
|
41
|
+
n.current = !0, l(!0), m && await m();
|
|
42
|
+
}, [m]), _ = e.useCallback(async () => {
|
|
43
|
+
n.current = !1, l(!1), d && await d();
|
|
44
|
+
}, [d]), j = e.useCallback(
|
|
45
|
+
(t) => {
|
|
46
|
+
const C = t.results, T = C[C.length - 1], Y = Array.from(T).map((I) => ({
|
|
47
|
+
transcript: I.transcript,
|
|
48
|
+
confidence: I.confidence
|
|
49
|
+
}));
|
|
50
|
+
c == null || c({
|
|
51
|
+
isFinal: T.isFinal,
|
|
52
|
+
alternatives: Y
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
[c]
|
|
56
|
+
), q = e.useCallback(
|
|
57
|
+
(t) => {
|
|
58
|
+
l(!1), n.current = !1, r == null || r({
|
|
59
|
+
errorMessage: t.error
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
[r]
|
|
63
|
+
), D = () => {
|
|
64
|
+
var t;
|
|
65
|
+
if (typeof window != "undefined" && !("webkitSpeechRecognition" in window || "SpeechRecognition" in window)) {
|
|
66
|
+
r && r({ errorMessage: "Speech Recognition API is not supported in this browser." });
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
(t = o.current) != null && t.isActive() && o.current.stop(), o.current = new Z({
|
|
70
|
+
lang: v,
|
|
71
|
+
continuous: S,
|
|
72
|
+
interimResults: b,
|
|
73
|
+
maxAlternatives: k,
|
|
74
|
+
events: {
|
|
75
|
+
start: W,
|
|
76
|
+
end: _,
|
|
77
|
+
result: j,
|
|
78
|
+
error: q
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}, R = e.useCallback(() => {
|
|
82
|
+
var t;
|
|
83
|
+
!n.current && s && ((t = o.current) == null || t.start());
|
|
84
|
+
}, [s]), p = e.useCallback(() => {
|
|
85
|
+
var t;
|
|
86
|
+
n.current && s && ((t = o.current) == null || t.stop());
|
|
87
|
+
}, [s]), G = e.useCallback(() => {
|
|
88
|
+
var t;
|
|
89
|
+
n.current && s && ((t = o.current) == null || t.abort(), n.current = !1, l(!1));
|
|
90
|
+
}, [s]), J = () => n.current;
|
|
91
|
+
e.useImperativeHandle(E, () => ({
|
|
92
|
+
start: R,
|
|
93
|
+
stop: p,
|
|
94
|
+
abort: G,
|
|
95
|
+
isActive: J
|
|
96
|
+
})), e.useEffect(() => (D(), () => {
|
|
97
|
+
n.current && p();
|
|
98
|
+
}), [v, S, b, k, w]);
|
|
99
|
+
const Q = () => {
|
|
100
|
+
i ? p() : R();
|
|
101
|
+
}, V = a.icon !== void 0 || a.iconClass !== void 0 || a.imageUrl !== void 0, X = e.useMemo(() => i ? re : h || oe, [i, h]);
|
|
102
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
103
|
+
$,
|
|
104
|
+
{
|
|
105
|
+
id: K,
|
|
106
|
+
className: te(
|
|
107
|
+
{
|
|
108
|
+
"k-speech-to-text-button": !0,
|
|
109
|
+
"k-listening": i
|
|
110
|
+
},
|
|
111
|
+
O
|
|
112
|
+
),
|
|
113
|
+
style: P,
|
|
114
|
+
svgIcon: V ? void 0 : X,
|
|
115
|
+
iconSize: F,
|
|
116
|
+
fillMode: z,
|
|
117
|
+
rounded: H,
|
|
118
|
+
size: B,
|
|
119
|
+
themeColor: L,
|
|
120
|
+
"aria-label": u != null ? u : g.toLanguageString(x, A[x]),
|
|
121
|
+
"aria-pressed": i,
|
|
122
|
+
disabled: N,
|
|
123
|
+
title: f != null ? f : g.toLanguageString(y, A[y]),
|
|
124
|
+
onClick: Q,
|
|
125
|
+
...U
|
|
126
|
+
},
|
|
127
|
+
a.children
|
|
128
|
+
), M && /* @__PURE__ */ e.createElement(ne, null));
|
|
129
|
+
});
|
|
130
|
+
ie.displayName = "KendoSpeechToTextButton";
|
|
131
|
+
export {
|
|
132
|
+
ie as SpeechToTextButton
|
|
133
|
+
};
|