mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Guess numeric formatting options
Summary: Change NumberParse.parse to return not just the parsed number but also information it gathered along the way about how the input string was formatted. Use this in the new NumberParse.guessOptions to guess the actual widget options based on an array of strings. Use NumberParse.guessOptions in TypeConversion (for when a user explicitly chooses to change type) and in ValueGuesser (for guesses about strings entered into empty columns). Test Plan: Adds unit tests for NumberParse and ValueGuesser and updates the TypeChange2 nbrowser test. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3294
This commit is contained in:
@@ -19,12 +19,14 @@
|
||||
*/
|
||||
|
||||
import {clamp} from 'app/common/gutil';
|
||||
import {StringUnion} from 'app/common/StringUnion';
|
||||
import * as LocaleCurrency from "locale-currency";
|
||||
import {FormatOptions} from 'app/common/ValueFormatter';
|
||||
import {DocumentSettings} from 'app/common/DocumentSettings';
|
||||
|
||||
// Options for number formatting.
|
||||
export type NumMode = 'currency' | 'decimal' | 'percent' | 'scientific';
|
||||
export const NumMode = StringUnion('currency', 'decimal', 'percent', 'scientific');
|
||||
export type NumMode = typeof NumMode.type;
|
||||
export type NumSign = 'parens';
|
||||
|
||||
export interface NumberFormatOptions extends FormatOptions {
|
||||
|
||||
Reference in New Issue
Block a user