@gridsheet/react-core 1.4.0 → 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/Cell.d.ts +3 -3
- package/dist/components/Cell.d.ts.map +1 -1
- package/dist/components/ContextMenu.d.ts +19 -2
- package/dist/components/ContextMenu.d.ts.map +1 -1
- package/dist/components/Editor.d.ts +4 -4
- package/dist/components/Editor.d.ts.map +1 -1
- package/dist/components/Emitter.d.ts +2 -2
- package/dist/components/Emitter.d.ts.map +1 -1
- package/dist/components/Fixed.d.ts +3 -3
- package/dist/components/Fixed.d.ts.map +1 -1
- package/dist/components/FormulaBar.d.ts +1 -2
- package/dist/components/FormulaBar.d.ts.map +1 -1
- package/dist/components/GridSheet.d.ts +1 -2
- package/dist/components/GridSheet.d.ts.map +1 -1
- package/dist/components/HeaderCellLeft.d.ts +2 -2
- package/dist/components/HeaderCellLeft.d.ts.map +1 -1
- package/dist/components/HeaderCellTop.d.ts +2 -2
- package/dist/components/HeaderCellTop.d.ts.map +1 -1
- package/dist/components/PluginBase.d.ts +4 -4
- package/dist/components/PluginBase.d.ts.map +1 -1
- package/dist/components/Resizer.d.ts +1 -2
- package/dist/components/Resizer.d.ts.map +1 -1
- package/dist/components/ScrollHandle.d.ts +9 -0
- package/dist/components/ScrollHandle.d.ts.map +1 -0
- package/dist/components/SearchBar.d.ts +1 -2
- package/dist/components/SearchBar.d.ts.map +1 -1
- package/dist/components/StoreObserver.d.ts +8 -0
- package/dist/components/StoreObserver.d.ts.map +1 -0
- package/dist/components/Tabular.d.ts +2 -3
- package/dist/components/Tabular.d.ts.map +1 -1
- package/dist/components/hooks.d.ts +2 -0
- package/dist/components/hooks.d.ts.map +1 -1
- package/dist/components/svg/AddIcon.d.ts +1 -2
- package/dist/components/svg/AddIcon.d.ts.map +1 -1
- package/dist/components/svg/Base.d.ts +4 -4
- package/dist/components/svg/Base.d.ts.map +1 -1
- package/dist/components/svg/CloseIcon.d.ts +1 -2
- package/dist/components/svg/CloseIcon.d.ts.map +1 -1
- package/dist/components/svg/SearchIcon.d.ts +1 -2
- package/dist/components/svg/SearchIcon.d.ts.map +1 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/formula/evaluator.d.ts +21 -10
- package/dist/formula/evaluator.d.ts.map +1 -1
- package/dist/formula/functions/__base.d.ts.map +1 -1
- package/dist/formula/functions/__utils.d.ts.map +1 -1
- package/dist/formula/functions/abs.d.ts.map +1 -1
- package/dist/formula/functions/acos.d.ts.map +1 -1
- package/dist/formula/functions/add.d.ts.map +1 -1
- package/dist/formula/functions/and.d.ts.map +1 -1
- package/dist/formula/functions/asin.d.ts.map +1 -1
- package/dist/formula/functions/atan.d.ts.map +1 -1
- package/dist/formula/functions/atan2.d.ts.map +1 -1
- package/dist/formula/functions/average.d.ts.map +1 -1
- package/dist/formula/functions/col.d.ts.map +1 -1
- package/dist/formula/functions/concat.d.ts.map +1 -1
- package/dist/formula/functions/concatenate.d.ts.map +1 -1
- package/dist/formula/functions/cos.d.ts.map +1 -1
- package/dist/formula/functions/count.d.ts.map +1 -1
- package/dist/formula/functions/counta.d.ts.map +1 -1
- package/dist/formula/functions/countif.d.ts.map +1 -1
- package/dist/formula/functions/divide.d.ts.map +1 -1
- package/dist/formula/functions/eq.d.ts.map +1 -1
- package/dist/formula/functions/exp.d.ts.map +1 -1
- package/dist/formula/functions/gt.d.ts.map +1 -1
- package/dist/formula/functions/gte.d.ts.map +1 -1
- package/dist/formula/functions/hlookup.d.ts.map +1 -1
- package/dist/formula/functions/if.d.ts.map +1 -1
- package/dist/formula/functions/iferror.d.ts.map +1 -1
- package/dist/formula/functions/len.d.ts.map +1 -1
- package/dist/formula/functions/lenb.d.ts.map +1 -1
- package/dist/formula/functions/ln.d.ts.map +1 -1
- package/dist/formula/functions/log.d.ts.map +1 -1
- package/dist/formula/functions/log10.d.ts.map +1 -1
- package/dist/formula/functions/lt.d.ts.map +1 -1
- package/dist/formula/functions/lte.d.ts.map +1 -1
- package/dist/formula/functions/max.d.ts.map +1 -1
- package/dist/formula/functions/min.d.ts.map +1 -1
- package/dist/formula/functions/minus.d.ts.map +1 -1
- package/dist/formula/functions/mod.d.ts.map +1 -1
- package/dist/formula/functions/multiply.d.ts.map +1 -1
- package/dist/formula/functions/ne.d.ts.map +1 -1
- package/dist/formula/functions/not.d.ts.map +1 -1
- package/dist/formula/functions/now.d.ts.map +1 -1
- package/dist/formula/functions/or.d.ts.map +1 -1
- package/dist/formula/functions/pi.d.ts.map +1 -1
- package/dist/formula/functions/power.d.ts.map +1 -1
- package/dist/formula/functions/product.d.ts.map +1 -1
- package/dist/formula/functions/radians.d.ts.map +1 -1
- package/dist/formula/functions/rand.d.ts.map +1 -1
- package/dist/formula/functions/round.d.ts.map +1 -1
- package/dist/formula/functions/rounddown.d.ts.map +1 -1
- package/dist/formula/functions/roundup.d.ts.map +1 -1
- package/dist/formula/functions/row.d.ts.map +1 -1
- package/dist/formula/functions/sin.d.ts.map +1 -1
- package/dist/formula/functions/sqrt.d.ts.map +1 -1
- package/dist/formula/functions/sum.d.ts.map +1 -1
- package/dist/formula/functions/sumif.d.ts.map +1 -1
- package/dist/formula/functions/tan.d.ts.map +1 -1
- package/dist/formula/functions/uminus.d.ts.map +1 -1
- package/dist/formula/functions/vlookup.d.ts.map +1 -1
- package/dist/formula/mapping.d.ts.map +1 -1
- package/dist/formula/solver.d.ts.map +1 -1
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9914 -20
- package/dist/index.js.map +1 -1
- package/dist/lib/autofill.d.ts +2 -2
- package/dist/lib/autofill.d.ts.map +1 -1
- package/dist/lib/clipboard.d.ts.map +1 -1
- package/dist/lib/converters.d.ts +3 -4
- package/dist/lib/converters.d.ts.map +1 -1
- package/dist/lib/events.d.ts +6 -0
- package/dist/lib/events.d.ts.map +1 -0
- package/dist/lib/hub.d.ts +39 -0
- package/dist/lib/hub.d.ts.map +1 -0
- package/dist/lib/input.d.ts +12 -2
- package/dist/lib/input.d.ts.map +1 -1
- package/dist/lib/operation.d.ts +27 -0
- package/dist/lib/operation.d.ts.map +1 -0
- package/dist/lib/palette.d.ts +1 -1
- package/dist/lib/palette.d.ts.map +1 -1
- package/dist/lib/paste.d.ts +4 -0
- package/dist/lib/paste.d.ts.map +1 -0
- package/dist/lib/sheet.d.ts +3 -0
- package/dist/lib/sheet.d.ts.map +1 -0
- package/dist/lib/structs.d.ts +7 -3
- package/dist/lib/structs.d.ts.map +1 -1
- package/dist/lib/table.d.ts +137 -76
- package/dist/lib/table.d.ts.map +1 -1
- package/dist/lib/time.d.ts +1 -0
- package/dist/lib/time.d.ts.map +1 -1
- package/dist/lib/virtualization.d.ts +3 -2
- package/dist/lib/virtualization.d.ts.map +1 -1
- package/dist/parsers/core.d.ts.map +1 -1
- package/dist/policy/core.d.ts +47 -0
- package/dist/policy/core.d.ts.map +1 -0
- package/dist/renderers/checkbox.d.ts +2 -2
- package/dist/renderers/checkbox.d.ts.map +1 -1
- package/dist/renderers/core.d.ts +36 -25
- package/dist/renderers/core.d.ts.map +1 -1
- package/dist/renderers/thousand_separator.d.ts.map +1 -1
- package/dist/store/actions.d.ts +25 -49
- package/dist/store/actions.d.ts.map +1 -1
- package/dist/store/dispatchers.d.ts +13 -0
- package/dist/store/dispatchers.d.ts.map +1 -0
- package/dist/store/helpers.d.ts +1 -0
- package/dist/store/helpers.d.ts.map +1 -1
- package/dist/store/index.d.ts +1 -2
- package/dist/store/index.d.ts.map +1 -1
- package/dist/styles/embedder.d.ts.map +1 -1
- package/dist/styles/minified.d.ts +2 -2
- package/dist/styles/minified.d.ts.map +1 -1
- package/dist/types.d.ts +108 -50
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +7 -10
- package/dist/_virtual/_commonjsHelpers.js +0 -7
- package/dist/_virtual/_commonjsHelpers.js.map +0 -1
- package/dist/_virtual/dayjs.min.js +0 -8
- package/dist/_virtual/dayjs.min.js.map +0 -1
- package/dist/_virtual/dayjs.min2.js +0 -5
- package/dist/_virtual/dayjs.min2.js.map +0 -1
- package/dist/_virtual/timezone.js +0 -8
- package/dist/_virtual/timezone.js.map +0 -1
- package/dist/_virtual/timezone2.js +0 -5
- package/dist/_virtual/timezone2.js.map +0 -1
- package/dist/_virtual/utc.js +0 -8
- package/dist/_virtual/utc.js.map +0 -1
- package/dist/_virtual/utc2.js +0 -5
- package/dist/_virtual/utc2.js.map +0 -1
- package/dist/components/Cell.js +0 -234
- package/dist/components/Cell.js.map +0 -1
- package/dist/components/ContextMenu.js +0 -297
- package/dist/components/ContextMenu.js.map +0 -1
- package/dist/components/Editor.js +0 -464
- package/dist/components/Editor.js.map +0 -1
- package/dist/components/Emitter.js +0 -26
- package/dist/components/Emitter.js.map +0 -1
- package/dist/components/Fixed.js +0 -17
- package/dist/components/Fixed.js.map +0 -1
- package/dist/components/FormulaBar.js +0 -150
- package/dist/components/FormulaBar.js.map +0 -1
- package/dist/components/GridSheet.js +0 -247
- package/dist/components/GridSheet.js.map +0 -1
- package/dist/components/HeaderCellLeft.js +0 -131
- package/dist/components/HeaderCellLeft.js.map +0 -1
- package/dist/components/HeaderCellTop.js +0 -132
- package/dist/components/HeaderCellTop.js.map +0 -1
- package/dist/components/PluginBase.js +0 -35
- package/dist/components/PluginBase.js.map +0 -1
- package/dist/components/Resizer.js +0 -98
- package/dist/components/Resizer.js.map +0 -1
- package/dist/components/SearchBar.js +0 -108
- package/dist/components/SearchBar.js.map +0 -1
- package/dist/components/SheetProvider.d.ts +0 -30
- package/dist/components/SheetProvider.d.ts.map +0 -1
- package/dist/components/SheetProvider.js +0 -59
- package/dist/components/SheetProvider.js.map +0 -1
- package/dist/components/StoreInitializer.d.ts +0 -4
- package/dist/components/StoreInitializer.d.ts.map +0 -1
- package/dist/components/StoreInitializer.js +0 -84
- package/dist/components/StoreInitializer.js.map +0 -1
- package/dist/components/Tabular.js +0 -317
- package/dist/components/Tabular.js.map +0 -1
- package/dist/components/Toggle.d.ts +0 -12
- package/dist/components/Toggle.d.ts.map +0 -1
- package/dist/components/hooks.js +0 -15
- package/dist/components/hooks.js.map +0 -1
- package/dist/components/svg/Base.js +0 -24
- package/dist/components/svg/Base.js.map +0 -1
- package/dist/components/svg/CloseIcon.js +0 -13
- package/dist/components/svg/CloseIcon.js.map +0 -1
- package/dist/components/svg/SearchIcon.js +0 -13
- package/dist/components/svg/SearchIcon.js.map +0 -1
- package/dist/constants.js +0 -43
- package/dist/constants.js.map +0 -1
- package/dist/formula/evaluator.js +0 -679
- package/dist/formula/evaluator.js.map +0 -1
- package/dist/formula/functions/__base.js +0 -20
- package/dist/formula/functions/__base.js.map +0 -1
- package/dist/formula/functions/__utils.js +0 -145
- package/dist/formula/functions/__utils.js.map +0 -1
- package/dist/formula/functions/abs.js +0 -24
- package/dist/formula/functions/abs.js.map +0 -1
- package/dist/formula/functions/abs.spec.d.ts +0 -2
- package/dist/formula/functions/abs.spec.d.ts.map +0 -1
- package/dist/formula/functions/acos.js +0 -32
- package/dist/formula/functions/acos.js.map +0 -1
- package/dist/formula/functions/add.js +0 -57
- package/dist/formula/functions/add.js.map +0 -1
- package/dist/formula/functions/and.js +0 -28
- package/dist/formula/functions/and.js.map +0 -1
- package/dist/formula/functions/asin.js +0 -32
- package/dist/formula/functions/asin.js.map +0 -1
- package/dist/formula/functions/atan.js +0 -29
- package/dist/formula/functions/atan.js.map +0 -1
- package/dist/formula/functions/atan2.js +0 -35
- package/dist/formula/functions/atan2.js.map +0 -1
- package/dist/formula/functions/average.js +0 -44
- package/dist/formula/functions/average.js.map +0 -1
- package/dist/formula/functions/col.js +0 -34
- package/dist/formula/functions/col.js.map +0 -1
- package/dist/formula/functions/col.spec.d.ts +0 -2
- package/dist/formula/functions/col.spec.d.ts.map +0 -1
- package/dist/formula/functions/concat.js +0 -27
- package/dist/formula/functions/concat.js.map +0 -1
- package/dist/formula/functions/concatenate.js +0 -28
- package/dist/formula/functions/concatenate.js.map +0 -1
- package/dist/formula/functions/cos.js +0 -29
- package/dist/formula/functions/cos.js.map +0 -1
- package/dist/formula/functions/count.js +0 -38
- package/dist/formula/functions/count.js.map +0 -1
- package/dist/formula/functions/counta.js +0 -38
- package/dist/formula/functions/counta.js.map +0 -1
- package/dist/formula/functions/countif.js +0 -32
- package/dist/formula/functions/countif.js.map +0 -1
- package/dist/formula/functions/countif.spec.d.ts +0 -2
- package/dist/formula/functions/countif.spec.d.ts.map +0 -1
- package/dist/formula/functions/divide.js +0 -33
- package/dist/formula/functions/divide.js.map +0 -1
- package/dist/formula/functions/eq.js +0 -29
- package/dist/formula/functions/eq.js.map +0 -1
- package/dist/formula/functions/eq.spec.d.ts +0 -2
- package/dist/formula/functions/eq.spec.d.ts.map +0 -1
- package/dist/formula/functions/exp.js +0 -29
- package/dist/formula/functions/exp.js.map +0 -1
- package/dist/formula/functions/gt.js +0 -29
- package/dist/formula/functions/gt.js.map +0 -1
- package/dist/formula/functions/gte.js +0 -29
- package/dist/formula/functions/gte.js.map +0 -1
- package/dist/formula/functions/hlookup.js +0 -75
- package/dist/formula/functions/hlookup.js.map +0 -1
- package/dist/formula/functions/if.js +0 -39
- package/dist/formula/functions/if.js.map +0 -1
- package/dist/formula/functions/iferror.js +0 -45
- package/dist/formula/functions/iferror.js.map +0 -1
- package/dist/formula/functions/iferror.spec.d.ts +0 -2
- package/dist/formula/functions/iferror.spec.d.ts.map +0 -1
- package/dist/formula/functions/len.js +0 -29
- package/dist/formula/functions/len.js.map +0 -1
- package/dist/formula/functions/lenb.js +0 -29
- package/dist/formula/functions/lenb.js.map +0 -1
- package/dist/formula/functions/ln.js +0 -32
- package/dist/formula/functions/ln.js.map +0 -1
- package/dist/formula/functions/log.js +0 -36
- package/dist/formula/functions/log.js.map +0 -1
- package/dist/formula/functions/log10.js +0 -32
- package/dist/formula/functions/log10.js.map +0 -1
- package/dist/formula/functions/lt.js +0 -29
- package/dist/formula/functions/lt.js.map +0 -1
- package/dist/formula/functions/lte.js +0 -29
- package/dist/formula/functions/lte.js.map +0 -1
- package/dist/formula/functions/max.js +0 -47
- package/dist/formula/functions/max.js.map +0 -1
- package/dist/formula/functions/min.js +0 -47
- package/dist/formula/functions/min.js.map +0 -1
- package/dist/formula/functions/minus.js +0 -57
- package/dist/formula/functions/minus.js.map +0 -1
- package/dist/formula/functions/mod.js +0 -33
- package/dist/formula/functions/mod.js.map +0 -1
- package/dist/formula/functions/mod.spec.d.ts +0 -2
- package/dist/formula/functions/mod.spec.d.ts.map +0 -1
- package/dist/formula/functions/multiply.js +0 -27
- package/dist/formula/functions/multiply.js.map +0 -1
- package/dist/formula/functions/ne.js +0 -29
- package/dist/formula/functions/ne.js.map +0 -1
- package/dist/formula/functions/not.js +0 -30
- package/dist/formula/functions/not.js.map +0 -1
- package/dist/formula/functions/now.js +0 -22
- package/dist/formula/functions/now.js.map +0 -1
- package/dist/formula/functions/or.js +0 -28
- package/dist/formula/functions/or.js.map +0 -1
- package/dist/formula/functions/pi.js +0 -22
- package/dist/formula/functions/pi.js.map +0 -1
- package/dist/formula/functions/power.js +0 -27
- package/dist/formula/functions/power.js.map +0 -1
- package/dist/formula/functions/product.js +0 -40
- package/dist/formula/functions/product.js.map +0 -1
- package/dist/formula/functions/radians.js +0 -29
- package/dist/formula/functions/radians.js.map +0 -1
- package/dist/formula/functions/rand.js +0 -22
- package/dist/formula/functions/rand.js.map +0 -1
- package/dist/formula/functions/round.js +0 -35
- package/dist/formula/functions/round.js.map +0 -1
- package/dist/formula/functions/rounddown.js +0 -35
- package/dist/formula/functions/rounddown.js.map +0 -1
- package/dist/formula/functions/roundup.js +0 -35
- package/dist/formula/functions/roundup.js.map +0 -1
- package/dist/formula/functions/row.js +0 -34
- package/dist/formula/functions/row.js.map +0 -1
- package/dist/formula/functions/row.spec.d.ts +0 -2
- package/dist/formula/functions/row.spec.d.ts.map +0 -1
- package/dist/formula/functions/sin.js +0 -29
- package/dist/formula/functions/sin.js.map +0 -1
- package/dist/formula/functions/sqrt.js +0 -32
- package/dist/formula/functions/sqrt.js.map +0 -1
- package/dist/formula/functions/sum.js +0 -47
- package/dist/formula/functions/sum.js.map +0 -1
- package/dist/formula/functions/sum.spec.d.ts +0 -2
- package/dist/formula/functions/sum.spec.d.ts.map +0 -1
- package/dist/formula/functions/sumif.js +0 -65
- package/dist/formula/functions/sumif.js.map +0 -1
- package/dist/formula/functions/tan.js +0 -29
- package/dist/formula/functions/tan.js.map +0 -1
- package/dist/formula/functions/uminus.js +0 -24
- package/dist/formula/functions/uminus.js.map +0 -1
- package/dist/formula/functions/vlookup.js +0 -75
- package/dist/formula/functions/vlookup.js.map +0 -1
- package/dist/formula/mapping.js +0 -119
- package/dist/formula/mapping.js.map +0 -1
- package/dist/formula/solver.js +0 -70
- package/dist/formula/solver.js.map +0 -1
- package/dist/lib/autofill.js +0 -391
- package/dist/lib/autofill.js.map +0 -1
- package/dist/lib/clipboard.js +0 -72
- package/dist/lib/clipboard.js.map +0 -1
- package/dist/lib/converters.js +0 -141
- package/dist/lib/converters.js.map +0 -1
- package/dist/lib/input.js +0 -52
- package/dist/lib/input.js.map +0 -1
- package/dist/lib/palette.js +0 -24
- package/dist/lib/palette.js.map +0 -1
- package/dist/lib/prevention.d.ts +0 -24
- package/dist/lib/prevention.d.ts.map +0 -1
- package/dist/lib/prevention.js +0 -82
- package/dist/lib/prevention.js.map +0 -1
- package/dist/lib/structs.js +0 -276
- package/dist/lib/structs.js.map +0 -1
- package/dist/lib/table.js +0 -1259
- package/dist/lib/table.js.map +0 -1
- package/dist/lib/time.js +0 -170
- package/dist/lib/time.js.map +0 -1
- package/dist/lib/virtualization.js +0 -129
- package/dist/lib/virtualization.js.map +0 -1
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/dayjs.min.js +0 -287
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/dayjs.min.js.map +0 -1
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/timezone.js +0 -72
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/timezone.js.map +0 -1
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/utc.js +0 -85
- package/dist/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/utc.js.map +0 -1
- package/dist/parsers/core.js +0 -111
- package/dist/parsers/core.js.map +0 -1
- package/dist/renderers/checkbox.js +0 -20
- package/dist/renderers/checkbox.js.map +0 -1
- package/dist/renderers/core.js +0 -135
- package/dist/renderers/core.js.map +0 -1
- package/dist/renderers/thousand_separator.js +0 -17
- package/dist/renderers/thousand_separator.js.map +0 -1
- package/dist/store/actions.js +0 -762
- package/dist/store/actions.js.map +0 -1
- package/dist/store/helpers.js +0 -88
- package/dist/store/helpers.js.map +0 -1
- package/dist/store/index.js +0 -8
- package/dist/store/index.js.map +0 -1
- package/dist/styles/embedder.js +0 -19
- package/dist/styles/embedder.js.map +0 -1
- package/dist/styles/minified.js +0 -7
- package/dist/styles/minified.js.map +0 -1
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { FormulaError } from "../evaluator.js";
|
|
2
|
-
import { solveTable } from "../solver.js";
|
|
3
|
-
import { Table } from "../../lib/table.js";
|
|
4
|
-
import { BaseFunction } from "./__base.js";
|
|
5
|
-
import { ensureString, check } from "./__utils.js";
|
|
6
|
-
class SumifFunction extends BaseFunction {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.example = 'SUMIF(A1:A10,">20")';
|
|
10
|
-
this.helpText = ["Returns the sum of a series of cells."];
|
|
11
|
-
this.helpArgs = [
|
|
12
|
-
{ name: "range1", description: "A condition range." },
|
|
13
|
-
{
|
|
14
|
-
name: "condition",
|
|
15
|
-
description: "A condition for summarization."
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
name: "range2",
|
|
19
|
-
description: "A range to be summarized.",
|
|
20
|
-
optional: true
|
|
21
|
-
}
|
|
22
|
-
];
|
|
23
|
-
}
|
|
24
|
-
validate() {
|
|
25
|
-
if (this.bareArgs.length !== 2 && this.bareArgs.length !== 3) {
|
|
26
|
-
throw new FormulaError("#N/A", "Number of arguments for SUMIF is incorrect.");
|
|
27
|
-
}
|
|
28
|
-
if (this.bareArgs[2] != void 0 && this.bareArgs[2] instanceof Table) {
|
|
29
|
-
throw new FormulaError("#N/A", "3rd argument must be range.");
|
|
30
|
-
}
|
|
31
|
-
this.bareArgs[1] = ensureString(this.bareArgs[1]);
|
|
32
|
-
}
|
|
33
|
-
main(range, condition, sumRange) {
|
|
34
|
-
if (!(range instanceof Table)) {
|
|
35
|
-
return check(range, condition) ? range : 0;
|
|
36
|
-
}
|
|
37
|
-
const conditionMatrix = solveTable({ table: range });
|
|
38
|
-
let sumMatrix = conditionMatrix;
|
|
39
|
-
if (sumRange) {
|
|
40
|
-
const [top, left] = [sumRange.top, sumRange.left];
|
|
41
|
-
const area = {
|
|
42
|
-
top,
|
|
43
|
-
left,
|
|
44
|
-
bottom: top + sumRange.getNumRows(),
|
|
45
|
-
right: left + sumRange.getNumCols()
|
|
46
|
-
};
|
|
47
|
-
sumMatrix = solveTable({ table: this.table.trim(area) });
|
|
48
|
-
}
|
|
49
|
-
let total = 0;
|
|
50
|
-
conditionMatrix.forEach(
|
|
51
|
-
(row, y) => row.forEach((c, x) => {
|
|
52
|
-
var _a;
|
|
53
|
-
const s = ((_a = sumMatrix[y]) == null ? void 0 : _a[x]) || 0;
|
|
54
|
-
if (typeof s === "number" && check(c, condition)) {
|
|
55
|
-
total += s;
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
);
|
|
59
|
-
return total;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
export {
|
|
63
|
-
SumifFunction
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=sumif.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sumif.js","sources":["../../../formula/functions/sumif.ts"],"sourcesContent":["import { FormulaError } from '../evaluator';\nimport { solveTable } from '../solver';\nimport { Table } from '../../lib/table';\nimport { BaseFunction } from './__base';\nimport { check, ensureString } from './__utils';\nimport { AreaType } from '../../types';\n\nexport class SumifFunction extends BaseFunction {\n example = 'SUMIF(A1:A10,\">20\")';\n helpText = ['Returns the sum of a series of cells.'];\n helpArgs = [\n { name: 'range1', description: 'A condition range.' },\n {\n name: 'condition',\n description: 'A condition for summarization.',\n },\n {\n name: 'range2',\n description: 'A range to be summarized.',\n optional: true,\n },\n ];\n\n protected validate() {\n if (this.bareArgs.length !== 2 && this.bareArgs.length !== 3) {\n throw new FormulaError('#N/A', 'Number of arguments for SUMIF is incorrect.');\n }\n if (this.bareArgs[2] != undefined && this.bareArgs[2] instanceof Table) {\n throw new FormulaError('#N/A', '3rd argument must be range.');\n }\n this.bareArgs[1] = ensureString(this.bareArgs[1]);\n }\n\n protected main(range: Table, condition: string, sumRange: Table) {\n if (!(range instanceof Table)) {\n return check(range, condition) ? range : 0;\n }\n const conditionMatrix = solveTable({ table: range });\n let sumMatrix = conditionMatrix;\n if (sumRange) {\n const [top, left] = [sumRange.top, sumRange.left];\n const area: AreaType = {\n top,\n left,\n bottom: top + sumRange.getNumRows(),\n right: left + sumRange.getNumCols(),\n };\n sumMatrix = solveTable({ table: this.table.trim(area) });\n }\n let total = 0;\n conditionMatrix.forEach((row, y) =>\n row.forEach((c, x) => {\n const s = sumMatrix[y]?.[x] || 0;\n if (typeof s === 'number' && check(c, condition)) {\n total += s;\n }\n }),\n );\n return total;\n }\n}\n"],"names":[],"mappings":";;;;;AAOO,MAAM,sBAAsB,aAAa;AAAA,EAAzC,cAAA;AAAA,UAAA,GAAA,SAAA;AACK,SAAA,UAAA;AACV,SAAA,WAAW,CAAC,uCAAuC;AACxC,SAAA,WAAA;AAAA,MACT,EAAE,MAAM,UAAU,aAAa,qBAAqB;AAAA,MACpD;AAAA,QACE,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,aAAa;AAAA,QACb,UAAU;AAAA,MAAA;AAAA,IAEd;AAAA,EAAA;AAAA,EAEU,WAAW;AACnB,QAAI,KAAK,SAAS,WAAW,KAAK,KAAK,SAAS,WAAW,GAAG;AACtD,YAAA,IAAI,aAAa,QAAQ,6CAA6C;AAAA,IAAA;AAE1E,QAAA,KAAK,SAAS,CAAC,KAAK,UAAa,KAAK,SAAS,CAAC,aAAa,OAAO;AAChE,YAAA,IAAI,aAAa,QAAQ,6BAA6B;AAAA,IAAA;AAE9D,SAAK,SAAS,CAAC,IAAI,aAAa,KAAK,SAAS,CAAC,CAAC;AAAA,EAAA;AAAA,EAGxC,KAAK,OAAc,WAAmB,UAAiB;AAC3D,QAAA,EAAE,iBAAiB,QAAQ;AAC7B,aAAO,MAAM,OAAO,SAAS,IAAI,QAAQ;AAAA,IAAA;AAE3C,UAAM,kBAAkB,WAAW,EAAE,OAAO,OAAO;AACnD,QAAI,YAAY;AAChB,QAAI,UAAU;AACN,YAAA,CAAC,KAAK,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI;AAChD,YAAM,OAAiB;AAAA,QACrB;AAAA,QACA;AAAA,QACA,QAAQ,MAAM,SAAS,WAAW;AAAA,QAClC,OAAO,OAAO,SAAS,WAAW;AAAA,MACpC;AACY,kBAAA,WAAW,EAAE,OAAO,KAAK,MAAM,KAAK,IAAI,GAAG;AAAA,IAAA;AAEzD,QAAI,QAAQ;AACI,oBAAA;AAAA,MAAQ,CAAC,KAAK,MAC5B,IAAI,QAAQ,CAAC,GAAG,MAAM;;AACpB,cAAM,MAAI,eAAU,CAAC,MAAX,mBAAe,OAAM;AAC/B,YAAI,OAAO,MAAM,YAAY,MAAM,GAAG,SAAS,GAAG;AACvC,mBAAA;AAAA,QAAA;AAAA,MAEZ,CAAA;AAAA,IACH;AACO,WAAA;AAAA,EAAA;AAEX;"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { FormulaError } from "../evaluator.js";
|
|
2
|
-
import { BaseFunction } from "./__base.js";
|
|
3
|
-
import { ensureNumber } from "./__utils.js";
|
|
4
|
-
class TanFunction extends BaseFunction {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.example = "TAN(1)";
|
|
8
|
-
this.helpText = ["Returns the tan of the angle specified in radians."];
|
|
9
|
-
this.helpArgs = [
|
|
10
|
-
{
|
|
11
|
-
name: "angle",
|
|
12
|
-
description: "An angle in radians, at which you want the tan."
|
|
13
|
-
}
|
|
14
|
-
];
|
|
15
|
-
}
|
|
16
|
-
validate() {
|
|
17
|
-
if (this.bareArgs.length !== 1) {
|
|
18
|
-
throw new FormulaError("#N/A", "Number of arguments for TAN is incorrect.");
|
|
19
|
-
}
|
|
20
|
-
this.bareArgs = this.bareArgs.map((arg) => ensureNumber(arg));
|
|
21
|
-
}
|
|
22
|
-
main(angle) {
|
|
23
|
-
return Math.tan(angle);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
TanFunction
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=tan.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tan.js","sources":["../../../formula/functions/tan.ts"],"sourcesContent":["import { FormulaError } from '../evaluator';\nimport { BaseFunction } from './__base';\nimport { ensureNumber } from './__utils';\n\nexport class TanFunction extends BaseFunction {\n example = 'TAN(1)';\n helpText = ['Returns the tan of the angle specified in radians.'];\n helpArgs = [\n {\n name: 'angle',\n description: 'An angle in radians, at which you want the tan.',\n },\n ];\n\n protected validate() {\n if (this.bareArgs.length !== 1) {\n throw new FormulaError('#N/A', 'Number of arguments for TAN is incorrect.');\n }\n this.bareArgs = this.bareArgs.map((arg) => ensureNumber(arg));\n }\n\n protected main(angle: number) {\n return Math.tan(angle);\n }\n}\n"],"names":[],"mappings":";;;AAIO,MAAM,oBAAoB,aAAa;AAAA,EAAvC,cAAA;AAAA,UAAA,GAAA,SAAA;AACK,SAAA,UAAA;AACV,SAAA,WAAW,CAAC,oDAAoD;AACrD,SAAA,WAAA;AAAA,MACT;AAAA,QACE,MAAM;AAAA,QACN,aAAa;AAAA,MAAA;AAAA,IAEjB;AAAA,EAAA;AAAA,EAEU,WAAW;AACf,QAAA,KAAK,SAAS,WAAW,GAAG;AACxB,YAAA,IAAI,aAAa,QAAQ,2CAA2C;AAAA,IAAA;AAEvE,SAAA,WAAW,KAAK,SAAS,IAAI,CAAC,QAAQ,aAAa,GAAG,CAAC;AAAA,EAAA;AAAA,EAGpD,KAAK,OAAe;AACrB,WAAA,KAAK,IAAI,KAAK;AAAA,EAAA;AAEzB;"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { FormulaError } from "../evaluator.js";
|
|
2
|
-
import { BaseFunction } from "./__base.js";
|
|
3
|
-
import { ensureNumber } from "./__utils.js";
|
|
4
|
-
class UminusFunction extends BaseFunction {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.example = "UMINUS(4)";
|
|
8
|
-
this.helpText = ["Returns a number with positive and negative values reversed."];
|
|
9
|
-
this.helpArgs = [{ name: "value1", description: "A number that will be subtracted." }];
|
|
10
|
-
}
|
|
11
|
-
validate() {
|
|
12
|
-
if (this.bareArgs.length !== 1) {
|
|
13
|
-
throw new FormulaError("#N/A", "A single numerical value is only required.");
|
|
14
|
-
}
|
|
15
|
-
this.bareArgs = this.bareArgs.map((arg) => ensureNumber(arg));
|
|
16
|
-
}
|
|
17
|
-
main(v1) {
|
|
18
|
-
return -v1;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export {
|
|
22
|
-
UminusFunction
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=uminus.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uminus.js","sources":["../../../formula/functions/uminus.ts"],"sourcesContent":["import { FormulaError } from '../evaluator';\nimport { BaseFunction } from './__base';\nimport { ensureNumber } from './__utils';\n\nexport class UminusFunction extends BaseFunction {\n example = 'UMINUS(4)';\n helpText = ['Returns a number with positive and negative values reversed.'];\n helpArgs = [{ name: 'value1', description: 'A number that will be subtracted.' }];\n\n protected validate() {\n if (this.bareArgs.length !== 1) {\n throw new FormulaError('#N/A', 'A single numerical value is only required.');\n }\n this.bareArgs = this.bareArgs.map((arg) => ensureNumber(arg));\n }\n\n protected main(v1: number) {\n return -v1;\n }\n}\n"],"names":[],"mappings":";;;AAIO,MAAM,uBAAuB,aAAa;AAAA,EAA1C,cAAA;AAAA,UAAA,GAAA,SAAA;AACK,SAAA,UAAA;AACV,SAAA,WAAW,CAAC,8DAA8D;AAC1E,SAAA,WAAW,CAAC,EAAE,MAAM,UAAU,aAAa,qCAAqC;AAAA,EAAA;AAAA,EAEtE,WAAW;AACf,QAAA,KAAK,SAAS,WAAW,GAAG;AACxB,YAAA,IAAI,aAAa,QAAQ,4CAA4C;AAAA,IAAA;AAExE,SAAA,WAAW,KAAK,SAAS,IAAI,CAAC,QAAQ,aAAa,GAAG,CAAC;AAAA,EAAA;AAAA,EAGpD,KAAK,IAAY;AACzB,WAAO,CAAC;AAAA,EAAA;AAEZ;"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { FormulaError } from "../evaluator.js";
|
|
2
|
-
import { solveTable } from "../solver.js";
|
|
3
|
-
import { Table } from "../../lib/table.js";
|
|
4
|
-
import { BaseFunction } from "./__base.js";
|
|
5
|
-
import { stripTable, ensureNumber, ensureBoolean } from "./__utils.js";
|
|
6
|
-
class VlookupFunction extends BaseFunction {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.example = "VLOOKUP(10003, A2:B26, 2, FALSE)";
|
|
10
|
-
this.helpText = [
|
|
11
|
-
"Searches vertically for the specified key in the first column of the range and returns the value of the specified cell in the same row."
|
|
12
|
-
];
|
|
13
|
-
this.helpArgs = [
|
|
14
|
-
{ name: "key", description: "Search key." },
|
|
15
|
-
{
|
|
16
|
-
name: "range",
|
|
17
|
-
description: "A range for search"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: "index",
|
|
21
|
-
description: "The index of the column in the range."
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: "is_sorted",
|
|
25
|
-
description: "FALSE: Exact match. This is recommended. TRUE: Approximate match. Before you use an approximate match, sort your search key in ascending order. Otherwise, you may likely get a wrong return value.",
|
|
26
|
-
option: true
|
|
27
|
-
}
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
validate() {
|
|
31
|
-
if (this.bareArgs.length !== 3 && this.bareArgs.length !== 4) {
|
|
32
|
-
throw new FormulaError("#N/A", "Number of arguments for VLOOKUP is incorrect.");
|
|
33
|
-
}
|
|
34
|
-
if (this.bareArgs[0] instanceof Table) {
|
|
35
|
-
this.bareArgs[0] = stripTable(this.bareArgs[0]);
|
|
36
|
-
}
|
|
37
|
-
if (!(this.bareArgs[1] instanceof Table)) {
|
|
38
|
-
throw new FormulaError("#REF!", "2nd argument must be range");
|
|
39
|
-
}
|
|
40
|
-
this.bareArgs[2] = ensureNumber(this.bareArgs[2]);
|
|
41
|
-
this.bareArgs[3] = ensureBoolean(this.bareArgs[3], true);
|
|
42
|
-
}
|
|
43
|
-
main(key, range, index, isSorted) {
|
|
44
|
-
var _a, _b, _c, _d;
|
|
45
|
-
const matrix = solveTable({ table: range });
|
|
46
|
-
if (isSorted) {
|
|
47
|
-
let last = -1;
|
|
48
|
-
for (let y = 0; y <= range.getNumRows(); y++) {
|
|
49
|
-
const v = (_a = matrix[y]) == null ? void 0 : _a[0];
|
|
50
|
-
if (v == null) {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
if (v <= key) {
|
|
54
|
-
last = y;
|
|
55
|
-
} else {
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (last !== -1) {
|
|
60
|
-
return (_b = matrix[last]) == null ? void 0 : _b[index - 1];
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
for (let y = 0; y <= range.getNumRows(); y++) {
|
|
64
|
-
if (((_c = matrix[y]) == null ? void 0 : _c[0]) === key) {
|
|
65
|
-
return (_d = matrix[y]) == null ? void 0 : _d[index - 1];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
throw new FormulaError("#N/A", `No values found for '${key}'.`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
export {
|
|
73
|
-
VlookupFunction
|
|
74
|
-
};
|
|
75
|
-
//# sourceMappingURL=vlookup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vlookup.js","sources":["../../../formula/functions/vlookup.ts"],"sourcesContent":["import { FormulaError } from '../evaluator';\nimport { solveTable } from '../solver';\nimport { Table } from '../../lib/table';\nimport { BaseFunction } from './__base';\nimport { ensureBoolean, ensureNumber, stripTable } from './__utils';\n\nexport class VlookupFunction extends BaseFunction {\n example = 'VLOOKUP(10003, A2:B26, 2, FALSE)';\n helpText = [\n 'Searches vertically for the specified key in the first column of the range and returns the value of the specified cell in the same row.',\n ];\n helpArgs = [\n { name: 'key', description: 'Search key.' },\n {\n name: 'range',\n description: 'A range for search',\n },\n {\n name: 'index',\n description: 'The index of the column in the range.',\n },\n {\n name: 'is_sorted',\n description:\n 'FALSE: Exact match. This is recommended. TRUE: Approximate match. Before you use an approximate match, sort your search key in ascending order. Otherwise, you may likely get a wrong return value.',\n option: true,\n },\n ];\n\n protected validate() {\n if (this.bareArgs.length !== 3 && this.bareArgs.length !== 4) {\n throw new FormulaError('#N/A', 'Number of arguments for VLOOKUP is incorrect.');\n }\n if (this.bareArgs[0] instanceof Table) {\n this.bareArgs[0] = stripTable(this.bareArgs[0]);\n }\n if (!(this.bareArgs[1] instanceof Table)) {\n throw new FormulaError('#REF!', '2nd argument must be range');\n }\n this.bareArgs[2] = ensureNumber(this.bareArgs[2]);\n this.bareArgs[3] = ensureBoolean(this.bareArgs[3], true);\n }\n\n protected main(key: any, range: Table, index: number, isSorted: boolean) {\n const matrix = solveTable({ table: range });\n if (isSorted) {\n let last = -1;\n for (let y = 0; y <= range.getNumRows(); y++) {\n const v = matrix[y]?.[0];\n if (v == null) {\n continue;\n }\n if (v <= key) {\n last = y;\n } else {\n break;\n }\n }\n if (last !== -1) {\n return matrix[last]?.[index - 1];\n }\n } else {\n for (let y = 0; y <= range.getNumRows(); y++) {\n if (matrix[y]?.[0] === key) {\n return matrix[y]?.[index - 1];\n }\n }\n }\n throw new FormulaError('#N/A', `No values found for '${key}'.`);\n }\n}\n"],"names":[],"mappings":";;;;;AAMO,MAAM,wBAAwB,aAAa;AAAA,EAA3C,cAAA;AAAA,UAAA,GAAA,SAAA;AACK,SAAA,UAAA;AACC,SAAA,WAAA;AAAA,MACT;AAAA,IACF;AACW,SAAA,WAAA;AAAA,MACT,EAAE,MAAM,OAAO,aAAa,cAAc;AAAA,MAC1C;AAAA,QACE,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,aACE;AAAA,QACF,QAAQ;AAAA,MAAA;AAAA,IAEZ;AAAA,EAAA;AAAA,EAEU,WAAW;AACnB,QAAI,KAAK,SAAS,WAAW,KAAK,KAAK,SAAS,WAAW,GAAG;AACtD,YAAA,IAAI,aAAa,QAAQ,+CAA+C;AAAA,IAAA;AAEhF,QAAI,KAAK,SAAS,CAAC,aAAa,OAAO;AACrC,WAAK,SAAS,CAAC,IAAI,WAAW,KAAK,SAAS,CAAC,CAAC;AAAA,IAAA;AAEhD,QAAI,EAAE,KAAK,SAAS,CAAC,aAAa,QAAQ;AAClC,YAAA,IAAI,aAAa,SAAS,4BAA4B;AAAA,IAAA;AAE9D,SAAK,SAAS,CAAC,IAAI,aAAa,KAAK,SAAS,CAAC,CAAC;AAC3C,SAAA,SAAS,CAAC,IAAI,cAAc,KAAK,SAAS,CAAC,GAAG,IAAI;AAAA,EAAA;AAAA,EAG/C,KAAK,KAAU,OAAc,OAAe,UAAmB;;AACvE,UAAM,SAAS,WAAW,EAAE,OAAO,OAAO;AAC1C,QAAI,UAAU;AACZ,UAAI,OAAO;AACX,eAAS,IAAI,GAAG,KAAK,MAAM,WAAA,GAAc,KAAK;AAC5C,cAAM,KAAI,YAAO,CAAC,MAAR,mBAAY;AACtB,YAAI,KAAK,MAAM;AACb;AAAA,QAAA;AAEF,YAAI,KAAK,KAAK;AACL,iBAAA;AAAA,QAAA,OACF;AACL;AAAA,QAAA;AAAA,MACF;AAEF,UAAI,SAAS,IAAI;AACf,gBAAO,YAAO,IAAI,MAAX,mBAAe,QAAQ;AAAA,MAAC;AAAA,IACjC,OACK;AACL,eAAS,IAAI,GAAG,KAAK,MAAM,WAAA,GAAc,KAAK;AAC5C,cAAI,YAAO,CAAC,MAAR,mBAAY,QAAO,KAAK;AAC1B,kBAAO,YAAO,CAAC,MAAR,mBAAY,QAAQ;AAAA,QAAC;AAAA,MAC9B;AAAA,IACF;AAEF,UAAM,IAAI,aAAa,QAAQ,wBAAwB,GAAG,IAAI;AAAA,EAAA;AAElE;"}
|
package/dist/formula/mapping.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { AddFunction } from "./functions/add.js";
|
|
2
|
-
import { MinusFunction } from "./functions/minus.js";
|
|
3
|
-
import { MultiplyFunction } from "./functions/multiply.js";
|
|
4
|
-
import { DivideFunction } from "./functions/divide.js";
|
|
5
|
-
import { ModFunction } from "./functions/mod.js";
|
|
6
|
-
import { SumFunction } from "./functions/sum.js";
|
|
7
|
-
import { ConcatFunction } from "./functions/concat.js";
|
|
8
|
-
import { ConcatenateFunction } from "./functions/concatenate.js";
|
|
9
|
-
import { EqFunction } from "./functions/eq.js";
|
|
10
|
-
import { NeFunction } from "./functions/ne.js";
|
|
11
|
-
import { GtFunction } from "./functions/gt.js";
|
|
12
|
-
import { GteFunction } from "./functions/gte.js";
|
|
13
|
-
import { LtFunction } from "./functions/lt.js";
|
|
14
|
-
import { LteFunction } from "./functions/lte.js";
|
|
15
|
-
import { NowFunction } from "./functions/now.js";
|
|
16
|
-
import { AndFunction } from "./functions/and.js";
|
|
17
|
-
import { OrFunction } from "./functions/or.js";
|
|
18
|
-
import { IfFunction } from "./functions/if.js";
|
|
19
|
-
import { IfErrorFunction } from "./functions/iferror.js";
|
|
20
|
-
import { NotFunction } from "./functions/not.js";
|
|
21
|
-
import { CountFunction } from "./functions/count.js";
|
|
22
|
-
import { CountifFunction } from "./functions/countif.js";
|
|
23
|
-
import { SumifFunction } from "./functions/sumif.js";
|
|
24
|
-
import { VlookupFunction } from "./functions/vlookup.js";
|
|
25
|
-
import { HlookupFunction } from "./functions/hlookup.js";
|
|
26
|
-
import { LogFunction } from "./functions/log.js";
|
|
27
|
-
import { Log10Function } from "./functions/log10.js";
|
|
28
|
-
import { LnFunction } from "./functions/ln.js";
|
|
29
|
-
import { AbsFunction } from "./functions/abs.js";
|
|
30
|
-
import { ProductFunction } from "./functions/product.js";
|
|
31
|
-
import { RandFunction } from "./functions/rand.js";
|
|
32
|
-
import { PiFunction } from "./functions/pi.js";
|
|
33
|
-
import { ExpFunction } from "./functions/exp.js";
|
|
34
|
-
import { RadiansFunction } from "./functions/radians.js";
|
|
35
|
-
import { PowerFunction } from "./functions/power.js";
|
|
36
|
-
import { SqrtFunction } from "./functions/sqrt.js";
|
|
37
|
-
import { RoundFunction } from "./functions/round.js";
|
|
38
|
-
import { RoundupFunction } from "./functions/roundup.js";
|
|
39
|
-
import { RounddownFunction } from "./functions/rounddown.js";
|
|
40
|
-
import { SinFunction } from "./functions/sin.js";
|
|
41
|
-
import { CosFunction } from "./functions/cos.js";
|
|
42
|
-
import { TanFunction } from "./functions/tan.js";
|
|
43
|
-
import { AsinFunction } from "./functions/asin.js";
|
|
44
|
-
import { AcosFunction } from "./functions/acos.js";
|
|
45
|
-
import { AtanFunction } from "./functions/atan.js";
|
|
46
|
-
import { Atan2Function } from "./functions/atan2.js";
|
|
47
|
-
import { CountaFunction } from "./functions/counta.js";
|
|
48
|
-
import { AverageFunction } from "./functions/average.js";
|
|
49
|
-
import { MaxFunction } from "./functions/max.js";
|
|
50
|
-
import { MinFunction } from "./functions/min.js";
|
|
51
|
-
import { LenFunction } from "./functions/len.js";
|
|
52
|
-
import { LenbFunction } from "./functions/lenb.js";
|
|
53
|
-
import { UminusFunction } from "./functions/uminus.js";
|
|
54
|
-
import { RowFunction } from "./functions/row.js";
|
|
55
|
-
import { ColFunction } from "./functions/col.js";
|
|
56
|
-
const functions = {
|
|
57
|
-
abs: AbsFunction,
|
|
58
|
-
add: AddFunction,
|
|
59
|
-
divide: DivideFunction,
|
|
60
|
-
mod: ModFunction,
|
|
61
|
-
minus: MinusFunction,
|
|
62
|
-
uminus: UminusFunction,
|
|
63
|
-
multiply: MultiplyFunction,
|
|
64
|
-
pow: PowerFunction,
|
|
65
|
-
power: PowerFunction,
|
|
66
|
-
sqrt: SqrtFunction,
|
|
67
|
-
sum: SumFunction,
|
|
68
|
-
sumif: SumifFunction,
|
|
69
|
-
max: MaxFunction,
|
|
70
|
-
min: MinFunction,
|
|
71
|
-
average: AverageFunction,
|
|
72
|
-
count: CountFunction,
|
|
73
|
-
counta: CountaFunction,
|
|
74
|
-
countif: CountifFunction,
|
|
75
|
-
product: ProductFunction,
|
|
76
|
-
concat: ConcatFunction,
|
|
77
|
-
concatenate: ConcatenateFunction,
|
|
78
|
-
eq: EqFunction,
|
|
79
|
-
ne: NeFunction,
|
|
80
|
-
gt: GtFunction,
|
|
81
|
-
gte: GteFunction,
|
|
82
|
-
lt: LtFunction,
|
|
83
|
-
lte: LteFunction,
|
|
84
|
-
and: AndFunction,
|
|
85
|
-
or: OrFunction,
|
|
86
|
-
round: RoundFunction,
|
|
87
|
-
rounddown: RounddownFunction,
|
|
88
|
-
roundup: RoundupFunction,
|
|
89
|
-
if: IfFunction,
|
|
90
|
-
// @ts-expect-error iferror does not extends BaseFunction
|
|
91
|
-
iferror: IfErrorFunction,
|
|
92
|
-
not: NotFunction,
|
|
93
|
-
vlookup: VlookupFunction,
|
|
94
|
-
hlookup: HlookupFunction,
|
|
95
|
-
row: RowFunction,
|
|
96
|
-
col: ColFunction,
|
|
97
|
-
column: ColFunction,
|
|
98
|
-
now: NowFunction,
|
|
99
|
-
rand: RandFunction,
|
|
100
|
-
log: LogFunction,
|
|
101
|
-
log10: Log10Function,
|
|
102
|
-
ln: LnFunction,
|
|
103
|
-
exp: ExpFunction,
|
|
104
|
-
pi: PiFunction,
|
|
105
|
-
radians: RadiansFunction,
|
|
106
|
-
sin: SinFunction,
|
|
107
|
-
cos: CosFunction,
|
|
108
|
-
tan: TanFunction,
|
|
109
|
-
asin: AsinFunction,
|
|
110
|
-
acos: AcosFunction,
|
|
111
|
-
atan: AtanFunction,
|
|
112
|
-
atan2: Atan2Function,
|
|
113
|
-
len: LenFunction,
|
|
114
|
-
lenb: LenbFunction
|
|
115
|
-
};
|
|
116
|
-
export {
|
|
117
|
-
functions
|
|
118
|
-
};
|
|
119
|
-
//# sourceMappingURL=mapping.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.js","sources":["../../formula/mapping.ts"],"sourcesContent":["import { AddFunction } from './functions/add';\nimport { MinusFunction } from './functions/minus';\nimport { MultiplyFunction } from './functions/multiply';\nimport { DivideFunction } from './functions/divide';\nimport { ModFunction } from './functions/mod';\nimport { SumFunction } from './functions/sum';\nimport { ConcatFunction } from './functions/concat';\nimport { ConcatenateFunction } from './functions/concatenate';\nimport { EqFunction } from './functions/eq';\nimport { NeFunction } from './functions/ne';\nimport { GtFunction } from './functions/gt';\nimport { GteFunction } from './functions/gte';\nimport { LtFunction } from './functions/lt';\nimport { LteFunction } from './functions/lte';\nimport { NowFunction } from './functions/now';\nimport { AndFunction } from './functions/and';\nimport { OrFunction } from './functions/or';\nimport { IfFunction } from './functions/if';\nimport { IfErrorFunction } from './functions/iferror';\nimport { NotFunction } from './functions/not';\nimport { CountFunction } from './functions/count';\nimport { CountifFunction } from './functions/countif';\nimport { SumifFunction } from './functions/sumif';\nimport { VlookupFunction } from './functions/vlookup';\nimport { HlookupFunction } from './functions/hlookup';\nimport { LogFunction } from './functions/log';\nimport { Log10Function } from './functions/log10';\nimport { LnFunction } from './functions/ln';\nimport { AbsFunction } from './functions/abs';\nimport { ProductFunction } from './functions/product';\nimport { RandFunction } from './functions/rand';\nimport { PiFunction } from './functions/pi';\nimport { ExpFunction } from './functions/exp';\nimport { RadiansFunction } from './functions/radians';\nimport { PowerFunction } from './functions/power';\nimport { SqrtFunction } from './functions/sqrt';\nimport { RoundFunction } from './functions/round';\nimport { RoundupFunction } from './functions/roundup';\nimport { RounddownFunction } from './functions/rounddown';\nimport { SinFunction } from './functions/sin';\nimport { CosFunction } from './functions/cos';\nimport { TanFunction } from './functions/tan';\nimport { AsinFunction } from './functions/asin';\nimport { AcosFunction } from './functions/acos';\nimport { AtanFunction } from './functions/atan';\nimport { Atan2Function } from './functions/atan2';\nimport { CountaFunction } from './functions/counta';\nimport { AverageFunction } from './functions/average';\nimport { MaxFunction } from './functions/max';\nimport { MinFunction } from './functions/min';\nimport { LenFunction } from './functions/len';\nimport { LenbFunction } from './functions/lenb';\nimport { UminusFunction } from './functions/uminus';\nimport { RowFunction } from './functions/row';\nimport { ColFunction } from './functions/col';\nimport type { FunctionMapping } from './functions/__base';\n\nexport const functions: FunctionMapping = {\n abs: AbsFunction,\n add: AddFunction,\n divide: DivideFunction,\n mod: ModFunction,\n minus: MinusFunction,\n uminus: UminusFunction,\n multiply: MultiplyFunction,\n pow: PowerFunction,\n power: PowerFunction,\n sqrt: SqrtFunction,\n sum: SumFunction,\n sumif: SumifFunction,\n max: MaxFunction,\n min: MinFunction,\n average: AverageFunction,\n count: CountFunction,\n counta: CountaFunction,\n countif: CountifFunction,\n product: ProductFunction,\n concat: ConcatFunction,\n concatenate: ConcatenateFunction,\n eq: EqFunction,\n ne: NeFunction,\n gt: GtFunction,\n gte: GteFunction,\n lt: LtFunction,\n lte: LteFunction,\n and: AndFunction,\n or: OrFunction,\n round: RoundFunction,\n rounddown: RounddownFunction,\n roundup: RoundupFunction,\n if: IfFunction,\n // @ts-expect-error iferror does not extends BaseFunction\n iferror: IfErrorFunction,\n not: NotFunction,\n vlookup: VlookupFunction,\n hlookup: HlookupFunction,\n row: RowFunction,\n col: ColFunction,\n column: ColFunction,\n now: NowFunction,\n rand: RandFunction,\n log: LogFunction,\n log10: Log10Function,\n ln: LnFunction,\n exp: ExpFunction,\n pi: PiFunction,\n radians: RadiansFunction,\n sin: SinFunction,\n cos: CosFunction,\n tan: TanFunction,\n asin: AsinFunction,\n acos: AcosFunction,\n atan: AtanFunction,\n atan2: Atan2Function,\n len: LenFunction,\n lenb: LenbFunction,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDO,MAAM,YAA6B;AAAA,EACxC,KAAK;AAAA,EACL,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,KAAK;AAAA,EACL,KAAK;AAAA,EACL,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,WAAW;AAAA,EACX,SAAS;AAAA,EACT,IAAI;AAAA;AAAA,EAEJ,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AAAA,EACT,SAAS;AAAA,EACT,KAAK;AAAA,EACL,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AACR;"}
|
package/dist/formula/solver.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Special } from "../constants.js";
|
|
2
|
-
import { Table } from "../lib/table.js";
|
|
3
|
-
import { Lexer, Parser, FormulaError } from "./evaluator.js";
|
|
4
|
-
import { p2a } from "../lib/converters.js";
|
|
5
|
-
const SOLVING = new Special("solving");
|
|
6
|
-
const solveFormula = ({ value, table, raise = true, evaluates = true, origin }) => {
|
|
7
|
-
var _a;
|
|
8
|
-
if (evaluates === null) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
let solved = value;
|
|
12
|
-
if (typeof value === "string") {
|
|
13
|
-
if (value.charAt(0) === "=") {
|
|
14
|
-
try {
|
|
15
|
-
const lexer = new Lexer(value.substring(1), { origin });
|
|
16
|
-
lexer.tokenize();
|
|
17
|
-
const parser = new Parser(lexer.tokens);
|
|
18
|
-
if (evaluates === false) {
|
|
19
|
-
return "=" + lexer.stringifyToRef(table);
|
|
20
|
-
}
|
|
21
|
-
const expr = parser.build();
|
|
22
|
-
solved = (_a = expr == null ? void 0 : expr.evaluate) == null ? void 0 : _a.call(expr, { table });
|
|
23
|
-
} catch (e) {
|
|
24
|
-
if (raise) {
|
|
25
|
-
throw e;
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (solved instanceof Table) {
|
|
32
|
-
solved = solveTable({ table: solved, raise })[0][0];
|
|
33
|
-
}
|
|
34
|
-
return solved;
|
|
35
|
-
};
|
|
36
|
-
const solveTable = ({ table, raise = true }) => {
|
|
37
|
-
const area = table.getArea();
|
|
38
|
-
return table.getMatrixFlatten({ area, evaluates: null }).map((row, i) => {
|
|
39
|
-
const y = area.top + i;
|
|
40
|
-
return row.map((value, j) => {
|
|
41
|
-
const x = area.left + j;
|
|
42
|
-
const address = p2a({ y, x });
|
|
43
|
-
const cache = table.getSolvedCache(address);
|
|
44
|
-
try {
|
|
45
|
-
if (cache === SOLVING) {
|
|
46
|
-
throw new FormulaError("#REF!", "References are circulating.", new Error(value));
|
|
47
|
-
} else if (cache instanceof FormulaError) {
|
|
48
|
-
throw cache;
|
|
49
|
-
} else if (cache != null) {
|
|
50
|
-
return cache;
|
|
51
|
-
}
|
|
52
|
-
table.setSolvedCache(address, SOLVING);
|
|
53
|
-
const solved = solveFormula({ value, table, raise, origin: { y, x } });
|
|
54
|
-
table.setSolvedCache(address, solved);
|
|
55
|
-
return solved;
|
|
56
|
-
} catch (e) {
|
|
57
|
-
table.setSolvedCache(address, e);
|
|
58
|
-
if (raise) {
|
|
59
|
-
throw e;
|
|
60
|
-
}
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
export {
|
|
67
|
-
solveFormula,
|
|
68
|
-
solveTable
|
|
69
|
-
};
|
|
70
|
-
//# sourceMappingURL=solver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solver.js","sources":["../../formula/solver.ts"],"sourcesContent":["import { Special } from '../constants';\nimport { Table } from '../lib/table';\nimport { MatrixType, PointType } from '../types';\nimport { FormulaError, Lexer, Parser } from './evaluator';\nimport { p2a } from '../lib/converters';\n\nconst SOLVING = new Special('solving');\n\ntype SolveFormulaType = {\n value: any;\n table: Table;\n raise?: boolean;\n evaluates?: boolean | null;\n origin?: PointType;\n};\n\nexport const solveFormula = ({ value, table, raise = true, evaluates = true, origin }: SolveFormulaType) => {\n if (evaluates === null) {\n return value;\n }\n let solved = value;\n if (typeof value === 'string') {\n if (value.charAt(0) === '=') {\n try {\n const lexer = new Lexer(value.substring(1), { origin });\n lexer.tokenize();\n const parser = new Parser(lexer.tokens);\n if (evaluates === false) {\n return '=' + lexer.stringifyToRef(table);\n }\n const expr = parser.build();\n solved = expr?.evaluate?.({ table });\n } catch (e) {\n if (raise) {\n throw e;\n }\n return null;\n }\n }\n }\n if (solved instanceof Table) {\n solved = solveTable({ table: solved, raise })[0][0];\n }\n return solved;\n};\n\nexport const solveTable = ({ table, raise = true }: { table: Table; raise?: boolean }): MatrixType => {\n const area = table.getArea();\n return table.getMatrixFlatten({ area, evaluates: null }).map((row, i) => {\n const y = area.top + i;\n return row.map((value, j) => {\n const x = area.left + j;\n const address = p2a({ y, x });\n const cache = table.getSolvedCache(address);\n\n try {\n if (cache === SOLVING) {\n throw new FormulaError('#REF!', 'References are circulating.', new Error(value as string));\n } else if (cache instanceof FormulaError) {\n throw cache;\n } else if (cache != null) {\n return cache;\n }\n table.setSolvedCache(address, SOLVING);\n const solved = solveFormula({ value, table, raise, origin: { y, x } });\n table.setSolvedCache(address, solved);\n return solved;\n } catch (e) {\n table.setSolvedCache(address, e);\n if (raise) {\n throw e;\n }\n return null;\n }\n });\n });\n};\n"],"names":[],"mappings":";;;;AAMA,MAAM,UAAU,IAAI,QAAQ,SAAS;AAUxB,MAAA,eAAe,CAAC,EAAE,OAAO,OAAO,QAAQ,MAAM,YAAY,MAAM,aAA+B;;AAC1G,MAAI,cAAc,MAAM;AACf,WAAA;AAAA,EAAA;AAET,MAAI,SAAS;AACT,MAAA,OAAO,UAAU,UAAU;AAC7B,QAAI,MAAM,OAAO,CAAC,MAAM,KAAK;AACvB,UAAA;AACI,cAAA,QAAQ,IAAI,MAAM,MAAM,UAAU,CAAC,GAAG,EAAE,QAAQ;AACtD,cAAM,SAAS;AACf,cAAM,SAAS,IAAI,OAAO,MAAM,MAAM;AACtC,YAAI,cAAc,OAAO;AAChB,iBAAA,MAAM,MAAM,eAAe,KAAK;AAAA,QAAA;AAEnC,cAAA,OAAO,OAAO,MAAM;AAC1B,kBAAS,kCAAM,aAAN,8BAAiB,EAAE,MAAA;AAAA,eACrB,GAAG;AACV,YAAI,OAAO;AACH,gBAAA;AAAA,QAAA;AAED,eAAA;AAAA,MAAA;AAAA,IACT;AAAA,EACF;AAEF,MAAI,kBAAkB,OAAO;AAClB,aAAA,WAAW,EAAE,OAAO,QAAQ,OAAO,EAAE,CAAC,EAAE,CAAC;AAAA,EAAA;AAE7C,SAAA;AACT;AAEO,MAAM,aAAa,CAAC,EAAE,OAAO,QAAQ,WAA0D;AAC9F,QAAA,OAAO,MAAM,QAAQ;AACpB,SAAA,MAAM,iBAAiB,EAAE,MAAM,WAAW,KAAM,CAAA,EAAE,IAAI,CAAC,KAAK,MAAM;AACjE,UAAA,IAAI,KAAK,MAAM;AACrB,WAAO,IAAI,IAAI,CAAC,OAAO,MAAM;AACrB,YAAA,IAAI,KAAK,OAAO;AACtB,YAAM,UAAU,IAAI,EAAE,GAAG,GAAG;AACtB,YAAA,QAAQ,MAAM,eAAe,OAAO;AAEtC,UAAA;AACF,YAAI,UAAU,SAAS;AACrB,gBAAM,IAAI,aAAa,SAAS,+BAA+B,IAAI,MAAM,KAAe,CAAC;AAAA,QAAA,WAChF,iBAAiB,cAAc;AAClC,gBAAA;AAAA,QAAA,WACG,SAAS,MAAM;AACjB,iBAAA;AAAA,QAAA;AAEH,cAAA,eAAe,SAAS,OAAO;AAC/B,cAAA,SAAS,aAAa,EAAE,OAAO,OAAO,OAAO,QAAQ,EAAE,GAAG,EAAE,GAAG;AAC/D,cAAA,eAAe,SAAS,MAAM;AAC7B,eAAA;AAAA,eACA,GAAG;AACJ,cAAA,eAAe,SAAS,CAAC;AAC/B,YAAI,OAAO;AACH,gBAAA;AAAA,QAAA;AAED,eAAA;AAAA,MAAA;AAAA,IACT,CACD;AAAA,EAAA,CACF;AACH;"}
|