@progress/kendo-react-buttons 7.2.4-develop.2 → 7.2.4-develop.4
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 +8 -0
- package/Button.mjs +124 -0
- package/ButtonGroup.js +8 -0
- package/ButtonGroup.mjs +76 -0
- package/Chip/Chip.js +8 -0
- package/Chip/Chip.mjs +220 -0
- package/Chip/ChipList.js +8 -0
- package/Chip/ChipList.mjs +190 -0
- package/Chip/chip-list-contexts.js +8 -0
- package/Chip/chip-list-contexts.mjs +18 -0
- package/Chip/data-reducer.js +8 -0
- package/Chip/data-reducer.mjs +25 -0
- package/Chip/focus-reducer.js +8 -0
- package/Chip/focus-reducer.mjs +28 -0
- package/Chip/selection-reducer.js +8 -0
- package/Chip/selection-reducer.mjs +47 -0
- package/FloatingActionButton/FloatingActionButton.js +8 -0
- package/FloatingActionButton/FloatingActionButton.mjs +343 -0
- package/FloatingActionButton/FloatingActionButtonItem.js +8 -0
- package/FloatingActionButton/FloatingActionButtonItem.mjs +93 -0
- package/FloatingActionButton/utils.js +8 -0
- package/FloatingActionButton/utils.mjs +46 -0
- package/ListButton/ButtonItem.js +8 -0
- package/ListButton/ButtonItem.mjs +63 -0
- package/ListButton/DropDownButton.js +8 -0
- package/ListButton/DropDownButton.mjs +267 -0
- package/ListButton/DropDownButtonItem.js +8 -0
- package/ListButton/DropDownButtonItem.mjs +31 -0
- package/ListButton/SplitButton.js +8 -0
- package/ListButton/SplitButton.mjs +298 -0
- package/ListButton/SplitButtonItem.js +8 -0
- package/ListButton/SplitButtonItem.mjs +30 -0
- package/ListButton/utils/navigation.js +8 -0
- package/ListButton/utils/navigation.mjs +35 -0
- package/ListButton/utils/popup.js +8 -0
- package/ListButton/utils/popup.mjs +20 -0
- package/dist/cdn/js/kendo-react-buttons.js +8 -5
- package/index.d.mts +2227 -5
- package/index.d.ts +2227 -40
- package/index.js +8 -5
- package/index.mjs +44 -1906
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +3 -3
- package/toolbar/Toolbar.js +8 -0
- package/toolbar/Toolbar.mjs +124 -0
- package/toolbar/tools/ToolbarItem.js +8 -0
- package/toolbar/tools/ToolbarItem.mjs +44 -0
- package/toolbar/tools/ToolbarSeparator.js +8 -0
- package/toolbar/tools/ToolbarSeparator.mjs +21 -0
- package/toolbar/tools/ToolbarSpacer.js +8 -0
- package/toolbar/tools/ToolbarSpacer.mjs +36 -0
- package/util.js +8 -0
- package/util.mjs +36 -0
- package/Button.d.ts +0 -146
- package/ButtonGroup.d.ts +0 -36
- package/ButtonGroupInterface.d.ts +0 -36
- package/ButtonInterface.d.ts +0 -39
- package/Chip/Chip.d.ts +0 -238
- package/Chip/ChipList.d.ts +0 -119
- package/Chip/chip-list-contexts.d.ts +0 -17
- package/Chip/data-reducer.d.ts +0 -26
- package/Chip/focus-reducer.d.ts +0 -28
- package/Chip/selection-reducer.d.ts +0 -34
- package/FloatingActionButton/FloatingActionButton.d.ts +0 -21
- package/FloatingActionButton/FloatingActionButtonItem.d.ts +0 -109
- package/FloatingActionButton/interfaces/FloatingActionButtonHandle.d.ts +0 -17
- package/FloatingActionButton/interfaces/FloatingActionButtonPopupSettings.d.ts +0 -28
- package/FloatingActionButton/interfaces/FloatingActionButtonProps.d.ts +0 -219
- package/FloatingActionButton/models/align-offset.d.ts +0 -24
- package/FloatingActionButton/models/align.d.ts +0 -31
- package/FloatingActionButton/models/events.d.ts +0 -25
- package/FloatingActionButton/models/position-mode.d.ts +0 -13
- package/FloatingActionButton/models/rounded.d.ts +0 -16
- package/FloatingActionButton/models/size.d.ts +0 -15
- package/FloatingActionButton/models/theme-color.d.ts +0 -22
- package/FloatingActionButton/utils.d.ts +0 -31
- package/ListButton/ButtonItem.d.ts +0 -34
- package/ListButton/DropDownButton.d.ts +0 -127
- package/ListButton/DropDownButtonItem.d.ts +0 -34
- package/ListButton/SplitButton.d.ts +0 -129
- package/ListButton/SplitButtonItem.d.ts +0 -29
- package/ListButton/models/ButtonItem.d.ts +0 -38
- package/ListButton/models/ListButtonProps.d.ts +0 -339
- package/ListButton/models/PopupSettings.d.ts +0 -32
- package/ListButton/models/events.d.ts +0 -51
- package/ListButton/utils/navigation.d.ts +0 -9
- package/ListButton/utils/popup.d.ts +0 -13
- package/models/index.d.ts +0 -92
- package/package-metadata.d.ts +0 -9
- package/toolbar/Toolbar.d.ts +0 -175
- package/toolbar/tools/ToolbarItem.d.ts +0 -42
- package/toolbar/tools/ToolbarSeparator.d.ts +0 -20
- package/toolbar/tools/ToolbarSpacer.d.ts +0 -27
- package/util.d.ts +0 -31
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),l=require("@progress/kendo-react-common");function u(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const c=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,c.get?c:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const t=u(o),m=e=>{const n=t.useCallback(d=>{e.onClick(d,e.index)},[e]),a=e.dataItem.render||e.item||(e.item===void 0?e.render:null),c=e.dataItem.text!==void 0?e.dataItem.text:e.textField?e.dataItem[e.textField]:e.dataItem,i=t.createElement("li",{id:e.id,className:l.classNames("k-item",e.className,{"k-focus":e.focused}),tabIndex:-1,onClick:n,onMouseDown:e.onDown,onPointerDown:e.onDown,role:"menuitem","aria-disabled":e.dataItem.disabled||void 0},t.createElement("span",{tabIndex:-1,className:l.classNames("k-link k-menu-link",{"k-selected":e.dataItem.selected,"k-disabled":e.dataItem.disabled}),key:"icon"},a?t.createElement(a,{item:e.dataItem,itemIndex:e.index}):t.createElement(t.Fragment,null,(e.dataItem.icon||e.dataItem.iconClass||e.dataItem.svgIcon)&&t.createElement(l.IconWrap,{className:e.dataItem.iconClass,name:e.dataItem.icon,icon:e.dataItem.svgIcon}),e.dataItem.imageUrl&&t.createElement("img",{role:"presentation",alt:"",src:e.dataItem.imageUrl,className:"k-icon"}),c&&t.createElement("span",{className:"k-menu-link-text"},c))));return e.item!==void 0&&e.render!==void 0?e.render.call(void 0,i,e):i};m.displayName="KendoReactButtonItem";exports.ButtonItem=m;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 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 client";
|
|
9
|
+
import * as t from "react";
|
|
10
|
+
import { classNames as d, IconWrap as c } from "@progress/kendo-react-common";
|
|
11
|
+
const I = (e) => {
|
|
12
|
+
const i = t.useCallback(
|
|
13
|
+
(l) => {
|
|
14
|
+
e.onClick(l, e.index);
|
|
15
|
+
},
|
|
16
|
+
[e]
|
|
17
|
+
), a = e.dataItem.render || e.item || (e.item === void 0 ? e.render : null), n = e.dataItem.text !== void 0 ? e.dataItem.text : e.textField ? e.dataItem[e.textField] : e.dataItem, m = /* @__PURE__ */ t.createElement(
|
|
18
|
+
"li",
|
|
19
|
+
{
|
|
20
|
+
id: e.id,
|
|
21
|
+
className: d(
|
|
22
|
+
"k-item",
|
|
23
|
+
e.className,
|
|
24
|
+
{ "k-focus": e.focused }
|
|
25
|
+
),
|
|
26
|
+
tabIndex: -1,
|
|
27
|
+
onClick: i,
|
|
28
|
+
onMouseDown: e.onDown,
|
|
29
|
+
onPointerDown: e.onDown,
|
|
30
|
+
role: "menuitem",
|
|
31
|
+
"aria-disabled": e.dataItem.disabled || void 0
|
|
32
|
+
},
|
|
33
|
+
/* @__PURE__ */ t.createElement(
|
|
34
|
+
"span",
|
|
35
|
+
{
|
|
36
|
+
tabIndex: -1,
|
|
37
|
+
className: d(
|
|
38
|
+
"k-link k-menu-link",
|
|
39
|
+
{
|
|
40
|
+
"k-selected": e.dataItem.selected,
|
|
41
|
+
"k-disabled": e.dataItem.disabled
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
key: "icon"
|
|
45
|
+
},
|
|
46
|
+
a ? /* @__PURE__ */ t.createElement(a, { item: e.dataItem, itemIndex: e.index }) : /* @__PURE__ */ t.createElement(t.Fragment, null, (e.dataItem.icon || e.dataItem.iconClass || e.dataItem.svgIcon) && /* @__PURE__ */ t.createElement(c, { className: e.dataItem.iconClass, name: e.dataItem.icon, icon: e.dataItem.svgIcon }), e.dataItem.imageUrl && /* @__PURE__ */ t.createElement(
|
|
47
|
+
"img",
|
|
48
|
+
{
|
|
49
|
+
role: "presentation",
|
|
50
|
+
alt: "",
|
|
51
|
+
src: e.dataItem.imageUrl,
|
|
52
|
+
className: "k-icon"
|
|
53
|
+
}
|
|
54
|
+
), n && /* @__PURE__ */ t.createElement("span", { className: "k-menu-link-text" }, n))
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
return e.item !== void 0 && /* to be removed in 5.0.0 */
|
|
58
|
+
e.render !== void 0 ? e.render.call(void 0, m, e) : m;
|
|
59
|
+
};
|
|
60
|
+
I.displayName = "KendoReactButtonItem";
|
|
61
|
+
export {
|
|
62
|
+
I as ButtonItem
|
|
63
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),i=require("prop-types"),f=require("../Button.js"),s=require("@progress/kendo-react-common"),g=require("./utils/navigation.js"),y=require("./DropDownButtonItem.js"),C=require("./ButtonItem.js"),k=require("@progress/kendo-react-popup"),c=require("./utils/popup.js"),b=require("../package-metadata.js");function D(u){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const t in u)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(u,t);Object.defineProperty(o,t,e.get?e:{enumerable:!0,get:()=>u[t]})}}return o.default=u,Object.freeze(o)}const p=D(m),d=class d extends p.Component{constructor(o){super(o),this.state={opened:!1,focused:!1,focusedIndex:-1},this.mainButton=null,this.list=null,this.skipFocus=!1,this.buttonsData=[],this.onKeyDown=t=>{const{focusedIndex:e}=this.state;if(t.altKey){!this.opened&&t.keyCode===s.Keys.down?(t.preventDefault(),this.setOpen(!0,t),this.setState({focusedIndex:0})):this.opened&&t.keyCode===s.Keys.up&&(t.preventDefault(),this.setState({focusedIndex:-1}),this.setOpen(!1,t));return}const n={...this.state};if(t.keyCode===s.Keys.enter||t.keyCode===s.Keys.space){t.preventDefault(),e>=0&&this.dispatchClickEvent(t,e);const r=!this.opened;this.setState({focused:!0,focusedIndex:r?0:-1}),this.setOpen(r,t);return}if(this.opened&&t.keyCode===s.Keys.esc){this.setState({focusedIndex:-1}),this.setOpen(!1,t);return}if(this.opened){const r=g.navigate(e,t.keyCode,t.altKey,this.buttonsData.length);n.focusedIndex=r;const h=t.keyCode===s.Keys.up||t.keyCode===s.Keys.down||t.keyCode===s.Keys.left||t.keyCode===s.Keys.right;!t.altKey&&(h||t.keyCode===s.Keys.home||t.keyCode===s.Keys.end)&&t.preventDefault()}this.setState(n)},this.switchFocus=t=>{this.skipFocus=!0,t(),window.setTimeout(()=>this.skipFocus=!1,0)},this.handleFocus=t=>{this.skipFocus||(this.setState({focused:!0,focusedIndex:this.opened?0:-1}),s.dispatchEvent(this.props.onFocus,t,this,void 0))},this.handleButtonBlur=t=>{this.opened||(this.setState({focused:!1}),s.dispatchEvent(this.props.onBlur,t,this,void 0))},this.handleMenuBlur=t=>{this.skipFocus||(this.setState({focused:!1,focusedIndex:-1}),s.dispatchEvent(this.props.onBlur,t,this,void 0),setTimeout(()=>{this.setOpen(!1,t)},0))},this.setOpen=(t,e)=>{this.opened!==t&&(this.openedDuringOnChange=t,this.setState({opened:t}),e?this.dispatchPopupEvent(e,t):this.openedDuringOnChange=void 0)},this.onItemClick=(t,e)=>{this.setState({focusedIndex:-1}),this.dispatchClickEvent(t,e),this.setOpen(!1,t)},this.onItemDown=t=>{s.getActiveElement(document)===this.list&&t.preventDefault()},this.mouseDown=t=>{t.preventDefault();const e=s.getActiveElement(document);this.element&&e!==this.element&&e!==this.list&&this.element.focus()},this.onPopupClose=t=>{var n;const e=s.getActiveElement(document);this.element&&this.element.removeAttribute("tabindex"),(e===this.list||(n=this.list)!=null&&n.contains(e))&&this.switchFocus(()=>{this.element&&this.element.focus({preventScroll:!0})}),this.props.popupSettings&&this.props.popupSettings.onClose&&this.props.popupSettings.onClose.call(void 0,t)},this.listRef=t=>{this.list=t,t&&this.state.focused&&this.switchFocus(()=>{t.focus({preventScroll:!0}),this.element&&(this.element.tabIndex=-1)})},this.onClickMainButton=t=>{if(!this.buttonsData.length)return;const e=!this.opened;this.setState({focused:!0,focusedIndex:e?0:-1}),this.setOpen(e,t)},this.dispatchPopupEvent=(t,e)=>{s.dispatchEvent(e?this.props.onOpen:this.props.onClose,t,this,void 0),this.openedDuringOnChange=void 0},s.validatePackage(b.packageMetadata)}get guid(){return this.props.id+"-accessibility-id"}get opened(){return this.openedDuringOnChange!==void 0?this.openedDuringOnChange:this.props.opened===void 0?this.state.opened:this.props.opened}render(){const o=this.isRtl(),t=o?"rtl":void 0,{id:e,style:n,tabIndex:r,disabled:h}=this.props;return this.buttonsData=this.props.items||p.Children.toArray(this.props.children).filter(a=>a&&a.type===y.DropDownButtonItem).map(a=>a.props),p.createElement(p.Fragment,null,p.createElement(f.Button,{id:e,size:this.props.size,style:n,rounded:this.props.rounded,fillMode:this.props.fillMode,themeColor:this.props.themeColor,onClick:this.onClickMainButton,onMouseDown:this.mouseDown,onKeyDown:this.onKeyDown,onFocus:this.handleFocus,onBlur:this.handleButtonBlur,"aria-disabled":h?"true":void 0,tabIndex:r,accessKey:this.props.accessKey,icon:this.props.icon,svgIcon:this.props.svgIcon,iconClass:this.props.iconClass,className:s.classNames(this.props.buttonClass,this.props.className,"k-menu-button","k-dropdown-button",{"k-focus":this.state.focused},{"k-disabled":h}),imageUrl:this.props.imageUrl,dir:t,ref:a=>this.mainButton=a&&a.element,type:"button","aria-haspopup":"menu","aria-expanded":this.opened?"true":"false","aria-label":this.props.ariaLabel,"aria-controls":this.opened?this.guid:void 0,title:this.props.title},this.props.text),this.renderPopup(o))}componentDidMount(){(this.props.dir===void 0&&this.isRtl()||this.opened)&&this.forceUpdate()}get element(){return this.mainButton}dispatchClickEvent(o,t){this.isItemDisabled(t)||s.dispatchEvent(this.props.onItemClick,o,this,{item:this.buttonsData[t],itemIndex:t})}renderPopup(o){const{popupSettings:t={},id:e}=this.props,{focusedIndex:n}=this.state;return p.createElement(k.Popup,{anchor:this.mainButton,show:this.opened,animate:t.animate,popupClass:s.classNames("k-menu-popup",t.popupClass),anchorAlign:t.anchorAlign||c.getAnchorAlign(o),popupAlign:t.popupAlign||c.getPopupAlign(o),style:o?{direction:"rtl"}:void 0,onClose:this.onPopupClose},p.createElement("ul",{role:"menu",id:this.guid,"aria-labelledby":e,tabIndex:-1,"aria-activedescendant":n>=0?`${this.guid}-${n}`:void 0,ref:this.listRef,onKeyDown:this.onKeyDown,onBlur:this.handleMenuBlur,className:s.classNames("k-group k-menu-group k-reset",{[`k-menu-group-${s.kendoThemeMaps.sizeMap[this.props.size]||this.props.size}`]:this.props.size})},this.renderChildItems()))}renderChildItems(){const{item:o,itemRender:t,textField:e}=this.props;return this.buttonsData.length>0?this.buttonsData.map((n,r)=>p.createElement(C.ButtonItem,{className:"k-menu-item",dataItem:n,textField:e,focused:this.state.focusedIndex===r,onClick:this.onItemClick,onDown:this.onItemDown,render:t,item:o,index:r,key: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.mainButton&&getComputedStyle(this.mainButton).direction==="rtl"}};d.propTypes={accessKey:i.string,ariaLabel:i.string,title:i.string,onFocus:i.func,onBlur:i.func,onItemClick:i.func,onOpen:i.func,onClose:i.func,items:i.arrayOf(i.any),textField:i.string,tabIndex:i.number,disabled:i.bool,icon:i.string,svgIcon:s.svgIconPropType,iconClass:i.string,imageUrl:i.string,popupSettings:i.object,itemRender:i.func,item:i.func,className:i.string,buttonClass:i.string,dir:i.string},d.defaultProps={size:"medium",rounded:"medium",fillMode:"solid",themeColor:"base"};let l=d;exports.DropDownButton=l;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 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 client";
|
|
9
|
+
import * as r from "react";
|
|
10
|
+
import s from "prop-types";
|
|
11
|
+
import { Button as f } from "../Button.mjs";
|
|
12
|
+
import { Keys as p, dispatchEvent as a, getActiveElement as l, validatePackage as g, svgIconPropType as C, classNames as c, kendoThemeMaps as k } from "@progress/kendo-react-common";
|
|
13
|
+
import { navigate as y } from "./utils/navigation.mjs";
|
|
14
|
+
import { DropDownButtonItem as b } from "./DropDownButtonItem.mjs";
|
|
15
|
+
import { ButtonItem as I } from "./ButtonItem.mjs";
|
|
16
|
+
import { Popup as D } from "@progress/kendo-react-popup";
|
|
17
|
+
import { getAnchorAlign as w, getPopupAlign as S } from "./utils/popup.mjs";
|
|
18
|
+
import { packageMetadata as x } from "../package-metadata.mjs";
|
|
19
|
+
const u = class u extends r.Component {
|
|
20
|
+
constructor(i) {
|
|
21
|
+
super(i), this.state = {
|
|
22
|
+
opened: !1,
|
|
23
|
+
focused: !1,
|
|
24
|
+
focusedIndex: -1
|
|
25
|
+
}, this.mainButton = null, this.list = null, this.skipFocus = !1, this.buttonsData = [], this.onKeyDown = (t) => {
|
|
26
|
+
const { focusedIndex: e } = this.state;
|
|
27
|
+
if (t.altKey) {
|
|
28
|
+
!this.opened && t.keyCode === p.down ? (t.preventDefault(), this.setOpen(!0, t), this.setState({ focusedIndex: 0 })) : this.opened && t.keyCode === p.up && (t.preventDefault(), this.setState({ focusedIndex: -1 }), this.setOpen(!1, t));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const o = { ...this.state };
|
|
32
|
+
if (t.keyCode === p.enter || t.keyCode === p.space) {
|
|
33
|
+
t.preventDefault(), e >= 0 && this.dispatchClickEvent(t, e);
|
|
34
|
+
const n = !this.opened;
|
|
35
|
+
this.setState({
|
|
36
|
+
focused: !0,
|
|
37
|
+
focusedIndex: n ? 0 : -1
|
|
38
|
+
}), this.setOpen(n, t);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (this.opened && t.keyCode === p.esc) {
|
|
42
|
+
this.setState({ focusedIndex: -1 }), this.setOpen(!1, t);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (this.opened) {
|
|
46
|
+
const n = y(
|
|
47
|
+
e,
|
|
48
|
+
t.keyCode,
|
|
49
|
+
t.altKey,
|
|
50
|
+
this.buttonsData.length
|
|
51
|
+
);
|
|
52
|
+
o.focusedIndex = n;
|
|
53
|
+
const d = t.keyCode === p.up || t.keyCode === p.down || t.keyCode === p.left || t.keyCode === p.right;
|
|
54
|
+
!t.altKey && (d || t.keyCode === p.home || t.keyCode === p.end) && t.preventDefault();
|
|
55
|
+
}
|
|
56
|
+
this.setState(o);
|
|
57
|
+
}, this.switchFocus = (t) => {
|
|
58
|
+
this.skipFocus = !0, t(), window.setTimeout(() => this.skipFocus = !1, 0);
|
|
59
|
+
}, this.handleFocus = (t) => {
|
|
60
|
+
this.skipFocus || (this.setState({ focused: !0, focusedIndex: this.opened ? 0 : -1 }), a(this.props.onFocus, t, this, void 0));
|
|
61
|
+
}, this.handleButtonBlur = (t) => {
|
|
62
|
+
this.opened || (this.setState({ focused: !1 }), a(this.props.onBlur, t, this, void 0));
|
|
63
|
+
}, this.handleMenuBlur = (t) => {
|
|
64
|
+
this.skipFocus || (this.setState({ focused: !1, focusedIndex: -1 }), a(this.props.onBlur, t, this, void 0), setTimeout(() => {
|
|
65
|
+
this.setOpen(!1, t);
|
|
66
|
+
}, 0));
|
|
67
|
+
}, this.setOpen = (t, e) => {
|
|
68
|
+
this.opened !== t && (this.openedDuringOnChange = t, this.setState({ opened: t }), e ? this.dispatchPopupEvent(e, t) : this.openedDuringOnChange = void 0);
|
|
69
|
+
}, this.onItemClick = (t, e) => {
|
|
70
|
+
this.setState({ focusedIndex: -1 }), this.dispatchClickEvent(t, e), this.setOpen(!1, t);
|
|
71
|
+
}, this.onItemDown = (t) => {
|
|
72
|
+
l(document) === this.list && t.preventDefault();
|
|
73
|
+
}, this.mouseDown = (t) => {
|
|
74
|
+
t.preventDefault();
|
|
75
|
+
const e = l(document);
|
|
76
|
+
this.element && e !== this.element && e !== this.list && this.element.focus();
|
|
77
|
+
}, this.onPopupClose = (t) => {
|
|
78
|
+
var o;
|
|
79
|
+
const e = l(document);
|
|
80
|
+
this.element && this.element.removeAttribute("tabindex"), (e === this.list || (o = this.list) != null && o.contains(e)) && this.switchFocus(() => {
|
|
81
|
+
this.element && this.element.focus({ preventScroll: !0 });
|
|
82
|
+
}), this.props.popupSettings && this.props.popupSettings.onClose && this.props.popupSettings.onClose.call(void 0, t);
|
|
83
|
+
}, this.listRef = (t) => {
|
|
84
|
+
this.list = t, t && this.state.focused && this.switchFocus(() => {
|
|
85
|
+
t.focus({ preventScroll: !0 }), this.element && (this.element.tabIndex = -1);
|
|
86
|
+
});
|
|
87
|
+
}, this.onClickMainButton = (t) => {
|
|
88
|
+
if (!this.buttonsData.length)
|
|
89
|
+
return;
|
|
90
|
+
const e = !this.opened;
|
|
91
|
+
this.setState({
|
|
92
|
+
focused: !0,
|
|
93
|
+
focusedIndex: e ? 0 : -1
|
|
94
|
+
}), this.setOpen(e, t);
|
|
95
|
+
}, this.dispatchPopupEvent = (t, e) => {
|
|
96
|
+
a(e ? this.props.onOpen : this.props.onClose, t, this, void 0), this.openedDuringOnChange = void 0;
|
|
97
|
+
}, g(x);
|
|
98
|
+
}
|
|
99
|
+
get guid() {
|
|
100
|
+
return this.props.id + "-accessibility-id";
|
|
101
|
+
}
|
|
102
|
+
get opened() {
|
|
103
|
+
return this.openedDuringOnChange !== void 0 ? this.openedDuringOnChange : this.props.opened === void 0 ? this.state.opened : this.props.opened;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @hidden
|
|
107
|
+
*/
|
|
108
|
+
render() {
|
|
109
|
+
const i = this.isRtl(), t = i ? "rtl" : void 0, { id: e, style: o, tabIndex: n, disabled: d } = this.props;
|
|
110
|
+
return this.buttonsData = this.props.items || r.Children.toArray(this.props.children).filter((h) => h && h.type === b).map((h) => h.props), /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(
|
|
111
|
+
f,
|
|
112
|
+
{
|
|
113
|
+
id: e,
|
|
114
|
+
size: this.props.size,
|
|
115
|
+
style: o,
|
|
116
|
+
rounded: this.props.rounded,
|
|
117
|
+
fillMode: this.props.fillMode,
|
|
118
|
+
themeColor: this.props.themeColor,
|
|
119
|
+
onClick: this.onClickMainButton,
|
|
120
|
+
onMouseDown: this.mouseDown,
|
|
121
|
+
onKeyDown: this.onKeyDown,
|
|
122
|
+
onFocus: this.handleFocus,
|
|
123
|
+
onBlur: this.handleButtonBlur,
|
|
124
|
+
"aria-disabled": d ? "true" : void 0,
|
|
125
|
+
tabIndex: n,
|
|
126
|
+
accessKey: this.props.accessKey,
|
|
127
|
+
icon: this.props.icon,
|
|
128
|
+
svgIcon: this.props.svgIcon,
|
|
129
|
+
iconClass: this.props.iconClass,
|
|
130
|
+
className: c(
|
|
131
|
+
this.props.buttonClass,
|
|
132
|
+
this.props.className,
|
|
133
|
+
"k-menu-button",
|
|
134
|
+
// Used for a11y testing.
|
|
135
|
+
"k-dropdown-button",
|
|
136
|
+
// Used because of the old name of the component. Have the same styles as 'k-menu-button'.
|
|
137
|
+
{ "k-focus": this.state.focused },
|
|
138
|
+
{ "k-disabled": d }
|
|
139
|
+
),
|
|
140
|
+
imageUrl: this.props.imageUrl,
|
|
141
|
+
dir: t,
|
|
142
|
+
ref: (h) => this.mainButton = h && h.element,
|
|
143
|
+
type: "button",
|
|
144
|
+
"aria-haspopup": "menu",
|
|
145
|
+
"aria-expanded": this.opened ? "true" : "false",
|
|
146
|
+
"aria-label": this.props.ariaLabel,
|
|
147
|
+
"aria-controls": this.opened ? this.guid : void 0,
|
|
148
|
+
title: this.props.title
|
|
149
|
+
},
|
|
150
|
+
this.props.text
|
|
151
|
+
), this.renderPopup(i));
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* @hidden
|
|
155
|
+
*/
|
|
156
|
+
componentDidMount() {
|
|
157
|
+
(this.props.dir === void 0 && this.isRtl() || this.opened) && this.forceUpdate();
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The DOM element of main button.
|
|
161
|
+
*/
|
|
162
|
+
get element() {
|
|
163
|
+
return this.mainButton;
|
|
164
|
+
}
|
|
165
|
+
dispatchClickEvent(i, t) {
|
|
166
|
+
this.isItemDisabled(t) || a(
|
|
167
|
+
this.props.onItemClick,
|
|
168
|
+
i,
|
|
169
|
+
this,
|
|
170
|
+
{
|
|
171
|
+
item: this.buttonsData[t],
|
|
172
|
+
itemIndex: t
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
renderPopup(i) {
|
|
177
|
+
const { popupSettings: t = {}, id: e } = this.props, { focusedIndex: o } = this.state;
|
|
178
|
+
return /* @__PURE__ */ r.createElement(
|
|
179
|
+
D,
|
|
180
|
+
{
|
|
181
|
+
anchor: this.mainButton,
|
|
182
|
+
show: this.opened,
|
|
183
|
+
animate: t.animate,
|
|
184
|
+
popupClass: c("k-menu-popup", t.popupClass),
|
|
185
|
+
anchorAlign: t.anchorAlign || w(i),
|
|
186
|
+
popupAlign: t.popupAlign || S(i),
|
|
187
|
+
style: i ? { direction: "rtl" } : void 0,
|
|
188
|
+
onClose: this.onPopupClose
|
|
189
|
+
},
|
|
190
|
+
/* @__PURE__ */ r.createElement(
|
|
191
|
+
"ul",
|
|
192
|
+
{
|
|
193
|
+
role: "menu",
|
|
194
|
+
id: this.guid,
|
|
195
|
+
"aria-labelledby": e,
|
|
196
|
+
tabIndex: -1,
|
|
197
|
+
"aria-activedescendant": o >= 0 ? `${this.guid}-${o}` : void 0,
|
|
198
|
+
ref: this.listRef,
|
|
199
|
+
onKeyDown: this.onKeyDown,
|
|
200
|
+
onBlur: this.handleMenuBlur,
|
|
201
|
+
className: c("k-group k-menu-group k-reset", {
|
|
202
|
+
[`k-menu-group-${k.sizeMap[this.props.size] || this.props.size}`]: this.props.size
|
|
203
|
+
})
|
|
204
|
+
},
|
|
205
|
+
this.renderChildItems()
|
|
206
|
+
)
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
renderChildItems() {
|
|
210
|
+
const { item: i, itemRender: t, textField: e } = this.props;
|
|
211
|
+
return this.buttonsData.length > 0 ? this.buttonsData.map((o, n) => /* @__PURE__ */ r.createElement(
|
|
212
|
+
I,
|
|
213
|
+
{
|
|
214
|
+
className: "k-menu-item",
|
|
215
|
+
dataItem: o,
|
|
216
|
+
textField: e,
|
|
217
|
+
focused: this.state.focusedIndex === n,
|
|
218
|
+
onClick: this.onItemClick,
|
|
219
|
+
onDown: this.onItemDown,
|
|
220
|
+
render: t,
|
|
221
|
+
item: i,
|
|
222
|
+
index: n,
|
|
223
|
+
key: n,
|
|
224
|
+
id: `${this.guid}-${n}`
|
|
225
|
+
}
|
|
226
|
+
)) : null;
|
|
227
|
+
}
|
|
228
|
+
isItemDisabled(i) {
|
|
229
|
+
return this.buttonsData[i] ? this.buttonsData[i].disabled : this.props.disabled;
|
|
230
|
+
}
|
|
231
|
+
isRtl() {
|
|
232
|
+
return this.props.dir !== void 0 ? this.props.dir === "rtl" : !!this.mainButton && getComputedStyle(this.mainButton).direction === "rtl";
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
u.propTypes = {
|
|
236
|
+
accessKey: s.string,
|
|
237
|
+
ariaLabel: s.string,
|
|
238
|
+
title: s.string,
|
|
239
|
+
onFocus: s.func,
|
|
240
|
+
onBlur: s.func,
|
|
241
|
+
onItemClick: s.func,
|
|
242
|
+
onOpen: s.func,
|
|
243
|
+
onClose: s.func,
|
|
244
|
+
items: s.arrayOf(s.any),
|
|
245
|
+
textField: s.string,
|
|
246
|
+
tabIndex: s.number,
|
|
247
|
+
disabled: s.bool,
|
|
248
|
+
icon: s.string,
|
|
249
|
+
svgIcon: C,
|
|
250
|
+
iconClass: s.string,
|
|
251
|
+
imageUrl: s.string,
|
|
252
|
+
popupSettings: s.object,
|
|
253
|
+
itemRender: s.func,
|
|
254
|
+
item: s.func,
|
|
255
|
+
className: s.string,
|
|
256
|
+
buttonClass: s.string,
|
|
257
|
+
dir: s.string
|
|
258
|
+
}, u.defaultProps = {
|
|
259
|
+
size: "medium",
|
|
260
|
+
rounded: "medium",
|
|
261
|
+
fillMode: "solid",
|
|
262
|
+
themeColor: "base"
|
|
263
|
+
};
|
|
264
|
+
let m = u;
|
|
265
|
+
export {
|
|
266
|
+
m as DropDownButton
|
|
267
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),e=require("prop-types");function l(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const c=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,c.get?c:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const a=l(i),o=class o extends a.Component{render(){return null}};o.propTypes={text:e.string,icon:e.string,iconClass:e.string,imageUrl:e.string,selected:e.bool,disabled:e.bool,render:e.any};let s=o;exports.DropDownButtonItem=s;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 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 client";
|
|
9
|
+
import * as i from "react";
|
|
10
|
+
import e from "prop-types";
|
|
11
|
+
const s = class s extends i.Component {
|
|
12
|
+
/**
|
|
13
|
+
* @hidden
|
|
14
|
+
*/
|
|
15
|
+
render() {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
s.propTypes = {
|
|
20
|
+
text: e.string,
|
|
21
|
+
icon: e.string,
|
|
22
|
+
iconClass: e.string,
|
|
23
|
+
imageUrl: e.string,
|
|
24
|
+
selected: e.bool,
|
|
25
|
+
disabled: e.bool,
|
|
26
|
+
render: e.any
|
|
27
|
+
};
|
|
28
|
+
let r = s;
|
|
29
|
+
export {
|
|
30
|
+
r as DropDownButtonItem
|
|
31
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react"),i=require("prop-types"),c=require("../Button.js"),s=require("@progress/kendo-react-common"),g=require("./ButtonItem.js"),C=require("./SplitButtonItem.js"),b=require("./utils/navigation.js"),y=require("@progress/kendo-react-popup"),m=require("./utils/popup.js"),k=require("../package-metadata.js"),D=require("@progress/kendo-svg-icons");function I(h){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const t in h)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(h,t);Object.defineProperty(o,t,e.get?e:{enumerable:!0,get:()=>h[t]})}}return o.default=h,Object.freeze(o)}const a=I(f),u=class u extends a.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.onKeyDown=t=>{const{focusedIndex:e}=this.state;if(t.altKey){!this.opened&&t.keyCode===s.Keys.down?(t.preventDefault(),this.setState({focusedIndex:0}),this.setOpen(!0,t)):this.opened&&t.keyCode===s.Keys.up&&(t.preventDefault(),this.setState({focusedIndex:-1}),this.setOpen(!1,t));return}let n;if(t.keyCode===s.Keys.enter||t.keyCode===s.Keys.space){if(t.preventDefault(),this.dispatchClickEvent(t,e),e>=0){n={focusedIndex:this.opened?-1:0};const r=!this.opened;this.setOpen(r,t)}}else if(this.opened&&t.keyCode===s.Keys.esc){this.setState({focusedIndex:-1}),this.setOpen(!1,t);return}if(this.opened){const r=b.navigate(e,t.keyCode,t.altKey,this.buttonsData.length);r!==e&&(n=n||{},n.focusedIndex=r);const d=t.keyCode===s.Keys.up||t.keyCode===s.Keys.down||t.keyCode===s.Keys.left||t.keyCode===s.Keys.right;!t.altKey&&(d||t.keyCode===s.Keys.home||t.keyCode===s.Keys.end)&&t.preventDefault()}n&&this.setState(n)},this.switchFocus=t=>{this.skipFocus=!0,t(),window.setTimeout(()=>this.skipFocus=!1,0)},this.onFocus=t=>{this.skipFocus||(s.dispatchEvent(this.props.onFocus,t,this,void 0),this.setState({focused:!0}))},this.setOpen=(t,e)=>{this.opened!==t&&(this.openedDuringOnChange=t,this.setState({opened:t}),e?this.dispatchPopupEvent(e,t):this.openedDuringOnChange=void 0)},this.onItemClick=(t,e)=>{this.opened&&this.setState({focusedIndex:0}),this.dispatchClickEvent(t,e),this.setOpen(!1,t)},this.onBlur=t=>{this.skipFocus||(this.setState({focused:!1,focusedIndex:-1}),s.dispatchEvent(this.props.onBlur,t,this,void 0),setTimeout(()=>{this.setOpen(!1,t)},0))},this.onPopupClose=t=>{var n;const e=s.getActiveElement(document);this.element&&this.element.removeAttribute("tabindex"),(e===this.list||(n=this.list)!=null&&n.contains(e))&&this.switchFocus(()=>{this.element&&this.element.focus({preventScroll:!0})}),this.props.popupSettings&&this.props.popupSettings.onClose&&this.props.popupSettings.onClose.call(void 0,t)},this.listRef=t=>{this.list=t,t&&this.state.focused&&this.switchFocus(()=>{t.focus({preventScroll:!0}),this.element&&(this.element.tabIndex=-1)})},this.onSplitPartClick=t=>{if(this.buttonsData.length){const e=!this.opened;this.setState({focusedIndex:e?0:-1,focused:!0}),this.setOpen(e,t)}},this.onDownSplitPart=t=>{t.preventDefault();const e=s.getActiveElement(document);this.element&&e!==this.element&&e!==this.list&&this.element.focus()},this.onItemDown=t=>{s.getActiveElement(document)===this.list&&t.preventDefault()},this.dispatchPopupEvent=(t,e)=>{s.dispatchEvent(e?this.props.onOpen:this.props.onClose,t,this,void 0),this.openedDuringOnChange=void 0},s.validatePackage(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||a.Children.toArray(this.props.children).filter(p=>p&&p.type===C.SplitButtonItem).map(p=>p.props);const o=this.isRtl(),t=o?"rtl":void 0,{id:e,style:n,tabIndex:r,disabled:d}=this.props;return a.createElement("div",{id:e,style:n,className:s.classNames("k-split-button","k-button-group",{"k-focus":this.state.focused},`k-rounded-${s.kendoThemeMaps.roundedMap[this.props.rounded||"medium"]}`,this.props.className),onKeyDown:this.onKeyDown,onFocus:this.onFocus,onBlur:this.onBlur,dir:t,ref:p=>this.wrapper=p},a.createElement(c.Button,{ref:p=>this.mainButton=p&&p.element,type:"button",size:this.props.size,rounded:this.props.rounded,fillMode:this.props.fillMode,themeColor:this.props.themeColor,onClick:p=>this.onItemClick(p,-1),disabled:d||void 0,tabIndex:r,accessKey:this.props.accessKey,className:this.props.buttonClass,icon:this.props.icon,svgIcon:this.props.svgIcon,iconClass:this.props.iconClass,imageUrl:this.props.imageUrl,dir:t,"aria-disabled":d,"aria-haspopup":!0,"aria-expanded":this.opened||void 0,"aria-label":this.props.ariaLabel,"aria-controls":this.opened?this.guid:void 0,id:"button-"+this.guid,title:this.props.title},this.props.text),a.createElement(c.Button,{type:"button",size:this.props.size,rounded:this.props.rounded,fillMode:this.props.fillMode,themeColor:this.props.themeColor,icon:"caret-alt-down",svgIcon:D.caretAltDownIcon,className:"k-split-button-arrow",disabled:d||void 0,tabIndex:-1,onClick:this.onSplitPartClick,onMouseDown:this.onDownSplitPart,onPointerDown:this.onDownSplitPart,dir:t,"aria-label":"menu toggling button"}),this.renderPopup(o))}componentDidMount(){(this.props.dir===void 0&&this.isRtl()||this.opened)&&this.forceUpdate()}get element(){return this.mainButton}dispatchClickEvent(o,t){this.isItemDisabled(t)||(t===-1?s.dispatchEvent(this.props.onButtonClick,o,this,void 0):s.dispatchEvent(this.props.onItemClick,o,this,{item:this.buttonsData[t],itemIndex:t}))}renderPopup(o){const{popupSettings:t={}}=this.props,{focusedIndex:e}=this.state;return a.createElement(y.Popup,{anchor:this.wrapper,show:this.opened,animate:t.animate,popupClass:s.classNames("k-menu-popup",t.popupClass),anchorAlign:t.anchorAlign||m.getAnchorAlign(o),popupAlign:t.popupAlign||m.getPopupAlign(o),style:o?{direction:"rtl"}:void 0,onClose:this.onPopupClose},a.createElement("ul",{role:"menu",id:this.guid,"aria-labelledby":"button-"+this.guid,tabIndex:-1,ref:this.listRef,"aria-activedescendant":e>=0?`${this.guid}-${e}`:void 0,className:s.classNames("k-group k-menu-group k-reset",{[`k-menu-group-${s.kendoThemeMaps.sizeMap[this.props.size]||this.props.size}`]:this.props.size})},this.renderChildItems()))}renderChildItems(){const{item:o,itemRender:t,textField:e}=this.props;return this.buttonsData.length>0?this.buttonsData.map((n,r)=>a.createElement(g.ButtonItem,{className:"k-menu-item",dataItem:n,textField:e,focused:this.state.focusedIndex===r,onClick:this.onItemClick,onDown:this.onItemDown,render:t,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"}};u.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,iconClass:i.string,imageUrl:i.string,popupSettings:i.object,itemRender:i.any,item:i.func,className:i.string,buttonClass:i.string,dir:i.string},u.defaultProps={size:"medium",rounded:"medium",fillMode:"solid",themeColor:"base"};let l=u;exports.SplitButton=l;
|