-
Notifications
You must be signed in to change notification settings - Fork 138
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
1 parent
c64775b
commit 1eb92eb
Showing
142 changed files
with
3,694 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
/lib | ||
|
||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
# /dist | ||
# /build | ||
# public | ||
.cache | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
/cypress/screenshots | ||
/cypress/snapshots |
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,12 @@ | ||
.circleci | ||
node_modules | ||
build | ||
cypress | ||
cypress.json | ||
public | ||
src | ||
tsconfig.*json | ||
package.*json | ||
azure-pipelines-upgrade-rc-version.yml | ||
snapshots.js | ||
.gitignore |
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,5 @@ | ||
import { PointerEvent } from '../Functions'; | ||
import { State, Location, Behavior } from '../Model'; | ||
export declare class CellSelectionBehavior extends Behavior { | ||
handlePointerDown(event: PointerEvent, location: Location, state: State): State; | ||
} |
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,28 @@ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
import { focusLocation } from '../Functions'; | ||
import { Behavior } from '../Model'; | ||
var CellSelectionBehavior = (function (_super) { | ||
__extends(CellSelectionBehavior, _super); | ||
function CellSelectionBehavior() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
CellSelectionBehavior.prototype.handlePointerDown = function (event, location, state) { | ||
if (event.target.className === 'reactgrid-content') | ||
return state; | ||
return focusLocation(state, location); | ||
}; | ||
return CellSelectionBehavior; | ||
}(Behavior)); | ||
export { CellSelectionBehavior }; |
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,11 @@ | ||
import { State, Behavior, KeyboardEvent, ClipboardEvent, PointerEvent, Location, PointerLocation } from "../Model"; | ||
export declare class DefaultBehavior extends Behavior { | ||
handlePointerDown(event: PointerEvent, location: PointerLocation, state: State): State; | ||
private getNewBehavior; | ||
handleDoubleClick(event: PointerEvent, location: Location, state: State): State; | ||
handleKeyDown(event: KeyboardEvent, state: State): State; | ||
handleKeyUp(event: KeyboardEvent, state: State): State; | ||
handleCopy(event: ClipboardEvent, state: State): State; | ||
handlePaste(event: ClipboardEvent, state: State): State; | ||
handleCut(event: ClipboardEvent, state: State): State; | ||
} |
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,93 @@ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import { Behavior } from "../Model"; | ||
import { handleKeyDown } from "../Functions/handleKeyDown"; | ||
import { keyCodes, isBrowserSafari } from "../Functions"; | ||
import { getCompatibleCellAndTemplate } from '../Functions/getCompatibleCellAndTemplate'; | ||
import { areLocationsEqual } from '../Functions/areLocationsEqual'; | ||
import { isSelectionKey } from '../Functions/isSelectionKey'; | ||
import { CellSelectionBehavior } from './CellSelectionBehavior'; | ||
import { handlePaste } from '../Functions/handlePaste'; | ||
import { copySelectedRangeToClipboardOnSafari, copySelectedRangeToClipboard } from '../Functions/copySelectedRange'; | ||
var DefaultBehavior = (function (_super) { | ||
__extends(DefaultBehavior, _super); | ||
function DefaultBehavior() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
DefaultBehavior.prototype.handlePointerDown = function (event, location, state) { | ||
state = __assign(__assign({}, state), { currentBehavior: this.getNewBehavior(event, location, state) }); | ||
return state.currentBehavior.handlePointerDown(event, location, state); | ||
}; | ||
DefaultBehavior.prototype.getNewBehavior = function (event, location, state) { | ||
return new CellSelectionBehavior(); | ||
}; | ||
DefaultBehavior.prototype.handleDoubleClick = function (event, location, state) { | ||
if (areLocationsEqual(location, state.focusedLocation)) { | ||
var _a = getCompatibleCellAndTemplate(state, location), cell = _a.cell, cellTemplate = _a.cellTemplate; | ||
if (cellTemplate.handleKeyDown) { | ||
var _b = cellTemplate.handleKeyDown(cell, 1, isSelectionKey(event), event.shiftKey, event.altKey), newCell = _b.cell, enableEditMode = _b.enableEditMode; | ||
if (enableEditMode) { | ||
return __assign(__assign({}, state), { currentlyEditedCell: newCell }); | ||
} | ||
} | ||
} | ||
return state; | ||
}; | ||
DefaultBehavior.prototype.handleKeyDown = function (event, state) { | ||
return handleKeyDown(state, event); | ||
}; | ||
DefaultBehavior.prototype.handleKeyUp = function (event, state) { | ||
if (event.keyCode === keyCodes.TAB || event.keyCode === keyCodes.ENTER) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
} | ||
return state; | ||
}; | ||
DefaultBehavior.prototype.handleCopy = function (event, state) { | ||
if (isBrowserSafari()) { | ||
copySelectedRangeToClipboardOnSafari(event, state); | ||
} | ||
else { | ||
copySelectedRangeToClipboard(state); | ||
} | ||
event.preventDefault(); | ||
return __assign({}, state); | ||
}; | ||
DefaultBehavior.prototype.handlePaste = function (event, state) { | ||
return handlePaste(event, state); | ||
}; | ||
DefaultBehavior.prototype.handleCut = function (event, state) { | ||
if (isBrowserSafari()) { | ||
copySelectedRangeToClipboardOnSafari(event, state, true); | ||
} | ||
else { | ||
copySelectedRangeToClipboard(state, true); | ||
} | ||
event.preventDefault(); | ||
return state; | ||
}; | ||
return DefaultBehavior; | ||
}(Behavior)); | ||
export { DefaultBehavior }; |
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,19 @@ | ||
import * as React from 'react'; | ||
import { CellTemplate, Compatible, Cell, Uncertain, UncertainCompatible } from '../Model'; | ||
export interface CheckboxCell extends Cell { | ||
type: 'checkbox'; | ||
checked: boolean; | ||
checkedText?: string; | ||
uncheckedText?: string; | ||
} | ||
export declare class CheckboxCellTemplate implements CellTemplate<CheckboxCell> { | ||
getCompatibleCell(uncertainCell: Uncertain<CheckboxCell>): Compatible<CheckboxCell>; | ||
handleKeyDown(cell: Compatible<CheckboxCell>, keyCode: number, ctrl: boolean, shift: boolean, alt: boolean): { | ||
cell: Compatible<CheckboxCell>; | ||
enableEditMode: boolean; | ||
}; | ||
private toggleCheckboxCell; | ||
update(cell: Compatible<CheckboxCell>, cellToMerge: UncertainCompatible<CheckboxCell>): Compatible<CheckboxCell>; | ||
getClassName(cell: Compatible<CheckboxCell>, isInEditMode: boolean): string; | ||
render(cell: Compatible<CheckboxCell>, isInEditMode: boolean, onCellChanged: (cell: Compatible<CheckboxCell>, commit: boolean) => void): React.ReactNode; | ||
} |
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,49 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import * as React from 'react'; | ||
import { keyCodes } from '../Functions/keyCodes'; | ||
import { getCellProperty } from '../Functions/getCellProperty'; | ||
var CheckboxCellTemplate = (function () { | ||
function CheckboxCellTemplate() { | ||
} | ||
CheckboxCellTemplate.prototype.getCompatibleCell = function (uncertainCell) { | ||
var checked = getCellProperty(uncertainCell, 'checked', 'boolean'); | ||
var text = checked ? | ||
uncertainCell.checkedText ? uncertainCell.checkedText : '1' : | ||
uncertainCell.uncheckedText ? uncertainCell.uncheckedText : ''; | ||
return __assign(__assign({}, uncertainCell), { checked: checked, value: checked ? 1 : NaN, text: text }); | ||
}; | ||
CheckboxCellTemplate.prototype.handleKeyDown = function (cell, keyCode, ctrl, shift, alt) { | ||
if (!shift && (keyCode === keyCodes.SPACE || keyCode === keyCodes.ENTER)) | ||
return { cell: this.getCompatibleCell(this.toggleCheckboxCell(cell)), enableEditMode: false }; | ||
return { cell: cell, enableEditMode: false }; | ||
}; | ||
CheckboxCellTemplate.prototype.toggleCheckboxCell = function (cell) { | ||
return this.getCompatibleCell(__assign(__assign({}, cell), { checked: !cell.checked })); | ||
}; | ||
CheckboxCellTemplate.prototype.update = function (cell, cellToMerge) { | ||
var checked = cellToMerge.type === 'checkbox' ? cellToMerge.checked : !!cellToMerge.value; | ||
return this.getCompatibleCell(__assign(__assign({}, cell), { checked: checked })); | ||
}; | ||
CheckboxCellTemplate.prototype.getClassName = function (cell, isInEditMode) { | ||
return cell.className ? cell.className : ''; | ||
}; | ||
CheckboxCellTemplate.prototype.render = function (cell, isInEditMode, onCellChanged) { | ||
var _this = this; | ||
return (React.createElement(React.Fragment, null, | ||
React.createElement("label", null, | ||
React.createElement("input", { type: "checkbox", checked: cell.checked, onChange: function (e) { return onCellChanged(_this.toggleCheckboxCell(cell), true); } }), | ||
React.createElement("span", null)))); | ||
}; | ||
return CheckboxCellTemplate; | ||
}()); | ||
export { CheckboxCellTemplate }; |
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,17 @@ | ||
import * as React from 'react'; | ||
import { CellTemplate, Cell, Compatible, Uncertain, UncertainCompatible } from '../Model'; | ||
export interface DateCell extends Cell { | ||
type: 'date'; | ||
date?: Date; | ||
format?: Intl.DateTimeFormat; | ||
} | ||
export declare class DateCellTemplate implements CellTemplate<DateCell> { | ||
getCompatibleCell(uncertainCell: Uncertain<DateCell>): Compatible<DateCell>; | ||
handleKeyDown(cell: Compatible<DateCell>, keyCode: number, ctrl: boolean, shift: boolean, alt: boolean): { | ||
cell: Compatible<DateCell>; | ||
enableEditMode: boolean; | ||
}; | ||
update(cell: Compatible<DateCell>, cellToMerge: UncertainCompatible<DateCell>): Compatible<DateCell>; | ||
getClassName(cell: Compatible<DateCell>, isInEditMode: boolean): string; | ||
render(cell: Compatible<DateCell>, isInEditMode: boolean, onCellChanged: (cell: Compatible<DateCell>, commit: boolean) => void): React.ReactNode; | ||
} |
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,67 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
import * as React from 'react'; | ||
import { keyCodes } from '../Functions/keyCodes'; | ||
import { inNumericKey, isNavigationKey, isAlphaNumericKey } from './keyCodeCheckings'; | ||
import { getCellProperty } from '../Functions/getCellProperty'; | ||
import { getTimestamp, getFormattedTimeUnit } from './timeUtils'; | ||
var DateCellTemplate = (function () { | ||
function DateCellTemplate() { | ||
} | ||
DateCellTemplate.prototype.getCompatibleCell = function (uncertainCell) { | ||
var date = uncertainCell.date ? getCellProperty(uncertainCell, 'date', 'object') : new Date(NaN); | ||
var dateFormat = uncertainCell.format || new Intl.DateTimeFormat(window.navigator.language); | ||
var value = date.getTime(); | ||
var text = !Number.isNaN(value) ? dateFormat.format(date) : ''; | ||
return __assign(__assign({}, uncertainCell), { date: date, value: value, text: text }); | ||
}; | ||
DateCellTemplate.prototype.handleKeyDown = function (cell, keyCode, ctrl, shift, alt) { | ||
if (!ctrl && !alt && !shift && isAlphaNumericKey(keyCode)) | ||
return { cell: this.getCompatibleCell(__assign({}, cell)), enableEditMode: true }; | ||
return { cell: cell, enableEditMode: keyCode === keyCodes.POINTER || keyCode === keyCodes.ENTER }; | ||
}; | ||
DateCellTemplate.prototype.update = function (cell, cellToMerge) { | ||
return this.getCompatibleCell(__assign(__assign({}, cell), { date: new Date(cellToMerge.value) })); | ||
}; | ||
DateCellTemplate.prototype.getClassName = function (cell, isInEditMode) { | ||
return cell.className ? cell.className : ''; | ||
}; | ||
DateCellTemplate.prototype.render = function (cell, isInEditMode, onCellChanged) { | ||
var _this = this; | ||
if (!isInEditMode) | ||
return cell.text; | ||
var year = getFormattedTimeUnit(cell.date.getFullYear()); | ||
var month = getFormattedTimeUnit(cell.date.getMonth() + 1); | ||
var day = getFormattedTimeUnit(cell.date.getDate()); | ||
return React.createElement("input", { ref: function (input) { | ||
if (input) | ||
input.focus(); | ||
}, type: "date", defaultValue: year + "-" + month + "-" + day, onChange: function (e) { | ||
var timestamp = getTimestamp(e.currentTarget.value, ''); | ||
if (!Number.isNaN(timestamp)) { | ||
onCellChanged(_this.getCompatibleCell(__assign(__assign({}, cell), { date: new Date(timestamp) })), false); | ||
} | ||
}, onBlur: function (e) { | ||
var timestamp = getTimestamp(e.currentTarget.value, ''); | ||
if (!Number.isNaN(timestamp)) { | ||
onCellChanged(_this.getCompatibleCell(__assign(__assign({}, cell), { date: new Date(timestamp) })), true); | ||
} | ||
}, onKeyDown: function (e) { | ||
if (inNumericKey(e.keyCode) || isNavigationKey(e.keyCode) || (e.keyCode === keyCodes.COMMA || e.keyCode === keyCodes.PERIOD)) | ||
e.stopPropagation(); | ||
if (!inNumericKey(e.keyCode) && !isNavigationKey(e.keyCode) && (e.keyCode !== keyCodes.COMMA && e.keyCode !== keyCodes.PERIOD)) | ||
e.preventDefault(); | ||
}, onCopy: function (e) { return e.stopPropagation(); }, onCut: function (e) { return e.stopPropagation(); }, onPaste: function (e) { return e.stopPropagation(); }, onPointerDown: function (e) { return e.stopPropagation(); } }); | ||
}; | ||
return DateCellTemplate; | ||
}()); | ||
export { DateCellTemplate }; |
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,18 @@ | ||
import * as React from 'react'; | ||
import { CellTemplate, Cell, Compatible, Uncertain, UncertainCompatible } from '../Model'; | ||
export interface EmailCell extends Cell { | ||
type: 'email'; | ||
text: string; | ||
validator?: (text: string) => boolean; | ||
renderer?: (text: string) => React.ReactNode; | ||
} | ||
export declare class EmailCellTemplate implements CellTemplate<EmailCell> { | ||
getCompatibleCell(uncertainCell: Uncertain<EmailCell>): Compatible<EmailCell>; | ||
handleKeyDown(cell: Compatible<EmailCell>, keyCode: number, ctrl: boolean, shift: boolean, alt: boolean): { | ||
cell: Compatible<EmailCell>; | ||
enableEditMode: boolean; | ||
}; | ||
update(cell: Compatible<EmailCell>, cellToMerge: UncertainCompatible<EmailCell>): Compatible<EmailCell>; | ||
getClassName(cell: Compatible<EmailCell>, isInEditMode: boolean): "invalid" | "valid"; | ||
render(cell: Compatible<EmailCell>, isInEditMode: boolean, onCellChanged: (cell: Compatible<EmailCell>, commit: boolean) => void): React.ReactNode; | ||
} |
Oops, something went wrong.