@progress/kendo-react-layout
Version:
React Layout components enable you to create a perceptive and intuitive layout of web projects. KendoReact Layout package
9 lines (8 loc) • 5.78 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("react"),u=require("prop-types"),W=require("@progress/kendo-react-animation"),A=require("@progress/kendo-react-common"),K=require("./ActionSheetItem.js"),F=require("./ActionSheetHeader.js"),X=require("./ActionSheetFooter.js"),Y=require("./ActionSheetContent.js"),H=require("./ActionSheetView.js");function Z(e){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const f=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(d,r,f.get?f:{enumerable:!0,get:()=>e[r]})}}return d.default=e,Object.freeze(d)}const n=Z(Q),R=n.forwardRef((e,d)=>{var q,_;const{navigatableElements:r=k.navigatableElements,navigatable:f=k.navigatable,position:V=k.position,animationDuration:l=300,prefixActions:N,suffixActions:g,filter:w}=e,L=(t,a,i)=>{i.preventDefault(),i.shiftKey?a.focusPrevious(t):a.focusNext(t)},M=(t,a,i)=>{if(t.ariaDisabled)return;const s=t.className&&t.className.indexOf?t.className.indexOf("k-actionsheet-item")!==-1:!1,x=a.elements.filter(y=>y.className.indexOf("k-actionsheet-item")!==-1);if(s&&e.onItemSelect){i.preventDefault();const y=e.items[x.indexOf(t)];e.onItemSelect.call(void 0,{syntheticEvent:i,item:y,title:y&&y.title})}e.animation||h()},$=(t,a,i)=>{e.onClose&&(i.preventDefault(),e.onClose.call(void 0,i)),e.animation||h()},h=()=>{b({show:!1})},B=t=>{f&&v.current.triggerKeyboardEvent(t)},z=t=>{e.onClose&&e.onClose.call(void 0,t),e.animation||h()},C=t=>{e.onItemSelect&&e.onItemSelect.call(void 0,t),e.animation||h()},U=t=>{const a={},i=[];return n.Children.forEach(t,s=>{s&&(s.type.displayName===H.ActionSheetViewDisplayName?i.push(s):a[s.type.displayName]=s)}),i.length>0?i:a},I=n.useRef(null),E=n.useRef(null);n.useImperativeHandle(I,()=>({props:e,element:E.current})),n.useImperativeHandle(d,()=>I.current);const v=n.useRef(void 0),D=n.useRef({bottom:"0",width:"100%"}),O=n.useRef(void 0),[o,G]=n.useState({show:!1,slide:!1}),b=t=>{G(a=>({...a,...t}))};n.useEffect(()=>{e.expand&&!o.show&&b({show:!0})},[]),n.useEffect(()=>{const t=E.current;if(e.expand&&!o.show&&b({show:!0}),e.expand&&o.show&&!o.slide&&b({slide:!0}),!e.expand&&o.show&&o.slide&&b({slide:!1}),O!==o&&o.slide&&t&&!e.className&&(t.style.setProperty("--kendo-actionsheet-height","auto"),t.style.setProperty("--kendo-actionsheet-max-height","none")),t&&f){const i=[".k-actionsheet-item",...[".k-actionsheet-footer",".k-actionsheet-content",".k-actionsheet-view",".k-actionsheet-titlebar"].map(s=>A.FOCUSABLE_ELEMENTS.concat(r).map(x=>`${s} ${x}`)).flat()];v.current=new A.Navigation({tabIndex:e.tabIndex||0,root:E,rovingTabIndex:!1,selectors:i,keyboardEvents:{keydown:{Tab:L,Enter:M,Escape:$}}}),v.current.focusElement(v.current.first,null)}O.current={...o}});const T="k-actionsheet-title",P=T,c=(q=e.items)==null?void 0:q.filter(t=>!t.group||t.group==="top"),S=(_=e.items)==null?void 0:_.filter(t=>t.group==="bottom"),J=c&&c.length>0&&S&&S.length>0,m=U(e.children),j=o.slide&&n.createElement("div",{className:A.classNames(`k-actionsheet k-actionsheet-${V}`,e.className),role:"dialog","aria-modal":"true",style:e.style,"aria-hidden":!1,"aria-labelledby":P,ref:E,onKeyDown:B},Array.isArray(m)?n.createElement(n.Fragment,null,m.map(t=>t)):n.createElement(H.ActionSheetView,null,m[F.headerDisplayName]&&!e.title&&!e.subTitle&&m[F.headerDisplayName],(e.title||e.subTitle||N||g||w)&&n.createElement("div",{className:"k-actionsheet-titlebar"},n.createElement("div",{className:"k-actionsheet-titlebar-group"},N&&n.createElement("div",{className:"k-actionsheet-actions"},N),n.createElement("div",{className:T,id:P},n.createElement("div",{className:"k-text-center"},e.title),e.subTitle&&n.createElement("div",{className:"k-actionsheet-subtitle k-text-center"},e.subTitle)),g&&n.createElement("div",{className:"k-actionsheet-actions"},g)),w&&n.createElement("div",{className:"k-actionsheet-titlebar-group k-actionsheet-filter"},w)),m[Y.contentDisplayName]||n.createElement("div",{className:"k-actionsheet-content"},n.createElement("div",{className:"k-list-ul",role:"group"},c&&c.map((t,a)=>n.createElement(K.ActionSheetItem,{...t,id:a,key:a,item:t,onClick:C})),J&&n.createElement("hr",{className:"k-hr"}),S&&S.map((t,a)=>n.createElement(K.ActionSheetItem,{...t,id:a+((c==null?void 0:c.length)||0),key:a,item:t,onClick:C})))),m[X.footerDisplayName]));return n.createElement(n.Fragment,null,e.expand||o.show?n.createElement("div",{className:"k-actionsheet-container"},n.createElement("div",{className:"k-overlay",onClick:z}),e.animation?n.createElement(W.Animation,{transitionName:o.slide?"slide-up":"slide-down",onExited:h,transitionEnterDuration:typeof l=="object"&&Object.keys(l).length>0&&l.openDuration?Number(l.openDuration):Number(l),transitionExitDuration:typeof l=="object"&&Object.keys(l).length>0&&l.closeDuration?Number(l.closeDuration):Number(l),animationEnteringStyle:e.animationStyles||D.current,animationEnteredStyle:e.animationStyles||D.current,animationExitingStyle:e.animationStyles||D.current,exit:!0,enter:!0,appear:!1},j):j):null)}),k={navigatable:!0,navigatableElements:[],position:"bottom"};R.propTypes={items:u.array,subTitle:u.node,title:u.node,navigatable:u.bool,navigatableElements:u.array,position:u.oneOf(["top","bottom","left","right","fullscreen"])};R.displayName="KendoReactActionSheet";exports.ActionSheet=R;exports.actionSheetDefaultProps=k;