@ishibashi0112/spreadsheet-grid-core 0.48.0 → 0.50.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/dist/controllers/autoHeightMeasurer.cjs +1 -1
- package/dist/controllers/autoHeightMeasurer.js +4 -2
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.d.ts +2 -1
- package/dist/controllers/clipboardController.js +67 -61
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +3 -0
- package/dist/controllers/columnAutosizeRunner.js +40 -24
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.js +5 -2
- package/dist/controllers/dateRolloverStore.cjs +1 -0
- package/dist/controllers/dateRolloverStore.d.ts +13 -0
- package/dist/controllers/dateRolloverStore.js +41 -0
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +2 -2
- package/dist/controllers/fillHandleController.cjs +1 -0
- package/dist/controllers/fillHandleController.d.ts +87 -0
- package/dist/controllers/fillHandleController.js +346 -0
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +55 -46
- package/dist/controllers/globalFilteredOrder.cjs +1 -1
- package/dist/controllers/globalFilteredOrder.js +5 -5
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +1 -0
- package/dist/controllers/historyController.js +8 -5
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.js +2 -2
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +2 -0
- package/dist/controllers/pointerInteractionsController.js +136 -132
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +104 -97
- package/dist/controllers/scrollSyncController.cjs +1 -1
- package/dist/controllers/scrollSyncController.d.ts +1 -0
- package/dist/controllers/scrollSyncController.js +32 -21
- package/dist/controllers/selectOptionsCollector.cjs +1 -1
- package/dist/controllers/selectOptionsCollector.js +5 -5
- package/dist/controllers/selectionAggregatesRunner.cjs +1 -0
- package/dist/controllers/selectionAggregatesRunner.d.ts +27 -0
- package/dist/controllers/selectionAggregatesRunner.js +65 -0
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.js +75 -69
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +44 -43
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +3 -2
- package/dist/controllers/viewportSyncController.js +6 -4
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.js +1 -1
- package/dist/engine/columnLayout.cjs +1 -1
- package/dist/engine/columnLayout.js +1 -1
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +4 -0
- package/dist/engine/createGridEngine.js +58 -54
- package/dist/engine/gridApi.cjs +1 -1
- package/dist/engine/gridApi.d.ts +6 -0
- package/dist/engine/gridApi.js +130 -119
- package/dist/engine/rowPipeline.cjs +1 -1
- package/dist/engine/rowPipeline.d.ts +2 -0
- package/dist/engine/rowPipeline.js +67 -35
- package/dist/logic/aggregation.cjs +1 -1
- package/dist/logic/aggregation.d.ts +1 -0
- package/dist/logic/aggregation.js +16 -7
- package/dist/logic/autoScrollGeometry.cjs +1 -1
- package/dist/logic/autoScrollGeometry.d.ts +1 -0
- package/dist/logic/autoScrollGeometry.js +3 -3
- package/dist/logic/clearCells.cjs +1 -1
- package/dist/logic/clearCells.d.ts +1 -1
- package/dist/logic/clearCells.js +7 -7
- package/dist/logic/columnAutosize.cjs +1 -1
- package/dist/logic/columnAutosize.d.ts +6 -0
- package/dist/logic/columnAutosize.js +60 -39
- package/dist/logic/columnFlex.cjs +1 -1
- package/dist/logic/columnFlex.js +20 -22
- package/dist/logic/exportCsv.cjs +2 -2
- package/dist/logic/exportCsv.d.ts +5 -1
- package/dist/logic/exportCsv.js +16 -15
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +2 -1
- package/dist/logic/exportData.js +27 -21
- package/dist/logic/fillHandle.cjs +1 -0
- package/dist/logic/fillHandle.d.ts +69 -0
- package/dist/logic/fillHandle.js +254 -0
- package/dist/logic/fillSeries.cjs +1 -0
- package/dist/logic/fillSeries.d.ts +11 -0
- package/dist/logic/fillSeries.js +239 -0
- package/dist/logic/filtering.cjs +1 -1
- package/dist/logic/filtering.d.ts +2 -0
- package/dist/logic/filtering.js +50 -37
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +1 -0
- package/dist/logic/gridState.js +2 -2
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +2 -2
- package/dist/logic/labelRows.cjs +1 -1
- package/dist/logic/labelRows.js +1 -1
- package/dist/logic/selectOptions.cjs +1 -1
- package/dist/logic/selectOptions.js +1 -1
- package/dist/logic/selectionAggregates.cjs +1 -0
- package/dist/logic/selectionAggregates.d.ts +25 -0
- package/dist/logic/selectionAggregates.js +74 -0
- package/dist/logic/sorting.cjs +1 -1
- package/dist/logic/sorting.d.ts +18 -0
- package/dist/logic/sorting.js +133 -64
- package/dist/logic/totalRow.cjs +1 -0
- package/dist/logic/totalRow.d.ts +25 -0
- package/dist/logic/totalRow.js +90 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +73 -68
- package/dist/model/gridTypes.core.d.ts +204 -17
- package/dist/model/gridTypes.unbound.d.ts +4 -0
- package/dist/utils/clipboard.cjs +1 -1
- package/dist/utils/clipboard.d.ts +1 -1
- package/dist/utils/clipboard.js +9 -9
- package/dist/utils/permissions.cjs +1 -1
- package/dist/utils/permissions.d.ts +6 -2
- package/dist/utils/permissions.js +8 -2
- package/package.json +1 -1
package/dist/logic/exportCsv.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { getCellValue as e } from "../utils/permissions.js";
|
|
2
2
|
//#region src/logic/exportCsv.ts
|
|
3
|
-
var t = (e, t) => e.includes(t) || e.includes("\"") || e.includes("\n") || e.includes("\r") ? `"${e.replace(/"/g, "\"\"")}"` : e, n = (t, n) => {
|
|
3
|
+
var t = (e, t) => e.includes(t) || e.includes("\"") || e.includes("\n") || e.includes("\r") ? `"${e.replace(/"/g, "\"\"")}"` : e, n = /^[=+\-@\t\r]/, r = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i, i = (e) => n.test(e) && !r.test(e) ? `'${e}` : e, a = (t, n) => {
|
|
4
4
|
let r = e(t, n);
|
|
5
5
|
return n.formatClipboardValue ? n.formatClipboardValue(r, t) : String(r ?? "");
|
|
6
|
-
},
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
for (let
|
|
10
|
-
let
|
|
11
|
-
if (!
|
|
12
|
-
let e =
|
|
13
|
-
e &&
|
|
6
|
+
}, o = (e) => e == null ? "" : String(e), s = (e) => e == null ? "" : String(e), c = ({ getRow: e, startRow: n, endRow: r, columns: c, delimiter: l = ",", includeHeaders: u = !0, bom: d = !1, escapeFormulas: f = !1, isRowIncluded: p, getLabelLine: m, totalLine: h }) => {
|
|
7
|
+
let g = [], _ = (e) => t(f ? i(e) : e, l);
|
|
8
|
+
u && g.push(c.map((e) => t(e.title || e.key, l)).join(l));
|
|
9
|
+
for (let t = n; t < r; t += 1) {
|
|
10
|
+
let n = e(t);
|
|
11
|
+
if (!n) {
|
|
12
|
+
let e = m?.(t);
|
|
13
|
+
e && g.push(c.map((t, n) => _(o(e[n]))).join(l));
|
|
14
14
|
continue;
|
|
15
15
|
}
|
|
16
|
-
if (
|
|
17
|
-
let
|
|
18
|
-
|
|
16
|
+
if (p && !p(n, t)) continue;
|
|
17
|
+
let r = c.map((e) => _(a(n, e)));
|
|
18
|
+
g.push(r.join(l));
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
h && g.push(c.map((e, t) => _(s(h[t]))).join(l));
|
|
21
|
+
let v = g.join("\r\n");
|
|
22
|
+
return d ? `\uFEFF${v}` : v;
|
|
22
23
|
};
|
|
23
24
|
//#endregion
|
|
24
|
-
export {
|
|
25
|
+
export { i as escapeCsvFormula, o as labelExportCellText, c as serializeRowsToCsv, s as totalExportCellText };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./exportCsv.cjs");var n=({getRow:n,startRow:r,endRow:i,columns:a,isRowIncluded:o,getLabelLine:s})=>{let
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./exportCsv.cjs");var n=({getRow:n,startRow:r,endRow:i,columns:a,isRowIncluded:o,getLabelLine:s,totalLine:c})=>{let l=a.map(e=>({key:e.key,title:e.title||e.key})),u=[],d=s||c?[]:void 0;for(let c=r;c<i;c+=1){let r=n(c);if(!r){let e=s?.(c);e&&(u.push(a.map((n,r)=>{let i=e[r];return{value:i??null,text:t.labelExportCellText(i)}})),d?.push(`label`));continue}o&&!o(r,c)||(d?.push(`data`),u.push(a.map(t=>{let n=e.getCellValue(r,t);return{value:n,text:t.formatClipboardValue?t.formatClipboardValue(n,r):String(n??``)}})))}return c&&(u.push(a.map((e,n)=>{let r=c[n];return{value:r??null,text:t.totalExportCellText(r)}})),d?.push(`total`)),d?{columns:l,rows:u,rowKinds:d}:{columns:l,rows:u}};exports.buildGridExportData=n;
|
|
@@ -7,5 +7,6 @@ export type BuildGridExportDataParams<T> = {
|
|
|
7
7
|
columns: GridColumn<T>[];
|
|
8
8
|
isRowIncluded?: (row: T, rowIndex: number) => boolean;
|
|
9
9
|
getLabelLine?: (rowIndex: number) => LabelExportLine | undefined;
|
|
10
|
+
totalLine?: ReadonlyArray<unknown>;
|
|
10
11
|
};
|
|
11
|
-
export declare const buildGridExportData: <T>({ getRow, startRow, endRow, columns, isRowIncluded, getLabelLine, }: BuildGridExportDataParams<T>) => GridExportData;
|
|
12
|
+
export declare const buildGridExportData: <T>({ getRow, startRow, endRow, columns, isRowIncluded, getLabelLine, totalLine, }: BuildGridExportDataParams<T>) => GridExportData;
|
package/dist/logic/exportData.js
CHANGED
|
@@ -1,40 +1,46 @@
|
|
|
1
1
|
import { getCellValue as e } from "../utils/permissions.js";
|
|
2
|
-
import { labelExportCellText as t } from "./exportCsv.js";
|
|
2
|
+
import { labelExportCellText as t, totalExportCellText as n } from "./exportCsv.js";
|
|
3
3
|
//#region src/logic/exportData.ts
|
|
4
|
-
var
|
|
5
|
-
let
|
|
4
|
+
var r = ({ getRow: r, startRow: i, endRow: a, columns: o, isRowIncluded: s, getLabelLine: c, totalLine: l }) => {
|
|
5
|
+
let u = o.map((e) => ({
|
|
6
6
|
key: e.key,
|
|
7
|
-
title: e.title
|
|
8
|
-
})),
|
|
9
|
-
for (let
|
|
10
|
-
let
|
|
11
|
-
if (!
|
|
12
|
-
let e =
|
|
13
|
-
e && (
|
|
7
|
+
title: e.title || e.key
|
|
8
|
+
})), d = [], f = c || l ? [] : void 0;
|
|
9
|
+
for (let n = i; n < a; n += 1) {
|
|
10
|
+
let i = r(n);
|
|
11
|
+
if (!i) {
|
|
12
|
+
let e = c?.(n);
|
|
13
|
+
e && (d.push(o.map((n, r) => {
|
|
14
14
|
let i = e[r];
|
|
15
15
|
return {
|
|
16
16
|
value: i ?? null,
|
|
17
17
|
text: t(i)
|
|
18
18
|
};
|
|
19
|
-
})),
|
|
19
|
+
})), f?.push("label"));
|
|
20
20
|
continue;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
let n = e(
|
|
22
|
+
s && !s(i, n) || (f?.push("data"), d.push(o.map((t) => {
|
|
23
|
+
let n = e(i, t);
|
|
24
24
|
return {
|
|
25
25
|
value: n,
|
|
26
|
-
text: t.formatClipboardValue ? t.formatClipboardValue(n,
|
|
26
|
+
text: t.formatClipboardValue ? t.formatClipboardValue(n, i) : String(n ?? "")
|
|
27
27
|
};
|
|
28
28
|
})));
|
|
29
29
|
}
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
return l && (d.push(o.map((e, t) => {
|
|
31
|
+
let r = l[t];
|
|
32
|
+
return {
|
|
33
|
+
value: r ?? null,
|
|
34
|
+
text: n(r)
|
|
35
|
+
};
|
|
36
|
+
})), f?.push("total")), f ? {
|
|
37
|
+
columns: u,
|
|
38
|
+
rows: d,
|
|
39
|
+
rowKinds: f
|
|
34
40
|
} : {
|
|
35
|
-
columns:
|
|
36
|
-
rows:
|
|
41
|
+
columns: u,
|
|
42
|
+
rows: d
|
|
37
43
|
};
|
|
38
44
|
};
|
|
39
45
|
//#endregion
|
|
40
|
-
export {
|
|
46
|
+
export { r as buildGridExportData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./detailRow.cjs"),n=require("./geometry.cjs"),r=require("./validation.cjs"),i=require("./fillSeries.cjs");var a=(e,t,n,r)=>{let i;if(e?.type===`cell`){let{start:t,end:n}=e.range;i={startRow:Math.min(t.row,n.row),endRow:Math.max(t.row,n.row),startCol:Math.min(t.col,n.col),endCol:Math.max(t.col,n.col)}}else if(e===null&&t)i={startRow:t.row,endRow:t.row,startCol:t.col,endCol:t.col};else return null;return i.startRow<0||i.endRow>=n||i.startCol<0||i.endCol>=r?null:i},o=(e,t)=>({startRow:Math.min(e.startRow,t.range.startRow),endRow:Math.max(e.endRow,t.range.endRow),startCol:Math.min(e.startCol,t.range.startCol),endCol:Math.max(e.endCol,t.range.endCol)}),s=(e,t)=>e.startRow===t.startRow&&e.endRow===t.endRow&&e.startCol===t.startCol&&e.endCol===t.endCol,c=e=>{let n=-1,r=-1;return e.forEach((e,i)=>{t.isSyntheticColumnKey(e.key)||(n===-1&&(n=i),r=i)}),n===-1?null:{first:n,last:r}},l=(e,t,n,r)=>{if(n<=0)return null;let i=Math.min(Math.max(t.row,0),n-1),a=Math.min(Math.max(t.col,r.first),r.last),o=i-e.endRow,s=e.startRow-i,c=a-e.endCol,l=e.startCol-a,u=Math.max(o,s,0),d=Math.max(c,l,0);return u===0&&d===0?null:u>=d?o>0?{direction:`down`,range:{startRow:e.endRow+1,endRow:i,startCol:e.startCol,endCol:e.endCol}}:{direction:`up`,range:{startRow:i,endRow:e.startRow-1,startCol:e.startCol,endCol:e.endCol}}:c>0?{direction:`right`,range:{startRow:e.startRow,endRow:e.endRow,startCol:e.endCol+1,endCol:a}}:{direction:`left`,range:{startRow:e.startRow,endRow:e.endRow,startCol:a,endCol:e.startCol-1}}},u=(e,t)=>e.getLabelRow?.(t)!==void 0||e.getGroupRow?.(t)!==void 0,d=e=>e!=null&&e!==``,f=(e,n,r)=>{let i=!1;for(let n=e.startCol;n<=e.endCol;n+=1){let e=r[n];if(e!==void 0&&!t.isSyntheticColumnKey(e.key)){i=!0;break}}if(!i)return!1;for(let t=e.startRow;t<=e.endRow;t+=1)if(!u(n,t))return!0;return!1},p=(n,r,i)=>{let a=r.getRowCount(),o=n.endRow+1;if(o>=a)return null;let s=e=>u(r,e)?void 0:r.getRow(e),c=(e,n)=>{for(let r=e;r>=0&&r<i.length;r+=n)if(!t.isSyntheticColumnKey(i[r].key))return r;return-1},l=i.slice(n.startCol,n.endCol+1).filter(e=>!t.isSyntheticColumnKey(e.key));if(l.length===0)return null;for(let t of[c(n.startCol-1,-1),c(n.endCol+1,1)]){if(t===-1)continue;let r=i[t],c=n.endRow;for(let t=o;t<a;t+=1){let n=s(t);if(n===void 0||!d(e.getCellValue(n,r))||l.some(t=>d(e.getCellValue(n,t))))break;c=t}if(c>n.endRow)return{direction:`down`,range:{startRow:o,endRow:c,startCol:n.startCol,endCol:n.endCol}}}return null},m=(e,t,n,r)=>{let i=[];for(let a=e;n===1?a<=t:a>=t;a+=n)r(a)&&i.push(a);return i},h=({rowModel:n,columns:a,source:o,target:s,request:c,canWriteCell:l,getFillValue:d})=>{let f=[],p=`copy`,h=!1,{direction:g,range:_}=s,v=g===`down`||g===`up`,y=g===`down`||g===`right`,b=(e,t,n)=>{if(e.length===0||t.length===0)return;let a=i.analyzeFillLine(e,{backward:!y}),o=i.resolveFillLineKind(a,c);a.series!==null&&(h=!0),o===`series`&&(p=`series`);let s=i.createFillLineValues(e,a,o);t.forEach((t,i)=>{let{viewIndex:a,colIndex:c,row:u,column:p}=n(t);if(u===void 0||!l(a,c,u,p))return;let m=s(i),h=d?d({column:p,row:u,rowIndex:a,sourceValues:e,index:i,direction:g,kind:o,defaultValue:m}):m;r.decideCellWrite(p,u,h).action!==`reject`&&f.push({viewIndex:a,column:p,value:h})})};if(v){let r=e=>!u(n,e),i=y?m(o.startRow,o.endRow,1,r):m(o.endRow,o.startRow,-1,r),s=y?m(_.startRow,_.endRow,1,r):m(_.endRow,_.startRow,-1,r);for(let r=o.startCol;r<=o.endCol;r+=1){let o=a[r];if(!o||t.isSyntheticColumnKey(o.key))continue;let c=[],l=!0;for(let t of i){let r=n.getRow(t);if(r===void 0){l=!1;break}c.push(e.getCellValue(r,o))}l&&b(c,s,e=>({viewIndex:e,colIndex:r,row:n.getRow(e),column:o}))}}else{let r=e=>{let n=a[e];return n!==void 0&&!t.isSyntheticColumnKey(n.key)},i=y?m(o.startCol,o.endCol,1,r):m(o.endCol,o.startCol,-1,r),s=y?m(_.startCol,_.endCol,1,r):m(_.endCol,_.startCol,-1,r);for(let t=o.startRow;t<=o.endRow;t+=1){if(u(n,t))continue;let r=n.getRow(t);r!==void 0&&b(i.map(t=>e.getCellValue(r,a[t])),s,e=>({viewIndex:t,colIndex:e,row:r,column:a[e]}))}}return{edits:f,kind:p,seriesAvailable:h}},g=({rowModel:n,columns:r,source:a,target:o,request:s,canWriteCell:c,getFillValue:l})=>{let{direction:d,range:f}=o,p=d===`down`||d===`up`,h=d===`down`||d===`right`,g,_,v,y,b,x=!1,S;if(p){let i=m(a.startCol,a.endCol,1,e=>{let n=r[e];return n!==void 0&&!t.isSyntheticColumnKey(n.key)})[0];if(i===void 0)return null;v=i,_=r[v];let o=e=>!u(n,e),s=h?m(a.startRow,a.endRow,1,o):m(a.endRow,a.startRow,-1,o),c=h?m(f.startRow,f.endRow,1,o):m(f.endRow,f.startRow,-1,o);if(s.length===0||c.length===0)return null;g=[];let l;for(let t of s){if(l=n.getRow(t),l===void 0)return null;g.push(e.getCellValue(l,_))}S=c.length-1,y=c[S],b=n.getRow(y),x=b===void 0,b??=l}else{let i=m(a.startRow,a.endRow,1,e=>!u(n,e))[0];if(i===void 0)return null;let o=n.getRow(i);if(o===void 0)return null;let s=e=>{let n=r[e];return n!==void 0&&!t.isSyntheticColumnKey(n.key)},c=h?m(a.startCol,a.endCol,1,s):m(a.endCol,a.startCol,-1,s),l=h?m(f.startCol,f.endCol,1,s):m(f.endCol,f.startCol,-1,s);if(c.length===0||l.length===0)return null;g=c.map(t=>e.getCellValue(o,r[t])),S=l.length-1,v=l[S],_=r[v],y=i,b=o}let C=i.analyzeFillLine(g,{backward:!h}),w=i.resolveFillLineKind(C,s),T=i.createFillLineValues(g,C,w)(S),E=l&&b!==void 0&&!x&&(c===void 0||c(y,v,b,_))?l({column:_,row:b,rowIndex:y,sourceValues:g,index:S,direction:d,kind:w,defaultValue:T}):T;return{column:_,row:b,value:E}},_=(t,n,r)=>{if(r.length===0)return t;let i=[...t];for(let{viewIndex:t,column:a,value:o}of r){let r=n.getSourceIndex(t);if(r===void 0)continue;let s=i[r];s!==void 0&&(i[r]=e.setCellValue(s,a,o))}return i},v=(e,t,r,i,a)=>{if(e.endRow<i||e.endRow>a)return null;let o=n.computeSinglePaneColumnExtent(t,e.endCol);return o?{pane:o.pane,x:o.extent.end,y:r.rowTop(e.endRow)+r.cellHeight(e.endRow),paneWidth:t[o.pane].totalWidth}:null},y=36,b=22,x=4,S=(e,t,n=1/0)=>({x:e.x+x+36<=e.paneWidth?e.x+x:Math.max(e.x-36-x,0),y:e.y+x+22<=Math.min(t,n)?e.y+x:Math.max(e.y-22-x,0)});exports.FILL_OPTIONS_CHIP_HEIGHT=b,exports.FILL_OPTIONS_CHIP_WIDTH=y,exports.applyFillEditsToRows=_,exports.buildFillEdits=h,exports.hasFillableSource=f,exports.isSameFillRange=s,exports.previewFillValue=g,exports.resolveFillColumnBounds=c,exports.resolveFillCornerPlacement=v,exports.resolveFillDoubleClickTarget=p,exports.resolveFillOptionsChipPosition=S,exports.resolveFillSource=a,exports.resolveFillTarget=l,exports.unionFillRange=o;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { CellCoord, GridColumn, GridFillDirection, GridFillKind, GridFillValueParams, GridSelection, RowModel } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import { type ColumnPane, type GridPaneLayout } from './geometry.js';
|
|
3
|
+
import type { RowMetrics } from './verticalGeometry.js';
|
|
4
|
+
import { type FillRequest } from './fillSeries.js';
|
|
5
|
+
export type FillRange = {
|
|
6
|
+
startRow: number;
|
|
7
|
+
endRow: number;
|
|
8
|
+
startCol: number;
|
|
9
|
+
endCol: number;
|
|
10
|
+
};
|
|
11
|
+
export type FillTarget = {
|
|
12
|
+
direction: GridFillDirection;
|
|
13
|
+
range: FillRange;
|
|
14
|
+
};
|
|
15
|
+
export type FillCellEdit<T> = {
|
|
16
|
+
viewIndex: number;
|
|
17
|
+
column: GridColumn<T>;
|
|
18
|
+
value: unknown;
|
|
19
|
+
};
|
|
20
|
+
export declare const resolveFillSource: (selection: GridSelection, activeCell: CellCoord | null, rowCount: number, columnCount: number) => FillRange | null;
|
|
21
|
+
export declare const unionFillRange: (source: FillRange, target: FillTarget) => FillRange;
|
|
22
|
+
export declare const isSameFillRange: (a: FillRange, b: FillRange) => boolean;
|
|
23
|
+
export declare const resolveFillColumnBounds: <T>(columns: readonly GridColumn<T>[]) => {
|
|
24
|
+
first: number;
|
|
25
|
+
last: number;
|
|
26
|
+
} | null;
|
|
27
|
+
export declare const resolveFillTarget: (source: FillRange, pointer: CellCoord, rowCount: number, columnBounds: {
|
|
28
|
+
first: number;
|
|
29
|
+
last: number;
|
|
30
|
+
}) => FillTarget | null;
|
|
31
|
+
export declare const hasFillableSource: <T>(source: FillRange, rowModel: RowModel<T>, columns: readonly GridColumn<T>[]) => boolean;
|
|
32
|
+
export declare const resolveFillDoubleClickTarget: <T>(source: FillRange, rowModel: RowModel<T>, columns: readonly GridColumn<T>[]) => FillTarget | null;
|
|
33
|
+
export type BuildFillEditsParams<T> = {
|
|
34
|
+
rowModel: RowModel<T>;
|
|
35
|
+
columns: readonly GridColumn<T>[];
|
|
36
|
+
source: FillRange;
|
|
37
|
+
target: FillTarget;
|
|
38
|
+
request: FillRequest;
|
|
39
|
+
canWriteCell: (viewIndex: number, colIndex: number, row: T, column: GridColumn<T>) => boolean;
|
|
40
|
+
getFillValue?: (params: GridFillValueParams<T>) => unknown;
|
|
41
|
+
};
|
|
42
|
+
export type FillEditsResult<T> = {
|
|
43
|
+
edits: FillCellEdit<T>[];
|
|
44
|
+
kind: GridFillKind;
|
|
45
|
+
seriesAvailable: boolean;
|
|
46
|
+
};
|
|
47
|
+
export declare const buildFillEdits: <T>({ rowModel, columns, source, target, request, canWriteCell, getFillValue, }: BuildFillEditsParams<T>) => FillEditsResult<T>;
|
|
48
|
+
export type FillPreview<T> = {
|
|
49
|
+
column: GridColumn<T>;
|
|
50
|
+
row: T | undefined;
|
|
51
|
+
value: unknown;
|
|
52
|
+
};
|
|
53
|
+
export declare const previewFillValue: <T>({ rowModel, columns, source, target, request, canWriteCell, getFillValue, }: Omit<BuildFillEditsParams<T>, "canWriteCell"> & {
|
|
54
|
+
canWriteCell?: BuildFillEditsParams<T>["canWriteCell"];
|
|
55
|
+
}) => FillPreview<T> | null;
|
|
56
|
+
export declare const applyFillEditsToRows: <T>(rows: readonly T[], rowModel: Pick<RowModel<T>, "getSourceIndex">, edits: readonly FillCellEdit<T>[]) => T[];
|
|
57
|
+
export type FillCornerPlacement = {
|
|
58
|
+
pane: ColumnPane;
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
paneWidth: number;
|
|
62
|
+
};
|
|
63
|
+
export declare const resolveFillCornerPlacement: <T>(range: FillRange, paneLayout: GridPaneLayout<T>, rowMetrics: Pick<RowMetrics, "rowTop" | "cellHeight">, windowFirstRow: number, windowLastRow: number) => FillCornerPlacement | null;
|
|
64
|
+
export declare const FILL_OPTIONS_CHIP_WIDTH = 36;
|
|
65
|
+
export declare const FILL_OPTIONS_CHIP_HEIGHT = 22;
|
|
66
|
+
export declare const resolveFillOptionsChipPosition: (corner: FillCornerPlacement, totalBodyHeight: number, visibleBottom?: number) => {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
};
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { getCellValue as e, setCellValue as t } from "../utils/permissions.js";
|
|
2
|
+
import { isSyntheticColumnKey as n } from "./detailRow.js";
|
|
3
|
+
import { computeSinglePaneColumnExtent as r } from "./geometry.js";
|
|
4
|
+
import { decideCellWrite as i } from "./validation.js";
|
|
5
|
+
import { analyzeFillLine as a, createFillLineValues as o, resolveFillLineKind as s } from "./fillSeries.js";
|
|
6
|
+
//#region src/logic/fillHandle.ts
|
|
7
|
+
var c = (e, t, n, r) => {
|
|
8
|
+
let i;
|
|
9
|
+
if (e?.type === "cell") {
|
|
10
|
+
let { start: t, end: n } = e.range;
|
|
11
|
+
i = {
|
|
12
|
+
startRow: Math.min(t.row, n.row),
|
|
13
|
+
endRow: Math.max(t.row, n.row),
|
|
14
|
+
startCol: Math.min(t.col, n.col),
|
|
15
|
+
endCol: Math.max(t.col, n.col)
|
|
16
|
+
};
|
|
17
|
+
} else if (e === null && t) i = {
|
|
18
|
+
startRow: t.row,
|
|
19
|
+
endRow: t.row,
|
|
20
|
+
startCol: t.col,
|
|
21
|
+
endCol: t.col
|
|
22
|
+
};
|
|
23
|
+
else return null;
|
|
24
|
+
return i.startRow < 0 || i.endRow >= n || i.startCol < 0 || i.endCol >= r ? null : i;
|
|
25
|
+
}, l = (e, t) => ({
|
|
26
|
+
startRow: Math.min(e.startRow, t.range.startRow),
|
|
27
|
+
endRow: Math.max(e.endRow, t.range.endRow),
|
|
28
|
+
startCol: Math.min(e.startCol, t.range.startCol),
|
|
29
|
+
endCol: Math.max(e.endCol, t.range.endCol)
|
|
30
|
+
}), u = (e, t) => e.startRow === t.startRow && e.endRow === t.endRow && e.startCol === t.startCol && e.endCol === t.endCol, d = (e) => {
|
|
31
|
+
let t = -1, r = -1;
|
|
32
|
+
return e.forEach((e, i) => {
|
|
33
|
+
n(e.key) || (t === -1 && (t = i), r = i);
|
|
34
|
+
}), t === -1 ? null : {
|
|
35
|
+
first: t,
|
|
36
|
+
last: r
|
|
37
|
+
};
|
|
38
|
+
}, f = (e, t, n, r) => {
|
|
39
|
+
if (n <= 0) return null;
|
|
40
|
+
let i = Math.min(Math.max(t.row, 0), n - 1), a = Math.min(Math.max(t.col, r.first), r.last), o = i - e.endRow, s = e.startRow - i, c = a - e.endCol, l = e.startCol - a, u = Math.max(o, s, 0), d = Math.max(c, l, 0);
|
|
41
|
+
return u === 0 && d === 0 ? null : u >= d ? o > 0 ? {
|
|
42
|
+
direction: "down",
|
|
43
|
+
range: {
|
|
44
|
+
startRow: e.endRow + 1,
|
|
45
|
+
endRow: i,
|
|
46
|
+
startCol: e.startCol,
|
|
47
|
+
endCol: e.endCol
|
|
48
|
+
}
|
|
49
|
+
} : {
|
|
50
|
+
direction: "up",
|
|
51
|
+
range: {
|
|
52
|
+
startRow: i,
|
|
53
|
+
endRow: e.startRow - 1,
|
|
54
|
+
startCol: e.startCol,
|
|
55
|
+
endCol: e.endCol
|
|
56
|
+
}
|
|
57
|
+
} : c > 0 ? {
|
|
58
|
+
direction: "right",
|
|
59
|
+
range: {
|
|
60
|
+
startRow: e.startRow,
|
|
61
|
+
endRow: e.endRow,
|
|
62
|
+
startCol: e.endCol + 1,
|
|
63
|
+
endCol: a
|
|
64
|
+
}
|
|
65
|
+
} : {
|
|
66
|
+
direction: "left",
|
|
67
|
+
range: {
|
|
68
|
+
startRow: e.startRow,
|
|
69
|
+
endRow: e.endRow,
|
|
70
|
+
startCol: a,
|
|
71
|
+
endCol: e.startCol - 1
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}, p = (e, t) => e.getLabelRow?.(t) !== void 0 || e.getGroupRow?.(t) !== void 0, m = (e) => e != null && e !== "", h = (e, t, r) => {
|
|
75
|
+
let i = !1;
|
|
76
|
+
for (let t = e.startCol; t <= e.endCol; t += 1) {
|
|
77
|
+
let e = r[t];
|
|
78
|
+
if (e !== void 0 && !n(e.key)) {
|
|
79
|
+
i = !0;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!i) return !1;
|
|
84
|
+
for (let n = e.startRow; n <= e.endRow; n += 1) if (!p(t, n)) return !0;
|
|
85
|
+
return !1;
|
|
86
|
+
}, g = (t, r, i) => {
|
|
87
|
+
let a = r.getRowCount(), o = t.endRow + 1;
|
|
88
|
+
if (o >= a) return null;
|
|
89
|
+
let s = (e) => p(r, e) ? void 0 : r.getRow(e), c = (e, t) => {
|
|
90
|
+
for (let r = e; r >= 0 && r < i.length; r += t) if (!n(i[r].key)) return r;
|
|
91
|
+
return -1;
|
|
92
|
+
}, l = i.slice(t.startCol, t.endCol + 1).filter((e) => !n(e.key));
|
|
93
|
+
if (l.length === 0) return null;
|
|
94
|
+
for (let n of [c(t.startCol - 1, -1), c(t.endCol + 1, 1)]) {
|
|
95
|
+
if (n === -1) continue;
|
|
96
|
+
let r = i[n], c = t.endRow;
|
|
97
|
+
for (let t = o; t < a; t += 1) {
|
|
98
|
+
let n = s(t);
|
|
99
|
+
if (n === void 0 || !m(e(n, r)) || l.some((t) => m(e(n, t)))) break;
|
|
100
|
+
c = t;
|
|
101
|
+
}
|
|
102
|
+
if (c > t.endRow) return {
|
|
103
|
+
direction: "down",
|
|
104
|
+
range: {
|
|
105
|
+
startRow: o,
|
|
106
|
+
endRow: c,
|
|
107
|
+
startCol: t.startCol,
|
|
108
|
+
endCol: t.endCol
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}, _ = (e, t, n, r) => {
|
|
114
|
+
let i = [];
|
|
115
|
+
for (let a = e; n === 1 ? a <= t : a >= t; a += n) r(a) && i.push(a);
|
|
116
|
+
return i;
|
|
117
|
+
}, v = ({ rowModel: t, columns: r, source: c, target: l, request: u, canWriteCell: d, getFillValue: f }) => {
|
|
118
|
+
let m = [], h = "copy", g = !1, { direction: v, range: y } = l, b = v === "down" || v === "up", x = v === "down" || v === "right", S = (e, t, n) => {
|
|
119
|
+
if (e.length === 0 || t.length === 0) return;
|
|
120
|
+
let r = a(e, { backward: !x }), c = s(r, u);
|
|
121
|
+
r.series !== null && (g = !0), c === "series" && (h = "series");
|
|
122
|
+
let l = o(e, r, c);
|
|
123
|
+
t.forEach((t, r) => {
|
|
124
|
+
let { viewIndex: a, colIndex: o, row: s, column: u } = n(t);
|
|
125
|
+
if (s === void 0 || !d(a, o, s, u)) return;
|
|
126
|
+
let p = l(r), h = f ? f({
|
|
127
|
+
column: u,
|
|
128
|
+
row: s,
|
|
129
|
+
rowIndex: a,
|
|
130
|
+
sourceValues: e,
|
|
131
|
+
index: r,
|
|
132
|
+
direction: v,
|
|
133
|
+
kind: c,
|
|
134
|
+
defaultValue: p
|
|
135
|
+
}) : p;
|
|
136
|
+
i(u, s, h).action !== "reject" && m.push({
|
|
137
|
+
viewIndex: a,
|
|
138
|
+
column: u,
|
|
139
|
+
value: h
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
if (b) {
|
|
144
|
+
let i = (e) => !p(t, e), a = x ? _(c.startRow, c.endRow, 1, i) : _(c.endRow, c.startRow, -1, i), o = x ? _(y.startRow, y.endRow, 1, i) : _(y.endRow, y.startRow, -1, i);
|
|
145
|
+
for (let i = c.startCol; i <= c.endCol; i += 1) {
|
|
146
|
+
let s = r[i];
|
|
147
|
+
if (!s || n(s.key)) continue;
|
|
148
|
+
let c = [], l = !0;
|
|
149
|
+
for (let n of a) {
|
|
150
|
+
let r = t.getRow(n);
|
|
151
|
+
if (r === void 0) {
|
|
152
|
+
l = !1;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
c.push(e(r, s));
|
|
156
|
+
}
|
|
157
|
+
l && S(c, o, (e) => ({
|
|
158
|
+
viewIndex: e,
|
|
159
|
+
colIndex: i,
|
|
160
|
+
row: t.getRow(e),
|
|
161
|
+
column: s
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
let i = (e) => {
|
|
166
|
+
let t = r[e];
|
|
167
|
+
return t !== void 0 && !n(t.key);
|
|
168
|
+
}, a = x ? _(c.startCol, c.endCol, 1, i) : _(c.endCol, c.startCol, -1, i), o = x ? _(y.startCol, y.endCol, 1, i) : _(y.endCol, y.startCol, -1, i);
|
|
169
|
+
for (let n = c.startRow; n <= c.endRow; n += 1) {
|
|
170
|
+
if (p(t, n)) continue;
|
|
171
|
+
let i = t.getRow(n);
|
|
172
|
+
i !== void 0 && S(a.map((t) => e(i, r[t])), o, (e) => ({
|
|
173
|
+
viewIndex: n,
|
|
174
|
+
colIndex: e,
|
|
175
|
+
row: i,
|
|
176
|
+
column: r[e]
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
edits: m,
|
|
182
|
+
kind: h,
|
|
183
|
+
seriesAvailable: g
|
|
184
|
+
};
|
|
185
|
+
}, y = ({ rowModel: t, columns: r, source: i, target: c, request: l, canWriteCell: u, getFillValue: d }) => {
|
|
186
|
+
let { direction: f, range: m } = c, h = f === "down" || f === "up", g = f === "down" || f === "right", v, y, b, x, S, C = !1, w;
|
|
187
|
+
if (h) {
|
|
188
|
+
let a = _(i.startCol, i.endCol, 1, (e) => {
|
|
189
|
+
let t = r[e];
|
|
190
|
+
return t !== void 0 && !n(t.key);
|
|
191
|
+
})[0];
|
|
192
|
+
if (a === void 0) return null;
|
|
193
|
+
b = a, y = r[b];
|
|
194
|
+
let o = (e) => !p(t, e), s = g ? _(i.startRow, i.endRow, 1, o) : _(i.endRow, i.startRow, -1, o), c = g ? _(m.startRow, m.endRow, 1, o) : _(m.endRow, m.startRow, -1, o);
|
|
195
|
+
if (s.length === 0 || c.length === 0) return null;
|
|
196
|
+
v = [];
|
|
197
|
+
let l;
|
|
198
|
+
for (let n of s) {
|
|
199
|
+
if (l = t.getRow(n), l === void 0) return null;
|
|
200
|
+
v.push(e(l, y));
|
|
201
|
+
}
|
|
202
|
+
w = c.length - 1, x = c[w], S = t.getRow(x), C = S === void 0, S ??= l;
|
|
203
|
+
} else {
|
|
204
|
+
let a = _(i.startRow, i.endRow, 1, (e) => !p(t, e))[0];
|
|
205
|
+
if (a === void 0) return null;
|
|
206
|
+
let o = t.getRow(a);
|
|
207
|
+
if (o === void 0) return null;
|
|
208
|
+
let s = (e) => {
|
|
209
|
+
let t = r[e];
|
|
210
|
+
return t !== void 0 && !n(t.key);
|
|
211
|
+
}, c = g ? _(i.startCol, i.endCol, 1, s) : _(i.endCol, i.startCol, -1, s), l = g ? _(m.startCol, m.endCol, 1, s) : _(m.endCol, m.startCol, -1, s);
|
|
212
|
+
if (c.length === 0 || l.length === 0) return null;
|
|
213
|
+
v = c.map((t) => e(o, r[t])), w = l.length - 1, b = l[w], y = r[b], x = a, S = o;
|
|
214
|
+
}
|
|
215
|
+
let T = a(v, { backward: !g }), E = s(T, l), D = o(v, T, E)(w), O = d && S !== void 0 && !C && (u === void 0 || u(x, b, S, y)) ? d({
|
|
216
|
+
column: y,
|
|
217
|
+
row: S,
|
|
218
|
+
rowIndex: x,
|
|
219
|
+
sourceValues: v,
|
|
220
|
+
index: w,
|
|
221
|
+
direction: f,
|
|
222
|
+
kind: E,
|
|
223
|
+
defaultValue: D
|
|
224
|
+
}) : D;
|
|
225
|
+
return {
|
|
226
|
+
column: y,
|
|
227
|
+
row: S,
|
|
228
|
+
value: O
|
|
229
|
+
};
|
|
230
|
+
}, b = (e, n, r) => {
|
|
231
|
+
if (r.length === 0) return e;
|
|
232
|
+
let i = [...e];
|
|
233
|
+
for (let { viewIndex: e, column: a, value: o } of r) {
|
|
234
|
+
let r = n.getSourceIndex(e);
|
|
235
|
+
if (r === void 0) continue;
|
|
236
|
+
let s = i[r];
|
|
237
|
+
s !== void 0 && (i[r] = t(s, a, o));
|
|
238
|
+
}
|
|
239
|
+
return i;
|
|
240
|
+
}, x = (e, t, n, i, a) => {
|
|
241
|
+
if (e.endRow < i || e.endRow > a) return null;
|
|
242
|
+
let o = r(t, e.endCol);
|
|
243
|
+
return o ? {
|
|
244
|
+
pane: o.pane,
|
|
245
|
+
x: o.extent.end,
|
|
246
|
+
y: n.rowTop(e.endRow) + n.cellHeight(e.endRow),
|
|
247
|
+
paneWidth: t[o.pane].totalWidth
|
|
248
|
+
} : null;
|
|
249
|
+
}, S = 36, C = 22, w = 4, T = (e, t, n = Infinity) => ({
|
|
250
|
+
x: e.x + w + 36 <= e.paneWidth ? e.x + w : Math.max(e.x - 36 - w, 0),
|
|
251
|
+
y: e.y + w + 22 <= Math.min(t, n) ? e.y + w : Math.max(e.y - 22 - w, 0)
|
|
252
|
+
});
|
|
253
|
+
//#endregion
|
|
254
|
+
export { C as FILL_OPTIONS_CHIP_HEIGHT, S as FILL_OPTIONS_CHIP_WIDTH, b as applyFillEditsToRows, v as buildFillEdits, h as hasFillableSource, u as isSameFillRange, y as previewFillValue, d as resolveFillColumnBounds, x as resolveFillCornerPlacement, g as resolveFillDoubleClickTarget, T as resolveFillOptionsChipPosition, c as resolveFillSource, f as resolveFillTarget, l as unionFillRange };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=e=>e==null||e===``,t=e=>typeof e==`number`&&Number.isFinite(e),n=e=>Number.isInteger(e)?e:Number(e.toPrecision(15)),r=e=>{let t=e.length,n=(t-1)/2,r=0;for(let t of e)r+=t;r/=t;let i=0,a=0;for(let o=0;o<t;o+=1)i+=(o-n)*(e[o]-r),a+=(o-n)**2;let o=a===0?0:i/a,s=r-o*n;return e=>s+o*e},i=e=>{if(e.length<2)return null;let t=e[1]-e[0];for(let n=2;n<e.length;n+=1)if(e[n]-e[n-1]!==t)return null;return t},a=(e,t)=>{let a=e.length,o=e[a-1];if(a===1)return e=>n(o+t*(e+1));let s=i(e);if(s!==null)return e=>n(o+s*(e+1));let c=r(e);return e=>n(c(a+e))},o=/^(\d{4})([-/])(\d{1,2})\2(\d{1,2})$/,s=864e5,c=(e,t)=>new Date(Date.UTC(e,t+1,0)).getUTCDate(),l=e=>{let t=o.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[3]),i=Number(t[4]);return r<1||r>12||i<1||i>c(n,r-1)?null:{year:n,monthIndex:r-1,day:i,separator:t[2],padded:t[3].length===2&&t[4].length===2}},u=({year:e,monthIndex:t,day:n})=>Math.round(Date.UTC(e,t,n)/s),d=e=>{let t=new Date(e*s);return{year:t.getUTCFullYear(),monthIndex:t.getUTCMonth(),day:t.getUTCDate()}},f=(e,t)=>{let n=e.year*12+e.monthIndex+t,r=Math.floor(n/12),i=n-r*12;return{year:r,monthIndex:i,day:Math.min(e.day,c(r,i))}},p=(e,t)=>{let n=e.length,r=e[n-1];if(n>=2&&e.every(e=>e.day===r.day)){let t=i(e.map(e=>e.year*12+e.monthIndex));if(t!==null&&t!==0)return e=>f(r,t*(e+1))}let o=a(e.map(u),t);return e=>d(Math.round(o(e)))},m=e=>String(e).padStart(2,`0`),h=(e,t,n)=>{let r=e.monthIndex+1;return n?`${e.year}${t}${m(r)}${t}${m(e.day)}`:`${e.year}${t}${r}${t}${e.day}`},g=e=>e instanceof Date&&!Number.isNaN(e.getTime()),_=[[`月`,`火`,`水`,`木`,`金`,`土`,`日`],[`月曜`,`火曜`,`水曜`,`木曜`,`金曜`,`土曜`,`日曜`],[`月曜日`,`火曜日`,`水曜日`,`木曜日`,`金曜日`,`土曜日`,`日曜日`],[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],[`1月`,`2月`,`3月`,`4月`,`5月`,`6月`,`7月`,`8月`,`9月`,`10月`,`11月`,`12月`],[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]],v=_.map(e=>new Map(e.map((e,t)=>[e.toLowerCase(),t]))),y=(e,t)=>t===t.toUpperCase()&&t!==t.toLowerCase()?e.toUpperCase():t===t.toLowerCase()&&t!==t.toUpperCase()?e.toLowerCase():e,b=(e,t)=>{for(let n=0;n<_.length;n+=1){let r=v[n],i=[];for(let t of e){let e=r.get(t.toLowerCase());if(e===void 0)break;i.push(e)}if(i.length!==e.length)continue;let a=_[n],o=a.length,s=t;if(i.length>=2){let e=(i[1]-i[0]+o)%o;for(let t=2;t<i.length;t+=1)if((i[t]-i[t-1]+o)%o!==e)return null;s=e}let c=i[i.length-1],l=e[e.length-1];return e=>y(a[((c+s*(e+1))%o+o)%o],l)}return null},x=/^(.*?)(\d+)$/,S=/^\d+$/,C=/^-?\d+(?:\.\d+)?$/,w=15,T=(e,t)=>{let n=[];for(let t of e){let e=x.exec(t);if(!e||e[2].length>w)return null;n.push({prefix:e[1],digits:e[2]})}let{prefix:r,digits:i}=n[n.length-1];if(n.some(e=>e.prefix!==r))return null;let o=i.length>1&&i.startsWith(`0`)?i.length:0,s=a(n.map(e=>Number(e.digits)),t);return e=>`${r}${String(Math.abs(Math.round(s(e)))).padStart(o,`0`)}`},E=(n,r={})=>{let i={defaultKind:`copy`,series:null};if(n.length===0||n.some(e))return i;let o=n.length===1,s=r.backward?-1:1;if(n.every(t))return{defaultKind:o?`copy`:`series`,series:a(n,s)};if(n.every(g)){let e=n[n.length-1],t=e.getHours(),r=e.getMinutes(),i=e.getSeconds(),a=e.getMilliseconds(),o=p(n.map(e=>({year:e.getFullYear(),monthIndex:e.getMonth(),day:e.getDate()})),s);return{defaultKind:`series`,series:e=>{let n=o(e),s=new Date(2e3,0,1,t,r,i,a);return s.setFullYear(n.year,n.monthIndex,n.day),s}}}if(!n.every(e=>typeof e==`string`))return i;let c=n,u=c.map(l);if(u.every(e=>e!==null)){let e=u[u.length-1],t=u.every(e=>e.padded),n=p(u,s);return{defaultKind:`series`,series:r=>h(n(r),e.separator,t)}}if(c.every(e=>C.test(e))&&!c.every(e=>S.test(e))){let e=a(c.map(Number),s);return{defaultKind:o?`copy`:`series`,series:t=>String(e(t))}}let d=b(c,s);if(d)return{defaultKind:`series`,series:d};let f=T(c,s);if(f){let e=c.every(e=>S.test(e));return{defaultKind:o&&e?`copy`:`series`,series:f}}return i},D=(e,t)=>e.series===null||t===`copy`?`copy`:t===`series`?`series`:t===`toggled`?e.defaultKind===`series`?`copy`:`series`:e.defaultKind,O=(e,t,n)=>n===`series`&&t.series!==null?t.series:t=>{let n=e[t%e.length];return n instanceof Date?new Date(n.getTime()):n};exports.analyzeFillLine=E,exports.createFillLineValues=O,exports.resolveFillLineKind=D;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type FillKind = 'series' | 'copy';
|
|
2
|
+
export type FillRequest = 'auto' | 'toggled' | FillKind;
|
|
3
|
+
export type FillLineAnalysis = {
|
|
4
|
+
defaultKind: FillKind;
|
|
5
|
+
series: ((index: number) => unknown) | null;
|
|
6
|
+
};
|
|
7
|
+
export declare const analyzeFillLine: (source: readonly unknown[], options?: {
|
|
8
|
+
backward?: boolean;
|
|
9
|
+
}) => FillLineAnalysis;
|
|
10
|
+
export declare const resolveFillLineKind: (analysis: FillLineAnalysis, request: FillRequest) => FillKind;
|
|
11
|
+
export declare const createFillLineValues: (source: readonly unknown[], analysis: FillLineAnalysis, kind: FillKind) => ((index: number) => unknown);
|