123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110 |
- import {
- Hn,
- Oe,
- Ut,
- tt as tt2
- } from "./chunk-ALDCSYO3.js";
- import {
- $m,
- Bn,
- D2,
- Er,
- Et,
- Gm,
- Gt,
- Hr,
- Jm,
- Ks,
- Lt,
- Nn,
- Pt as Pt2,
- Sn,
- Td,
- Uo,
- Wn,
- _1 as _12,
- bi,
- ef,
- go,
- gr,
- ke,
- me,
- mn,
- pn,
- rE,
- rt as rt2,
- tf,
- tt,
- ue,
- ut,
- xd,
- yr as yr2
- } from "./chunk-T4NNB5UY.js";
- import {
- Aa,
- Ae as Ae2,
- Br,
- Ce,
- F,
- Go,
- Kd,
- Me,
- N,
- Pe,
- Q,
- Te,
- V,
- Xa,
- an,
- et,
- re as re2,
- wh,
- wn,
- zd
- } from "./chunk-BW43Z7N3.js";
- import {
- $e as $e2,
- Fb,
- Fi,
- Ji,
- Ju,
- K,
- Pr,
- X,
- bs,
- ca,
- en as en2,
- fn,
- fr,
- m as m2,
- pc,
- yr,
- zi
- } from "./chunk-QRYBFJ3R.js";
- import {
- He,
- Se,
- at,
- ct,
- dA,
- kn,
- lA,
- mA
- } from "./chunk-MIOQ566M.js";
- import {
- $e,
- Ae,
- Bl,
- Fa,
- I1,
- Le,
- Pi,
- Wt,
- _1,
- f1,
- i3,
- it,
- l1,
- m1,
- n1,
- n3,
- rt,
- u3,
- zl
- } from "./chunk-POAJ2YNP.js";
- import {
- Gf,
- JO,
- Po,
- QC,
- r_,
- rg
- } from "./chunk-GBYP4PB2.js";
- import {
- M,
- m
- } from "./chunk-PZD7N4BC.js";
- import {
- $,
- Sx,
- Yx,
- i2,
- vf
- } from "./chunk-2MK3Q52E.js";
- import {
- Af,
- B0,
- BehaviorSubject,
- CR,
- Ct,
- DC,
- De,
- Dt,
- Fe,
- J0,
- Mf,
- Mi,
- Mt,
- Nr,
- Nt,
- OR,
- Observable,
- Ot,
- Pt,
- Ra,
- SE,
- Subject,
- Vn,
- Vr,
- W0,
- Wd,
- Ze,
- _n,
- ar,
- combineLatestWith,
- debounceTime,
- distinctUntilChanged,
- dn,
- en,
- fC,
- filter,
- fs,
- gC,
- iu,
- k0,
- kt,
- map,
- merge,
- ml,
- noop,
- nt,
- nu,
- oE,
- of,
- ot,
- qt,
- re,
- st,
- su,
- switchMap,
- throttleTime,
- vC,
- wu,
- yC,
- z0
- } from "./chunk-23V3HWTR.js";
- import {
- require_react
- } from "./chunk-GNR2UJZM.js";
- import {
- __toESM
- } from "./chunk-2LSFTFF7.js";
- // node_modules/.pnpm/@univerjs+sheets-formula-ui@0.5.5_@grpc+grpc-js@1.13.4_react-dom@18.3.1_react@18.3.1_rxjs@7.8.1_typescript@5.4.5/node_modules/@univerjs/sheets-formula-ui/lib/es/index.js
- var import_react = __toESM(require_react());
- var ro = Object.defineProperty;
- var oo = (e, t, n) => t in e ? ro(e, t, { enumerable: true, configurable: true, writable: true, value: n }) : e[t] = n;
- var Q2 = (e, t, n) => oo(e, typeof t != "symbol" ? t + "" : t, n);
- var Sn2 = {
- id: "sheet.command.paste-formula",
- type: ar.COMMAND,
- handler: async (e) => e.get(Pt).executeCommand(mn.id, {
- value: rt2.SPECIAL_PASTE_FORMULA
- })
- };
- var ut2 = {
- id: "formula-ui.operation.select-editor-formula",
- type: ar.OPERATION,
- handler: (e, t) => true
- };
- var Ms = Object.defineProperty;
- var Ps = Object.getOwnPropertyDescriptor;
- var As = (e, t, n, o) => {
- for (var r = o > 1 ? void 0 : o ? Ps(t, n) : t, i = e.length - 1, s; i >= 0; i--)
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
- return o && r && Ms(t, n, r), r;
- };
- var Ls = (e, t) => (n, o) => t(n, o, e);
- var ws = "FORMULA_PROMPT_ACTIVATED";
- var Nt2 = Ct("formula-ui.prompt-service");
- var an2 = class {
- constructor(e) {
- Q2(this, "_search$", new Subject());
- Q2(this, "_help$", new Subject());
- Q2(this, "_navigate$", new Subject());
- Q2(this, "_accept$", new Subject());
- Q2(this, "_acceptFormulaName$", new Subject());
- Q2(this, "search$", this._search$.asObservable());
- Q2(this, "help$", this._help$.asObservable());
- Q2(this, "navigate$", this._navigate$.asObservable());
- Q2(this, "accept$", this._accept$.asObservable());
- Q2(this, "acceptFormulaName$", this._acceptFormulaName$.asObservable());
- Q2(this, "_searching", false);
- Q2(this, "_helping", false);
- Q2(this, "_sequenceNodes", []);
- Q2(this, "_isLockedOnSelectionChangeRefString", false);
- Q2(this, "_isLockedOnSelectionInsertRefString", false);
- this._contextService = e;
- }
- dispose() {
- this._search$.complete(), this._help$.complete(), this._navigate$.complete(), this._accept$.complete(), this._acceptFormulaName$.complete(), this._sequenceNodes = [];
- }
- search(e) {
- this._contextService.setContextValue(ws, e.visible), this._searching = e.visible, this._search$.next(e);
- }
- isSearching() {
- return this._searching;
- }
- help(e) {
- this._helping = e.visible, this._help$.next(e);
- }
- isHelping() {
- return this._helping;
- }
- navigate(e) {
- this._navigate$.next(e);
- }
- accept(e) {
- this._accept$.next(e);
- }
- acceptFormulaName(e) {
- this._acceptFormulaName$.next(e);
- }
- getSequenceNodes() {
- return [...this._sequenceNodes];
- }
- setSequenceNodes(e) {
- this._sequenceNodes = e;
- }
- clearSequenceNodes() {
- this._sequenceNodes = [];
- }
- getCurrentSequenceNode(e) {
- return this._sequenceNodes[this.getCurrentSequenceNodeIndex(e)];
- }
- getCurrentSequenceNodeByIndex(e) {
- return this._sequenceNodes[e];
- }
- /**
- * Query the text coordinates in the sequenceNodes and determine the actual insertion index.
- * @param strIndex
- */
- getCurrentSequenceNodeIndex(e) {
- let t = 0;
- const n = this._sequenceNodes[0];
- for (let o = 0, r = this._sequenceNodes.length; o < r; o++) {
- const i = this._sequenceNodes[o];
- if (typeof i == "string")
- t++;
- else {
- const { endIndex: s } = i;
- t = s;
- }
- if (e <= t)
- return typeof n == "string" && e !== 0 ? o + 1 : o;
- }
- return this._sequenceNodes.length;
- }
- /**
- * Synchronize the reference text based on the changes of the selection.
- * @param nodeIndex
- * @param refString
- */
- updateSequenceRef(e, t) {
- const n = this._sequenceNodes[e];
- if (typeof n == "string" || n.nodeType !== $e2.REFERENCE)
- return;
- const o = t.length - n.token.length, r = { ...n };
- r.token = t, r.endIndex += o, this._sequenceNodes[e] = r;
- for (let i = e + 1, s = this._sequenceNodes.length; i < s; i++) {
- const c = this._sequenceNodes[i];
- if (typeof c == "string")
- continue;
- const a = { ...c };
- a.startIndex += o, a.endIndex += o, this._sequenceNodes[i] = a;
- }
- }
- /**
- * When the cursor is on the right side of a formula token,
- * you can add reference text to the formula by drawing a selection.
- * @param index
- * @param refString
- */
- insertSequenceRef(e, t) {
- const n = t.length, o = this.getCurrentSequenceNodeIndex(e);
- this._sequenceNodes.splice(o, 0, {
- token: t,
- startIndex: e,
- endIndex: e + n - 1,
- nodeType: $e2.REFERENCE
- });
- for (let r = o + 1, i = this._sequenceNodes.length; r < i; r++) {
- const s = this._sequenceNodes[r];
- if (typeof s == "string")
- continue;
- const c = { ...s };
- c.startIndex += n, c.endIndex += n, this._sequenceNodes[r] = c;
- }
- }
- /**
- * Insert a string at the cursor position in the text corresponding to the sequenceNodes.
- * @param index
- * @param content
- */
- insertSequenceString(e, t) {
- const n = this.getCurrentSequenceNodeIndex(e), o = t.split("");
- this._sequenceNodes.splice(n, 0, ...o);
- const r = o.length;
- for (let i = n + r, s = this._sequenceNodes.length; i < s; i++) {
- const c = this._sequenceNodes[i];
- if (typeof c == "string")
- continue;
- const a = { ...c };
- a.startIndex += r, a.endIndex += r, this._sequenceNodes[i] = a;
- }
- }
- enableLockedSelectionChange() {
- this._isLockedOnSelectionChangeRefString = true;
- }
- disableLockedSelectionChange() {
- this._isLockedOnSelectionChangeRefString = false;
- }
- isLockedSelectionChange() {
- return this._isLockedOnSelectionChangeRefString;
- }
- enableLockedSelectionInsert() {
- this._isLockedOnSelectionInsertRefString = true;
- }
- disableLockedSelectionInsert() {
- this._isLockedOnSelectionInsertRefString = false;
- }
- isLockedSelectionInsert() {
- return this._isLockedOnSelectionInsertRefString;
- }
- };
- an2 = As([
- Ls(0, fs)
- ], an2);
- var $s = {
- id: "formula-ui.operation.help-function",
- type: ar.OPERATION,
- handler: async (e, t) => (e.get(Nt2).help(t), true)
- };
- var vn = {
- id: "formula-ui.operation.insert-function",
- type: ar.OPERATION,
- // eslint-disable-next-line max-lines-per-function
- handler: async (e, t) => {
- var C, _;
- const n = e.get(F), o = e.get(He), r = n.getCurrentSelections();
- if (!r || !r.length)
- return false;
- const i = N(e.get(_n));
- if (!i)
- return false;
- const { worksheet: s, unitId: c, subUnitId: a } = i, d = s.getCellMatrix(), { value: u } = t, h = e.get(Pt), f = e.get(tt), g = [];
- let l = null, m3 = 0, S = 0, R = "";
- if (r.length === 1 && (js(r[0].range) || Hs(r[0].range))) {
- const { range: E, primary: x } = r[0], M2 = (C = x == null ? void 0 : x.actualRow) != null ? C : E.startRow, T = (_ = x == null ? void 0 : x.actualColumn) != null ? _ : E.startColumn;
- l = E, m3 = M2, S = T;
- const P = Kn(d, M2, T);
- P && (R = fr(P));
- } else
- r.some((E) => {
- var w, I;
- const { range: x, primary: M2 } = E, T = (w = M2 == null ? void 0 : M2.actualRow) != null ? w : x.startRow, P = (I = M2 == null ? void 0 : M2.actualColumn) != null ? I : x.startColumn, A = Kn(d, T, P);
- if (!A)
- return l = x, m3 = T, S = P, true;
- const N2 = fr(A), b = `=${u}(${N2})`;
- return g.push({
- range: x,
- primary: {
- row: T,
- column: P
- },
- formula: b
- }), false;
- });
- if (l) {
- const E = zd(m3, S, s), x = {
- range: en.clone(l),
- primary: {
- startRow: E.startRow,
- startColumn: E.startColumn,
- endRow: E.endRow,
- endColumn: E.endColumn,
- actualRow: m3,
- actualColumn: S,
- isMerged: E.isMerged,
- isMergedMainCell: E.startRow === m3 && E.startColumn === S
- }
- }, M2 = {
- unitId: c,
- subUnitId: a,
- selections: [x]
- };
- await h.executeCommand(re2.id, M2);
- const T = o.getEditor(su), P = o.getEditor(iu);
- f.changeVisible({
- visible: true,
- unitId: c,
- eventType: vf.Dblclick
- });
- const A = `=${u}(${R}`;
- T == null || T.replaceText(A), P == null || P.replaceText(A, false);
- }
- return g.length === 0 ? false : h.executeCommand(Hn.id, {
- list: g
- });
- }
- };
- function Kn(e, t, n) {
- const o = Ds(e, t, n);
- if (o !== t)
- return {
- startRow: o,
- endRow: t - 1,
- startColumn: n,
- endColumn: n
- };
- const r = ks(e, t, n);
- return r !== n ? {
- startRow: t,
- endRow: t,
- startColumn: r,
- endColumn: n - 1
- } : null;
- }
- function Ds(e, t, n) {
- let o = false;
- if (t === 0)
- return t;
- for (let r = t - 1; r >= 0; r--) {
- const i = e.getValue(r, n);
- if (Ot2(i) && !o) {
- if (r === 0)
- return 0;
- o = true;
- } else {
- if (o && !Ot2(i))
- return r + 1;
- if (o && r === 0)
- return 0;
- }
- }
- return t;
- }
- function ks(e, t, n) {
- let o = false;
- if (n === 0)
- return n;
- for (let r = n - 1; r >= 0; r--) {
- const i = e.getValue(t, r);
- if (Ot2(i) && !o) {
- if (r === 0)
- return 0;
- o = true;
- } else {
- if (o && !Ot2(i))
- return r + 1;
- if (o && r === 0)
- return 0;
- }
- }
- return n;
- }
- function Ot2(e) {
- if (e != null && e.p) {
- const t = e == null ? void 0 : e.p.body;
- if (t == null)
- return false;
- const n = t.dataStream, r = n.substring(n.length - 2, n.length) === Wd ? n.substring(0, n.length - 2) : n;
- return DC(r);
- }
- return e && (e.t === dn.NUMBER || gC(e) === dn.NUMBER);
- }
- function js(e) {
- return e.startRow === e.endRow && e.startColumn === e.endColumn;
- }
- function Hs(e) {
- return e.startRow !== e.endRow && e.startColumn !== e.endColumn;
- }
- var Or = "SHEET_FORMULA_UI_PLUGIN";
- var Mr = `${Or}_MORE_FUNCTIONS_COMPONENT`;
- var Cn = {
- id: "formula-ui.operation.more-functions",
- type: ar.OPERATION,
- handler: async (e) => (e.get(rt).open({
- header: { title: "formula.insert.tooltip" },
- children: { label: Mr }
- }), true)
- };
- var Pr2 = {
- id: "formula-ui.operation.change-ref-to-absolute",
- type: ar.OPERATION,
- handler: async (e) => true
- };
- var Ws = {
- id: "formula-ui.operation.search-function",
- type: ar.OPERATION,
- handler: async (e, t) => (e.get(Nt2).search(t), true)
- };
- var Xt = { exports: {} };
- var ht = {};
- var Yn;
- function Us() {
- if (Yn)
- return ht;
- Yn = 1;
- var e = import_react.default, t = Symbol.for("react.element"), n = Symbol.for("react.fragment"), o = Object.prototype.hasOwnProperty, r = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: true, ref: true, __self: true, __source: true };
- function s(c, a, d) {
- var u, h = {}, f = null, g = null;
- d !== void 0 && (f = "" + d), a.key !== void 0 && (f = "" + a.key), a.ref !== void 0 && (g = a.ref);
- for (u in a)
- o.call(a, u) && !i.hasOwnProperty(u) && (h[u] = a[u]);
- if (c && c.defaultProps)
- for (u in a = c.defaultProps, a)
- h[u] === void 0 && (h[u] = a[u]);
- return { $$typeof: t, type: c, key: f, ref: g, props: h, _owner: r.current };
- }
- return ht.Fragment = n, ht.jsx = s, ht.jsxs = s, ht;
- }
- var zn;
- function Vs() {
- return zn || (zn = 1, Xt.exports = Us()), Xt.exports;
- }
- var p = Vs();
- var Ie = function() {
- return Ie = Object.assign || function(e) {
- for (var t, n = 1, o = arguments.length; n < o; n++) {
- t = arguments[n];
- for (var r in t)
- Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]);
- }
- return e;
- }, Ie.apply(this, arguments);
- };
- var Bs = function(e, t) {
- var n = {};
- for (var o in e)
- Object.prototype.hasOwnProperty.call(e, o) && t.indexOf(o) < 0 && (n[o] = e[o]);
- if (e != null && typeof Object.getOwnPropertySymbols == "function")
- for (var r = 0, o = Object.getOwnPropertySymbols(e); r < o.length; r++)
- t.indexOf(o[r]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[r]) && (n[o[r]] = e[o[r]]);
- return n;
- };
- var Ye = (0, import_react.forwardRef)(function(e, t) {
- var n = e.icon, o = e.id, r = e.className, i = e.extend, s = Bs(e, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(o, " ").concat(r || "").trim(), a = (0, import_react.useRef)("_".concat(Ys()));
- return Ar(n, "".concat(o), { defIds: n.defIds, idSuffix: a.current }, Ie({ ref: t, className: c }, s), i);
- });
- function Ar(e, t, n, o, r) {
- return (0, import_react.createElement)(e.tag, Ie(Ie({ key: t }, qs(e, n, r)), o), (Ks2(e, n).children || []).map(function(i, s) {
- return Ar(i, "".concat(t, "-").concat(e.tag, "-").concat(s), n, void 0, r);
- }));
- }
- function qs(e, t, n) {
- var o = Ie({}, e.attrs);
- n != null && n.colorChannel1 && o.fill === "colorChannel1" && (o.fill = n.colorChannel1);
- var r = t.defIds;
- return !r || r.length === 0 || (e.tag === "use" && o["xlink:href"] && (o["xlink:href"] = o["xlink:href"] + t.idSuffix), Object.entries(o).forEach(function(i) {
- var s = i[0], c = i[1];
- typeof c == "string" && (o[s] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
- })), o;
- }
- function Ks2(e, t) {
- var n, o = t.defIds;
- return !o || o.length === 0 ? e : e.tag === "defs" && (!((n = e.children) === null || n === void 0) && n.length) ? Ie(Ie({}, e), { children: e.children.map(function(r) {
- return typeof r.attrs.id == "string" && o && o.indexOf(r.attrs.id) > -1 ? Ie(Ie({}, r), { attrs: Ie(Ie({}, r.attrs), { id: r.attrs.id + t.idSuffix }) }) : r;
- }) }) : e;
- }
- function Ys() {
- return Math.random().toString(36).substring(2, 8);
- }
- Ye.displayName = "UniverIcon";
- var zs = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
- var Lr = (0, import_react.forwardRef)(function(e, t) {
- return (0, import_react.createElement)(Ye, Object.assign({}, e, {
- id: "check-mark-single",
- ref: t,
- icon: zs
- }));
- });
- Lr.displayName = "CheckMarkSingle";
- var Zs = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z" } }] };
- var Bt = (0, import_react.forwardRef)(function(e, t) {
- return (0, import_react.createElement)(Ye, Object.assign({}, e, {
- id: "close-single",
- ref: t,
- icon: Zs
- }));
- });
- Bt.displayName = "CloseSingle";
- var Gs = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
- var wr = (0, import_react.forwardRef)(function(e, t) {
- return (0, import_react.createElement)(Ye, Object.assign({}, e, {
- id: "delete-single",
- ref: t,
- icon: Gs
- }));
- });
- wr.displayName = "DeleteSingle";
- var Xs = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.75 5.32495C8.75 5.73916 8.41421 6.07495 8 6.07495 7.58579 6.07495 7.25 5.73916 7.25 5.32495 7.25 4.91074 7.58579 4.57495 8 4.57495 8.41421 4.57495 8.75 4.91074 8.75 5.32495zM8.5999 7.52505C8.5999 7.19368 8.33127 6.92505 7.9999 6.92505 7.66853 6.92505 7.3999 7.19368 7.3999 7.52505V11.425C7.3999 11.7564 7.66853 12.025 7.9999 12.025 8.33127 12.025 8.5999 11.7564 8.5999 11.425V7.52505z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M0.899902 8.00002C0.899902 4.0788 4.07868 0.900024 7.9999 0.900024C11.9211 0.900024 15.0999 4.0788 15.0999 8.00002C15.0999 11.9212 11.9211 15.1 7.9999 15.1C4.07868 15.1 0.899902 11.9212 0.899902 8.00002ZM7.9999 2.10002C4.74142 2.10002 2.0999 4.74154 2.0999 8.00002C2.0999 11.2585 4.74142 13.9 7.9999 13.9C11.2584 13.9 13.8999 11.2585 13.8999 8.00002C13.8999 4.74154 11.2584 2.10002 7.9999 2.10002Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
- var $r = (0, import_react.forwardRef)(function(e, t) {
- return (0, import_react.createElement)(Ye, Object.assign({}, e, {
- id: "details-single",
- ref: t,
- icon: Xs
- }));
- });
- $r.displayName = "DetailsSingle";
- var Js = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z" } }] };
- var Dr = (0, import_react.forwardRef)(function(e, t) {
- return (0, import_react.createElement)(Ye, Object.assign({}, e, {
- id: "increase-single",
- ref: t,
- icon: Js
- }));
- });
- Dr.displayName = "IncreaseSingle";
- var Qs = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.90913 3.57564C6.14345 3.34132 6.52335 3.34132 6.75766 3.57564L10.7577 7.57564C10.992 7.80995 10.992 8.18985 10.7577 8.42417L6.75766 12.4242C6.52335 12.6585 6.14345 12.6585 5.90913 12.4242C5.67482 12.1899 5.67482 11.81 5.90913 11.5756L9.48487 7.9999L5.90913 4.42417C5.67482 4.18985 5.67482 3.80995 5.90913 3.57564Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
- var _n2 = (0, import_react.forwardRef)(function(e, t) {
- return (0, import_react.createElement)(Ye, Object.assign({}, e, {
- id: "more-single",
- ref: t,
- icon: Qs
- }));
- });
- _n2.displayName = "MoreSingle";
- var ei = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M12.6185 12.4423C12.5907 12.2749 12.7773 12.15 12.9343 12.2308L15.4242 13.5126C15.6102 13.6084 15.5544 13.8745 15.3439 13.8955L14.2456 14.184L13.4521 15.1286C13.3495 15.2939 13.085 15.2463 13.0534 15.0568L12.6185 12.4423Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1 3.6C1 2.16406 2.16406 1 3.6 1H12.3C13.7359 1 14.9 2.16406 14.9 3.6V5.81156C14.9003 5.81881 14.9004 5.82609 14.9004 5.8334C14.9004 5.84071 14.9003 5.84799 14.9 5.85524V10.045C14.9003 10.0522 14.9004 10.0595 14.9004 10.0668C14.9004 10.3982 14.6318 10.6668 14.3004 10.6668H11.1668C10.8907 10.6668 10.6668 10.8907 10.6668 11.1668V14.3C10.6668 14.6314 10.3982 14.9 10.0668 14.9L10.05 14.8998L3.6 14.9C2.16406 14.9 1 13.7359 1 12.3V3.6ZM13.2 5.2334C13.4761 5.2334 13.7 5.00954 13.7 4.7334V3.6C13.7 2.8268 13.0732 2.2 12.3 2.2H11.1668C10.8907 2.2 10.6668 2.42386 10.6668 2.7V4.7334C10.6668 5.00954 10.8907 5.2334 11.1668 5.2334H13.2ZM10.6668 6.9334C10.6668 6.65726 10.8907 6.4334 11.1668 6.4334H13.2C13.4761 6.4334 13.7 6.65726 13.7 6.9334V8.9668C13.7 9.24294 13.4761 9.4668 13.2 9.4668H11.1668C10.8907 9.4668 10.6668 9.24294 10.6668 8.9668V6.9334ZM8.9668 5.2334C9.24294 5.2334 9.4668 5.00954 9.4668 4.7334V2.7C9.4668 2.42386 9.24294 2.2 8.9668 2.2H6.9334C6.65726 2.2 6.4334 2.42386 6.4334 2.7V4.7334C6.4334 5.00954 6.65726 5.2334 6.9334 5.2334L8.9668 5.2334ZM6.4334 6.9334C6.4334 6.65726 6.65726 6.4334 6.9334 6.4334L8.9668 6.4334C9.24294 6.4334 9.4668 6.65726 9.4668 6.9334V8.9668C9.4668 9.24294 9.24294 9.4668 8.9668 9.4668L6.9334 9.4668C6.65726 9.4668 6.4334 9.24294 6.4334 8.9668V6.9334ZM4.7334 5.2334C5.00954 5.2334 5.2334 5.00954 5.2334 4.7334V2.7C5.2334 2.42386 5.00954 2.2 4.7334 2.2H3.6C2.8268 2.2 2.2 2.8268 2.2 3.6V4.7334C2.2 5.00954 2.42386 5.2334 2.7 5.2334H4.7334ZM2.2 6.9334C2.2 6.65726 2.42386 6.4334 2.7 6.4334H4.7334C5.00954 6.4334 5.2334 6.65725 5.2334 6.9334V8.9668C5.2334 9.24294 5.00954 9.4668 4.7334 9.4668H2.7C2.42386 9.4668 2.2 9.24294 2.2 8.9668V6.9334ZM5.2334 11.1668C5.2334 10.8907 5.00954 10.6668 4.7334 10.6668H2.7C2.42386 10.6668 2.2 10.8907 2.2 11.1668V12.3C2.2 13.0732 2.8268 13.7 3.6 13.7H4.7334C5.00954 13.7 5.2334 13.4761 5.2334 13.2V11.1668ZM9.4668 11.1668C9.4668 10.8907 9.24294 10.6668 8.9668 10.6668H6.9334C6.65726 10.6668 6.4334 10.8907 6.4334 11.1668V13.2C6.4334 13.4761 6.65726 13.7 6.9334 13.7H8.9668C9.24294 13.7 9.4668 13.4761 9.4668 13.2V11.1668Z", fillRule: "evenodd", clipRule: "evenodd" } }] };
- var kr = (0, import_react.forwardRef)(function(e, t) {
- return (0, import_react.createElement)(Ye, Object.assign({}, e, {
- id: "select-range-single",
- ref: t,
- icon: ei
- }));
- });
- kr.displayName = "SelectRangeSingle";
- function jr(e) {
- var t, n, o = "";
- if (typeof e == "string" || typeof e == "number")
- o += e;
- else if (typeof e == "object")
- if (Array.isArray(e)) {
- var r = e.length;
- for (t = 0; t < r; t++)
- e[t] && (n = jr(e[t])) && (o && (o += " "), o += n);
- } else
- for (n in e)
- e[n] && (o && (o += " "), o += n);
- return o;
- }
- function ln() {
- for (var e, t, n = 0, o = "", r = arguments.length; n < r; n++)
- (e = arguments[n]) && (t = jr(e)) && (o && (o += " "), o += t);
- return o;
- }
- var ti = Object.defineProperty;
- var ni = Object.getOwnPropertyDescriptor;
- var ri = (e, t, n, o) => {
- for (var r = o > 1 ? void 0 : o ? ni(t, n) : t, i = e.length - 1, s; i >= 0; i--)
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
- return o && r && ti(t, n, r), r;
- };
- var tt3 = (e, t) => (n, o) => t(n, o, e);
- var Fe2 = class extends ef {
- constructor(t, n, o, r, i, s, c) {
- super(
- n,
- o,
- r,
- i,
- s
- );
- Q2(this, "_workbookSelections");
- Q2(this, "_eventDisposables");
- this._context = t, this._contextService = s, this._refSelectionsService = c, this._workbookSelections = this._refSelectionsService.getWorkbookSelections(this._context.unitId), this._initSelectionChangeListener(), this._initSkeletonChangeListener(), this._initUserActionSyncListener(), this._setSelectionStyle(oi(this._themeService)), this._remainLastEnabled = true, this._highlightHeader = false;
- }
- getLocation() {
- return this._skeleton.getLocation();
- }
- setRemainLastEnabled(t) {
- this._remainLastEnabled = t;
- }
- /**
- * This is set to true when you need to add a new selection.
- * @param {boolean} enabled
- * @memberof RefSelectionsRenderService
- */
- setSkipLastEnabled(t) {
- this._skipLastEnabled = t;
- }
- clearLastSelection() {
- const t = this._selectionControls[this._selectionControls.length - 1];
- t && (t.dispose(), this._selectionControls.pop());
- }
- /**
- * Call this method and user will be able to select on the canvas to update selections.
- */
- enableSelectionChanging() {
- return this._disableSelectionChanging(), this._eventDisposables = this._initCanvasEventListeners(), Ze(() => this._disableSelectionChanging());
- }
- _disableSelectionChanging() {
- var t;
- (t = this._eventDisposables) == null || t.dispose(), this._eventDisposables = null;
- }
- disableSelectionChanging() {
- this._disableSelectionChanging();
- }
- _initCanvasEventListeners() {
- const t = this._getSheetObject(), { spreadsheetRowHeader: n, spreadsheetColumnHeader: o, spreadsheet: r, spreadsheetLeftTopPlaceholder: i } = t, { scene: s } = this._context, c = new Mi();
- return c.add(r == null ? void 0 : r.onPointerDown$.subscribeEvent((a, d) => {
- this.inRefSelectionMode() && (this._onPointerDown(a, r.zIndex + 1, De.NORMAL, this._getActiveViewport(a)), a.button !== 2 && d.stopPropagation());
- })), c.add(
- n == null ? void 0 : n.onPointerDown$.subscribeEvent((a, d) => {
- if (!this.inRefSelectionMode())
- return;
- const u = this._sheetSkeletonManagerService.getCurrent().skeleton, { row: h } = Nn(a.offsetX, a.offsetY, s, u);
- Uo(this._workbookSelections.getCurrentSelections(), h, De.ROW) || (this._onPointerDown(a, (r.zIndex || 1) + 1, De.ROW, this._getActiveViewport(a), Sx.Y), a.button !== 2 && d.stopPropagation());
- })
- ), c.add(o == null ? void 0 : o.onPointerDown$.subscribeEvent((a, d) => {
- if (!this.inRefSelectionMode())
- return;
- const u = this._sheetSkeletonManagerService.getCurrent().skeleton, { column: h } = Nn(a.offsetX, a.offsetY, s, u);
- Uo(this._workbookSelections.getCurrentSelections(), h, De.COLUMN) || (this._onPointerDown(a, (r.zIndex || 1) + 1, De.COLUMN, this._getActiveViewport(a), Sx.X), a.button !== 2 && d.stopPropagation());
- })), c.add(i == null ? void 0 : i.onPointerDown$.subscribeEvent((a, d) => {
- if (this._reset(), !this.inRefSelectionMode())
- return;
- const u = this._sheetSkeletonManagerService.getCurrent().skeleton, h = tf(u);
- this._addSelectionControlByModelData(h), this._selectionMoveStart$.next(this.getSelectionDataWithStyle());
- const f = s.onPointerUp$.subscribeEvent(() => {
- f.unsubscribe(), this._selectionMoveEnd$.next(this.getSelectionDataWithStyle());
- });
- a.button !== 2 && d.stopPropagation();
- })), c;
- }
- /**
- * Add a selection in spreadsheet, create a new SelectionControl and then update this control by range derives from selection.
- * For ref selection, create selectionShapeExtension to handle user action.
- * @param {ISelectionWithCoord} selectionWithStyle
- */
- _addSelectionControlByModelData(t) {
- var s;
- const n = this._skeleton, o = (s = t.style) != null ? s : yr2(this._themeService), r = this._scene;
- return t.style = o, this.newSelectionControl(r, n, t);
- }
- _initSelectionChangeListener() {
- this.disposeWithMe(this._refSelectionsService.selectionSet$.subscribe((t) => {
- this._reset(), this._skeleton && this.resetSelectionsByModelData(t || []);
- }));
- }
- /**
- * Update selectionModel in this._workbookSelections by user action in spreadsheet area.
- */
- _initUserActionSyncListener() {
- this.disposeWithMe(this.selectionMoveStart$.subscribe((t) => {
- this._updateSelections(t, Ce.MOVE_START);
- })), this.disposeWithMe(this.selectionMoving$.subscribe((t) => {
- this._updateSelections(t, Ce.MOVING);
- })), this.disposeWithMe(this.selectionMoveEnd$.subscribe((t) => {
- this._updateSelections(t, Ce.MOVE_END);
- }));
- }
- _updateSelections(t, n) {
- const r = this._context.unit.getActiveSheet().getSheetId();
- t.length !== 0 && this._workbookSelections.setSelections(
- r,
- t.map((i) => wh(i)),
- n
- );
- }
- _initSkeletonChangeListener() {
- this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((t) => {
- if (!t)
- return;
- const { skeleton: n } = t, { scene: o } = this._context, r = o.getViewport(i2.VIEW_MAIN);
- this._skeleton && this._skeleton.worksheet.getSheetId() !== n.worksheet.getSheetId() && this._reset(), this._changeRuntime(n, o, r);
- const i = this._workbookSelections.getCurrentSelections();
- this.resetSelectionsByModelData(i);
- }));
- }
- _getActiveViewport(t) {
- const n = this._getSheetObject();
- return n == null ? void 0 : n.scene.getActiveViewportByCoord($.FromArray([t.offsetX, t.offsetY]));
- }
- _getSheetObject() {
- return pn(this._context.unit, this._context);
- }
- /**
- * Handle pointer down event, bind pointermove & pointerup handler.
- * then trigger selectionMoveStart$.
- *
- * @param evt
- * @param _zIndex
- * @param rangeType
- * @param viewport
- * @param scrollTimerType
- */
- // eslint-disable-next-line complexity, max-lines-per-function
- _onPointerDown(t, n = 0, o = De.NORMAL, r, i = Sx.ALL) {
- var N2;
- this._rangeType = o;
- const s = this._skeleton, c = this._scene;
- if (!c || !s)
- return;
- r && (this._activeViewport = r);
- const { offsetX: a, offsetY: d } = t, u = c.getViewport(i2.VIEW_MAIN);
- if (!u)
- return;
- const h = c.getCoordRelativeToViewport($.FromArray([a, d])), { x: f, y: g } = h;
- this._startViewportPosX = f, this._startViewportPosY = g;
- const l = c.getScrollXYInfoByViewport(h), { scaleX: m3, scaleY: S } = c.getAncestorScale(), R = this._skeleton.getCellByOffset(f, g, m3, S, l);
- if (!R)
- return;
- switch (o) {
- case De.NORMAL:
- break;
- case De.ROW:
- R.startColumn = 0, R.endColumn = this._skeleton.getColumnCount() - 1;
- break;
- case De.COLUMN:
- R.startRow = 0, R.endRow = this._skeleton.getRowCount() - 1;
- break;
- case De.ALL:
- R.startRow = 0, R.startColumn = 0, R.endRow = this._skeleton.getRowCount() - 1, R.endColumn = this._skeleton.getColumnCount() - 1;
- }
- const C = { range: R, primary: R, style: null };
- C.range.rangeType = o;
- const _ = Pt2(C, this._skeleton);
- this._startRangeWhenPointerDown = { ..._.rangeWithCoord };
- const E = { ..._.rangeWithCoord, rangeType: o };
- let x = this.getActiveSelectionControl();
- const M2 = this.getSelectionControls();
- for (const b of M2) {
- if (t.button === 2 && b.model.isInclude(E)) {
- x = b;
- return;
- }
- if (b.model.isEqual(E)) {
- x = b;
- break;
- }
- }
- this._checkClearPreviousControls(t);
- const T = x == null ? void 0 : x.model.currentCell, P = t.shiftKey && T, A = this._remainLastEnabled && !t.ctrlKey && !t.shiftKey && !this._skipLastEnabled && !this._singleSelectionEnabled;
- P && T ? this._makeSelectionByTwoCells(
- T,
- E,
- s,
- o,
- x
- // Get updated in this method
- ) : A && x ? x.updateRangeBySelectionWithCoord(_) : x = this.newSelectionControl(c, s, C);
- for (let b = 0; b < this.getSelectionControls().length - 1; b++)
- this.getSelectionControls()[b].clearHighlight();
- this._selectionMoveStart$.next(this.getSelectionDataWithStyle()), c.disableObjectsEvent(), this._clearUpdatingListeners(), this._addEndingListeners(), (N2 = c.getTransformer()) == null || N2.clearSelectedObjects(), this._setupPointerMoveListener(u, x, o, i, f, g), this._escapeShortcutDisposable = this._shortcutService.forceEscape(), this._scenePointerUpSub = c.onPointerUp$.subscribeEvent(() => {
- var b;
- this._clearUpdatingListeners(), this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()), (b = this._escapeShortcutDisposable) == null || b.dispose(), this._escapeShortcutDisposable = null;
- });
- }
- /**
- * Diff between normal selection, no highlightHeader for ref selections.
- * @param scene
- * @param skeleton
- * @param selectionWithCoord
- * @returns {SelectionControl} selectionControl just created
- */
- newSelectionControl(t, n, o) {
- const r = this.getSelectionControls().length, { rowHeaderWidth: i, columnHeaderHeight: s } = n, c = new xd(t, r, this._themeService, {
- highlightHeader: this._highlightHeader,
- enableAutoFill: false,
- rowHeaderWidth: i,
- columnHeaderHeight: s
- }), a = Pt2(o, n);
- return c.updateRangeBySelectionWithCoord(a), this._selectionControls.push(c), c.setControlExtension({
- skeleton: n,
- scene: t,
- themeService: this._themeService,
- injector: this._injector,
- selectionHooks: {
- selectionMoveEnd: () => {
- this._selectionMoveEnd$.next(this.getSelectionDataWithStyle());
- }
- }
- }), c;
- }
- };
- Fe2 = ri([
- tt3(1, ot(Ot)),
- tt3(2, ot(ml)),
- tt3(3, it),
- tt3(4, ot(me)),
- tt3(5, fs),
- tt3(6, Xa)
- ], Fe2);
- function oi(e) {
- const t = yr2(e);
- return t.widgets = { tl: true, tc: true, tr: true, ml: true, mr: true, bl: true, bc: true, br: true }, t;
- }
- var si = (e, t, n) => {
- const r = W0(Yx).getRenderById(e), i = r == null ? void 0 : r.with(Fe2);
- (0, import_react.useEffect)(() => {
- if (n && i) {
- const s = n.input$.subscribe((c) => {
- c.content === K.COMMA ? i.setSkipLastEnabled(true) : i.setSkipLastEnabled(false);
- });
- return () => {
- s.unsubscribe();
- };
- }
- }, [n, i]), (0, import_react.useEffect)(() => {
- i && (t.endsWith(K.COMMA) || i.setSkipLastEnabled(false));
- }, [t, i]);
- };
- var qt2 = () => {
- const e = W0(ca);
- return (0, import_react.useCallback)((n) => e.sequenceNodesBuilder(n) || [], [e]);
- };
- var ii = (e, t, n, o, r, i) => {
- const s = qt2(), c = (0, import_react.useRef)(true);
- (0, import_react.useEffect)(() => {
- var a, d;
- if (i) {
- if (c.current) {
- const u = s(e);
- if (u.length) {
- const h = o(i, u);
- n && r(h);
- } else {
- const h = i.getDocumentData(), g = { dataStream: (d = (a = h.body) == null ? void 0 : a.dataStream) != null ? d : `${t}\r
- `, ...h.body };
- i.setDocumentData({ ...h, body: g });
- }
- c.current = false;
- } else if (n) {
- const u = s(e), h = o(i, u);
- r(h);
- }
- }
- }, [i, n]);
- };
- var Hr2 = (e) => n3((n) => {
- var o, r;
- if (e) {
- e.focus();
- const i = [...e.getSelectionRanges()];
- if (re.isDefine(n))
- e.setSelectionRanges([{ startOffset: n, endOffset: n }]);
- else if (!i.length && !e.docSelectionRenderService.isOnPointerEvent) {
- const s = (r = (o = e.getDocumentData().body) == null ? void 0 : o.dataStream) != null ? r : `\r
- `, c = Math.max(s.length - 2, 0);
- e.setSelectionRanges([{ startOffset: c, endOffset: c }]);
- }
- }
- });
- function ci(e, t, n) {
- const o = e.getCurrentTheme(), r = new Nt(t).setAlpha(0.05).toRgbString();
- return {
- id: n,
- strokeWidth: 1,
- stroke: t,
- fill: r,
- widgets: { tl: true, tc: true, tr: true, ml: true, mr: true, bl: true, bc: true, br: true },
- widgetSize: 6,
- widgetStrokeWidth: 1,
- widgetStroke: o.colorWhite
- };
- }
- function Wr(e) {
- var R, C, _;
- const {
- unitId: t,
- subUnitId: n,
- refSelections: o,
- editor: r,
- refSelectionsService: i,
- refSelectionsRenderService: s,
- sheetSkeletonManagerService: c,
- themeService: a,
- univerInstanceService: d
- } = e, u = d.getUnit(t, Fe.UNIVER_SHEET), h = u == null ? void 0 : u.getActiveSheet(), f = [];
- if (!u || !h) {
- i.setSelections(f);
- return;
- }
- const g = h.getSheetId(), l = (E) => {
- var x;
- return (x = u == null ? void 0 : u.getSheetBySheetName(E)) == null ? void 0 : x.getSheetId();
- };
- if (!((R = c == null ? void 0 : c.getWorksheetSkeleton(g)) == null ? void 0 : R.skeleton))
- return;
- const S = [];
- for (let E = 0, x = o.length; E < x; E++) {
- const M2 = o[E], { themeColor: T, token: P, refIndex: A, endIndex: N2 } = M2, b = fn(P), { unitId: w, sheetName: I, range: v } = b;
- if (w && t !== w)
- continue;
- const F2 = l(I);
- if (F2 && F2 !== g || !F2 && g !== n)
- continue;
- const O = Kd(v, h.getRowCount(), h.getColumnCount());
- f.push({
- range: O,
- primary: null,
- style: ci(a, T, A.toString())
- }), S.push(N2);
- }
- if (r) {
- const E = (_ = (C = r.getSelectionRanges()) == null ? void 0 : C[0]) == null ? void 0 : _.startOffset, x = S.findIndex((M2) => M2 + 2 === E);
- x !== -1 ? s == null || s.setActiveSelectionIndex(x) : s == null || s.resetActiveSelectionIndex();
- }
- return f;
- }
- function Rn(e, t) {
- const n = W0(_n), o = W0(ml), r = W0(Xa), s = W0(Yx).getRenderById(e), c = s == null ? void 0 : s.with(Fe2), a = s == null ? void 0 : s.with(me), d = (0, import_react.useCallback)((u, h) => {
- const f = Wr({
- unitId: e,
- subUnitId: t,
- refSelections: u,
- editor: h,
- refSelectionsService: r,
- refSelectionsRenderService: c,
- sheetSkeletonManagerService: a,
- themeService: o,
- univerInstanceService: n
- });
- if (!f)
- return;
- ((c == null ? void 0 : c.getSelectionControls()) || []).length === f.length ? c == null || c.resetSelectionsByModelData(f) : r.setSelections(f);
- }, [c, r, a, o, e, t, n]);
- return (0, import_react.useEffect)(() => () => {
- c == null || c.resetActiveSelectionIndex();
- }, [c]), d;
- }
- function Ur(e = "") {
- const t = W0(Ut), n = Vr2(), o = W0(Pt), r = (0, import_react.useMemo)(() => e.length, [e]);
- return (0, import_react.useCallback)((s, c, a = true, d) => {
- const u = s.getDocumentData(), h = s.getEditorId();
- if (!u)
- return [];
- const f = u.body;
- if (!f)
- return [];
- const g = f.dataStream.slice(0, f.dataStream.length - 2), l = { dataStream: "", ...u.body };
- if (!g.startsWith(e))
- return [];
- if (c == null || c.length === 0)
- return l.textRuns = [], o.syncExecuteCommand(mA.id, {
- unitId: h,
- body: Dt(l, 0, l.dataStream.length - 2)
- }), [];
- {
- const { textRuns: m3, refSelections: S } = Br2(t, n, c);
- r && m3.forEach((_) => {
- _.ed = _.ed + r, _.st = _.st + r;
- }), l.textRuns = [{ st: 0, ed: 1, ts: { fs: 11 } }, ...m3];
- const R = c.reduce((_, E) => typeof E == "string" ? `${_}${E}` : `${_}${E.token}`, "");
- l.dataStream = `${e}${R}\r
- `;
- let C;
- if (a) {
- C = s.getSelectionRanges();
- const _ = l.dataStream.length - 2 + r;
- C.forEach((E) => {
- E.startOffset = Math.max(0, Math.min(E.startOffset, _)), E.endOffset = Math.max(0, Math.min(E.endOffset, _));
- });
- }
- return o.syncExecuteCommand(mA.id, {
- unitId: h,
- body: Dt(l, 0, l.dataStream.length - 2),
- textRanges: d != null ? d : C
- }), S;
- }
- }, [o, t, n, r, e]);
- }
- function Vr2() {
- const t = W0(ml).getCurrentTheme();
- return (0, import_react.useMemo)(() => {
- const o = [
- t.loopColor1,
- t.loopColor2,
- t.loopColor3,
- t.loopColor4,
- t.loopColor5,
- t.loopColor6,
- t.loopColor7,
- t.loopColor8,
- t.loopColor9,
- t.loopColor10,
- t.loopColor11,
- t.loopColor12
- ], r = t.hyacinth700, i = t.verdancy800, s = t.colorBlack;
- return { formulaRefColors: o, numberColor: r, stringColor: i, plainTextColor: s };
- }, [t]);
- }
- function Br2(e, t, n) {
- const { formulaRefColors: o, numberColor: r, stringColor: i, plainTextColor: s } = t, c = [], a = [], d = /* @__PURE__ */ new Map();
- let u = 0;
- for (let h = 0, f = n.length; h < f; h++) {
- const g = n[h];
- if (typeof g == "string") {
- const _ = c[c.length - 1], E = _ ? _.ed : 0, x = E + g.length;
- c.push({
- st: E,
- ed: x,
- ts: {
- cl: {
- rgb: s
- },
- fs: 11
- }
- });
- continue;
- }
- if (e.hasDefinedNameDescription(g.token.trim())) {
- c.push({
- st: g.startIndex,
- ed: g.endIndex + 1,
- ts: {
- cl: {
- rgb: s
- },
- fs: 11
- }
- });
- continue;
- }
- const { startIndex: l, endIndex: m3, nodeType: S, token: R } = g;
- let C = "";
- if (S === $e2.REFERENCE) {
- if (d.has(R))
- C = d.get(R);
- else {
- const _ = u % o.length;
- C = o[_], d.set(R, C), u++;
- }
- a.push({
- refIndex: h,
- themeColor: C,
- token: R,
- startIndex: g.startIndex,
- endIndex: g.endIndex,
- index: a.length
- });
- } else
- S === $e2.NUMBER ? C = r : (S === $e2.STRING || S === $e2.ARRAY) && (C = i);
- C && C.length > 0 ? c.push({
- st: l,
- ed: m3 + 1,
- ts: {
- cl: {
- rgb: C
- },
- fs: 11
- }
- }) : c.push({
- st: l,
- ed: m3 + 1,
- ts: {
- cl: {
- rgb: s
- },
- fs: 11
- }
- });
- }
- return { textRuns: c, refSelections: a };
- }
- function ai(e) {
- var r, i;
- const n = e.get(_n).getCurrentUniverDocInstance();
- return n != null && n.getBody() ? { dataStream: (i = (r = n.getBody()) == null ? void 0 : r.dataStream) != null ? i : "", offset: 0 } : void 0;
- }
- var Mt2 = ((e) => (e[e.NOT_SELECT = 0] = "NOT_SELECT", e[e.NEED_ADD = 1] = "NEED_ADD", e[e.CAN_EDIT = 2] = "CAN_EDIT", e))(Mt2 || {});
- function li(e, t, n) {
- var g;
- const r = W0(Yx).getRenderById(e), i = r == null ? void 0 : r.with(Se), s = W0(m), c = W0(Ot), [a, d] = (0, import_react.useState)(
- 0
- /* NOT_SELECT */
- ), u = W0(ca), h = (0, import_react.useRef)(true), f = (0, import_react.useRef)(a);
- return f.current = a, (0, import_react.useEffect)(() => {
- const l = s.textSelection$.pipe(
- filter((m3) => m3.unitId === e),
- map(() => {
- const m3 = i == null ? void 0 : i.getActiveTextRange();
- return m3 != null && m3.collapsed ? m3.startOffset : -1;
- })
- ).subscribe((m3) => {
- var P, A;
- const S = ai(c);
- if (!S)
- return;
- const R = (P = S == null ? void 0 : S.dataStream) == null ? void 0 : P.slice(0, -2), C = (A = u.sequenceNodesBuilder(R)) != null ? A : [], _ = R[m3 - 1], E = R[m3], x = C.findIndex((N2) => typeof N2 == "object" && N2.nodeType === $e2.REFERENCE && m3 === N2.endIndex + 2), M2 = _ && Fb(_) && (!E || en2(E) && E !== K.OPEN_BRACKET), T = x > -1;
- if ((R == null ? void 0 : R.substring(0, 1)) === "=" && (M2 || T))
- if (T) {
- if (h.current)
- return;
- d(
- 2
- /* CAN_EDIT */
- );
- } else
- h.current = false, d(
- 1
- /* NEED_ADD */
- );
- else
- d(
- 0
- /* NOT_SELECT */
- );
- });
- return () => l.unsubscribe();
- }, [s.textSelection$, i, e, c, u]), (0, import_react.useEffect)(() => {
- t || (d(
- 0
- /* NOT_SELECT */
- ), h.current = true);
- }, [t]), (0, import_react.useEffect)(() => {
- var m3;
- if (!n)
- return;
- const l = (m3 = r == null ? void 0 : r.mainComponent) == null ? void 0 : m3.onPointerDown$.subscribeEvent(() => {
- d(
- 0
- /* NOT_SELECT */
- ), h.current = true;
- });
- return () => l == null ? void 0 : l.unsubscribe();
- }, [n, (g = r == null ? void 0 : r.mainComponent) == null ? void 0 : g.onPointerDown$]), { isSelecting: a };
- }
- var qr = (e, t, n, o) => {
- const r = W0(Pt), i = W0(it), s = (0, import_react.useRef)(t);
- s.current = t;
- const c = (0, import_react.useRef)(o);
- c.current = o, (0, import_react.useEffect)(() => {
- if (!n || !e)
- return;
- const d = `sheet.formula-embedding-editor.${n.getEditorId()}`, u = new Mi(), h = (l, m3) => {
- if (c.current) {
- c.current(l, m3);
- return;
- }
- let S = wu.LEFT;
- l === I1.ARROW_DOWN ? S = wu.DOWN : l === I1.ARROW_UP ? S = wu.UP : l === I1.ARROW_RIGHT && (S = wu.RIGHT), m3 === Ae.SHIFT ? r.executeCommand(ct.id, {
- direction: S
- }) : r.executeCommand(at.id, {
- direction: S
- });
- }, f = (l, m3) => {
- let S = wu.DOWN;
- l === I1.ARROW_DOWN ? S = wu.DOWN : l === I1.ARROW_UP ? S = wu.UP : l === I1.ARROW_LEFT ? S = wu.LEFT : l === I1.ARROW_RIGHT && (S = wu.RIGHT), s.current ? m3 === Ae.CTRL_COMMAND ? r.executeCommand(Lt.id, {
- direction: S,
- jumpOver: Bn.moveGap,
- extra: "formula-editor",
- fromCurrentSelection: s.current === Mt2.NEED_ADD
- }) : m3 === Ae.SHIFT ? r.executeCommand(Gt.id, {
- direction: S,
- extra: "formula-editor"
- }) : m3 === (Ae.CTRL_COMMAND | Ae.SHIFT) ? r.executeCommand(Gt.id, {
- direction: S,
- jumpOver: Bn.moveGap,
- extra: "formula-editor"
- }) : r.executeCommand(Lt.id, {
- direction: S,
- extra: "formula-editor",
- fromCurrentSelection: s.current === Mt2.NEED_ADD
- }) : h(l, m3);
- };
- return u.add(r.registerCommand({
- id: d,
- type: ar.OPERATION,
- handler(l, m3) {
- const { keyCode: S, metaKey: R } = m3;
- f(S, R);
- }
- })), [
- { keyCode: I1.ARROW_DOWN },
- { keyCode: I1.ARROW_LEFT },
- { keyCode: I1.ARROW_RIGHT },
- { keyCode: I1.ARROW_UP },
- { keyCode: I1.ARROW_DOWN, metaKey: Ae.SHIFT },
- { keyCode: I1.ARROW_LEFT, metaKey: Ae.SHIFT },
- { keyCode: I1.ARROW_RIGHT, metaKey: Ae.SHIFT },
- { keyCode: I1.ARROW_UP, metaKey: Ae.SHIFT },
- { keyCode: I1.ARROW_DOWN, metaKey: Ae.CTRL_COMMAND },
- { keyCode: I1.ARROW_LEFT, metaKey: Ae.CTRL_COMMAND },
- { keyCode: I1.ARROW_RIGHT, metaKey: Ae.CTRL_COMMAND },
- { keyCode: I1.ARROW_UP, metaKey: Ae.CTRL_COMMAND },
- { keyCode: I1.ARROW_DOWN, metaKey: Ae.CTRL_COMMAND | Ae.SHIFT },
- { keyCode: I1.ARROW_LEFT, metaKey: Ae.CTRL_COMMAND | Ae.SHIFT },
- { keyCode: I1.ARROW_RIGHT, metaKey: Ae.CTRL_COMMAND | Ae.SHIFT },
- { keyCode: I1.ARROW_UP, metaKey: Ae.CTRL_COMMAND | Ae.SHIFT }
- ].map(({ keyCode: l, metaKey: m3 }) => ({
- id: d,
- binding: m3 ? l | m3 : l,
- preconditions: () => true,
- priority: 900,
- staticParameters: {
- eventType: vf.Keyboard,
- keyCode: l,
- metaKey: m3
- }
- })).forEach((l) => {
- u.add(i.registerShortcut(l));
- }), () => {
- u.dispose();
- };
- }, [r, n, e, i]);
- };
- var Kr = (e, t) => {
- const o = W0(Yx).getRenderById(e), r = o == null ? void 0 : o.with(Fe2);
- (0, import_react.useEffect)(() => {
- r && (t ? r == null || r.setRemainLastEnabled(false) : r == null || r.setRemainLastEnabled(true));
- }, [t, r]);
- };
- var In = (e, t, n, o = true) => {
- const r = W0(Yx), i = W0(fs), s = W0(Wt), c = W0(Xa), a = r.getRenderById(n), d = a == null ? void 0 : a.with(Fe2);
- (0, import_react.useLayoutEffect)(() => {
- if (e)
- return i.setContextValue(oE, true), () => {
- i.setContextValue(oE, false), c.clear();
- };
- }, [i, e, c]), (0, import_react.useLayoutEffect)(() => {
- if (e && t) {
- const u = d == null ? void 0 : d.enableSelectionChanging();
- return i.setContextValue(Aa, true), () => {
- i.setContextValue(Aa, false), u == null || u.dispose();
- };
- }
- }, [i, e, d, t]), (0, import_react.useEffect)(() => {
- if (e)
- return i.setContextValue(oE, true), o && s.disable(), () => {
- i.setContextValue(oE, false), o && s.enable();
- };
- }, [s, i, e, o]), (0, import_react.useEffect)(() => {
- e && (d == null || d.setSkipLastEnabled(false));
- }, [e, d]);
- };
- var ui = () => {
- (0, import_react.useEffect)(() => () => {
- }, []);
- };
- var Yr = (e, t, n) => {
- const o = W0(_n), r = W0(F);
- return (0, import_react.useCallback)(() => {
- if (e) {
- const s = [...r.getWorkbookSelections(t).getSelectionsOfWorksheet(n)], c = o.getCurrentUnitForType(Fe.UNIVER_SHEET), a = c == null ? void 0 : c.getActiveSheet();
- a && a.getSheetId() === n && r.setSelections(s);
- }
- }, [e, r, n, t, o]);
- };
- var un = (e) => typeof e == "string" ? e === K.COMMA : false;
- var fi = (e) => {
- if (typeof e == "object")
- return e.nodeType === $e2.REFERENCE;
- };
- var hi = (e) => e.filter((t) => un(t) || fi(t));
- var En = (e) => {
- if (e.endColumn < e.startColumn) {
- const t = e.endColumn;
- e.endColumn = e.startColumn, e.startColumn = t;
- }
- if (e.endRow < e.startRow) {
- const t = e.endRow;
- e.endRow = e.startRow, e.startRow = t;
- }
- return e;
- };
- var Oe2 = (e) => e.map((t) => typeof t == "string" ? t : t.token).join("");
- function Zn(e, t, n) {
- var o, r;
- return ((r = (o = e.getUnit(t)) == null ? void 0 : o.getSheetBySheetId(n)) == null ? void 0 : r.getName()) || "";
- }
- var Ne = (e, t = false, n = "") => t ? e.map((o) => o.sheetName !== "" && o.sheetName !== n ? pc(o.sheetName, o.range) : fr(o.range)) : e.map((o) => fr(o.range));
- var zr = (e, t, n, o, r, i, s) => {
- const c = W0(Yx), a = W0(_n), d = (0, import_react.useRef)(false), u = c.getRenderById(t), h = u == null ? void 0 : u.with(Fe2), f = (0, import_react.useRef)([]), g = (0, import_react.useMemo)(() => {
- const m3 = hi(o), S = f.current;
- return m3.length === S.length ? (S.splice(0), S.push(...m3), S) : m3;
- }, [o]);
- f.current = g;
- const l = (0, import_react.useRef)();
- (0, import_react.useEffect)(() => {
- if (e && h) {
- let m3 = true;
- const S = (_, E) => {
- var I;
- if (m3 || d.current) {
- m3 = false;
- return;
- }
- const x = [..._], M2 = a.getUnit(t), T = ((I = M2 == null ? void 0 : M2.getActiveSheet()) == null ? void 0 : I.getName()) || "", P = g.map((v, F2) => {
- if (typeof v == "string") {
- if (!g[F2 - 1])
- return null;
- const L = g[F2 + 1];
- return un(v) && (un(L) || F2 === g.length - 1) ? null : v;
- } else if (v.nodeType === $e2.REFERENCE) {
- const O = fn(v.token);
- O.unitId = O.unitId === "" ? t : O.unitId, O.sheetName = O.sheetName === "" ? T : O.sheetName;
- const { unitId: L, sheetName: B } = O;
- if (i && (L !== t || T !== B))
- return null;
- if (L === t && T === B) {
- const K2 = x.shift();
- if (K2 && Zn(a, t, K2.rangeWithCoord.sheetId || "") === B) {
- const V2 = { ...v };
- return En(K2.rangeWithCoord), r ? V2.token = pc(T, K2.rangeWithCoord) : V2.token = fr(K2.rangeWithCoord), V2;
- }
- }
- return v;
- }
- return null;
- }).filter((v) => !!v), A = Ne(
- x.map((v) => {
- var F2, O, L;
- return {
- range: v.rangeWithCoord,
- unitId: (F2 = v.rangeWithCoord.unitId) != null ? F2 : "",
- sheetName: Zn(a, (O = v.rangeWithCoord.unitId) != null ? O : "", (L = v.rangeWithCoord.sheetId) != null ? L : "")
- };
- }),
- r
- ).join(K.COMMA), N2 = Oe2(P), b = `${N2}${N2 && A ? K.COMMA : ""}${A}`, w = d.current;
- s(b, w ? -1 : b.length, E);
- }, R = h.selectionMoveEnd$.subscribe((_) => {
- if (S(_, true), d.current = false, l.current) {
- const { result: E, offset: x } = l.current;
- s(E, x, true), l.current = void 0;
- }
- }), C = h.selectionMoving$.pipe(throttleTime(50)).subscribe((_) => {
- S(_, false);
- });
- return () => {
- R.unsubscribe(), C.unsubscribe();
- };
- }
- }, [e, g, h, r, i, s, a, t]), (0, import_react.useEffect)(() => {
- if (e && h) {
- const m3 = new Mi(), S = (_, E) => {
- var w;
- let x = 0, M2 = 0, T = false;
- const P = a.getUnit(t), A = ((w = P == null ? void 0 : P.getActiveSheet()) == null ? void 0 : w.getName()) || "", N2 = g.map((I) => {
- if (typeof I == "string")
- return T || (M2 += I.length), I;
- if (I.nodeType === $e2.REFERENCE) {
- const v = fn(_);
- if (v.unitId = v.unitId === "" ? t : v.unitId, v.sheetName = v.sheetName === "" ? A : v.sheetName, x === E) {
- T = true;
- const F2 = { ...I, token: _ };
- return r ? F2.token = pc(v.sheetName, v.range) : F2.token = fr(v.range), x++, M2 += F2.token.length, F2;
- }
- return x++, T || (M2 += I.token.length), I;
- }
- return I;
- }), b = Oe2(N2);
- l.current = { result: b, offset: M2 }, s(b, -1, false);
- };
- let R = 0;
- const C = h.selectionMoveEnd$.subscribe(() => {
- R = setTimeout(() => {
- m3.dispose(), h.getSelectionControls().forEach((E, x) => {
- m3.add(merge(E.selectionMoving$, E.selectionScaling$).pipe(
- map((M2) => fr(M2)),
- distinctUntilChanged()
- ).subscribe((M2) => {
- d.current = true, S(M2, x);
- }));
- });
- }, 30);
- });
- return () => {
- C.unsubscribe(), m3.dispose(), clearTimeout(R);
- };
- }
- }, [e, h, g, s, a, t, r]);
- };
- var bn = (e, t, n, o, r, i) => {
- const s = W0(Pt), c = W0(He), d = W0(Yx).getRenderById(t), u = d == null ? void 0 : d.with(Fe2);
- (0, import_react.useEffect)(() => {
- if (e && u)
- if (n) {
- const h = s.onCommandExecuted((f) => {
- if (f.id === an.id) {
- const g = u.getSelectionControls().length;
- for (let l = 1; l <= g; l++)
- u.clearLastSelection();
- setTimeout(() => {
- i();
- }, 30);
- }
- });
- return () => {
- h.dispose();
- };
- } else {
- const h = s.beforeCommandExecuted((f) => {
- if (f.id === an.id) {
- o(false), r(), i();
- const g = c.getEditor(su);
- g == null || g.focus();
- }
- });
- return () => {
- h.dispose();
- };
- }
- }, [e, u]);
- };
- var Zr = (e) => !e.some((n) => {
- if (typeof n == "string") {
- if (n !== K.COMMA)
- return true;
- } else if (n.nodeType !== $e2.REFERENCE)
- return true;
- return false;
- });
- var di = (e, t, n) => {
- const o = (0, import_react.useRef)(true);
- (0, import_react.useEffect)(() => {
- if (e) {
- const r = setTimeout(() => {
- o.current = false;
- }, 500);
- return () => {
- clearTimeout(r);
- };
- }
- }, [e]), (0, import_react.useEffect)(() => {
- if (!o.current && t) {
- const r = Zr(n);
- t(r, Oe2(n));
- }
- }, [n, t]);
- };
- var mi = "univer-sheet-range-selector-text-wrap";
- var gi = "univer-sheet-range-selector-placeholder";
- var pi = "univer-sheet-range-selector-error";
- var Si = "univer-sheet-range-selector-error-wrap";
- var vi = "univer-sheet-range-selector-text";
- var Ci = "univer-sheet-range-selector-active";
- var _i = "univer-sheet-range-selector-icon";
- var Ri = "univer-sheet-range-selector-dialog-item";
- var Ii = "univer-sheet-range-selector-dialog-item-delete";
- var xe = {
- sheetRangeSelectorTextWrap: mi,
- sheetRangeSelectorPlaceholder: gi,
- sheetRangeSelectorError: pi,
- sheetRangeSelectorErrorWrap: Si,
- sheetRangeSelectorText: vi,
- sheetRangeSelectorActive: Ci,
- sheetRangeSelectorIcon: _i,
- sheetRangeSelectorDialogItem: Ri,
- sheetRangeSelectorDialogItemDelete: Ii
- };
- var dt = () => {
- };
- function Ei(e) {
- const {
- initValue: t,
- unitId: n,
- subUnitId: o,
- errorText: r,
- placeholder: i,
- actions: s,
- onChange: c = dt,
- onVerify: a = dt,
- onRangeSelectorDialogVisibleChange: d = dt,
- onBlur: u = dt,
- onFocus: h = dt,
- isFocus: f = true,
- isOnlyOneRange: g = false,
- isSupportAcrossSheet: l = false
- } = e, m3 = n3(c), S = W0(He), R = W0(Vr), C = W0(Pt), _ = W0(ca), E = (0, import_react.useRef)(null), [x, M2] = (0, import_react.useState)(false), [T, P] = (0, import_react.useState)(f), A = (0, import_react.useMemo)(() => k0(`${_12}-${qt(4)}`), []), N2 = (0, import_react.useRef)(), b = N2.current, w = (0, import_react.useRef)(null), I = W0(_n), v = (0, import_react.useMemo)(() => !x && T, [x, T]), [F2, O] = (0, import_react.useState)(() => typeof t == "string" ? t : Ne(t, l).join(K.COMMA)), L = (0, import_react.useMemo)(() => I.getCurrentTypeOfUnit$(Fe.UNIVER_DOC), [I]), B = z0(L), K2 = (B == null ? void 0 : B.getUnitId()) === A, V2 = (0, import_react.useRef)([]), U = n3((j, k) => {
- E.current && !x && !E.current.contains(j.target) && k();
- });
- s && (s.handleOutClick = U);
- const ne = (0, import_react.useMemo)(() => F2.split(K.COMMA).filter((j) => !!j).map((j) => fn(j)), [F2]), ie = (0, import_react.useMemo)(() => r !== void 0, [r]), te = Yr(!x && T, n, o);
- (0, import_react.useMemo)(() => (j) => {
- const k = _.sequenceNodesBuilder(j);
- if (k) {
- if (Zr(k)) {
- const X2 = k.map((oe) => {
- if (typeof oe == "string")
- return oe;
- if (oe.nodeType === $e2.REFERENCE) {
- const Je = { ...oe }, Pe2 = fn(oe.token);
- return Pe2.range = En(Pe2.range), l || (Pe2.sheetName = "", Pe2.unitId = ""), Je.token = Ne([Pe2], l)[0], Je;
- }
- return oe;
- }), J = Oe2(X2);
- m3(J);
- }
- } else
- O("");
- }, [l]);
- const W = Hr2(b), { checkScrollBar: Ce2 } = dA(b, true, true), de = qt2(), fe = (0, import_react.useMemo)(() => de(F2), [F2]), re3 = Ur(), be = Rn(n, o), ce = n3((j, k = true, z = true) => {
- if (!N2.current)
- return;
- const X2 = de(j), J = re3(N2.current, X2, k);
- V2.current = J, z && be(J, N2.current);
- });
- (0, import_react.useEffect)(() => {
- const j = C.onCommandExecuted((k) => {
- var z, X2;
- if (k.id === M.id) {
- const J = k.params, { unitId: oe } = J;
- oe === A && m3(st.transform.getPlainText((X2 = (z = b == null ? void 0 : b.getDocumentData().body) == null ? void 0 : z.dataStream) != null ? X2 : ""));
- }
- });
- return () => j.dispose();
- }, [C, b, A, m3]);
- const _e = n3((j, k, z) => {
- ce(j), O(j), z && (W(), k !== -1 && setTimeout(() => {
- const X2 = { startOffset: k, endOffset: k };
- b == null || b.setSelectionRanges([X2]);
- const J = b == null ? void 0 : b.render.with(kn);
- J == null || J.scrollToRange({ ...X2, collapsed: true });
- }, 50), Ce2());
- });
- zr(v, n, o, fe, l, g, _e), In(v, v && K2, n), Kr(n, g), si(n, F2, b), di(v, a, fe), qr(v, 0, b), ui(), bn(v, n, l, P, u, () => {
- v && ce(F2);
- }), (0, import_react.useEffect)(() => {
- if (b) {
- const j = b.input$.pipe(throttleTime(100)).subscribe((k) => {
- var X2, J;
- const z = ((J = (X2 = k.data.body) == null ? void 0 : X2.dataStream) != null ? J : "").replaceAll(/\n|\r/g, "").replaceAll(/,{2,}/g, ",").replaceAll(/(^,)/g, "");
- ce(z, false), O(z);
- });
- return () => {
- j.unsubscribe();
- };
- }
- }, [b]), (0, import_react.useEffect)(() => {
- const j = C.onCommandExecuted((k) => {
- k.id === Et.id && (M2(false), d(false), P(false), u());
- });
- return () => {
- j.dispose();
- };
- }, [l]), (0, import_react.useLayoutEffect)(() => {
- let j;
- if (w.current) {
- j = S.register({
- autofocus: true,
- editorUnitId: A,
- initialSnapshot: {
- id: A,
- body: { dataStream: `${F2}\r
- `, textRuns: [] },
- documentStyle: {}
- }
- }, w.current);
- const k = S.getEditor(A);
- N2.current = k, ce(F2, false, false);
- }
- return () => {
- j == null || j.dispose();
- };
- }, []), (0, import_react.useLayoutEffect)(() => {
- f ? (P(f), W()) : (b == null || b.blur(), te(), P(f));
- }, [f, W]), ii(F2, "", T, re3, be, b);
- const me2 = () => {
- h(), W(), P(true);
- }, Re = (j) => {
- const k = Ne(j, l).join(K.COMMA);
- k || b == null || b.setDocumentData({ ...b.getDocumentData(), body: { dataStream: `\r
- `, textRuns: [] } }), ce(k), O(k), M2(false), d(false), setTimeout(() => {
- P(true), b == null || b.setSelectionRanges([{ startOffset: k.length, endOffset: k.length }]), W(), Ce2();
- }, 30);
- }, je = () => {
- M2(false), d(false), setTimeout(() => {
- P(true), W();
- }, 30);
- }, He2 = () => {
- ie || (W(), setTimeout(() => {
- M2(true), d(true), P(false);
- }, 30));
- };
- return p.jsxs("div", { className: xe.sheetRangeSelector, ref: E, children: [
- p.jsxs(
- "div",
- {
- className: ln(xe.sheetRangeSelectorTextWrap, {
- [xe.sheetRangeSelectorActive]: T && !ie,
- [xe.sheetRangeSelectorError]: ie
- }),
- children: [
- p.jsx("div", { className: xe.sheetRangeSelectorText, ref: w, onMouseUp: me2 }),
- p.jsx(Gf, { title: R.t("rangeSelector.buttonTooltip"), placement: "bottom", children: p.jsx(kr, { className: xe.sheetRangeSelectorIcon, onClick: He2 }) }),
- r !== void 0 ? p.jsx("div", { className: xe.sheetRangeSelectorErrorWrap, children: r }) : null,
- i !== void 0 && !F2 ? p.jsx("div", { className: xe.sheetRangeSelectorPlaceholder, children: i }) : null
- ]
- }
- ),
- x && p.jsx(
- bi2,
- {
- editorId: A,
- handleConfirm: Re,
- handleClose: je,
- unitId: n,
- subUnitId: o,
- initValue: ne,
- visible: x,
- isOnlyOneRange: g,
- isSupportAcrossSheet: l
- }
- )
- ] });
- }
- function bi2(e) {
- const { handleConfirm: t, handleClose: n, visible: o, initValue: r, unitId: i, subUnitId: s, isOnlyOneRange: c, isSupportAcrossSheet: a } = e, d = W0(Vr), u = W0(Ut), h = W0(ca), g = W0(Yx).getRenderById(i), l = g == null ? void 0 : g.with(Fe2), [m3, S] = (0, import_react.useState)(() => {
- if (c) {
- const v = r[0];
- return v ? Ne([v], a) : [""];
- }
- return Ne(r, a);
- }), [R, C] = (0, import_react.useState)(() => m3.length - 1), _ = Vr2(), E = (0, import_react.useMemo)(() => m3.join(K.COMMA), [m3]), x = qt2(), M2 = (0, import_react.useMemo)(() => x(E), [E]), T = (0, import_react.useMemo)(() => Br2(u, _, M2).refSelections, [M2]), P = () => {
- S([]), setTimeout(() => {
- n();
- }, 30);
- }, A = (v, F2) => {
- F2 ? l == null || l.setSkipLastEnabled(false) : l == null || l.setSkipLastEnabled(true), S((O) => {
- const L = [...O];
- return L[v] = F2, L;
- });
- }, N2 = (v) => {
- l == null || l.setSkipLastEnabled(false), S((F2) => {
- if (F2.length === 1)
- return F2;
- const O = [];
- return F2.forEach((L, B) => {
- v !== B && O.push(L);
- }), O;
- });
- }, b = () => {
- l == null || l.setSkipLastEnabled(true), S((v) => (v.push(""), C(v.length - 1), [...v]));
- }, w = n3((v) => {
- var O;
- l == null || l.setSkipLastEnabled(false);
- const F2 = v.split(K.COMMA).filter((L) => !!L);
- S(c ? [(O = F2[0]) != null ? O : ""] : F2);
- }), I = Rn(i, s);
- return zr(R >= 0, i, s, M2, a, c, w), In(R >= 0, R >= 0, i), Kr(i, c), bn(R >= 0, i, a, noop, noop, () => I(T)), (0, import_react.useEffect)(() => {
- I(T);
- }, [T]), (0, import_react.useEffect)(() => {
- (m3.length === 0 || m3.length === 1 && !m3[0]) && (l == null || l.setSkipLastEnabled(true));
- }, [m3]), p.jsx(
- rg,
- {
- width: "328px",
- visible: o,
- title: d.t("rangeSelector.title"),
- draggable: true,
- closeIcon: p.jsx(Bt, {}),
- footer: p.jsxs("footer", { children: [
- p.jsx(Po, { onClick: P, children: d.t("rangeSelector.cancel") }),
- p.jsx(
- Po,
- {
- style: { marginLeft: 10 },
- onClick: () => t(m3.filter((v) => {
- const F2 = h.sequenceNodesBuilder(v);
- return F2 && F2.length === 1 && typeof F2[0] != "string" && F2[0].nodeType === $e2.REFERENCE;
- }).map((v) => fn(v)).map((v) => ({ ...v, range: En(v.range) }))),
- type: "primary",
- children: d.t("rangeSelector.confirm")
- }
- )
- ] }),
- onClose: P,
- children: p.jsxs("div", { className: xe.sheetRangeSelectorDialog, children: [
- m3.map((v, F2) => p.jsxs("div", { className: xe.sheetRangeSelectorDialogItem, children: [
- p.jsx(
- QC,
- {
- affixWrapperStyle: { width: "100%" },
- placeholder: d.t("rangeSelector.placeHolder"),
- onFocus: () => C(F2),
- value: v,
- onChange: (O) => A(F2, O)
- },
- `input_${F2}`
- ),
- m3.length > 1 && !c && p.jsx(wr, { className: xe.sheetRangeSelectorDialogItemDelete, onClick: () => N2(F2) })
- ] }, `${v}_${F2}`)),
- !c && p.jsx("div", { children: p.jsxs(Po, { type: "link", size: "small", onClick: b, children: [
- p.jsx(Dr, {}),
- p.jsx("span", { children: d.t("rangeSelector.addAnotherRange") })
- ] }) })
- ] })
- }
- );
- }
- function xi(e, t) {
- return Object.keys(e).filter((n) => isNaN(Number(n)) && n !== "DefinedName").map((n) => ({
- label: t.t(`formula.functionType.${n.toLocaleLowerCase()}`),
- value: `${e[n]}`
- }));
- }
- function xn(e) {
- if (!e.require && !e.repeat)
- return `[${e.name}]`;
- if (e.require && !e.repeat)
- return e.name;
- if (!e.require && e.repeat)
- return `[${e.name},...]`;
- if (e.require && e.repeat)
- return `${e.name},...`;
- }
- var Ni = (e, t = 100) => {
- (0, import_react.useEffect)(() => {
- let n = null;
- const o = () => {
- n === null && (n = window.setTimeout(() => {
- e(), n = null;
- }, t));
- };
- return window.addEventListener("scroll", o), window.addEventListener("resize", o), () => {
- n !== null && clearTimeout(n), window.removeEventListener("scroll", o), window.removeEventListener("resize", o);
- };
- }, [e, t]);
- };
- function Gr(e, t, n) {
- const o = W0(He), r = (0, import_react.useMemo)(() => new BehaviorSubject({ left: -999, top: -999, right: -999, bottom: -999 }), []), i = W0(rt), s = W0(_n), c = n3(() => {
- const a = o.getEditor(e);
- if (!a)
- return;
- const d = a.getBoundingClientRect(), { left: u, top: h, right: f, bottom: g } = d, l = r.getValue();
- if (!(l.left === u && l.top === h && l.right === f && l.bottom === g))
- return r.next({ left: u - 1, right: f + 1, top: h - 1, bottom: g + 1 }), d;
- });
- return (0, import_react.useEffect)(() => {
- t && c();
- }, [e, o, s.unitAdded$, c, t, ...n != null ? n : []]), Ni(c), (0, import_react.useEffect)(() => {
- const a = i.scrollEvent$.pipe(throttleTime(100)).subscribe(c);
- return () => {
- a.unsubscribe();
- };
- }, []), [r, c];
- }
- var Ct2 = (e) => {
- const t = (0, import_react.useRef)(e);
- return t.current = e, t;
- };
- var Fi2 = (e, t, n) => {
- const o = W0(Ut), r = W0(ca), [i, s] = (0, import_react.useState)(), [c, a] = (0, import_react.useState)(-1), [d, u] = (0, import_react.useState)(true), h = Ct2(d), f = (0, import_react.useRef)(t);
- f.current = t;
- const g = () => {
- s(void 0), a(-1), u(false);
- };
- return (0, import_react.useEffect)(() => {
- if (n && e) {
- const l = n.selectionChange$.pipe(debounceTime(50)).subscribe((S) => {
- if (S.textRanges.length === 1) {
- const [R] = S.textRanges;
- if (R.collapsed && h.current) {
- const C = r.getFunctionAndParameter(`${f.current}A`, R.startOffset - 1);
- if (C) {
- const { functionName: _, paramIndex: E } = C, x = o.getFunctionInfo(_);
- s(x), a(E);
- return;
- }
- }
- }
- s(void 0), a(-1);
- }), m3 = n.selectionChange$.pipe(
- filter((S) => S.isEditing),
- filter((S) => S.textRanges.length === 1),
- map((S) => S.textRanges[0].startOffset),
- distinctUntilChanged()
- ).subscribe(() => {
- u(true);
- });
- return () => {
- l.unsubscribe(), m3.unsubscribe();
- };
- }
- }, [n, e]), (0, import_react.useEffect)(() => {
- e || g();
- }, [e]), {
- functionInfo: i,
- paramIndex: c,
- reset: g
- };
- };
- var yi = "univer-formula-help-function";
- var Ti = "univer-formula-help-function-title";
- var Oi = "univer-formula-help-function-title-icons";
- var Mi2 = "univer-formula-help-function-title-icon";
- var Pi2 = "univer-formula-help-function-content";
- var Ai = "univer-formula-help-function-content-inner";
- var Li = "univer-formula-help-function-content-params";
- var wi = "univer-formula-help-function-content-params-title";
- var $i = "univer-formula-help-function-content-params-detail";
- var Di = "univer-formula-help-function-active";
- var ki = "univer-formula-help-decorator";
- var ji = "univer-formula-help-param";
- var Hi = "univer-formula-help-param-prefix";
- var Wi = "univer-formula-help-param-item";
- var Ui = "univer-formula-help-param-active";
- var ue2 = {
- formulaHelpFunction: yi,
- formulaHelpFunctionTitle: Ti,
- formulaHelpFunctionTitleIcons: Oi,
- formulaHelpFunctionTitleIcon: Mi2,
- formulaHelpFunctionContent: Pi2,
- formulaHelpFunctionContentInner: Ai,
- formulaHelpFunctionContentParams: Li,
- formulaHelpFunctionContentParamsTitle: wi,
- formulaHelpFunctionContentParamsDetail: $i,
- formulaHelpFunctionActive: Di,
- formulaHelpDecorator: ki,
- formulaHelpParam: ji,
- formulaHelpParamPrefix: Hi,
- formulaHelpParamItem: Wi,
- formulaHelpParamActive: Ui
- };
- var Jt = ({ className: e, title: t, value: n }) => p.jsxs("div", { className: ue2.formulaHelpFunctionContentParams, children: [
- p.jsx(
- "div",
- {
- className: `
- ${ue2.formulaHelpFunctionContentParamsTitle}
- ${e}
- `,
- children: t
- }
- ),
- p.jsx("div", { className: ue2.formulaHelpFunctionContentParamsDetail, children: n })
- ] });
- var Vi = (e) => {
- const { prefix: t, value: n, active: o, onClick: r } = e;
- return p.jsxs("div", { className: ue2.formulaHelpParam, children: [
- p.jsxs("span", { className: ue2.formulaHelpParamPrefix, children: [
- t,
- "("
- ] }),
- n && n.map((i, s) => p.jsxs("span", { className: ue2.formulaHelpParamItem, children: [
- p.jsx(
- "span",
- {
- className: o === s ? ue2.formulaHelpFunctionActive : ue2.formulaHelpParamActive,
- onClick: () => r(s),
- children: xn(i)
- }
- ),
- s === n.length - 1 ? "" : ","
- ] }, i.name)),
- ")"
- ] });
- };
- var Gn = () => {
- };
- function Bi(e) {
- const { onParamsSwitch: t = Gn, onClose: n = Gn, isFocus: o, editor: r, formulaText: i } = e, { functionInfo: s, paramIndex: c, reset: a } = Fi2(o, i, r), d = (0, import_react.useMemo)(() => !!s && c >= 0, [s, c]), [u, h] = (0, import_react.useState)(true), f = W0(Vr), g = f.t("formula.prompt.required"), l = f.t("formula.prompt.optional"), m3 = r.getEditorId(), [S] = Gr(m3, d, [s, c]);
- function R(_) {
- t && t(_);
- }
- const C = () => {
- a(), n();
- };
- return d && s ? p.jsx(i3, { portal: true, onClickOutside: () => a(), anchorRect$: S, direction: "vertical", children: p.jsxs("div", { className: ue2.formulaHelpFunction, children: [
- p.jsxs("div", { className: ue2.formulaHelpFunctionTitle, children: [
- p.jsx(
- Vi,
- {
- prefix: s.functionName,
- value: s.functionParameter,
- active: c,
- onClick: R
- }
- ),
- p.jsxs("div", { className: ue2.formulaHelpFunctionTitleIcons, children: [
- p.jsx(
- "div",
- {
- className: ue2.formulaHelpFunctionTitleIcon,
- style: { transform: u ? "rotateZ(-90deg)" : "rotateZ(90deg)" },
- onClick: () => h(!u),
- children: p.jsx(_n2, {})
- }
- ),
- p.jsx(
- "div",
- {
- className: ue2.formulaHelpFunctionTitleIcon,
- onClick: C,
- children: p.jsx(Bt, {})
- }
- )
- ] })
- ] }),
- p.jsx(
- "div",
- {
- className: ue2.formulaHelpFunctionContent,
- style: {
- height: u ? "unset" : 0,
- padding: u ? "revert-layer" : 0
- },
- children: p.jsxs("div", { className: ue2.formulaHelpFunctionContentInner, children: [
- p.jsx(
- Jt,
- {
- title: f.t("formula.prompt.helpExample"),
- value: `${s.functionName}(${s.functionParameter.map((_) => _.example).join(",")})`
- }
- ),
- p.jsx(
- Jt,
- {
- title: f.t("formula.prompt.helpAbstract"),
- value: s.description
- }
- ),
- s && s.functionParameter && s.functionParameter.map((_, E) => p.jsx(
- Jt,
- {
- className: c === E ? ue2.formulaHelpFunctionActive : "",
- title: _.name,
- value: `${_.require ? g : l} ${_.detail}`
- },
- E
- ))
- ] })
- }
- )
- ] }) }) : null;
- }
- var Xr = (e, t, n = true) => {
- let o = -1;
- return e.reduce((r, i, s) => {
- if (r.isFinish)
- return r;
- const c = r.currentIndex;
- if (typeof i != "string")
- r.currentIndex += i.token.length;
- else {
- const a = i.length;
- r.currentIndex += a;
- }
- return (n ? r.currentIndex === t : t > c && t <= r.currentIndex) && (o = s, r.isFinish = true), r;
- }, { currentIndex: 0, isFinish: false }), o;
- };
- var yt = (e) => e.reduce((t, n) => typeof n == "string" ? t + n.length : t + n.token.length, 0);
- var qi = () => {
- };
- var Ki = (e, t, n, o, r, i, s, c, a, d, u = qi) => {
- const h = W0(Yx), f = W0(_n), g = W0(Pt), l = Ct2(i), m3 = W0(m), S = W0(ml), R = f.getUnit(o), C = n3((I) => {
- var v, F2;
- return (F2 = (v = R == null ? void 0 : R.getSheetBySheetId(I)) == null ? void 0 : v.getName()) != null ? F2 : "";
- }), _ = (0, import_react.useMemo)(() => C(r), [C, r]), E = z0(R == null ? void 0 : R.activeSheet$), x = Ct2({ activeSheet: E, sheetName: _ }), M2 = h.getRenderById(o), T = M2 == null ? void 0 : M2.with(Fe2), P = M2 == null ? void 0 : M2.with(me), A = W0(Xa), N2 = (0, import_react.useRef)(false), b = (0, import_react.useRef)(n);
- b.current = n;
- const w = (0, import_react.useRef)();
- (0, import_react.useEffect)(() => {
- if (T && e) {
- let I = true;
- const v = (O, L) => {
- var ie, te, W, Ce2, de, fe;
- if (I) {
- I = false;
- return;
- }
- const B = d == null ? void 0 : d.getSelectionRanges();
- if ((B == null ? void 0 : B.length) !== 1)
- return;
- const V2 = B[0].startOffset - 1, U = [...l.current], ne = Xr(U, V2, false);
- if (b.current === Mt2.NEED_ADD)
- if (V2 !== 0) {
- if (ne === -1 && U.length)
- return;
- const re3 = O[O.length - 1], be = U.splice(ne + 1), ce = (ie = re3.rangeWithCoord.sheetId) != null ? ie : r, _e = {
- range: re3.rangeWithCoord,
- unitId: (te = re3.rangeWithCoord.unitId) != null ? te : o,
- sheetName: C(ce)
- }, Re = Ne([_e], c && ce !== r, _);
- U.push({ token: Re[0], nodeType: $e2.REFERENCE });
- const je = [...U, ...be], He2 = Oe2(je);
- u(He2, yt(U), L);
- } else {
- const re3 = O[O.length - 1], be = (W = re3.rangeWithCoord.sheetId) != null ? W : r, ce = {
- range: re3.rangeWithCoord,
- unitId: (Ce2 = re3.rangeWithCoord.unitId) != null ? Ce2 : o,
- sheetName: C(be)
- }, me2 = Ne([ce], c && be !== r);
- U.unshift({ token: me2[0], nodeType: $e2.REFERENCE });
- const Re = Oe2(U);
- u(Re, me2[0].length, L);
- }
- else {
- let re3 = 0;
- const be = U.map((j) => {
- var k, z, X2;
- if (typeof j == "string")
- return j;
- if (j.nodeType === $e2.REFERENCE) {
- const J = fn(j.token);
- if (J.sheetName || (J.sheetName = _), c && ((k = x.current.activeSheet) == null ? void 0 : k.getName()) !== J.sheetName)
- return j.token;
- const oe = O[re3];
- if (re3++, !oe)
- return "";
- const Je = (z = oe.rangeWithCoord.sheetId) != null ? z : r, Pe2 = {
- range: oe.rangeWithCoord,
- unitId: (X2 = oe.rangeWithCoord.unitId) != null ? X2 : o,
- sheetName: C(Je)
- };
- return Ne([Pe2], c, _)[0];
- }
- return j.token;
- });
- let ce = "", _e;
- be.forEach((j, k) => {
- ce += j, k === ne && (_e = ce.length);
- });
- const me2 = [];
- for (let j = re3; j <= O.length - 1; j++) {
- const k = O[j], z = (de = k.rangeWithCoord.sheetId) != null ? de : r, X2 = {
- range: k.rangeWithCoord,
- unitId: (fe = k.rangeWithCoord.unitId) != null ? fe : o,
- sheetName: C(z)
- }, oe = Ne([X2], c && z !== r, _);
- me2.push(oe[0]);
- }
- const Re = U[U.length - 1], je = Re && (typeof Re == "string" ? false : Re.nodeType === $e2.REFERENCE), He2 = `${ce}${me2.length && je ? "," : ""}${me2.join(",")}`;
- u(He2, !me2.length && _e ? _e : He2.length, L);
- }
- }, F2 = new Mi();
- return F2.add(T.selectionMoving$.subscribe((O) => {
- N2.current || v(O, false);
- })), F2.add(T.selectionMoveEnd$.subscribe((O) => {
- N2.current || v(O, true);
- })), () => {
- F2.dispose();
- };
- }
- }, [T, d, c, e, l, r, o, C, _, u, x]), (0, import_react.useEffect)(() => {
- if (t && T && d) {
- const I = new Mi(), v = (L, B) => {
- let K2 = 0, V2 = 0, U = false;
- const { sheetName: ne } = x.current, ie = l.current.map((W) => {
- var Ce2;
- if (typeof W == "string")
- return U || (V2 += W.length), W;
- if (W.nodeType === $e2.REFERENCE) {
- const de = fn(W.token);
- if (de.unitId || (de.unitId = o), de.sheetName || (de.sheetName = ne), c && ((Ce2 = x.current.activeSheet) == null ? void 0 : Ce2.getName()) !== de.sheetName)
- return U || (V2 += W.token.length), W;
- if (K2 === B) {
- U = true;
- const fe = { ...W, token: L };
- return c && de.sheetName !== ne ? fe.token = pc(de.sheetName, fn(L).range) : fe.token = L, V2 += fe.token.length, K2++, fe;
- }
- return U || (V2 += W.token.length), K2++, W;
- }
- return U || (V2 += W.token.length), W;
- }), te = Oe2(ie);
- u(te, -1, true), w.current = { result: te, offset: V2 };
- }, F2 = () => {
- I.dispose(), T.getSelectionControls().forEach((B, K2) => {
- I.add(merge(B.selectionMoving$, B.selectionScaling$).pipe(
- map((V2) => fr(V2)),
- distinctUntilChanged(),
- debounceTime(100)
- ).subscribe((V2) => {
- N2.current = true, v(V2, K2);
- }));
- }), I.add(T.selectionMoveEnd$.subscribe((B) => {
- if (N2.current = false, w.current) {
- const { result: K2, offset: V2 } = w.current;
- u(K2, V2 || -1, true), w.current = void 0;
- }
- }));
- }, O = merge(
- d.input$,
- A.selectionSet$,
- T.selectionMoveEnd$
- ).pipe(
- debounceTime(50)
- ).subscribe(() => {
- F2();
- });
- return () => {
- O.unsubscribe(), I.dispose();
- };
- }
- }, [t, T, d, A.selectionSet$, x, l, u, c, o]), (0, import_react.useEffect)(() => {
- if (a) {
- const I = g.onCommandExecuted((v) => {
- if (v.id !== re2.id)
- return;
- const F2 = v.params;
- if (F2.extra !== "formula-editor")
- return;
- const { selections: O } = F2;
- if (O.length) {
- const L = O[O.length - 1];
- if (L) {
- const B = L.range, K2 = r, V2 = {
- range: B,
- unitId: F2.unitId === o ? "" : F2.unitId,
- sheetName: F2.subUnitId === K2 ? "" : C(K2)
- }, U = [...l.current], ie = Ne([V2], c, _)[0];
- let te = U[U.length - 1];
- if (typeof te == "object" && te.nodeType === $e2.REFERENCE) {
- te = { ...te }, te.token = ie, te.endIndex = te.startIndex + ie.length, U[U.length - 1] = te;
- const W = Oe2(U);
- u(W, yt(U), true);
- } else {
- const W = yt(U);
- U.push({
- nodeType: $e2.REFERENCE,
- token: ie,
- startIndex: W,
- endIndex: W + ie.length
- });
- const Ce2 = Oe2(U);
- u(Ce2, yt(U), true);
- }
- }
- }
- });
- return () => {
- I.dispose();
- };
- }
- }, [g, C, u, c, a, l, _, r, o]), (0, import_react.useEffect)(() => {
- if (!d)
- return;
- const I = m3.textSelection$.subscribe((v) => {
- v.unitId === d.getEditorId() && Wr({
- unitId: o,
- subUnitId: r,
- refSelections: s.current,
- editor: d,
- refSelectionsService: A,
- refSelectionsRenderService: T,
- sheetSkeletonManagerService: P,
- themeService: S,
- univerInstanceService: f
- });
- });
- return () => I.unsubscribe();
- }, [m3.textSelection$, d, s, T, A, l, P, r, S, o, f]);
- };
- var Yi = (e, t, n) => {
- const o = W0(ca), r = (0, import_react.useRef)(true);
- (0, import_react.useEffect)(() => {
- if (e) {
- const i = setTimeout(() => {
- r.current = false;
- }, 500);
- return () => {
- clearTimeout(i);
- };
- }
- }, [e]), (0, import_react.useEffect)(() => {
- if (!r.current && t) {
- const i = o.checkIfAddBracket(n);
- t(i === 0 && n.startsWith(X.EQUALS), `${n}`);
- }
- }, [n, t]);
- };
- var zi2 = "univer-sheet-embedding-formula-editor-active";
- var Zi = "univer-sheet-embedding-formula-editor-wrap";
- var Gi = "univer-sheet-embedding-formula-editor-text";
- var Xi = "univer-sheet-embedding-formula-editor-error";
- var Ji2 = "univer-sheet-embedding-formula-editor";
- var Qi = "univer-sheet-embedding-formula-editor-error-wrap";
- var nt2 = {
- sheetEmbeddingFormulaEditorActive: zi2,
- sheetEmbeddingFormulaEditorWrap: Zi,
- sheetEmbeddingFormulaEditorText: Gi,
- sheetEmbeddingFormulaEditorError: Xi,
- sheetEmbeddingFormulaEditor: Ji2,
- sheetEmbeddingFormulaEditorErrorWrap: Qi
- };
- var ec = (e, t = [], n) => {
- const o = W0(Ut), [r, i] = (0, import_react.useState)([]), [s, c] = (0, import_react.useState)(""), a = (0, import_react.useRef)(-1), d = Ct2({ nodes: t }), u = () => {
- i([]), c(""), a.current = -1;
- };
- return (0, import_react.useEffect)(() => {
- if (n && e) {
- const f = n.input$.pipe(debounceTime(300)).subscribe(() => {
- const g = n.getSelectionRanges();
- if (g.length === 1) {
- const l = d.current.nodes, m3 = g[0];
- if (m3.collapsed) {
- const S = Xr(l, m3.startOffset - 1, false);
- a.current = S;
- const R = l[S];
- if (R && typeof R != "string" && R.nodeType === $e2.FUNCTION) {
- a.current = S;
- const C = R.token, _ = o.getSearchListByNameFirstLetter(C);
- i(_), c(C);
- return;
- }
- }
- }
- a.current = -1, c(""), i((l) => l != null && l.length ? [] : l);
- });
- return () => {
- f.unsubscribe();
- };
- }
- }, [n, e]), (0, import_react.useEffect)(() => {
- e || u();
- }, [e]), {
- searchList: r,
- searchText: s,
- handlerFormulaReplace: (f) => {
- const g = [...d.current.nodes];
- if (a.current !== -1) {
- const l = g.splice(a.current + 1), m3 = g.pop() || "";
- let S = (typeof m3 == "string" ? m3.length : m3.token.length) - f.length;
- return g.push(f), l[0] !== K.OPEN_BRACKET && (g.push(K.OPEN_BRACKET), S--), { text: Oe2([...g, ...l]), offset: S };
- }
- },
- reset: u
- };
- };
- var tc = "univer-formula-search-function";
- var nc = "univer-formula-search-function-item";
- var rc = "univer-formula-search-function-item-name";
- var oc = "univer-formula-search-function-item-name-light";
- var sc = "univer-formula-search-function-item-desc";
- var ic = "univer-formula-search-function-item-active";
- var We = {
- formulaSearchFunction: tc,
- formulaSearchFunctionItem: nc,
- formulaSearchFunctionItemName: rc,
- formulaSearchFunctionItemNameLight: oc,
- formulaSearchFunctionItemDesc: sc,
- formulaSearchFunctionItemActive: ic
- };
- var cc = () => {
- };
- var ac = (0, import_react.forwardRef)(lc);
- function lc(e, t) {
- const { isFocus: n, sequenceNodes: o, onSelect: r, editor: i, onClose: s = cc } = e, c = i.getEditorId(), a = W0(it), d = W0(Pt), { searchList: u, searchText: h, handlerFormulaReplace: f, reset: g } = ec(n, o, i), l = (0, import_react.useMemo)(() => !!u.length, [u]), m3 = (0, import_react.useRef)(), [S, R] = (0, import_react.useState)(0), C = (0, import_react.useRef)(false), [_] = Gr(c, l, [h, u]), E = Ct2({ searchList: u, active: S }), x = (N2) => {
- const b = f(N2);
- b && (g(), r(b));
- };
- function M2(N2) {
- C.current && R(N2);
- }
- function T() {
- C.current && R(-1);
- }
- (0, import_react.useEffect)(() => {
- if (!u.length)
- return;
- const N2 = `sheet.formula-embedding-editor.search_function.${c}`, b = new Mi(), w = (I) => {
- const { searchList: v, active: F2 } = E.current;
- switch (I) {
- case I1.ARROW_UP: {
- R((O) => {
- const L = Math.max(0, O - 1);
- return P(L), L;
- });
- break;
- }
- case I1.ARROW_DOWN: {
- R((O) => {
- const L = Math.min(v.length - 1, O + 1);
- return P(L), L;
- });
- break;
- }
- case I1.TAB:
- case I1.ENTER: {
- const O = v[F2];
- x(O.name);
- break;
- }
- case I1.ESC: {
- g(), s();
- break;
- }
- }
- };
- return b.add(d.registerCommand({
- id: N2,
- type: ar.OPERATION,
- handler(I, v) {
- const { keyCode: F2 } = v;
- w(F2);
- }
- })), [I1.ARROW_UP, I1.ARROW_DOWN, I1.ENTER, I1.ESC, I1.TAB].map((I) => ({
- id: N2,
- binding: I,
- preconditions: () => true,
- priority: 1e3,
- staticParameters: {
- eventType: vf.Keyboard,
- keyCode: I
- }
- })).forEach((I) => {
- b.add(a.registerShortcut(I));
- }), () => {
- b.dispose();
- };
- }, [u]);
- function P(N2) {
- var V2;
- const b = (V2 = m3.current) == null ? void 0 : V2.querySelectorAll(`.${We.formulaSearchFunctionItem}`)[N2];
- if (!b)
- return;
- const w = b.parentNode;
- if (!w)
- return;
- const v = w.getBoundingClientRect().top, F2 = w.offsetHeight, O = b.getBoundingClientRect(), L = O.top, B = O.height;
- if (L >= 0 && L > v && L - v + B <= F2)
- return;
- const K2 = b.offsetTop - (F2 - B) / 2;
- w.scrollTo({
- top: K2,
- behavior: "smooth"
- });
- }
- const A = (0, import_react.useMemo)(() => {
- let N2 = "";
- return () => {
- clearTimeout(N2), C.current = true, N2 = setTimeout(() => {
- C.current = false;
- }, 300);
- };
- }, []);
- return u.length > 0 && l && p.jsx(i3, { portal: true, anchorRect$: _, direction: "vertical", children: p.jsx(
- "ul",
- {
- className: We.formulaSearchFunction,
- ref: (N2) => {
- m3.current = N2, t && (t.current = N2);
- },
- children: u.map((N2, b) => p.jsxs(
- "li",
- {
- className: S === b ? `
- ${We.formulaSearchFunctionItem}
- ${We.formulaSearchFunctionItemActive}
- ` : We.formulaSearchFunctionItem,
- onMouseEnter: () => M2(b),
- onMouseLeave: T,
- onMouseMove: A,
- onClick: () => {
- x(N2.name), i && i.focus();
- },
- children: [
- p.jsxs("span", { className: We.formulaSearchFunctionItemName, children: [
- p.jsx("span", { className: We.formulaSearchFunctionItemNameLight, children: N2.name.substring(0, h.length) }),
- p.jsx("span", { children: N2.name.slice(h.length) })
- ] }),
- p.jsx("span", { className: We.formulaSearchFunctionItemDesc, children: N2.desc })
- ]
- },
- N2.name
- ))
- }
- ) });
- }
- var uc = (e) => e.startsWith(X.EQUALS) ? e.slice(1) : "";
- var Qt = () => {
- };
- function fc(e) {
- var Yt, Nn2;
- const {
- errorText: t,
- initValue: n,
- unitId: o,
- subUnitId: r,
- isFocus: i = true,
- isSupportAcrossSheet: s = false,
- onFocus: c = Qt,
- onBlur: a = Qt,
- onChange: d,
- onVerify: u,
- actions: h,
- className: f,
- editorId: g,
- moveCursor: l = true,
- onFormulaSelectingChange: m3,
- keyboradEventConfig: S,
- onMoveInEditor: R,
- resetSelectionOnBlur: C = true,
- autoScrollbar: _ = true,
- isSingle: E = true,
- disableSelectionOnClick: x = false,
- disableContextMenu: M2
- } = e, T = W0(He), P = (0, import_react.useRef)(null), A = n3(d);
- h && (h.handleOutClick = (ae, le) => {
- P.current && !P.current.contains(ae.target) && le();
- });
- const N2 = n3(m3), b = (0, import_react.useRef)(null), w = (0, import_react.useRef)(), I = w.current, [v, F2] = (0, import_react.useState)(i), O = (0, import_react.useRef)(null), L = (0, import_react.useMemo)(() => g != null ? g : k0(`${D2}-${qt(4)}`), []), B = (0, import_react.useMemo)(() => t !== void 0, [t]), K2 = W0(_n), V2 = K2.getUnit(L);
- z0(V2 == null ? void 0 : V2.change$);
- const U = qt2(), ne = st.transform.getPlainText((Nn2 = (Yt = V2 == null ? void 0 : V2.getBody()) == null ? void 0 : Yt.dataStream) != null ? Nn2 : ""), ie = (0, import_react.useMemo)(() => uc(ne), [ne]), te = (0, import_react.useMemo)(() => U(ie), [ie, U]), { isSelecting: W } = li(L, v, x), Ce2 = (0, import_react.useRef)(""), fe = W0(Yx).getRenderById(L), re3 = fe == null ? void 0 : fe.with(Se), be = re3 == null ? void 0 : re3.isFocusing, ce = (0, import_react.useMemo)(() => K2.getCurrentTypeOfUnit$(Fe.UNIVER_DOC), [K2]), _e = z0(ce), me2 = (_e == null ? void 0 : _e.getUnitId()) === L, Re = (0, import_react.useRef)([]), je = W;
- Bl(() => {
- A(ne);
- }, [ne, A]);
- const He2 = Ur("="), j = Rn(o, r), k = n3((ae, le = true, Ae3, Qe) => {
- if (!w.current)
- return;
- Ce2.current = ae;
- const zt = U(ae[0] === "=" ? ae.slice(1) : ""), et2 = He2(
- w.current,
- zt,
- le,
- Qe
- );
- Re.current = et2, Ae3 && j(v ? et2 : [], w.current);
- });
- (0, import_react.useEffect)(() => {
- v && k(ne, false, true);
- }, [ne, v, k]), Yi(v, u, ne);
- const z = Hr2(I), X2 = Yr(v, o, r);
- (0, import_react.useEffect)(() => {
- N2(W);
- }, [N2, W]), lA(v, S, I), (0, import_react.useLayoutEffect)(() => {
- let ae;
- if (O.current) {
- ae = T.register({
- autofocus: true,
- editorUnitId: L,
- initialSnapshot: {
- id: L,
- body: {
- dataStream: `${n}\r
- `,
- textRuns: [],
- customBlocks: [],
- customDecorations: [],
- customRanges: []
- },
- documentStyle: {}
- }
- }, O.current);
- const le = T.getEditor(L);
- w.current = le, k(n, false, true);
- }
- return () => {
- ae == null || ae.dispose();
- };
- }, []), (0, import_react.useLayoutEffect)(() => {
- i ? (F2(i), z()) : (C && (I == null || I.blur(), X2()), F2(i));
- }, [i, I, z, X2, C]);
- const { checkScrollBar: J } = dA(I, E, _);
- In(v, !!(W && me2), o, M2), qr(v && l, je, I, R);
- const oe = n3((ae, le, Ae3) => {
- if (!be)
- return;
- const Qe = le !== -1 ? [{ startOffset: le + 1, endOffset: le + 1, collapsed: true }] : void 0;
- k(`=${ae}`, true, Ae3, Qe), Ae3 && (z(), le !== -1 && setTimeout(() => {
- const zt = { startOffset: le + 1, endOffset: le + 1 }, et2 = I == null ? void 0 : I.render.with(kn);
- et2 == null || et2.scrollToRange({ ...zt, collapsed: true });
- }, 50), J());
- });
- Ki(
- v && !!(W && me2),
- v,
- W,
- o,
- r,
- te,
- Re,
- s,
- !!je,
- I,
- oe
- ), bn(v && !!(W && me2), o, s, F2, a, Qt);
- const Je = (ae) => {
- if (ae) {
- const le = I == null ? void 0 : I.getSelectionRanges();
- if (le && le.length === 1) {
- const Ae3 = le[0];
- if (Ae3.collapsed) {
- const Qe = ae.offset;
- setTimeout(() => {
- I == null || I.setSelectionRanges([{ startOffset: Ae3.startOffset - Qe, endOffset: Ae3.endOffset - Qe }]);
- }, 30);
- }
- }
- z(), k(`=${ae.text}`);
- }
- }, Pe2 = () => {
- F2(true), c(), z();
- };
- return p.jsxs("div", { className: ln(nt2.sheetEmbeddingFormulaEditor, f), children: [
- p.jsx(
- "div",
- {
- className: ln(nt2.sheetEmbeddingFormulaEditorWrap, {
- [nt2.sheetEmbeddingFormulaEditorActive]: v,
- [nt2.sheetEmbeddingFormulaEditorError]: B
- }),
- ref: P,
- children: p.jsx(
- "div",
- {
- className: nt2.sheetEmbeddingFormulaEditorText,
- ref: O,
- onMouseUp: Pe2
- }
- )
- }
- ),
- t !== void 0 ? p.jsx("div", { className: nt2.sheetEmbeddingFormulaEditorErrorWrap, children: t }) : null,
- I ? p.jsx(
- Bi,
- {
- editor: I,
- isFocus: v,
- formulaText: ne,
- onClose: () => z()
- }
- ) : null,
- I ? p.jsx(
- ac,
- {
- isFocus: v,
- sequenceNodes: te,
- onSelect: Je,
- ref: b,
- editor: I
- }
- ) : null
- ] });
- }
- var hc = "sheets-formula-ui.base.config";
- var Xn = {};
- function dc(e) {
- return e.getContextValue(Nr) && e.getContextValue(CR);
- }
- function Jr(e, t = false) {
- return !t && !(vC(e == null ? void 0 : e.f) || yC(e == null ? void 0 : e.si)) ? null : typeof (e == null ? void 0 : e.v) == "string" && yr.has(e.v) ? e.v : null;
- }
- var mc = Object.defineProperty;
- var gc = Object.getOwnPropertyDescriptor;
- var pc2 = (e, t, n, o) => {
- for (var r = o > 1 ? void 0 : o ? gc(t, n) : t, i = e.length - 1, s; i >= 0; i--)
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
- return o && r && mc(t, n, r), r;
- };
- var mt = (e, t) => (n, o) => t(n, o, e);
- var en3 = "SHEET_FORMULA_ALERT";
- var Sc = {
- [m2.DIV_BY_ZERO]: "divByZero",
- [m2.NAME]: "name",
- [m2.VALUE]: "value",
- [m2.NUM]: "num",
- [m2.NA]: "na",
- [m2.CYCLE]: "cycle",
- [m2.REF]: "ref",
- [m2.SPILL]: "spill",
- [m2.CALC]: "calc",
- [m2.ERROR]: "error",
- [m2.CONNECT]: "connect",
- [m2.NULL]: "null"
- };
- var fn2 = class extends nt {
- constructor(e, t, n, o, r, i) {
- super(), this._context = e, this._hoverManagerService = t, this._cellAlertManagerService = n, this._localeService = o, this._formulaDataModel = r, this._zenZoneService = i, this._init();
- }
- _init() {
- this._initCellAlertPopup(), this._initZenService();
- }
- _initCellAlertPopup() {
- this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((e) => {
- var t, n, o, r, i;
- if (e) {
- const c = this._context.unit.getActiveSheet();
- if (!c)
- return;
- const a = c.getCell(e.location.row, e.location.col), d = (r = (o = (n = (t = this._formulaDataModel.getArrayFormulaCellData()) == null ? void 0 : t[e.location.unitId]) == null ? void 0 : n[e.location.subUnitId]) == null ? void 0 : o[e.location.row]) == null ? void 0 : r[e.location.col];
- if (fC(a)) {
- const u = Jr(a, !!d);
- if (!u) {
- this._hideAlert();
- return;
- }
- const h = this._cellAlertManagerService.currentAlert.get(en3), f = (i = h == null ? void 0 : h.alert) == null ? void 0 : i.location;
- if (f && f.row === e.location.row && f.col === e.location.col && f.subUnitId === e.location.subUnitId && f.unitId === e.location.unitId)
- return;
- this._cellAlertManagerService.showAlert({
- type: Ks.ERROR,
- title: this._localeService.t("formula.error.title"),
- message: this._localeService.t(`formula.error.${Sc[u]}`),
- location: e.location,
- width: 200,
- height: 74,
- key: en3
- });
- return;
- }
- }
- this._hideAlert();
- }));
- }
- _initZenService() {
- this.disposeWithMe(this._zenZoneService.visible$.subscribe((e) => {
- e && this._hideAlert();
- }));
- }
- _hideAlert() {
- this._cellAlertManagerService.removeAlert(en3);
- }
- };
- fn2 = pc2([
- mt(1, ot(Er)),
- mt(2, ot(bi)),
- mt(3, ot(Vr)),
- mt(4, ot(Pr)),
- mt(5, u3)
- ], fn2);
- var vc = Object.defineProperty;
- var Cc = Object.getOwnPropertyDescriptor;
- var _c = (e, t, n, o) => {
- for (var r = o > 1 ? void 0 : o ? Cc(t, n) : t, i = e.length - 1, s; i >= 0; i--)
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
- return o && r && vc(t, n, r), r;
- };
- var Jn = (e, t) => (n, o) => t(n, o, e);
- var Pt3 = class extends nt {
- constructor(e, t) {
- super(), this._autoFillService = e, this._lexerTreeBuilder = t, this._registerAutoFill();
- }
- _registerAutoFill() {
- const e = {
- type: ut.FORMULA,
- priority: 1001,
- match: (t) => vC(t == null ? void 0 : t.f) || yC(t == null ? void 0 : t.si),
- isContinue: (t, n) => t.type === ut.FORMULA,
- applyFunctions: {
- [ke.COPY]: (t, n, o, r) => {
- const { data: i, index: s } = t;
- return this._fillCopyFormula(i, n, o, s, r);
- }
- }
- };
- this._autoFillService.registerRule(e);
- }
- _fillCopyFormula(e, t, n, o, r) {
- var a, d;
- const i = Ic(r), s = [], c = /* @__PURE__ */ new Map();
- for (let u = 1; u <= t; u++) {
- const h = (u - 1) % e.length, f = re.deepClone(e[h]);
- if (f) {
- const g = ((a = e[h]) == null ? void 0 : a.f) || "", l = ((d = e[h]) == null ? void 0 : d.si) || "", m3 = vC(g);
- if (yC(l))
- f.si = l, f.f = null, f.v = null, f.p = null, f.t = null, s.push(f);
- else if (m3) {
- let R = c.get(h);
- if (R)
- f.si = R, f.f = null, f.v = null, f.p = null, f.t = null;
- else {
- R = re.generateRandomId(6), c.set(h, R);
- const { offsetX: C, offsetY: _ } = Rc(i, t, n), E = this._lexerTreeBuilder.moveFormulaRefOffset(
- g,
- C,
- _
- );
- f.si = R, f.f = E, f.v = null, f.p = null, f.t = null;
- }
- s.push(f);
- }
- }
- }
- return s;
- }
- };
- Pt3 = _c([
- Jn(0, Hr),
- Jn(1, ot(ca))
- ], Pt3);
- function Rc(e, t, n) {
- let o = 0, r = 0;
- switch (n) {
- case wu.UP:
- r = -e * t;
- break;
- case wu.RIGHT:
- o = e;
- break;
- case wu.DOWN:
- r = e;
- break;
- case wu.LEFT:
- o = -e * t;
- break;
- }
- return { offsetX: o, offsetY: r };
- }
- function Ic(e) {
- let t = 0;
- for (const n in e)
- e[n].forEach((o) => {
- t += o.data.length;
- });
- return t;
- }
- var Ec = Object.defineProperty;
- var bc = Object.getOwnPropertyDescriptor;
- var xc = (e, t, n, o) => {
- for (var r = o > 1 ? void 0 : o ? bc(t, n) : t, i = e.length - 1, s; i >= 0; i--)
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
- return o && r && Ec(t, n, r), r;
- };
- var gt = (e, t) => (n, o) => t(n, o, e);
- var Nc = "default-paste-formula";
- var At = class extends nt {
- constructor(e, t, n, o, r) {
- super(), this._currentUniverSheet = e, this._lexerTreeBuilder = t, this._sheetClipboardService = n, this._injector = o, this._formulaDataModel = r, this._initialize();
- }
- _initialize() {
- this._registerClipboardHook();
- }
- _registerClipboardHook() {
- this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._pasteFormulaHook())), this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._pasteWithFormulaHook()));
- }
- _pasteFormulaHook() {
- return {
- id: rt2.SPECIAL_PASTE_FORMULA,
- priority: 10,
- specialPasteInfo: { label: "specialPaste.formula" },
- onPasteCells: (e, t, n, o) => this._onPasteCells(e, t, n, o, true)
- };
- }
- _pasteWithFormulaHook() {
- return {
- id: Nc,
- priority: 10,
- onPasteCells: (e, t, n, o) => this._onPasteCells(e, t, n, o, false)
- };
- }
- _onPasteCells(e, t, n, o, r) {
- var f;
- if ([
- rt2.SPECIAL_PASTE_FORMAT,
- rt2.SPECIAL_PASTE_COL_WIDTH
- ].includes(o.pasteType))
- return {
- undos: [],
- redos: []
- };
- const s = this._currentUniverSheet.getCurrentUnitForType(Fe.UNIVER_SHEET), c = t.unitId || s.getUnitId(), a = t.subUnitId || ((f = s.getActiveSheet()) == null ? void 0 : f.getSheetId());
- if (!c || !a)
- return {
- undos: [],
- redos: []
- };
- const d = t.range, u = n, h = {
- copyType: o.copyType || gr.COPY,
- copyRange: e == null ? void 0 : e.range,
- pasteType: o.pasteType
- };
- return this._injector.invoke((g) => Fc(
- c,
- a,
- d,
- u,
- g,
- h,
- this._lexerTreeBuilder,
- this._formulaDataModel,
- r,
- e
- ));
- }
- };
- At = xc([
- gt(0, _n),
- gt(1, ot(ca)),
- gt(2, Sn),
- gt(3, ot(Ot)),
- gt(4, ot(Pr))
- ], At);
- function Fc(e, t, n, o, r, i, s, c, a = false, d) {
- const u = [], h = [], f = yc(e, t, n, o, i, s, c, d), g = {
- unitId: e,
- subUnitId: t,
- cellValue: f.getData()
- };
- u.push({
- id: Q.id,
- params: g
- });
- const l = Ae2(
- r,
- g
- );
- return h.push({
- id: Q.id,
- params: l
- }), {
- undos: h,
- redos: u
- };
- }
- function yc(e, t, n, o, r, i, s, c) {
- return c ? r.pasteType === rt2.SPECIAL_PASTE_VALUE ? Oc(e, t, n, o, s, c) : r.pasteType === rt2.SPECIAL_PASTE_FORMULA ? Mc(e, t, n, o, i, s, c) : Pc(e, t, n, o, i, s, c) : Tc(e, t, n, o, s);
- }
- function Tc(e, t, n, o, r) {
- const i = new kt(), s = r.getSheetFormulaData(e, t);
- return o.forValue((c, a, d) => {
- var g;
- const u = n.rows[c], h = n.cols[a], f = {};
- vC(d.v) ? (f.v = null, f.f = `${d.v}`, f.si = null, f.p = null, i.setValue(u, h, f)) : (g = s == null ? void 0 : s[u]) != null && g[h] && (f.v = d.v, f.f = null, f.si = null, f.p = null, i.setValue(u, h, f));
- }), i;
- }
- function Oc(e, t, n, o, r, i) {
- var d, u;
- const s = new kt(), c = (u = (d = r.getArrayFormulaCellData()) == null ? void 0 : d[i.unitId]) == null ? void 0 : u[i.subUnitId], a = r.getSheetFormulaData(e, t);
- return o.forValue((h, f, g) => {
- var _, E;
- const l = i.range.rows[h % i.range.rows.length], m3 = i.range.cols[f % i.range.cols.length], S = n.rows[h], R = n.cols[f], C = {};
- if (vC(g.f) || yC(g.si))
- C.v = g.v, C.f = null, C.si = null, C.p = null, s.setValue(S, R, C);
- else if ((_ = c == null ? void 0 : c[l]) != null && _[m3]) {
- const x = c[l][m3];
- C.v = x.v, C.f = null, C.si = null, C.p = null, s.setValue(S, R, C);
- } else if ((E = a == null ? void 0 : a[S]) != null && E[R]) {
- if (C.v = g.v, C.f = null, C.si = null, C.p = null, g.p) {
- const x = Qr(g);
- x && (C.v = x);
- }
- s.setValue(S, R, C);
- }
- }), s;
- }
- function Mc(e, t, n, o, r, i, s) {
- const c = new kt(), a = /* @__PURE__ */ new Map();
- return o.forValue((d, u, h) => {
- const f = n.rows[d], g = n.cols[u], l = {};
- if (yC(h.si)) {
- if (s.unitId !== e || s.subUnitId !== t) {
- const m3 = i.getFormulaStringByCell(
- s.range.rows[d % s.range.rows.length],
- s.range.cols[u % s.range.cols.length],
- s.subUnitId,
- s.unitId
- ), S = n.cols[u] - s.range.cols[u % s.range.cols.length], R = n.rows[d] - s.range.rows[d % s.range.rows.length], C = r.moveFormulaRefOffset(m3 || "", S, R);
- l.si = null, l.f = C;
- } else
- l.si = h.si, l.f = null;
- l.v = null, l.p = null, c.setValue(f, g, l);
- } else if (vC(h.f)) {
- const m3 = `${d % s.range.rows.length}_${u % s.range.cols.length}`;
- let S = a.get(m3);
- if (S)
- l.si = S, l.f = null;
- else {
- S = re.generateRandomId(6), a.set(m3, S);
- const R = n.cols[u] - s.range.cols[u % s.range.cols.length], C = n.rows[d] - s.range.rows[d % s.range.rows.length], _ = r.moveFormulaRefOffset(h.f || "", R, C);
- l.si = S, l.f = _;
- }
- l.v = null, l.p = null, c.setValue(f, g, l);
- } else {
- if (l.v = h.v, l.f = null, l.si = null, l.p = null, h.p) {
- const m3 = Qr(h);
- m3 && (l.v = m3);
- }
- c.setValue(f, g, l);
- }
- }), c;
- }
- function Pc(e, t, n, o, r, i, s) {
- const c = new kt(), a = /* @__PURE__ */ new Map(), d = i.getSheetFormulaData(e, t);
- return o.forValue((u, h, f) => {
- var S;
- const g = n.rows[u], l = n.cols[h], m3 = {};
- if (yC(f.si)) {
- if (s.unitId !== e || s.subUnitId !== t) {
- const R = i.getFormulaStringByCell(
- s.range.rows[u % s.range.rows.length],
- s.range.cols[h % s.range.cols.length],
- s.subUnitId,
- s.unitId
- ), C = n.cols[h] - s.range.cols[h % s.range.cols.length], _ = n.rows[u] - s.range.rows[u % s.range.rows.length], E = r.moveFormulaRefOffset(R || "", C, _);
- m3.si = null, m3.f = E;
- } else
- m3.si = f.si, m3.f = null;
- m3.v = null, m3.p = null, c.setValue(g, l, m3);
- } else if (vC(f.f)) {
- const R = `${u % s.range.rows.length}_${h % s.range.cols.length}`;
- let C = a.get(R);
- if (C)
- m3.si = C, m3.f = null;
- else {
- C = re.generateRandomId(6), a.set(R, C);
- const _ = n.cols[h] - s.range.cols[h % s.range.cols.length], E = n.rows[u] - s.range.rows[u % s.range.rows.length], x = r.moveFormulaRefOffset(f.f || "", _, E);
- m3.si = C, m3.f = x;
- }
- m3.v = null, m3.p = null, c.setValue(g, l, m3);
- } else
- (S = d == null ? void 0 : d[g]) != null && S[l] && (m3.v = f.v, m3.f = null, m3.si = null, m3.p = f.p, c.setValue(g, l, m3));
- }), c;
- }
- function Qr(e) {
- if (e != null && e.p) {
- const t = e == null ? void 0 : e.p.body;
- if (t == null)
- return;
- const n = t.dataStream;
- return n.substring(n.length - 2, n.length) === Wd ? n.substring(0, n.length - 2) : n;
- }
- }
- var Ac = Object.defineProperty;
- var Lc = Object.getOwnPropertyDescriptor;
- var wc = (e, t, n, o) => {
- for (var r = o > 1 ? void 0 : o ? Lc(t, n) : t, i = e.length - 1, s; i >= 0; i--)
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
- return o && r && Ac(t, n, r), r;
- };
- var ze = (e, t) => (n, o) => t(n, o, e);
- var Lt2 = class extends nt {
- constructor(t, n, o, r, i, s, c, a) {
- super();
- Q2(this, "_previousShape");
- Q2(this, "_skeleton");
- this._context = t, this._sheetInterceptorService = n, this._formulaDataModel = o, this._themeService = r, this._renderManagerService = i, this._sheetSkeletonManagerService = s, this._commandService = c, this._logService = a, this._initSkeletonChangeListener(), this._initInterceptorEditorStart(), this._commandExecutedListener();
- }
- _initSkeletonChangeListener() {
- this.disposeWithMe(
- this._sheetSkeletonManagerService.currentSkeleton$.subscribe((t) => {
- var n, o;
- if (t == null)
- this._logService.debug("[FormulaEditorShowController]: should not receive currentSkeleton$ as null!");
- else {
- const { skeleton: r } = t, i = (o = (n = this._skeleton) == null ? void 0 : n.worksheet) == null ? void 0 : o.getSheetId();
- if (this._changeRuntime(r), i !== r.worksheet.getSheetId())
- this._removeArrayFormulaRangeShape();
- else {
- const { unitId: s, sheetId: c } = t;
- this._updateArrayFormulaRangeShape(s, c);
- }
- }
- })
- );
- }
- _changeRuntime(t) {
- this._skeleton = t;
- }
- _initInterceptorEditorStart() {
- this.disposeWithMe(
- Ze(
- this._sheetInterceptorService.writeCellInterceptor.intercept(
- Go,
- {
- handler: (t, n, o) => {
- var l, m3, S, R;
- const { row: r, col: i, unitId: s, subUnitId: c, worksheet: a } = n, d = this._formulaDataModel.getArrayFormulaRange(), u = this._formulaDataModel.getArrayFormulaCellData();
- if (this._removeArrayFormulaRangeShape(), t == null)
- return o(t);
- let h = null;
- const f = this._formulaDataModel.getFormulaStringByCell(r, i, c, s);
- if (f !== null && (h = { f }), t.v != null && t.v !== "" && ((S = (m3 = (l = u[s]) == null ? void 0 : l[c]) == null ? void 0 : m3[r]) == null ? void 0 : S[i]) == null)
- return h ? { ...t, ...h } : o(t);
- const g = (R = d == null ? void 0 : d[s]) == null ? void 0 : R[c];
- return g != null && (h = this._displayArrayFormulaRangeShape(g, r, i, s, c, a, h)), h ? { ...t, ...h } : o(t);
- }
- }
- )
- )
- );
- }
- _commandExecutedListener() {
- this.disposeWithMe(this._commandService.onCommandExecuted((t, n) => {
- (t.id === Ji.id || t.id === bs.id && n && n.remove) && this._removeArrayFormulaRangeShape();
- })), this.disposeWithMe(
- this._commandService.beforeCommandExecuted((t) => {
- Br.id === t.id && requestIdleCallback(() => {
- const n = t.params, { unitId: o, subUnitId: r, rowsAutoHeightInfo: i } = n;
- this._refreshArrayFormulaRangeShapeByRow(o, r, i);
- });
- })
- );
- }
- _displayArrayFormulaRangeShape(t, n, o, r, i, s, c) {
- const a = this._formulaDataModel.getSheetFormulaData(r, i);
- return new kt(t).forValue((d, u, h) => {
- var S;
- if (h == null)
- return true;
- const { startRow: f, startColumn: g, endRow: l, endColumn: m3 } = h;
- if (d === n && u === o)
- return this._createArrayFormulaRangeShape(h, r), false;
- if (n >= f && n <= l && o >= g && o <= m3) {
- const R = s.getCell(f, g);
- if ((R == null ? void 0 : R.v) === m2.SPILL)
- return;
- const C = (S = a == null ? void 0 : a[d]) == null ? void 0 : S[u];
- return C == null || C.f == null ? true : (c == null && (c = {
- f: C.f,
- isInArrayFormulaRange: true
- }), this._createArrayFormulaRangeShape(h, r), false);
- }
- }), c;
- }
- _createArrayFormulaRangeShape(t, n) {
- const o = this._renderManagerService.getRenderById(n), r = this._sheetSkeletonManagerService.getCurrentSkeleton();
- if (!o || !r)
- return;
- const { scene: i } = o;
- if (!i)
- return;
- const s = this._themeService.getCurrentTheme(), c = {
- range: t,
- primary: null,
- style: {
- strokeWidth: 1,
- stroke: s.hyacinth700,
- fill: new Nt(s.colorWhite).setAlpha(0).toString(),
- widgets: {}
- }
- }, a = Pt2(c, r), { rowHeaderWidth: d, columnHeaderHeight: u } = r, h = new xd(i, $m.FORMULA_EDITOR_SHOW, this._themeService, {
- highlightHeader: false,
- rowHeaderWidth: d,
- columnHeaderHeight: u
- });
- h.updateRangeBySelectionWithCoord(a), h.setEvent(false), this._previousShape = h;
- }
- _removeArrayFormulaRangeShape() {
- this._previousShape != null && (this._previousShape.dispose(), this._previousShape = null);
- }
- _refreshArrayFormulaRangeShape(t, n) {
- if (this._previousShape) {
- const { startRow: o, endRow: r, startColumn: i, endColumn: s } = this._previousShape.getRange(), c = { startRow: o, endRow: r, startColumn: i, endColumn: s };
- this._removeArrayFormulaRangeShape(), this._createArrayFormulaRangeShape(c, t);
- }
- }
- _checkCurrentSheet(t, n) {
- const o = this._sheetSkeletonManagerService.getCurrentSkeleton();
- if (!o)
- return false;
- const r = o.worksheet;
- return r ? r.unitId === t && r.getSheetId() === n : false;
- }
- _updateArrayFormulaRangeShape(t, n) {
- this._checkCurrentSheet(t, n) && this._previousShape && this._refreshArrayFormulaRangeShape(t);
- }
- _refreshArrayFormulaRangeShapeByRow(t, n, o) {
- if (!this._checkCurrentSheet(t, n) || !this._previousShape)
- return;
- const { startRow: r, endRow: i, startColumn: s, endColumn: c } = this._previousShape.getRange();
- for (let a = 0; a < o.length; a++) {
- const { row: d } = o[a];
- if (r >= d) {
- const u = {
- startRow: r,
- endRow: i,
- startColumn: s,
- endColumn: c
- };
- this._refreshArrayFormulaRangeShape(t, u);
- break;
- }
- }
- }
- };
- Lt2 = wc([
- ze(1, ot(V)),
- ze(2, ot(Pr)),
- ze(3, ot(ml)),
- ze(4, Yx),
- ze(5, ot(me)),
- ze(6, Pt),
- ze(7, Mt)
- ], Lt2);
- var $c = Object.defineProperty;
- var Dc = Object.getOwnPropertyDescriptor;
- var kc = (e, t, n, o) => {
- for (var r = o > 1 ? void 0 : o ? Dc(t, n) : t, i = e.length - 1, s; i >= 0; i--)
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
- return o && r && $c(t, n, r), r;
- };
- var Qn = (e, t) => (n, o) => t(n, o, e);
- var jc = {
- tl: {
- size: 6,
- color: "#409f11"
- }
- };
- var wt = class extends J0 {
- constructor(e, t) {
- super(), this._sheetInterceptorService = e, this._formulaDataModel = t, this.disposeWithMe(this._sheetInterceptorService.intercept(
- et.CELL_CONTENT,
- {
- effect: Vn.Style,
- handler: (n, o, r) => {
- var c, a, d, u;
- const i = (u = (d = (a = (c = this._formulaDataModel.getArrayFormulaCellData()) == null ? void 0 : c[o.unitId]) == null ? void 0 : a[o.subUnitId]) == null ? void 0 : d[o.row]) == null ? void 0 : u[o.col];
- return Jr(n, !!i) ? r({
- ...n,
- markers: {
- ...n == null ? void 0 : n.markers,
- ...jc
- }
- }) : r(n);
- },
- priority: 10
- }
- ));
- }
- };
- wt = kc([
- Qn(0, ot(V)),
- Qn(1, ot(Pr))
- ], wt);
- function Hc() {
- const e = W0(Oe), t = W0(Pt), n = z0(e.progress$), o = (0, import_react.useCallback)(() => {
- t.executeCommand(zi.id);
- }, [t]), r = (0, import_react.useCallback)(() => {
- e.clearProgress();
- }, [e]);
- return p.jsx(zl, { progress: n, onTerminate: o, onClearProgress: r });
- }
- var Wc = (e, t = 100) => {
- (0, import_react.useEffect)(() => {
- let n = null;
- const o = () => {
- n === null && (n = window.setTimeout(() => {
- e(), n = null;
- }, t));
- };
- return window.addEventListener("scroll", o), window.addEventListener("resize", o), () => {
- n !== null && clearTimeout(n), window.removeEventListener("scroll", o), window.removeEventListener("resize", o);
- };
- }, [e, t]);
- };
- var Uc = "univer-formula-help-function";
- var Vc = "univer-formula-help-function-title";
- var Bc = "univer-formula-help-function-title-icons";
- var qc = "univer-formula-help-function-title-icon";
- var Kc = "univer-formula-help-function-content";
- var Yc = "univer-formula-help-function-content-inner";
- var zc = "univer-formula-help-function-content-params";
- var Zc = "univer-formula-help-function-content-params-title";
- var Gc = "univer-formula-help-function-content-params-detail";
- var Xc = "univer-formula-help-function-active";
- var Jc = "univer-formula-help-decorator";
- var Qc = "univer-formula-help-param";
- var ea = "univer-formula-help-param-prefix";
- var ta = "univer-formula-help-param-item";
- var na = "univer-formula-help-param-active";
- var se = {
- formulaHelpFunction: Uc,
- formulaHelpFunctionTitle: Vc,
- formulaHelpFunctionTitleIcons: Bc,
- formulaHelpFunctionTitleIcon: qc,
- formulaHelpFunctionContent: Kc,
- formulaHelpFunctionContentInner: Yc,
- formulaHelpFunctionContentParams: zc,
- formulaHelpFunctionContentParamsTitle: Zc,
- formulaHelpFunctionContentParamsDetail: Gc,
- formulaHelpFunctionActive: Xc,
- formulaHelpDecorator: Jc,
- formulaHelpParam: Qc,
- formulaHelpParamPrefix: ea,
- formulaHelpParamItem: ta,
- formulaHelpParamActive: na
- };
- function ra() {
- const [e, t] = (0, import_react.useState)(false), [n, o] = (0, import_react.useState)(true), [r, i] = (0, import_react.useState)(true), [s, c] = (0, import_react.useState)(0), [a, d] = (0, import_react.useState)([0, 0]), [u, h] = (0, import_react.useState)({ left: 0, top: 0 }), [f, g] = (0, import_react.useState)(null), l = W0(Nt2), m3 = W0(Vr), S = m3.t("formula.prompt.required"), R = m3.t("formula.prompt.optional"), C = W0(_n), _ = W0(He), E = W0(rt), x = Af();
- Wc(M2), (0, import_react.useEffect)(() => {
- const N2 = l.help$.subscribe((w) => {
- const { visible: I, paramIndex: v, functionInfo: F2 } = w;
- if (!I) {
- t(I);
- return;
- }
- const O = T();
- if (O == null)
- return;
- const { left: L, top: B, height: K2 } = O;
- F2.description === "" && F2.functionParameter.length === 0 || (d([L, B + K2]), c(v), g(F2), h({ left: L, top: B }), t(I));
- }), b = E.scrollEvent$.pipe(throttleTime(100)).subscribe(M2);
- return () => {
- N2 == null || N2.unsubscribe(), b.unsubscribe();
- };
- }, []);
- function M2() {
- if (!r)
- return;
- const N2 = T();
- if (N2 == null)
- return;
- const { left: b, top: w, height: I } = N2;
- d([b, w + I]);
- }
- function T() {
- const N2 = C.getCurrentUniverDocInstance();
- if (!N2)
- return;
- const b = N2.getUnitId();
- if (!_.isEditor(b))
- return;
- const w = _.getEditor(b);
- return w == null ? void 0 : w.getBoundingClientRect();
- }
- function P(N2) {
- c(N2);
- }
- function A() {
- i(!r), x.get(_1).focus();
- }
- return p.jsx(p.Fragment, { children: r ? p.jsx(JO, { visible: e, offset: a, children: f ? p.jsxs("div", { className: se.formulaHelpFunction, children: [
- p.jsxs("div", { className: se.formulaHelpFunctionTitle, children: [
- p.jsx(
- oa,
- {
- prefix: f.functionName,
- value: f.functionParameter,
- active: s,
- onClick: P
- }
- ),
- p.jsxs("div", { className: se.formulaHelpFunctionTitleIcons, children: [
- p.jsx(
- "div",
- {
- className: se.formulaHelpFunctionTitleIcon,
- style: { transform: n ? "rotateZ(-90deg)" : "rotateZ(90deg)" },
- onClick: () => o(!n),
- children: p.jsx(_n2, {})
- }
- ),
- p.jsx(
- "div",
- {
- className: se.formulaHelpFunctionTitleIcon,
- onClick: A,
- children: p.jsx(Bt, {})
- }
- )
- ] })
- ] }),
- p.jsx(
- "div",
- {
- className: se.formulaHelpFunctionContent,
- style: {
- height: n ? "unset" : 0,
- padding: n ? "revert-layer" : 0
- },
- children: p.jsxs("div", { className: se.formulaHelpFunctionContentInner, children: [
- p.jsx(
- tn,
- {
- title: m3.t("formula.prompt.helpExample"),
- value: `${f.functionName}(${f.functionParameter.map((N2) => N2.example).join(",")})`
- }
- ),
- p.jsx(
- tn,
- {
- title: m3.t("formula.prompt.helpAbstract"),
- value: f.description
- }
- ),
- f && f.functionParameter && f.functionParameter.map((N2, b) => p.jsx(
- tn,
- {
- className: s === b ? se.formulaHelpFunctionActive : "",
- title: N2.name,
- value: `${N2.require ? S : R} ${N2.detail}`
- },
- b
- ))
- ] })
- }
- )
- ] }) : p.jsx(p.Fragment, {}) }) : e ? p.jsx(
- "div",
- {
- className: se.formulaHelpDecorator,
- onClick: () => i(!r),
- style: { left: u.left - 24, top: u.top },
- children: p.jsx($r, {})
- }
- ) : p.jsx(p.Fragment, {}) });
- }
- var tn = (e) => p.jsxs("div", { className: se.formulaHelpFunctionContentParams, children: [
- p.jsx(
- "div",
- {
- className: `
- ${se.formulaHelpFunctionContentParamsTitle}
- ${e.className}
- `,
- children: e.title
- }
- ),
- p.jsx("div", { className: se.formulaHelpFunctionContentParamsDetail, children: e.value })
- ] });
- var oa = (e) => {
- const { prefix: t, value: n, active: o, onClick: r } = e;
- return p.jsxs("div", { className: se.formulaHelpParam, children: [
- p.jsxs("span", { className: se.formulaHelpParamPrefix, children: [
- t,
- "("
- ] }),
- n && n.map((i, s) => (
- // TODO@Dushusir: more params needs to be active
- p.jsxs("span", { className: se.formulaHelpParamItem, children: [
- p.jsx(
- "span",
- {
- className: o === s ? se.formulaHelpFunctionActive : se.formulaHelpParamActive,
- onClick: () => r(s),
- children: xn(i)
- }
- ),
- s === n.length - 1 ? "" : ","
- ] }, s)
- )),
- ")"
- ] });
- };
- var sa = "univer-formula-search-function";
- var ia = "univer-formula-search-function-item";
- var ca2 = "univer-formula-search-function-item-name";
- var aa = "univer-formula-search-function-item-name-light";
- var la = "univer-formula-search-function-item-desc";
- var ua = "univer-formula-search-function-item-active";
- var Ue = {
- formulaSearchFunction: sa,
- formulaSearchFunctionItem: ia,
- formulaSearchFunctionItemName: ca2,
- formulaSearchFunctionItemNameLight: aa,
- formulaSearchFunctionItemDesc: la,
- formulaSearchFunctionItemActive: ua
- };
- function fa() {
- const [e, t] = (0, import_react.useState)(false), [n, o] = (0, import_react.useState)(0), [r, i] = (0, import_react.useState)([0, 0]), [s, c] = (0, import_react.useState)([]), [a, d] = (0, import_react.useState)(""), u = (0, import_react.useRef)(null), h = W0(Nt2), f = W0(_n), g = W0(He);
- (0, import_react.useEffect)(() => {
- let C = [], _ = 0;
- const E = h.search$.subscribe((T) => {
- const { visible: P, searchText: A, searchList: N2 } = T;
- if (!P) {
- t(P);
- return;
- }
- const b = l();
- if (b == null)
- return;
- const { left: w, top: I, height: v } = b;
- d(A), c(N2), C = N2, i([w, I + v]), t(P), o(0), _ = 0;
- }), x = h.navigate$.subscribe((T) => {
- const { direction: P } = T;
- if (P === wu.UP) {
- let A = _ - 1;
- A = A < 0 ? C.length - 1 : A, o(A), _ = A;
- } else if (P === wu.DOWN) {
- let A = _ + 1;
- A = A >= C.length ? 0 : A, o(A), _ = A;
- }
- R(_);
- }), M2 = h.accept$.subscribe((T) => {
- const P = C[_].name;
- h.acceptFormulaName(P);
- });
- return () => {
- E == null || E.unsubscribe(), x == null || x.unsubscribe(), M2 == null || M2.unsubscribe();
- };
- }, []);
- function l() {
- const _ = f.getCurrentUniverDocInstance().getUnitId();
- if (!g.isEditor(_))
- return;
- const E = g.getEditor(_);
- return E == null ? void 0 : E.getBoundingClientRect();
- }
- function m3(C) {
- o(C);
- }
- function S() {
- o(-1);
- }
- function R(C) {
- var w;
- const _ = (w = u.current) == null ? void 0 : w.querySelectorAll(`.${Ue.formulaSearchFunctionItem}`)[C];
- if (!_)
- return;
- const E = _.parentNode;
- if (!E)
- return;
- const M2 = E.getBoundingClientRect().top, T = E.offsetHeight, P = _.getBoundingClientRect(), A = P.top, N2 = P.height;
- if (A >= 0 && A > M2 && A - M2 + N2 <= T)
- return;
- const b = _.offsetTop - (T - N2) / 2;
- E.scrollTo({
- top: b,
- behavior: "smooth"
- });
- }
- return s.length > 0 && p.jsx(JO, { visible: e, offset: r, children: p.jsx("ul", { className: Ue.formulaSearchFunction, ref: u, children: s.map((C, _) => p.jsxs(
- "li",
- {
- className: n === _ ? `
- ${Ue.formulaSearchFunctionItem}
- ${Ue.formulaSearchFunctionItemActive}
- ` : Ue.formulaSearchFunctionItem,
- onMouseEnter: () => m3(_),
- onMouseLeave: S,
- onClick: () => h.acceptFormulaName(C.name),
- children: [
- p.jsxs("span", { className: Ue.formulaSearchFunctionItemName, children: [
- p.jsx("span", { className: Ue.formulaSearchFunctionItemNameLight, children: C.name.substring(0, a.length) }),
- p.jsx("span", { children: C.name.slice(a.length) })
- ] }),
- p.jsx("span", { className: Ue.formulaSearchFunctionItemDesc, children: C.desc })
- ]
- },
- _
- )) }) });
- }
- function ha() {
- return p.jsxs(p.Fragment, { children: [
- p.jsx(fa, {}),
- p.jsx(ra, {})
- ] });
- }
- var da = "univer-formula-more-functions";
- var ma = "univer-formula-more-functions-operation";
- var er = {
- formulaMoreFunctions: da,
- formulaMoreFunctionsOperation: ma
- };
- function eo(e) {
- const { prefix: t, value: n } = e;
- return p.jsxs("div", { children: [
- p.jsxs("span", { children: [
- t,
- "("
- ] }),
- n && n.map((o, r) => p.jsxs("span", { children: [
- p.jsx("span", { children: xn(o) }),
- r === n.length - 1 ? "" : ","
- ] }, r)),
- ")"
- ] });
- }
- var ga = "univer-formula-function-params";
- var pa = "univer-formula-function-params-title";
- var Sa = "univer-formula-function-params-detail";
- var nn = {
- formulaFunctionParams: ga,
- formulaFunctionParamsTitle: pa,
- formulaFunctionParamsDetail: Sa
- };
- function St(e) {
- const { className: t, value: n, title: o } = e;
- return p.jsxs("div", { className: nn.formulaFunctionParams, children: [
- p.jsx(
- "div",
- {
- className: `
- ${nn.formulaFunctionParamsTitle}
- ${t}
- `,
- children: o
- }
- ),
- p.jsx("div", { className: nn.formulaFunctionParamsDetail, children: n })
- ] });
- }
- var va = "univer-formula-input-params-list";
- var Ca = "univer-formula-input-params-list-item-name";
- var _a = "univer-formula-input-params-list-item-selector";
- var pt = {
- formulaInputParamsList: va,
- formulaInputParamsListItemName: Ca,
- formulaInputParamsListItemSelector: _a
- };
- function Ra2(e) {
- const { functionInfo: t, onChange: n } = e;
- if (!t)
- return null;
- (0, import_react.useState)([]);
- const [o, r] = (0, import_react.useState)(t.functionParameter), [i, s] = (0, import_react.useState)(-1);
- return p.jsxs("div", { className: pt.formulaInputParams, children: [
- p.jsx("div", { className: pt.formulaInputParamsList, children: o.map((c, a) => p.jsxs("div", { children: [
- p.jsx("div", { className: pt.formulaInputParamsListItemName, children: c.name }),
- p.jsx("div", { className: pt.formulaInputParamsListItemSelector })
- ] }, a)) }),
- p.jsx("div", { className: pt.formulaInputParamsInfo, children: p.jsx(
- St,
- {
- title: i === -1 ? p.jsx(eo, { prefix: t.functionName, value: o }) : o[i].name,
- value: i === -1 ? t.description : o[i].detail
- }
- ) })
- ] });
- }
- var Ia = "univer-formula-select-function-select";
- var Ea = "univer-formula-select-function-result";
- var ba = "univer-formula-select-function-result-item";
- var xa = "univer-formula-select-function-result-item-name-light";
- var Na = "univer-formula-select-function-result-item-selected";
- var Fa2 = "univer-formula-select-function-result-item-active";
- var ya = "univer-formula-select-function-content";
- var Le2 = {
- formulaSelectFunctionSelect: Ia,
- formulaSelectFunctionResult: Ea,
- formulaSelectFunctionResultItem: ba,
- formulaSelectFunctionResultItemNameLight: xa,
- formulaSelectFunctionResultItemSelected: Na,
- formulaSelectFunctionResultItemActive: Fa2,
- formulaSelectFunctionContent: ya
- };
- function Ta(e) {
- const { onChange: t } = e, n = "-1", [o, r] = (0, import_react.useState)(""), [i, s] = (0, import_react.useState)([]), [c, a] = (0, import_react.useState)(0), [d, u] = (0, import_react.useState)(n), [h, f] = (0, import_react.useState)(0), [g, l] = (0, import_react.useState)(null), m3 = W0(Ut), S = W0(Vr), R = W0(rt), C = z0(R.sidebarOptions$), _ = xi(Ju, S);
- _.unshift({
- label: S.t("formula.moreFunctions.allFunctions"),
- value: n
- });
- const E = S.t("formula.prompt.required"), x = S.t("formula.prompt.optional");
- (0, import_react.useEffect)(() => {
- P(n);
- }, []), (0, import_react.useEffect)(() => {
- T(0);
- }, [i]), (0, import_react.useEffect)(() => {
- C != null && C.visible && (r(""), s([]), a(0), u(n), f(0), l(null), P(n));
- }, [C]);
- const M2 = (I) => {
- if (o.trim() === "")
- return I;
- const v = new RegExp(`(${o.toLocaleUpperCase()})`);
- return I.split(v).filter(Boolean).map((O, L) => O.match(v) ? p.jsx("span", { className: Le2.formulaSelectFunctionResultItemNameLight, children: O }, L) : O);
- }, T = (I) => {
- if (i.length === 0) {
- l(null);
- return;
- }
- f(I);
- const v = m3.getFunctionInfo(i[I].name);
- if (!v) {
- l(null);
- return;
- }
- l(v), t(v);
- };
- function P(I) {
- u(I);
- const v = m3.getSearchListByType(+I);
- s(v);
- }
- function A(I) {
- r(I);
- const v = m3.getSearchListByName(I);
- s(v);
- }
- function N2(I) {
- if (I.stopPropagation(), I.key === "ArrowDown") {
- const v = c + 1;
- a(v === i.length ? 0 : v);
- } else if (I.key === "ArrowUp") {
- const v = c - 1;
- a(v === -1 ? i.length - 1 : v);
- } else
- I.key === "Enter" && T(c);
- }
- const b = (I) => {
- a(I);
- }, w = () => {
- a(-1);
- };
- return p.jsxs("div", { children: [
- p.jsxs("div", { className: Le2.formulaSelectFunctionSelect, children: [
- p.jsx(r_, { value: d, options: _, onChange: P }),
- p.jsx(
- QC,
- {
- placeholder: S.t("formula.moreFunctions.searchFunctionPlaceholder"),
- onKeyDown: N2,
- value: o,
- onChange: A,
- size: "large",
- allowClear: true
- }
- )
- ] }),
- p.jsx("ul", { className: Le2.formulaSelectFunctionResult, onKeyDown: N2, tabIndex: -1, children: i.map(({ name: I }, v) => p.jsxs(
- "li",
- {
- className: c === v ? `
- ${Le2.formulaSelectFunctionResultItem}
- ${Le2.formulaSelectFunctionResultItemActive}
- ` : Le2.formulaSelectFunctionResultItem,
- onMouseEnter: () => b(v),
- onMouseLeave: w,
- onClick: () => T(v),
- children: [
- h === v && p.jsx(Lr, { className: Le2.formulaSelectFunctionResultItemSelected }),
- p.jsx("span", { className: Le2.formulaSelectFunctionResultItemName, children: M2(I) })
- ]
- },
- v
- )) }),
- g && p.jsxs("div", { className: Le2.formulaSelectFunctionContent, children: [
- p.jsx(St, { title: g.functionName, value: g.description }),
- p.jsx(
- St,
- {
- title: S.t("formula.moreFunctions.syntax"),
- value: p.jsx(eo, { prefix: g.functionName, value: g.functionParameter })
- }
- ),
- p.jsx(
- St,
- {
- title: S.t("formula.prompt.helpExample"),
- value: `${g.functionName}(${g.functionParameter.map((I) => I.example).join(",")})`
- }
- ),
- g.functionParameter && g.functionParameter.map((I, v) => p.jsx(
- St,
- {
- title: I.name,
- value: `${I.require ? E : x} ${I.detail}`
- },
- v
- ))
- ] })
- ] });
- }
- function Oa() {
- const e = Wn(), [t, n] = (0, import_react.useState)(true), [o, r] = (0, import_react.useState)(false), [i, s] = (0, import_react.useState)(null), c = W0(tt), a = W0(Vr), d = W0(He), u = W0(_n);
- function h() {
- n(!t), r(!o);
- }
- function f() {
- const g = N(u);
- if (!g)
- return;
- c.changeVisible({
- visible: true,
- unitId: g.unitId,
- eventType: vf.Dblclick
- });
- const l = d.getEditor(su), m3 = d.getEditor(iu), S = `=${i == null ? void 0 : i.functionName}(`;
- l == null || l.replaceText(S), m3 == null || m3.replaceText(S, false);
- }
- return p.jsxs("div", { className: er.formulaMoreFunctions, children: [
- t && p.jsx(Ta, { onChange: s }),
- o && p.jsx(Ra2, { functionInfo: i, onChange: () => {
- } }),
- p.jsxs("div", { className: er.formulaMoreFunctionsOperation, children: [
- o && p.jsx(Po, { type: "primary", size: "small", onClick: h, children: a.t("formula.moreFunctions.next") }),
- o && p.jsx(Po, { size: "small", onClick: h, children: a.t("formula.moreFunctions.prev") }),
- t && !!e && p.jsx(Po, { type: "primary", size: "small", onClick: f, children: a.t("formula.moreFunctions.confirm") })
- ] })
- ] });
- }
- function Ma(e) {
- return {
- id: vn.id,
- icon: "FunctionSingle",
- tooltip: "formula.insert.tooltip",
- type: $e.SELECTOR,
- selections: [
- {
- label: "SUM",
- value: "SUM",
- icon: "SumSingle"
- },
- {
- label: "AVERAGE",
- value: "AVERAGE",
- icon: "AvgSingle"
- },
- {
- label: "COUNT",
- value: "COUNT",
- icon: "CntSingle"
- },
- {
- label: "MAX",
- value: "MAX",
- icon: "MaxSingle"
- },
- {
- label: "MIN",
- value: "MIN",
- icon: "MinSingle"
- }
- ],
- hidden$: Fa(e, Fe.UNIVER_SHEET),
- disabled$: ue(e, { workbookTypes: [Me], worksheetTypes: [Te, wn], rangeTypes: [Pe] })
- };
- }
- function Pa(e) {
- return {
- id: Cn.id,
- title: "formula.insert.more",
- type: $e.BUTTON
- };
- }
- function Aa2(e) {
- return e.get(_n).getCurrentTypeOfUnit$(Fe.UNIVER_SHEET).pipe(
- switchMap((o) => o ? e.get(Pi) ? new Observable((i) => i.next(!e.get(Pi).supportClipboard)) : of(true) : of(true))
- );
- }
- function La(e) {
- return {
- id: Sn2.id,
- type: $e.BUTTON,
- title: "formula.operation.pasteFormula",
- disabled$: Aa2(e).pipe(
- combineLatestWith(ue(e, { workbookTypes: [Me], rangeTypes: [Pe], worksheetTypes: [wn, Te] })),
- map(([t, n]) => t || n)
- )
- };
- }
- var wa = {
- [l1.FORMULAS_INSERT]: {
- [vn.id]: {
- order: 1,
- menuItemFactory: Ma,
- [Cn.id]: {
- order: 1,
- menuItemFactory: Pa
- }
- }
- },
- [go]: {
- [Sn2.id]: {
- order: 4,
- menuItemFactory: La
- }
- }
- };
- var $a = "meta_key_ctrl_And_Shift";
- var Kt = [
- I1.ARROW_DOWN,
- I1.ARROW_UP,
- I1.ARROW_LEFT,
- I1.ARROW_RIGHT
- ];
- var Da = [...Kt, I1.ENTER, I1.TAB, I1.ESC];
- function ka() {
- const e = [];
- for (const t of Da)
- e.push({
- id: ut2.id,
- binding: t,
- preconditions: (n) => rE(n),
- staticParameters: {
- eventType: vf.Keyboard,
- keycode: t
- }
- });
- return e;
- }
- function ja() {
- const e = [];
- for (const t of Kt)
- e.push({
- id: ut2.id,
- binding: t | Ae.SHIFT,
- preconditions: (n) => rE(n),
- staticParameters: {
- eventType: vf.Keyboard,
- keycode: t,
- metaKey: Ae.SHIFT
- }
- });
- return e;
- }
- function Ha() {
- const e = [];
- for (const t of Kt)
- e.push({
- id: ut2.id,
- binding: t | Ae.CTRL_COMMAND,
- preconditions: (n) => rE(n),
- staticParameters: {
- eventType: vf.Keyboard,
- keycode: t,
- metaKey: Ae.CTRL_COMMAND
- }
- });
- return e;
- }
- function Wa() {
- const e = [];
- for (const t of Kt)
- e.push({
- id: ut2.id,
- binding: t | Ae.SHIFT | Ae.CTRL_COMMAND,
- preconditions: (n) => rE(n),
- staticParameters: {
- eventType: vf.Keyboard,
- keycode: t,
- metaKey: $a
- }
- });
- return e;
- }
- var Ua = {
- id: Pr2.id,
- binding: I1.F4,
- preconditions: (e) => rE(e)
- };
- function Va() {
- const e = [];
- for (const t of [I1.ENTER, I1.TAB, I1.ARROW_DOWN, I1.ARROW_UP])
- e.push({
- id: ut2.id,
- binding: t,
- preconditions: (n) => dc(n),
- staticParameters: {
- eventType: vf.Keyboard,
- keycode: t,
- isSingleEditor: true
- }
- });
- return e;
- }
- var Ba = Object.defineProperty;
- var qa = Object.getOwnPropertyDescriptor;
- var Ka = (e, t, n, o) => {
- for (var r = o > 1 ? void 0 : o ? qa(t, n) : t, i = e.length - 1, s; i >= 0; i--)
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
- return o && r && Ba(t, n, r), r;
- };
- var Ze2 = (e, t) => (n, o) => t(n, o, e);
- var $t = class extends nt {
- constructor(e, t, n, o, r, i, s) {
- super(), this._injector = e, this._menuManagerService = t, this._commandService = n, this._shortcutService = o, this._uiPartsService = r, this._renderManagerService = i, this._componentManager = s, this._initialize();
- }
- _initialize() {
- this._registerCommands(), this._registerMenus(), this._registerShortcuts(), this._registerComponents(), this._registerRenderModules();
- }
- _registerMenus() {
- this._menuManagerService.mergeMenu(wa);
- }
- _registerCommands() {
- [
- Sn2,
- vn,
- Cn,
- Ws,
- $s,
- ut2,
- Pr2
- ].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e)));
- }
- _registerShortcuts() {
- [
- ...ka(),
- ...ja(),
- ...Ha(),
- ...Wa(),
- ...Va(),
- Ua
- ].forEach((e) => {
- this.disposeWithMe(this._shortcutService.registerShortcut(e));
- });
- }
- _registerComponents() {
- this.disposeWithMe(this._uiPartsService.registerComponent(Le.CONTENT, () => B0(ha, this._injector))), this.disposeWithMe(this._uiPartsService.registerComponent(Gm.FORMULA_AUX, () => B0(Hc, this._injector))), this._componentManager.register(Mr, Oa);
- }
- _registerRenderModules() {
- this.disposeWithMe(this._renderManagerService.registerRenderModule(Fe.UNIVER_SHEET, [Lt2]));
- }
- };
- $t = Ka([
- Ze2(0, ot(Ot)),
- Ze2(1, m1),
- Ze2(2, Pt),
- Ze2(3, it),
- Ze2(4, f1),
- Ze2(5, Yx),
- Ze2(6, ot(n1))
- ], $t);
- var to = Object.defineProperty;
- var Ya = Object.getOwnPropertyDescriptor;
- var za = (e, t, n) => t in e ? to(e, t, { enumerable: true, configurable: true, writable: true, value: n }) : e[t] = n;
- var Za = (e, t, n, o) => {
- for (var r = o > 1 ? void 0 : o ? Ya(t, n) : t, i = e.length - 1, s; i >= 0; i--)
- (s = e[i]) && (r = (o ? s(t, n, r) : s(r)) || r);
- return o && r && to(t, n, r), r;
- };
- var rn = (e, t) => (n, o) => t(n, o, e);
- var no = (e, t, n) => za(e, typeof t != "symbol" ? t + "" : t, n);
- var Dt2 = class extends Ra {
- constructor(e = Xn, t, n, o) {
- super(), this._config = e, this._injector = t, this._renderManagerService = n, this._configService = o;
- const { menu: r, ...i } = nu(
- Xn,
- this._config
- );
- r && this._configService.setConfig("menu", r, { merge: true }), this._configService.setConfig(hc, i);
- }
- onStarting() {
- const e = this._injector;
- [
- [Nt2, { useClass: an2 }],
- [$t],
- [Pt3],
- [At],
- [Lt2],
- [wt]
- ].forEach((o) => e.add(o));
- const n = this._injector.get(n1);
- n.register(Jm, Ei), n.register(Td, fc);
- }
- onRendered() {
- [
- [Fe2],
- [fn2]
- ].forEach((e) => {
- this.disposeWithMe(this._renderManagerService.registerRenderModule(Fe.UNIVER_SHEET, e));
- }), Mf(this._injector, [
- [$t],
- // FormulaProgressBar relies on TriggerCalculationController, but it is necessary to ensure that the formula calculation is done after rendered.
- [At],
- [wt]
- ]);
- }
- onSteady() {
- this._injector.get(Pt3);
- }
- };
- no(Dt2, "pluginName", Or);
- no(Dt2, "type", Fe.UNIVER_SHEET);
- Dt2 = Za([
- OR(Fi, tt2),
- rn(1, ot(Ot)),
- rn(2, Yx),
- rn(3, SE)
- ], Dt2);
- export {
- Sn2 as Sn,
- ut2 as ut,
- ws,
- $s,
- vn,
- Cn,
- Pr2 as Pr,
- Ws,
- Fe2 as Fe,
- Ei,
- fc,
- Dt2 as Dt
- };
- /*! Bundled license information:
- @univerjs/sheets-formula-ui/lib/es/index.js:
- (**
- * @license React
- * react-jsx-runtime.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *)
- */
- //# sourceMappingURL=chunk-U3EPM6JO.js.map
|