@8sheets/data-grid 1.0.1 → 1.1.0
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.
- package/README.md +1 -1
- package/api/theme-core.js +2 -0
- package/calc/adjust.js +1 -1
- package/calc/compile.js +1 -1
- package/calc/engine.js +1 -1
- package/calc/functions/array.js +1 -1
- package/calc/functions/date.js +1 -1
- package/calc/functions/dbcs.js +1 -0
- package/calc/functions/financial.js +1 -1
- package/calc/functions/helpers.js +1 -1
- package/calc/functions/index.js +7 -1
- package/calc/functions/info.js +1 -1
- package/calc/functions/logical.js +1 -1
- package/calc/functions/lookup.js +1 -1
- package/calc/functions/math.js +1 -1
- package/calc/functions/stat.js +1 -1
- package/calc/functions/text.js +1 -1
- package/calc/parser.js +3 -3
- package/calc/values.js +1 -1
- package/calcx/culture/custom.js +1 -0
- package/calcx/culture/format-locale.js +1 -1
- package/calcx/culture/separators.js +1 -0
- package/calcx/functions/text.js +1 -1
- package/calcx/lang/convert.js +1 -0
- package/cells/axis-ops.js +1 -1
- package/cells/block.js +1 -0
- package/cells/book-css.js +2 -2
- package/cells/cell-defaults.js +1 -1
- package/cells/cf-engine.js +1 -1
- package/cells/consolidate-links.js +1 -1
- package/cells/find-engine.js +2 -2
- package/cells/format-panes.js +3 -3
- package/cells/format-tabs.js +5 -5
- package/cells/name-box.js +1 -1
- package/cells/outline-column.js +1 -1
- package/cells/panes.js +1 -1
- package/cells/selection-modes.js +1 -1
- package/cells/shift-check.js +1 -0
- package/cells/table-rows.js +1 -0
- package/cells/text-layout.js +9 -8
- package/cells/ui-kit.js +15 -0
- package/cells/view-options.js +1 -1
- package/celltypes/diagonal.js +1 -1
- package/celltypes/dropdowns.js +2 -2
- package/core/address.js +1 -1
- package/core/autofill.js +1 -0
- package/core/axis-styles.js +1 -0
- package/core/axis.js +1 -1
- package/core/cond-format.js +1 -1
- package/core/culture.js +1 -0
- package/core/default-names.js +1 -1
- package/core/formula-refs.js +1 -1
- package/core/input.js +1 -1
- package/core/merge.js +1 -0
- package/core/numfmt.js +1 -1
- package/core/region-input.js +1 -0
- package/core/row-fit.js +1 -0
- package/core/sheet.js +1 -1
- package/core/structure.js +1 -0
- package/core/styles.js +1 -1
- package/core/tables.js +2 -2
- package/core/whatif.js +1 -1
- package/core/workbook.js +1 -1
- package/datasheets/data-core.js +1 -1
- package/datasheets/gantt-paint.js +1 -1
- package/datasheets/path-binding.js +2 -2
- package/datasheets/rules.js +1 -1
- package/datasheets/view.js +2 -2
- package/i18n/dom.js +1 -1
- package/i18n/en/cells.js +1 -1
- package/i18n/en/common.js +1 -1
- package/i18n/en/format.js +1 -1
- package/i18n/en/shell.js +2 -1
- package/i18n/pl/cells.js +1 -1
- package/i18n/pl/common.js +1 -1
- package/i18n/pl/format.js +1 -1
- package/i18n/pl/shell.js +2 -1
- package/io/csv.js +8 -8
- package/io/plan.js +1 -1
- package/io/text-split.js +3 -3
- package/io/xlsx-write.js +2 -2
- package/objects/chart-model.js +1 -1
- package/package.json +1 -1
- package/pivot/engine.js +1 -1
- package/print/paginate.js +1 -1
- package/print/render-page.js +3 -3
- package/table-view/api.js +1 -1
- package/table-view/cell-editor.js +2 -1
- package/table-view/chart.js +1 -0
- package/table-view/column-drag.js +1 -1
- package/table-view/context-menu.js +1 -0
- package/table-view/editors.js +1 -0
- package/table-view/events.js +1 -1
- package/table-view/files.js +1 -1
- package/table-view/fill-handle.js +1 -0
- package/table-view/filter-builder.js +1 -0
- package/table-view/find.js +1 -0
- package/table-view/grid-keys.js +2 -2
- package/table-view/labels-de.js +1 -0
- package/table-view/labels-es.js +1 -0
- package/table-view/labels-fr.js +1 -0
- package/table-view/labels-ja.js +1 -0
- package/table-view/labels.js +1 -1
- package/table-view/model.js +1 -1
- package/table-view/mount.js +1 -1
- package/table-view/panel.js +1 -1
- package/table-view/pivot-spec.js +1 -0
- package/table-view/pivot.js +1 -1
- package/table-view/public.d.ts +277 -28
- package/table-view/reader.worker.js +1 -1
- package/table-view/remote.js +1 -1
- package/table-view/row-drag.js +1 -0
- package/table-view/sparkline.js +1 -0
- package/table-view/state-check.js +1 -0
- package/table-view/table-css.js +380 -0
- package/table-view/version.js +1 -1
- package/ui/dialogs.js +3 -3
- package/ui/icons.js +1 -1
- package/ui/menu-base.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LCID_TAGS as z}from"./lcid.js";const C=new Map,N={ja:["午前","午後"],ko:["오전","오후"],zh:["上午","下午"]},
|
|
1
|
+
import{LCID_TAGS as z}from"./lcid.js";const C=new Map,N={ja:["午前","午後"],ko:["오전","오후"],zh:["上午","下午"]},T={es:{shortMonths:["ene.","feb.","mar.","abr.","may.","jun.","jul.","ago.","sep.","oct.","nov.","dic."],shortDays:["do.","lu.","ma.","mi.","ju.","vi.","sá."]},pl:{shortDays:["niedz.","pon.","wt.","śr.","czw.","pt.","sob."]},ru:{shortDays:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"]},de:{shortDays:["So","Mo","Di","Mi","Do","Fr","Sa"]},cs:{shortMonths:["I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII"]},sv:{shortDays:[,,,,"tor"]},he:{shortDays:["יום א","יום ב","יום ג","יום ד","יום ה","יום ו"]},ar:{shortDays:[,"الإثنين"],days:[,"الإثنين"]}},A={"pt-PT":{shortDays:["domingo","segunda","terça","quarta","quinta","sexta","sábado"],shortMonths:["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"]}},E=(e,n)=>n?e.map((t,o)=>n[o]??t):e;function H(e){let n=C.get(e);if(n!==void 0)return n;const t=[],o=[],s=[],r=[],l=[],a=c=>new Intl.DateTimeFormat(e,{...c,timeZone:"UTC",calendar:"gregory"}),u=a({month:"long"}),d=a({day:"numeric",month:"long"}),h=a({month:"short"}),y=a({weekday:"long"}),x=a({weekday:"short"});for(let c=0;c<12;c++){const f=new Date(Date.UTC(2024,c,15));t.push(u.format(f)),o.push(d.formatToParts(f).find(D=>D.type==="month").value),s.push(h.format(f))}for(let c=0;c<7;c++){const f=new Date(Date.UTC(2024,0,7+c));r.push(y.format(f)),l.push(x.format(f))}const i=e.split("-")[0],p=A[e]??T[i];return n={tag:e,months:t,monthsWithDay:o,shortMonths:E(s,p?.shortMonths),days:E(r,p?.days),shortDays:E(l,p?.shortDays),am:N[i]?.[0]??"AM",pm:N[i]?.[1]??"PM"},C.set(e,n),n}function Z(e){const n=/^\$([^-]*)(?:-(.*))?$/.exec(e);if(n===null)return null;const t={currency:n[1]||null,tag:null,calendar:0,numerals:0,gannen:!1,system:null},o=n[2];if(o===void 0||o==="")return t;const s=o.toLowerCase();if(s==="x-sysdate")t.system="date";else if(s==="x-systime")t.system="time";else if(/^[0-9a-f]{1,8}$/i.test(o)){const r=parseInt(o,16);(r&65535)===63488?t.system="date":(r&65535)===62464?t.system="time":(t.numerals=r>>>24&255,t.calendar=r>>>16&255,t.tag=z[r&65535]??null)}else{t.gannen=/-x-gannen$/i.test(o),t.tag=o.replace(/-x-.*$/i,"");try{Intl.getCanonicalLocales(t.tag)}catch{t.tag=null}}return t}const L=[{start:0,name:"明治",abbreviation:"明",symbol:"M",firstYear:1868},{start:4595,name:"大正",abbreviation:"大",symbol:"T",firstYear:1912},{start:9856,name:"昭和",abbreviation:"昭",symbol:"S",firstYear:1926},{start:32516,name:"平成",abbreviation:"平",symbol:"H",firstYear:1989},{start:43586,name:"令和",abbreviation:"令",symbol:"R",firstYear:2019}];function q(e){return e.map(n=>{const[t,o,s]=n.start.split("-").map(Number),r=Date.UTC(t,o-1,s)/864e5+25569;return{...n,start:r<61?r-1:r,firstYear:t}}).sort((n,t)=>n.start-t.start)}function K(e,n){if(n?.eras)return n.eras;const t=e?.tag??n?.tag??null;return e?.calendar===3||t&&t.split("-")[0]==="ja"?L:null}function Q(e,n){let t=e[0];for(const o of e)n>=o.start&&(t=o);return t}const P=1948439,v=2415019;function O(e){const n=Math.floor(e),t=(n<60?n+1:n)+v-P,o=Math.floor(t/10631);let s=t-o*10631,r=0;for(;;){const a=_(r+1)?355:354;if(s<a)break;s-=a,r++}let l=0;for(;;){const a=l%2===0||l===11&&_(r+1)?30:29;if(s<a)break;s-=a,l++}return{year:o*30+r+1,month:l+1,day:s+1}}const k=new Set([2,5,7,10,13,15,18,21,24,26,29]),_=e=>k.has((e-1)%30+1),R=["محرم","صفر","ربيع الأول","ربيع الثاني","جمادى الأولى","جمادى الثانية","رجب","شعبان","رمضان","شوال","ذو القعدة","ذو الحجة"],$=e=>(7*e+1)%19<7;function m(e){const n=Math.floor((235*e-234)/19),t=12084+13753*n;let o=n*29+Math.floor(t/25920);return 3*(o+1)%7<3&&o++,o}function b(e){const n=m(e-1),t=m(e);return m(e+1)-t===356?2:t-n===382?1:0}const Y=e=>m(e+1)+b(e+1)-m(e)-b(e),g=-1373427,F=693594;function W(e){const n=Math.floor(e),t=(n<60?n+1:n)+F;let o=Math.floor((t-g)/365.2468)+1;for(;g+m(o)+b(o)>t;)o--;for(;g+m(o+1)+b(o+1)<=t;)o++;let s=t-(g+m(o)+b(o));const r=Y(o),l=$(o),a=[30,r%10===5?30:29,r%10===3?29:30,29,30];l?a.push(30,29):a.push(29),a.push(30,29,30,29,30,29);let u=0;for(;s>=a[u];)s-=a[u],u++;return{year:o,month:u+1,day:s+1,leap:l}}const B=["תשרי","חשון","כסלו","טבת","שבט","אדר","ניסן","אייר","סיון","תמוז","אב","אלול"],J=["תשרי","חשון","כסלו","טבת","שבט","אדר א","אדר ב","ניסן","אייר","סיון","תמוז","אב","אלול"];function tt(e,n,t,o){switch(e){case 6:case"hijri":{const s=O(n);return{...s,monthName:o===null||o.startsWith("ar")?R[s.month-1]:null}}case 7:return{year:t.year+543,month:t.month,day:t.day};case 5:return{year:t.year+2333,month:t.month,day:t.day};case 8:{const s=W(n),r=s.leap?J:B;return{...s,monthName:o?.startsWith("he")?r[s.month-1]:null}}default:return null}}const et=()=>H("ar-SA"),M="0123456789",j={ja:{1:"〇一二三四五六七八九",2:"〇壱弐参四伍六七八九",3:M},"zh-CN":{1:"○一二三四五六七八九",2:"零壹贰叁肆伍陆柒捌玖",3:M},zh:{1:"○一二三四五六七八九",2:"零壹貳參肆伍陸柒捌玖",3:M},ko:{1:"0一二三四五六七八九",2:"零壹貳參四伍六七八九",3:M}};function nt(e,n){if(!n)return null;const t=n.split("-")[0];return j[n==="zh-CN"||n==="zh-SG"?"zh-CN":t]?.[e]??null}const U={ja:{1:{small:"十百千",big:"万億兆",dropOne:!0},2:{small:"拾百阡",big:"万億兆"},3:{small:"十百千",big:"万億兆",dropOne:!0}},ko:{1:{small:"十百千",big:"万億兆"}},"zh-CN":{1:{small:"十百千",big:"万亿兆",zeroes:!0},2:{small:"拾佰仟",big:"万亿兆",zeroes:!0}}};function ot(e,n,t){if(!t)return null;const o=t.split("-")[0],s=t==="zh-CN"||t==="zh-SG"?"zh-CN":o,r=U[s]?.[n],l=j[s]?.[n];if(!r||!l)return null;const a=/^(\d+)(\.\d+)?$/.exec(e);if(a===null)return null;const u=[...l],d=a[1];if(/^0+$/.test(d))return u[0]+(a[2]?`.${[...a[2].slice(1)].map(i=>u[Number(i)]).join("")}`:"");let h="",y=!1;const x=Math.ceil(d.length/4);for(let i=0;i<x;i++){const p=d.length-(x-1-i)*4,c=d.slice(Math.max(0,p-4),p);let f=!1;for(let I=0;I<c.length;I++){const w=Number(c[I]),S=c.length-1-I;if(w===0){y=h!==""||f;continue}y&&r.zeroes&&(h+=u[0]),y=!1,S>0&&w===1&&r.dropOne||(h+=u[w]),S>0&&(h+=[...r.small][S-1]),f=!0}const D=x-1-i;f&&D>0&&(h+=[...r.big][D-1])}return h+(a[2]?`.${[...a[2].slice(1)].map(i=>u[Number(i)]).join("")}`:"")}const X={2:1632,3:1776,4:2406,5:2534,6:2662,7:2790,8:2918,10:3174,11:3302,12:3430,13:3664,14:3792,15:3872,16:4160,18:6112,19:6160};function st(e){if(e===9)return"0௧௨௩௪௫௬௭௮௯";if(e===17)return"0፩፪፫፬፭፮፯፰፱";const n=X[e];return n===void 0?null:Array.from({length:10},(t,o)=>String.fromCodePoint(n+o)).join("")}function rt(e,n){const t=[...n];let o="";for(let s=0;s<e.length;s++){const r=e.charCodeAt(s);o+=r>=48&&r<=57?t[r-48]:e[s]}return o}export{tt as calendarParts,nt as dbnumDigits,ot as dbnumPlaces,Q as eraAt,K as erasOf,et as hijriLocale,H as localeData,rt as mapDigits,st as numeralDigits,Z as parseLocaleBracket,q as preparedEras};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={fr:[".",";"],es:["\\",";"],pl:["\\",";"],pt:["\\",";"],nl:["\\",";"],sv:["\\",";"],cs:["\\",";"],da:["\\",";"],fi:["\\",";"],hu:["\\",";"],it:["\\","."],nb:["\\","."],no:["\\","."],nn:["\\","."],ru:[";",":"],tr:[";","\\"],de:[".",";"],en:[",",";"],ja:[",",";"],ko:[",",";"],zh:[",",";"]};function t(o,a){const n=o.split("-")[0].toLowerCase(),r=e[n];return r&&!(a===","&&r[0]===",")?{arrayColSep:r[0],arrayRowSep:r[1]}:a===","?{arrayColSep:"\\",arrayRowSep:";"}:{arrayColSep:",",arrayRowSep:";"}}export{t as arraySeparatorsOf};
|
package/calcx/functions/text.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{lift as u,raw as U,setCategory as
|
|
1
|
+
import{lift as u,raw as U,setCategory as p}from"../../calc/functions/registry.js";import{Arr as m,ERR as f,num as d,OMITTED as R,Ref as N,RefList as F,str as T,XlError as A}from"../../calc/values.js";import{evaluateXPath as $,parseXml as k}from"./xml.js";import{asyncCall as x}from"../async.js";import{mayReach as W}from"../../core/online.js";import{dbcsLanguage as D,toFullWidth as B}from"../../calc/functions/dbcs.js";const O=t=>t!==void 0&&t!==R;p("Text"),u("JIS",1,1,t=>D()?B(T(t)):T(t)),U("PHONETIC",1,1,(t,e)=>{if(!D())throw f.NA;const r=t.toArr(e[0]);let n="";for(const o of r.data)typeof o=="string"&&(n+=o);return n});const y=["ศูนย์","หนึ่ง","สอง","สาม","สี่","ห้า","หก","เจ็ด","แปด","เก้า"],G=["","สิบ","ร้อย","พัน","หมื่น","แสน"];function I(t){if(/^0*$/.test(t))return y[0];let e="";const r=t.replace(/^0+/,""),n=[];for(let o=r.length;o>0;o-=6)n.unshift(r.slice(Math.max(0,o-6),o));return n.forEach((o,a)=>{const s=o.length;let h="";for(let i=0;i<s;i++){const c=o.charCodeAt(i)-48;if(c===0)continue;const l=s-1-i;l===1&&c===1?h+="สิบ":l===1&&c===2?h+="ยี่สิบ":l===0&&c===1&&(s>1||a>0)?h+=o.slice(0,-1).replace(/0/g,"")!==""||a>0?"เอ็ด":"หนึ่ง":h+=y[c]+G[l]}e+=h,a<n.length-1&&(e+="ล้าน")}),e}function P(t){if(t<1e15)return String(t);const e=t.toExponential(14),r=e.indexOf("e"),n=Number(e.slice(r+1));return(e[0]+e.slice(2,r)).slice(0,n+1).padEnd(n+1,"0")}function Y(t){const e=t<0,r=Math.round(Math.abs(t)*100),n=Math.floor(r/100),o=r-n*100;let a="";return n>0&&(a+=`${I(P(n))}บาท`),o===0?a+=n>0?"ถ้วน":`${y[0]}บาทถ้วน`:a+=`${I(String(o))}สตางค์`,e?`ลบ${a}`:a}u("BAHTTEXT",1,1,t=>Y(d(t)));const _=["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"],J=["วันอาทิตย์","วันจันทร์","วันอังคาร","วันพุธ","วันพฤหัสบดี","วันศุกร์","วันเสาร์"],C=t=>new Date(Date.UTC(1899,11,30)+Math.floor(t)*864e5);u("THAIDAYOFWEEK",1,1,t=>J[C(d(t)).getUTCDay()]),u("THAIMONTHOFYEAR",1,1,t=>{const e=Math.trunc(d(t));if(e<1||e>12)throw f.VALUE;return _[e-1]}),u("THAIYEAR",1,1,t=>C(d(t)).getUTCFullYear()+543),u("THAIDIGIT",1,1,t=>T(t).replace(/[0-9]/g,e=>String.fromCharCode(3664+Number(e)))),u("ISTHAIDIGIT",1,1,t=>/[๐-๙]/.test(T(t))),u("THAINUMSTRING",1,1,t=>{const e=d(t),[r,n]=Math.abs(e).toString().split(".");let o=I(r);return n&&(o+=`จุด${[...n].map(a=>y[Number(a)]).join("")}`),e<0?`ลบ${o}`:o}),u("THAINUMSOUND",1,1,t=>[...T(t)].map(e=>/[0-9]/.test(e)?y[Number(e)]:e).join("")),u("THAISTRINGLENGTH",1,1,t=>[...T(t).replace(/[ัิ-ฺ็-๎]/g,"")].length);const b=(t,e)=>{const r=t<0?-1:1,n=Math.abs(t)*4;return r*(e?Math.ceil(n-1e-9):Math.floor(n+1e-9))/4};p("Math & Trig"),u("ROUNDBAHTDOWN",1,1,t=>b(d(t),!1)),u("ROUNDBAHTUP",1,1,t=>b(d(t),!0)),p("Text");const V=["〇","一","二","三","四","五","六","七","八","九"],j=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"];function H(t,e,r,n,o){const a=String(Math.round(Math.abs(t)));if(a==="0")return e[0];let s="";const h=a.length;let i=!1;for(let c=0;c<h;c++){const l=a.charCodeAt(c)-48,E=h-1-c;l===0?i=s!=="":(i&&o&&(s+=e[0]),i=!1,s+=e[l]+r[E%4]),E%4===0&&E>0&&s!==""&&(s+=n[E/4-1])}return t<0?`负${s}`:s}u("NUMBERSTRING",2,2,(t,e)=>{const r=d(t),n=Math.trunc(d(e));if(n===1)return H(r,["〇",...V.slice(1)],["","十","百","千"],["万","亿","兆"],!0);if(n===2)return H(r,j,["","拾","佰","仟"],["万","亿","兆"],!0);if(n===3)return[...String(Math.round(Math.abs(r)))].map(o=>V[Number(o)]).join("");throw f.VALUE}),u("DATESTRING",1,1,t=>{const e=typeof t=="string"?Date.parse(t):d(t),r=C(typeof t=="string"?e/864e5+25569:e),n=s=>String(s).padStart(2,"0"),o=r.getUTCFullYear(),a=o>=2019?["令和",o-2018]:o>=1989?["平成",o-1988]:o>=1926?["昭和",o-1925]:o>=1912?["大正",o-1911]:["明治",o-1867];return`${a[0]}${n(a[1])}年${n(r.getUTCMonth()+1)}月${n(r.getUTCDate())}日`});const K={EUR:[1,2],ATS:[13.7603,2],BEF:[40.3399,0],DEM:[1.95583,2],ESP:[166.386,0],FIM:[5.94573,2],FRF:[6.55957,2],GRD:[340.75,0],IEP:[.787564,2],ITL:[1936.27,0],LUF:[40.3399,0],NLG:[2.20371,2],PTE:[200.482,2],SIT:[239.64,2],CYP:[.585274,2],MTL:[.4293,2],SKK:[30.126,2],EEK:[15.6466,2],LVL:[.702804,2],LTL:[3.4528,2],HRK:[7.5345,2]},M=t=>{const e=K[T(t).toUpperCase()];if(e===void 0)throw f.VALUE;return e};u("EUROCONVERT",3,5,(t,e,r,n,o)=>{const a=d(t),[s]=M(e),[h,i]=M(r);let c=a/s;if(O(o)){const g=Math.trunc(d(o));if(g<3)throw f.VALUE;c=Number(c.toFixed(g))}const l=c*h;return(O(n)?d(n)!==0:!1)?l:Number(l.toFixed(i))}),u("EURO",1,1,t=>M(t)[0]),p("Web"),u("ENCODEURL",1,1,t=>{const e=T(t);if(e.length>2048)throw f.VALUE;return encodeURIComponent(e).replace(/[!'()*]/g,r=>`%${r.charCodeAt(0).toString(16).toUpperCase()}`)}),U("FILTERXML",2,2,(t,e,r,n)=>{const o=t.scalar(e[0],r,n),a=t.scalar(e[1],r,n);if(o instanceof A)return o;if(a instanceof A)return a;let s;try{s=k(T(o))}catch{return f.VALUE}let h;try{h=$(s,T(a))}catch{return f.VALUE}if(h.length===0)return f.VALUE;const i=h.map(c=>{const l=Number(c);return c.trim()!==""&&Number.isFinite(l)?l:c});return i.length===1?i[0]:m.column(i)},{array:!0});const w={fetch:null};function et(t=e=>fetch(e).then(r=>{if(!r.ok)throw new Error(String(r.status));return r.text()})){w.fetch=t}const rt=()=>{w.fetch=null};U("WEBSERVICE",1,1,(t,e,r,n,o)=>{const a=t.scalar(e[0],r,n);if(a instanceof A)return a;const s=T(a);return s.length>2048||!/^https?:\/\//i.test(s)?f.VALUE:w.fetch===null||!W(s)?f.BLOCKED:x(t,{name:"WEBSERVICE",key:s,row:r,col:n,sheet:o,run:()=>w.fetch(s),onError:()=>f.VALUE})},{volatile:!1}),p("Text"),u("STARTSWITH",2,2,(t,e)=>T(t).toLowerCase().startsWith(T(e).toLowerCase())),u("ENDSWITH",2,2,(t,e)=>T(t).toLowerCase().endsWith(T(e).toLowerCase())),p("Other"),u("UUID",0,0,()=>{const t=new Uint8Array(16);globalThis.crypto.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=[...t].map(r=>r.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`},{volatile:!0});const S=t=>t==null?null:typeof t=="number"||typeof t=="string"||typeof t=="boolean"?t:JSON.stringify(t);u("FILTERJSON",1,1,t=>{if(typeof t!="string")throw f.VALUE;let e;try{e=JSON.parse(t)}catch{throw f.VALUE}if(Array.isArray(e)){if(e.length===0)throw f.CALC;return m.column(e.map(S))}return S(e)});const L=t=>{if(t instanceof A)throw t;return t===R||t===void 0?null:t};U("OBJECT",2,254,(t,e,r,n)=>{if(e.length%2!==0)return f.VALUE;if(e.length===2&&e[0]instanceof N&&e[1]instanceof N&&!e[0].isCell){const i=t.toArr(e[0]).data,c=t.toArr(e[1]).data;if(i.length!==c.length)return f.VALUE;const l={};return i.forEach((E,g)=>{l[T(L(E))]=L(c[g])}),JSON.stringify(l)}const o=[],a=[];let s=null;for(let i=0;i<e.length;i+=2){const c=t.scalar(e[i],r,n);if(c instanceof A)return c;o.push(T(c));const l=e[i+1]instanceof N||e[i+1]instanceof F?t.refToValue(e[i+1]):e[i+1];if(l instanceof A)return l;if(l instanceof m&&l.data.length>1){if(s!==null&&s!==l.data.length)return f.VALUE;s=l.data.length}a.push(l)}const h=i=>{const c={};return o.forEach((l,E)=>{const g=a[E];c[l]=L(g instanceof m?g.data[g.data.length>1?i:0]:g)}),JSON.stringify(c)};return s===null?h(0):m.column(Array.from({length:s},(i,c)=>h(c)))},{array:!0}),u("PROPERTY",2,2,(t,e)=>{let r=t;if(typeof t=="string")try{r=JSON.parse(t)}catch{throw f.NA}if(r===null||typeof r!="object")throw f.NA;for(const n of T(e).split(".").flatMap(o=>o.split(/[[\]]/).filter(Boolean))){if(r===null||typeof r!="object"||!Object.hasOwn(r,n))throw f.NA;r=r[n]}return S(r)??""}),p("Date & Time");const q={y:"year",year:"year",q:"quarter",quarter:"quarter",m:"month",month:"month",d:"day",day:"day",w:"weekday",weekday:"weekday",h:"hour",hour:"hour",n:"minute",minute:"minute",s:"second",second:"second",yd:"dayofyear",dayofyear:"dayofyear",ww:"week",week:"week"};u("DATEPART",2,2,(t,e)=>{const r=d(t);if(r<0)throw f.NUM;const n=C(r),o=r-Math.floor(r),a=Math.round(o*86400),s=n.getUTCFullYear(),h=Math.floor((n-Date.UTC(s,0,1))/864e5)+1;switch(q[T(e).toLowerCase()]){case"year":return s;case"quarter":return Math.floor(n.getUTCMonth()/3)+1;case"month":return n.getUTCMonth()+1;case"day":return n.getUTCDate();case"weekday":return n.getUTCDay()+1;case"hour":return Math.floor(a/3600)%24;case"minute":return Math.floor(a/60)%60;case"second":return a%60;case"dayofyear":return h;case"week":return Math.floor((h+new Date(Date.UTC(s,0,1)).getUTCDay()-1)/7)+1;default:throw f.VALUE}});export{et as allowWebFunctions,Y as bahtText,rt as blockWebFunctions};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const L=new Map;let p=null;function W(e,n){const r=e.toLowerCase(),s=n.parent?L.get(n.parent.toLowerCase()):null;L.set(r,y(r,n,s)),p?.code===r&&(p=L.get(r))}function y(e,n,r){const s={...r?.source.functions??{},...n.functions??{}},u={...r?.source.errors??{},...n.errors??{}},f={...r?.source.booleans??{},...n.booleans??{}},i={...r?.source.structured??{},...n.structured??{}},h=d=>new Map(Object.entries(d).map(([t,l])=>[l.toUpperCase(),t]));return{code:e,name:n.name??e,source:{functions:s,errors:u,booleans:f,structured:i},fnToLocal:new Map(Object.entries(s)),fnToEnglish:h(s),errToLocal:new Map(Object.entries(u).map(([d,t])=>[d.toUpperCase(),t])),errToEnglish:h(u),boolToLocal:new Map(Object.entries(f)),boolToEnglish:h(f),structToLocal:new Map(Object.entries(i).map(([d,t])=>[d.toUpperCase(),t])),structToEnglish:h(i)}}const v=()=>[...L.values()].map(e=>({code:e.code,name:e.name}));function B(e){if(!e||e.toLowerCase()==="en")return p=null,!0;const n=L.get(e.toLowerCase());return n===void 0?!1:(p=n,!0)}const X=()=>p?.code??"en",b="_XLL.",g=new Set,A=e=>{for(const n of g)if(n(e))return!0;return!1};function z(e){return g.add(e),()=>g.delete(e)}function S(e,n){let r=n;for(;r.startsWith(b);)r=r.slice(b.length);if(e.fnToLocal.has(r))return!1;const s=e.fnToEnglish.get(r);return s!==void 0&&s!==r}function E(e,n){const r=n.toUpperCase();return S(e,r)?`_xll.${n}`:e.fnToLocal.get(r)??n}function j(e,n){const r=n.toUpperCase();return r.startsWith(b)&&S(e,r)?n.slice(b.length):e.fnToEnglish.get(r)??n}const H=e=>p?E(p,e):e,P=e=>(p?j(p,e):e).toUpperCase(),Q=e=>p?.errToLocal.get(e.toUpperCase())??e,$=e=>{const n=e?"TRUE":"FALSE";return p?.boolToLocal.get(n)??n},O=Object.freeze({decimal:".",listSep:",",arrayColSep:",",arrayRowSep:";"}),m=e=>e>="0"&&e<="9",_=/[\p{L}_\\]/u,D=/[\p{L}\p{N}_.\\?]/u;function F(e,n,r){let s=n+1;for(;s<e.length;)if(e[s]===r)if(e[s+1]===r)s+=2;else return s+1;else s++;return s}function M(e,n,r,s){if(/^\[\d+\]/.test(e)&&!e.includes("#"))return e;let u="",f=0,i=0;for(;i<e.length;){const h=e[i];if(h==="'"&&e[i+1]!==void 0)u+=h+e[i+1],i+=2;else if(h==="["){if(f++,u+=h,i++,e[i]==="#"){const d=e.indexOf("]",i),t=e.slice(i,d<0?e.length:d),l=s?n?s.structToLocal.get(t.toUpperCase()):s.structToEnglish.get(t.toUpperCase()):void 0;u+=l??t,i+=t.length}}else h==="]"?(f--,u+=h,i++):f===1&&h===(n?",":r)?(u+=n?r:",",i++):(u+=h,i++)}return u}function R(e,n,r,s){const{decimal:u,listSep:f,arrayColSep:i,arrayRowSep:h}=r,d=e.length;let t="",l=0,T=0;for(;l<d;){const c=e[l];if(c==='"'||c==="'"){const a=F(e,l,c);t+=e.slice(l,a),l=a}else if(c==="["){let a=0,o=l;for(;o<d;o++)if(e[o]==="'")o++;else if(e[o]==="[")a++;else if(e[o]==="]"&&(a--,a===0))break;t+=M(e.slice(l,o+1),n,f,s),l=o+1}else if(c==="{")T++,t+=c,l++;else if(c==="}")T--,t+=c,l++;else if(c==="#"){const a=/^#[^\s,;:()+\-*^&=<>{}\\|]*[!?]?/u.exec(e.slice(l,l+40));let o=null;if(a&&s){const w=n?s.errToLocal:s.errToEnglish;for(let C=a[0].length;C>1;C--){const U=w.get(a[0].slice(0,C).toUpperCase());if(U!==void 0){o={len:C,swapped:U};break}}}o?(t+=o.swapped,l+=o.len):(t+=c,l++)}else if(m(c)||c===(n?".":u)&&m(e[l+1]??"")){const a=n?".":u;let o=l;for(;o<d&&m(e[o]);)o++;if(e[o]===a)for(o++;o<d&&m(e[o]);)o++;if((e[o]==="e"||e[o]==="E")&&(m(e[o+1]??"")||(e[o+1]==="+"||e[o+1]==="-")&&m(e[o+2]??"")))for(o+=2;o<d&&m(e[o]);)o++;const w=e.slice(l,o);t+=a===(n?u:".")?w:w.replace(a,n?u:"."),l=o}else if(_.test(c)&&!(c==="\\"&&T>0)){let a=l+1;for(;a<d&&D.test(e[a]);)a++;const o=e.slice(l,a),w=e[a];if(s&&w==="(")A(o.toUpperCase())?t+=o:t+=n?E(s,o):j(s,o);else if(s&&w!=="!"&&w!=="["){const C=o.toUpperCase(),U=n?s.boolToLocal.get(C):s.boolToEnglish.get(C);t+=U??o}else t+=o;l=a}else n?(c===","?t+=T>0?i:f:c===";"&&T>0?t+=h:t+=c,l++):(T>0&&c===i?t+=",":T>0&&c===h?t+=";":T===0&&c===f?t+=",":t+=c,l++)}return t}const N=e=>e.decimal==="."&&e.listSep===","&&e.arrayColSep===","&&e.arrayRowSep===";";function G(e,n=O){return p===null&&N(n)?e:R(e,!0,n,p)}function I(e,n=O){return p===null&&N(n)?e:R(e,!1,n,p)}function J(e,n,r=40){const s=e.toUpperCase(),u=[];for(const f of n){if(f.startsWith("_"))continue;const i=p?E(p,f):f;i.toUpperCase().startsWith(s)&&u.push({local:i,english:f})}return u.sort((f,i)=>f.local.localeCompare(i.local)),u.slice(0,r)}export{O as STANDARD_SEPARATORS,z as addDefinedNameCheck,v as availableLanguages,J as completeFunctionName,P as englishFunctionName,I as formulaFromUser,X as formulaLanguage,G as formulaToUser,$ as localBooleanText,Q as localErrorText,H as localFunctionName,W as registerLanguage,B as setFormulaLanguage};
|
package/cells/axis-ops.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{selectedSheets as C}from"../core/sheet-group.js";import{openFormatCells as O,promptNumber as F}from"../ui/dialogs.js";import{guardOption as R}from"../ui/protection-ui.js";import{MAX_COLS as
|
|
1
|
+
import{selectedSheets as C}from"../core/sheet-group.js";import{openFormatCells as O,promptNumber as F}from"../ui/dialogs.js";import{guardOption as R}from"../ui/protection-ui.js";import{MAX_COLS as b,MAX_ROWS as z}from"../core/address.js";import{CHUNK_BITS as T}from"../core/sheet.js";import{wrapsByAlign as _}from"./text-layout.js";import{canResize as H}from"./axis-limits.js";import{openTrackSize as v}from"./cell-options-ui.js";import{openHeaderColors as y}from"./header-colors.js";const h=o=>o==="col"?"cols":"rows";function I(o){const e=o.grid.selection.ranges[0];e.c0===0&&e.c1===b-1?y(o,"row",e.r0,e.r1):y(o,"col",e.c0,e.c1)}function m(o,e,r){return()=>{const n=o[e];return o[e]=r,e==="cols"&&(o.colsChanged=!0),o.revision++,m(o,e,n)}}function w(o,e){const{book:r,grid:n}=o;e==="col"&&(r.sheet.colsChanged=!0),r.dirty=!0,o.objects?.geometryChanged?.(),n.invalidate()}function U(o,e){const{sheet:r,styles:n}=o.book,t=new Set,c=new Map,l=s=>{let i=c.get(s);if(i===void 0){const f=n.get(s);i=!!(f.wrap||_(f)),c.set(s,i)}return i};o:for(const s of e.slice(0,256)){const i=r.columns[s];if(i===void 0)continue;const f=r.colStyles?.get(s)??0;for(let d=0;d<i.length;d++){const u=i[d];if(u!==void 0)for(let a=0;a<u.kinds.length;a++){if(u.kinds[a]===0)continue;const g=u.styles===null||u.styles[a]===0?f:u.styles[a];if(!(g===0||!l(g))&&(t.add((d<<T)+a),t.size>=B))break o}}}for(const s of t)o.commands._growRow(s);return t.size>0}const B=2e3;function k(o,e,r){const n=o.book.sheet,t=n.rows.reshaped();if(!U(o,e))return r;const c=(l,s)=>()=>{const i=l(),f=s();return c(f,i)};return c(m(n,"rows",t),r)}function A(o,e,r,n=null){const{book:t}=o,c=t.sheet,l=h(e);t.transact("axis",()=>{const s=c[l].reshaped();r(),c.revision++;const i=m(c,l,s);return n!==null&&e==="col"?k(o,n,i):i}),w(o,e),n!==null&&t.collab?.changed?.()}const x=(o,e)=>o==="col"?e.r0===0&&e.r1===z-1:e.c0===0&&e.c1===b-1,S=(o,e)=>o==="col"?[e.c0,e.c1]:[e.r0,e.r1];function V(o,e){const r=e.map(t=>S(o,t)).sort((t,c)=>t[0]-c[0]),n=[];for(const[t,c]of r){const l=n[n.length-1];l&&t<=l[1]+1?l[1]=Math.max(l[1],c):n.push([t,c])}return n}function M(o,e,r){const n=new Set,t=e==="col"?b-1:z-1;for(const c of r.ranges){const[l,s]=S(e,c),i=e==="col"?o.maxCol:o.maxRow,f=s>=t?Math.max(l,i):s;for(let d=l;d<=f;d++)n.add(d)}return[...n]}function j(o,e,r,n){const t=[];let c=!1;for(const l of n.ranges){if(!x(e,l))continue;const[s,i]=S(e,l);r>=s&&r<=i&&(c=!0);const f=Math.min(i,s+2e4);for(let d=s;d<=f;d++)t.push(d)}return c?t:[r]}function Y(o,e,r,n){const t=j(o,e,r,n),c=o[h(e)];return{list:t,saved:c.reshaped(),starts:t.map(l=>c.sizeOf(l))}}function Z(o,e,r,n){const t=o[h(e)];for(const c of r.group.list)t.isHidden(c)&&t.setHidden(c,!1),t.setSize(c,n)}function $(o,e){const{book:r}=o,n=r.sheet,t=e.type==="colResize"?"col":"row",c=h(t),l=n[c],{list:s,starts:i,saved:f}=e.group;s.forEach((d,u)=>{l.sizeOf(d)===0&&!l.isHidden(d)&&(i[u]>0&&l.setSize(d,i[u]),l.setHidden(d,!0))}),r.transact("axis",()=>t==="col"?k(o,s,m(n,c,f)):m(n,c,f)),w(o,t),t==="col"&&r.collab?.changed?.()}function oo(o,e,r){if(!R(o,e==="row"?"formatRows":"formatColumns"))return;const n=o.book.sheet,t=n[h(e)],c=M(n,e,o.grid.selection).filter(s=>H(n,e,s)),l=C(o.book);if(l.length>1){const s=h(e);o.book.transact("axis",()=>{const i=l.map(d=>{const u=d[s].reshaped();for(const g of c)H(d,e,g)&&(r===0?d[s].setHidden(g,!0):(d[s].setHidden(g,!1),d[s].setSize(g,r)));d.revision++,s==="cols"&&(d.colsChanged=!0);const a=m(d,s,u);return e==="col"&&d===n?k(o,c,a):a}),f=d=>()=>f(d.map(u=>u()));return f(i)}),w(o,e),e==="col"&&o.book.collab?.changed?.();return}A(o,e,()=>{for(const s of c)r===0?t.setHidden(s,!0):(t.setHidden(s,!1),t.setSize(s,r))},e==="col"?c:null)}function eo(o,e,r){if(!R(o,e==="row"?"formatRows":"formatColumns"))return;const n=o.book.sheet,t=n[h(e)];A(o,e,()=>{for(const c of o.grid.selection.ranges){const[l,s]=S(e,c);if(r)for(let i=l;i<=s;i++)t.setHidden(i,!0);else if(t.hiddenSizes)for(const i of[...t.hiddenSizes.keys()])i<l||i>s||e==="row"&&n.filteredRows?.has(i)||t.setHidden(i,!1)}})}function W(o,e){const{book:r,commands:n,grid:t}=o,c=r.sheet,l=M(c,e,t.selection);if(e==="row"){n.fitAxis("row",l);return}const s=t.selection.ranges[t.selection.ranges.length-1];n.fitAxis("col",l,x("col",s)?null:s)}const p=o=>o<=5?0:Math.round((o-5)/6*100)/100,D=o=>o<=0?0:Math.round(o*6+5);function E(o){const{book:e,grid:r}=o,n=e.sheet;F(o,"Standard Width","Standard column width:",p(n.cols.defaultSize),0,255,t=>{const c=C(e);e.transact("axis",()=>{const l=c.map(i=>{const f=i.cols;return i.cols=f.reshaped(f.count,Math.max(1,D(t))),i.standardWidthChanged=!0,m(i,"cols",f)}),s=i=>()=>s(i.map(f=>f()));return s(l)}),w(o,"col"),r.invalidate()})}function to(o){const e=o.commands;return{items:[["Row Height…",()=>v(o,"row")],["AutoFit Row Height",()=>W(o,"row")],null,["Column Width…",()=>v(o,"col")],["AutoFit Selection",()=>W(o,"col")],["Standard Width…",()=>E(o)],null,["Hide & Unhide",()=>{},{items:()=>({items:[["Hide Rows",()=>e.setHidden("row",!0)],["Hide Columns",()=>e.setHidden("col",!0)],null,["Unhide Rows",()=>e.setHidden("row",!1)],["Unhide Columns",()=>e.setHidden("col",!1)]]})}],null,["Header Color…",()=>I(o)],["Format Cells…",()=>O(o),{kbd:"⌘1"}]]}}function no(o,e){const r=o.book.sheet,n=e.type==="colResize"?"col":"row";m(r,h(n),e.group.saved)(),n==="col"&&(r.colsChanged=!0),o.objects?.geometryChanged?.(),o.grid.invalidate()}export{A as axisStep,H as canResize,no as cancelAxisDrag,D as charsToWidth,Y as dragGroup,Z as dragSize,$ as endAxisDrag,W as fitSelected,to as formatMenu,eo as hideSelected,E as openStandardWidth,j as selectedAround,V as selectedSpans,oo as setSelectedSize,p as widthToChars};
|
package/cells/block.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EMPTY as M,FORMULA as g,SPILL as R}from"../core/sheet.js";import{MAX_COLS as F,MAX_ROWS as I}from"../core/address.js";import{formulaText as A}from"../core/formula-refs.js";import{CellLog as C}from"../core/workbook.js";const L=t=>t.r0===0&&t.r1===I-1,O=t=>t.c0===0&&t.c1===F-1,P=(t,n)=>t.r0<=n.r1&&t.r1>=n.r0&&t.c0<=n.c1&&t.c1>=n.c0,U=(t,n)=>t.r0>=n.r0&&t.r1<=n.r1&&t.c0>=n.c0&&t.c1<=n.c1,_=(t,n)=>t.r0===n.r0&&t.r1===n.r1&&t.c0===n.c0&&t.c1===n.c1,z=(t,n,s)=>t>=s.r0&&t<=s.r1&&n>=s.c0&&n<=s.c1;function E(t,n){const s=t.selectedSheets?.size>1?t.selectedSheets:[t.sheet];for(const e of s)if(!(!e.spills||e.protection&&e!==t.sheet)){for(const r of e.spills.values())if(r.fixed&&n.some(o=>P(o,r))&&!n.some(o=>U(r,o)))return!0}return!1}function H(t,n){return{r0:t.r0,c0:t.c0,r1:L(t)?Math.min(t.r1,Math.max(n.maxRow,t.r0)):t.r1,c1:O(t)?Math.min(t.c1,Math.max(n.maxCol,t.c0)):t.c1}}function Y(t,n){const s=new Int32Array(n-t+1);for(let e=0;e<s.length;e++)s[e]=t+e;return s}function j(t,n){for(const s of[...t.formulas.keys()])n.styles.get(t.styles[s]).hiddenFormula&&(t.kinds[s]&=~g,t.formulas.delete(s));return t}function q(t,n,s){const e=n.length,r=s.length,o=e*r,l=new Uint8Array(o),c=new Float64Array(o),i=new Uint16Array(o),u=new Uint16Array(o),S=new Map,k=t.rowStyles!==null||t.colStyles!==null;for(let p=0;p<r;p++){const x=s[p],a=t.columns[x];if(!(a===void 0&&!k))for(let d=0;d<e;d++){const h=n[d],f=d*r+p,m=a===void 0?void 0:a[h>>>10];if(m!==void 0){const y=h&1023;if(l[f]=m.kinds[y],c[f]=m.values[y],m.styles!==null&&(u[f]=m.styles[y]),l[f]&g){const w=t.formula(h,x);w&&S.set(f,{info:w,text:A(w,h,x)})}}i[f]=u[f]!==0||!k?u[f]:t.style(h,x)}}return{sheet:t,rows:n,cols:s,h:e,w:r,kinds:l,values:c,styles:i,own:u,formulas:S}}function D(t,n){const s=[],e=n.length,r=t.length;let o=null;for(let l=0;l<e;l++){const c=t[l%r],i=n[l];o!==null&&c===o.s+o.n&&i===o.t+o.n?o.n++:(o={s:c,t:i,n:1},s.push(o))}return s}function G(t,n,s){const e=[];for(const r of t)for(const o of n){const l=s?{r0:o.s,r1:o.s+o.n-1,c0:r.s,c1:r.s+r.n-1}:{r0:r.s,r1:r.s+r.n-1,c0:o.s,c1:o.s+o.n-1};e.push({source:l,target:{r0:r.t,r1:r.t+r.n-1,c0:o.t,c1:o.t+o.n-1},transpose:s})}return e}function J(t,n){const{source:s,target:e}=n;return n.transpose?{r0:e.r0+t.c0-s.c0,r1:e.r0+t.c1-s.c0,c0:e.c0+t.r0-s.r0,c1:e.c0+t.r1-s.r0}:{r0:e.r0+t.r0-s.r0,r1:e.r0+t.r1-s.r0,c0:e.c0+t.c0-s.c0,c1:e.c0+t.c1-s.c0}}function K(t){let n=1/0,s=1/0,e=-1,r=-1;for(const o of t)o.r0<n&&(n=o.r0),o.c0<s&&(s=o.c0),o.r1>e&&(e=o.r1),o.c1>r&&(r=o.c1);return{r0:n,c0:s,r1:e,c1:r}}function W(t){const n=t.filter(Boolean);return s=>{const e=[];for(let r=n.length-1;r>=0;r--)e.push(n[r](s));return W(e)}}class N{constructor(n,s){this.book=n,this.sheet=s,this.log=new C}save(n,s){this.log.push(this.sheet,n,s)}undo(){const{book:n,sheet:s,log:e}=this;if(e.count===0)return null;const r=o=>()=>{const l=new C;for(let c=o.count-1;c>=0;c--){const i=o.rows[c],u=o.cols[c];l.push(s,i,u),s.setCell(i,u,o.kinds[c],o.values[c]),s.setStyle(i,u,o.styles[c]),s.setFormula(i,u,o.kinds[c]&g?o.formulas.get(c):null)}return s.revision++,n.engine?.cellsChanged(s,o.rows,o.cols,o.count),r(l)};return this.notify(),r(e)}notify(){const{log:n,sheet:s,book:e}=this;s.revision++,e.engine?.cellsChanged(s,n.rows,n.cols,n.count)}}function Q(t){const n=new WeakSet,s=new WeakSet;return t.columns=t.columns.slice(),{sheet:t,saveCell(e,r){let o=t.columns[r];if(o===void 0)return;n.has(o)||(o=o.slice(),t.columns[r]=o,n.add(o));const l=e>>>10,c=o[l];if(c===void 0||s.has(c))return;const i={kinds:c.kinds.slice(),values:c.values.slice(),styles:c.styles?c.styles.slice():null};o[l]=i,s.add(i)}}}export{M as EMPTY,N as ForeignLog,R as SPILL,W as allUndo,K as boundsOf,z as cellInRect,E as changesPartOfArray,Q as cowTx,A as formulaText,Y as indexRange,L as isWholeCols,O as isWholeRows,J as mapRect,q as readBlock,U as rectInside,G as rectPairs,P as rectsTouch,_ as sameRect,D as segmentsOf,H as usedPart,j as withoutHiddenFormulas};
|
package/cells/book-css.js
CHANGED
|
@@ -167,8 +167,8 @@ const r=`
|
|
|
167
167
|
#app.bk-fx-expanded #formula-input { height: 72px; }
|
|
168
168
|
|
|
169
169
|
.bk-note { position: absolute; z-index: 6; border: 1px solid #808080; background: #ffffe1; color: #000; box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.3); padding: 2px 3px; white-space: pre-wrap; overflow: hidden; cursor: move; font-size: 10px; line-height: 1.25; }
|
|
170
|
-
.bk-note-edit { padding: 4px 5px; border-style: dashed !important; }
|
|
171
|
-
.bk-note-text { display: block; width: 100%; height: 100%; resize: none; outline: 0; padding: 0; background: transparent; color: inherit; cursor: text; user-select: text; }
|
|
170
|
+
.bk-note-edit { display: flex; flex-direction: column; padding: 4px 5px; border-style: dashed !important; }
|
|
171
|
+
.bk-note-text { flex: 1; min-height: 0; display: block; width: 100%; height: 100%; resize: none; outline: 0; padding: 0; background: transparent; color: inherit; cursor: text; user-select: text; }
|
|
172
172
|
.bk-note-body { height: 100%; overflow: hidden; pointer-events: none; }
|
|
173
173
|
.bk-note-grip { position: absolute; right: 0; bottom: 0; width: 8px; height: 8px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, #808080 50%); }
|
|
174
174
|
.bk-mentions { position: fixed; z-index: 50; min-width: 150px; max-height: 40vh; overflow-y: auto; padding: 5px; border-radius: 8px; background: var(--menu); color: var(--ink); box-shadow: var(--shadow); }
|
package/cells/cell-defaults.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BOOL as
|
|
1
|
+
import{BOOL as m,EMPTY as v,ERR as z,ERRORS as T,NUM as k,STR as g}from"../core/sheet.js";import{registerSparseMap as E,sparseKey as C}from"../core/sparse.js";import{registerSection as Y}from"./sections.js";E("cellDefaults");const y=16384;function O(e,r,s,f,o){if(o.f===void 0)return typeof o.v=="number"?{kind:k,value:o.v}:typeof o.v=="boolean"?{kind:m,value:o.v?1:0}:{kind:g,value:e.strings.add(String(o.v))};const{engine:n}=e;if(!n)return{kind:v,value:0};try{const l=n.template(o.f,s,f).fn(s,f,r),t=l?.sheet?n.refAuto(l,s,f):l;return typeof t=="number"?{kind:k,value:t}:typeof t=="boolean"?{kind:m,value:t?1:0}:typeof t=="string"?{kind:g,value:e.strings.add(t)}:t&&t.code!==void 0?{kind:z,value:Math.max(0,T.indexOf(t.code))}:{kind:v,value:0}}catch{return{kind:v,value:0}}}function B(e,r,s,f,o,n,l,t,i,a,u){const{book:p,dpr:M}=e;for(const[x,R]of s.cellDefaults){const c=Math.floor(x/y),d=x-c*y;if(c<o||c>n||d<l||d>t||s.kind(c,d)!==0)continue;const{kind:D,value:S}=O(p,s,c,d,R);if(D===v)continue;const b=Math.round(f.x*M+(e.displayCols.offsetOf(d)-f.originX)*i),A=Math.round(f.y*M+(s.rows.offsetOf(c)-f.originY)*i),h=Math.round(e.displayCols.sizeOf(d)*i),w=Math.round(s.rows.sizeOf(c)*i);h>0&&w>0&&e._paintText(r,c,d,D,S,b,A,h,w,i,l,t,a,u)}}function H(e,r,s){const{book:f,grid:o}=e,n=f.sheet;f.guardHint={ranges:r},f.transact("entry",()=>{const l=n.cellDefaults??null,t=new Map(l??[]);for(const a of r)for(let u=a.r0;u<=Math.min(a.r1,a.r0+1e5);u++)for(let p=a.c0;p<=Math.min(a.c1,a.c0+1e3);p++)s===void 0?t.delete(C(u,p)):t.set(C(u,p),s);n.cellDefaults=t.size>0?t:null,n.cellTypesChanged=!0;const i=a=>()=>{const u=n.cellDefaults;return n.cellDefaults=a,n.cellTypesChanged=!0,i(u)};return i(l)}),o.invalidate()}function I(e){for(const r of e.sheets){if(!r.cellDefaults)continue;const s=new Map;for(const[f,o]of r.cellDefaults){const n=Math.floor(f/y),l=f-n*y;if(r.kind(n,l)!==0)continue;const t=O(e,r,n,l,o);t.kind!==v&&(r._ensure(n,l),n>r.maxRow&&(r.maxRow=n),l>r.maxCol&&(r.maxCol=l),s.set(f,t))}r.defaultsForSave=s.size>0?s:null}}const F=e=>typeof e=="number"||typeof e=="boolean"||typeof e=="string";Y("cellDefaults",{sheet:{save(e){return e.cellDefaults?.size>0?[...e.cellDefaults]:void 0},load(e,r,s){if(!Array.isArray(r))return;const f=r.filter(o=>Array.isArray(o)&&Number.isInteger(o[0])&&o[1]&&(typeof o[1].f=="string"||F(o[1].v)));e.cellDefaults=f.length>0?new Map(f):null;for(const[o,n]of f){const l=Math.floor(o/y),t=o-l*y,i=e.kind(l,t)&7;if(i===v)continue;(n.f!==void 0||(i===k?e.value(l,t)===n.v:i===g?s.strings.get(e.value(l,t))===String(n.v):i===m))&&!(e.kind(l,t)&8)&&e.setCell(l,t,0,0)}}}});export{O as defaultValueAt,B as paintCellDefaults,I as prepareDefaultsForSave,H as setCellDefaults};
|
package/cells/cf-engine.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseRangeRef as D}from"../core/address.js";import{CHUNK_BITS as C,CHUNK_MASK as q,DIRTY as P,KIND_MASK as B,NUM as E}from"../core/sheet.js";import{partsToSerial as R,serialToParts as F}from"../core/numfmt.js";import{compareValues as v,XlError as g}from"../calc/values.js";import{resolveColor as V}from"../io/xlsx-styles.js";const W=c=>c.split(/\s+/).map(D).filter(Boolean),K=1<<19,L=Object.freeze({}),O=new Set(["colorScale","dataBar","iconSet"]),$=c=>[parseInt(c.slice(1,3),16),parseInt(c.slice(3,5),16),parseInt(c.slice(5,7),16)],I=c=>(c<16?"0":"")+c.toString(16),k=c=>c<0?0:c>1?1:c;function U(c,s){const o={...s,...c};return(c.fill!==void 0||c.pattern!==void 0||c.gradient!==void 0||c.noFill)&&(c.pattern===void 0&&delete o.pattern,c.gradient===void 0&&delete o.gradient,c.fill===void 0&&delete o.fill,c.noFill||delete o.noFill),c.borders&&s.borders&&(o.borders={l:c.borders.l??s.borders.l,r:c.borders.r??s.borders.r,t:c.borders.t??s.borders.t,b:c.borders.b??s.borders.b}),o}const N=c=>c instanceof g?String(c.code??c.message??c).toLowerCase():typeof c=="boolean"?c?"true":"false":String(c).toLowerCase();class H{constructor(s,o,n){this.book=s,this.sheet=o,this.colorOf=n??(e=>V(e,s.theme??[])),this.cache=new Map,this.stats=new Map,this.data=new Map,this.flat=null,this.flatOf=null,this.today=0}invalidate(){this.cache.clear(),this.stats.clear(),this.data.clear(),this.flat=null,this.today=0}_rules(){const{cf:s}=this.sheet;if(this.flat!==null&&this.flatOf===s)return this.flat;const o=[];for(const n of s??[]){n._ranges===void 0&&(n._ranges=W(n.sqref));const e=n._ranges;if(e.length===0)continue;let t=1/0,r=1/0,i=-1,l=-1;for(const a of e)a.r0<t&&(t=a.r0),a.c0<r&&(r=a.c0),a.r1>i&&(i=a.r1),a.c1>l&&(l=a.c1);n._base={r0:t,c0:r};for(const a of n.rules)o.push({rule:a,block:n,r0:t,c0:r,r1:i,c1:l,single:e.length===1})}return o.sort((n,e)=>n.rule.priority-e.rule.priority),this.flat=o,this.flatOf=s,this.stoppers=o.filter(n=>n.rule.stopIfTrue&&!O.has(n.rule.type)),o}stoppedBefore(s,o,n){this._rules();for(const e of this.stoppers){if(e.rule.priority>=s)break;if(!(o<e.r0||o>e.r1||n<e.c0||n>e.c1)&&!(!e.single&&!e.block._ranges.some(t=>o>=t.r0&&o<=t.r1&&n>=t.c0&&n<=t.c1))&&this._evaluate(e.rule,e.block,o,n)!==null)return!0}return!1}at(s,o){const n=s*16384+o,e=this.cache.get(n);if(e!==void 0)return e;const t=this._rules();let r=null;for(let i=0;i<t.length;i++){const l=t[i];if(s<l.r0||s>l.r1||o<l.c0||o>l.c1)continue;if(!l.single){const u=l.block._ranges;let h=!1;for(let d=0;d<u.length&&!h;d++){const f=u[d];h=s>=f.r0&&s<=f.r1&&o>=f.c0&&o<=f.c1}if(!h)continue}const a=this._evaluate(l.rule,l.block,s,o);if(a!==null&&(r=r===null?a:U(r,a),l.rule.stopIfTrue&&!O.has(l.rule.type)))break}return this.cache.size>=K&&this.cache.clear(),this.cache.set(n,r),r}_value(s,o){return this.book.engine?this.book.engine.read(this.sheet,s,o):null}_stat(s){let o=this.stats.get(s);if(o!==void 0)return o;const{sheet:n}=this,{engine:e}=this.book;let t=new Float64Array(1024),r=0;for(const u of s._ranges){const h=Math.min(u.c1,n.maxCol),d=Math.min(u.r1,n.maxRow);for(let f=u.c0;f<=h;f++){const m=n.columns[f];if(m!==void 0)for(let p=u.r0>>>C;p<=d>>>C;p++){const _=m[p];if(_===void 0)continue;const x=p<<C,y=Math.max(u.r0-x,0),M=Math.min(d-x,q),{kinds:A,values:T}=_;if(r+(M-y+1)>t.length){const b=new Float64Array(Math.max(t.length*2,r+M-y+1));b.set(t),t=b}for(let b=y;b<=M;b++){const S=A[b];S!==0&&(S&P?(e&&e.read(n,x+b,f),(A[b]&B)===E&&(t[r++]=T[b])):(S&B)===E&&(t[r++]=T[b]))}}}}t=t.subarray(0,r).sort();let i=0;for(let u=0;u<r;u++)i+=t[u];const l=r?i/r:0;let a=0;for(let u=0;u<r;u++)a+=(t[u]-l)**2;return o={nums:t,n:r,mean:l,stdP:r>0?Math.sqrt(a/r):0,min:r?t[0]:0,max:r?t[r-1]:0,others:null},this.stats.set(s,o),o}_others(s){const o=this._stat(s);if(o.others!==null)return o.others;const n=new Map;for(const e of s._ranges)this.book.engine?.scan({sheet:this.sheet,r0:e.r0,c0:e.c0,r1:e.r1,c1:e.c1},t=>{if(typeof t=="number")return;const r=N(t);n.set(r,(n.get(r)??0)+1)});return o.others=n,n}_numberCount(s,o){const{nums:n,n:e}=this._stat(s);let t=0,r=e;for(;t<r;){const i=t+r>>>1;n[i]<o?t=i+1:r=i}return t>=e||n[t]!==o?0:t+1<e&&n[t+1]===o?2:1}_occurrences(s,o){const n=this._others(s);if(typeof o=="number")return this._numberCount(s,o)+(n.get(String(o))??0);const e=N(o),t=n.get(e)??0;return typeof o=="string"&&e!==""&&!Number.isNaN(Number(e))?t+this._numberCount(s,Number(e)):t}_template(s,o,n,e){const t=this._ruleData(s),r=`t${o}`;if(t[r]===void 0){const i=e._base;t[r]=this.book.engine.template(n,i.r0,i.c0)}return t[r]}_formula(s,o,n,e,t){const{engine:r}=this.book,i=s.formulas?.[o];return i===void 0||!r?null:this._run(this._template(s,o,i,n),e,t)}_run(s,o,n){const{engine:e}=this.book,t=e.legacy;e.legacy=!0;try{let r=s.fn(o,n,this.sheet);return(r&&r.sheet||r&&r.refs)&&(r=e.refAuto(r,o,n)),r&&r.data&&([r]=r.data),r===void 0?null:r}catch(r){return r instanceof g?r:null}finally{e.legacy=t}}_dxf(s){return s.dxf?s.dxf:s.dxfId!==null&&s.dxfId!==void 0?this.book.dxfs?.[s.dxfId]??L:L}_threshold(s,o){const n=this._stat(o);switch(s.type){case"min":return n.min;case"max":return n.max;case"autoMin":return Math.min(n.min,0);case"autoMax":return Math.max(n.max,0);default:break}const e=s.val;let t;if(typeof e=="string"&&!/^\s*[-+]?[\d.]+(?:[eE][-+]?\d+)?\s*$/.test(e)){const{engine:r}=this.book;if(!r)return 0;const i=o._base,l=this._run(r.template(e,i.r0,i.c0),i.r0,i.c0);t=typeof l=="number"?l:0}else t=e==null?0:Number(e);switch(s.type){case"percent":return n.min+(n.max-n.min)*t/100;case"percentile":{if(n.n===0)return 0;const r=k(t/100)*(n.n-1),i=Math.floor(r);return i+1<n.n?n.nums[i]+(r-i)*(n.nums[i+1]-n.nums[i]):n.nums[i]}default:return t}}_ruleData(s){let o=this.data.get(s);return o===void 0&&(o={},this.data.set(s,o)),o}_evaluate(s,o,n,e){switch(s.type){case"cellIs":{const t=this._value(n,e);if(t instanceof g)return null;const r=this._formula(s,0,o,n,e);if(r instanceof g)return null;const i=s.operator;let l=!1;if(i==="between"||i==="notBetween"){const a=this._formula(s,1,o,n,e);if(a instanceof g)return null;const u=v(r,a)<=0,h=u?r:a,d=u?a:r,f=v(t,h)>=0&&v(t,d)<=0;l=i==="between"?f:!f}else{const a=v(t,r);l=i==="greaterThan"?a>0:i==="lessThan"?a<0:i==="greaterThanOrEqual"?a>=0:i==="lessThanOrEqual"?a<=0:i==="equal"?a===0:i==="notEqual"?a!==0:!1}return l?this._dxf(s):null}case"expression":{const t=this._formula(s,0,o,n,e);return typeof t=="boolean"?t?this._dxf(s):null:typeof t=="number"&&t!==0?this._dxf(s):null}case"containsText":case"notContainsText":case"beginsWith":case"endsWith":return this._textRule(s,o,n,e)?this._dxf(s):null;case"containsBlanks":{const t=this._value(n,e);return t===null||typeof t=="string"&&t.trim()===""?this._dxf(s):null}case"notContainsBlanks":{const t=this._value(n,e);return t!==null&&!(t instanceof g)&&!(typeof t=="string"&&t.trim()==="")?this._dxf(s):null}case"containsErrors":return this._value(n,e)instanceof g?this._dxf(s):null;case"notContainsErrors":return this._value(n,e)instanceof g?null:this._dxf(s);case"duplicateValues":case"uniqueValues":{const t=this._value(n,e);if(t===null)return null;const r=this._occurrences(o,t);return(s.type==="duplicateValues"?r>1:r===1)?this._dxf(s):null}case"top10":{const t=this._value(n,e);if(typeof t!="number")return null;const r=this._stat(o);let i=s.rank??10;return s.percent&&(i=Math.max(1,Math.floor(r.n*i/100))),i=Math.min(i,r.n),i<=0?null:(s.bottom?t<=r.nums[i-1]:t>=r.nums[r.n-i])?this._dxf(s):null}case"aboveAverage":{const t=this._value(n,e);if(typeof t!="number")return null;const r=this._stat(o),i=s.aboveAverage!==!1,l=r.mean+(i?1:-1)*(s.stdDev||0)*r.stdP;return(i?s.equalAverage?t>=l:t>l:s.equalAverage?t<=l:t<l)?this._dxf(s):null}case"timePeriod":{const t=this._value(n,e);return typeof t=="number"&&this._inPeriod(t,s.timePeriod)?this._dxf(s):null}case"colorScale":{const t=this._value(n,e);return typeof t=="number"?this._colorScale(s,o,t):null}case"dataBar":{const t=this._value(n,e);return typeof t=="number"?this._dataBar(s,o,t):null}case"iconSet":{const t=this._value(n,e);return typeof t=="number"?this._iconSet(s,o,t):null}default:return null}}_textRule(s,o,n,e){if(s.formulas&&s.formulas.length>0&&this.book.engine){const l=this._formula(s,0,o,n,e);return l===!0||typeof l=="number"&&l!==0}const t=this._value(n,e),r=String(s.text??"").toLowerCase();if(t instanceof g)return s.type==="notContainsText";const i=t===null?"":typeof t=="boolean"?t?"true":"false":String(t).toLowerCase();switch(s.type){case"containsText":return i.includes(r);case"notContainsText":return!i.includes(r);case"beginsWith":return i.startsWith(r);default:return i.endsWith(r)}}_colorScale(s,o,n){const e=this._ruleData(s);if(e.stops===void 0){const{cfvo:i,colors:l}=s.colorScale;e.stops=i.map(a=>this._threshold(a,o)),e.css=l.map(a=>this.colorOf({a})??"#FFFFFF"),e.rgb=e.css.map($),e.ends=e.css.map(a=>({fill:a}))}const{stops:t}=e,r=t.length-1;if(n>=t[r])return e.ends[r];if(n<=t[0])return e.ends[0];for(let i=1;i<=r;i++)if(n<t[i]){const l=t[i]-t[i-1],a=l===0?1:(n-t[i-1])/l,u=e.rgb[i-1],h=e.rgb[i];return{fill:`#${I(Math.round(u[0]+(h[0]-u[0])*a))}${I(Math.round(u[1]+(h[1]-u[1])*a))}${I(Math.round(u[2]+(h[2]-u[2])*a))}`}}return e.ends[r]}_barStyle(s,o){const n=this._ruleData(s);if(n.bar!==void 0)return n.bar;const e=s.dataBar,t=e.ext,r=t?.cfvo??e.cfvo;let i=this._threshold(r[0],o),l=this._threshold(r[1],o);l<i&&([i,l]=[l,i]);const a=this.colorOf({a:e.color})??"#638EC6",u=(_,x)=>_?this.colorOf({a:_})??x:x,h=(t?t.minLength:e.minLength??10)/100,d=(t?t.maxLength:e.maxLength??90)/100,f=t?t.axisPosition??"automatic":"none";let m=-1;f==="middle"?m=.5:f==="automatic"&&(i<0&&l>0?m=-i/(l-i):l<=0&&i<0&&(m=1));const p=t?.border?u(t.borderColor,a):null;return n.bar={lo:i,hi:l,minL:h,maxL:d,start:t?h/2:h,axisAt:m,color:a,gradient:t?t.gradient!==!1:!0,border:p,negColor:t&&!t.negFillSame?u(t.negFill,"#FF0000"):a,negBorder:t?.border&&t.negBorderSame===!1?u(t.negBorder,"#FF0000"):p,axisColor:t?u(t.axisColor,"#000000"):"#000000",direction:t?.direction??"context",hide:e.showValue===!1},n.bar}_dataBar(s,o,n){const e=this._barStyle(s,o),{lo:t,hi:r,minL:i,maxL:l,axisAt:a,start:u}=e,h=l-i;let d,f;if(a<0)d=0,f=u+h*(r===t?1:k((n-t)/(r-t)));else{const _=s.dataBar.ext?.axisPosition==="middle"?Math.max(Math.abs(t),Math.abs(r)):n>=0?r:-t,y=(n>=0?1-a:a)*(u+h*(_>0?k(Math.abs(n)/_):0));n>=0?(d=a,f=a+y):(f=a,d=a-y)}return{bar:{style:e,x0:d,x1:f,negative:n<0,pct:f-d,color:n<0?e.negColor:e.color},hideValue:e.hide}}_iconSet(s,o,n){const e=this._ruleData(s),t=s.iconSet;if(e.levels===void 0){e.thresholds=t.cfvo.map(u=>this._threshold(u,o));const a=t.cfvo.length;e.levels=t.cfvo.map((u,h)=>{const d=t.reverse?a-1-h:h,f=t.custom?.[h],m=f?f.iconSet:t.name,p=f?f.iconId:d,_=t.showValue===!1;return m==="NoIcons"?{hideValue:_}:{icon:{name:m,level:p,count:a},hideValue:_}})}const{thresholds:r,levels:i}=e;let l=0;for(let a=r.length-1;a>=1;a--){const u=r[a];if(t.cfvo[a].gte===!1?n>u:n>=u){l=a;break}}return i[l]}_inPeriod(s,o){if(this.today===0){const a=new Date;this.today=R(a.getFullYear(),a.getMonth()+1,a.getDate())}const{today:n}=this,e=Math.floor(s);if(e<0)return!1;switch(o){case"today":return e===n;case"yesterday":return e===n-1;case"tomorrow":return e===n+1;case"last7Days":return e<=n&&e>n-7;default:break}const t=a=>a-F(a).weekday;switch(o){case"thisWeek":return t(e)===t(n);case"lastWeek":return t(e)===t(n)-7;case"nextWeek":return t(e)===t(n)+7;default:break}const r=F(e),i=F(n),l=(r.year-i.year)*12+r.month-i.month;switch(o){case"thisMonth":return l===0;case"lastMonth":return l===-1;case"nextMonth":return l===1;default:return!1}}}function j(c,s){if(!c.cfEval){if(!s)return null;c.cfEval=new H(s,c)}return c.cfEval}function w(c,s,o,n){if(!c.cf||c.cf.length===0)return null;const e=j(c,n),t=e?e.at(s,o):null;return t===null?null:{fill:t.fill??null,noFill:t.noFill===!0,color:t.color??null,iconSet:t.icon?.name??null,iconId:t.icon?.level??null}}function Q(c,s,o,n){const e=w(c,s,o,n);return e&&e.iconSet!==null?{iconSet:e.iconSet,iconId:e.iconId}:null}export{H as CondFormats,w as cfEffectAt,j as evaluatorOf,Q as iconAt};
|
|
1
|
+
import{parseRangeRef as N}from"../core/address.js";import{CHUNK_BITS as C,CHUNK_MASK as D,DIRTY as q,KIND_MASK as T,NUM as B}from"../core/sheet.js";import{partsToSerial as P,serialToParts as F}from"../core/numfmt.js";import{compareValues as M,XlError as x}from"../calc/values.js";import{wildcardRegex as R}from"../calc/functions/helpers.js";import{resolveColor as V}from"../io/xlsx-styles.js";const W=c=>c.split(/\s+/).map(N).filter(Boolean),K=1<<19,w=Object.freeze({}),E=new Set(["colorScale","dataBar","iconSet"]),$=c=>[parseInt(c.slice(1,3),16),parseInt(c.slice(3,5),16),parseInt(c.slice(5,7),16)],I=c=>(c<16?"0":"")+c.toString(16),k=c=>c<0?0:c>1?1:c;function U(c,s){const o={...s,...c};return(c.fill!==void 0||c.pattern!==void 0||c.gradient!==void 0||c.noFill)&&(c.pattern===void 0&&delete o.pattern,c.gradient===void 0&&delete o.gradient,c.fill===void 0&&delete o.fill,c.noFill||delete o.noFill),c.borders&&s.borders&&(o.borders={l:c.borders.l??s.borders.l,r:c.borders.r??s.borders.r,t:c.borders.t??s.borders.t,b:c.borders.b??s.borders.b}),o}const O=c=>c instanceof x?String(c.code??c.message??c).toLowerCase():typeof c=="boolean"?c?"true":"false":String(c).toLowerCase();class H{constructor(s,o,n){this.book=s,this.sheet=o,this.colorOf=n??(e=>V(e,s.theme??[])),this.cache=new Map,this.stats=new Map,this.data=new Map,this.flat=null,this.flatOf=null,this.today=0}invalidate(){this.cache.clear(),this.stats.clear(),this.data.clear(),this.flat=null,this.today=0}_rules(){const{cf:s}=this.sheet;if(this.flat!==null&&this.flatOf===s)return this.flat;const o=[];for(const n of s??[]){n._ranges===void 0&&(n._ranges=W(n.sqref));const e=n._ranges;if(e.length===0)continue;let t=1/0,r=1/0,i=-1,l=-1;for(const a of e)a.r0<t&&(t=a.r0),a.c0<r&&(r=a.c0),a.r1>i&&(i=a.r1),a.c1>l&&(l=a.c1);n._base={r0:t,c0:r};for(const a of n.rules)o.push({rule:a,block:n,r0:t,c0:r,r1:i,c1:l,single:e.length===1})}return o.sort((n,e)=>n.rule.priority-e.rule.priority),this.flat=o,this.flatOf=s,this.stoppers=o.filter(n=>n.rule.stopIfTrue&&!E.has(n.rule.type)),o}stoppedBefore(s,o,n){this._rules();for(const e of this.stoppers){if(e.rule.priority>=s)break;if(!(o<e.r0||o>e.r1||n<e.c0||n>e.c1)&&!(!e.single&&!e.block._ranges.some(t=>o>=t.r0&&o<=t.r1&&n>=t.c0&&n<=t.c1))&&this._evaluate(e.rule,e.block,o,n)!==null)return!0}return!1}at(s,o){const n=s*16384+o,e=this.cache.get(n);if(e!==void 0)return e;const t=this._rules();let r=null;for(let i=0;i<t.length;i++){const l=t[i];if(s<l.r0||s>l.r1||o<l.c0||o>l.c1)continue;if(!l.single){const u=l.block._ranges;let h=!1;for(let d=0;d<u.length&&!h;d++){const f=u[d];h=s>=f.r0&&s<=f.r1&&o>=f.c0&&o<=f.c1}if(!h)continue}const a=this._evaluate(l.rule,l.block,s,o);if(a!==null&&(r=r===null?a:U(r,a),l.rule.stopIfTrue&&!E.has(l.rule.type)))break}return this.cache.size>=K&&this.cache.clear(),this.cache.set(n,r),r}_value(s,o){return this.book.engine?this.book.engine.read(this.sheet,s,o):null}_stat(s){let o=this.stats.get(s);if(o!==void 0)return o;const{sheet:n}=this,{engine:e}=this.book;let t=new Float64Array(1024),r=0;for(const u of s._ranges){const h=Math.min(u.c1,n.maxCol),d=Math.min(u.r1,n.maxRow);for(let f=u.c0;f<=h;f++){const m=n.columns[f];if(m!==void 0)for(let p=u.r0>>>C;p<=d>>>C;p++){const _=m[p];if(_===void 0)continue;const b=p<<C,y=Math.max(u.r0-b,0),v=Math.min(d-b,D),{kinds:A,values:L}=_;if(r+(v-y+1)>t.length){const g=new Float64Array(Math.max(t.length*2,r+v-y+1));g.set(t),t=g}for(let g=y;g<=v;g++){const S=A[g];S!==0&&(S&q?(e&&e.read(n,b+g,f),(A[g]&T)===B&&(t[r++]=L[g])):(S&T)===B&&(t[r++]=L[g]))}}}}t=t.subarray(0,r).sort();let i=0;for(let u=0;u<r;u++)i+=t[u];const l=r?i/r:0;let a=0;for(let u=0;u<r;u++)a+=(t[u]-l)**2;return o={nums:t,n:r,mean:l,stdP:r>0?Math.sqrt(a/r):0,min:r?t[0]:0,max:r?t[r-1]:0,others:null,texts:null,wild:null},this.stats.set(s,o),o}_others(s){const o=this._stat(s);if(o.others!==null)return o.others;const n=new Map;for(const e of s._ranges)this.book.engine?.scan({sheet:this.sheet,r0:e.r0,c0:e.c0,r1:e.r1,c1:e.c1},t=>{if(typeof t=="number")return;const r=O(t);n.set(r,(n.get(r)??0)+1)});return o.others=n,n}_numberCount(s,o){const{nums:n,n:e}=this._stat(s);let t=0,r=e;for(;t<r;){const i=t+r>>>1;n[i]<o?t=i+1:r=i}return t>=e||n[t]!==o?0:t+1<e&&n[t+1]===o?2:1}_wildcardCount(s,o){const n=this._stat(s);if(n.texts===null){n.texts=new Map;for(const r of s._ranges)this.book.engine?.scan({sheet:this.sheet,r0:r.r0,c0:r.c0,r1:r.r1,c1:r.c1},i=>{typeof i=="string"&&n.texts.set(i.toLowerCase(),(n.texts.get(i.toLowerCase())??0)+1)})}n.wild??=new Map;const e=o.toLowerCase();let t=n.wild.get(e);if(t===void 0){const r=R(o);t=0;for(const[i,l]of n.texts)r.test(i)&&(t+=l);n.wild.set(e,t)}return t}_occurrences(s,o){if(typeof o=="string"&&/[*?]/.test(o))return this._wildcardCount(s,o);const n=this._others(s);if(typeof o=="number")return this._numberCount(s,o)+(n.get(String(o))??0);const e=O(o),t=n.get(e)??0;return typeof o=="string"&&e!==""&&!Number.isNaN(Number(e))?t+this._numberCount(s,Number(e)):t}_template(s,o,n,e){const t=this._ruleData(s),r=`t${o}`;if(t[r]===void 0){const i=e._base;t[r]=this.book.engine.template(n,i.r0,i.c0)}return t[r]}_formula(s,o,n,e,t){const{engine:r}=this.book,i=s.formulas?.[o];return i===void 0||!r?null:this._run(this._template(s,o,i,n),e,t)}_run(s,o,n){const{engine:e}=this.book,t=e.legacy;e.legacy=!0;try{let r=s.fn(o,n,this.sheet);return(r&&r.sheet||r&&r.refs)&&(r=e.refAuto(r,o,n)),r&&r.data&&([r]=r.data),r===void 0?null:r}catch(r){return r instanceof x?r:null}finally{e.legacy=t}}_dxf(s){return s.dxf?s.dxf:s.dxfId!==null&&s.dxfId!==void 0?this.book.dxfs?.[s.dxfId]??w:w}_threshold(s,o){const n=this._stat(o);switch(s.type){case"min":return n.min;case"max":return n.max;case"autoMin":return Math.min(n.min,0);case"autoMax":return Math.max(n.max,0);default:break}const e=s.val;let t;if(typeof e=="string"&&!/^\s*[-+]?[\d.]+(?:[eE][-+]?\d+)?\s*$/.test(e)){const{engine:r}=this.book;if(!r)return 0;const i=o._base,l=this._run(r.template(e,i.r0,i.c0),i.r0,i.c0);t=typeof l=="number"?l:0}else t=e==null?0:Number(e);switch(s.type){case"percent":return n.min+(n.max-n.min)*t/100;case"percentile":{if(n.n===0)return 0;const r=k(t/100)*(n.n-1),i=Math.floor(r);return i+1<n.n?n.nums[i]+(r-i)*(n.nums[i+1]-n.nums[i]):n.nums[i]}default:return t}}_ruleData(s){let o=this.data.get(s);return o===void 0&&(o={},this.data.set(s,o)),o}_evaluate(s,o,n,e){switch(s.type){case"cellIs":{const t=this._value(n,e);if(t instanceof x)return null;const r=this._formula(s,0,o,n,e);if(r instanceof x)return null;const i=s.operator;let l=!1;if(i==="between"||i==="notBetween"){const a=this._formula(s,1,o,n,e);if(a instanceof x)return null;const u=M(r,a)<=0,h=u?r:a,d=u?a:r,f=M(t,h)>=0&&M(t,d)<=0;l=i==="between"?f:!f}else{const a=M(t,r);l=i==="greaterThan"?a>0:i==="lessThan"?a<0:i==="greaterThanOrEqual"?a>=0:i==="lessThanOrEqual"?a<=0:i==="equal"?a===0:i==="notEqual"?a!==0:!1}return l?this._dxf(s):null}case"expression":{const t=this._formula(s,0,o,n,e);return typeof t=="boolean"?t?this._dxf(s):null:typeof t=="number"&&t!==0?this._dxf(s):null}case"containsText":case"notContainsText":case"beginsWith":case"endsWith":return this._textRule(s,o,n,e)?this._dxf(s):null;case"containsBlanks":{const t=this._value(n,e);return t===null||typeof t=="string"&&t.trim()===""?this._dxf(s):null}case"notContainsBlanks":{const t=this._value(n,e);return t!==null&&!(t instanceof x)&&!(typeof t=="string"&&t.trim()==="")?this._dxf(s):null}case"containsErrors":return this._value(n,e)instanceof x?this._dxf(s):null;case"notContainsErrors":return this._value(n,e)instanceof x?null:this._dxf(s);case"duplicateValues":case"uniqueValues":{const t=this._value(n,e);if(t===null)return null;const r=this._occurrences(o,t);return(s.type==="duplicateValues"?r>1:r===1)?this._dxf(s):null}case"top10":{const t=this._value(n,e);if(typeof t!="number")return null;const r=this._stat(o);let i=s.rank??10;return s.percent&&(i=Math.max(1,Math.floor(r.n*i/100))),i=Math.min(i,r.n),i<=0?null:(s.bottom?t<=r.nums[i-1]:t>=r.nums[r.n-i])?this._dxf(s):null}case"aboveAverage":{const t=this._value(n,e);if(typeof t!="number")return null;const r=this._stat(o),i=s.aboveAverage!==!1,l=r.mean+(i?1:-1)*(s.stdDev||0)*r.stdP;return(i?s.equalAverage?t>=l:t>l:s.equalAverage?t<=l:t<l)?this._dxf(s):null}case"timePeriod":{const t=this._value(n,e);return typeof t=="number"&&this._inPeriod(t,s.timePeriod)?this._dxf(s):null}case"colorScale":{const t=this._value(n,e);return typeof t=="number"?this._colorScale(s,o,t):null}case"dataBar":{const t=this._value(n,e);return typeof t=="number"?this._dataBar(s,o,t):null}case"iconSet":{const t=this._value(n,e);return typeof t=="number"?this._iconSet(s,o,t):null}default:return null}}_textRule(s,o,n,e){if(s.formulas&&s.formulas.length>0&&this.book.engine){const l=this._formula(s,0,o,n,e);return l===!0||typeof l=="number"&&l!==0}const t=this._value(n,e),r=String(s.text??"").toLowerCase();if(t instanceof x)return s.type==="notContainsText";const i=t===null?"":typeof t=="boolean"?t?"true":"false":String(t).toLowerCase();switch(s.type){case"containsText":return i.includes(r);case"notContainsText":return!i.includes(r);case"beginsWith":return i.startsWith(r);default:return i.endsWith(r)}}_colorScale(s,o,n){const e=this._ruleData(s);if(e.stops===void 0){const{cfvo:i,colors:l}=s.colorScale;e.stops=i.map(a=>this._threshold(a,o)),e.css=l.map(a=>this.colorOf({a})??"#FFFFFF"),e.rgb=e.css.map($),e.ends=e.css.map(a=>({fill:a}))}const{stops:t}=e,r=t.length-1;if(n>=t[r])return e.ends[r];if(n<=t[0])return e.ends[0];for(let i=1;i<=r;i++)if(n<t[i]){const l=t[i]-t[i-1],a=l===0?1:(n-t[i-1])/l,u=e.rgb[i-1],h=e.rgb[i];return{fill:`#${I(Math.round(u[0]+(h[0]-u[0])*a))}${I(Math.round(u[1]+(h[1]-u[1])*a))}${I(Math.round(u[2]+(h[2]-u[2])*a))}`}}return e.ends[r]}_barStyle(s,o){const n=this._ruleData(s);if(n.bar!==void 0)return n.bar;const e=s.dataBar,t=e.ext,r=t?.cfvo??e.cfvo;let i=this._threshold(r[0],o),l=this._threshold(r[1],o);l<i&&([i,l]=[l,i]);const a=this.colorOf({a:e.color})??"#638EC6",u=(_,b)=>_?this.colorOf({a:_})??b:b,h=(t?t.minLength:e.minLength??10)/100,d=(t?t.maxLength:e.maxLength??90)/100,f=t?t.axisPosition??"automatic":"none";let m=-1;f==="middle"?m=.5:f==="automatic"&&(i<0&&l>0?m=-i/(l-i):l<=0&&i<0&&(m=1));const p=t?.border?u(t.borderColor,a):null;return n.bar={lo:i,hi:l,minL:h,maxL:d,start:t?h/2:h,axisAt:m,color:a,gradient:t?t.gradient!==!1:!0,border:p,negColor:t&&!t.negFillSame?u(t.negFill,"#FF0000"):a,negBorder:t?.border&&t.negBorderSame===!1?u(t.negBorder,"#FF0000"):p,axisColor:t?u(t.axisColor,"#000000"):"#000000",direction:t?.direction??"context",hide:e.showValue===!1},n.bar}_dataBar(s,o,n){const e=this._barStyle(s,o),{lo:t,hi:r,minL:i,maxL:l,axisAt:a,start:u}=e,h=l-i;let d,f;if(a<0)d=0,f=u+h*(r===t?1:k((n-t)/(r-t)));else{const _=s.dataBar.ext?.axisPosition==="middle"?Math.max(Math.abs(t),Math.abs(r)):n>=0?r:-t,y=(n>=0?1-a:a)*(u+h*(_>0?k(Math.abs(n)/_):0));n>=0?(d=a,f=a+y):(f=a,d=a-y)}return{bar:{style:e,x0:d,x1:f,negative:n<0,pct:f-d,color:n<0?e.negColor:e.color},hideValue:e.hide}}_iconSet(s,o,n){const e=this._ruleData(s),t=s.iconSet;if(e.levels===void 0){e.thresholds=t.cfvo.map(u=>this._threshold(u,o));const a=t.cfvo.length;e.levels=t.cfvo.map((u,h)=>{const d=t.reverse?a-1-h:h,f=t.custom?.[h],m=f?f.iconSet:t.name,p=f?f.iconId:d,_=t.showValue===!1;return m==="NoIcons"?{hideValue:_}:{icon:{name:m,level:p,count:a},hideValue:_}})}const{thresholds:r,levels:i}=e;let l=0;for(let a=r.length-1;a>=1;a--){const u=r[a];if(t.cfvo[a].gte===!1?n>u:n>=u){l=a;break}}return i[l]}_inPeriod(s,o){if(this.today===0){const a=new Date;this.today=P(a.getFullYear(),a.getMonth()+1,a.getDate())}const{today:n}=this,e=Math.floor(s);if(e<0)return!1;switch(o){case"today":return e===n;case"yesterday":return e===n-1;case"tomorrow":return e===n+1;case"last7Days":return e<=n&&e>n-7;default:break}const t=a=>a-F(a).weekday;switch(o){case"thisWeek":return t(e)===t(n);case"lastWeek":return t(e)===t(n)-7;case"nextWeek":return t(e)===t(n)+7;default:break}const r=F(e),i=F(n),l=(r.year-i.year)*12+r.month-i.month;switch(o){case"thisMonth":return l===0;case"lastMonth":return l===-1;case"nextMonth":return l===1;default:return!1}}}function j(c,s){if(!c.cfEval){if(!s)return null;c.cfEval=new H(s,c)}return c.cfEval}function z(c,s,o,n){if(!c.cf||c.cf.length===0)return null;const e=j(c,n),t=e?e.at(s,o):null;return t===null?null:{fill:t.fill??null,noFill:t.noFill===!0,color:t.color??null,iconSet:t.icon?.name??null,iconId:t.icon?.level??null}}function tt(c,s,o,n){const e=z(c,s,o,n);return e&&e.iconSet!==null?{iconSet:e.iconSet,iconId:e.iconId}:null}export{H as CondFormats,z as cfEffectAt,j as evaluatorOf,tt as iconAt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{colName as
|
|
1
|
+
import{colName as I,rangeRef as K,sheetPrefix as O}from"../core/address.js";import{KIND_MASK as P,NUM as z}from"../core/sheet.js";import{changeOutline as H}from"../core/whatif.js";import{outlineChanged as M,setFlag as R}from"./outline-column.js";import{xmlAttr as j}from"../io/xml-escape.js";const A={Sum:["SUM",null],Count:["COUNTA","count"],Average:["AVERAGE","average"],Max:["MAX","max"],Min:["MIN","min"],Product:["PRODUCT","product"],"Count Numbers":["COUNT","countNums"],StdDev:["STDEV","stdDev"],StdDevp:["STDEVP","stdDevp"],Var:["VAR","var"],Varp:["VARP","varp"]},x=n=>typeof n=="string"&&/^[=+\-@']/.test(n)?`'${n}`:String(n??"");function F(n){return String(n??"Book1").replace(/\.[^.]+$/,"").toLowerCase().replace(/(^|[^\p{L}])(\p{L})/gu,(m,i,c)=>i+c.toUpperCase())}function J(n){if(!n)return"";const t=A[n.fn]?.[1],m=`${t?` function="${t}"`:""}${n.leftLabels?' leftLabels="1"':""}${n.topLabels?' topLabels="1"':""}${n.link?' link="1"':""}`,i=n.refs.map(c=>`<dataRef ref="${K(c.range)}" sheet="${j(c.sheet.name)}"/>`).join("");return`<dataConsolidate${m}><dataRefs count="${n.refs.length}">${i}</dataRefs></dataConsolidate>`}function Q(n,t,m,i,{topRow:c=!1,leftCol:w=!1}={}){const{book:d}=n,u=d.sheet;if(m.some(r=>r.sheet===u))return{error:"Links can't be created to source areas on the destination sheet."};const L=d.engine,v=A[i]?.[0]??"SUM",S=[],y=new Map,C=[],D=new Map,k=(r,l,a)=>{const p=String(a).toLowerCase();let s=r.get(p);return s===void 0&&(s=l.length,r.set(p,s),l.push(a)),s},T=m.map(({sheet:r,range:l})=>{const a=l.r0+(c?1:0),p=l.c0+(w?1:0),s=[];for(let e=p;e<=l.c1;e++){const o=c?L.read(r,l.r0,e):e-p;c&&(o===null||o==="")||s.push([e,k(D,C,o)])}const h=[];for(let e=a;e<=l.r1;e++){const o=w?L.read(r,e,l.c0):e-a;w&&(o===null||o==="")||h.push([e,k(y,S,o)])}return{from:r,cols:s,rows:h}}),$=t.col+(w?2:0),V=F(d.fileName??n.fileName);let f=t.row+(c?1:0);return d.guardHint={ranges:[{r0:t.row,c0:t.col,r1:t.row+1,c1:$+C.length}]},d.transact("consolidate",r=>{const l=U(u);return c&&C.forEach((a,p)=>d.setInput(r,t.row,$+p,x(a))),S.forEach((a,p)=>{const s=f,h=new Set;for(const o of T)for(const[g,b]of o.rows)if(b===p){w&&d.setInput(r,f,t.col+1,x(V));for(const[N,E]of o.cols)(o.from.kind(g,N)&P)===z&&(d.setInput(r,f,$+E,`=${O(o.from.name)}$${I(N)}$${g+1}`),h.add(E));f++}if(f===s)return;const e=f-1;H(u,"row",s,e,1);for(let o=s;o<=e;o++)u.rows.setHidden(o,!0);w&&d.setInput(r,f,t.col,x(a));for(const o of[...h].sort((g,b)=>g-b)){const g=I($+o);d.setInput(r,f,$+o,`=${v}(${g}${s+1}${e>s?`:${g}${e+1}`:""})`)}R(u,"row",f,!0),f++}),u.dataConsolidate={fn:i,leftLabels:w,topLabels:c,link:!0,refs:m.map(a=>({sheet:a.sheet,range:a.range}))},u.dataConsolidateChanged=!0,M(u),u.colsChanged=!0,l}),d.dirty=!0,n.objects?.geometryChanged?.(),n.grid.invalidate(),{rows:S.length,cols:C.length}}function U(n){const t={rowExtras:n.rowExtras?new Map(n.rowExtras):null,hidden:new Set(n.rows.hiddenSizes?n.rows.hiddenSizes.keys():[]),consolidate:n.dataConsolidate??null};return()=>{const m=U(n);if(n.rows.hiddenSizes)for(const i of[...n.rows.hiddenSizes.keys()])t.hidden.has(i)||n.rows.setHidden(i,!1);for(const i of t.hidden)n.rows.setHidden(i,!0);return n.rowExtras=t.rowExtras,n.dataConsolidate=t.consolidate,n.dataConsolidateChanged=!0,M(n),n.revision++,m}}export{A as LINK_FUNCTIONS,F as bookLabel,Q as consolidateLinked,J as dataConsolidateXml};
|
package/cells/find-engine.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CHUNK_BITS as T,CHUNK_MASK as R,EMPTY as
|
|
2
|
-
`);return{...t,text:s}}function z(e,t,n){if(!e.comments)return[];const s=[];for(const[o,i]of e.comments){const r=Math.floor(o/16384);s.push({row:r,col:o-r*16384,note:
|
|
1
|
+
import{formulaEntryLimit as B}from"../calc/parser.js";import{CHUNK_BITS as T,CHUNK_MASK as R,EMPTY as J,FORMULA as U,KIND_MASK as W,SPILL as D,STR as G}from"../core/sheet.js";const N=/[.+^${}()|[\]\\]/g;function H(e){if(!/[*?~]/.test(e))return null;let t="";for(let n=0;n<e.length;n++){const s=e[n];s==="~"&&n+1<e.length&&"*?~".includes(e[n+1])?t+=e[++n].replace(/[*?]/,"\\$&"):s==="*"?t+="[\\s\\S]*":s==="?"?t+="[\\s\\S]":t+=s.replace(N,"\\$&")}return t}function v(e,{matchCase:t=!1,whole:n=!1}={}){const s=H(e);if(s===null&&!n){if(t)return r=>r.includes(e);const i=e.toLowerCase();return r=>r.toLowerCase().includes(i)}if(s===null){if(t)return r=>r===e;const i=e.toLowerCase();return r=>r.toLowerCase()===i}const o=new RegExp(n?`^(?:${s})$`:s,t?"":"i");return i=>o.test(i)}function X(e,t,{matchCase:n=!1,whole:s=!1}={}){const o=H(e)??e.replace(N,"\\$&").replace(/[*?]/g,"\\$&"),i=new RegExp(s?`^(?:${o})$`:o,n?"g":"gi");return r=>r.replace(i,()=>t)}const Y=(e,t)=>e===t||e&&t&&typeof e=="object"&&JSON.stringify(e)===JSON.stringify(t);function q(e,t,n){const{styles:s,strings:o}=e,{what:i,look:r,format:h}=t,u=i===""?null:v(i,t),d=new Uint8Array(o.size+1),c=new Map,m=l=>{let a=c.get(l);if(a===void 0){const w=s.get(l);a=Object.keys(h).every(x=>Y(w[x]??null,h[x]??null)),c.set(l,a)}return a};return(l,a,w,x,f)=>{if(r==="values"&&(l.rows.isHidden(a)||l.cols.isHidden(w)||l.filteredRows?.has(a))||h!==null&&!m(l.style(a,w)))return!1;if(u===null)return!0;const p=x&W,S=l.protection&&x&U&&s.get(l.style(a,w)).hiddenFormula;if(r==="formulas"&&x&U&&!S)return u(e.editText(l,a,w));if(p===J)return!1;if(p===G){if(f>=d.length)return u(o.get(f));let y=d[f];return y===0&&(y=u(o.get(f))?1:2,d[f]=y),y===1}const g=r==="formulas"&&!S?e.editText(l,a,w):n(p,f,s.get(l.style(a,w)));return u(g)}}const P=12,F=()=>new Promise(e=>setTimeout(e,0));class K{constructor(t){this.ctrl=t,this.start=performance.now()}async pause(){return performance.now()-this.start<P?!this.ctrl.cancelled:(this.ctrl.onProgress?.(),await F(),this.start=performance.now(),!this.ctrl.cancelled)}}const A=(e,t,n)=>e?n*1048576+t:t*16384+n;function Q(e){const t=[];for(let n=0;n<=e.maxCol;n++)e.columns[n]!==void 0&&t.push(n);return t}async function _(e,{byCols:t,dir:n,from:s,to:o,withEmpty:i},r,h){const u=Q(e);n<0&&u.reverse();const d=s===null?-n*(1/0):s,c=o===null?n*(1/0):o,m=n>0?f=>f>=d&&f<=c:f=>f<=d&&f>=c,l=i===!0;if(t){for(const f of u){const p=e.columns[f],S=n>0?0:p.length-1,g=n>0?p.length:-1;for(let y=S;y!==g;y+=n){const L=p[y];if(L===void 0)continue;const k=y<<T,{kinds:I,values:M,styles:E}=L;for(let C=n>0?0:R;C>=0&&C<=R;C+=n){const O=I[C];if(O===0&&!(l&&E!==null&&E[C]!==0))continue;const $=k+C;if(m(A(!0,$,f))&&r($,f,O,M[C]))return!0}if(!await h.pause())return!1}}return!1}const a=e.maxRow>>>T,w=n>0?0:a,x=n>0?a+1:-1;for(let f=w;f!==x;f+=n){const p=[];for(const g of u){const y=e.columns[g][f];y!==void 0&&p.push(g,y)}if(p.length===0)continue;const S=f<<T;for(let g=n>0?0:R;g>=0&&g<=R;g+=n){const y=S+g;for(let L=0;L<p.length;L+=2){const k=p[L+1],I=k.kinds[g];if(I===0&&!(l&&k.styles!==null&&k.styles[g]!==0))continue;const M=p[L];if(m(A(!1,y,M))&&r(y,M,I,k.values[g]))return!0}}if(!await h.pause())return!1}return!1}function V(e,t){if(!t.author?.startsWith("tc="))return t;const n=t.author.slice(3),s=(e.threads??[]).filter(o=>o.id===n||o.parentId===n).map(o=>o.text).join(`
|
|
2
|
+
`);return{...t,text:s}}function z(e,t,n){if(!e.comments)return[];const s=[];for(const[o,i]of e.comments){const r=Math.floor(o/16384);s.push({row:r,col:o-r*16384,note:V(e,i)})}return s.sort((o,i)=>n*(A(t,o.row,o.col)-A(t,i.row,i.col))),s}function Z(e,t,n){const s=e.sheets.filter(r=>!r.hidden);if(t.within!=="workbook")return[e.sheet];const o=s.indexOf(e.sheet),i=[];for(let r=0;r<s.length;r++)i.push(s[(o+n*r+s.length*2)%s.length]);return i}const b=(e,t,n)=>e.some(s=>t>=s.r0&&t<=s.r1&&n>=s.c0&&n<=s.c1);function j(e,t,n){const s=q(e,t,n);if(!t.ranges)return s;const o=t.sheet??e.sheet;return(i,r,h,u,d)=>(i!==o||b(t.ranges,r,h))&&s(i,r,h,u,d)}async function ct(e,t,n,s,o,i={}){const r=t.byColumns===!0,h=new K(i),u=Z(e,t,s),d=A(r,n.row,n.col);if(t.look==="notes")return tt(e,t,u,d,r,s);const c=j(e,t,o),m=t.what===""&&t.format!==null;let l=null;const a=async(w,x,f,p)=>(await _(w,{byCols:r,dir:s,from:x,to:f,withEmpty:m},(S,g,y,L)=>p&&A(r,S,g)===d||!c(w,S,g,y,L)?!1:(l={sheet:w,row:S,col:g},!0),h),l!==null||i.cancelled===!0);if(await a(u[0],d,null,!0))return l;for(let w=1;w<u.length;w++)if(await a(u[w],null,null,!1))return l;return await a(u[0],null,d,!1),l}function tt(e,t,n,s,o,i){const r=v(t.what,t),h=c=>r(c.note.text??""),u=z(n[0],o,i),d=i>0?c=>c>s:c=>c<s;for(const c of u)if(d(A(o,c.row,c.col))&&h(c))return{sheet:n[0],row:c.row,col:c.col};for(let c=1;c<n.length;c++)for(const m of z(n[c],o,i))if(h(m))return{sheet:n[c],row:m.row,col:m.col};for(const c of u)if(!d(A(o,c.row,c.col))&&h(c))return{sheet:n[0],row:c.row,col:c.col};return null}class et{constructor(t){this.cap=t,this.count=0,this.overflow=!1,this.size=Math.min(t,1024),this.rows=new Uint32Array(this.size),this.cols=new Uint16Array(this.size),this.sheets=new Uint16Array(this.size),this.sheetList=[]}push(t,n,s){if(this.count===this.cap)return this.overflow=!0,!1;if(this.count===this.size){this.size=Math.min(this.cap,this.size*2);const r=(h,u)=>{const d=new h(this.size);return d.set(u),d};this.rows=r(Uint32Array,this.rows),this.cols=r(Uint16Array,this.cols),this.sheets=r(Uint16Array,this.sheets)}let o=this.sheetList.indexOf(t);o<0&&(o=this.sheetList.length,this.sheetList.push(t));const i=this.count++;return this.rows[i]=n,this.cols[i]=s,this.sheets[i]=o,!0}}async function nt(e,t,n,s={},o=1e5){const i=new et(o),r=t.byColumns===!0,h=new K(s),u=t.sheet?[t.sheet]:t.within==="workbook"?e.sheets.filter(m=>!m.hidden):[e.sheet];if(t.look==="notes"){const m=v(t.what,t);for(const l of u)for(const a of z(l,r,1))m(a.note.text??"")&&i.push(l,a.row,a.col);return i}const d=j(e,t,n),c=t.what===""&&t.format!==null;for(const m of u)if(await _(m,{byCols:r,dir:1,from:null,to:null,withEmpty:c},(a,w,x,f)=>d(m,a,w,x,f)?!i.push(m,a,w):!1,h)||s.cancelled)break;return i}function st(e,t,n,s,o,i,r=null){const{sheet:h}=t;let u=!1;if(o!==null){const d=h.formula(n,s);if(d&&d.t==="array")return!1;const c=h.kind(n,s);if(c&D&&!(c&U))return!1;const m=e.editText(h,n,s),l=o(m);if(l!==m&&l.startsWith("=")&&l.length>1&&!rt(e,l.slice(1)))return r!==null&&r.invalid++,!1;l!==m&&(e.setInput(t,n,s,l),u=!0)}return i&&(u||t.saveCell(n,s),h.setStyle(n,s,e.styles.derive(h.style(n,s),i)),u=!0),u}async function lt(e,t,n,s,o,i={}){const r=await nt(e,{...t,look:"formulas"},o,i,4294967295);if(i.cancelled)return{count:0,sheets:0,cancelled:!0};const h=t.what===""?null:X(t.what,n??"",t);let u=0,d=0;const c={locked:0,invalid:0},m=[];for(let l=0;l<r.sheetList.length;l++){const a=r.sheetList[l],w=[];let x=0,f=0;for(;f<r.count;){const p=performance.now(),S=e.runSlice(a,"replace",g=>{for(let y=0;f<r.count&&!(y%1024===1023&&performance.now()-p>P);f++,y++){if(r.sheets[f]!==l)continue;const L=r.rows[f],k=r.cols[f];if(a.protection&&e.styles.get(a.style(L,k)).unlocked!==!0){c.locked++;continue}st(e,g,L,k,h,s,c)&&x++}});if(S!==null&&w.push(S),i.onProgress?.(),f<r.count&&await F(),i.cancelled)return e.rollbackSlices([...m,...w]),{count:0,sheets:0,cancelled:!0}}m.push(...w),x>0&&(u+=x,d++)}return e.pushFolded(m,"replace",e.sheet),{count:u,sheets:d,...c}}function rt(e,t){if(!e.engine)return!B(t);try{return e.engine.validate(t),!0}catch{return!1}}export{et as FoundList,nt as findAll,ct as findNext,v as makeMatcher,X as makeReplacer,q as makeTest,lt as replaceAll,st as replaceInCell};
|
package/cells/format-panes.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{el as n}from"../ui/dialogs.js";import{PATTERN_LABELS as
|
|
2
|
-
<g data-hand><text x="10" y="79.5" font-size="13" fill="#000">${
|
|
3
|
-
<path data-mark d="${X(S.cx+S.radius,S.cy,3.4)}" fill="#8c1d2f"/></svg>`}function mt(e,t,l,r){D();let a=e.hAlign??"",c=e.rotation===255,u=e.rotation>90&&e.rotation<=180?90-e.rotation:e.rotation===255?0:e.rotation;const x=n("div",{class:"dlg-label",textContent:s("Indent:")}),v=_({value:e.indent,min:0,max:250,label:w("fc","Indent"),onInput:o=>{t.indent=Math.max(0,o||0)}}),L=()=>{const o=q.has(a)||Number(v.input.value)>0;v.setDisabled(!o),x.classList.toggle("fc-off",!o)},f=E("Justify distributed",e.justifyLastLine===!0,o=>{t.justifyLastLine=o||void 0}),F=()=>{const o=a==="distributed";f.input.disabled=!o},N=P(Y(ot),e.hAlign,o=>{a=o,t.hAlign=o||null,!q.has(o)&&Number(v.input.value)>0&&(v.set(0),t.indent=0),o!=="distributed"&&f.input.checked&&(f.input.checked=!1,t.justifyLastLine=void 0),L(),F()},"Horizontal alignment"),h=_({value:u,min:-90,max:90,label:"Degrees",onInput:o=>T(Math.max(-90,Math.min(90,o||0)),!1)}),g=it(rt()),y=g.querySelector("[data-hand]"),d=g.querySelector("[data-mark]"),p=n("button",{type:"button",class:"fc-vert","aria-label":s("Vertical text"),title:s("Vertical text"),"aria-pressed":String(c)},...[...s("Text")].map(o=>n("span",{textContent:o}))),I=()=>{y.setAttribute("transform",`rotate(${-u} ${S.cx} ${S.cy})`),d.setAttribute("transform",`rotate(${-u} ${S.cx} ${S.cy})`),y.style.opacity=c?"0.3":"1",d.style.display=c?"none":"",g.setAttribute("aria-valuenow",String(u)),p.setAttribute("aria-pressed",String(c))},T=(o,k=!0)=>{u=o,c=!1,t.rotation=o<0?90-o:o,k&&h.set(o),I()};p.addEventListener("click",()=>{c=!c,u=0,h.set(0),t.rotation=c?255:0,I()});const m=o=>{const k=g.getBoundingClientRect(),M=(o.clientX-k.left)*(91/k.width)-S.cx,z=S.cy-(o.clientY-k.top)*(150/k.height);let A=M<=0?Math.sign(z)*90:Math.round(Math.atan2(z,M)*180/Math.PI);const B=Math.round(A/15)*15;Math.abs(B-A)<=2&&(A=B),T(A===0?0:A)};return g.addEventListener("pointerdown",o=>{o.preventDefault(),g.setPointerCapture(o.pointerId),g.focus(),m(o)}),g.addEventListener("pointermove",o=>{g.hasPointerCapture(o.pointerId)&&m(o)}),g.addEventListener("keydown",o=>{const k={ArrowUp:1,ArrowRight:1,ArrowDown:-1,ArrowLeft:-1}[o.key];k&&(o.preventDefault(),T(Math.max(-90,Math.min(90,u+k))))}),L(),F(),I(),n("div",{class:"fc-align fc-bleed"},n("div",{class:"fc-align-left"},n("div",{class:"fc-align-grid"},n("div",{},n("div",{class:"dlg-label",textContent:s("Horizontal alignment:")}),N),n("div",{},x,v.node),n("div",{},n("div",{class:"dlg-label",textContent:s("Vertical alignment:")}),P(Y(st),e.vAlign,o=>{t.vAlign=o||null},"Vertical alignment"))),f),n("div",{class:"fc-align-right"},n("div",{class:"dlg-label",textContent:s("Orientation:")}),n("div",{class:"fc-orient"},p,g),n("div",{class:"fc-degrees"},n("span",{textContent:s("Degrees:")}),h.node)),n("div",{class:"fc-align-low"},n("div",{class:"dlg-label",textContent:s("Text control:")}),E("Wrap text",e.wrap,o=>{t.wrap=o}),E("Shrink to fit",e.shrink,o=>{t.shrink=o}),E("Merge cells",l,r),n("div",{class:"fc-textdir"},n("span",{textContent:s("Text direction:")}),P([[s("Context"),"0"],[s("Left-to-Right"),"1"],[s("Right-to-Left"),"2"]],String(e.readingOrder??0),o=>{t.readingOrder=Number(o)||void 0},"Text direction"))))}const ct=["Aptos Narrow","Aptos","Arial","Calibri","Cambria","Consolas","Courier New","Georgia","Helvetica Neue","Menlo","Tahoma","Times New Roman","Trebuchet MS","Verdana"],K=["Regular","Italic","Bold","Bold Italic"],dt=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72];function H(e,t,l={}){const r=n("input",{class:"dlg-input",spellcheck:!1,"aria-label":s(t),...l}),a=n("select",{class:"dlg-list",size:6,"aria-label":s("{name} list",{name:s(t)})});return{node:n("div",{class:"fc-combo"},n("label",{class:"fc-combo-head"},n("span",{textContent:s(e)}),r),a),input:r,list:a}}const j=(e,t,l=r=>r)=>{for(const r of t)e.append(n("option",{value:r,textContent:l(r)}))},R=e=>{const t=e.options[e.selectedIndex];if(!t)return;const l=t.offsetTop-e.options[0].offsetTop+t.offsetHeight;e.scrollTop=l>e.clientHeight?l-e.clientHeight+t.offsetHeight:0},G=(e,t)=>e&&t?"Bold Italic":e?"Bold":t?"Italic":"Regular",O=e=>w("fontstyle",e);function xt(e,t,l,r){D();const a=i=>l[i]!==void 0?l[i]:e[i],c=t.fontName,u=[...ct];u.includes(e.fontName)||u.unshift(e.fontName);const x=i=>s("{name} (Body)",{name:i}),v=i=>s("{name} (Headings)",{name:i}),L=i=>i===c?x(i):i,f=[x(""),v("")].filter(Boolean),F=i=>{const b=i.trim(),C=f.find($=>b.endsWith($));return C?b.slice(0,b.length-C.length).trim():b},N=[];r&&N.push(v(r)),N.push(x(c),...u);const h=n("div",{class:"fc-preview","aria-label":s("Preview")});let g=null;const y=()=>{const i=a("vertAlign"),b=Number(a("underline")??0);h.style.font=`${a("italic")?"italic ":""}${a("bold")?"bold ":""}${Math.min(a("fontSize"),36)}px "${a("fontName")}", sans-serif`,h.style.color=a("color")??"#000000",h.style.textDecoration=[b?"underline":"",a("strike")?"line-through":""].filter(Boolean).join(" "),h.style.textDecorationStyle=b===2||b===4?"double":"solid",h.replaceChildren(i?n(i==="superscript"?"sup":"sub",{textContent:a("fontName")}):document.createTextNode(a("fontName"))),g.checked=["fontName","fontSize","bold","italic","strike","color"].every(C=>(a(C)??null)===(t[C]??null))&&b===Number(t.underline??0)&&!i},d=H("Font:","Font");j(d.list,N),d.input.value=L(e.fontName),d.list.value=L(e.fontName),d.list.addEventListener("change",()=>{d.input.value=d.list.value,l.fontName=F(d.list.value),y()}),d.input.addEventListener("input",()=>{const i=F(d.input.value);if(i==="")return;l.fontName=i;const b=d.input.value.trim().toLowerCase(),C=N.find($=>$.toLowerCase().startsWith(b));C?(d.list.value=C,R(d.list)):d.list.selectedIndex=-1,y()}),d.input.addEventListener("change",()=>{d.input.value=L(F(d.input.value)||a("fontName"))});const p=H("Font style:","Font style");j(p.list,K,O);const I=i=>{p.input.value=O(i),p.list.value=i};I(G(e.bold,e.italic));const T=i=>{l.bold=i.includes("Bold"),l.italic=i.includes("Italic"),y()};p.list.addEventListener("change",()=>{p.input.value=O(p.list.value),T(p.list.value)}),p.input.addEventListener("input",()=>{const i=p.input.value.trim().toLowerCase(),b=K.find(C=>O(C).toLowerCase()===i);b&&(p.list.value=b,T(b))}),p.input.addEventListener("change",()=>I(G(a("bold"),a("italic"))));const m=H("Size:","Size",{type:"number",min:1,max:409,step:"any"});j(m.list,dt.map(String));const o=i=>{m.input.value=String(i),m.list.value=String(i)};o(e.fontSize),m.list.addEventListener("change",()=>{m.input.value=m.list.value,l.fontSize=Number(m.list.value),y()}),m.input.addEventListener("input",()=>{const i=Number(m.input.value);i>0&&(l.fontSize=i,m.list.value=String(i),y())});const k=P([[s("None"),"0"],[w("underline","Single"),"1"],[w("underline","Double"),"2"],[w("underline","Single Accounting"),"3"],[w("underline","Double Accounting"),"4"]],String(e.underline),i=>{l.underline=Number(i),y()},"Underline"),M=(i,b,C)=>{const $=n("input",{type:"checkbox",checked:b,"aria-label":s(i),on:{change:()=>{C($.checked),y()}}});return{i:$,row:n("label",{class:"dlg-row dlg-check"},$,s(i))}},z=M("Strikethrough",e.strike,i=>{l.strike=i}),A=M("Superscript",e.vertAlign==="superscript",i=>{l.vertAlign=i?"superscript":null,i&&(B.i.checked=!1)}),B=M("Subscript",e.vertAlign==="subscript",i=>{l.vertAlign=i?"subscript":null,i&&(A.i.checked=!1)}),J=V(e.color,"#000000",i=>{l.color=i,y()},{label:"Font color"});g=n("input",{type:"checkbox","aria-label":s("Normal font"),on:{change:()=>{if(!g.checked){y();return}Object.assign(l,{fontName:t.fontName,fontSize:t.fontSize,bold:t.bold,italic:t.italic,strike:t.strike,underline:t.underline??0,color:t.color??null,vertAlign:null}),d.input.value=L(t.fontName),d.list.value=L(t.fontName),o(t.fontSize),I(G(t.bold,t.italic)),k.value=String(t.underline??0),z.i.checked=t.strike,A.i.checked=!1,B.i.checked=!1,J.setValue(t.color??null),R(d.list),R(m.list),y()}}});const U=n("div",{class:"fc-font fc-bleed"},n("div",{class:"fc-font-top"},d.node,p.node,m.node,n("div",{class:"fc-font-cell"},n("div",{class:"dlg-label",textContent:s("Underline:")}),k),n("div",{class:"fc-font-cell"},n("div",{class:"dlg-label",textContent:s("Color:")}),J),n("div",{class:"fc-font-cell fc-font-normal"},n("label",{class:"dlg-row dlg-check"},g,s("Normal font")))),n("div",{class:"fc-font-low"},n("div",{},n("div",{class:"dlg-label",textContent:s("Effects:")}),z.row,A.row,B.row),n("div",{},n("div",{class:"dlg-label",textContent:s("Preview")}),h)));return U.onShow=()=>[d.list,p.list,m.list].forEach(R),y(),U}function Q(e){const t=document.createElement("canvas");if(t.width=32,t.height=20,e){const l=t.getContext("2d");l.fillStyle=W(l,{type:e,fg:"#000000"},1)??"#FFFFFF",l.fillRect(0,0,32,20)}return t}function ut(e,t){const l=n("span",{class:"fc-pat-chip"}),r=nt("Pattern style",l),a=()=>l.replaceChildren(...e?[Q(e)]:[]);return a(),r.setValue=c=>{e=c,a()},lt(r,"Pattern style list",c=>{const u=n("div",{class:"fc-pat-grid"});for(const[x,v]of tt)u.append(n("button",{type:"button",title:w("pattern",x),"aria-label":w("pattern",x),"aria-pressed":String(v===e),on:{click:()=>{e=v,a(),c(),t(v)}}},Q(v)));return u}),r}function ht(e,t,l){D();let r=e.pattern?.type??"",a=e.pattern?.fg??"#000000";const c=n("div",{class:"fc-sample","aria-label":s("Sample")}),u=()=>{const f=t.fill!==void 0?t.fill:e.fill,F=t.gradient!==void 0?t.gradient:e.gradient,N=t.pattern!==void 0?t.pattern:e.pattern;if(c.style.backgroundColor=f??(F||N?"#FFFFFF":"transparent"),c.style.backgroundImage="none",F)c.style.backgroundImage=et(F);else if(N){const h=document.createElement("canvas");h.width=16,h.height=16;const g=h.getContext("2d");g.fillStyle=W(g,N,1)??"#FFFFFF",g.fillRect(0,0,16,16),c.style.backgroundImage=`url(${h.toDataURL()})`}},x=ut(r,f=>{r=f,t.pattern=f?{type:f,fg:a}:null,f&&(t.gradient=null),f&&!e.fill&&!t.fill&&(t.fill="#FFFFFF"),u()}),v=V(e.fill??null,"#FFFFFF",f=>{f===null?(t.fill=null,t.pattern=null,t.gradient=null,r="",x.setValue("")):(t.fill=f,t.gradient=null),u()},{none:"No Color",label:"Background color",named:!0}),L=n("button",{type:"button",class:"dlg-btn",textContent:s("Fill Effects…"),on:{click:()=>l(t.gradient??e.gradient,f=>{t.gradient=f,t.pattern=null,t.fill=f.stops[0].color,r="",x.setValue(""),v.setValue(null),u()})}});return u(),n("div",{class:"fc-fill fc-bleed"},n("div",{class:"fc-fill-left"},n("div",{class:"dlg-label",textContent:s("Background color:")}),v,L),n("div",{class:"fc-fill-right"},n("div",{class:"dlg-label",textContent:s("Pattern color:")}),V(e.pattern?.fg??null,"#000000",f=>{a=f??"#000000",r&&(t.pattern={type:r,fg:a}),u()},{label:"Pattern color",named:!0}),n("div",{class:"dlg-label",textContent:s("Pattern style:")}),x),n("div",{class:"fc-fill-low"},n("div",{class:"dlg-label",textContent:s("Sample")}),c))}function yt(e,t){return D(),n("div",{class:"fc-protect"},n("p",{class:"fc-hint",textContent:s("To lock cells or hide formulas, protect the worksheet. On the Review tab, click Protect Sheet.")}),E(w("protect","Locked"),e.unlocked!==!0,l=>{t.unlocked=l?void 0:!0}),E(w("protect","Hidden"),e.hiddenFormula===!0,l=>{t.hiddenFormula=l?!0:void 0}),E("Allow editing in the cell",e.ext?.noEdit!==!0,l=>{t.ext={noEdit:l?null:!0}}))}export{mt as alignmentTab,ht as fillTab,xt as fontTab,yt as protectionTab};
|
|
1
|
+
import{el as n}from"../ui/dialogs.js";import{PATTERN_LABELS as te,patternFill as _}from"../render/patterns.js";import{gradientCss as ne}from"./paint.js";import{ensureStyles as z,numberField as q,paletteButton as H,popButton as le,popOver as ie,svgNode as oe}from"./format-tabs.js";import{t as s,tc as F}from"../i18n/index.js";const D=(t,e,i,c,d="dlg-input")=>{const r=n("select",{class:d,"aria-label":s(c)});for(const[p,m]of t)r.append(n("option",{value:m,textContent:p}));return r.value=e??"",r.addEventListener("change",()=>i(r.value)),r},E=(t,e,i)=>{const c=n("input",{type:"checkbox",checked:e,on:{change:()=>i(c.checked)}}),d=n("label",{class:"dlg-row dlg-check"},c,s(t));return d.input=c,d},se=[["General",""],["Left (Indent)","left"],["Center","center"],["Right (Indent)","right"],["Fill","fill"],["Justify","justify"],["Center Across Selection","centerContinuous"],["Distributed (Indent)","distributed"]],re=[["Top","top"],["Center","center"],["Bottom",""],["Justify","justify"],["Distributed","distributed"]],Y=new Set(["left","right","distributed"]),Z=t=>t.map(([e,i])=>[F("align",e),i]),X=t=>t.replace(/[&<>"]/g,e=>`&#${e.charCodeAt(0)};`),C={cx:7.5,cy:75,radius:69},ae=(t,e=C.radius)=>[C.cx+e*Math.cos(t*Math.PI/180),C.cy-e*Math.sin(t*Math.PI/180)],K=(t,e,i)=>`M${t} ${e-i}L${t+i} ${e}L${t} ${e+i}L${t-i} ${e}Z`;function ce(){let t="";for(let e=-90;e<=90;e+=15){const[i,c]=ae(e);t+=e%45===0?`<path d="${K(i,c,3)}" fill="#222"/>`:`<circle cx="${i}" cy="${c}" r="0.9" fill="#555"/>`}return`<svg class="fc-dial" viewBox="0 0 91 150" role="slider" aria-label="${X(s("Orientation"))}" aria-valuemin="-90" aria-valuemax="90" tabindex="0">${t}
|
|
2
|
+
<g data-hand><text x="10" y="79.5" font-size="13" fill="#000">${X(s("Text"))}</text><line x1="39" y1="75" x2="72" y2="75" stroke="#777" stroke-width="1"/></g>
|
|
3
|
+
<path data-mark d="${K(C.cx+C.radius,C.cy,3.4)}" fill="#8c1d2f"/></svg>`}function he(t,e,i,c){z();let d=t.hAlign??"",r=t.rotation===255,p=t.rotation>90&&t.rotation<=180?90-t.rotation:t.rotation===255?0:t.rotation;const m=n("div",{class:"dlg-label",textContent:s("Indent:")}),g=q({value:t.indent,min:0,max:250,label:F("fc","Indent"),onInput:l=>{e.indent=Math.max(0,l||0)}}),w=()=>{const l=Y.has(d)||Number(g.input.value)>0;g.setDisabled(!l),m.classList.toggle("fc-off",!l)},x=E("Justify distributed",t.justifyLastLine===!0,l=>{e.justifyLastLine=l||void 0}),N=()=>{const l=d==="distributed";x.input.disabled=!l},A=D(Z(se),t.hAlign,l=>{d=l,e.hAlign=l||null,!Y.has(l)&&Number(g.input.value)>0&&(g.set(0),e.indent=0),l!=="distributed"&&x.input.checked&&(x.input.checked=!1,e.justifyLastLine=void 0),w(),N()},"Horizontal alignment"),f=q({value:p,min:-90,max:90,label:"Degrees",onInput:l=>I(Math.max(-90,Math.min(90,l||0)),!1)}),u=oe(ce()),S=u.querySelector("[data-hand]"),b=u.querySelector("[data-mark]"),a=n("button",{type:"button",class:"fc-vert","aria-label":s("Vertical text"),title:s("Vertical text"),"aria-pressed":String(r)},...[...s("Text")].map(l=>n("span",{textContent:l}))),h=()=>{S.setAttribute("transform",`rotate(${-p} ${C.cx} ${C.cy})`),b.setAttribute("transform",`rotate(${-p} ${C.cx} ${C.cy})`),S.style.opacity=r?"0.3":"1",b.style.display=r?"none":"",u.setAttribute("aria-valuenow",String(p)),a.setAttribute("aria-pressed",String(r))},I=(l,y=!0)=>{p=l,r=!1,e.rotation=l<0?90-l:l,y&&f.set(l),h()};a.addEventListener("click",()=>{r=!r,p=0,f.set(0),e.rotation=r?255:0,h()});const M=l=>{const y=u.getBoundingClientRect(),B=(l.clientX-y.left)*(91/y.width)-C.cx,T=C.cy-(l.clientY-y.top)*(150/y.height);let L=B<=0?Math.sign(T)*90:Math.round(Math.atan2(T,B)*180/Math.PI);const R=Math.round(L/15)*15;Math.abs(R-L)<=2&&(L=R),I(L===0?0:L)};return u.addEventListener("pointerdown",l=>{l.preventDefault(),u.setPointerCapture(l.pointerId),u.focus(),M(l)}),u.addEventListener("pointermove",l=>{u.hasPointerCapture(l.pointerId)&&M(l)}),u.addEventListener("keydown",l=>{const y={ArrowUp:1,ArrowRight:1,ArrowDown:-1,ArrowLeft:-1}[l.key];y&&(l.preventDefault(),I(Math.max(-90,Math.min(90,p+y))))}),w(),N(),h(),n("div",{class:"fc-align fc-bleed"},n("div",{class:"fc-align-left"},n("div",{class:"fc-align-grid"},n("div",{},n("div",{class:"dlg-label",textContent:s("Horizontal alignment:")}),A),n("div",{},m,g.node),n("div",{},n("div",{class:"dlg-label",textContent:s("Vertical alignment:")}),D(Z(re),t.vAlign,l=>{e.vAlign=l||null},"Vertical alignment"))),x),n("div",{class:"fc-align-right"},n("div",{class:"dlg-label",textContent:s("Orientation:")}),n("div",{class:"fc-orient"},a,u),n("div",{class:"fc-degrees"},n("span",{textContent:s("Degrees:")}),f.node)),n("div",{class:"fc-align-low"},n("div",{class:"dlg-label",textContent:s("Text control:")}),E("Wrap text",t.wrap,l=>{e.wrap=l}),E("Shrink to fit",t.shrink,l=>{e.shrink=l}),E("Merge cells",i,c),n("div",{class:"fc-textdir"},n("span",{textContent:s("Text direction:")}),D([[s("Context"),"0"],[s("Left-to-Right"),"1"],[s("Right-to-Left"),"2"]],String(t.readingOrder??0),l=>{e.readingOrder=Number(l)||void 0},"Text direction"))))}const de=["Aptos Narrow","Aptos","Arial","Calibri","Cambria","Consolas","Courier New","Georgia","Helvetica Neue","Menlo","Tahoma","Times New Roman","Trebuchet MS","Verdana"],Q=["Regular","Italic","Bold","Bold Italic"],ue=[8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72];function j(t,e,i={}){const c=n("input",{class:"dlg-input",spellcheck:!1,"aria-label":s(e),...i}),d=n("select",{class:"dlg-list",size:6,"aria-label":s("{name} list",{name:s(e)})});return{node:n("div",{class:"fc-combo"},n("label",{class:"fc-combo-head"},n("span",{textContent:s(t)}),c),d),input:c,list:d}}const G=(t,e,i=c=>c)=>{for(const c of e)t.append(n("option",{value:c,textContent:i(c)}))},P=t=>{const e=t.options[t.selectedIndex];if(!e)return;const i=e.offsetTop-t.options[0].offsetTop+e.offsetHeight;t.scrollTop=i>t.clientHeight?i-t.clientHeight+e.offsetHeight:0},J=(t,e)=>t&&e?"Bold Italic":t?"Bold":e?"Italic":"Regular",O=t=>F("fontstyle",t);function xe(t,e,i,c,d){z();const r=o=>i[o]!==void 0?i[o]:t[o],p=e.fontName,m=[...de];m.includes(t.fontName)||m.unshift(t.fontName);const g=o=>s("{name} (Body)",{name:o}),w=o=>s("{name} (Headings)",{name:o}),x=o=>o===p?g(o):o,N=[g(""),w("")].filter(Boolean),A=o=>{const v=o.trim(),k=N.find($=>v.endsWith($));return k?v.slice(0,v.length-k.length).trim():v},f=[];c&&f.push(w(c)),f.push(g(p),...m);const u=n("div",{class:"fc-preview","aria-label":s("Preview")});let S=null;const b=()=>{const o=r("vertAlign"),v=Number(r("underline")??0);u.style.font=`${r("italic")?"italic ":""}${r("bold")?"bold ":""}${Math.min(r("fontSize"),36)}px "${r("fontName")}", sans-serif`,u.style.color=r("color")??"#000000",u.style.textDecoration=[v?"underline":"",r("strike")?"line-through":""].filter(Boolean).join(" "),u.style.textDecorationStyle=v===2||v===4?"double":"solid",u.replaceChildren(o?n(o==="superscript"?"sup":"sub",{textContent:r("fontName")}):document.createTextNode(r("fontName"))),S.checked=["fontName","fontSize","bold","italic","strike","color"].every(k=>(r(k)??null)===(e[k]??null))&&v===Number(e.underline??0)&&!o},a=j("Font:","Font");G(a.list,f),a.input.value=x(t.fontName),a.list.value=x(t.fontName),a.list.addEventListener("change",()=>{a.input.value=a.list.value,i.fontName=A(a.list.value),b()}),a.input.addEventListener("input",()=>{const o=A(a.input.value);if(o==="")return;i.fontName=o;const v=a.input.value.trim().toLowerCase(),k=f.find($=>$.toLowerCase().startsWith(v));k?(a.list.value=k,P(a.list)):a.list.selectedIndex=-1,b()}),a.input.addEventListener("change",()=>{a.input.value=x(A(a.input.value)||r("fontName"))});const h=j("Font style:","Font style");G(h.list,Q,O);const I=o=>{h.input.value=O(o),h.list.value=o};I(J(t.bold,t.italic));const M=o=>{i.bold=o.includes("Bold"),i.italic=o.includes("Italic"),b()};h.list.addEventListener("change",()=>{h.input.value=O(h.list.value),M(h.list.value)}),h.input.addEventListener("input",()=>{const o=h.input.value.trim().toLowerCase(),v=Q.find(k=>O(k).toLowerCase()===o);v&&(h.list.value=v,M(v))}),h.input.addEventListener("change",()=>I(J(r("bold"),r("italic"))));const l=j("Size:","Size",{type:"number",min:1,max:409,step:"any"});G(l.list,ue.map(String));const y=o=>{l.input.value=String(o),l.list.value=String(o)};y(t.fontSize),l.list.addEventListener("change",()=>{l.input.value=l.list.value,i.fontSize=Number(l.list.value),b()}),l.input.addEventListener("input",()=>{const o=Number(l.input.value);o>0&&(i.fontSize=o,l.list.value=String(o),b())});const B=D([[s("None"),"0"],[F("underline","Single"),"1"],[F("underline","Double"),"2"],[F("underline","Single Accounting"),"3"],[F("underline","Double Accounting"),"4"]],String(t.underline),o=>{i.underline=Number(o),b()},"Underline"),T=(o,v,k)=>{const $=n("input",{type:"checkbox",checked:v,"aria-label":s(o),on:{change:()=>{k($.checked),b()}}});return{i:$,row:n("label",{class:"dlg-row dlg-check"},$,s(o))}},L=T("Strikethrough",t.strike,o=>{i.strike=o}),R=T("Superscript",t.vertAlign==="superscript",o=>{i.vertAlign=o?"superscript":null,o&&(V.i.checked=!1)}),V=T("Subscript",t.vertAlign==="subscript",o=>{i.vertAlign=o?"subscript":null,o&&(R.i.checked=!1)}),U=H(t.color,"#000000",(o,v)=>{i.color=o,(i.themeRefs??={}).color=v,b()},{label:"Font color",theme:d});S=n("input",{type:"checkbox","aria-label":s("Normal font"),on:{change:()=>{if(!S.checked){b();return}Object.assign(i,{fontName:e.fontName,fontSize:e.fontSize,bold:e.bold,italic:e.italic,strike:e.strike,underline:e.underline??0,color:e.color??null,vertAlign:null}),a.input.value=x(e.fontName),a.list.value=x(e.fontName),y(e.fontSize),I(J(e.bold,e.italic)),B.value=String(e.underline??0),L.i.checked=e.strike,R.i.checked=!1,V.i.checked=!1,i.themeRefs&&delete i.themeRefs.color,U.setValue(e.color??null),P(a.list),P(l.list),b()}}});const W=n("div",{class:"fc-font fc-bleed"},n("div",{class:"fc-font-top"},a.node,h.node,l.node,n("div",{class:"fc-font-cell"},n("div",{class:"dlg-label",textContent:s("Underline:")}),B),n("div",{class:"fc-font-cell"},n("div",{class:"dlg-label",textContent:s("Color:")}),U),n("div",{class:"fc-font-cell fc-font-normal"},n("label",{class:"dlg-row dlg-check"},S,s("Normal font")))),n("div",{class:"fc-font-low"},n("div",{},n("div",{class:"dlg-label",textContent:s("Effects:")}),L.row,R.row,V.row),n("div",{},n("div",{class:"dlg-label",textContent:s("Preview")}),u)));return W.onShow=()=>[a.list,h.list,l.list].forEach(P),b(),W}function ee(t){const e=document.createElement("canvas");if(e.width=32,e.height=20,t){const i=e.getContext("2d");i.fillStyle=_(i,{type:t,fg:"#000000"},1)??"#FFFFFF",i.fillRect(0,0,32,20)}return e}function fe(t,e){const i=n("span",{class:"fc-pat-chip"}),c=le("Pattern style",i),d=()=>i.replaceChildren(...t?[ee(t)]:[]);return d(),c.setValue=r=>{t=r,d()},ie(c,"Pattern style list",r=>{const p=n("div",{class:"fc-pat-grid"});for(const[m,g]of te)p.append(n("button",{type:"button",title:F("pattern",m),"aria-label":F("pattern",m),"aria-pressed":String(g===t),on:{click:()=>{t=g,d(),r(),e(g)}}},ee(g)));return p}),c}function ye(t,e,i,c){z();let d=t.pattern?.type??"",r=t.pattern?.fg??"#000000",p=t.themeRefs?.patternFg;const m=n("div",{class:"fc-sample","aria-label":s("Sample")}),g=()=>{const f=e.fill!==void 0?e.fill:t.fill,u=e.gradient!==void 0?e.gradient:t.gradient,S=e.pattern!==void 0?e.pattern:t.pattern;if(m.style.backgroundColor=f??(u||S?"#FFFFFF":"transparent"),m.style.backgroundImage="none",u)m.style.backgroundImage=ne(u);else if(S){const b=document.createElement("canvas");b.width=16,b.height=16;const a=b.getContext("2d");a.fillStyle=_(a,S,1)??"#FFFFFF",a.fillRect(0,0,16,16),m.style.backgroundImage=`url(${b.toDataURL()})`}},w=()=>{e.pattern=d?{type:d,fg:r}:null,d&&p?(e.themeRefs??={}).patternFg=p:e.themeRefs&&delete e.themeRefs.patternFg},x=fe(d,f=>{d=f,w(),f&&(e.gradient=null),f&&!t.fill&&!e.fill&&(e.fill="#FFFFFF"),g()}),N=H(t.fill??null,"#FFFFFF",(f,u)=>{(e.themeRefs??={}).fill=u,f===null?(e.fill=null,e.gradient=null,d="",w(),x.setValue("")):(e.fill=f,e.gradient=null),g()},{none:"No Color",label:"Background color",named:!0,theme:c}),A=n("button",{type:"button",class:"dlg-btn",textContent:s("Fill Effects…"),on:{click:()=>i(e.gradient??t.gradient,f=>{e.gradient=f,e.fill=f.stops[0].color,e.themeRefs&&delete e.themeRefs.fill,d="",w(),x.setValue(""),N.setValue(null),g()})}});return g(),n("div",{class:"fc-fill fc-bleed"},n("div",{class:"fc-fill-left"},n("div",{class:"dlg-label",textContent:s("Background color:")}),N,A),n("div",{class:"fc-fill-right"},n("div",{class:"dlg-label",textContent:s("Pattern color:")}),H(t.pattern?.fg??null,"#000000",(f,u)=>{p=u,r=f??"#000000",d&&w(),g()},{label:"Pattern color",named:!0,theme:c}),n("div",{class:"dlg-label",textContent:s("Pattern style:")}),x),n("div",{class:"fc-fill-low"},n("div",{class:"dlg-label",textContent:s("Sample")}),m))}function ke(t,e){return z(),n("div",{class:"fc-protect"},n("p",{class:"fc-hint",textContent:s("To lock cells or hide formulas, protect the worksheet. On the Review tab, click Protect Sheet.")}),E(F("protect","Locked"),t.unlocked!==!0,i=>{e.unlocked=i?void 0:!0}),E(F("protect","Hidden"),t.hiddenFormula===!0,i=>{e.hiddenFormula=i?!0:void 0}),E("Allow editing in the cell",t.ext?.noEdit!==!0,i=>{e.ext={noEdit:i?null:!0}}))}export{he as alignmentTab,ye as fillTab,xe as fontTab,ke as protectionTab};
|