@odoo/o-spreadsheet 15.2.4 → 15.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27022,14 +27022,31 @@ class ContentEditableHelper {
27022
27022
  * */
27023
27023
  getCurrentSelection() {
27024
27024
  let { startElement, endElement, startSelectionOffset, endSelectionOffset } = this.getStartAndEndSelection();
27025
- let startSizeBefore = this.findSizeBeforeElement(startElement);
27026
- let endSizeBefore = this.findSizeBeforeElement(endElement);
27025
+ let startSizeBefore = this.findSelectionIndex(startElement, startSelectionOffset);
27026
+ let endSizeBefore = this.findSelectionIndex(endElement, endSelectionOffset);
27027
27027
  return {
27028
- start: startSizeBefore + startSelectionOffset,
27029
- end: endSizeBefore + endSelectionOffset,
27028
+ start: startSizeBefore,
27029
+ end: endSizeBefore,
27030
27030
  };
27031
27031
  }
27032
- findSizeBeforeElement(nodeToFind) {
27032
+ /**
27033
+ * Computes the text 'index' inside this.el based on the currently selected node and its offset.
27034
+ * The selected node is either a Text node or an Element node.
27035
+ *
27036
+ * case 1 -Text node:
27037
+ * the offset is the number of characters from the start of the node. We have to add this offset to the
27038
+ * content length of all previous nodes.
27039
+ *
27040
+ * case 2 - Element node:
27041
+ * the offset is the number of child nodes before the selected node. We have to add the content length of
27042
+ * all the bnodes prior to the selected node as well as the content of the child node before the offset.
27043
+ *
27044
+ * See the MDN documentation for more details.
27045
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset
27046
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
27047
+ *
27048
+ */
27049
+ findSelectionIndex(nodeToFind, nodeOffset) {
27033
27050
  let it = this.iterateChildren(this.el);
27034
27051
  let usedCharacters = 0;
27035
27052
  let current = it.next();
@@ -27041,6 +27058,19 @@ class ContentEditableHelper {
27041
27058
  }
27042
27059
  current = it.next();
27043
27060
  }
27061
+ if (current.value === nodeToFind) {
27062
+ if (!current.value.hasChildNodes()) {
27063
+ usedCharacters += nodeOffset;
27064
+ }
27065
+ else {
27066
+ const children = [...current.value.childNodes].slice(0, nodeOffset);
27067
+ for (const child of children) {
27068
+ if (!child.textContent)
27069
+ continue;
27070
+ usedCharacters += child.textContent.length;
27071
+ }
27072
+ }
27073
+ }
27044
27074
  return usedCharacters;
27045
27075
  }
27046
27076
  getStartAndEndSelection() {
@@ -31302,6 +31332,6 @@ exports.registries = registries;
31302
31332
  exports.setTranslationMethod = setTranslationMethod;
31303
31333
 
31304
31334
 
31305
- __info__.version = '15.2.4';
31306
- __info__.date = '2023-04-13T08:15:24.992Z';
31307
- __info__.hash = '23f0126';
31335
+ __info__.version = '15.2.5';
31336
+ __info__.date = '2023-04-21T07:27:24.954Z';
31337
+ __info__.hash = '0896859';
@@ -4288,7 +4288,24 @@ declare class ContentEditableHelper {
4288
4288
  start: number;
4289
4289
  end: number;
4290
4290
  };
4291
- private findSizeBeforeElement;
4291
+ /**
4292
+ * Computes the text 'index' inside this.el based on the currently selected node and its offset.
4293
+ * The selected node is either a Text node or an Element node.
4294
+ *
4295
+ * case 1 -Text node:
4296
+ * the offset is the number of characters from the start of the node. We have to add this offset to the
4297
+ * content length of all previous nodes.
4298
+ *
4299
+ * case 2 - Element node:
4300
+ * the offset is the number of child nodes before the selected node. We have to add the content length of
4301
+ * all the bnodes prior to the selected node as well as the content of the child node before the offset.
4302
+ *
4303
+ * See the MDN documentation for more details.
4304
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset
4305
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
4306
+ *
4307
+ */
4308
+ private findSelectionIndex;
4292
4309
  private getStartAndEndSelection;
4293
4310
  }
4294
4311
 
@@ -26999,14 +26999,31 @@ class ContentEditableHelper {
26999
26999
  * */
27000
27000
  getCurrentSelection() {
27001
27001
  let { startElement, endElement, startSelectionOffset, endSelectionOffset } = this.getStartAndEndSelection();
27002
- let startSizeBefore = this.findSizeBeforeElement(startElement);
27003
- let endSizeBefore = this.findSizeBeforeElement(endElement);
27002
+ let startSizeBefore = this.findSelectionIndex(startElement, startSelectionOffset);
27003
+ let endSizeBefore = this.findSelectionIndex(endElement, endSelectionOffset);
27004
27004
  return {
27005
- start: startSizeBefore + startSelectionOffset,
27006
- end: endSizeBefore + endSelectionOffset,
27005
+ start: startSizeBefore,
27006
+ end: endSizeBefore,
27007
27007
  };
27008
27008
  }
27009
- findSizeBeforeElement(nodeToFind) {
27009
+ /**
27010
+ * Computes the text 'index' inside this.el based on the currently selected node and its offset.
27011
+ * The selected node is either a Text node or an Element node.
27012
+ *
27013
+ * case 1 -Text node:
27014
+ * the offset is the number of characters from the start of the node. We have to add this offset to the
27015
+ * content length of all previous nodes.
27016
+ *
27017
+ * case 2 - Element node:
27018
+ * the offset is the number of child nodes before the selected node. We have to add the content length of
27019
+ * all the bnodes prior to the selected node as well as the content of the child node before the offset.
27020
+ *
27021
+ * See the MDN documentation for more details.
27022
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset
27023
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
27024
+ *
27025
+ */
27026
+ findSelectionIndex(nodeToFind, nodeOffset) {
27010
27027
  let it = this.iterateChildren(this.el);
27011
27028
  let usedCharacters = 0;
27012
27029
  let current = it.next();
@@ -27018,6 +27035,19 @@ class ContentEditableHelper {
27018
27035
  }
27019
27036
  current = it.next();
27020
27037
  }
27038
+ if (current.value === nodeToFind) {
27039
+ if (!current.value.hasChildNodes()) {
27040
+ usedCharacters += nodeOffset;
27041
+ }
27042
+ else {
27043
+ const children = [...current.value.childNodes].slice(0, nodeOffset);
27044
+ for (const child of children) {
27045
+ if (!child.textContent)
27046
+ continue;
27047
+ usedCharacters += child.textContent.length;
27048
+ }
27049
+ }
27050
+ }
27021
27051
  return usedCharacters;
27022
27052
  }
27023
27053
  getStartAndEndSelection() {
@@ -31256,6 +31286,6 @@ const helpers = {
31256
31286
  export { CommandResult, CorePlugin, DATETIME_FORMAT, DataSource, DispatchResult, Model, Registry, Revision, SPREADSHEET_DIMENSIONS, Spreadsheet, UIPlugin, DEBUG as __DEBUG__, __info__, astToFormula, cellTypes, compile, convertAstNodes, coreTypes, functionCache, helpers, invalidateEvaluationCommands, parse, readonlyAllowedCommands, registries, setTranslationMethod };
31257
31287
 
31258
31288
 
31259
- __info__.version = '15.2.4';
31260
- __info__.date = '2023-04-13T08:15:24.992Z';
31261
- __info__.hash = '23f0126';
31289
+ __info__.version = '15.2.5';
31290
+ __info__.date = '2023-04-21T07:27:24.954Z';
31291
+ __info__.hash = '0896859';
@@ -27019,14 +27019,31 @@
27019
27019
  * */
27020
27020
  getCurrentSelection() {
27021
27021
  let { startElement, endElement, startSelectionOffset, endSelectionOffset } = this.getStartAndEndSelection();
27022
- let startSizeBefore = this.findSizeBeforeElement(startElement);
27023
- let endSizeBefore = this.findSizeBeforeElement(endElement);
27022
+ let startSizeBefore = this.findSelectionIndex(startElement, startSelectionOffset);
27023
+ let endSizeBefore = this.findSelectionIndex(endElement, endSelectionOffset);
27024
27024
  return {
27025
- start: startSizeBefore + startSelectionOffset,
27026
- end: endSizeBefore + endSelectionOffset,
27025
+ start: startSizeBefore,
27026
+ end: endSizeBefore,
27027
27027
  };
27028
27028
  }
27029
- findSizeBeforeElement(nodeToFind) {
27029
+ /**
27030
+ * Computes the text 'index' inside this.el based on the currently selected node and its offset.
27031
+ * The selected node is either a Text node or an Element node.
27032
+ *
27033
+ * case 1 -Text node:
27034
+ * the offset is the number of characters from the start of the node. We have to add this offset to the
27035
+ * content length of all previous nodes.
27036
+ *
27037
+ * case 2 - Element node:
27038
+ * the offset is the number of child nodes before the selected node. We have to add the content length of
27039
+ * all the bnodes prior to the selected node as well as the content of the child node before the offset.
27040
+ *
27041
+ * See the MDN documentation for more details.
27042
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset
27043
+ * https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
27044
+ *
27045
+ */
27046
+ findSelectionIndex(nodeToFind, nodeOffset) {
27030
27047
  let it = this.iterateChildren(this.el);
27031
27048
  let usedCharacters = 0;
27032
27049
  let current = it.next();
@@ -27038,6 +27055,19 @@
27038
27055
  }
27039
27056
  current = it.next();
27040
27057
  }
27058
+ if (current.value === nodeToFind) {
27059
+ if (!current.value.hasChildNodes()) {
27060
+ usedCharacters += nodeOffset;
27061
+ }
27062
+ else {
27063
+ const children = [...current.value.childNodes].slice(0, nodeOffset);
27064
+ for (const child of children) {
27065
+ if (!child.textContent)
27066
+ continue;
27067
+ usedCharacters += child.textContent.length;
27068
+ }
27069
+ }
27070
+ }
27041
27071
  return usedCharacters;
27042
27072
  }
27043
27073
  getStartAndEndSelection() {
@@ -31301,9 +31331,9 @@
31301
31331
  Object.defineProperty(exports, '__esModule', { value: true });
31302
31332
 
31303
31333
 
31304
- __info__.version = '15.2.4';
31305
- __info__.date = '2023-04-13T08:15:24.992Z';
31306
- __info__.hash = '23f0126';
31334
+ __info__.version = '15.2.5';
31335
+ __info__.date = '2023-04-21T07:27:24.954Z';
31336
+ __info__.hash = '0896859';
31307
31337
 
31308
31338
 
31309
31339
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);
@@ -1749,7 +1749,7 @@
1749
1749
  }
1750
1750
  }
1751
1751
  }
