Skip to content

Commit

Permalink
type updates
Browse files Browse the repository at this point in the history
  • Loading branch information
revolist committed Sep 19, 2020
1 parent d1051ef commit c6e3166
Show file tree
Hide file tree
Showing 24 changed files with 194 additions and 131 deletions.
10 changes: 9 additions & 1 deletion custom-elements.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@
},
{
"name": "theme",
"description": "Theme name"
"description": "Theme name",
"values": [
{
"name": "default"
},
{
"name": "material"
}
]
}
]
},
Expand Down
39 changes: 18 additions & 21 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export namespace Components {
/**
* Columns - defines an array of grid columns. Can be column or grouped column.
*/
"columns": (RevoGrid.ColumnDataSchemaRegular|RevoGrid.ColumnDataSchemaGrouping)[];
"columns": (RevoGrid.ColumnRegular|RevoGrid.ColumnGrouping)[];
/**
* Custom editors register
*/
Expand Down Expand Up @@ -51,17 +51,17 @@ export namespace Components {
*/
"rowSize": number;
/**
* Source: {[T in ColumnProp]: any} - defines main data source. Can be an Object or 2 dimensional array([][]); ColumnProp - string|number. It is reference for column mapping.
* Source - defines main data source. Can be an Object or 2 dimensional array([][]); Keys/indexes referenced from columns Prop
*/
"source": RevoGrid.DataType[];
/**
* Theme name
*/
"theme": string;
"theme": 'default'|'material';
}
interface RevogrData {
"canDrag": boolean;
"colData": RevoGrid.ColumnDataSchemaRegular[];
"colData": RevoGrid.ColumnRegular[];
"cols": RevoGrid.VirtualPositionItem[];
/**
* Static stores, not expected to change during component lifetime
Expand All @@ -73,7 +73,7 @@ export namespace Components {
"rows": RevoGrid.VirtualPositionItem[];
}
interface RevogrEdit {
"column": RevoGrid.ColumnDataSchemaRegular|null;
"column": RevoGrid.ColumnRegular|null;
"editCell": Edition.EditCell;
/**
* Custom editors register
Expand All @@ -82,7 +82,7 @@ export namespace Components {
}
interface RevogrHeader {
"canResize": boolean;
"colData": RevoGrid.ColumnDataSchemaRegular[];
"colData": RevoGrid.ColumnRegular[];
"cols": RevoGrid.VirtualPositionItem[];
"dimensionCol": ObservableMap<RevoGrid.DimensionSettingsState>;
"groupingDepth": number;
Expand All @@ -100,7 +100,7 @@ export namespace Components {
}
interface RevogrOverlaySelection {
"canDrag": boolean;
"colData": RevoGrid.ColumnDataSchemaRegular[];
"colData": RevoGrid.ColumnRegular[];
/**
* Static stores, not expected to change during component lifetime
*/
Expand Down Expand Up @@ -129,7 +129,7 @@ export namespace Components {
"virtualSize": number;
}
interface RevogrViewport {
"columnStores": {[T in RevoGrid.DimensionCols]: ObservableMap<DataSourceState<RevoGrid.ColumnDataSchemaRegular, RevoGrid.DimensionCols>>};
"columnStores": {[T in RevoGrid.DimensionCols]: ObservableMap<DataSourceState<RevoGrid.ColumnRegular, RevoGrid.DimensionCols>>};
"dimensions": {[T in RevoGrid.MultiDimensionType]: ObservableMap<RevoGrid.DimensionSettingsState>};
/**
* Custom editors register
Expand Down Expand Up @@ -224,7 +224,7 @@ declare namespace LocalJSX {
/**
* Columns - defines an array of grid columns. Can be column or grouped column.
*/
"columns"?: (RevoGrid.ColumnDataSchemaRegular|RevoGrid.ColumnDataSchemaGrouping)[];
"columns"?: (RevoGrid.ColumnRegular|RevoGrid.ColumnGrouping)[];
/**
* Custom editors register
*/
Expand Down Expand Up @@ -284,17 +284,17 @@ declare namespace LocalJSX {
*/
"rowSize"?: number;
/**
* Source: {[T in ColumnProp]: any} - defines main data source. Can be an Object or 2 dimensional array([][]); ColumnProp - string|number. It is reference for column mapping.
* Source - defines main data source. Can be an Object or 2 dimensional array([][]); Keys/indexes referenced from columns Prop
*/
"source"?: RevoGrid.DataType[];
/**
* Theme name
*/
"theme"?: string;
"theme"?: 'default'|'material';
}
interface RevogrData {
"canDrag"?: boolean;
"colData"?: RevoGrid.ColumnDataSchemaRegular[];
"colData"?: RevoGrid.ColumnRegular[];
"cols"?: RevoGrid.VirtualPositionItem[];
/**
* Static stores, not expected to change during component lifetime
Expand All @@ -307,7 +307,7 @@ declare namespace LocalJSX {
"rows"?: RevoGrid.VirtualPositionItem[];
}
interface RevogrEdit {
"column"?: RevoGrid.ColumnDataSchemaRegular|null;
"column"?: RevoGrid.ColumnRegular|null;
"editCell"?: Edition.EditCell;
/**
* Custom editors register
Expand All @@ -321,12 +321,12 @@ declare namespace LocalJSX {
}
interface RevogrHeader {
"canResize"?: boolean;
"colData"?: RevoGrid.ColumnDataSchemaRegular[];
"colData"?: RevoGrid.ColumnRegular[];
"cols"?: RevoGrid.VirtualPositionItem[];
"dimensionCol"?: ObservableMap<RevoGrid.DimensionSettingsState>;
"groupingDepth"?: number;
"groups"?: Groups;
"onHeaderClick"?: (event: CustomEvent<RevoGrid.ColumnDataSchemaRegular>) => void;
"onHeaderClick"?: (event: CustomEvent<RevoGrid.ColumnRegular>) => void;
"onHeaderResize"?: (event: CustomEvent<RevoGrid.ViewSettingSizeProp>) => void;
"parent"?: string;
}
Expand All @@ -350,7 +350,7 @@ declare namespace LocalJSX {
}
interface RevogrOverlaySelection {
"canDrag"?: boolean;
"colData"?: RevoGrid.ColumnDataSchemaRegular[];
"colData"?: RevoGrid.ColumnRegular[];
/**
* Static stores, not expected to change during component lifetime
*/
Expand All @@ -371,10 +371,7 @@ declare namespace LocalJSX {
/**
* Selection range changed
*/
"onInitialSelectionChanged"?: (event: CustomEvent<{
newRange: {start: Selection.Cell; end: Selection.Cell;};
oldRange: {start: Selection.Cell; end: Selection.Cell;};
}>) => void;
"onInitialSelectionChanged"?: (event: CustomEvent<Selection.ChangedRange>) => void;
"onSetEdit"?: (event: CustomEvent<string|boolean>) => void;
"onUnregister"?: (event: CustomEvent<any>) => void;
"range"?: boolean;
Expand All @@ -391,7 +388,7 @@ declare namespace LocalJSX {
"virtualSize"?: number;
}
interface RevogrViewport {
"columnStores"?: {[T in RevoGrid.DimensionCols]: ObservableMap<DataSourceState<RevoGrid.ColumnDataSchemaRegular, RevoGrid.DimensionCols>>};
"columnStores"?: {[T in RevoGrid.DimensionCols]: ObservableMap<DataSourceState<RevoGrid.ColumnRegular, RevoGrid.DimensionCols>>};
"dimensions"?: {[T in RevoGrid.MultiDimensionType]: ObservableMap<RevoGrid.DimensionSettingsState>};
/**
* Custom editors register
Expand Down
10 changes: 5 additions & 5 deletions src/components/data/columnService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import DataSource = RevoGrid.DataSource;
import DataType = RevoGrid.DataType;

export interface ColumnServiceI {
columns: RevoGrid.ColumnDataSchemaRegular[];
columns: RevoGrid.ColumnRegular[];

customRenderer(r: number, c: number): VNode | void;

Expand All @@ -20,19 +20,19 @@ export interface ColumnServiceI {
}

export default class ColumnService implements ColumnServiceI {
private source: RevoGrid.ColumnDataSchemaRegular[] = [];
private source: RevoGrid.ColumnRegular[] = [];

get columns(): RevoGrid.ColumnDataSchemaRegular[] {
get columns(): RevoGrid.ColumnRegular[] {
return this.source;
}

set columns(source: RevoGrid.ColumnDataSchemaRegular[]) {
set columns(source: RevoGrid.ColumnRegular[]) {
this.source = source;
}

constructor(
private dataStore: ObservableMap<DataSourceState<RevoGrid.DataType, RevoGrid.DimensionRows>>,
columns: RevoGrid.ColumnDataSchemaRegular[]) {
columns: RevoGrid.ColumnRegular[]) {
this.source = columns;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/data/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| Property | Attribute | Description | Type | Default |
| -------------- | ---------- | --------------------------------------------------------------- | --------------------------------------------------------- | ----------- |
| `canDrag` | `can-drag` | | `boolean` | `undefined` |
| `colData` | -- | | `ColumnDataSchemaRegular[]` | `undefined` |
| `colData` | -- | | `ColumnRegular[]` | `undefined` |
| `cols` | -- | | `VirtualPositionItem[]` | `undefined` |
| `dataStore` | -- | Static stores, not expected to change during component lifetime | `ObservableMap<DataSourceState<DataType, DimensionRows>>` | `undefined` |
| `dimensionRow` | -- | | `ObservableMap<DimensionSettingsState>` | `undefined` |
Expand Down
4 changes: 2 additions & 2 deletions src/components/data/revogr-data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class RevogrData {
private columnService: ColumnService;

@Element() element!: HTMLStencilElement;
@Prop() colData: RevoGrid.ColumnDataSchemaRegular[];
@Prop() colData: RevoGrid.ColumnRegular[];

@Prop() readonly: boolean;
@Prop() range: boolean;
Expand All @@ -33,7 +33,7 @@ export class RevogrData {

@Event() dragStartCell: EventEmitter<MouseEvent>;

@Watch('colData') colChanged(newData: RevoGrid.ColumnDataSchemaRegular[]): void {
@Watch('colData') colChanged(newData: RevoGrid.ColumnRegular[]): void {
this.columnService.columns = newData;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/header/headerRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { RevoGrid } from '../../interfaces';
import { DATA_COL, HEADER_CLASS } from '../../utils/consts';

type Props = {
data: RevoGrid.ColumnDataSchemaRegular;
data: RevoGrid.ColumnRegular;
column: RevoGrid.VirtualPositionItem;
onClick(data: RevoGrid.ColumnDataSchemaRegular): void;
onClick(data: RevoGrid.ColumnRegular): void;
}

const HeaderRenderer = ({column, data, onClick}: Props, _children: VNode[]): VNode[] => {
Expand Down
10 changes: 5 additions & 5 deletions src/components/header/headerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ interface Config {
}

export default class HeaderService {
private source: RevoGrid.ColumnDataSchemaRegular[] = [];
get columns(): RevoGrid.ColumnDataSchemaRegular[] {
private source: RevoGrid.ColumnRegular[] = [];
get columns(): RevoGrid.ColumnRegular[] {
return this.source;
}
set columns(source: RevoGrid.ColumnDataSchemaRegular[]) {
set columns(source: RevoGrid.ColumnRegular[]) {
this.source = source;
}
constructor(private target: string, columns: RevoGrid.ColumnDataSchemaRegular[], private config: Config) {
constructor(private target: string, columns: RevoGrid.ColumnRegular[], private config: Config) {
this.columns = columns;
this.resizeChange(config.canResize);
}
Expand All @@ -28,7 +28,7 @@ export default class HeaderService {
edges: { bottom: false, right: true },
onend: event => {
const index: number = parseInt(event.target.getAttribute(DATA_COL), 10);
const col: RevoGrid.ColumnDataSchemaRegular = this.columns[index];
const col: RevoGrid.ColumnRegular = this.columns[index];
let width: number = event.rect.width;
const minSize: number = col.minSize || MIN_COL_SIZE;
if (width < minSize) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/header/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| Property | Attribute | Description | Type | Default |
| --------------- | ---------------- | ----------- | --------------------------------------- | ----------- |
| `canResize` | `can-resize` | | `boolean` | `undefined` |
| `colData` | -- | | `ColumnDataSchemaRegular[]` | `undefined` |
| `colData` | -- | | `ColumnRegular[]` | `undefined` |
| `cols` | -- | | `VirtualPositionItem[]` | `undefined` |
| `dimensionCol` | -- | | `ObservableMap<DimensionSettingsState>` | `undefined` |
| `groupingDepth` | `grouping-depth` | | `number` | `0` |
Expand All @@ -22,7 +22,7 @@

| Event | Description | Type |
| -------------- | ----------- | ------------------------------------------- |
| `headerClick` | | `CustomEvent<ColumnDataSchemaRegular>` |
| `headerClick` | | `CustomEvent<ColumnRegular>` |
| `headerResize` | | `CustomEvent<{ [index: string]: number; }>` |


Expand Down
6 changes: 3 additions & 3 deletions src/components/header/revogr-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export class RevogrHeaderComponent {
@Prop() groups: Groups;
@Prop() groupingDepth: number = 0;

@Event() headerClick: EventEmitter<RevoGrid.ColumnDataSchemaRegular>;
@Event() headerClick: EventEmitter<RevoGrid.ColumnRegular>;
@Event() headerResize: EventEmitter<RevoGrid.ViewSettingSizeProp>;
@Prop() canResize: boolean;

@Prop() colData: RevoGrid.ColumnDataSchemaRegular[];
@Prop() colData: RevoGrid.ColumnRegular[];
private headerService: HeaderService;

@Watch('colData') colChanged(newVal: RevoGrid.ColumnDataSchemaRegular[]): void {
@Watch('colData') colChanged(newVal: RevoGrid.ColumnRegular[]): void {
this.headerService.columns = newVal;
}
@Watch('canResize') onResizeChanged(newVal: boolean) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/overlay/editors/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class TextEditor implements Edition.EditorBase {
public editCell: Edition.EditCell|null = null;

constructor(
public column: RevoGrid.ColumnDataSchemaRegular,
public column: RevoGrid.ColumnRegular,
private editCallback?: (value: Edition.SaveData) => void
) {}

Expand Down
2 changes: 1 addition & 1 deletion src/components/overlay/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| Property | Attribute | Description | Type | Default |
| ---------------- | ---------- | --------------------------------------------------------------- | --------------------------------------------------------- | ----------- |
| `canDrag` | `can-drag` | | `boolean` | `undefined` |
| `colData` | -- | | `ColumnDataSchemaRegular[]` | `undefined` |
| `colData` | -- | | `ColumnRegular[]` | `undefined` |
| `dataStore` | -- | Static stores, not expected to change during component lifetime | `ObservableMap<DataSourceState<DataType, DimensionRows>>` | `undefined` |
| `dimensionCol` | -- | | `ObservableMap<DimensionSettingsState>` | `undefined` |
| `dimensionRow` | -- | | `ObservableMap<DimensionSettingsState>` | `undefined` |
Expand Down
2 changes: 1 addition & 1 deletion src/components/overlay/revogr-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class Edit {
@Prop() editCell: Edition.EditCell;
private currentEditor: Edition.EditorBase|null = null;

@Prop() column: RevoGrid.ColumnDataSchemaRegular|null;
@Prop() column: RevoGrid.ColumnRegular|null;
/** Custom editors register */
@Prop() editor: Edition.EditorCtr|null;

Expand Down
9 changes: 3 additions & 6 deletions src/components/overlay/revogr-overlay-selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ export class OverlaySelection {
/** Static stores, not expected to change during component lifetime */
@Prop() dataStore: ObservableMap<DataSourceState<RevoGrid.DataType, RevoGrid.DimensionRows>>;

@Prop() colData: RevoGrid.ColumnDataSchemaRegular[];
@Prop() colData: RevoGrid.ColumnRegular[];
/** Last cell position */
@Prop() lastCell: Selection.Cell;
/** Custom editors register */
@Prop() editors: Edition.Editors;

@Watch('colData') colChanged(newData: RevoGrid.ColumnDataSchemaRegular[]): void {
@Watch('colData') colChanged(newData: RevoGrid.ColumnRegular[]): void {
this.columnService.columns = newData;
}
@Watch('lastCell') lastCellChanged(cell: Cell): void {
Expand All @@ -70,10 +70,7 @@ export class OverlaySelection {
@Event({ bubbles: false }) unregister: EventEmitter;

/** Selection range changed */
@Event({ cancelable: true }) initialSelectionChanged: EventEmitter<{
newRange: {start: Selection.Cell; end: Selection.Cell;};
oldRange: {start: Selection.Cell; end: Selection.Cell;};
}>;
@Event({ cancelable: true }) initialSelectionChanged: EventEmitter<Selection.ChangedRange>;

/** Pointer left document, clear any active operation */
@Listen('mouseleave', { target: 'document' })
Expand Down
Loading

0 comments on commit c6e3166

Please sign in to comment.