UNPKG

@progress/kendo-react-grid

Version:

React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package

10 lines (9 loc) 5.13 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use client"; "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),q=require("react-dom"),I=require("@progress/kendo-react-layout"),s=require("@progress/kendo-react-buttons"),o=require("@progress/kendo-react-labels"),x=require("@progress/kendo-react-intl"),M=require("@progress/kendo-react-dateinputs"),_=require("@progress/kendo-react-common"),m=require("@progress/kendo-svg-icons"),L=require("@progress/kendo-react-inputs"),T=require("@progress/kendo-react-data-tools"),y=require("@progress/kendo-react-dialogs"),r=require("@progress/kendo-react-form"),A=require("../utils/GridContext.js"),i=require("../messages/index.js"),w=l=>{var R;const S=x.useLocalization(),E=_.useAdaptiveModeContext(),n=e.useContext(A.GridContext),u=(a,t)=>{n.onDialogEditSubmit&&n.onDialogEditSubmit({dataItem:a,syntheticEvent:t})},c=a=>{n.onDialogEditCancel&&n.onDialogEditCancel({syntheticEvent:a})},N=a=>{const{validationMessage:t,visited:z,id:v,valid:O,editor:p,value:b,label:f,...k}=a,C=n.mobileMode?"large":"medium";switch(p){case"numeric":return e.createElement(e.Fragment,null,e.createElement(o.Label,{editorId:v,className:"k-form-label"},f,":"),e.createElement("div",{className:"k-form-field-wrap"},e.createElement(L.NumericTextBox,{...k,size:C,value:b,[T.TABLE_PREVENT_SELECTION_ELEMENT]:!0}),t&&e.createElement(o.Error,null,t)));case"date":return e.createElement(e.Fragment,null,e.createElement(o.Label,{editorId:v,className:"k-form-label"},f,":"),e.createElement("div",{className:"k-form-field-wrap"},e.createElement(M.DatePicker,{valid:!0,...k,value:b,adaptive:n.mobileMode,size:C,[T.TABLE_PREVENT_SELECTION_ELEMENT]:!0}),t&&e.createElement(o.Error,null,t)));case"boolean":return e.createElement("div",{className:"k-form-field-wrap"},e.createElement(o.Label,{editorId:v,className:"k-form-label"},f,":  ",e.createElement(L.Checkbox,{...k,size:C,value:b,[T.TABLE_PREVENT_SELECTION_ELEMENT]:!0}),t&&e.createElement(o.Error,null,t)));default:return e.createElement(e.Fragment,null,e.createElement(o.Label,{editorId:v,className:"k-form-label"},f,":"),e.createElement("div",{className:"k-form-field-wrap"},e.createElement(L.TextBox,{...k,size:C,value:b||"",[T.TABLE_PREVENT_SELECTION_ELEMENT]:!0}),t&&e.createElement(o.Error,null,t)))}},D=S.toLanguageString(i.editDialogTitle,i.messages[i.editDialogTitle]),h=S.toLanguageString(i.editDialogSaveButtonTitle,i.messages[i.editDialogSaveButtonTitle]),B=S.toLanguageString(i.editDialogCancelButtonTitle,i.messages[i.editDialogCancelButtonTitle]),F={animation:!0,navigatable:!1,navigatableElements:[],expand:!0,title:n.adpativeTitle||D,suffixActions:e.createElement(s.Button,{svgIcon:m.xIcon,onClick:c,fillMode:"flat"}),animationStyles:E&&n.adaptiveColumnMenuRef<=E.small?{top:0,width:"100%",height:"100%"}:void 0,className:"k-adaptive-actionsheet",position:E&&n.adaptiveColumnMenuRef<=E.small?"fullscreen":void 0},{customEditDialog:g}=l,d=(R=l.columns)==null?void 0:R.filter(a=>a.editable);return e.createElement(e.Fragment,null,q.createPortal(e.createElement(e.Fragment,null,n.mobileMode?e.createElement(e.Fragment,null,g?e.createElement(g,{columns:l.columns,dataItem:l.dataItem,onSubmit:u,onCancel:c}):e.createElement(r.Form,{initialValues:l.dataItem,onSubmit:u,id:"kendo-grid-edit-dialog",render:a=>e.createElement(I.ActionSheet,{...F},e.createElement(I.ActionSheetContent,null,e.createElement(r.FormElement,null,d==null?void 0:d.map(t=>e.createElement(r.FieldWrapper,{key:t.field},e.createElement(r.Field,{name:t.field,id:t.field,editor:t.editor,component:N,label:t.title||t.field,validator:t==null?void 0:t.validator}))))),e.createElement(I.ActionSheetFooter,null,e.createElement(s.Button,{onClick:c,type:"reset",icon:"cancel",size:"large",svgIcon:m.cancelIcon},B),e.createElement(s.Button,{type:"submit",themeColor:"primary",size:"large",disabled:!a.allowSubmit||!a.valid,onClick:a.onSubmit,icon:"save",svgIcon:m.saveIcon},h)))})):g?e.createElement(g,{columns:l.columns,dataItem:l.dataItem,onSubmit:u,onCancel:c}):e.createElement(r.Form,{initialValues:l.dataItem,onSubmit:u,id:"kendo-grid-edit-dialog",render:a=>e.createElement(y.Dialog,{title:D,width:450,onClose:t=>c(t.syntheticEvent)},e.createElement(r.FormElement,null,d==null?void 0:d.map(t=>e.createElement(r.FieldWrapper,{key:t.field},e.createElement(r.Field,{name:t.field,id:t.field,editor:t.editor,component:N,label:t.title||t.field,validator:t==null?void 0:t.validator})))),e.createElement(y.DialogActionsBar,{layout:"start"},e.createElement(s.Button,{type:"submit",themeColor:"primary",disabled:!a.allowSubmit||!a.valid,onClick:a.onSubmit,icon:"save",svgIcon:m.saveIcon},h),e.createElement(s.Button,{onClick:c,type:"reset",icon:"cancel",svgIcon:m.cancelIcon},B)))})),document.body))};exports.GridEditDialog=w;