forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose factory functions as public API (apache#43)
feat: Expose factory functions through API
- Loading branch information
Showing
10 changed files
with
129 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,63 @@ | ||
export const DOLLAR = '$,.2f'; | ||
export const DOLLAR_CHANGE = '+$,.2f'; | ||
export const DOLLAR_ROUND = '$,d'; | ||
export const DOLLAR_ROUND_CHANGE = '+$,d'; | ||
|
||
export const FLOAT_1_POINT = ',.1f'; | ||
export const FLOAT_2_POINT = ',.2f'; | ||
export const FLOAT_3_POINT = ',.3f'; | ||
export const FLOAT = FLOAT_2_POINT; | ||
|
||
export const FLOAT_CHANGE_1_POINT = '+,.1f'; | ||
export const FLOAT_CHANGE_2_POINT = '+,.2f'; | ||
export const FLOAT_CHANGE_3_POINT = '+,.3f'; | ||
export const FLOAT_CHANGE = FLOAT_CHANGE_2_POINT; | ||
|
||
export const INTEGER = ',d'; | ||
export const INTEGER_CHANGE = '+,d'; | ||
|
||
export const PERCENT_1_POINT = ',.1%'; | ||
export const PERCENT_2_POINT = ',.2%'; | ||
export const PERCENT_3_POINT = ',.3%'; | ||
export const PERCENT = PERCENT_2_POINT; | ||
|
||
export const PERCENT_CHANGE_1_POINT = '+,.1%'; | ||
export const PERCENT_CHANGE_2_POINT = '+,.2%'; | ||
export const PERCENT_CHANGE_3_POINT = '+,.3%'; | ||
export const PERCENT_CHANGE = PERCENT_CHANGE_2_POINT; | ||
|
||
export const SI_1_DIGIT = '.1s'; | ||
export const SI_2_DIGIT = '.2s'; | ||
export const SI_3_DIGIT = '.3s'; | ||
const DOLLAR = '$,.2f'; | ||
const DOLLAR_CHANGE = '+$,.2f'; | ||
const DOLLAR_ROUND = '$,d'; | ||
const DOLLAR_ROUND_CHANGE = '+$,d'; | ||
|
||
const FLOAT_1_POINT = ',.1f'; | ||
const FLOAT_2_POINT = ',.2f'; | ||
const FLOAT_3_POINT = ',.3f'; | ||
const FLOAT = FLOAT_2_POINT; | ||
|
||
const FLOAT_CHANGE_1_POINT = '+,.1f'; | ||
const FLOAT_CHANGE_2_POINT = '+,.2f'; | ||
const FLOAT_CHANGE_3_POINT = '+,.3f'; | ||
const FLOAT_CHANGE = FLOAT_CHANGE_2_POINT; | ||
|
||
const INTEGER = ',d'; | ||
const INTEGER_CHANGE = '+,d'; | ||
|
||
const PERCENT_1_POINT = ',.1%'; | ||
const PERCENT_2_POINT = ',.2%'; | ||
const PERCENT_3_POINT = ',.3%'; | ||
const PERCENT = PERCENT_2_POINT; | ||
|
||
const PERCENT_CHANGE_1_POINT = '+,.1%'; | ||
const PERCENT_CHANGE_2_POINT = '+,.2%'; | ||
const PERCENT_CHANGE_3_POINT = '+,.3%'; | ||
const PERCENT_CHANGE = PERCENT_CHANGE_2_POINT; | ||
|
||
const SI_1_DIGIT = '.1s'; | ||
const SI_2_DIGIT = '.2s'; | ||
const SI_3_DIGIT = '.3s'; | ||
const SI = SI_3_DIGIT; | ||
|
||
const NumberFormats = { | ||
DOLLAR, | ||
DOLLAR_CHANGE, | ||
DOLLAR_ROUND, | ||
DOLLAR_ROUND_CHANGE, | ||
FLOAT, | ||
FLOAT_1_POINT, | ||
FLOAT_2_POINT, | ||
FLOAT_3_POINT, | ||
FLOAT_CHANGE, | ||
FLOAT_CHANGE_1_POINT, | ||
FLOAT_CHANGE_2_POINT, | ||
FLOAT_CHANGE_3_POINT, | ||
INTEGER, | ||
INTEGER_CHANGE, | ||
PERCENT, | ||
PERCENT_1_POINT, | ||
PERCENT_2_POINT, | ||
PERCENT_3_POINT, | ||
PERCENT_CHANGE, | ||
PERCENT_CHANGE_1_POINT, | ||
PERCENT_CHANGE_2_POINT, | ||
PERCENT_CHANGE_3_POINT, | ||
SI, | ||
SI_1_DIGIT, | ||
SI_2_DIGIT, | ||
SI_3_DIGIT, | ||
}; | ||
|
||
export default NumberFormats; |
6 changes: 2 additions & 4 deletions
6
packages/superset-ui-number-format/src/NumberFormatterRegistry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import * as NumberFormats from './NumberFormats'; | ||
export { default as NumberFormats } from './NumberFormats'; | ||
export { default as NumberFormatter, PREVIEW_VALUE } from './NumberFormatter'; | ||
|
||
export { | ||
default as getNumberFormatterRegistry, | ||
formatNumber, | ||
getNumberFormatter, | ||
} from './NumberFormatterRegistrySingleton'; | ||
|
||
export { default as NumberFormatter, PREVIEW_VALUE } from './NumberFormatter'; | ||
export { NumberFormats }; | ||
export { default as createD3NumberFormatter } from './factories/createD3NumberFormatter'; | ||
export { | ||
default as createSiAtMostNDigitFormatter, | ||
} from './factories/createSiAtMostNDigitFormatter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
export const LOCAL_PREFIX = 'local!'; | ||
|
||
export const DATABASE_DATETIME = '%Y-%m-%d %H:%M:%S'; | ||
export const DATABASE_DATETIME_REVERSE = '%d-%m-%Y %H:%M:%S'; | ||
export const US_DATE = '%m/%d/%Y'; | ||
export const INTERNATIONAL_DATE = '%d/%m/%Y'; | ||
export const DATABASE_DATE = '%Y-%m-%d'; | ||
export const TIME = '%H:%M:%S'; | ||
const DATABASE_DATETIME = '%Y-%m-%d %H:%M:%S'; | ||
const DATABASE_DATETIME_REVERSE = '%d-%m-%Y %H:%M:%S'; | ||
const US_DATE = '%m/%d/%Y'; | ||
const INTERNATIONAL_DATE = '%d/%m/%Y'; | ||
const DATABASE_DATE = '%Y-%m-%d'; | ||
const TIME = '%H:%M:%S'; | ||
|
||
const TimeFormats = { | ||
DATABASE_DATE, | ||
DATABASE_DATETIME, | ||
DATABASE_DATETIME_REVERSE, | ||
INTERNATIONAL_DATE, | ||
TIME, | ||
US_DATE, | ||
}; | ||
|
||
export default TimeFormats; |
6 changes: 2 additions & 4 deletions
6
packages/superset-ui-time-format/src/TimeFormatterRegistry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import * as TimeFormats from './TimeFormats'; | ||
export { default as TimeFormats, LOCAL_PREFIX } from './TimeFormats'; | ||
export { default as TimeFormatter, PREVIEW_TIME } from './TimeFormatter'; | ||
|
||
export { | ||
default as getTimeFormatterRegistry, | ||
formatTime, | ||
getTimeFormatter, | ||
} from './TimeFormatterRegistrySingleton'; | ||
|
||
export { default as TimeFormatter, PREVIEW_TIME } from './TimeFormatter'; | ||
export { TimeFormats }; | ||
export { default as createD3TimeFormatter } from './factories/createD3TimeFormatter'; | ||
export { default as createMultiFormatter } from './factories/createMultiFormatter'; | ||
|
||
export { default as smartDateFormatter } from './formatters/smartDate'; | ||
export { default as smartDateVerboseFormatter } from './formatters/smartDateVerbose'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
import { | ||
createD3TimeFormatter, | ||
createMultiFormatter, | ||
formatTime, | ||
TimeFormats, | ||
getTimeFormatter, | ||
getTimeFormatterRegistry, | ||
TimeFormatter, | ||
LOCAL_PREFIX, | ||
PREVIEW_TIME, | ||
smartDateFormatter, | ||
smartDateVerboseFormatter, | ||
TimeFormats, | ||
TimeFormatter, | ||
} from '../src/index'; | ||
|
||
describe('index', () => { | ||
it('exports modules', () => { | ||
[ | ||
createD3TimeFormatter, | ||
createMultiFormatter, | ||
formatTime, | ||
TimeFormats, | ||
getTimeFormatter, | ||
getTimeFormatterRegistry, | ||
TimeFormatter, | ||
LOCAL_PREFIX, | ||
PREVIEW_TIME, | ||
smartDateFormatter, | ||
smartDateVerboseFormatter, | ||
TimeFormats, | ||
TimeFormatter, | ||
].forEach(x => expect(x).toBeDefined()); | ||
}); | ||
}); |