@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) • 6.13 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"),d=require("prop-types"),W=require("@progress/kendo-react-animation"),I=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 f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const m in e)if(m!=="default"){const h=Object.getOwnPropertyDescriptor(e,m);Object.defineProperty(f,m,h.get?h:{enumerable:!0,get:()=>e[m]})}}return f.default=e,Object.freeze(f)}const n=Z(Q),w=n.forwardRef((e,f)=>{var q,_;const{navigatableElements:m=N.navigatableElements,navigatable:h=N.navigatable,position:V=N.position,animationDuration:o=300,prefixActions:g,suffixActions:x,filter:D}=e,L=(t,i,a)=>{a.preventDefault(),a.shiftKey?i.focusPrevious(t):i.focusNext(t)},M=(t,i,a)=>{if(t.ariaDisabled)return;const c=t.className&&t.className.indexOf?t.className.indexOf("k-actionsheet-item")!==-1:!1,S=i.elements.filter(s=>s.className.indexOf("k-actionsheet-item")!==-1);if(c&&e.onItemClick){a.preventDefault();const s=e.items[S.indexOf(t)];e.onItemClick.call(void 0,{syntheticEvent:a,item:s,title:s&&s.title})}if(c&&e.onItemSelect){a.preventDefault();const s=e.items[S.indexOf(t)];e.onItemSelect.call(void 0,{syntheticEvent:a,item:s,title:s&&s.title})}e.animation||b()},$=(t,i,a)=>{e.onOverlayClick&&(a.preventDefault(),e.onOverlayClick.call(void 0,a)),e.onClose&&(a.preventDefault(),e.onClose.call(void 0,a)),e.animation||b()},b=()=>{y({show:!1})},B=t=>{h&&E.current.triggerKeyboardEvent(t)},z=t=>{e.onOverlayClick&&e.onOverlayClick.call(void 0,t),e.onClose&&e.onClose.call(void 0,t),e.animation||b()},A=t=>{e.onItemClick&&e.onItemClick.call(void 0,t),e.onItemSelect&&e.onItemSelect.call(void 0,t),e.animation||b()},U=t=>{const i={},a=[];return n.Children.forEach(t,c=>{c&&(c.type.displayName===H.ActionSheetViewDisplayName?a.push(c):i[c.type.displayName]=c)}),a.length>0?a:i},O=n.useRef(null),k=n.useRef(null);n.useImperativeHandle(O,()=>({props:e,element:k.current})),n.useImperativeHandle(f,()=>O.current);const E=n.useRef(void 0),C=n.useRef({bottom:"0",width:"100%"}),R=n.useRef(void 0),[l,G]=n.useState({show:!1,slide:!1}),y=t=>{G(i=>({...i,...t}))};n.useEffect(()=>{e.expand&&!l.show&&y({show:!0})},[]),n.useEffect(()=>{const t=k.current;if(e.expand&&!l.show&&y({show:!0}),e.expand&&l.show&&!l.slide&&y({slide:!0}),!e.expand&&l.show&&l.slide&&y({slide:!1}),R!==l&&l.slide&&t&&!e.className&&(t.style.setProperty("--kendo-actionsheet-height","auto"),t.style.setProperty("--kendo-actionsheet-max-height","none")),t&&h){const a=[".k-actionsheet-item",...[".k-actionsheet-footer",".k-actionsheet-content",".k-actionsheet-view",".k-actionsheet-titlebar"].map(c=>I.FOCUSABLE_ELEMENTS.concat(m).map(S=>`${c} ${S}`)).flat()];E.current=new I.Navigation({tabIndex:e.tabIndex||0,root:k,rovingTabIndex:!1,selectors:a,keyboardEvents:{keydown:{Tab:L,Enter:M,Escape:$}}}),E.current.focusElement(E.current.first,null)}R.current={...l}});const T="k-actionsheet-title",P=T,r=(q=e.items)==null?void 0:q.filter(t=>!t.group||t.group==="top"),v=(_=e.items)==null?void 0:_.filter(t=>t.group==="bottom"),J=r&&r.length>0&&v&&v.length>0,u=U(e.children),j=l.slide&&n.createElement("div",{className:I.classNames(`k-actionsheet k-actionsheet-${V}`,e.className),role:"dialog","aria-modal":"true",style:e.style,"aria-hidden":!1,"aria-labelledby":P,ref:k,onKeyDown:B},Array.isArray(u)?n.createElement(n.Fragment,null,u.map(t=>t)):n.createElement(H.ActionSheetView,null,u[F.headerDisplayName]&&!e.title&&!e.subTitle&&u[F.headerDisplayName],(e.title||e.subTitle||g||x||D)&&n.createElement("div",{className:"k-actionsheet-titlebar"},n.createElement("div",{className:"k-actionsheet-titlebar-group"},g&&n.createElement("div",{className:"k-actionsheet-actions"},g),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)),x&&n.createElement("div",{className:"k-actionsheet-actions"},x)),D&&n.createElement("div",{className:"k-actionsheet-titlebar-group k-actionsheet-filter"},D)),u[Y.contentDisplayName]||n.createElement("div",{className:"k-actionsheet-content"},n.createElement("div",{className:"k-list-ul",role:"group"},r&&r.map((t,i)=>n.createElement(K.ActionSheetItem,{...t,id:i,key:i,item:t,tabIndex:e.tabIndex||0,onClick:A})),J&&n.createElement("hr",{className:"k-hr"}),v&&v.map((t,i)=>n.createElement(K.ActionSheetItem,{...t,id:i+((r==null?void 0:r.length)||0),key:i,item:t,tabIndex:e.tabIndex||0,onClick:A})))),u[X.footerDisplayName]));return n.createElement(n.Fragment,null,e.expand||l.show?n.createElement("div",{className:"k-actionsheet-container"},n.createElement("div",{className:"k-overlay",onClick:z}),e.animation?n.createElement(W.Animation,{transitionName:l.slide?"slide-up":"slide-down",onExited:b,transitionEnterDuration:typeof o=="object"&&Object.keys(o).length>0&&o.openDuration?Number(o.openDuration):Number(o),transitionExitDuration:typeof o=="object"&&Object.keys(o).length>0&&o.closeDuration?Number(o.closeDuration):Number(o),animationEnteringStyle:e.animationStyles||C.current,animationEnteredStyle:e.animationStyles||C.current,animationExitingStyle:e.animationStyles||C.current,exit:!0,enter:!0,appear:!1},j):j):null)}),N={navigatable:!0,navigatableElements:[],position:"bottom"};w.propTypes={items:d.array,subTitle:d.node,title:d.node,navigatable:d.bool,navigatableElements:d.array,position:d.oneOf(["top","bottom","left","right","fullscreen"])};w.displayName="KendoReactActionSheet";exports.ActionSheet=w;exports.actionSheetDefaultProps=N;