Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Dec 1, 2018
2 parents ec8ecb2 + 85d2fe6 commit 05d91bb
Show file tree
Hide file tree
Showing 59 changed files with 266 additions and 112 deletions.
13 changes: 13 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"buildCommand": "npm run dist",
"src": {
"tagName": "v%s"
},
"npm": {
"publish": true
},
"github": {
"release": true,
"assets": ["dist/*.zip"]
}
}
38 changes: 38 additions & 0 deletions demo/categories.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>LineUp Builder Test</title>

<link href="./LineUpJS.css" rel="stylesheet">
<link href="./demo.css" rel="stylesheet">
</head>
<body>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="./LineUpJS.js"></script>

<script>
window.onload = function () {
const numCats = 60;
const arr = [];
const cats = (new Array(numCats)).fill(0).map((_, i) => `c${i + 1}`);
for (let i = 0; i < 100; ++i) {
arr.push({
d: 'Row ' + i,
cat: cats[Math.floor(Math.random() * cats.length)]
})
}
const builder = LineUpJS.builder(arr);

// manually define columns
builder
.column(LineUpJS.buildStringColumn('d').label('Label').alignment('right').width(100))
.column(LineUpJS.buildCategoricalColumn('cat', cats).color('green'));

const lineup = builder.build(document.body);

};
</script>

</body>
</html>
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
},
"homepage": "https://lineup.js.org",
"main": "build/LineUpJS.js",
"jsnext:main": "build/LineUpJS.js",
"module": "build/LineUpJS.js",
"unpkg": "build/LineUpJS.js",
"types": "src/index.d.ts",
Expand Down Expand Up @@ -58,7 +57,7 @@
"clean:compile": "rimraf .cache-loader src/**/*.map src/**/*.js src/**/*.d.ts tests/**/*.js tests/**/*.map tests/**/*.d.ts demo/*.js demo/*.map demo/*.d.ts",
"compile": "tsc",
"compile:dev": "tsc -p ./tsconfig.dev.json",
"lint": "tslint --project tsconfig.json -c tslint.json && stylelint src/**/*.scss",
"lint": "tslint -p tsconfig.json -c tslint.json && stylelint src/**/*.scss",
"docs": "npm run clean:compile && typedoc --tsconfig tsconfig.dev.json --out ./build/docs/ --plugin typedoc-plugin-as-member-of src tsd.d.ts",
"pretest": "npm run clean && npm run compile",
"test": "jest",
Expand All @@ -71,15 +70,16 @@
"dev": "npm run clean && npm run compile:dev && npm run build:dev",
"watch": "webpack --mode development --watch --devtool source-map",
"start": "webpack-dev-server --mode development --devtool source-map",
"predist": "npm run build && npm run docs",
"dist": "mkdirp dist && cd build && tar cvzf ../dist/lineupjs.tar.gz --exclude \"docs\" * && cd ..",
"predist": "npm run build",
"dist": "mkdirp dist && cross-zip ./build ./dist/lineupjs.zip",
"postdist": "npm run docs && cross-zip ./build/docs ./dist/lineupjs_docs.zip",
"preversion": "npm test",
"prepare": "echo 'dummy prepare since prepack has no dev dependencies'",
"prepack": "npm run clean && npm run compile && npm run build:prod",
"release:major": "npm version major && npm publish && git push --follow-tags",
"release:minor": "npm version minor && npm publish && git push --follow-tags",
"release:patch": "npm version patch && npm publish && git push --follow-tags",
"release:pre": "npm version prerelease && npm publish --tag=next && git push --follow-tags"
"release:major": "release-it major",
"release:minor": "release-it minor",
"release:patch": "release-it patch",
"release:pre": "release-it --preRelease=alpha --npm.tag=next"
},
"repository": {
"type": "git",
Expand All @@ -97,6 +97,7 @@
"@types/jest": "^23.3.5",
"cache-loader": "^1.2.2",
"css-loader": "^1.0.0",
"cross-zip-cli": "^1.0.0",
"d3-array": "^1.2.4",
"d3-color": "^1.2.3",
"d3-dispatch": "^1.0.5",
Expand All @@ -117,6 +118,7 @@
"mkdirp": "^0.5.1",
"node-sass": "^4.9.4",
"raw-loader": "^1.0.0-beta.0",
"release-it": "^8.0.1",
"rimraf": "^2.6.2",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
Expand Down
19 changes: 18 additions & 1 deletion src/builder/adapter/column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
INumberColumnDesc,
IPartialCategoryNode,
IActionColumnDesc,
ILinkColumnDesc
ILinkColumnDesc,
IBooleanColumnDesc
} from '../../model';

