forked from qlik-oss/sn-pivot-table
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,875 additions
and
4,851 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
module.exports = { | ||
plugins: ['react-native-web'], | ||
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/typescript'], | ||
}; |
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
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,87 +1,51 @@ | ||
import React from 'react'; | ||
import { View, Text, StyleSheet } from 'react-native'; | ||
import { Model } from '../../types/types'; | ||
import { Cell, TYPE } from '../handle-data'; | ||
import { ItemData, TYPE } from '../../types/types'; | ||
import DimensionCell from './DimensionCell'; | ||
import MeasureCell from './MeasureCell'; | ||
import sharedStyles from './shared-styles'; | ||
import DimensionTitleCell from './DimensionTitleCell'; | ||
import EmptyHeaderCell from './EmptyHeaderCell'; | ||
import EmptyCell from './EmptyCell'; | ||
|
||
export interface CellFactoryProps { | ||
cell: Cell; | ||
interface GridCallbackProps { | ||
columnIndex: number; | ||
rowIndex: number; | ||
colIndex: number; | ||
model: Model; | ||
isLeftColumn?: boolean; | ||
isHeader?: boolean; | ||
style: ReactWindow.ItemStyle; | ||
data: ItemData; | ||
} | ||
|
||
const borderColor = 'rgb(230, 230, 230)'; | ||
const color = 'rgb(89, 89, 89)'; | ||
const minHeight = 24; | ||
const CellFactory = ({ columnIndex, rowIndex, style, data }: GridCallbackProps): JSX.Element | null => { | ||
const { model, pivotData } = data; | ||
const cell = pivotData.matrix[columnIndex][rowIndex]; | ||
|
||
const styles = StyleSheet.create({ | ||
mergedCell: { | ||
borderLeftWidth: 0, | ||
borderBottomWidth: 1, | ||
borderColor, | ||
}, | ||
cell: { | ||
color, | ||
borderLeftWidth: 1, | ||
borderBottomWidth: 1, | ||
borderColor, | ||
paddingLeft: 4, | ||
paddingRight: 4, | ||
minHeight, | ||
justifyContent: 'center', | ||
}, | ||
label: { | ||
fontWeight: 500, | ||
color, | ||
borderLeftWidth: 1, | ||
borderBottomWidth: 1, | ||
borderColor, | ||
paddingLeft: 4, | ||
paddingRight: 4, | ||
minHeight, | ||
justifyContent: 'center', | ||
}, | ||
header: { | ||
minHeight: 36 | ||
}, | ||
labelText: { | ||
fontStyle: 'italic', | ||
}, | ||
}); | ||
|
||
const CellFactory = ({ cell, model, isLeftColumn = false, isHeader = false, rowIndex, colIndex }: CellFactoryProps): JSX.Element => { | ||
if (cell.type === TYPE.DIMENSION) { | ||
const isLeftColumn = rowIndex >= pivotData.nbrTopRows; | ||
|
||
return <DimensionCell | ||
cell={cell} | ||
model={model} | ||
rowIndex={rowIndex} | ||
colIndex={colIndex} | ||
style={isHeader ? [styles.cell, styles.header] : styles.cell} | ||
isLeftColumn={isLeftColumn} | ||
/> | ||
rowIndex={isLeftColumn ? rowIndex - pivotData.nbrTopRows : rowIndex} | ||
colIndex={isLeftColumn ? columnIndex : columnIndex - pivotData.nbrLeftColumns} | ||
style={style} | ||
/>; | ||
} | ||
|
||
if (cell.type === TYPE.MEASURE) { | ||
return <MeasureCell cell={cell} style={styles.cell} /> | ||
return <MeasureCell | ||
cell={cell} | ||
style={style} | ||
/> | ||
} | ||
|
||
if (cell.type === TYPE.LABEL) { | ||
return ( | ||
<View style={[styles.label, styles.header]}> | ||
<Text style={[sharedStyles.text, styles.labelText]}>{cell.value}</Text> | ||
</View>) | ||
return <DimensionTitleCell cell={cell} style={style} /> | ||
} | ||
|
||
if (isHeader) { | ||
return <View style={[styles.mergedCell, styles.header]}>{null}</View> | ||
if (cell.type === TYPE.EMPTY && rowIndex < pivotData.nbrTopRows) { | ||
return <EmptyHeaderCell style={style} /> | ||
} | ||
|
||
return <View style={styles.cell}>{null}</View> | ||
}; | ||
return <EmptyCell style={style} /> | ||
} | ||
|
||
export default CellFactory; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import { Cell } from '../../types/types'; | ||
import { borderStyle, textStyle } from './shared-styles'; | ||
|
||
interface LabelCellProps { | ||
cell: Cell; | ||
style: ReactWindow.ItemStyle; | ||
} | ||
|
||
const labelTextStyle: React.CSSProperties = { | ||
...textStyle, | ||
fontStyle: 'italic' | ||
}; | ||
|
||
const DimensionTitleCell = ({ cell, style }: LabelCellProps): JSX.Element => ( | ||
<div style={{ ...style, ...borderStyle }}> | ||
<div style={labelTextStyle}>{cell.value}</div> | ||
</div> | ||
); | ||
|
||
export default DimensionTitleCell; |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import { borderStyle } from './shared-styles'; | ||
|
||
interface EmptyCellProps { | ||
style: ReactWindow.ItemStyle; | ||
} | ||
|
||
const EmptyCell = ({ style }: EmptyCellProps): JSX.Element => ( | ||
<div style={{ ...style, ...borderStyle }}> | ||
{null} | ||
</div> | ||
); | ||
|
||
export default EmptyCell; |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import { borderStyle } from './shared-styles'; | ||
|
||
interface EmptyHeaderCellProps { | ||
style: ReactWindow.ItemStyle; | ||
} | ||
|
||
const EmptyHeaderCell = ({ style }: EmptyHeaderCellProps): JSX.Element => ( | ||
<div style={{ ...style, ...borderStyle, ...{ borderLeftWidth: 0 } }}> | ||
{null} | ||
</div> | ||
); | ||
|
||
export default EmptyHeaderCell; |
Oops, something went wrong.