UNPKG

@progress/kendo-react-listview

Version:

React ListView enables you to display a custom layout of data items. KendoReact ListView package

16 lines (15 loc) 3.77 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ /** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@progress/kendo-react-common")):"function"==typeof define&&define.amd?define(["exports","react","@progress/kendo-react-common"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactListview={},e.React,e.KendoReactCommon)}(this,(function(e,t,s){"use strict";function a(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var a=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,a.get?a:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}var r=a(t);const n={name:"@progress/kendo-react-listview",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"10.1.0",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},l="k-focus",o=r.forwardRef(((e,t)=>{const a=!s.validatePackage(n,{component:"ListView"}),{data:o=[],item:i,footer:c,header:d,className:u,style:m,onScroll:f,navigatable:v}=e,p=r.useRef(null),w=r.useRef(null),E=r.useCallback((()=>({onScroll:f,props:e,context:{},state:{},refs:{}})),[]);r.useImperativeHandle(w,E),r.useImperativeHandle(t,(()=>w.current));const k=r.useCallback((e=>s.dispatchEvent(f,e,E(),void 0)),[]),y=(e,t,s)=>{s.preventDefault(),t.focusNext(e),t.next(e).classList.add(l),t.previous(e).classList.remove(l)},b=(e,t,s)=>{s.preventDefault(),t.focusPrevious(e),t.next(e).classList.remove(l),t.previous(e).classList.add(l)},N=r.useMemo((()=>new s.Navigation({root:p,selectors:[".k-listview-item"],rovingTabIndex:!0,keyboardEvents:{keydown:{ArrowDown:y,ArrowRight:y,ArrowUp:b,ArrowLeft:b,Home:(e,t,s)=>{s.preventDefault();const a=t.first;a&&t.focusElement(a,e)},End:(e,t,s)=>{s.preventDefault();const a=t.last;a&&t.focusElement(a,e)},Tab:(e,t,s)=>{t.removeFocusClass(e)}}},tabIndex:0,focusClass:l})),[]),g=r.useCallback(N.triggerKeyboardEvent.bind(N),[]),L=r.useCallback((e=>{e.nativeEvent.target.classList.add(l),N.elements.forEach((t=>{t!==e.nativeEvent.target&&t.classList.remove(l)}))}),[]);return r.useEffect((()=>{if(v)return N.initializeRovingTab(),()=>N.removeFocusListener()}),[]),r.createElement("div",{className:s.classNames("k-listview",u),style:m,onKeyDown:e=>v&&g(e),onClick:L},d?r.createElement(d,null):null,r.createElement("div",{role:"list",className:"k-listview-content",onScroll:k,ref:p},i&&o.map(((e,t)=>r.createElement(i,{dataItem:e,index:t,key:t})))),c?r.createElement(c,null):null,a&&r.createElement(s.WatermarkOverlay,null))}));o.displayName="KendoReactListView";e.ListView=o,e.ListViewFooter=e=>r.createElement("div",{className:s.classNames("k-listview-footer",e.className),style:e.style},e.children),e.ListViewHeader=e=>r.createElement("div",{className:s.classNames("k-listview-header",e.className),style:e.style},e.children),e.ListViewItemWrapper=e=>{const{children:t,style:a,className:n}=e;return r.createElement("div",{role:"listitem",style:a,className:s.classNames("k-listview-item",n)},t)}}));