@gridsheet/core 3.0.0-rc.10
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/LICENSE +190 -0
- package/README.md +17 -0
- package/dist/constants.d.ts +21 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +28 -0
- package/dist/constants.js.map +1 -0
- package/dist/formula/evaluator.d.ts +134 -0
- package/dist/formula/evaluator.d.ts.map +1 -0
- package/dist/formula/evaluator.js +585 -0
- package/dist/formula/evaluator.js.map +1 -0
- package/dist/formula/formula-error.d.ts +10 -0
- package/dist/formula/formula-error.d.ts.map +1 -0
- package/dist/formula/formula-error.js +15 -0
- package/dist/formula/formula-error.js.map +1 -0
- package/dist/formula/functions/__async.d.ts +67 -0
- package/dist/formula/functions/__async.d.ts.map +1 -0
- package/dist/formula/functions/__async.js +70 -0
- package/dist/formula/functions/__async.js.map +1 -0
- package/dist/formula/functions/__base.d.ts +112 -0
- package/dist/formula/functions/__base.d.ts.map +1 -0
- package/dist/formula/functions/__base.js +265 -0
- package/dist/formula/functions/__base.js.map +1 -0
- package/dist/formula/functions/__utils.d.ts +28 -0
- package/dist/formula/functions/__utils.d.ts.map +1 -0
- package/dist/formula/functions/__utils.js +179 -0
- package/dist/formula/functions/__utils.js.map +1 -0
- package/dist/formula/functions/abs.d.ts +9 -0
- package/dist/formula/functions/abs.d.ts.map +1 -0
- package/dist/formula/functions/abs.js +15 -0
- package/dist/formula/functions/abs.js.map +1 -0
- package/dist/formula/functions/add.d.ts +10 -0
- package/dist/formula/functions/add.d.ts.map +1 -0
- package/dist/formula/functions/add.js +37 -0
- package/dist/formula/functions/add.js.map +1 -0
- package/dist/formula/functions/and.d.ts +9 -0
- package/dist/formula/functions/and.d.ts.map +1 -0
- package/dist/formula/functions/and.js +23 -0
- package/dist/formula/functions/and.js.map +1 -0
- package/dist/formula/functions/arrayformula.d.ts +12 -0
- package/dist/formula/functions/arrayformula.d.ts.map +1 -0
- package/dist/formula/functions/arrayformula.js +24 -0
- package/dist/formula/functions/arrayformula.js.map +1 -0
- package/dist/formula/functions/average.d.ts +9 -0
- package/dist/formula/functions/average.d.ts.map +1 -0
- package/dist/formula/functions/average.js +40 -0
- package/dist/formula/functions/average.js.map +1 -0
- package/dist/formula/functions/concat.d.ts +9 -0
- package/dist/formula/functions/concat.d.ts.map +1 -0
- package/dist/formula/functions/concat.js +27 -0
- package/dist/formula/functions/concat.js.map +1 -0
- package/dist/formula/functions/count.d.ts +9 -0
- package/dist/formula/functions/count.d.ts.map +1 -0
- package/dist/formula/functions/count.js +32 -0
- package/dist/formula/functions/count.js.map +1 -0
- package/dist/formula/functions/counta.d.ts +9 -0
- package/dist/formula/functions/counta.d.ts.map +1 -0
- package/dist/formula/functions/counta.js +32 -0
- package/dist/formula/functions/counta.js.map +1 -0
- package/dist/formula/functions/divide.d.ts +10 -0
- package/dist/formula/functions/divide.d.ts.map +1 -0
- package/dist/formula/functions/divide.js +34 -0
- package/dist/formula/functions/divide.js.map +1 -0
- package/dist/formula/functions/eq.d.ts +9 -0
- package/dist/formula/functions/eq.d.ts.map +1 -0
- package/dist/formula/functions/eq.js +19 -0
- package/dist/formula/functions/eq.js.map +1 -0
- package/dist/formula/functions/gt.d.ts +9 -0
- package/dist/formula/functions/gt.d.ts.map +1 -0
- package/dist/formula/functions/gt.js +19 -0
- package/dist/formula/functions/gt.js.map +1 -0
- package/dist/formula/functions/gte.d.ts +9 -0
- package/dist/formula/functions/gte.d.ts.map +1 -0
- package/dist/formula/functions/gte.js +19 -0
- package/dist/formula/functions/gte.js.map +1 -0
- package/dist/formula/functions/if.d.ts +9 -0
- package/dist/formula/functions/if.d.ts.map +1 -0
- package/dist/formula/functions/if.js +29 -0
- package/dist/formula/functions/if.js.map +1 -0
- package/dist/formula/functions/iferror.d.ts +10 -0
- package/dist/formula/functions/iferror.d.ts.map +1 -0
- package/dist/formula/functions/iferror.js +28 -0
- package/dist/formula/functions/iferror.js.map +1 -0
- package/dist/formula/functions/len.d.ts +9 -0
- package/dist/formula/functions/len.d.ts.map +1 -0
- package/dist/formula/functions/len.js +21 -0
- package/dist/formula/functions/len.js.map +1 -0
- package/dist/formula/functions/lt.d.ts +9 -0
- package/dist/formula/functions/lt.d.ts.map +1 -0
- package/dist/formula/functions/lt.js +19 -0
- package/dist/formula/functions/lt.js.map +1 -0
- package/dist/formula/functions/lte.d.ts +9 -0
- package/dist/formula/functions/lte.d.ts.map +1 -0
- package/dist/formula/functions/lte.js +19 -0
- package/dist/formula/functions/lte.js.map +1 -0
- package/dist/formula/functions/max.d.ts +9 -0
- package/dist/formula/functions/max.d.ts.map +1 -0
- package/dist/formula/functions/max.js +37 -0
- package/dist/formula/functions/max.js.map +1 -0
- package/dist/formula/functions/min.d.ts +9 -0
- package/dist/formula/functions/min.d.ts.map +1 -0
- package/dist/formula/functions/min.js +37 -0
- package/dist/formula/functions/min.js.map +1 -0
- package/dist/formula/functions/minus.d.ts +10 -0
- package/dist/formula/functions/minus.d.ts.map +1 -0
- package/dist/formula/functions/minus.js +41 -0
- package/dist/formula/functions/minus.js.map +1 -0
- package/dist/formula/functions/multiply.d.ts +9 -0
- package/dist/formula/functions/multiply.d.ts.map +1 -0
- package/dist/formula/functions/multiply.js +19 -0
- package/dist/formula/functions/multiply.js.map +1 -0
- package/dist/formula/functions/ne.d.ts +9 -0
- package/dist/formula/functions/ne.d.ts.map +1 -0
- package/dist/formula/functions/ne.js +19 -0
- package/dist/formula/functions/ne.js.map +1 -0
- package/dist/formula/functions/not.d.ts +9 -0
- package/dist/formula/functions/not.d.ts.map +1 -0
- package/dist/formula/functions/not.js +22 -0
- package/dist/formula/functions/not.js.map +1 -0
- package/dist/formula/functions/now.d.ts +9 -0
- package/dist/formula/functions/now.d.ts.map +1 -0
- package/dist/formula/functions/now.js +14 -0
- package/dist/formula/functions/now.js.map +1 -0
- package/dist/formula/functions/or.d.ts +9 -0
- package/dist/formula/functions/or.d.ts.map +1 -0
- package/dist/formula/functions/or.js +23 -0
- package/dist/formula/functions/or.js.map +1 -0
- package/dist/formula/functions/power.d.ts +9 -0
- package/dist/formula/functions/power.d.ts.map +1 -0
- package/dist/formula/functions/power.js +18 -0
- package/dist/formula/functions/power.js.map +1 -0
- package/dist/formula/functions/sum.d.ts +9 -0
- package/dist/formula/functions/sum.d.ts.map +1 -0
- package/dist/formula/functions/sum.js +34 -0
- package/dist/formula/functions/sum.js.map +1 -0
- package/dist/formula/functions/uminus.d.ts +9 -0
- package/dist/formula/functions/uminus.d.ts.map +1 -0
- package/dist/formula/functions/uminus.js +17 -0
- package/dist/formula/functions/uminus.js.map +1 -0
- package/dist/formula/mapping.d.ts +11 -0
- package/dist/formula/mapping.d.ts.map +1 -0
- package/dist/formula/mapping.js +82 -0
- package/dist/formula/mapping.js.map +1 -0
- package/dist/formula/solver.d.ts +39 -0
- package/dist/formula/solver.d.ts.map +1 -0
- package/dist/formula/solver.js +71 -0
- package/dist/formula/solver.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +132 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/autofill.d.ts +22 -0
- package/dist/lib/autofill.d.ts.map +1 -0
- package/dist/lib/autofill.js +276 -0
- package/dist/lib/autofill.js.map +1 -0
- package/dist/lib/book.d.ts +131 -0
- package/dist/lib/book.d.ts.map +1 -0
- package/dist/lib/book.js +53 -0
- package/dist/lib/book.js.map +1 -0
- package/dist/lib/cell.d.ts +17 -0
- package/dist/lib/cell.d.ts.map +1 -0
- package/dist/lib/cell.js +17 -0
- package/dist/lib/cell.js.map +1 -0
- package/dist/lib/coords.d.ts +22 -0
- package/dist/lib/coords.d.ts.map +1 -0
- package/dist/lib/coords.js +73 -0
- package/dist/lib/coords.js.map +1 -0
- package/dist/lib/date.d.ts +2 -0
- package/dist/lib/date.d.ts.map +1 -0
- package/dist/lib/date.js +91 -0
- package/dist/lib/date.js.map +1 -0
- package/dist/lib/dom.d.ts +7 -0
- package/dist/lib/dom.d.ts.map +1 -0
- package/dist/lib/dom.js +28 -0
- package/dist/lib/dom.js.map +1 -0
- package/dist/lib/filter.d.ts +7 -0
- package/dist/lib/filter.d.ts.map +1 -0
- package/dist/lib/filter.js +122 -0
- package/dist/lib/filter.js.map +1 -0
- package/dist/lib/input.d.ts +28 -0
- package/dist/lib/input.d.ts.map +1 -0
- package/dist/lib/input.js +73 -0
- package/dist/lib/input.js.map +1 -0
- package/dist/lib/label.d.ts +4 -0
- package/dist/lib/label.d.ts.map +1 -0
- package/dist/lib/label.js +10 -0
- package/dist/lib/label.js.map +1 -0
- package/dist/lib/operation.d.ts +31 -0
- package/dist/lib/operation.d.ts.map +1 -0
- package/dist/lib/operation.js +36 -0
- package/dist/lib/operation.js.map +1 -0
- package/dist/lib/palette.d.ts +2 -0
- package/dist/lib/palette.d.ts.map +1 -0
- package/dist/lib/palette.js +26 -0
- package/dist/lib/palette.js.map +1 -0
- package/dist/lib/popup.d.ts +24 -0
- package/dist/lib/popup.d.ts.map +1 -0
- package/dist/lib/popup.js +21 -0
- package/dist/lib/popup.js.map +1 -0
- package/dist/lib/reference.d.ts +19 -0
- package/dist/lib/reference.d.ts.map +1 -0
- package/dist/lib/reference.js +40 -0
- package/dist/lib/reference.js.map +1 -0
- package/dist/lib/sheet.d.ts +512 -0
- package/dist/lib/sheet.d.ts.map +1 -0
- package/dist/lib/sheet.js +1530 -0
- package/dist/lib/sheet.js.map +1 -0
- package/dist/lib/sheet_utils.d.ts +55 -0
- package/dist/lib/sheet_utils.d.ts.map +1 -0
- package/dist/lib/sheet_utils.js +125 -0
- package/dist/lib/sheet_utils.js.map +1 -0
- package/dist/lib/spatial.d.ts +79 -0
- package/dist/lib/spatial.d.ts.map +1 -0
- package/dist/lib/spatial.js +227 -0
- package/dist/lib/spatial.js.map +1 -0
- package/dist/lib/time.d.ts +29 -0
- package/dist/lib/time.d.ts.map +1 -0
- package/dist/lib/time.js +113 -0
- package/dist/lib/time.js.map +1 -0
- package/dist/lib/virtualization.d.ts +22 -0
- package/dist/lib/virtualization.d.ts.map +1 -0
- package/dist/lib/virtualization.js +91 -0
- package/dist/lib/virtualization.js.map +1 -0
- package/dist/policy/core.d.ts +161 -0
- package/dist/policy/core.d.ts.map +1 -0
- package/dist/policy/core.js +248 -0
- package/dist/policy/core.js.map +1 -0
- package/dist/policy/thousand_separator.d.ts +4 -0
- package/dist/policy/thousand_separator.d.ts.map +1 -0
- package/dist/policy/thousand_separator.js +13 -0
- package/dist/policy/thousand_separator.js.map +1 -0
- package/dist/sentinels.d.ts +40 -0
- package/dist/sentinels.d.ts.map +1 -0
- package/dist/sentinels.js +41 -0
- package/dist/sentinels.js.map +1 -0
- package/dist/styles/embedder.d.ts +2 -0
- package/dist/styles/embedder.d.ts.map +1 -0
- package/dist/styles/embedder.js +11 -0
- package/dist/styles/embedder.js.map +1 -0
- package/dist/styles/minified.d.ts +3 -0
- package/dist/styles/minified.d.ts.map +1 -0
- package/dist/styles/minified.js +6 -0
- package/dist/styles/minified.js.map +1 -0
- package/dist/types.d.ts +310 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +5 -0
- package/dist/utils.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtualization.js","sources":["../../src/lib/virtualization.ts"],"sourcesContent":["import { DEFAULT_HEIGHT, DEFAULT_WIDTH, OVERSCAN_X, OVERSCAN_Y } from '../constants';\nimport { range, binarySearch, type BinarySearchPredicate } from './spatial';\nimport { Sheet } from './sheet';\nimport type { AreaType, PointType, Virtualization } from '../types';\n\nexport const getCellRectPositions = (sheet: Sheet, { y, x }: PointType) => {\n // Use System.offsetLeft / offsetTop stored on header cells for O(1) lookup\n const colCell = sheet.getCell({ y: 0, x }, { resolution: 'SYSTEM' });\n const rowCell = sheet.getCell({ y, x: 0 }, { resolution: 'SYSTEM' });\n const left = sheet.getSystem({ y: 0, x })?.offsetLeft ?? 0;\n const top = sheet.getSystem({ y, x: 0 })?.offsetTop ?? 0;\n const w = colCell?.width || DEFAULT_WIDTH;\n const h = rowCell?.filtered ? 0 : rowCell?.height || DEFAULT_HEIGHT;\n return {\n top,\n left,\n bottom: top + h,\n right: left + w,\n width: w,\n height: h,\n };\n};\n\nexport const getScreenRect = (e: HTMLDivElement) => {\n const top = e.scrollTop,\n left = e.scrollLeft;\n const height = e.offsetHeight,\n width = e.offsetWidth;\n const bottom = top + height,\n right = left + width;\n return { top, left, bottom, right, height, width };\n};\n\nexport const virtualize = (sheet: Sheet, e: HTMLDivElement | null): Virtualization | null => {\n if (e == null) {\n return null;\n }\n let boundaryTop = 0,\n boundaryLeft = 0,\n boundaryBottom = sheet.numRows,\n boundaryRight = sheet.numCols;\n\n const { top, left, bottom, right } = getScreenRect(e);\n let width = 0,\n height = 0;\n for (let x = 1; x <= sheet.numCols; x++) {\n const w = sheet.getCell({ y: 0, x }, { resolution: 'SYSTEM' })?.width || DEFAULT_WIDTH;\n width += w;\n if (boundaryLeft === 0 && width > left) {\n boundaryLeft = Math.max(x - OVERSCAN_X, 1);\n }\n if (width > right) {\n boundaryRight = Math.min(x + OVERSCAN_X, sheet.numCols);\n break;\n }\n }\n for (let y = 1; y <= sheet.numRows; y++) {\n if (sheet.isRowFiltered(y)) {\n continue;\n }\n const h = sheet.getCell({ y, x: 0 }, { resolution: 'SYSTEM' })?.height || DEFAULT_HEIGHT;\n height += h;\n if (boundaryTop === 0 && height > top) {\n boundaryTop = Math.max(y - OVERSCAN_Y, 1);\n }\n if (height > bottom) {\n boundaryBottom = Math.min(y + OVERSCAN_Y, sheet.numRows);\n break;\n }\n }\n const ys = boundaryTop === 0 ? [] : range(boundaryTop, boundaryBottom).filter((y) => !sheet.isRowFiltered(y));\n const xs = range(boundaryLeft, boundaryRight);\n const before = sheet.getRectSize({\n top: 1,\n left: 1,\n bottom: boundaryTop,\n right: boundaryLeft,\n });\n const after = sheet.getRectSize({\n top: boundaryBottom,\n left: boundaryRight,\n bottom: sheet.numRows,\n right: sheet.numCols,\n });\n return {\n ys,\n xs,\n adjuster: {\n top: before.height,\n left: before.width,\n bottom: after.height,\n right: after.width,\n },\n };\n};\n\nexport const smartScroll = (\n sheet: Sheet,\n e: HTMLDivElement | null,\n targetPoint: PointType,\n behavior: ScrollBehavior = 'auto',\n) => {\n if (e == null) {\n return;\n }\n const screen = getScreenRect(e);\n const target = getCellRectPositions(sheet, targetPoint);\n\n // when header is sticky\n const up = target.top - sheet.headerHeight;\n const left = target.left - sheet.headerWidth;\n const down = target.bottom - screen.height + 1;\n const right = target.right - screen.width + 1;\n\n const isTopOver = up < screen.top;\n const isLeftOver = left < screen.left;\n const isBottomOver = target.bottom > screen.bottom;\n const isRightOver = target.right > screen.right;\n\n if (isLeftOver) {\n if (isTopOver) {\n // go left up\n e.scrollTo({ left, top: up, behavior });\n } else if (isBottomOver) {\n // go left down\n e.scrollTo({ left, top: down, behavior });\n } else {\n // go left\n e.scrollTo({ left, top: screen.top, behavior });\n }\n } else if (isRightOver) {\n if (isTopOver) {\n // go right up\n e.scrollTo({ left: right, top: up, behavior });\n } else if (isBottomOver) {\n // go right down\n e.scrollTo({ left: right, top: down, behavior });\n } else {\n // go right\n e.scrollTo({ left: right, top: screen.top, behavior });\n }\n } else {\n if (isTopOver) {\n // go up\n e.scrollTo({ left: screen.left, top: up, behavior });\n } else if (isBottomOver) {\n // go down\n e.scrollTo({ left: screen.left, top: down, behavior });\n } else {\n // go nowhere\n }\n }\n};\n\ntype PositionGetter = (rect: DOMRect) => number;\n\nconst findVisibleElement = (\n elements: HTMLTableHeaderCellElement[],\n getPosition: PositionGetter,\n boundary: number,\n dataKey: string,\n): number => {\n const index = binarySearch(\n 0,\n elements.length - 1,\n (mid) => getPosition(elements[mid].getBoundingClientRect()) < boundary,\n false,\n );\n return parseInt(elements[index]?.dataset[dataKey] ?? '1');\n};\n\nexport const getAreaInTabular = (tabularElement: HTMLDivElement): AreaType => {\n const {\n top: topPosition,\n left: leftPosition,\n bottom: bottomPosition,\n right: rightPosition,\n } = tabularElement.getBoundingClientRect();\n\n const rows = Array.from(tabularElement.querySelectorAll('.gs-th-left')) as HTMLTableHeaderCellElement[];\n const cols = Array.from(tabularElement.querySelectorAll('.gs-th-top')) as HTMLTableHeaderCellElement[];\n\n const top = findVisibleElement(rows, (rect) => rect.top, topPosition, 'y');\n const bottom = findVisibleElement(rows, (rect) => rect.bottom, bottomPosition, 'y');\n const left = findVisibleElement(cols, (rect) => rect.left, leftPosition, 'x');\n const right = findVisibleElement(cols, (rect) => rect.right, rightPosition, 'x');\n\n return { top, left, bottom, right };\n};\n"],"names":["getCellRectPositions","sheet","y","x","colCell","rowCell","left","_a","top","_b","w","DEFAULT_WIDTH","h","DEFAULT_HEIGHT","getScreenRect","e","height","width","bottom","right","virtualize","boundaryTop","boundaryLeft","boundaryBottom","boundaryRight","OVERSCAN_X","OVERSCAN_Y","ys","range","xs","before","after","smartScroll","targetPoint","behavior","screen","target","up","down","isTopOver","isLeftOver","isBottomOver","isRightOver","findVisibleElement","elements","getPosition","boundary","dataKey","index","binarySearch","mid","getAreaInTabular","tabularElement","topPosition","leftPosition","bottomPosition","rightPosition","rows","cols","rect"],"mappings":";;AAKO,MAAMA,IAAuB,CAACC,GAAc,EAAE,GAAAC,GAAG,GAAAC,QAAmB;;AAEnE,QAAAC,IAAUH,EAAM,QAAQ,EAAE,GAAG,GAAG,GAAAE,KAAK,EAAE,YAAY,UAAU,GAC7DE,IAAUJ,EAAM,QAAQ,EAAE,GAAAC,GAAG,GAAG,KAAK,EAAE,YAAY,UAAU,GAC7DI,MAAOC,IAAAN,EAAM,UAAU,EAAE,GAAG,GAAG,GAAAE,EAAA,CAAG,MAA3B,gBAAAI,EAA8B,eAAc,GACnDC,MAAMC,IAAAR,EAAM,UAAU,EAAE,GAAAC,GAAG,GAAG,EAAA,CAAG,MAA3B,gBAAA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AAOC;AAAA,EAAA,IACLJ,EAAe,sBAAsB,GAEnCK,IAAO,MAAM,KAAKL,EAAe,iBAAiB,aAAa,CAAC,GAChEM,IAAO,MAAM,KAAKN,EAAe,iBAAiB,YAAY,CAAC,GAE/D5C,IAAMmC,EAAmBc,GAAM,CAACE,MAASA,EAAK,KAAKN,GAAa,GAAG,GACnEnC,IAASyB,EAAmBc,GAAM,CAACE,MAASA,EAAK,QAAQJ,GAAgB,GAAG,GAC5EjD,IAAOqC,EAAmBe,GAAM,CAACC,MAASA,EAAK,MAAML,GAAc,GAAG,GACtEnC,IAAQwB,EAAmBe,GAAM,CAACC,MAASA,EAAK,OAAOH,GAAe,GAAG;AAE/E,SAAO,EAAE,KAAAhD,GAAK,MAAAF,GAAM,QAAAY,GAAQ,OAAAC,EAAM;AACpC;"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { CellPatchType, CellType, OperationType, PointType } from '../types';
|
|
2
|
+
import { Sheet, UserSheet } from '../lib/sheet';
|
|
3
|
+
import { FormulaError } from '../formula/formula-error';
|
|
4
|
+
import { Time } from '../lib/time';
|
|
5
|
+
export type AutocompleteOption = {
|
|
6
|
+
value: any;
|
|
7
|
+
label?: any;
|
|
8
|
+
keywords?: string[];
|
|
9
|
+
tooltip?: any;
|
|
10
|
+
};
|
|
11
|
+
export type SelectProps = {
|
|
12
|
+
sheet: UserSheet;
|
|
13
|
+
point: PointType;
|
|
14
|
+
current?: CellType;
|
|
15
|
+
next?: CellType;
|
|
16
|
+
operation: OperationType;
|
|
17
|
+
};
|
|
18
|
+
export type SerializeForClipboardProps = {
|
|
19
|
+
sheet: UserSheet;
|
|
20
|
+
point: PointType;
|
|
21
|
+
};
|
|
22
|
+
export type SelectFallbackProps = {
|
|
23
|
+
sheet: UserSheet;
|
|
24
|
+
point: PointType;
|
|
25
|
+
value: any;
|
|
26
|
+
};
|
|
27
|
+
export type Scalar = string | number | boolean | null | undefined;
|
|
28
|
+
export type ScalarProps<T = any> = {
|
|
29
|
+
value?: T;
|
|
30
|
+
cell?: CellType<T>;
|
|
31
|
+
sheet: Sheet;
|
|
32
|
+
point: PointType;
|
|
33
|
+
};
|
|
34
|
+
export type RenderProps<T = any> = {
|
|
35
|
+
value: T;
|
|
36
|
+
cell?: CellType<T>;
|
|
37
|
+
sheet: Sheet;
|
|
38
|
+
point: PointType;
|
|
39
|
+
apply?: (sheet: UserSheet) => void;
|
|
40
|
+
};
|
|
41
|
+
export type SerializeProps<T = any> = {
|
|
42
|
+
value: T;
|
|
43
|
+
cell?: CellType<T>;
|
|
44
|
+
sheet: Sheet;
|
|
45
|
+
point: PointType;
|
|
46
|
+
};
|
|
47
|
+
export type PolicyMixinType = {
|
|
48
|
+
datetimeFormat?: string;
|
|
49
|
+
dateFormat?: string;
|
|
50
|
+
timeFormat?: string;
|
|
51
|
+
decimalPrecision?: number;
|
|
52
|
+
render?: (props: RenderProps) => any;
|
|
53
|
+
renderCallback?: (rendered: any, props: RenderProps) => any;
|
|
54
|
+
renderString?: (props: RenderProps<string>) => any;
|
|
55
|
+
renderNumber?: (props: RenderProps<number>) => any;
|
|
56
|
+
renderBool?: (props: RenderProps<boolean>) => any;
|
|
57
|
+
renderDate?: (props: RenderProps<Date>) => any;
|
|
58
|
+
renderTime?: (props: RenderProps<Time>) => any;
|
|
59
|
+
renderArray?: (props: RenderProps<any[]>) => any;
|
|
60
|
+
renderObject?: (props: RenderProps<any>) => any;
|
|
61
|
+
renderNull?: (props: RenderProps<null | undefined>) => any;
|
|
62
|
+
renderSheet?: (props: RenderProps<UserSheet>) => any;
|
|
63
|
+
renderRowHeaderLabel?: (n: number) => string | null;
|
|
64
|
+
renderColHeaderLabel?: (n: number) => string | null;
|
|
65
|
+
serialize?: (props: SerializeProps) => string;
|
|
66
|
+
serializeString?: (props: SerializeProps<string>) => string;
|
|
67
|
+
serializeNumber?: (props: SerializeProps<number>) => string;
|
|
68
|
+
serializeBool?: (props: SerializeProps<boolean>) => string;
|
|
69
|
+
serializeDate?: (props: SerializeProps<Date>) => string;
|
|
70
|
+
serializeTime?: (props: SerializeProps<Time>) => string;
|
|
71
|
+
serializeArray?: (props: SerializeProps<any[]>) => string;
|
|
72
|
+
serializeNull?: (props: SerializeProps<null | undefined>) => string;
|
|
73
|
+
serializeFormulaError?: (props: SerializeProps<FormulaError>) => string;
|
|
74
|
+
serializeError?: (props: SerializeProps<Error>) => string;
|
|
75
|
+
deserialize?: (value: string, cell?: CellType) => CellType;
|
|
76
|
+
deserializeRaw?: (value: any, cell?: CellType) => CellType;
|
|
77
|
+
deserializeCallback?: (parsed: any, cell?: CellType) => CellType;
|
|
78
|
+
deserializeFirst?: (value: string, cell?: CellType) => CellPatchType<any>;
|
|
79
|
+
deserializeNumber?: (value: string, cell?: CellType) => CellPatchType<number | undefined>;
|
|
80
|
+
deserializeBool?: (value: string, cell?: CellType) => CellPatchType<boolean | undefined>;
|
|
81
|
+
deserializeDate?: (value: string, cell?: CellType) => CellPatchType<Date | undefined>;
|
|
82
|
+
deserializeTime?: (value: string, cell?: CellType) => CellPatchType<Time | undefined>;
|
|
83
|
+
deserializeAny?: (value: string, cell?: CellType) => CellPatchType<string | undefined>;
|
|
84
|
+
toScalar?: (props: ScalarProps) => Scalar;
|
|
85
|
+
toScalarString?: (props: ScalarProps<string>) => Scalar;
|
|
86
|
+
toScalarNumber?: (props: ScalarProps<number>) => Scalar;
|
|
87
|
+
toScalarBool?: (props: ScalarProps<boolean>) => Scalar;
|
|
88
|
+
toScalarDate?: (props: ScalarProps<Date>) => Scalar;
|
|
89
|
+
toScalarTime?: (props: ScalarProps<Time>) => Scalar;
|
|
90
|
+
toScalarArray?: (props: ScalarProps<any[]>) => Scalar;
|
|
91
|
+
toScalarNull?: (props: ScalarProps<null | undefined>) => Scalar;
|
|
92
|
+
getSelectOptions?: () => AutocompleteOption[];
|
|
93
|
+
getSelectFallback?: (props: SelectFallbackProps) => CellType | undefined;
|
|
94
|
+
select?: (props: SelectProps) => CellType | undefined;
|
|
95
|
+
serializeForClipboard?: (props: SerializeForClipboardProps) => string;
|
|
96
|
+
};
|
|
97
|
+
type PolicyProps = {
|
|
98
|
+
mixins?: PolicyMixinType[];
|
|
99
|
+
priority?: number;
|
|
100
|
+
};
|
|
101
|
+
export declare class Policy implements PolicyMixinType {
|
|
102
|
+
priority: number;
|
|
103
|
+
datetimeFormat: string;
|
|
104
|
+
dateFormat: string;
|
|
105
|
+
timeFormat: string;
|
|
106
|
+
decimalPrecision: number;
|
|
107
|
+
deserializeFunctions: ((value: string, cell?: CellType) => CellPatchType<any>)[];
|
|
108
|
+
deserializeCallback?: (parsed: any, cell?: CellType) => CellType;
|
|
109
|
+
deserializeFirst?: (value: string, cell?: CellType) => CellPatchType<any>;
|
|
110
|
+
renderCallback?: (rendered: any, props: RenderProps) => any;
|
|
111
|
+
constructor(props?: PolicyProps);
|
|
112
|
+
private registerDeserializeFunctions;
|
|
113
|
+
private applyMixins;
|
|
114
|
+
render(props: RenderProps): any;
|
|
115
|
+
renderString({ value }: RenderProps<string>): any;
|
|
116
|
+
renderBool({ value }: RenderProps<boolean>): any;
|
|
117
|
+
renderNumber({ value }: RenderProps<number>): any;
|
|
118
|
+
renderDate({ value }: RenderProps<Date>): any;
|
|
119
|
+
renderTime({ value }: RenderProps<Time>): any;
|
|
120
|
+
renderArray(props: RenderProps<any[]>): any;
|
|
121
|
+
renderObject({ value }: RenderProps<any>): any;
|
|
122
|
+
renderNull(_props: RenderProps<null | undefined>): any;
|
|
123
|
+
renderSheet({ value: childSheet, ...rest }: RenderProps<UserSheet>): any;
|
|
124
|
+
renderRowHeaderLabel(_n: number): string | null;
|
|
125
|
+
renderColHeaderLabel(_n: number): string | null;
|
|
126
|
+
toScalar(props: ScalarProps): Scalar;
|
|
127
|
+
toScalarString({ value }: ScalarProps<string>): Scalar;
|
|
128
|
+
toScalarNumber({ value }: ScalarProps<number>): Scalar;
|
|
129
|
+
toScalarBool({ value }: ScalarProps<boolean>): Scalar;
|
|
130
|
+
toScalarDate({ value }: ScalarProps<Date>): Scalar;
|
|
131
|
+
toScalarTime({ value }: ScalarProps<Time>): Scalar;
|
|
132
|
+
toScalarArray({ value, cell, sheet, point }: ScalarProps<any[]>): Scalar;
|
|
133
|
+
toScalarNull(_props: ScalarProps<null | undefined>): Scalar;
|
|
134
|
+
serialize({ value, cell, sheet, point }: SerializeProps): string;
|
|
135
|
+
serializeString({ value }: SerializeProps<string>): string;
|
|
136
|
+
serializeBool({ value }: SerializeProps<boolean>): string;
|
|
137
|
+
serializeNumber({ value }: SerializeProps<number>): string;
|
|
138
|
+
serializeDate({ value }: SerializeProps<Date>): string;
|
|
139
|
+
serializeTime({ value }: SerializeProps<Time>): string;
|
|
140
|
+
serializeArray(props: SerializeProps<any[]>): string;
|
|
141
|
+
serializeNull(_props: SerializeProps<null | undefined>): string;
|
|
142
|
+
serializeFormulaError({ value }: SerializeProps<FormulaError>): string;
|
|
143
|
+
serializeError(_props: SerializeProps<Error>): string;
|
|
144
|
+
serializeForClipboard(props: SerializeForClipboardProps): string;
|
|
145
|
+
deserializeValue(value: any, cell: CellType): CellType;
|
|
146
|
+
deserializeRaw(value: any, cell?: CellType): CellType;
|
|
147
|
+
deserialize(value: string, cell?: CellType): CellPatchType<any>;
|
|
148
|
+
deserializeAny(value: string, _cell?: CellType): CellPatchType<string | undefined>;
|
|
149
|
+
deserializeBool(value: string, _cell?: CellType): CellPatchType<boolean | undefined>;
|
|
150
|
+
deserializeNumber(value: string, _cell?: CellType): CellPatchType<number | undefined>;
|
|
151
|
+
deserializeTime(value: string, _cell?: CellType): CellPatchType<Time | undefined>;
|
|
152
|
+
deserializeDate(value: string, _cell?: CellType): CellPatchType<Date | undefined>;
|
|
153
|
+
getSelectFallback(_props: SelectFallbackProps): any;
|
|
154
|
+
getSelectOptions(): AutocompleteOption[];
|
|
155
|
+
select(props: SelectProps): CellType | undefined;
|
|
156
|
+
}
|
|
157
|
+
export type PolicyType = Policy;
|
|
158
|
+
export declare const DEFAULT_POLICY_NAME = "default";
|
|
159
|
+
export declare const nonePolicy: Policy;
|
|
160
|
+
export {};
|
|
161
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/policy/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGnC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAElE,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,GAAG,IAAI;IAC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Aa,CAAC,MAAM,GAAG,SAAS,CAAC;IAQrF,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC,IAAI,GAAG,SAAS,CAAC;IAOjF,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC,IAAI,GAAG,SAAS,CAAC;IAMjF,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,GAAG,GAAG;IAInD,gBAAgB,IAAI,kBAAkB,EAAE;IAIxC,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS;CAYxD;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,UAAU,QAA8B,CAAC"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { isSheet as h } from "../formula/functions/__base.js";
|
|
2
|
+
import o from "dayjs";
|
|
3
|
+
import { FormulaError as l } from "../formula/formula-error.js";
|
|
4
|
+
import { Pending as u } from "../sentinels.js";
|
|
5
|
+
import { Time as a } from "../lib/time.js";
|
|
6
|
+
import { parseDate as f } from "../lib/date.js";
|
|
7
|
+
const m = { true: !0, false: !1 };
|
|
8
|
+
class d {
|
|
9
|
+
constructor(r) {
|
|
10
|
+
this.priority = 0, this.datetimeFormat = "YYYY-MM-DD HH:mm:ss", this.dateFormat = "YYYY-MM-DD", this.timeFormat = "HH:mm:ss", this.decimalPrecision = 15, this.deserializeFunctions = [], this.priority = (r == null ? void 0 : r.priority) ?? 1, this.applyMixins(r == null ? void 0 : r.mixins), this.registerDeserializeFunctions();
|
|
11
|
+
}
|
|
12
|
+
registerDeserializeFunctions() {
|
|
13
|
+
this.deserializeFunctions = [
|
|
14
|
+
...this.deserializeFirst ? [this.deserializeFirst.bind(this)] : [],
|
|
15
|
+
this.deserializeNumber.bind(this),
|
|
16
|
+
this.deserializeTime.bind(this),
|
|
17
|
+
this.deserializeDate.bind(this),
|
|
18
|
+
this.deserializeBool.bind(this),
|
|
19
|
+
this.deserializeAny.bind(this)
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
applyMixins(r) {
|
|
23
|
+
if (r == null)
|
|
24
|
+
return;
|
|
25
|
+
const e = Object.getPrototypeOf(this);
|
|
26
|
+
for (const t of r)
|
|
27
|
+
for (const i in t)
|
|
28
|
+
e !== d.prototype && Object.prototype.hasOwnProperty.call(e, i) || (this[i] = t[i]);
|
|
29
|
+
}
|
|
30
|
+
// --- RENDER ---
|
|
31
|
+
render(r) {
|
|
32
|
+
let { value: e, cell: t } = r;
|
|
33
|
+
const { sheet: i, point: s } = r;
|
|
34
|
+
t == null && (t = i.getCell(s, { resolution: "EVALUATED", raise: !0 }) ?? {}, e = t.value);
|
|
35
|
+
let n;
|
|
36
|
+
if (u.is(e))
|
|
37
|
+
n = "";
|
|
38
|
+
else if (e == null)
|
|
39
|
+
n = this.renderNull({ ...r, value: e, cell: t });
|
|
40
|
+
else
|
|
41
|
+
switch (typeof e) {
|
|
42
|
+
case "object":
|
|
43
|
+
if (e instanceof Date)
|
|
44
|
+
n = this.renderDate({ ...r, value: e, cell: t });
|
|
45
|
+
else if (a.is(e))
|
|
46
|
+
n = this.renderTime({ value: a.ensure(e), cell: t, sheet: i, point: s });
|
|
47
|
+
else if (Array.isArray(e))
|
|
48
|
+
n = this.renderArray({ ...r, value: e, cell: t });
|
|
49
|
+
else {
|
|
50
|
+
if (l.is(e))
|
|
51
|
+
throw e;
|
|
52
|
+
h(e) ? n = this.renderSheet({ ...r, value: e, cell: t }) : n = this.renderObject({ ...r, value: e, cell: t });
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
case "string":
|
|
56
|
+
n = this.renderString({ ...r, value: e, cell: t });
|
|
57
|
+
break;
|
|
58
|
+
case "number":
|
|
59
|
+
n = this.renderNumber({ ...r, value: e, cell: t });
|
|
60
|
+
break;
|
|
61
|
+
case "boolean":
|
|
62
|
+
n = this.renderBool({ ...r, value: e, cell: t });
|
|
63
|
+
break;
|
|
64
|
+
case "function":
|
|
65
|
+
n = e();
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
n = "";
|
|
69
|
+
}
|
|
70
|
+
return this.renderCallback ? this.renderCallback(n, { ...r, value: e, cell: t }) : n;
|
|
71
|
+
}
|
|
72
|
+
renderString({ value: r }) {
|
|
73
|
+
return r;
|
|
74
|
+
}
|
|
75
|
+
renderBool({ value: r }) {
|
|
76
|
+
return r ? "TRUE" : "FALSE";
|
|
77
|
+
}
|
|
78
|
+
renderNumber({ value: r }) {
|
|
79
|
+
return isNaN(r) ? "NaN" : parseFloat(r.toPrecision(this.decimalPrecision));
|
|
80
|
+
}
|
|
81
|
+
renderDate({ value: r }) {
|
|
82
|
+
return r.getHours() + r.getMinutes() + r.getSeconds() === 0 ? o(r).format(this.dateFormat) : o(r).format(this.datetimeFormat);
|
|
83
|
+
}
|
|
84
|
+
renderTime({ value: r }) {
|
|
85
|
+
return r.stringify(this.timeFormat);
|
|
86
|
+
}
|
|
87
|
+
renderArray(r) {
|
|
88
|
+
let { value: e, cell: t } = r;
|
|
89
|
+
return e = e == null ? void 0 : e[0], Array.isArray(e) && (e = e[0]), this.render({ ...r, value: e, cell: t });
|
|
90
|
+
}
|
|
91
|
+
renderObject({ value: r }) {
|
|
92
|
+
return JSON.stringify(r);
|
|
93
|
+
}
|
|
94
|
+
renderNull(r) {
|
|
95
|
+
return "";
|
|
96
|
+
}
|
|
97
|
+
renderSheet({ value: r, ...e }) {
|
|
98
|
+
const t = e.sheet.getId(e.point), i = r.__raw__.strip({ raise: !0, at: t });
|
|
99
|
+
return this.render({ ...e, value: i });
|
|
100
|
+
}
|
|
101
|
+
renderRowHeaderLabel(r) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
renderColHeaderLabel(r) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
// --- TO SCALAR ---
|
|
108
|
+
toScalar(r) {
|
|
109
|
+
const { value: e, cell: t, sheet: i, point: s } = r;
|
|
110
|
+
if (!u.is(e)) {
|
|
111
|
+
if (e == null)
|
|
112
|
+
return this.toScalarNull({ value: e, cell: t, sheet: i, point: s });
|
|
113
|
+
switch (typeof e) {
|
|
114
|
+
case "string":
|
|
115
|
+
return this.toScalarString({ value: e, cell: t, sheet: i, point: s });
|
|
116
|
+
case "number":
|
|
117
|
+
return this.toScalarNumber({ value: e, cell: t, sheet: i, point: s });
|
|
118
|
+
case "boolean":
|
|
119
|
+
return this.toScalarBool({ value: e, cell: t, sheet: i, point: s });
|
|
120
|
+
case "object":
|
|
121
|
+
if (e instanceof Date)
|
|
122
|
+
return this.toScalarDate({ value: e, cell: t, sheet: i, point: s });
|
|
123
|
+
if (a.is(e))
|
|
124
|
+
return this.toScalarTime({ value: a.ensure(e), cell: t, sheet: i, point: s });
|
|
125
|
+
if (Array.isArray(e))
|
|
126
|
+
return this.toScalarArray({ value: e, cell: t, sheet: i, point: s });
|
|
127
|
+
if (l.is(e))
|
|
128
|
+
throw e;
|
|
129
|
+
return;
|
|
130
|
+
default:
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
toScalarString({ value: r }) {
|
|
136
|
+
return r;
|
|
137
|
+
}
|
|
138
|
+
toScalarNumber({ value: r }) {
|
|
139
|
+
return r == null ? void 0 : r.toPrecision(this.decimalPrecision);
|
|
140
|
+
}
|
|
141
|
+
toScalarBool({ value: r }) {
|
|
142
|
+
return r;
|
|
143
|
+
}
|
|
144
|
+
toScalarDate({ value: r }) {
|
|
145
|
+
return r.getHours() + r.getMinutes() + r.getSeconds() === 0 ? o(r).format(this.dateFormat) : o(r).format(this.datetimeFormat);
|
|
146
|
+
}
|
|
147
|
+
toScalarTime({ value: r }) {
|
|
148
|
+
return r.stringify(this.timeFormat);
|
|
149
|
+
}
|
|
150
|
+
toScalarArray({ value: r, cell: e, sheet: t, point: i }) {
|
|
151
|
+
let s = r == null ? void 0 : r[0];
|
|
152
|
+
return Array.isArray(s) && (s = s[0]), this.toScalar({ value: s, cell: e, sheet: t, point: i });
|
|
153
|
+
}
|
|
154
|
+
toScalarNull(r) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
// --- SERIALIZE ---
|
|
158
|
+
serialize({ value: r, cell: e, sheet: t, point: i }) {
|
|
159
|
+
return r === void 0 && (r = e == null ? void 0 : e.value), u.is(r) ? "" : r instanceof Date ? this.serializeDate({ value: r, cell: e, sheet: t, point: i }) : a.is(r) ? this.serializeTime({ value: a.ensure(r), cell: e, sheet: t, point: i }) : r == null ? this.serializeNull({ cell: e, sheet: t, point: i }) : Array.isArray(r) ? this.serializeArray({ value: r, cell: e, sheet: t, point: i }) : r instanceof l ? this.serializeFormulaError({ value: r, cell: e, sheet: t, point: i }) : r instanceof Error ? this.serializeError({ value: r, cell: e, sheet: t, point: i }) : r.toString();
|
|
160
|
+
}
|
|
161
|
+
serializeString({ value: r }) {
|
|
162
|
+
return r;
|
|
163
|
+
}
|
|
164
|
+
serializeBool({ value: r }) {
|
|
165
|
+
return r ? "true" : "false";
|
|
166
|
+
}
|
|
167
|
+
serializeNumber({ value: r }) {
|
|
168
|
+
return isNaN(r) ? "NaN" : parseFloat(r.toPrecision(this.decimalPrecision)).toString();
|
|
169
|
+
}
|
|
170
|
+
serializeDate({ value: r }) {
|
|
171
|
+
return r.getHours() + r.getMinutes() + r.getSeconds() === 0 ? o(r).format(this.dateFormat) : o(r).format(this.datetimeFormat);
|
|
172
|
+
}
|
|
173
|
+
serializeTime({ value: r }) {
|
|
174
|
+
return r.stringify(this.timeFormat);
|
|
175
|
+
}
|
|
176
|
+
serializeArray(r) {
|
|
177
|
+
let { value: e } = r;
|
|
178
|
+
return e = e == null ? void 0 : e[0], Array.isArray(e) && (e = e[0]), this.serialize({ ...r, value: e });
|
|
179
|
+
}
|
|
180
|
+
serializeNull(r) {
|
|
181
|
+
return "";
|
|
182
|
+
}
|
|
183
|
+
serializeFormulaError({ value: r }) {
|
|
184
|
+
return r.code;
|
|
185
|
+
}
|
|
186
|
+
serializeError(r) {
|
|
187
|
+
return "";
|
|
188
|
+
}
|
|
189
|
+
serializeForClipboard(r) {
|
|
190
|
+
const { point: e, sheet: t } = r;
|
|
191
|
+
return t.getSerializedValue({ point: e }) ?? "";
|
|
192
|
+
}
|
|
193
|
+
// --- DESERIALIZE ---
|
|
194
|
+
deserializeValue(r, e) {
|
|
195
|
+
try {
|
|
196
|
+
const t = typeof r != "string" ? this.deserializeRaw(r, e) : this.deserialize(r, e);
|
|
197
|
+
return this.deserializeCallback ? this.deserializeCallback(t, e) : t;
|
|
198
|
+
} catch (t) {
|
|
199
|
+
return { ...e, value: String(t) };
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
deserializeRaw(r, e) {
|
|
203
|
+
return a.is(r) && (r = a.ensure(r)), { ...e, value: r };
|
|
204
|
+
}
|
|
205
|
+
deserialize(r, e) {
|
|
206
|
+
if (r[0] === "'")
|
|
207
|
+
return { ...e, value: r };
|
|
208
|
+
for (let t = 0; t < this.deserializeFunctions.length; t++) {
|
|
209
|
+
const i = this.deserializeFunctions[t](r, e);
|
|
210
|
+
if ((i == null ? void 0 : i.value) !== void 0)
|
|
211
|
+
return { ...e, ...i };
|
|
212
|
+
}
|
|
213
|
+
return r === "" ? { ...e, value: void 0 } : { ...e, value: r };
|
|
214
|
+
}
|
|
215
|
+
deserializeAny(r, e) {
|
|
216
|
+
return r == null || r === "" ? { value: void 0 } : { value: r };
|
|
217
|
+
}
|
|
218
|
+
deserializeBool(r, e) {
|
|
219
|
+
return { value: m[r.toLowerCase()] };
|
|
220
|
+
}
|
|
221
|
+
deserializeNumber(r, e) {
|
|
222
|
+
return r.match(/^-?[\d.]+$/) != null && r.match(/\.$/) == null && (r.match(/\./g) || []).length <= 1 ? { value: parseFloat(r) } : { value: void 0 };
|
|
223
|
+
}
|
|
224
|
+
deserializeTime(r, e) {
|
|
225
|
+
return r.length < 3 || isNaN(r[r.length - 1]) ? { value: void 0 } : { value: a.parse(r) };
|
|
226
|
+
}
|
|
227
|
+
deserializeDate(r, e) {
|
|
228
|
+
return { value: f(r) };
|
|
229
|
+
}
|
|
230
|
+
// --- SELECT ---
|
|
231
|
+
getSelectFallback(r) {
|
|
232
|
+
return { value: null };
|
|
233
|
+
}
|
|
234
|
+
getSelectOptions() {
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
select(r) {
|
|
238
|
+
const { next: e, sheet: t, point: i } = r, s = this.getSelectOptions();
|
|
239
|
+
return s.length === 0 || s.some((c) => c.value === (e == null ? void 0 : e.value)) ? e : { ...e, ...this.getSelectFallback({ sheet: t, point: i, value: e == null ? void 0 : e.value }) };
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const A = "default", N = new d({ priority: 0 });
|
|
243
|
+
export {
|
|
244
|
+
A as DEFAULT_POLICY_NAME,
|
|
245
|
+
d as Policy,
|
|
246
|
+
N as nonePolicy
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sources":["../../src/policy/core.ts"],"sourcesContent":["import type { CellPatchType, CellType, OperationType, PointType } from '../types';\nimport type { Sheet, UserSheet } from '../lib/sheet';\nimport { isSheet } from '../formula/functions/__base';\nimport dayjs from 'dayjs';\nimport { FormulaError } from '../formula/formula-error';\nimport { Pending } from '../sentinels';\nimport { Time } from '../lib/time';\nimport { parseDate } from '../lib/date';\n\nexport type AutocompleteOption = {\n value: any;\n label?: any;\n keywords?: string[];\n tooltip?: any;\n};\n\nexport type SelectProps = {\n sheet: UserSheet;\n point: PointType;\n current?: CellType;\n next?: CellType;\n operation: OperationType;\n};\n\nexport type SerializeForClipboardProps = {\n sheet: UserSheet;\n point: PointType;\n};\n\nexport type SelectFallbackProps = {\n sheet: UserSheet;\n point: PointType;\n value: any;\n};\n\nexport type Scalar = string | number | boolean | null | undefined;\n\nexport type ScalarProps<T = any> = {\n value?: T;\n cell?: CellType<T>;\n sheet: Sheet;\n point: PointType;\n};\n\nexport type RenderProps<T = any> = {\n value: T;\n cell?: CellType<T>;\n sheet: Sheet;\n point: PointType;\n apply?: (sheet: UserSheet) => void;\n};\n\nexport type SerializeProps<T = any> = {\n value: T;\n cell?: CellType<T>;\n sheet: Sheet;\n point: PointType;\n};\n\nexport type PolicyMixinType = {\n // format settings\n datetimeFormat?: string;\n dateFormat?: string;\n timeFormat?: string;\n decimalPrecision?: number;\n\n // render\n render?: (props: RenderProps) => any;\n renderCallback?: (rendered: any, props: RenderProps) => any;\n renderString?: (props: RenderProps<string>) => any;\n renderNumber?: (props: RenderProps<number>) => any;\n renderBool?: (props: RenderProps<boolean>) => any;\n renderDate?: (props: RenderProps<Date>) => any;\n renderTime?: (props: RenderProps<Time>) => any;\n renderArray?: (props: RenderProps<any[]>) => any;\n renderObject?: (props: RenderProps<any>) => any;\n renderNull?: (props: RenderProps<null | undefined>) => any;\n renderSheet?: (props: RenderProps<UserSheet>) => any;\n renderRowHeaderLabel?: (n: number) => string | null;\n renderColHeaderLabel?: (n: number) => string | null;\n\n // serialize\n serialize?: (props: SerializeProps) => string;\n serializeString?: (props: SerializeProps<string>) => string;\n serializeNumber?: (props: SerializeProps<number>) => string;\n serializeBool?: (props: SerializeProps<boolean>) => string;\n serializeDate?: (props: SerializeProps<Date>) => string;\n serializeTime?: (props: SerializeProps<Time>) => string;\n serializeArray?: (props: SerializeProps<any[]>) => string;\n serializeNull?: (props: SerializeProps<null | undefined>) => string;\n serializeFormulaError?: (props: SerializeProps<FormulaError>) => string;\n serializeError?: (props: SerializeProps<Error>) => string;\n\n // deserialize\n deserialize?: (value: string, cell?: CellType) => CellType;\n deserializeRaw?: (value: any, cell?: CellType) => CellType;\n deserializeCallback?: (parsed: any, cell?: CellType) => CellType;\n // Priority slot: called before built-in deserializers when defined\n deserializeFirst?: (value: string, cell?: CellType) => CellPatchType<any>;\n // Built-in deserializers\n deserializeNumber?: (value: string, cell?: CellType) => CellPatchType<number | undefined>;\n deserializeBool?: (value: string, cell?: CellType) => CellPatchType<boolean | undefined>;\n deserializeDate?: (value: string, cell?: CellType) => CellPatchType<Date | undefined>;\n deserializeTime?: (value: string, cell?: CellType) => CellPatchType<Time | undefined>;\n deserializeAny?: (value: string, cell?: CellType) => CellPatchType<string | undefined>;\n\n // toScalar\n toScalar?: (props: ScalarProps) => Scalar;\n toScalarString?: (props: ScalarProps<string>) => Scalar;\n toScalarNumber?: (props: ScalarProps<number>) => Scalar;\n toScalarBool?: (props: ScalarProps<boolean>) => Scalar;\n toScalarDate?: (props: ScalarProps<Date>) => Scalar;\n toScalarTime?: (props: ScalarProps<Time>) => Scalar;\n toScalarArray?: (props: ScalarProps<any[]>) => Scalar;\n toScalarNull?: (props: ScalarProps<null | undefined>) => Scalar;\n\n // select\n getSelectOptions?: () => AutocompleteOption[];\n getSelectFallback?: (props: SelectFallbackProps) => CellType | undefined;\n select?: (props: SelectProps) => CellType | undefined;\n serializeForClipboard?: (props: SerializeForClipboardProps) => string;\n};\n\ntype PolicyProps = {\n mixins?: PolicyMixinType[];\n priority?: number;\n};\n\nconst BOOLS = { true: true, false: false } as { [s: string]: boolean };\n\nexport class Policy implements PolicyMixinType {\n public priority: number = 0;\n\n public datetimeFormat: string = 'YYYY-MM-DD HH:mm:ss';\n public dateFormat: string = 'YYYY-MM-DD';\n public timeFormat: string = 'HH:mm:ss';\n public decimalPrecision: number = 15;\n\n public deserializeFunctions: ((value: string, cell?: CellType) => CellPatchType<any>)[] = [];\n public deserializeCallback?: (parsed: any, cell?: CellType) => CellType;\n public deserializeFirst?: (value: string, cell?: CellType) => CellPatchType<any>;\n public renderCallback?: (rendered: any, props: RenderProps) => any;\n\n constructor(props?: PolicyProps) {\n this.priority = props?.priority ?? 1;\n this.applyMixins(props?.mixins);\n\n this.registerDeserializeFunctions();\n }\n\n private registerDeserializeFunctions(): void {\n this.deserializeFunctions = [\n ...(this.deserializeFirst ? [this.deserializeFirst.bind(this)] : []),\n this.deserializeNumber.bind(this),\n this.deserializeTime.bind(this),\n this.deserializeDate.bind(this),\n this.deserializeBool.bind(this),\n this.deserializeAny.bind(this),\n ];\n }\n\n private applyMixins(mixins?: PolicyMixinType[]) {\n if (mixins == null) {\n return;\n }\n const subclassProto = Object.getPrototypeOf(this);\n for (const mixin of mixins) {\n for (const key in mixin) {\n // Methods defined in a subclass take priority over mixins\n const overriddenBySubclass =\n subclassProto !== Policy.prototype && Object.prototype.hasOwnProperty.call(subclassProto, key);\n if (!overriddenBySubclass) {\n (this as any)[key] = (mixin as any)[key];\n }\n }\n }\n }\n\n // --- RENDER ---\n\n public render(props: RenderProps): any {\n let { value, cell } = props;\n const { sheet, point } = props;\n\n // Cell lookup: if cell not provided, resolve from sheet (entry-point usage)\n if (cell == null) {\n cell = sheet.getCell(point, { resolution: 'EVALUATED', raise: true }) ?? {};\n value = cell.value;\n }\n\n let rendered: any;\n\n if (Pending.is(value)) {\n rendered = '';\n } else if (value == null) {\n rendered = this.renderNull({ ...props, value: value as null | undefined, cell });\n } else {\n switch (typeof value) {\n case 'object':\n if (value instanceof Date) {\n rendered = this.renderDate({ ...props, value, cell });\n } else if (Time.is(value)) {\n rendered = this.renderTime({ value: Time.ensure(value), cell, sheet, point });\n } else if (Array.isArray(value)) {\n rendered = this.renderArray({ ...props, value, cell });\n } else if (FormulaError.is(value)) {\n throw value;\n } else if (isSheet(value)) {\n rendered = this.renderSheet({ ...props, value, cell });\n } else {\n rendered = this.renderObject({ ...props, value, cell });\n }\n break;\n case 'string':\n rendered = this.renderString({ ...props, value, cell });\n break;\n case 'number':\n rendered = this.renderNumber({ ...props, value, cell });\n break;\n case 'boolean':\n rendered = this.renderBool({ ...props, value, cell });\n break;\n case 'function':\n rendered = (value as () => any)();\n break;\n default:\n rendered = '';\n }\n }\n\n return this.renderCallback ? this.renderCallback(rendered, { ...props, value, cell }) : rendered;\n }\n\n public renderString({ value }: RenderProps<string>): any {\n return value!;\n }\n\n public renderBool({ value }: RenderProps<boolean>): any {\n return value ? 'TRUE' : 'FALSE';\n }\n\n public renderNumber({ value }: RenderProps<number>): any {\n if (isNaN(value!)) {\n return 'NaN';\n }\n return parseFloat(value!.toPrecision(this.decimalPrecision));\n }\n\n public renderDate({ value }: RenderProps<Date>): any {\n if (value!.getHours() + value!.getMinutes() + value!.getSeconds() === 0) {\n return dayjs(value).format(this.dateFormat);\n }\n return dayjs(value).format(this.datetimeFormat);\n }\n\n public renderTime({ value }: RenderProps<Time>): any {\n return value!.stringify(this.timeFormat);\n }\n\n public renderArray(props: RenderProps<any[]>): any {\n let { value, cell } = props;\n value = value?.[0];\n if (Array.isArray(value)) {\n value = value[0];\n }\n return this.render({ ...props, value, cell });\n }\n\n public renderObject({ value }: RenderProps<any>): any {\n return JSON.stringify(value);\n }\n\n public renderNull(_props: RenderProps<null | undefined>): any {\n return '';\n }\n\n public renderSheet({ value: childSheet, ...rest }: RenderProps<UserSheet>): any {\n const at = rest.sheet.getId(rest.point);\n const stripped = childSheet.__raw__.strip({ raise: true, at });\n return this.render({ ...rest, value: stripped });\n }\n\n public renderRowHeaderLabel(_n: number): string | null {\n return null;\n }\n\n public renderColHeaderLabel(_n: number): string | null {\n return null;\n }\n\n // --- TO SCALAR ---\n\n public toScalar(props: ScalarProps): Scalar {\n const { value, cell, sheet, point } = props;\n if (Pending.is(value)) {\n return undefined;\n }\n if (value == null) {\n return this.toScalarNull({ value: value as null | undefined, cell, sheet, point });\n }\n switch (typeof value) {\n case 'string':\n return this.toScalarString({ value, cell, sheet, point });\n case 'number':\n return this.toScalarNumber({ value, cell, sheet, point });\n case 'boolean':\n return this.toScalarBool({ value, cell, sheet, point });\n case 'object':\n if (value instanceof Date) {\n return this.toScalarDate({ value, cell, sheet, point });\n } else if (Time.is(value)) {\n return this.toScalarTime({ value: Time.ensure(value), cell, sheet, point });\n } else if (Array.isArray(value)) {\n return this.toScalarArray({ value, cell, sheet, point });\n } else if (FormulaError.is(value)) {\n throw value;\n }\n return undefined;\n default:\n return undefined;\n }\n }\n\n public toScalarString({ value }: ScalarProps<string>): Scalar {\n return value;\n }\n\n public toScalarNumber({ value }: ScalarProps<number>): Scalar {\n return value?.toPrecision(this.decimalPrecision);\n }\n\n public toScalarBool({ value }: ScalarProps<boolean>): Scalar {\n return value;\n }\n\n public toScalarDate({ value }: ScalarProps<Date>): Scalar {\n if (value!.getHours() + value!.getMinutes() + value!.getSeconds() === 0) {\n return dayjs(value).format(this.dateFormat);\n }\n return dayjs(value).format(this.datetimeFormat);\n }\n\n public toScalarTime({ value }: ScalarProps<Time>): Scalar {\n return value!.stringify(this.timeFormat);\n }\n\n public toScalarArray({ value, cell, sheet, point }: ScalarProps<any[]>): Scalar {\n let v = value?.[0];\n if (Array.isArray(v)) {\n v = v[0];\n }\n return this.toScalar({ value: v, cell, sheet, point });\n }\n\n public toScalarNull(_props: ScalarProps<null | undefined>): Scalar {\n return null;\n }\n\n // --- SERIALIZE ---\n\n public serialize({ value, cell, sheet, point }: SerializeProps): string {\n if (value === undefined) {\n value = cell?.value;\n }\n if (Pending.is(value)) {\n return '';\n }\n if (value instanceof Date) {\n return this.serializeDate({ value, cell, sheet, point } as SerializeProps<Date>);\n }\n if (Time.is(value)) {\n return this.serializeTime({ value: Time.ensure(value), cell, sheet, point } as SerializeProps<Time>);\n }\n if (value == null) {\n return this.serializeNull({ cell, sheet, point } as SerializeProps<null | undefined>);\n }\n if (Array.isArray(value)) {\n return this.serializeArray({ value, cell, sheet, point } as SerializeProps<any[]>);\n }\n if (value instanceof FormulaError) {\n return this.serializeFormulaError({ value, cell, sheet, point } as SerializeProps<FormulaError>);\n }\n if (value instanceof Error) {\n return this.serializeError({ value, cell, sheet, point } as SerializeProps<Error>);\n }\n return value.toString();\n }\n\n public serializeString({ value }: SerializeProps<string>): string {\n return value;\n }\n\n public serializeBool({ value }: SerializeProps<boolean>): string {\n return value ? 'true' : 'false';\n }\n\n public serializeNumber({ value }: SerializeProps<number>): string {\n if (isNaN(value)) {\n return 'NaN';\n }\n return parseFloat(value.toPrecision(this.decimalPrecision)).toString();\n }\n\n public serializeDate({ value }: SerializeProps<Date>): string {\n if (value!.getHours() + value!.getMinutes() + value!.getSeconds() === 0) {\n return dayjs(value).format(this.dateFormat);\n }\n return dayjs(value).format(this.datetimeFormat);\n }\n\n public serializeTime({ value }: SerializeProps<Time>): string {\n return value.stringify(this.timeFormat);\n }\n\n public serializeArray(props: SerializeProps<any[]>): string {\n let { value } = props;\n value = value?.[0];\n if (Array.isArray(value)) {\n value = value[0];\n }\n return this.serialize({ ...props, value });\n }\n\n public serializeNull(_props: SerializeProps<null | undefined>): string {\n return '';\n }\n\n public serializeFormulaError({ value }: SerializeProps<FormulaError>): string {\n return value.code;\n }\n\n public serializeError(_props: SerializeProps<Error>): string {\n return '';\n }\n\n public serializeForClipboard(props: SerializeForClipboardProps): string {\n const { point, sheet } = props;\n return sheet.getSerializedValue({ point }) ?? '';\n }\n\n // --- DESERIALIZE ---\n public deserializeValue(value: any, cell: CellType): CellType {\n try {\n const parsed = typeof value !== 'string' ? this.deserializeRaw(value, cell) : this.deserialize(value, cell);\n if (this.deserializeCallback) {\n return this.deserializeCallback(parsed, cell);\n }\n return parsed;\n } catch (e) {\n return { ...cell, value: String(e) };\n }\n }\n\n public deserializeRaw(value: any, cell?: CellType): CellType {\n if (Time.is(value)) {\n value = Time.ensure(value);\n }\n return { ...cell, value };\n }\n\n public deserialize(value: string, cell?: CellType): CellPatchType<any> {\n if (value[0] === \"'\") {\n return { ...cell, value };\n }\n for (let i = 0; i < this.deserializeFunctions.length; i++) {\n const result = this.deserializeFunctions[i](value, cell);\n if (result?.value !== undefined) {\n return { ...cell, ...result };\n }\n }\n if (value === '') {\n return { ...cell, value: undefined };\n }\n return { ...cell, value };\n }\n\n public deserializeAny(value: string, _cell?: CellType): CellPatchType<string | undefined> {\n if (value == null || value === '') {\n return { value: undefined };\n }\n return { value };\n }\n\n public deserializeBool(value: string, _cell?: CellType): CellPatchType<boolean | undefined> {\n return { value: BOOLS[value.toLowerCase()] };\n }\n\n public deserializeNumber(value: string, _cell?: CellType): CellPatchType<number | undefined> {\n const m = value.match(/^-?[\\d.]+$/);\n if (m != null && value.match(/\\.$/) == null && (value.match(/\\./g) || []).length <= 1) {\n return { value: parseFloat(value) };\n }\n return { value: undefined };\n }\n\n public deserializeTime(value: string, _cell?: CellType): CellPatchType<Time | undefined> {\n if (value.length < 3 || isNaN(value[value.length - 1] as unknown as number)) {\n return { value: undefined };\n }\n return { value: Time.parse(value) };\n }\n\n public deserializeDate(value: string, _cell?: CellType): CellPatchType<Date | undefined> {\n return { value: parseDate(value) };\n }\n\n // --- SELECT ---\n\n public getSelectFallback(_props: SelectFallbackProps): any {\n return { value: null };\n }\n\n public getSelectOptions(): AutocompleteOption[] {\n return [];\n }\n\n public select(props: SelectProps): CellType | undefined {\n const { next, sheet, point } = props;\n const options = this.getSelectOptions();\n if (options.length === 0) {\n return next;\n }\n const ok = options.some((o) => o.value === next?.value);\n if (!ok) {\n return { ...next, ...this.getSelectFallback({ sheet, point, value: next?.value }) };\n }\n return next;\n }\n}\n\nexport type PolicyType = Policy;\nexport const DEFAULT_POLICY_NAME = 'default';\nexport const nonePolicy = new Policy({ priority: 0 });\n"],"names":["BOOLS","Policy","props","mixins","subclassProto","mixin","key","value","cell","sheet","point","rendered","Pending","Time","FormulaError","isSheet","dayjs","_props","childSheet","rest","at","stripped","_n","v","parsed","e","i","result","_cell","parseDate","next","options","o","DEFAULT_POLICY_NAME","nonePolicy"],"mappings":";;;;;;AAgIA,MAAMA,IAAQ,EAAE,MAAM,IAAM,OAAO,GAAM;AAElC,MAAMC,EAAkC;AAAA,EAa7C,YAAYC,GAAqB;AAZjC,SAAO,WAAmB,GAE1B,KAAO,iBAAyB,uBAChC,KAAO,aAAqB,cAC5B,KAAO,aAAqB,YAC5B,KAAO,mBAA2B,IAElC,KAAO,uBAAmF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C;AAgB3D,eAAO,MAAM,4BAA4B,EAAE,eAAiD,CAAC;AAC7F,eAAO,MAAM,iCAAiC,EAAE,eAAiD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const t = (o) => ({
|
|
2
|
+
renderNumber({ value: r }) {
|
|
3
|
+
if (r == null || isNaN(r))
|
|
4
|
+
return "NaN";
|
|
5
|
+
const [e, n] = String(parseFloat(r.toPrecision(this.decimalPrecision))).split("."), i = e.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, `$1${o}`);
|
|
6
|
+
return n == null ? i : `${i}.${n}`;
|
|
7
|
+
}
|
|
8
|
+
}), a = t(","), s = t(" ");
|
|
9
|
+
export {
|
|
10
|
+
a as ThousandSeparatorPolicyMixin,
|
|
11
|
+
s as ThousandSpaceSeparatorPolicyMixin
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=thousand_separator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thousand_separator.js","sources":["../../src/policy/thousand_separator.ts"],"sourcesContent":["import type { PolicyMixinType, RenderProps } from './core';\n\nconst makeThousandSeparatorMixin = (sep: string): PolicyMixinType => ({\n renderNumber({ value }: RenderProps<number>): any {\n if (value == null || isNaN(value)) {\n return 'NaN';\n }\n const [int, fraction] = String(parseFloat(value.toPrecision(this.decimalPrecision))).split('.');\n const result = int.replace(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/g, `$1${sep}`);\n if (fraction == null) {\n return result;\n }\n return `${result}.${fraction}`;\n },\n});\n\nexport const ThousandSeparatorPolicyMixin: PolicyMixinType = makeThousandSeparatorMixin(',');\nexport const ThousandSpaceSeparatorPolicyMixin: PolicyMixinType = makeThousandSeparatorMixin(' ');\n"],"names":["makeThousandSeparatorMixin","sep","value","int","fraction","result","ThousandSeparatorPolicyMixin","ThousandSpaceSeparatorPolicyMixin"],"mappings":"AAEA,MAAMA,IAA6B,CAACC,OAAkC;AAAA,EACpE,aAAa,EAAE,OAAAC,KAAmC;AAChD,QAAIA,KAAS,QAAQ,MAAMA,CAAK;AACvB,aAAA;AAET,UAAM,CAACC,GAAKC,CAAQ,IAAI,OAAO,WAAWF,EAAM,YAAY,KAAK,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,GACxFG,IAASF,EAAI,QAAQ,4BAA4B,KAAKF,CAAG,EAAE;AACjE,WAAIG,KAAY,OACPC,IAEF,GAAGA,CAAM,IAAID,CAAQ;AAAA,EAAA;AAEhC,IAEaE,IAAgDN,EAA2B,GAAG,GAC9EO,IAAqDP,EAA2B,GAAG;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare class Sentinel {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
readonly __gsType: "Sentinel";
|
|
4
|
+
constructor(code: string);
|
|
5
|
+
is(obj: any): obj is this;
|
|
6
|
+
static is(obj: any, code?: string): obj is Sentinel;
|
|
7
|
+
}
|
|
8
|
+
export declare const SOLVING: Sentinel;
|
|
9
|
+
/**
|
|
10
|
+
* Sentinel value representing an in-flight async formula computation.
|
|
11
|
+
* Cells whose solved cache contains a Pending will render a loading indicator.
|
|
12
|
+
* Dependent cells that encounter a Pending value also become pending.
|
|
13
|
+
*/
|
|
14
|
+
export declare class Pending<T = unknown> {
|
|
15
|
+
private readonly timestamp;
|
|
16
|
+
readonly promise: Promise<T>;
|
|
17
|
+
readonly __gsType: "Pending";
|
|
18
|
+
constructor(promise: Promise<T>);
|
|
19
|
+
static is(obj: any): obj is Pending;
|
|
20
|
+
toString(): string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returned by functions that want to spill a 2D result into adjacent cells.
|
|
24
|
+
*
|
|
25
|
+
* Usage in a function:
|
|
26
|
+
* return new Spilling([[1, 2], [3, 4]]);
|
|
27
|
+
*
|
|
28
|
+
* The solver detects Spilling via `Spilling.is()` and calls
|
|
29
|
+
* `sheet.spill(origin, result.matrix)` to perform obstruction checks
|
|
30
|
+
* and write values into the solvedCaches.
|
|
31
|
+
*/
|
|
32
|
+
export declare class Spilling {
|
|
33
|
+
readonly __gsType: "Spilling";
|
|
34
|
+
/** The 2D matrix of resolved values. matrix[row][col] */
|
|
35
|
+
readonly matrix: any[][];
|
|
36
|
+
constructor(matrix: any[] | any[][]);
|
|
37
|
+
private ensure2D;
|
|
38
|
+
static is(obj: any): obj is Spilling;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=sentinels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentinels.d.ts","sourceRoot":"","sources":["../src/sentinels.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;aAES,IAAI,EAAE,MAAM;IADxC,SAAgB,QAAQ,EAAG,UAAU,CAAU;gBACnB,IAAI,EAAE,MAAM;IAExC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,IAAI;IAIzB,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,IAAI,QAAQ;CAOpD;AAED,eAAO,MAAM,OAAO,UAA0B,CAAC;AAE/C;;;;GAIG;AACH,qBAAa,OAAO,CAAC,CAAC,GAAG,OAAO;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC,SAAgB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpC,SAAgB,QAAQ,EAAG,SAAS,CAAU;gBAElC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAK/B,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,OAAO;IAInC,QAAQ,IAAI,MAAM;CAGnB;AAED;;;;;;;;;GASG;AACH,qBAAa,QAAQ;IACnB,SAAgB,QAAQ,EAAG,UAAU,CAAU;IAC/C,yDAAyD;IACzD,SAAgB,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;gBAEpB,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,EAAE;IAInC,OAAO,CAAC,QAAQ;IAahB,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,QAAQ;CAGrC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
class t {
|
|
2
|
+
constructor(s) {
|
|
3
|
+
this.code = s, this.__gsType = "Sentinel";
|
|
4
|
+
}
|
|
5
|
+
is(s) {
|
|
6
|
+
return t.is(s, this.code);
|
|
7
|
+
}
|
|
8
|
+
static is(s, n) {
|
|
9
|
+
return s instanceof t || (s == null ? void 0 : s.__gsType) === "Sentinel" ? n == null || s.code === n : !1;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const c = new t("solving");
|
|
13
|
+
class e {
|
|
14
|
+
constructor(s) {
|
|
15
|
+
this.__gsType = "Pending", this.promise = s, this.timestamp = Date.now();
|
|
16
|
+
}
|
|
17
|
+
static is(s) {
|
|
18
|
+
return s instanceof e || (s == null ? void 0 : s.__gsType) === "Pending";
|
|
19
|
+
}
|
|
20
|
+
toString() {
|
|
21
|
+
return `<Pending #${this.timestamp}>`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class i {
|
|
25
|
+
constructor(s) {
|
|
26
|
+
this.__gsType = "Spilling", this.matrix = this.ensure2D(s);
|
|
27
|
+
}
|
|
28
|
+
ensure2D(s) {
|
|
29
|
+
return s.length === 0 ? [] : Array.isArray(s[0]) ? s : [s];
|
|
30
|
+
}
|
|
31
|
+
static is(s) {
|
|
32
|
+
return s instanceof i || (s == null ? void 0 : s.__gsType) === "Spilling";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
e as Pending,
|
|
37
|
+
c as SOLVING,
|
|
38
|
+
t as Sentinel,
|
|
39
|
+
i as Spilling
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=sentinels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentinels.js","sources":["../src/sentinels.ts"],"sourcesContent":["export class Sentinel {\n public readonly __gsType = 'Sentinel' as const;\n constructor(public readonly code: string) {}\n\n is(obj: any): obj is this {\n return Sentinel.is(obj, this.code);\n }\n\n static is(obj: any, code?: string): obj is Sentinel {\n const match = obj instanceof Sentinel || obj?.__gsType === 'Sentinel';\n if (!match) {\n return false;\n }\n return code == null || obj.code === code;\n }\n}\n\nexport const SOLVING = new Sentinel('solving');\n\n/**\n * Sentinel value representing an in-flight async formula computation.\n * Cells whose solved cache contains a Pending will render a loading indicator.\n * Dependent cells that encounter a Pending value also become pending.\n */\nexport class Pending<T = unknown> {\n private readonly timestamp: number;\n\n public readonly promise: Promise<T>;\n public readonly __gsType = 'Pending' as const;\n\n constructor(promise: Promise<T>) {\n this.promise = promise;\n this.timestamp = Date.now();\n }\n\n static is(obj: any): obj is Pending {\n return obj instanceof Pending || obj?.__gsType === 'Pending';\n }\n\n toString(): string {\n return `<Pending #${this.timestamp}>`;\n }\n}\n\n/**\n * Returned by functions that want to spill a 2D result into adjacent cells.\n *\n * Usage in a function:\n * return new Spilling([[1, 2], [3, 4]]);\n *\n * The solver detects Spilling via `Spilling.is()` and calls\n * `sheet.spill(origin, result.matrix)` to perform obstruction checks\n * and write values into the solvedCaches.\n */\nexport class Spilling {\n public readonly __gsType = 'Spilling' as const;\n /** The 2D matrix of resolved values. matrix[row][col] */\n public readonly matrix: any[][];\n\n constructor(matrix: any[] | any[][]) {\n this.matrix = this.ensure2D(matrix);\n }\n\n private ensure2D(matrix: any[] | any[][]): any[][] {\n if (matrix.length === 0) {\n return [];\n }\n if (Array.isArray(matrix[0])) {\n return matrix as any[][];\n }\n // 1D array is treated as a single row (horizontal expansion).\n // e.g. [1, 2, 3] → [[1, 2, 3]]\n // To expand vertically instead, use: matrix.map(v => [v])\n return [matrix as any[]];\n }\n\n static is(obj: any): obj is Spilling {\n return obj instanceof Spilling || obj?.__gsType === 'Spilling';\n }\n}\n"],"names":["Sentinel","code","obj","SOLVING","Pending","promise","Spilling","matrix"],"mappings":"AAAO,MAAMA,EAAS;AAAA,EAEpB,YAA4BC,GAAc;AAAd,SAAA,OAAAA,GAD5B,KAAgB,WAAW;AAAA,EAAA;AAAA,EAG3B,GAAGC,GAAuB;AACxB,WAAOF,EAAS,GAAGE,GAAK,KAAK,IAAI;AAAA,EAAA;AAAA,EAGnC,OAAO,GAAGA,GAAUD,GAAgC;AAElD,WADcC,aAAeF,MAAYE,KAAA,gBAAAA,EAAK,cAAa,aAIpDD,KAAQ,QAAQC,EAAI,SAASD,IAF3B;AAAA,EAE2B;AAExC;AAEa,MAAAE,IAAU,IAAIH,EAAS,SAAS;AAOtC,MAAMI,EAAqB;AAAA,EAMhC,YAAYC,GAAqB;AAFjC,SAAgB,WAAW,WAGzB,KAAK,UAAUA,GACV,KAAA,YAAY,KAAK,IAAI;AAAA,EAAA;AAAA,EAG5B,OAAO,GAAGH,GAA0B;AAC3B,WAAAA,aAAeE,MAAWF,KAAA,gBAAAA,EAAK,cAAa;AAAA,EAAA;AAAA,EAGrD,WAAmB;AACV,WAAA,aAAa,KAAK,SAAS;AAAA,EAAA;AAEtC;AAYO,MAAMI,EAAS;AAAA,EAKpB,YAAYC,GAAyB;AAJrC,SAAgB,WAAW,YAKpB,KAAA,SAAS,KAAK,SAASA,CAAM;AAAA,EAAA;AAAA,EAG5B,SAASA,GAAkC;AAC7C,WAAAA,EAAO,WAAW,IACb,CAAC,IAEN,MAAM,QAAQA,EAAO,CAAC,CAAC,IAClBA,IAKF,CAACA,CAAe;AAAA,EAAA;AAAA,EAGzB,OAAO,GAAGL,GAA2B;AAC5B,WAAAA,aAAeI,MAAYJ,KAAA,gBAAAA,EAAK,cAAa;AAAA,EAAA;AAExD;"}
|