@progress/kendo-react-spreadsheet
Version:
KendoReact Spreadsheet package
9 lines (8 loc) • 3.86 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
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("react"),p=require("@progress/kendo-react-buttons"),v=require("@progress/kendo-react-common"),a=require("@progress/kendo-svg-icons"),I=require("@progress/kendo-react-intl"),t=require("../messages.js");function K(n){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const c in n)if(c!=="default"){const s=Object.getOwnPropertyDescriptor(n,c);Object.defineProperty(i,c,s.get?s:{enumerable:!0,get:()=>n[c]})}}return i.default=n,Object.freeze(i)}const g=K(N),r=[{icon:"align-left",svgIcon:a.alignLeftIcon,textKey:t.keys.alignLeft,commandName:"textAlign",value:"left",selected:!1},{icon:"align-center",svgIcon:a.alignCenterIcon,textKey:t.keys.alignCenter,commandName:"textAlign",value:"center",selected:!1},{icon:"align-right",svgIcon:a.alignRightIcon,textKey:t.keys.alignRight,commandName:"textAlign",value:"right",selected:!1},{icon:"align-justify",svgIcon:a.alignJustifyIcon,textKey:t.keys.alignJustify,commandName:"textAlign",value:"justify",selected:!1},{icon:"align-top",svgIcon:a.alignTopIcon,textKey:t.keys.alignTop,commandName:"verticalAlign",value:"top",selected:!1},{icon:"align-middle",svgIcon:a.alignMiddleIcon,textKey:t.keys.alignMiddle,commandName:"verticalAlign",value:"center",selected:!1},{icon:"align-bottom",svgIcon:a.alignBottomIcon,textKey:t.keys.alignBottom,commandName:"verticalAlign",value:"bottom",selected:!1}],b=[r[0],{...r[1],textKey:t.keys.center},r[2],{...r[3],textKey:t.keys.justify}],C=r.filter(n=>n.commandName==="verticalAlign"),x=n=>{const{value:i,spreadsheetRef:c}=n,{textAlign:s,verticalAlign:u}=i||{},d=I.useLocalization(),y=g.useCallback(e=>{if(c.current){const m=e.item,o={command:"PropertyChangeCommand",options:{property:m.commandName,value:m.value||null}};c.current.executeCommand(o)}},[]);let l=r.slice();return l=l.map(e=>({...e,text:d.toLanguageString(e.textKey,t.messages[e.textKey])})),s&&(l=l.map(e=>e.commandName==="textAlign"?{...e,selected:e.value===s}:e)),u&&(l=l.map(e=>e.commandName==="verticalAlign"?{...e,selected:e.value===u}:e)),g.createElement(p.DropDownButton,{icon:"align-left",svgIcon:a.alignLeftIcon,items:l,fillMode:"flat",onItemClick:y,title:d.toLanguageString(t.keys.align,t.messages[t.keys.align]),text:g.createElement(v.IconWrap,{name:"caret-alt-down",icon:a.caretAltDownIcon})})};x.displayName="Alignment";const L={items:b,icon:{icon:"align-left",svgIcon:a.alignLeftIcon},displayName:"AlignHorizontally",titleKey:t.keys.alignHorizontally},z={items:C,icon:{icon:"align-bottom",svgIcon:a.alignBottomIcon},displayName:"AlignVertically",titleKey:t.keys.alignVertically},A=n=>{const i=c=>{const{value:s,spreadsheetRef:u}=c,d=I.useLocalization(),y=g.useCallback(o=>{if(u.current){const f=o.item,k={command:"PropertyChangeCommand",options:{property:f.commandName,value:f.value||null}};u.current.executeCommand(k)}},[]);let l=n.items.slice();l=l.map(o=>({...o,text:d.toLanguageString(o.textKey,t.messages[o.textKey])})),l=l.map(o=>({...o,selected:o.value===s}));const e={...n.icon},m=l.find(o=>o.selected);return m&&(e.icon=m.icon,e.svgIcon=m.svgIcon),g.createElement(p.DropDownButton,{...e,items:l,fillMode:"flat",onItemClick:y,title:d.toLanguageString(n.titleKey,t.messages[n.titleKey]),text:g.createElement(v.IconWrap,{name:"caret-alt-down",icon:a.caretAltDownIcon})})};return i.displayName=n.displayName,i},R=A(L),S=A(z);exports.AlignHorizontally=R;exports.AlignVertically=S;exports.Alignment=x;