export interface IBuilderAdapterColumnDescProps extends Partial<IColumnDesc> {
Expand Down Expand Up @@ -190,6 +191,22 @@ export function buildString(props: IBuilderAdapterStringColumnDescProps): ILinkC
return desc;
}

export interface IBuilderAdapterBooleanColumnDescProps extends IBuilderAdapterColumnDescProps {
trueMarker?: string;
falseMarker?: string;
}

export function buildBoolean(props: IBuilderAdapterBooleanColumnDescProps): IBooleanColumnDesc {
const desc: any = build({...props, type: 'boolean'});

(<(keyof IBuilderAdapterBooleanColumnDescProps)[]>['trueMarker', 'falseMarker']).forEach((key) => {
if (props.hasOwnProperty(key)) {
desc[key] = props[key];
}
});
return desc;
}

export interface IBuilderAdapterActionsColumnDescProps extends IBuilderAdapterColumnDescProps {
actions?: IAction[];
groupActions?: IGroupAction[];
Expand Down
28 changes: 28 additions & 0 deletions src/builder/column/BooleanColumnBuilder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {IBooleanColumnDesc} from '../../model';
import ColumnBuilder from './ColumnBuilder';

export default class BooleanColumnBuilder extends ColumnBuilder<IBooleanColumnDesc> {

constructor(column: string) {
super('boolean', column);
}

trueMarker(marker: string) {
this.desc.trueMarker = marker;
return this;
}

falseMarker(marker: string) {
this.desc.falseMarker = marker;
return this;
}
}

/**
* builds a boolean column builder
* @param {string} column column which contains the associated data
* @returns {BooleanColumnBuilder}
*/
export function buildBooleanColumn(column: string) {
return new BooleanColumnBuilder(column);
}
1 change: 1 addition & 0 deletions src/builder/column/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './StringColumnBuilder';
export * from './DateColumnBuilder';
export * from './HierarchyColumnBuilder';
export * from './ActionsColumnBuilder';
export * from './BooleanColumnBuilder';
50 changes: 26 additions & 24 deletions src/internal/dnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,39 +136,41 @@ export function dragAble(node: HTMLElement, onDragStart: () => IDragStartResult,
* @param {(result: IDropResult, e: DragEvent) => boolean} onDrop callback when dropped, returns true if the drop was successful
* @param {(e: DragEvent) => void} onDragOver optional drag over handler, e.g. for special effects
* @param {boolean} stopPropagation flag if the event propagation should be stopped in case of success
* @param {() => boolean} optional whether to enable dropping at all
* @internal
*/
export function dropAble(node: HTMLElement, mimeTypes: string[], onDrop: (result: IDropResult, e: DragEvent) => boolean, onDragOver: null | ((e: DragEvent) => void) = null, stopPropagation: boolean = false) {
export function dropAble(node: HTMLElement, mimeTypes: string[], onDrop: (result: IDropResult, e: DragEvent) => boolean, onDragOver: null | ((e: DragEvent) => void) = null, stopPropagation: boolean = false, canDrop: () => boolean = (() => true)) {
node.addEventListener('dragenter', (e) => {
//var xy = mouse($node.node());
if (!node.classList.contains(cssClass('dragging')) && (hasDnDType(e, ...mimeTypes) || isEdgeDnD(e))) {
node.classList.add(cssClass('dragover'));
if (stopPropagation) {
e.stopPropagation();
}
//sounds good
return false;
if (node.classList.contains(cssClass('dragging')) || !(hasDnDType(e, ...mimeTypes) || isEdgeDnD(e)) || !canDrop()) {
//not a valid mime type
node.classList.remove(cssClass('dragover'));
return;
}
//not a valid mime type
node.classList.remove(cssClass('dragover'));
return;
node.classList.add(cssClass('dragover'));
if (stopPropagation) {
e.stopPropagation();
}
//sounds good
return false;
});
node.addEventListener('dragover', (e) => {
if (!node.classList.contains(cssClass('dragging')) && (hasDnDType(e, ...mimeTypes) || isEdgeDnD(e))) {
e.preventDefault();
updateDropEffect(e);
node.classList.add(cssClass('dragover'));
if (node.classList.contains(cssClass('dragging')) || !(hasDnDType(e, ...mimeTypes) || isEdgeDnD(e)) || !canDrop()) {
return;
}

if (stopPropagation) {
e.stopPropagation();
}
if (onDragOver) {
onDragOver(e);
}
//sound good
return false;
e.preventDefault();
updateDropEffect(e);
node.classList.add(cssClass('dragover'));

if (stopPropagation) {
e.stopPropagation();
}
return;
if (onDragOver) {
onDragOver(e);
}
//sound good
return false;
});
node.addEventListener('dragleave', (evt) => {
// same fix as in phovea
Expand Down
1 change: 1 addition & 0 deletions src/model/AggregateGroupColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default class AggregateGroupColumn extends Column {
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down
1 change: 1 addition & 0 deletions src/model/AnnotateColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class AnnotateColumn extends StringColumn {
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down
1 change: 1 addition & 0 deletions src/model/BooleanColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default class BooleanColumn extends ValueColumn<boolean> implements ICate
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down
1 change: 1 addition & 0 deletions src/model/BooleansColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default class BooleansColumn extends ArrayColumn<boolean> implements ISet
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down
1 change: 1 addition & 0 deletions src/model/BoxPlotColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export default class BoxPlotColumn extends ValueColumn<IBoxPlotData> implements
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down
1 change: 1 addition & 0 deletions src/model/CategoricalColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default class CategoricalColumn extends ValueColumn<string> implements IC
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down
1 change: 1 addition & 0 deletions src/model/CategoricalMapColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class CategoricalMapColumn extends MapColumn<string | null> {
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down
1 change: 1 addition & 0 deletions src/model/CategoricalsColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default class CategoricalsColumn extends ArrayColumn<string | null> {
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/Column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export default class Column extends AEventDispatcher {
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(type, listener);
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/CompositeColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class CompositeColumn extends Column implements IColumnParent {
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(type, listener);
}
Expand Down
5 changes: 3 additions & 2 deletions src/model/DateColumn.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {timeFormat, timeParse} from 'd3-time-format';
import {Category, toolbar, dialogAddons} from './annotations';
import {IDataRow, IGroupData} from './interfaces';
import {IDataRow, IGroupData, IGroup} from './interfaces';
import {isMissingValue, missingGroup, isUnknown} from './missing';
import ValueColumn, {IValueColumnDesc, dataLoaded} from './ValueColumn';
import {widthChanged, labelChanged, metaDataChanged, dirty, dirtyHeader, dirtyValues, rendererTypeChanged, groupRendererChanged, summaryRendererChanged, visibilityChanged, ECompareValueType, dirtyCaches} from './Column';
Expand Down Expand Up @@ -90,6 +90,7 @@ export default class DateColumn extends ValueColumn<Date> implements IDateColumn
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down Expand Up @@ -166,7 +167,7 @@ export default class DateColumn extends ValueColumn<Date> implements IDateColumn
this.fire([DateColumn.EVENT_GROUPING_CHANGED, Column.EVENT_DIRTY_VALUES, Column.EVENT_DIRTY], bak, value);
}

group(row: IDataRow) {
group(row: IDataRow): IGroup {
const v = this.getDate(row);
if (!v || !(v instanceof Date)) {
return missingGroup;
Expand Down
1 change: 1 addition & 0 deletions src/model/DatesColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default class DatesColumn extends ArrayColumn<Date | null> implements IDa
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down
1 change: 1 addition & 0 deletions src/model/DatesMapColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default class DatesMapColumn extends MapColumn<Date | null> implements ID
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down
1 change: 1 addition & 0 deletions src/model/GroupColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default class GroupColumn extends Column {
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down
1 change: 1 addition & 0 deletions src/model/HierarchyColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default class HierarchyColumn extends ValueColumn<string> implements ICat
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(<any>type, listener);
}
Expand Down
1 change: 1 addition & 0 deletions src/model/ImpositionBoxPlotColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default class ImpositionBoxPlotColumn extends CompositeColumn implements
on(type: typeof Column.EVENT_GROUP_RENDERER_TYPE_CHANGED, listener: typeof groupRendererChanged | null): this;
on(type: typeof Column.EVENT_SUMMARY_RENDERER_TYPE_CHANGED, listener: typeof summaryRendererChanged | null): this;
on(type: typeof Column.EVENT_VISIBILITY_CHANGED, listener: typeof visibilityChanged | null): this;
on(type: string | string[], listener: IEventListener | null): this; // required for correct typings in *.d.ts
on(type: string | string[], listener: IEventListener | null): this {
return super.on(type, listener);
}
Expand Down
Loading

0 comments on commit 05d91bb

Please sign in to comment.