1752
- `;class Rp extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],selectedIndex:0})}setup(){bp((()=>this.filter(this.props.search))),Sp((e=>this.checkUpdateProps(e))),this.props.exposeAPI({getValueToFill:()=>this.getValueToFill(),moveDown:()=>this.moveDown(),moveUp:()=>this.moveUp()})}checkUpdateProps(e){e.search!==this.props.search&&this.filter(e.search)}async filter(e){let t=Ip.get(this.props.provider)();t=this.props.filter?this.props.filter(e,t):t.filter((t=>t.text.toUpperCase().startsWith(e.toUpperCase()))).sort(((e,t)=>e.text<t.text?-1:e.text>t.text?1:0)),this.state.values=t.slice(0,10),this.state.selectedIndex=0}fillValue(e){this.state.selectedIndex=e,this.props.onCompleted(this.getValueToFill())}moveDown(){this.state.selectedIndex=(this.state.selectedIndex+1)%this.state.values.length}moveUp(){this.state.selectedIndex--,this.state.selectedIndex<0&&(this.state.selectedIndex=this.state.values.length-1)}getValueToFill(){if(this.state.values.length)return this.state.values[this.state.selectedIndex].text}}Rp.template=xp,Rp.style=Tp;class Lp{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let s=window.getSelection();this.removeSelection();let o=document.createRange();if(e==t&&0===e)o.setStart(this.el,0),o.setEnd(this.el,0),s.addRange(o);else{(e<0||t>this.el.textContent.length)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${this.el.textContent.length}`),e<0&&(e=0),t>this.el.textContent.length&&(t=this.el.textContent.length),e>this.el.textContent.length&&(e=this.el.textContent.length));let i=this.findChildAtCharacterIndex(e),n=this.findChildAtCharacterIndex(t);o.setStart(i.node,i.offset),s.addRange(o),s.extend(n.node,n.offset)}}findChildAtCharacterIndex(e){let t,s,o=this.iterateChildren(this.el),i=e;do{t=o.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<i?i-=t.value.textContent.length:o.return(t.value),s=t.value)}while(!t.done);return t.value?{node:t.value,offset:i}:{node:s,offset:i}}*iterateChildren(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*this.iterateChildren(t)}setText(e){if(0!==e.length)for(const t of e){const e=document.createElement("span");e.innerText=t.value,t.color&&(e.style.color=t.color),t.class&&e.classList.add(t.class),this.el.appendChild(e)}}removeSelection(){window.getSelection().removeAllRanges()}removeAll(){if(this.el)for(;this.el.firstChild;)this.el.removeChild(this.el.firstChild)}getCurrentSelection(){let{startElement:e,endElement:t,startSelectionOffset:s,endSelectionOffset:o}=this.getStartAndEndSelection();return{start:this.findSizeBeforeElement(e)+s,end:this.findSizeBeforeElement(t)+o}}findSizeBeforeElement(e){let t=this.iterateChildren(this.el),s=0,o=t.next();for(;!o.done&&o.value!==e;)o.value.hasChildNodes()||o.value.textContent&&(s+=o.value.textContent.length),o=t.next();return s}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}}const Mp=a("ABOUT"),Ap=a("optional"),_p=a("by default"),Op=a("repeatable"),{xml:Np,css:kp}=t.tags,{useState:Fp,onWillUnmount:$p}=t.hooks,Dp=Np`
1752
+ `;class Rp extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],selectedIndex:0})}setup(){bp((()=>this.filter(this.props.search))),Sp((e=>this.checkUpdateProps(e))),this.props.exposeAPI({getValueToFill:()=>this.getValueToFill(),moveDown:()=>this.moveDown(),moveUp:()=>this.moveUp()})}checkUpdateProps(e){e.search!==this.props.search&&this.filter(e.search)}async filter(e){let t=Ip.get(this.props.provider)();t=this.props.filter?this.props.filter(e,t):t.filter((t=>t.text.toUpperCase().startsWith(e.toUpperCase()))).sort(((e,t)=>e.text<t.text?-1:e.text>t.text?1:0)),this.state.values=t.slice(0,10),this.state.selectedIndex=0}fillValue(e){this.state.selectedIndex=e,this.props.onCompleted(this.getValueToFill())}moveDown(){this.state.selectedIndex=(this.state.selectedIndex+1)%this.state.values.length}moveUp(){this.state.selectedIndex--,this.state.selectedIndex<0&&(this.state.selectedIndex=this.state.values.length-1)}getValueToFill(){if(this.state.values.length)return this.state.values[this.state.selectedIndex].text}}Rp.template=xp,Rp.style=Tp;class Lp{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let s=window.getSelection();this.removeSelection();let o=document.createRange();if(e==t&&0===e)o.setStart(this.el,0),o.setEnd(this.el,0),s.addRange(o);else{(e<0||t>this.el.textContent.length)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${this.el.textContent.length}`),e<0&&(e=0),t>this.el.textContent.length&&(t=this.el.textContent.length),e>this.el.textContent.length&&(e=this.el.textContent.length));let i=this.findChildAtCharacterIndex(e),n=this.findChildAtCharacterIndex(t);o.setStart(i.node,i.offset),s.addRange(o),s.extend(n.node,n.offset)}}findChildAtCharacterIndex(e){let t,s,o=this.iterateChildren(this.el),i=e;do{t=o.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<i?i-=t.value.textContent.length:o.return(t.value),s=t.value)}while(!t.done);return t.value?{node:t.value,offset:i}:{node:s,offset:i}}*iterateChildren(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*this.iterateChildren(t)}setText(e){if(0!==e.length)for(const t of e){const e=document.createElement("span");e.innerText=t.value,t.color&&(e.style.color=t.color),t.class&&e.classList.add(t.class),this.el.appendChild(e)}}removeSelection(){window.getSelection().removeAllRanges()}removeAll(){if(this.el)for(;this.el.firstChild;)this.el.removeChild(this.el.firstChild)}getCurrentSelection(){let{startElement:e,endElement:t,startSelectionOffset:s,endSelectionOffset:o}=this.getStartAndEndSelection();return{start:this.findSelectionIndex(e,s),end:this.findSelectionIndex(t,o)}}findSelectionIndex(e,t){let s=this.iterateChildren(this.el),o=0,i=s.next();for(;!i.done&&i.value!==e;)i.value.hasChildNodes()||i.value.textContent&&(o+=i.value.textContent.length),i=s.next();if(i.value===e)if(i.value.hasChildNodes()){const e=[...i.value.childNodes].slice(0,t);for(const t of e)t.textContent&&(o+=t.textContent.length)}else o+=t;return o}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}}const Mp=a("ABOUT"),Ap=a("optional"),_p=a("by default"),Op=a("repeatable"),{xml:Np,css:kp}=t.tags,{useState:Fp,onWillUnmount:$p}=t.hooks,Dp=Np`
1753
1753
  <div class="o-formula-assistant-container"
1754
1754
  t-att-style="props.borderStyle"
1755
1755
  t-att-class="{
@@ -3087,4 +3087,4 @@
3087
3087
  height: ${15}px;
3088
3088
  vertical-align: sub;
3089
3089
  }
3090
- `;class Wf extends t.Component{constructor(e,s={}){super(e,s),this.model=new Nu(this.props.data,{evalContext:{env:this.env},transportService:this.props.transportService,client:this.props.client,isReadonly:this.props.isReadonly,snapshotRequested:this.props.snapshotRequested},this.props.stateUpdateMessages),this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.linkEditor=t.useState({isOpen:!1}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})},Pf({openSidePanel:(e,t={})=>this.openSidePanel(e,t),toggleSidePanel:(e,t={})=>this.toggleSidePanel(e,t),dispatch:this.model.dispatch,getters:this.model.getters,uuidGenerator:this.model.uuidGenerator,_t:Wf._t,clipboard:navigator.clipboard,export:this.model.exportData.bind(this.model),waitForIdle:this.model.waitForIdle.bind(this.model),exportXLSX:this.model.exportXLSX.bind(this.model),openLinkEditor:()=>this.openLinkEditor()}),this.activateFirstSheet()}setup(){Df(window,"resize",this.render),Df(document.body,"keyup",this.onKeyup.bind(this)),Df(window,"beforeunload",this.leaveCollaborativeSession.bind(this)),Uf((()=>this.initiateModelEvents())),Vf((()=>this.leaveCollaborativeSession())),Bf((e=>this.checkReadonly(e)))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}initiateModelEvents(){this.model.on("update",this,this.render),this.model.on("notify-ui",this,this.onNotifyUI),this.model.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.props.client&&this.model.joinSession(this.props.client)}onNotifyUI(e){if("NOTIFICATION"===e.type)this.env.notifyUser(e.text)}checkReadonly(e){this.props.isReadonly!==e.isReadonly&&this.model.updateReadOnly(e.isReadonly)}leaveCollaborativeSession(){this.model.off("update",this),this.model.leaveSession()}activateFirstSheet(){const e=this.model.getters.getActiveSheetId(),[t]=this.model.getters.getSheets();t.id!==e&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:t.id})}destroy(){this.model.destroy(),super.destroy()}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}openLinkEditor(){this.linkEditor.isOpen=!0}closeLinkEditor(){this.linkEditor.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}save(){this.trigger("save-content",{data:this.model.exportData()})}onKeyup(e){"Control"===e.key&&this.model.getters.getSelectionMode()!==Rh.expanding&&this.model.dispatch("STOP_SELECTION")}onKeydown(e){"Control"!==e.key||e.repeat||this.model.dispatch(this.model.getters.getSelectionMode()===Rh.idle?"PREPARE_SELECTION_EXPANSION":"START_SELECTION_EXPANSION");let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let s=this.keyDownMapping[t];if(s)return e.preventDefault(),e.stopPropagation(),void s()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}}Wf.template=Zf,Wf.style=Gf,Wf.components={TopBar:$f,Grid:wf,BottomBar:ip,SidePanel:Mf,LinkEditor:ef},Wf._t=e=>e;const qf={},jf={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:m,HEADER_WIDTH:v,TOPBAR_HEIGHT:E,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:b,DEFAULT_CELL_HEIGHT:S,SCROLLBAR_WIDTH:C},Xf={autofillModifiersRegistry:La,autofillRulesRegistry:Ma,cellMenuRegistry:gl,colMenuRegistry:fl,linkMenuRegistry:ml,functionRegistry:cr,uiPluginRegistry:ad,corePluginRegistry:rd,rowMenuRegistry:vl,sidePanelRegistry:bh,sheetMenuRegistry:bl,topbarMenuRegistry:Sl,topbarComponentRegistry:Sh,otRegistry:Cl,inverseCommandRegistry:_a,cellRegistry:Wr},Yf={LinkCell:ta},Kf={args:Oe,toBoolean:fe,toNumber:de,toString:pe,toXC:is,toZone:Ws,toCartesian:os,numberToLetters:ss,createFullMenuItem:ka,UuidGenerator:Bs,formatDecimal:ae,computeTextWidth:vs,isMarkdownLink:xs,parseMarkdownLink:Rs,markdownLink:Ts,createEmptyWorkbookData:ga};e.CorePlugin=ma,e.DATETIME_FORMAT=_,e.DataSource=hd,e.DispatchResult=Ve,e.Model=Nu,e.Registry=Me,e.Revision=Kh,e.SPREADSHEET_DIMENSIONS=jf,e.Spreadsheet=Wf,e.UIPlugin=Ch,e.__DEBUG__=Os,e.__info__=qf,e.astToFormula=Fr,e.cellTypes=Yf,e.compile=Zr,e.convertAstNodes=kr,e.coreTypes=Pe,e.functionCache=zr,e.helpers=Kf,e.invalidateEvaluationCommands=$e,e.parse=Or,e.readonlyAllowedCommands=De,e.registries=Xf,e.setTranslationMethod=function(e){i=e},Object.defineProperty(e,"__esModule",{value:!0}),qf.version="15.2.4",qf.date="2023-04-13T08:15:24.992Z",qf.hash="23f0126"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
3090
+ `;class Wf extends t.Component{constructor(e,s={}){super(e,s),this.model=new Nu(this.props.data,{evalContext:{env:this.env},transportService:this.props.transportService,client:this.props.client,isReadonly:this.props.isReadonly,snapshotRequested:this.props.snapshotRequested},this.props.stateUpdateMessages),this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.linkEditor=t.useState({isOpen:!1}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})},Pf({openSidePanel:(e,t={})=>this.openSidePanel(e,t),toggleSidePanel:(e,t={})=>this.toggleSidePanel(e,t),dispatch:this.model.dispatch,getters:this.model.getters,uuidGenerator:this.model.uuidGenerator,_t:Wf._t,clipboard:navigator.clipboard,export:this.model.exportData.bind(this.model),waitForIdle:this.model.waitForIdle.bind(this.model),exportXLSX:this.model.exportXLSX.bind(this.model),openLinkEditor:()=>this.openLinkEditor()}),this.activateFirstSheet()}setup(){Df(window,"resize",this.render),Df(document.body,"keyup",this.onKeyup.bind(this)),Df(window,"beforeunload",this.leaveCollaborativeSession.bind(this)),Uf((()=>this.initiateModelEvents())),Vf((()=>this.leaveCollaborativeSession())),Bf((e=>this.checkReadonly(e)))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}initiateModelEvents(){this.model.on("update",this,this.render),this.model.on("notify-ui",this,this.onNotifyUI),this.model.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.props.client&&this.model.joinSession(this.props.client)}onNotifyUI(e){if("NOTIFICATION"===e.type)this.env.notifyUser(e.text)}checkReadonly(e){this.props.isReadonly!==e.isReadonly&&this.model.updateReadOnly(e.isReadonly)}leaveCollaborativeSession(){this.model.off("update",this),this.model.leaveSession()}activateFirstSheet(){const e=this.model.getters.getActiveSheetId(),[t]=this.model.getters.getSheets();t.id!==e&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:t.id})}destroy(){this.model.destroy(),super.destroy()}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}openLinkEditor(){this.linkEditor.isOpen=!0}closeLinkEditor(){this.linkEditor.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}save(){this.trigger("save-content",{data:this.model.exportData()})}onKeyup(e){"Control"===e.key&&this.model.getters.getSelectionMode()!==Rh.expanding&&this.model.dispatch("STOP_SELECTION")}onKeydown(e){"Control"!==e.key||e.repeat||this.model.dispatch(this.model.getters.getSelectionMode()===Rh.idle?"PREPARE_SELECTION_EXPANSION":"START_SELECTION_EXPANSION");let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let s=this.keyDownMapping[t];if(s)return e.preventDefault(),e.stopPropagation(),void s()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}),this.env.dispatch("UNFOCUS_SELECTION_INPUT"))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}}Wf.template=Zf,Wf.style=Gf,Wf.components={TopBar:$f,Grid:wf,BottomBar:ip,SidePanel:Mf,LinkEditor:ef},Wf._t=e=>e;const qf={},jf={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:m,HEADER_WIDTH:v,TOPBAR_HEIGHT:E,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:b,DEFAULT_CELL_HEIGHT:S,SCROLLBAR_WIDTH:C},Xf={autofillModifiersRegistry:La,autofillRulesRegistry:Ma,cellMenuRegistry:gl,colMenuRegistry:fl,linkMenuRegistry:ml,functionRegistry:cr,uiPluginRegistry:ad,corePluginRegistry:rd,rowMenuRegistry:vl,sidePanelRegistry:bh,sheetMenuRegistry:bl,topbarMenuRegistry:Sl,topbarComponentRegistry:Sh,otRegistry:Cl,inverseCommandRegistry:_a,cellRegistry:Wr},Yf={LinkCell:ta},Kf={args:Oe,toBoolean:fe,toNumber:de,toString:pe,toXC:is,toZone:Ws,toCartesian:os,numberToLetters:ss,createFullMenuItem:ka,UuidGenerator:Bs,formatDecimal:ae,computeTextWidth:vs,isMarkdownLink:xs,parseMarkdownLink:Rs,markdownLink:Ts,createEmptyWorkbookData:ga};e.CorePlugin=ma,e.DATETIME_FORMAT=_,e.DataSource=hd,e.DispatchResult=Ve,e.Model=Nu,e.Registry=Me,e.Revision=Kh,e.SPREADSHEET_DIMENSIONS=jf,e.Spreadsheet=Wf,e.UIPlugin=Ch,e.__DEBUG__=Os,e.__info__=qf,e.astToFormula=Fr,e.cellTypes=Yf,e.compile=Zr,e.convertAstNodes=kr,e.coreTypes=Pe,e.functionCache=zr,e.helpers=Kf,e.invalidateEvaluationCommands=$e,e.parse=Or,e.readonlyAllowedCommands=De,e.registries=Xf,e.setTranslationMethod=function(e){i=e},Object.defineProperty(e,"__esModule",{value:!0}),qf.version="15.2.5",qf.date="2023-04-21T07:27:24.954Z",qf.hash="0896859"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odoo/o-spreadsheet",
3
- "version": "15.2.4",
3
+ "version": "15.2.5",
4
4
  "description": "A spreadsheet component",
5
5
  "main": "dist/o-spreadsheet.cjs.js",
6
6
  "browser": "dist/o-spreadsheet.iife.js",