@progress/kendo-react-buttons 14.5.0-develop.8 → 15.0.0-develop.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/Button.d.ts +7 -3
- package/Button.js +1 -1
- package/Button.mjs +80 -78
- package/Chip/Chip.d.ts +6 -0
- package/Chip/Chip.js +1 -1
- package/Chip/Chip.mjs +67 -63
- package/Chip/ChipList.js +1 -1
- package/Chip/ChipList.mjs +1 -1
- package/FloatingActionButton/FloatingActionButton.js +1 -1
- package/FloatingActionButton/FloatingActionButton.mjs +100 -111
- package/FloatingActionButton/interfaces/FloatingActionButtonProps.d.ts +1 -7
- package/FloatingActionButton/models/size.d.ts +2 -1
- package/FloatingActionButton/models/theme-color.d.ts +2 -8
- package/ListButton/DropDownButton.js +1 -1
- package/ListButton/DropDownButton.mjs +44 -46
- package/ListButton/SplitButton.js +1 -1
- package/ListButton/SplitButton.mjs +58 -56
- package/ListButton/models/ListButtonProps.d.ts +2 -2
- package/README.md +4 -4
- package/SegmentedControl/SegmentedControl.js +1 -1
- package/SegmentedControl/SegmentedControl.mjs +28 -27
- package/SpeechToTextButton/SpeechToTextButton.js +1 -1
- package/SpeechToTextButton/SpeechToTextButton.mjs +27 -27
- package/dist/cdn/js/kendo-react-buttons.js +1 -1
- package/messages/index.d.ts +5 -0
- package/messages/index.js +1 -1
- package/messages/index.mjs +8 -6
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +11 -6
- package/toolbar/Toolbar.js +1 -1
- package/toolbar/Toolbar.mjs +68 -62
- package/toolbar/tools/ToolbarOverflowSection.js +1 -1
- package/toolbar/tools/ToolbarOverflowSection.mjs +66 -40
- package/toolbar/tools/ToolbarScrollButton.js +1 -1
- package/toolbar/tools/ToolbarScrollButton.mjs +14 -16
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as p from "react";
|
|
9
9
|
import s from "prop-types";
|
|
10
|
-
import { Button as
|
|
11
|
-
import { withIdHOC as
|
|
10
|
+
import { Button as N } from "../Button.mjs";
|
|
11
|
+
import { withIdHOC as K, withPropsContext as A, withUnstyledHOC as R, withZIndexContext as T, createPropsContext as L, Keys as r, dispatchEvent as d, getActiveElement as f, validatePackage as z, getLicenseMessage as U, svgIconPropType as Z, classNames as u, uDropDownButton as c, WatermarkOverlay as $, ZIndexContext as W } from "@progress/kendo-react-common";
|
|
12
12
|
import { navigate as _ } from "./utils/navigation.mjs";
|
|
13
13
|
import { DropDownButtonItem as H } from "./DropDownButtonItem.mjs";
|
|
14
14
|
import { ButtonItem as X } from "./ButtonItem.mjs";
|
|
15
15
|
import { Popup as j } from "@progress/kendo-react-popup";
|
|
16
16
|
import { getPopupAlign as q, getAnchorAlign as G } from "./utils/popup.mjs";
|
|
17
|
-
import { packageMetadata as
|
|
17
|
+
import { packageMetadata as k } from "../package-metadata.mjs";
|
|
18
18
|
const J = 12e3, Q = 2e3, m = class m extends p.Component {
|
|
19
19
|
constructor(i) {
|
|
20
20
|
super(i), this.state = {
|
|
@@ -44,8 +44,8 @@ const J = 12e3, Q = 2e3, m = class m extends p.Component {
|
|
|
44
44
|
if (this.opened) {
|
|
45
45
|
const a = _(e, t.keyCode, t.altKey, this.buttonsData.length);
|
|
46
46
|
o.focusedIndex = a;
|
|
47
|
-
const
|
|
48
|
-
!t.altKey && (
|
|
47
|
+
const h = t.keyCode === r.up || t.keyCode === r.down || t.keyCode === r.left || t.keyCode === r.right;
|
|
48
|
+
!t.altKey && (h || t.keyCode === r.home || t.keyCode === r.end) && t.preventDefault();
|
|
49
49
|
}
|
|
50
50
|
this.setState(o);
|
|
51
51
|
}, this.switchFocus = (t) => {
|
|
@@ -88,7 +88,7 @@ const J = 12e3, Q = 2e3, m = class m extends p.Component {
|
|
|
88
88
|
}), this.setOpen(e, t);
|
|
89
89
|
}, this.dispatchPopupEvent = (t, e) => {
|
|
90
90
|
d(e ? this.props.onOpen : this.props.onClose, t, this, void 0), this.openedDuringOnChange = void 0;
|
|
91
|
-
}, this.showLicenseWatermark = !z(
|
|
91
|
+
}, this.showLicenseWatermark = !z(k, { component: "DropDownButton" }), this.licenseMessage = U(k);
|
|
92
92
|
}
|
|
93
93
|
get guid() {
|
|
94
94
|
return this.props.id + "-accessibility-id";
|
|
@@ -103,46 +103,46 @@ const J = 12e3, Q = 2e3, m = class m extends p.Component {
|
|
|
103
103
|
const i = this.isRtl(), t = this.props.unstyled && this.props.unstyled.uDropDownButton, e = i ? "rtl" : void 0, {
|
|
104
104
|
id: o,
|
|
105
105
|
style: a,
|
|
106
|
-
tabIndex:
|
|
106
|
+
tabIndex: h,
|
|
107
107
|
disabled: n,
|
|
108
|
-
size:
|
|
109
|
-
rounded:
|
|
110
|
-
fillMode:
|
|
111
|
-
themeColor:
|
|
112
|
-
ariaLabel:
|
|
113
|
-
title:
|
|
114
|
-
accessKey:
|
|
115
|
-
icon:
|
|
116
|
-
svgIcon:
|
|
117
|
-
iconClass:
|
|
118
|
-
buttonClass:
|
|
108
|
+
size: I,
|
|
109
|
+
rounded: w,
|
|
110
|
+
fillMode: b,
|
|
111
|
+
themeColor: B,
|
|
112
|
+
ariaLabel: O,
|
|
113
|
+
title: x,
|
|
114
|
+
accessKey: v,
|
|
115
|
+
icon: C,
|
|
116
|
+
svgIcon: D,
|
|
117
|
+
iconClass: y,
|
|
118
|
+
buttonClass: E,
|
|
119
119
|
className: S,
|
|
120
120
|
imageUrl: P,
|
|
121
121
|
startIcon: F,
|
|
122
|
-
endIcon:
|
|
122
|
+
endIcon: M
|
|
123
123
|
} = this.props;
|
|
124
|
-
return this.buttonsData = this.props.items || p.Children.toArray(this.props.children).filter((
|
|
125
|
-
|
|
124
|
+
return this.buttonsData = this.props.items || p.Children.toArray(this.props.children).filter((l) => l && l.type === H).map((l) => l.props), /* @__PURE__ */ p.createElement(p.Fragment, null, /* @__PURE__ */ p.createElement(
|
|
125
|
+
N,
|
|
126
126
|
{
|
|
127
127
|
id: o,
|
|
128
|
-
size:
|
|
128
|
+
size: I,
|
|
129
129
|
style: a,
|
|
130
|
-
rounded:
|
|
131
|
-
fillMode:
|
|
132
|
-
themeColor:
|
|
130
|
+
rounded: w,
|
|
131
|
+
fillMode: b,
|
|
132
|
+
themeColor: B,
|
|
133
133
|
onClick: this.onClickMainButton,
|
|
134
134
|
onMouseDown: this.mouseDown,
|
|
135
135
|
onKeyDown: this.onKeyDown,
|
|
136
136
|
onFocus: this.handleFocus,
|
|
137
137
|
onBlur: this.handleButtonBlur,
|
|
138
138
|
"aria-disabled": n ? "true" : void 0,
|
|
139
|
-
tabIndex:
|
|
140
|
-
accessKey:
|
|
141
|
-
icon:
|
|
142
|
-
svgIcon:
|
|
143
|
-
iconClass:
|
|
139
|
+
tabIndex: h,
|
|
140
|
+
accessKey: v,
|
|
141
|
+
icon: C,
|
|
142
|
+
svgIcon: D,
|
|
143
|
+
iconClass: y,
|
|
144
144
|
className: u(
|
|
145
|
-
|
|
145
|
+
E,
|
|
146
146
|
S,
|
|
147
147
|
c.wrapper({
|
|
148
148
|
c: t,
|
|
@@ -152,16 +152,16 @@ const J = 12e3, Q = 2e3, m = class m extends p.Component {
|
|
|
152
152
|
),
|
|
153
153
|
imageUrl: P,
|
|
154
154
|
dir: e,
|
|
155
|
-
ref: (
|
|
156
|
-
this.mainButton = (
|
|
155
|
+
ref: (l) => {
|
|
156
|
+
this.mainButton = (l == null ? void 0 : l.element) || null;
|
|
157
157
|
},
|
|
158
158
|
type: "button",
|
|
159
159
|
"aria-expanded": this.opened ? "true" : "false",
|
|
160
|
-
"aria-label":
|
|
160
|
+
"aria-label": O || (D || C || y ? "Menu" : void 0),
|
|
161
161
|
"aria-controls": this.opened ? this.guid : void 0,
|
|
162
|
-
title:
|
|
162
|
+
title: x,
|
|
163
163
|
startIcon: F,
|
|
164
|
-
endIcon:
|
|
164
|
+
endIcon: M
|
|
165
165
|
},
|
|
166
166
|
this.props.text
|
|
167
167
|
), this.showLicenseWatermark && /* @__PURE__ */ p.createElement($, { message: this.licenseMessage }), this.renderPopup(i));
|
|
@@ -185,14 +185,14 @@ const J = 12e3, Q = 2e3, m = class m extends p.Component {
|
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
187
|
renderPopup(i) {
|
|
188
|
-
const { popupSettings: t = {}, _zIndex: e, unstyled: o } = this.props, a = e ? e + Q : J,
|
|
188
|
+
const { popupSettings: t = {}, _zIndex: e, unstyled: o } = this.props, a = e ? e + Q : J, h = o && o.uDropDownButton, { focusedIndex: n } = this.state;
|
|
189
189
|
return /* @__PURE__ */ p.createElement(W.Provider, { value: a }, /* @__PURE__ */ p.createElement(
|
|
190
190
|
j,
|
|
191
191
|
{
|
|
192
192
|
anchor: this.mainButton,
|
|
193
193
|
show: this.opened,
|
|
194
194
|
animate: t.animate,
|
|
195
|
-
popupClass: u(c.popup({ c:
|
|
195
|
+
popupClass: u(c.popup({ c: h }), t.popupClass),
|
|
196
196
|
anchorAlign: t.anchorAlign || G(i),
|
|
197
197
|
popupAlign: t.popupAlign || q(i),
|
|
198
198
|
style: i ? { direction: "rtl" } : void 0,
|
|
@@ -201,7 +201,7 @@ const J = 12e3, Q = 2e3, m = class m extends p.Component {
|
|
|
201
201
|
/* @__PURE__ */ p.createElement(
|
|
202
202
|
"ul",
|
|
203
203
|
{
|
|
204
|
-
role: "
|
|
204
|
+
role: "menu",
|
|
205
205
|
id: this.guid,
|
|
206
206
|
tabIndex: -1,
|
|
207
207
|
"aria-activedescendant": n >= 0 ? `${this.guid}-${n}` : void 0,
|
|
@@ -210,7 +210,7 @@ const J = 12e3, Q = 2e3, m = class m extends p.Component {
|
|
|
210
210
|
onBlur: this.handleMenuBlur,
|
|
211
211
|
className: u(
|
|
212
212
|
c.ul({
|
|
213
|
-
c:
|
|
213
|
+
c: h,
|
|
214
214
|
size: this.props.size
|
|
215
215
|
})
|
|
216
216
|
)
|
|
@@ -221,18 +221,18 @@ const J = 12e3, Q = 2e3, m = class m extends p.Component {
|
|
|
221
221
|
}
|
|
222
222
|
renderChildItems() {
|
|
223
223
|
const { item: i, itemRender: t, textField: e, unstyled: o } = this.props, a = o && o.uDropDownButton;
|
|
224
|
-
return this.buttonsData.length > 0 ? this.buttonsData.map((
|
|
224
|
+
return this.buttonsData.length > 0 ? this.buttonsData.map((h, n) => /* @__PURE__ */ p.createElement(
|
|
225
225
|
X,
|
|
226
226
|
{
|
|
227
227
|
className: u(
|
|
228
228
|
c.item({
|
|
229
229
|
c: a
|
|
230
230
|
}),
|
|
231
|
-
|
|
231
|
+
h.className,
|
|
232
232
|
{ "k-first": n === 0 },
|
|
233
233
|
{ "k-last": n === this.buttonsData.length - 1 }
|
|
234
234
|
),
|
|
235
|
-
dataItem:
|
|
235
|
+
dataItem: h,
|
|
236
236
|
textField: e,
|
|
237
237
|
focused: this.state.focusedIndex === n,
|
|
238
238
|
onClick: this.onItemClick,
|
|
@@ -288,8 +288,6 @@ m.propTypes = {
|
|
|
288
288
|
"success",
|
|
289
289
|
"warning",
|
|
290
290
|
"error",
|
|
291
|
-
"dark",
|
|
292
|
-
"light",
|
|
293
291
|
"inverse"
|
|
294
292
|
])
|
|
295
293
|
}, m.defaultProps = {
|
|
@@ -299,7 +297,7 @@ m.propTypes = {
|
|
|
299
297
|
themeColor: void 0
|
|
300
298
|
};
|
|
301
299
|
let g = m;
|
|
302
|
-
const V = L(), Y =
|
|
300
|
+
const V = L(), Y = K(
|
|
303
301
|
A(
|
|
304
302
|
V,
|
|
305
303
|
R(T(g))
|
|
@@ -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 b=require("react"),i=require("prop-types"),f=require("../Button.js"),s=require("@progress/kendo-react-common"),D=require("./ButtonItem.js"),I=require("./SplitButtonItem.js"),w=require("./utils/navigation.js"),v=require("@progress/kendo-react-popup"),y=require("@progress/kendo-react-intl"),g=require("./utils/popup.js"),k=require("../package-metadata.js"),m=require("../messages/index.js"),S=require("@progress/kendo-svg-icons");function O(l){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const e in l)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(l,e);Object.defineProperty(o,e,t.get?t:{enumerable:!0,get:()=>l[e]})}}return o.default=l,Object.freeze(o)}const p=O(b),d=class d extends p.Component{constructor(o){super(o),this.state={focused:!1,focusedIndex:-1,opened:!1},this.wrapper=null,this.mainButton=null,this.list=null,this.skipFocus=!1,this.buttonsData=[],this.showLicenseWatermark=!1,this.onKeyDown=e=>{const{focusedIndex:t}=this.state;if(e.altKey){!this.opened&&e.keyCode===s.Keys.down?(e.preventDefault(),this.setState({focusedIndex:0}),this.setOpen(!0,e)):this.opened&&e.keyCode===s.Keys.up&&(e.preventDefault(),this.setState({focusedIndex:-1}),this.setOpen(!1,e));return}let n;if(e.keyCode===s.Keys.enter||e.keyCode===s.Keys.space){if(e.preventDefault(),this.dispatchClickEvent(e,t),t>=0){n={focusedIndex:this.opened?-1:0};const r=!this.opened;this.setOpen(r,e)}}else if(this.opened&&e.keyCode===s.Keys.esc){this.setState({focusedIndex:-1}),this.setOpen(!1,e);return}if(this.opened){const r=w.navigate(t,e.keyCode,e.altKey,this.buttonsData.length);r!==t&&(n=n||{},n.focusedIndex=r);const c=e.keyCode===s.Keys.up||e.keyCode===s.Keys.down||e.keyCode===s.Keys.left||e.keyCode===s.Keys.right;!e.altKey&&(c||e.keyCode===s.Keys.home||e.keyCode===s.Keys.end)&&e.preventDefault()}n&&this.setState(n)},this.switchFocus=e=>{this.skipFocus=!0,e(),window.setTimeout(()=>this.skipFocus=!1,0)},this.onFocus=e=>{this.skipFocus||(s.dispatchEvent(this.props.onFocus,e,this,void 0),this.setState({focused:!0}))},this.setOpen=(e,t)=>{this.opened!==e&&(this.openedDuringOnChange=e,this.setState({opened:e}),t?this.dispatchPopupEvent(t,e):this.openedDuringOnChange=void 0)},this.onItemClick=(e,t)=>{this.opened&&this.setState({focusedIndex:0}),this.dispatchClickEvent(e,t),this.setOpen(!1,e)},this.onBlur=e=>{this.skipFocus||(this.setState({focused:!1,focusedIndex:-1}),s.dispatchEvent(this.props.onBlur,e,this,void 0),setTimeout(()=>{this.setOpen(!1,e)},0))},this.onPopupClose=e=>{var n;const t=s.getActiveElement(document);this.element&&this.element.removeAttribute("tabindex"),(t===this.list||(n=this.list)!=null&&n.contains(t))&&this.switchFocus(()=>{this.element&&this.element.focus({preventScroll:!0})}),this.props.popupSettings&&this.props.popupSettings.onClose&&this.props.popupSettings.onClose.call(void 0,e)},this.listRef=e=>{this.list=e,e&&this.state.focused&&this.switchFocus(()=>{e.focus({preventScroll:!0}),this.element&&(this.element.tabIndex=-1)})},this.onSplitPartClick=e=>{if(this.buttonsData.length){const t=!this.opened;this.setState({focusedIndex:t?0:-1,focused:!0}),this.setOpen(t,e)}},this.onDownSplitPart=e=>{e.preventDefault();const t=s.getActiveElement(document);this.element&&t!==this.element&&t!==this.list&&this.element.focus()},this.onItemDown=e=>{s.getActiveElement(document)===this.list&&e.preventDefault()},this.dispatchPopupEvent=(e,t)=>{s.dispatchEvent(t?this.props.onOpen:this.props.onClose,e,this,void 0),this.openedDuringOnChange=void 0},this.showLicenseWatermark=!s.validatePackage(k.packageMetadata,{component:"SplitButton"}),this.licenseMessage=s.getLicenseMessage(k.packageMetadata)}get guid(){return this.props.id?this.props.id+"-accessibility-id":this.props.id}get opened(){return this.openedDuringOnChange!==void 0?this.openedDuringOnChange:this.props.opened===void 0?this.state.opened:this.props.opened}render(){this.buttonsData=this.props.items||p.Children.toArray(this.props.children).filter(a=>a&&a.type===I.SplitButtonItem).map(a=>a.props);const o=this.isRtl(),e=o?"rtl":void 0,n=y.provideLocalizationService(this).toLanguageString(m.splitButtonToggleDropdown,m.messages[m.splitButtonToggleDropdown]),{id:r,style:c,tabIndex:C,disabled:u}=this.props;return p.createElement(p.Fragment,null,p.createElement("div",{id:r,style:c,className:s.classNames("k-split-button","k-button-group",{"k-focus":this.state.focused},this.props.rounded&&`k-rounded-${s.kendoThemeMaps.roundedMap[this.props.rounded]}`,this.props.className),onKeyDown:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur,dir:e,ref:a=>{this.wrapper=a}},p.createElement(f.Button,{ref:a=>{this.mainButton=a&&a.element},type:"button",size:this.props.size,rounded:this.props.rounded,fillMode:this.props.fillMode,themeColor:this.props.themeColor,onClick:a=>this.onItemClick(a,-1),disabled:u||void 0,tabIndex:C,accessKey:this.props.accessKey,className:this.props.buttonClass,icon:this.props.icon,svgIcon:this.props.svgIcon,iconClass:this.props.iconClass,startIcon:this.props.startIcon,endIcon:this.props.endIcon,imageUrl:this.props.imageUrl,dir:e,"aria-disabled":u,"aria-label":this.props.ariaLabel,id:"button-"+this.guid,title:this.props.title},this.props.text),p.createElement(f.Button,{type:"button",size:this.props.size,rounded:this.props.rounded,fillMode:this.props.fillMode,themeColor:this.props.themeColor,icon:"chevron-down",svgIcon:S.chevronDownIcon,className:"k-split-button-arrow",disabled:u||void 0,tabIndex:-1,onClick:this.onSplitPartClick,onMouseDown:this.onDownSplitPart,onPointerDown:this.onDownSplitPart,dir:e,"aria-label":n,"aria-expanded":this.opened?"true":"false","aria-controls":this.opened?this.guid:void 0}),this.renderPopup(o)),this.showLicenseWatermark&&p.createElement(s.WatermarkOverlay,{message:this.licenseMessage}))}componentDidMount(){(this.props.dir===void 0&&this.isRtl()||this.opened)&&this.forceUpdate()}get element(){return this.mainButton}dispatchClickEvent(o,e){this.isItemDisabled(e)||(e===-1?s.dispatchEvent(this.props.onButtonClick,o,this,void 0):s.dispatchEvent(this.props.onItemClick,o,this,{item:this.buttonsData[e],itemIndex:e}))}renderPopup(o){const{popupSettings:e={}}=this.props,{focusedIndex:t}=this.state;return p.createElement(v.Popup,{anchor:this.wrapper,show:this.opened,animate:e.animate,popupClass:s.classNames("k-menu-popup",e.popupClass),anchorAlign:e.anchorAlign||g.getAnchorAlign(o),popupAlign:e.popupAlign||g.getPopupAlign(o),style:o?{direction:"rtl"}:void 0,onClose:this.onPopupClose},p.createElement("ul",{role:"menu",id:this.guid,tabIndex:-1,ref:this.listRef,"aria-activedescendant":t>=0?`${this.guid}-${t}`:void 0,className:s.classNames("k-menu-group",{[`k-menu-group-${s.kendoThemeMaps.sizeMap[this.props.size]||this.props.size}`]:this.props.size})},this.renderChildItems()))}renderChildItems(){const{item:o,itemRender:e,textField:t}=this.props;return this.buttonsData.length>0?this.buttonsData.map((n,r)=>p.createElement(D.ButtonItem,{className:s.classNames("k-menu-item",{"k-first":r===0},{"k-last":r===this.buttonsData.length-1}),dataItem:n,textField:t,focused:this.state.focusedIndex===r,onClick:this.onItemClick,onDown:this.onItemDown,render:e,item:o,key:r,index:r,id:`${this.guid}-${r}`})):null}isItemDisabled(o){return this.buttonsData[o]?this.buttonsData[o].disabled:this.props.disabled}isRtl(){return this.props.dir!==void 0?this.props.dir==="rtl":!!this.wrapper&&getComputedStyle(this.wrapper).direction==="rtl"}};d.propTypes={accessKey:i.string,ariaLabel:i.string,title:i.string,onButtonClick:i.func,onFocus:i.func,onBlur:i.func,onItemClick:i.func,onOpen:i.func,onClose:i.func,text:i.string,items:i.arrayOf(i.any),textField:i.string,tabIndex:i.number,disabled:i.bool,icon:i.string,svgIcon:s.svgIconPropType,imageUrl:i.string,popupSettings:i.object,itemRender:i.any,item:i.func,className:i.string,buttonClass:i.string,dir:i.string,size:i.oneOf(["small","medium","large"]),rounded:i.oneOf(["small","medium","large","full","none"]),fillMode:i.oneOf(["flat","link","outline","solid","clear"]),themeColor:i.oneOf(["base","primary","secondary","tertiary","info","success","warning","error","inverse"])},d.defaultProps={size:void 0,rounded:void 0,fillMode:void 0,themeColor:void 0};let h=d;y.registerForLocalization(h);exports.SplitButton=h;
|
|
@@ -7,16 +7,18 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as p from "react";
|
|
9
9
|
import s from "prop-types";
|
|
10
|
-
import { Button as
|
|
11
|
-
import { Keys as a, dispatchEvent as
|
|
12
|
-
import { ButtonItem as
|
|
13
|
-
import { SplitButtonItem as
|
|
14
|
-
import { navigate as
|
|
15
|
-
import { Popup as
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
10
|
+
import { Button as g } from "../Button.mjs";
|
|
11
|
+
import { Keys as a, dispatchEvent as h, getActiveElement as m, validatePackage as D, getLicenseMessage as w, svgIconPropType as I, classNames as l, kendoThemeMaps as C, WatermarkOverlay as v } from "@progress/kendo-react-common";
|
|
12
|
+
import { ButtonItem as S } from "./ButtonItem.mjs";
|
|
13
|
+
import { SplitButtonItem as O } from "./SplitButtonItem.mjs";
|
|
14
|
+
import { navigate as E } from "./utils/navigation.mjs";
|
|
15
|
+
import { Popup as F } from "@progress/kendo-react-popup";
|
|
16
|
+
import { provideLocalizationService as P, registerForLocalization as x } from "@progress/kendo-react-intl";
|
|
17
|
+
import { getPopupAlign as M, getAnchorAlign as z } from "./utils/popup.mjs";
|
|
18
|
+
import { packageMetadata as k } from "../package-metadata.mjs";
|
|
19
|
+
import { splitButtonToggleDropdown as b, messages as B } from "../messages/index.mjs";
|
|
20
|
+
import { chevronDownIcon as A } from "@progress/kendo-svg-icons";
|
|
21
|
+
const d = class d extends p.Component {
|
|
20
22
|
constructor(i) {
|
|
21
23
|
super(i), this.state = {
|
|
22
24
|
focused: !1,
|
|
@@ -42,16 +44,16 @@ const u = class u extends p.Component {
|
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
46
|
if (this.opened) {
|
|
45
|
-
const n =
|
|
47
|
+
const n = E(e, t.keyCode, t.altKey, this.buttonsData.length);
|
|
46
48
|
n !== e && (o = o || {}, o.focusedIndex = n);
|
|
47
|
-
const
|
|
48
|
-
!t.altKey && (
|
|
49
|
+
const u = t.keyCode === a.up || t.keyCode === a.down || t.keyCode === a.left || t.keyCode === a.right;
|
|
50
|
+
!t.altKey && (u || t.keyCode === a.home || t.keyCode === a.end) && t.preventDefault();
|
|
49
51
|
}
|
|
50
52
|
o && this.setState(o);
|
|
51
53
|
}, this.switchFocus = (t) => {
|
|
52
54
|
this.skipFocus = !0, t(), window.setTimeout(() => this.skipFocus = !1, 0);
|
|
53
55
|
}, this.onFocus = (t) => {
|
|
54
|
-
this.skipFocus || (
|
|
56
|
+
this.skipFocus || (h(this.props.onFocus, t, this, void 0), this.setState({ focused: !0 }));
|
|
55
57
|
}, this.setOpen = (t, e) => {
|
|
56
58
|
this.opened !== t && (this.openedDuringOnChange = t, this.setState({ opened: t }), e ? this.dispatchPopupEvent(e, t) : this.openedDuringOnChange = void 0);
|
|
57
59
|
}, this.onItemClick = (t, e) => {
|
|
@@ -60,12 +62,12 @@ const u = class u extends p.Component {
|
|
|
60
62
|
this.skipFocus || (this.setState({
|
|
61
63
|
focused: !1,
|
|
62
64
|
focusedIndex: -1
|
|
63
|
-
}),
|
|
65
|
+
}), h(this.props.onBlur, t, this, void 0), setTimeout(() => {
|
|
64
66
|
this.setOpen(!1, t);
|
|
65
67
|
}, 0));
|
|
66
68
|
}, this.onPopupClose = (t) => {
|
|
67
69
|
var o;
|
|
68
|
-
const e =
|
|
70
|
+
const e = m(document);
|
|
69
71
|
this.element && this.element.removeAttribute("tabindex"), (e === this.list || (o = this.list) != null && o.contains(e)) && this.switchFocus(() => {
|
|
70
72
|
this.element && this.element.focus({ preventScroll: !0 });
|
|
71
73
|
}), this.props.popupSettings && this.props.popupSettings.onClose && this.props.popupSettings.onClose.call(void 0, t);
|
|
@@ -83,13 +85,13 @@ const u = class u extends p.Component {
|
|
|
83
85
|
}
|
|
84
86
|
}, this.onDownSplitPart = (t) => {
|
|
85
87
|
t.preventDefault();
|
|
86
|
-
const e =
|
|
88
|
+
const e = m(document);
|
|
87
89
|
this.element && e !== this.element && e !== this.list && this.element.focus();
|
|
88
90
|
}, this.onItemDown = (t) => {
|
|
89
|
-
|
|
91
|
+
m(document) === this.list && t.preventDefault();
|
|
90
92
|
}, this.dispatchPopupEvent = (t, e) => {
|
|
91
|
-
|
|
92
|
-
}, this.showLicenseWatermark = !k
|
|
93
|
+
h(e ? this.props.onOpen : this.props.onClose, t, this, void 0), this.openedDuringOnChange = void 0;
|
|
94
|
+
}, this.showLicenseWatermark = !D(k, { component: "SplitButton" }), this.licenseMessage = w(k);
|
|
93
95
|
}
|
|
94
96
|
get guid() {
|
|
95
97
|
return this.props.id ? this.props.id + "-accessibility-id" : this.props.id;
|
|
@@ -101,20 +103,23 @@ const u = class u extends p.Component {
|
|
|
101
103
|
* @hidden
|
|
102
104
|
*/
|
|
103
105
|
render() {
|
|
104
|
-
this.buttonsData = this.props.items || p.Children.toArray(this.props.children).filter((r) => r && r.type ===
|
|
105
|
-
const i = this.isRtl(), t = i ? "rtl" : void 0,
|
|
106
|
+
this.buttonsData = this.props.items || p.Children.toArray(this.props.children).filter((r) => r && r.type === O).map((r) => r.props);
|
|
107
|
+
const i = this.isRtl(), t = i ? "rtl" : void 0, o = P(this).toLanguageString(
|
|
108
|
+
b,
|
|
109
|
+
B[b]
|
|
110
|
+
), { id: n, style: u, tabIndex: y, disabled: c } = this.props;
|
|
106
111
|
return /* @__PURE__ */ p.createElement(p.Fragment, null, /* @__PURE__ */ p.createElement(
|
|
107
112
|
"div",
|
|
108
113
|
{
|
|
109
|
-
id:
|
|
110
|
-
style:
|
|
111
|
-
className:
|
|
114
|
+
id: n,
|
|
115
|
+
style: u,
|
|
116
|
+
className: l(
|
|
112
117
|
"k-split-button",
|
|
113
118
|
"k-button-group",
|
|
114
119
|
{
|
|
115
120
|
"k-focus": this.state.focused
|
|
116
121
|
},
|
|
117
|
-
this.props.rounded && `k-rounded-${
|
|
122
|
+
this.props.rounded && `k-rounded-${C.roundedMap[this.props.rounded]}`,
|
|
118
123
|
this.props.className
|
|
119
124
|
),
|
|
120
125
|
onKeyDown: this.onKeyDown,
|
|
@@ -126,7 +131,7 @@ const u = class u extends p.Component {
|
|
|
126
131
|
}
|
|
127
132
|
},
|
|
128
133
|
/* @__PURE__ */ p.createElement(
|
|
129
|
-
|
|
134
|
+
g,
|
|
130
135
|
{
|
|
131
136
|
ref: (r) => {
|
|
132
137
|
this.mainButton = r && r.element;
|
|
@@ -137,8 +142,8 @@ const u = class u extends p.Component {
|
|
|
137
142
|
fillMode: this.props.fillMode,
|
|
138
143
|
themeColor: this.props.themeColor,
|
|
139
144
|
onClick: (r) => this.onItemClick(r, -1),
|
|
140
|
-
disabled:
|
|
141
|
-
tabIndex:
|
|
145
|
+
disabled: c || void 0,
|
|
146
|
+
tabIndex: y,
|
|
142
147
|
accessKey: this.props.accessKey,
|
|
143
148
|
className: this.props.buttonClass,
|
|
144
149
|
icon: this.props.icon,
|
|
@@ -148,38 +153,37 @@ const u = class u extends p.Component {
|
|
|
148
153
|
endIcon: this.props.endIcon,
|
|
149
154
|
imageUrl: this.props.imageUrl,
|
|
150
155
|
dir: t,
|
|
151
|
-
"aria-disabled":
|
|
152
|
-
"aria-haspopup": !0,
|
|
153
|
-
"aria-expanded": this.opened || void 0,
|
|
156
|
+
"aria-disabled": c,
|
|
154
157
|
"aria-label": this.props.ariaLabel,
|
|
155
|
-
"aria-controls": this.opened ? this.guid : void 0,
|
|
156
158
|
id: "button-" + this.guid,
|
|
157
159
|
title: this.props.title
|
|
158
160
|
},
|
|
159
161
|
this.props.text
|
|
160
162
|
),
|
|
161
163
|
/* @__PURE__ */ p.createElement(
|
|
162
|
-
|
|
164
|
+
g,
|
|
163
165
|
{
|
|
164
166
|
type: "button",
|
|
165
167
|
size: this.props.size,
|
|
166
168
|
rounded: this.props.rounded,
|
|
167
169
|
fillMode: this.props.fillMode,
|
|
168
170
|
themeColor: this.props.themeColor,
|
|
169
|
-
icon: "
|
|
170
|
-
svgIcon:
|
|
171
|
+
icon: "chevron-down",
|
|
172
|
+
svgIcon: A,
|
|
171
173
|
className: "k-split-button-arrow",
|
|
172
|
-
disabled:
|
|
174
|
+
disabled: c || void 0,
|
|
173
175
|
tabIndex: -1,
|
|
174
176
|
onClick: this.onSplitPartClick,
|
|
175
177
|
onMouseDown: this.onDownSplitPart,
|
|
176
178
|
onPointerDown: this.onDownSplitPart,
|
|
177
179
|
dir: t,
|
|
178
|
-
"aria-label":
|
|
180
|
+
"aria-label": o,
|
|
181
|
+
"aria-expanded": this.opened ? "true" : "false",
|
|
182
|
+
"aria-controls": this.opened ? this.guid : void 0
|
|
179
183
|
}
|
|
180
184
|
),
|
|
181
185
|
this.renderPopup(i)
|
|
182
|
-
), this.showLicenseWatermark && /* @__PURE__ */ p.createElement(
|
|
186
|
+
), this.showLicenseWatermark && /* @__PURE__ */ p.createElement(v, { message: this.licenseMessage }));
|
|
183
187
|
}
|
|
184
188
|
/**
|
|
185
189
|
* @hidden
|
|
@@ -194,7 +198,7 @@ const u = class u extends p.Component {
|
|
|
194
198
|
return this.mainButton;
|
|
195
199
|
}
|
|
196
200
|
dispatchClickEvent(i, t) {
|
|
197
|
-
this.isItemDisabled(t) || (t === -1 ?
|
|
201
|
+
this.isItemDisabled(t) || (t === -1 ? h(this.props.onButtonClick, i, this, void 0) : h(this.props.onItemClick, i, this, {
|
|
198
202
|
item: this.buttonsData[t],
|
|
199
203
|
itemIndex: t
|
|
200
204
|
}));
|
|
@@ -202,14 +206,14 @@ const u = class u extends p.Component {
|
|
|
202
206
|
renderPopup(i) {
|
|
203
207
|
const { popupSettings: t = {} } = this.props, { focusedIndex: e } = this.state;
|
|
204
208
|
return /* @__PURE__ */ p.createElement(
|
|
205
|
-
|
|
209
|
+
F,
|
|
206
210
|
{
|
|
207
211
|
anchor: this.wrapper,
|
|
208
212
|
show: this.opened,
|
|
209
213
|
animate: t.animate,
|
|
210
|
-
popupClass:
|
|
211
|
-
anchorAlign: t.anchorAlign ||
|
|
212
|
-
popupAlign: t.popupAlign ||
|
|
214
|
+
popupClass: l("k-menu-popup", t.popupClass),
|
|
215
|
+
anchorAlign: t.anchorAlign || z(i),
|
|
216
|
+
popupAlign: t.popupAlign || M(i),
|
|
213
217
|
style: i ? { direction: "rtl" } : void 0,
|
|
214
218
|
onClose: this.onPopupClose
|
|
215
219
|
},
|
|
@@ -218,12 +222,11 @@ const u = class u extends p.Component {
|
|
|
218
222
|
{
|
|
219
223
|
role: "menu",
|
|
220
224
|
id: this.guid,
|
|
221
|
-
"aria-labelledby": "button-" + this.guid,
|
|
222
225
|
tabIndex: -1,
|
|
223
226
|
ref: this.listRef,
|
|
224
227
|
"aria-activedescendant": e >= 0 ? `${this.guid}-${e}` : void 0,
|
|
225
|
-
className:
|
|
226
|
-
[`k-menu-group-${
|
|
228
|
+
className: l("k-menu-group", {
|
|
229
|
+
[`k-menu-group-${C.sizeMap[this.props.size] || this.props.size}`]: this.props.size
|
|
227
230
|
})
|
|
228
231
|
},
|
|
229
232
|
this.renderChildItems()
|
|
@@ -233,9 +236,9 @@ const u = class u extends p.Component {
|
|
|
233
236
|
renderChildItems() {
|
|
234
237
|
const { item: i, itemRender: t, textField: e } = this.props;
|
|
235
238
|
return this.buttonsData.length > 0 ? this.buttonsData.map((o, n) => /* @__PURE__ */ p.createElement(
|
|
236
|
-
|
|
239
|
+
S,
|
|
237
240
|
{
|
|
238
|
-
className:
|
|
241
|
+
className: l(
|
|
239
242
|
"k-menu-item",
|
|
240
243
|
{ "k-first": n === 0 },
|
|
241
244
|
{ "k-last": n === this.buttonsData.length - 1 }
|
|
@@ -260,7 +263,7 @@ const u = class u extends p.Component {
|
|
|
260
263
|
return this.props.dir !== void 0 ? this.props.dir === "rtl" : !!this.wrapper && getComputedStyle(this.wrapper).direction === "rtl";
|
|
261
264
|
}
|
|
262
265
|
};
|
|
263
|
-
|
|
266
|
+
d.propTypes = {
|
|
264
267
|
accessKey: s.string,
|
|
265
268
|
ariaLabel: s.string,
|
|
266
269
|
title: s.string,
|
|
@@ -276,7 +279,7 @@ u.propTypes = {
|
|
|
276
279
|
tabIndex: s.number,
|
|
277
280
|
disabled: s.bool,
|
|
278
281
|
icon: s.string,
|
|
279
|
-
svgIcon:
|
|
282
|
+
svgIcon: I,
|
|
280
283
|
imageUrl: s.string,
|
|
281
284
|
popupSettings: s.object,
|
|
282
285
|
itemRender: s.any,
|
|
@@ -296,17 +299,16 @@ u.propTypes = {
|
|
|
296
299
|
"success",
|
|
297
300
|
"warning",
|
|
298
301
|
"error",
|
|
299
|
-
"dark",
|
|
300
|
-
"light",
|
|
301
302
|
"inverse"
|
|
302
303
|
])
|
|
303
|
-
},
|
|
304
|
+
}, d.defaultProps = {
|
|
304
305
|
size: void 0,
|
|
305
306
|
rounded: void 0,
|
|
306
307
|
fillMode: void 0,
|
|
307
308
|
themeColor: void 0
|
|
308
309
|
};
|
|
309
|
-
let
|
|
310
|
+
let f = d;
|
|
311
|
+
x(f);
|
|
310
312
|
export {
|
|
311
|
-
|
|
313
|
+
f as SplitButton
|
|
312
314
|
};
|
|
@@ -212,7 +212,7 @@ export interface DropDownButtonProps extends KendoReactComponentBaseProps {
|
|
|
212
212
|
* <DropDownButton themeColor="primary" text="Actions" />
|
|
213
213
|
* ```
|
|
214
214
|
*/
|
|
215
|
-
themeColor?: 'base' | 'primary' | 'secondary' | 'tertiary' | 'info' | 'success' | 'warning' | 'error' | '
|
|
215
|
+
themeColor?: 'base' | 'primary' | 'secondary' | 'tertiary' | 'info' | 'success' | 'warning' | 'error' | 'inverse';
|
|
216
216
|
/**
|
|
217
217
|
* Sets an SVG icon or custom element before the content of the DropDownButton. For the custom component, we recommend using [Phrasing content](https://developer.mozilla.org/en-US/docs/Web/HTML/Content_categories#phrasing_content)
|
|
218
218
|
* but there must be no [Interactive content](https://developer.mozilla.org/en-US/docs/Web/HTML/Content_categories#interactive_content).
|
|
@@ -427,5 +427,5 @@ export interface SplitButtonProps extends KendoReactComponentBaseProps {
|
|
|
427
427
|
* <SplitButton themeColor="primary" text="Actions" />
|
|
428
428
|
* ```
|
|
429
429
|
*/
|
|
430
|
-
themeColor?: 'base' | 'primary' | 'secondary' | 'tertiary' | 'info' | 'success' | 'warning' | 'error' | '
|
|
430
|
+
themeColor?: 'base' | 'primary' | 'secondary' | 'tertiary' | 'info' | 'success' | 'warning' | 'error' | 'inverse';
|
|
431
431
|
}
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://www.telerik.com/kendo-react-ui/components/free?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-buttons&utm_content=banner)
|
|
1
|
+
[](https://www.telerik.com/kendo-react-ui/components/getting-started/free-vs-premium?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-buttons&utm_content=banner)
|
|
2
2
|
|
|
3
3
|
# KendoReact Buttons Library for React
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
>
|
|
7
7
|
> - This package is а part of [KendoReact](https://www.telerik.com/kendo-react-ui?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-buttons)—an enterprise-grade UI library with 120+ free and premium components.
|
|
8
8
|
> - It contains both free and premium KendoReact components and tools. To use the premium components, you must install a license key file, whether you are on a paid license or a 30-day free trial. To receive a license key, either [purchase a license](https://www.telerik.com/kendo-react-ui/pricing) or start a [free trial](https://www.telerik.com/download-login-v2-kendo-react-ui). You can use the free components without having to sign up or get a license key.
|
|
9
|
-
> - If you're looking for free React components, check out [Get Started with KendoReact Free](https://www.telerik.com/kendo-react-ui/components/
|
|
9
|
+
> - If you're looking for free React components, check out [Get Started with KendoReact Free](https://www.telerik.com/kendo-react-ui/components/getting-started).
|
|
10
10
|
> - If you have an active license, visit the [KendoReact My License page](https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-buttons) to learn how to configure your KendoReact licensing.
|
|
11
11
|
> - Installing and working with this package indicates that you [accept the KendoReact License Agreement](https://www.telerik.com/purchase/license-agreement/progress-kendoreact?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-buttons).
|
|
12
12
|
> - The 30-day free trial gives you access to all KendoReact components and their full functionality. Additionally, for the period of your trial, you can use our legendary technical support provided directly by the KendoReact dev team!
|
|
@@ -279,7 +279,7 @@ import { Toolbar, Button, ButtonGroup } from '@progress/kendo-react-buttons'; //
|
|
|
279
279
|
|
|
280
280
|
The following table outlines the key resources available with KendoReact and KendoReact Free.
|
|
281
281
|
|
|
282
|
-
| | [KendoReact Free](https://www.telerik.com/kendo-react-ui/components/free)
|
|
282
|
+
| | [KendoReact Free](https://www.telerik.com/kendo-react-ui/components/getting-started/free-vs-premium) | [KendoReact](https://www.telerik.com/kendo-react-ui) |
|
|
283
283
|
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
284
284
|
| React components | 50+ | 120+ |
|
|
285
285
|
| Four professional themes | <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" stroke="white" stroke-width="2"/></svg> | <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" stroke="white" stroke-width="2"/></svg> |
|
|
@@ -302,7 +302,7 @@ For any issues you might encounter while working with the KendoReact Buttons, us
|
|
|
302
302
|
## Resources
|
|
303
303
|
|
|
304
304
|
- [Getting Started with KendoReact](https://www.telerik.com/kendo-react-ui/components/getting-started/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-buttons)
|
|
305
|
-
- [Get Started with KendoReact Free](https://www.telerik.com/kendo-react-ui/components/
|
|
305
|
+
- [Get Started with KendoReact Free](https://www.telerik.com/kendo-react-ui/components/getting-started)
|
|
306
306
|
- [Getting Started with the KendoReact Buttons](https://www.telerik.com/kendo-react-ui/components/buttons/get-started/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-buttons)
|
|
307
307
|
- [API Reference of the KendoReact Buttons](https://www.telerik.com/kendo-react-ui/components/buttons/api/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-buttons)
|
|
308
308
|
- [KendoReact Roadmap](https://www.telerik.com/support/whats-new/kendo-react-ui/roadmap?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-buttons)
|
|
@@ -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 F=require("react"),m=require("@progress/kendo-react-common");function H(c){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const l in c)if(l!=="default"){const a=Object.getOwnPropertyDescriptor(c,l);Object.defineProperty(u,l,a.get?a:{enumerable:!0,get:()=>c[l]})}}return u.default=c,Object.freeze(u)}const n=H(F),R=n.forwardRef((c,u)=>{const{items:l=[],size:a,layoutMode:O="compact",value:d,onChange:b,itemTemplate:
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("react"),m=require("@progress/kendo-react-common");function H(c){const u=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const l in c)if(l!=="default"){const a=Object.getOwnPropertyDescriptor(c,l);Object.defineProperty(u,l,a.get?a:{enumerable:!0,get:()=>c[l]})}}return u.default=c,Object.freeze(u)}const n=H(F),R=n.forwardRef((c,u)=>{const{items:l=[],size:a,layoutMode:O="compact",value:d,onChange:b,itemTemplate:V,defaultValue:z,className:E,...I}=c,S=a?m.kendoThemeMaps.sizeMap[a]:void 0,k=n.useRef(null),N=n.useRef(null),[v,j]=n.useState({selectedValue:z,focusedValue:void 0}),h=d!=null?d:v.selectedValue,w=v.focusedValue,o=n.useCallback(()=>{const e=k.current,t=N.current;if(!e||!t)return;const s=e.querySelector(".k-segmented-control-button.k-selected");if(!s)return;const r=e.offsetWidth,{offsetWidth:p,offsetLeft:f}=s,g=`${f}px`,y=`${r-f-p}px`;t.style.left!==g&&(t.style.left=g),t.style.right!==y&&(t.style.right=y)},[]),i=e=>{j(t=>({...t,...e}))},T=n.useCallback(e=>t=>{var s,r;if(h===e.value){(s=e.onClick)==null||s.call(e,t);return}d===void 0&&e&&i({selectedValue:e.value}),b==null||b(e.value),(r=e.onClick)==null||r.call(e,t),o()},[d,b,o,h]),W=n.useCallback((e,t)=>s=>{i({hoveredValue:e}),t==null||t(s)},[]),x=n.useCallback(e=>t=>{i({hoveredValue:void 0}),e==null||e(t)},[]),P=n.useCallback((e,t)=>s=>{i({focusedValue:e}),t==null||t(s)},[]),q=n.useCallback(e=>t=>{i({focusedValue:void 0}),e==null||e(t)},[]);return n.useLayoutEffect(()=>{o()},[h,o]),n.useEffect(()=>{const e=k.current;if(!e||typeof ResizeObserver=="undefined")return;const t=new ResizeObserver(()=>{o()});return t.observe(e),()=>{t.disconnect()}},[o]),n.useImperativeHandle(u,()=>({element:k.current}),[]),n.createElement("div",{ref:k,className:m.classNames("k-segmented-control",S&&`k-segmented-control-${S}`,{"k-segmented-control-stretched":O==="stretch"},E),...I},n.createElement("div",{className:"k-segmented-control-thumb",ref:N,"aria-hidden":"true"}),l.map(e=>{const{value:t,disabled:s,text:r,svgIcon:p,iconClassName:f,type:g="button",onClick:y,onMouseEnter:L,onMouseLeave:M,onFocus:_,onBlur:$,...A}=e,C=h===t;return n.createElement("button",{key:t,type:g,className:m.classNames("k-segmented-control-button",{"k-selected":C,"k-hover":v.hoveredValue===t&&!s,"k-focus":w===t&&!s,"k-disabled":s}),"aria-pressed":C,disabled:s,onClick:T(e),onMouseEnter:W(t,L),onMouseLeave:x(M),onFocus:P(t,_),onBlur:q($),...A},V?V(e):n.createElement(n.Fragment,null,p&&n.createElement(m.IconWrap,{className:m.classNames("k-segmented-control-button-icon",{...f&&{[f]:C}}),icon:p}),n.createElement("span",{className:"k-segmented-control-button-text"},r)))}))});R.displayName="KendoReactSegmentedControl";exports.SegmentedControl=R;
|