Skip to content

Commit

Permalink
docs updates, event outside
Browse files Browse the repository at this point in the history
  • Loading branch information
revolist committed Sep 18, 2020
1 parent 3e5207d commit 70ae87c
Show file tree
Hide file tree
Showing 21 changed files with 292 additions and 166 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@revolist/revogrid",
"version": "1.4.5",
"version": "1.4.6",
"description": "Virtual reactive data grid component - RevoGrid.",
"license": "MIT",
"bugs": {
Expand Down
62 changes: 45 additions & 17 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export namespace Components {
/**
* Static stores, not expected to change during component lifetime
*/
"dataStore": ObservableMap<DataSourceState<RevoGrid.DataType>>;
"dataStore": ObservableMap<DataSourceState<RevoGrid.DataType, RevoGrid.DimensionRows>>;
"dimensionRow": ObservableMap<RevoGrid.DimensionSettingsState>;
"range": boolean;
"readonly": boolean;
Expand Down Expand Up @@ -94,7 +94,7 @@ export namespace Components {
/**
* Static stores, not expected to change during component lifetime
*/
"dataStore": ObservableMap<DataSourceState<RevoGrid.DataType>>;
"dataStore": ObservableMap<DataSourceState<RevoGrid.DataType, RevoGrid.DimensionRows>>;
"dragStart": (e: MouseEvent, data: { el: HTMLElement; rows: RevoGrid.DimensionSettingsState; cols: RevoGrid.DimensionSettingsState; }) => Promise<void>;
"endOrder": (e: MouseEvent, data: { el: HTMLElement; rows: RevoGrid.DimensionSettingsState; cols: RevoGrid.DimensionSettingsState; }) => Promise<void>;
}
Expand All @@ -104,7 +104,7 @@ export namespace Components {
/**
* Static stores, not expected to change during component lifetime
*/
"dataStore": ObservableMap<DataSourceState<RevoGrid.DataType>>;
"dataStore": ObservableMap<DataSourceState<RevoGrid.DataType, RevoGrid.DimensionRows>>;
"dimensionCol": ObservableMap<RevoGrid.DimensionSettingsState>;
"dimensionRow": ObservableMap<RevoGrid.DimensionSettingsState>;
/**
Expand All @@ -129,7 +129,7 @@ export namespace Components {
"virtualSize": number;
}
interface RevogrViewport {
"columnStores": {[T in RevoGrid.DimensionCols]: ObservableMap<DataSourceState<RevoGrid.ColumnDataSchemaRegular>>};
"columnStores": {[T in RevoGrid.DimensionCols]: ObservableMap<DataSourceState<RevoGrid.ColumnDataSchemaRegular, RevoGrid.DimensionCols>>};
"dimensions": {[T in RevoGrid.MultiDimensionType]: ObservableMap<RevoGrid.DimensionSettingsState>};
/**
* Custom editors register
Expand All @@ -138,7 +138,7 @@ export namespace Components {
"range": boolean;
"readonly": boolean;
"resize": boolean;
"rowStores": {[T in RevoGrid.DimensionRows]: ObservableMap<DataSourceState<RevoGrid.DataType>>};
"rowStores": {[T in RevoGrid.DimensionRows]: ObservableMap<DataSourceState<RevoGrid.DataType, RevoGrid.DimensionRows>>};
"uuid": string|null;
"viewports": {[T in RevoGrid.MultiDimensionType]: ObservableMap<RevoGrid.ViewportState>};
}
Expand Down Expand Up @@ -233,6 +233,32 @@ declare namespace LocalJSX {
* Defines how many rows/columns should be rendered outside visible area.
*/
"frameSize"?: number;
/**
* After edit. Triggered when after data applied.
*/
"onAfterEdit"?: (event: CustomEvent<Edition.BeforeSaveDataDetails>) => void;
/**
* Before autofill. Triggered before autofill applied. Use e.preventDefault() to prevent edit data apply.
*/
"onBeforeAutofill"?: (event: CustomEvent<{
newRange: {start: Selection.Cell; end: Selection.Cell;};
oldRange: {start: Selection.Cell; end: Selection.Cell;};
}>) => void;
/**
* Before edit event. Triggered before edit data applied. Use e.preventDefault() to prevent edit data set and use you own. Use e.val = {your value} to replace edit result with your own.
*/
"onBeforeEdit"?: (event: CustomEvent<Edition.BeforeSaveDataDetails>) => void;
/**
* Before range apply. Triggered before range applied. Use e.preventDefault() to prevent range.
*/
"onBeforeRange"?: (event: CustomEvent<{
newRange: {start: Selection.Cell; end: Selection.Cell;};
oldRange: {start: Selection.Cell; end: Selection.Cell;};
}>) => void;
/**
* Before row order apply. Use e.preventDefault() to prevent row order change.
*/
"onRowOrderChanged"?: (event: CustomEvent<{from: number; to: number;}>) => void;
/**
* Pinned bottom Source: {[T in ColumnProp]: any} - defines pinned bottom rows data source.
*/
Expand Down Expand Up @@ -273,7 +299,7 @@ declare namespace LocalJSX {
/**
* Static stores, not expected to change during component lifetime
*/
"dataStore"?: ObservableMap<DataSourceState<RevoGrid.DataType>>;
"dataStore"?: ObservableMap<DataSourceState<RevoGrid.DataType, RevoGrid.DimensionRows>>;
"dimensionRow"?: ObservableMap<RevoGrid.DimensionSettingsState>;
"onDragStartCell"?: (event: CustomEvent<MouseEvent>) => void;
"range"?: boolean;
Expand All @@ -288,6 +314,9 @@ declare namespace LocalJSX {
*/
"editor"?: Edition.EditorCtr|null;
"onCellEdit"?: (event: CustomEvent<Edition.SaveDataDetails>) => void;
/**
* Close editor event
*/
"onCloseEdit"?: (event: CustomEvent<any>) => void;
}
interface RevogrHeader {
Expand All @@ -305,7 +334,11 @@ declare namespace LocalJSX {
/**
* Static stores, not expected to change during component lifetime
*/
"dataStore"?: ObservableMap<DataSourceState<RevoGrid.DataType>>;
"dataStore"?: ObservableMap<DataSourceState<RevoGrid.DataType, RevoGrid.DimensionRows>>;
/**
* Row dragged, new range ready to be applied
*/
"onInitialRowDropped"?: (event: CustomEvent<{from: number; to: number;}>) => void;
/**
* Row drag started
*/
Expand All @@ -314,18 +347,14 @@ declare namespace LocalJSX {
* Row drag started
*/
"onRowDragStart"?: (event: CustomEvent<{cell: Selection.Cell, text: string}>) => void;
/**
* Row dragged, new range ready to be applied
*/
"onRowDropped"?: (event: CustomEvent<{from: number; to: number;}>) => void;
}
interface RevogrOverlaySelection {
"canDrag"?: boolean;
"colData"?: RevoGrid.ColumnDataSchemaRegular[];
/**
* Static stores, not expected to change during component lifetime
*/
"dataStore"?: ObservableMap<DataSourceState<RevoGrid.DataType>>;
"dataStore"?: ObservableMap<DataSourceState<RevoGrid.DataType, RevoGrid.DimensionRows>>;
"dimensionCol"?: ObservableMap<RevoGrid.DimensionSettingsState>;
"dimensionRow"?: ObservableMap<RevoGrid.DimensionSettingsState>;
/**
Expand All @@ -336,14 +365,13 @@ declare namespace LocalJSX {
* Last cell position
*/
"lastCell"?: Selection.Cell;
"onAfterEdit"?: (event: CustomEvent<Edition.BeforeSaveDataDetails>) => void;
"onBeforeEdit"?: (event: CustomEvent<Edition.BeforeSaveDataDetails>) => void;
"onCellEditInitiate"?: (event: CustomEvent<Edition.BeforeSaveDataDetails>) => void;
"onChangeSelection"?: (event: CustomEvent<{changes: Partial<Selection.Cell>; isMulti?: boolean; }>) => void;
"onFocusCell"?: (event: CustomEvent<{focus: Selection.Cell; end: Selection.Cell; }>) => void;
/**
* Selection range changed
*/
"onSelectionChanged"?: (event: CustomEvent<{
"onInitialSelectionChanged"?: (event: CustomEvent<{
newRange: {start: Selection.Cell; end: Selection.Cell;};
oldRange: {start: Selection.Cell; end: Selection.Cell;};
}>) => void;
Expand All @@ -363,7 +391,7 @@ declare namespace LocalJSX {
"virtualSize"?: number;
}
interface RevogrViewport {
"columnStores"?: {[T in RevoGrid.DimensionCols]: ObservableMap<DataSourceState<RevoGrid.ColumnDataSchemaRegular>>};
"columnStores"?: {[T in RevoGrid.DimensionCols]: ObservableMap<DataSourceState<RevoGrid.ColumnDataSchemaRegular, RevoGrid.DimensionCols>>};
"dimensions"?: {[T in RevoGrid.MultiDimensionType]: ObservableMap<RevoGrid.DimensionSettingsState>};
/**
* Custom editors register
Expand All @@ -375,7 +403,7 @@ declare namespace LocalJSX {
"range"?: boolean;
"readonly"?: boolean;
"resize"?: boolean;
"rowStores"?: {[T in RevoGrid.DimensionRows]: ObservableMap<DataSourceState<RevoGrid.DataType>>};
"rowStores"?: {[T in RevoGrid.DimensionRows]: ObservableMap<DataSourceState<RevoGrid.DataType, RevoGrid.DimensionRows>>};
"uuid"?: string|null;
"viewports"?: {[T in RevoGrid.MultiDimensionType]: ObservableMap<RevoGrid.ViewportState>};
}
Expand Down
21 changes: 5 additions & 16 deletions src/components/data/columnService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import DataType = RevoGrid.DataType;
export interface ColumnServiceI {
columns: RevoGrid.ColumnDataSchemaRegular[];

setCellData(r: number, c: number, val: string): void;

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

isReadOnly(r: number, c: number): boolean;
Expand All @@ -33,7 +31,7 @@ export default class ColumnService implements ColumnServiceI {
}

constructor(
private dataStore: ObservableMap<DataSourceState<RevoGrid.DataType>>,
private dataStore: ObservableMap<DataSourceState<RevoGrid.DataType, RevoGrid.DimensionRows>>,
columns: RevoGrid.ColumnDataSchemaRegular[]) {
this.source = columns;
}
Expand All @@ -54,24 +52,14 @@ export default class ColumnService implements ColumnServiceI {
return;
}

setCellData(r: number, c: number, val: string): void {
const {data, model, prop} = this.rowDataModel(r, c);
model[prop as number] = val;
this.dataStore.set('items', [...data]);
}

getCellData(r: number, c: number): string {
const {prop, model} = this.rowDataModel(r, c);
return ColumnService.getData(model[prop as number]);
}

getSaveData(r: number, c: number, val: string): BeforeSaveDataDetails {
const {prop, model} = this.rowDataModel(r, c);
return {
prop,
model,
val
}
getSaveData(rowIndex: number, c: number, val: string): BeforeSaveDataDetails {
const {prop} = this.rowDataModel(rowIndex, c);
return { prop, rowIndex, val, type: this.dataStore.get('type')};
}

getCellEditor(_r: number, c: number): string | undefined {
Expand All @@ -81,6 +69,7 @@ export default class ColumnService implements ColumnServiceI {
rowDataModel(r: number, c: number): ColumnDataSchemaModel {
const column = this.columns[c];
const prop: ColumnProp | undefined = column?.prop;

const data: DataSource = this.dataStore.get('items');
const model: DataType = data[r] || {};
return {prop, model, data, column};
Expand Down
20 changes: 10 additions & 10 deletions src/components/data/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

## Properties

| Property | Attribute | Description | Type | Default |
| -------------- | ---------- | --------------------------------------------------------------- | ------------------------------------------ | ----------- |
| `canDrag` | `can-drag` | | `boolean` | `undefined` |
| `colData` | -- | | `ColumnDataSchemaRegular[]` | `undefined` |
| `cols` | -- | | `VirtualPositionItem[]` | `undefined` |
| `dataStore` | -- | Static stores, not expected to change during component lifetime | `ObservableMap<DataSourceState<DataType>>` | `undefined` |
| `dimensionRow` | -- | | `ObservableMap<DimensionSettingsState>` | `undefined` |
| `range` | `range` | | `boolean` | `undefined` |
| `readonly` | `readonly` | | `boolean` | `undefined` |
| `rows` | -- | | `VirtualPositionItem[]` | `undefined` |
| Property | Attribute | Description | Type | Default |
| -------------- | ---------- | --------------------------------------------------------------- | --------------------------------------------------------- | ----------- |
| `canDrag` | `can-drag` | | `boolean` | `undefined` |
| `colData` | -- | | `ColumnDataSchemaRegular[]` | `undefined` |
| `cols` | -- | | `VirtualPositionItem[]` | `undefined` |
| `dataStore` | -- | Static stores, not expected to change during component lifetime | `ObservableMap<DataSourceState<DataType, DimensionRows>>` | `undefined` |
| `dimensionRow` | -- | | `ObservableMap<DimensionSettingsState>` | `undefined` |
| `range` | `range` | | `boolean` | `undefined` |
| `readonly` | `readonly` | | `boolean` | `undefined` |
| `rows` | -- | | `VirtualPositionItem[]` | `undefined` |


## Events
Expand Down
2 changes: 1 addition & 1 deletion src/components/data/revogr-data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class RevogrData {
@Prop() dimensionRow: ObservableMap<RevoGrid.DimensionSettingsState>;

/** Static stores, not expected to change during component lifetime */
@Prop() dataStore: ObservableMap<DataSourceState<RevoGrid.DataType>>;
@Prop() dataStore: ObservableMap<DataSourceState<RevoGrid.DataType, RevoGrid.DimensionRows>>;

@Event() dragStartCell: EventEmitter<MouseEvent>;

Expand Down
Loading

0 comments on commit 70ae87c

Please sign in to comment.