Comparing version 4.3.3 to 5.0.0-0
@@ -9,2 +9,7 @@ # Changelog | ||
## 5.0.0-0 | ||
* `FEAT`: transpile to ES5 + ES modules | ||
* `CHORE`: make `inferno` a peer dependency | ||
## 4.3.2 | ||
@@ -11,0 +16,0 @@ |
@@ -1,4 +0,2 @@ | ||
export { | ||
default | ||
} from 'diagram-js/lib/command'; | ||
export { default } from 'diagram-js/lib/command'; | ||
//# sourceMappingURL=index.js.map |
@@ -0,55 +1,66 @@ | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
import { Component } from 'inferno'; | ||
import { | ||
classNames, | ||
inject, | ||
mixin | ||
} from './utils'; | ||
import { classNames, inject, mixin } from './utils'; | ||
import { | ||
SelectionAware | ||
} from './mixins'; | ||
import { SelectionAware } from './mixins'; | ||
var BaseCell = function (_Component) { | ||
_inherits(BaseCell, _Component); | ||
export default class BaseCell extends Component { | ||
function BaseCell(props, context) { | ||
_classCallCheck(this, BaseCell); | ||
constructor(props, context) { | ||
super(props, context); | ||
var _this = _possibleConstructorReturn(this, (BaseCell.__proto__ || Object.getPrototypeOf(BaseCell)).call(this, props, context)); | ||
mixin(this, SelectionAware); | ||
mixin(_this, SelectionAware); | ||
inject(this); | ||
inject(_this); | ||
return _this; | ||
} | ||
getRenderProps(...cls) { | ||
_createClass(BaseCell, [{ | ||
key: 'getRenderProps', | ||
value: function getRenderProps() { | ||
var _props = this.props, | ||
className = _props.className, | ||
elementId = _props.elementId, | ||
coords = _props.coords, | ||
props = _objectWithoutProperties(_props, ['className', 'elementId', 'coords']); | ||
const { | ||
className, | ||
elementId, | ||
coords, | ||
...props | ||
} = this.props; | ||
for (var _len = arguments.length, cls = Array(_len), _key = 0; _key < _len; _key++) { | ||
cls[_key] = arguments[_key]; | ||
} | ||
const baseProps = { | ||
className: classNames( | ||
...cls, | ||
this.getSelectionClasses(), | ||
className | ||
) | ||
}; | ||
var baseProps = { | ||
className: classNames.apply(undefined, cls.concat([this.getSelectionClasses(), className])) | ||
}; | ||
if (elementId) { | ||
baseProps['data-element-id'] = elementId; | ||
} | ||
if (elementId) { | ||
baseProps['data-element-id'] = elementId; | ||
} | ||
if (coords) { | ||
baseProps['data-coords'] = coords; | ||
if (coords) { | ||
baseProps['data-coords'] = coords; | ||
} | ||
return _extends({}, baseProps, props); | ||
} | ||
}]); | ||
return { | ||
...baseProps, | ||
...props | ||
}; | ||
} | ||
return BaseCell; | ||
}(Component); | ||
} | ||
export default BaseCell; | ||
//# sourceMappingURL=BaseCell.js.map |
@@ -0,27 +1,43 @@ | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
import { createVNode, normalizeProps } from 'inferno'; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
import BaseCell from './BaseCell'; | ||
var HeaderCell = function (_BaseCell) { | ||
_inherits(HeaderCell, _BaseCell); | ||
export default class HeaderCell extends BaseCell { | ||
function HeaderCell(props, context) { | ||
_classCallCheck(this, HeaderCell); | ||
constructor(props, context) { | ||
super(props, context); | ||
var _this = _possibleConstructorReturn(this, (HeaderCell.__proto__ || Object.getPrototypeOf(HeaderCell)).call(this, props, context)); | ||
this.state = {}; | ||
_this.state = {}; | ||
return _this; | ||
} | ||
render() { | ||
_createClass(HeaderCell, [{ | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
const { | ||
children | ||
} = this.props; | ||
const props = this.getRenderProps('cell'); | ||
var props = this.getRenderProps('cell'); | ||
return ( | ||
<td { ...props }> | ||
{ children } | ||
</td> | ||
); | ||
} | ||
return normalizeProps(createVNode(1, 'td', null, children, 0, _extends({}, props))); | ||
} | ||
}]); | ||
} | ||
return HeaderCell; | ||
}(BaseCell); | ||
export default HeaderCell; | ||
//# sourceMappingURL=Cell.js.map |
@@ -1,18 +0,39 @@ | ||
import { Component } from 'inferno'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
export default class DiContainer extends Component { | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
getChildContext() { | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
return { | ||
injector: this.props.injector | ||
}; | ||
import { Component } from 'inferno'; | ||
} | ||
var DiContainer = function (_Component) { | ||
_inherits(DiContainer, _Component); | ||
render() { | ||
return this.props.children; | ||
function DiContainer() { | ||
_classCallCheck(this, DiContainer); | ||
return _possibleConstructorReturn(this, (DiContainer.__proto__ || Object.getPrototypeOf(DiContainer)).apply(this, arguments)); | ||
} | ||
} | ||
_createClass(DiContainer, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return { | ||
injector: this.props.injector | ||
}; | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return this.props.children; | ||
} | ||
}]); | ||
return DiContainer; | ||
}(Component); | ||
export default DiContainer; | ||
//# sourceMappingURL=DiContainer.js.map |
@@ -0,27 +1,43 @@ | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
import { createVNode, normalizeProps } from 'inferno'; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
import BaseCell from './BaseCell'; | ||
var HeaderCell = function (_BaseCell) { | ||
_inherits(HeaderCell, _BaseCell); | ||
export default class HeaderCell extends BaseCell { | ||
function HeaderCell(props, context) { | ||
_classCallCheck(this, HeaderCell); | ||
constructor(props, context) { | ||
super(props, context); | ||
var _this = _possibleConstructorReturn(this, (HeaderCell.__proto__ || Object.getPrototypeOf(HeaderCell)).call(this, props, context)); | ||
this.state = {}; | ||
_this.state = {}; | ||
return _this; | ||
} | ||
render() { | ||
_createClass(HeaderCell, [{ | ||
key: 'render', | ||
value: function render() { | ||
var children = this.props.children; | ||
const { | ||
children | ||
} = this.props; | ||
const props = this.getRenderProps('cell', 'header-cell'); | ||
var props = this.getRenderProps('cell', 'header-cell'); | ||
return ( | ||
<th { ...props }> | ||
{ children } | ||
</th> | ||
); | ||
} | ||
return normalizeProps(createVNode(1, 'th', null, children, 0, _extends({}, props))); | ||
} | ||
}]); | ||
} | ||
return HeaderCell; | ||
}(BaseCell); | ||
export default HeaderCell; | ||
//# sourceMappingURL=HeaderCell.js.map |
@@ -6,2 +6,3 @@ export { default as Cell } from './Cell'; | ||
export * from './mixins'; | ||
export * from './utils'; | ||
export * from './utils'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,2 @@ | ||
export { default as SelectionAware } from './SelectionAware'; | ||
export { default as SelectionAware } from './SelectionAware'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,19 +0,14 @@ | ||
import { | ||
classNames | ||
} from '../utils'; | ||
import { classNames } from '../utils'; | ||
/** | ||
* A mixin to make an element _selection aware_. | ||
*/ | ||
const SelectionAware = { | ||
var SelectionAware = { | ||
getSelectionClasses: function getSelectionClasses() { | ||
var _state = this.state, | ||
selected = _state.selected, | ||
selectedSecondary = _state.selectedSecondary, | ||
focussed = _state.focussed; | ||
getSelectionClasses() { | ||
const { | ||
selected, | ||
selectedSecondary, | ||
focussed | ||
} = this.state; | ||
return classNames({ | ||
@@ -25,10 +20,8 @@ 'selected': selected, | ||
}, | ||
selectionChanged: function selectionChanged(newSelection) { | ||
selectionChanged(newSelection) { | ||
// newSelection = { selected, selectedSecondary, focussed } | ||
this.setState(newSelection); | ||
}, | ||
componentWillUpdate(newProps) { | ||
componentWillUpdate: function componentWillUpdate(newProps) { | ||
if (newProps.elementId !== this.props.elementId) { | ||
@@ -38,5 +31,4 @@ this.updateSelectionSubscription(false); | ||
}, | ||
componentDidUpdate: function componentDidUpdate(oldProps) { | ||
componentDidUpdate(oldProps) { | ||
if (oldProps.elementId !== this.props.elementId) { | ||
@@ -46,15 +38,11 @@ this.updateSelectionSubscription(true); | ||
}, | ||
componentDidMount() { | ||
componentDidMount: function componentDidMount() { | ||
this.updateSelectionSubscription(true); | ||
}, | ||
componentWillUnmount() { | ||
componentWillUnmount: function componentWillUnmount() { | ||
this.updateSelectionSubscription(false); | ||
}, | ||
updateSelectionSubscription: function updateSelectionSubscription(enable) { | ||
var elementId = this.props.elementId; | ||
updateSelectionSubscription(enable) { | ||
const { | ||
elementId | ||
} = this.props; | ||
@@ -66,9 +54,5 @@ if (!elementId) { | ||
if (elementId) { | ||
this.eventBus[enable ? 'on' : 'off']( | ||
`selection.${elementId}.changed`, | ||
this.selectionChanged | ||
); | ||
this.eventBus[enable ? 'on' : 'off']('selection.' + elementId + '.changed', this.selectionChanged); | ||
} | ||
}, | ||
} | ||
}; | ||
@@ -78,2 +62,3 @@ | ||
SelectionAware.$inject = [ 'eventBus' ]; | ||
SelectionAware.$inject = ['eventBus']; | ||
//# sourceMappingURL=SelectionAware.js.map |
@@ -0,2 +1,9 @@ | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function newSet() { | ||
@@ -10,7 +17,5 @@ return { | ||
function add(set, element) { | ||
var elements = set.elements, | ||
index = set.index; | ||
const { | ||
elements, | ||
index | ||
} = set; | ||
@@ -21,7 +26,4 @@ if (index[element]) { | ||
return { | ||
elements: [ ...elements, element ], | ||
index: { | ||
...index, | ||
[element]: true | ||
} | ||
elements: [].concat(_toConsumableArray(elements), [element]), | ||
index: _extends({}, index, _defineProperty({}, element, true)) | ||
}; | ||
@@ -35,9 +37,13 @@ } | ||
export default function classNames(...args) { | ||
export default function classNames() { | ||
let set = newSet(); | ||
var set = newSet(); | ||
args.forEach(function(item) { | ||
const type = typeof item; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
args.forEach(function (item) { | ||
var type = typeof item === 'undefined' ? 'undefined' : _typeof(item); | ||
if (type === 'string' && item.length > 0) { | ||
@@ -47,4 +53,4 @@ set = add(set, item); | ||
Object.keys(item).forEach(function(key) { | ||
const value = item[key]; | ||
Object.keys(item).forEach(function (key) { | ||
var value = item[key]; | ||
@@ -59,2 +65,3 @@ if (value) { | ||
return join(set, ' '); | ||
} | ||
} | ||
//# sourceMappingURL=classNames.js.map |
@@ -13,11 +13,17 @@ | ||
*/ | ||
export default function compose(self, ...fns) { | ||
export default function compose(self) { | ||
for (var _len = arguments.length, fns = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
fns[_key - 1] = arguments[_key]; | ||
} | ||
return function(...args) { | ||
return function () { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
let result; | ||
var result = void 0; | ||
fns.forEach(function(fn) { | ||
fns.forEach(function (fn) { | ||
result = fn.call(self, ...args); | ||
result = fn.call.apply(fn, [self].concat(args)); | ||
@@ -31,3 +37,3 @@ if (typeof result !== 'undefined') { | ||
}.bind(self); | ||
} | ||
} | ||
//# sourceMappingURL=compose.js.map |
@@ -1,16 +0,8 @@ | ||
export { | ||
default as classNames | ||
} from './classNames'; | ||
export { default as classNames } from './classNames'; | ||
export { | ||
inject, | ||
injectType, | ||
} from './inject'; | ||
export { inject, injectType } from './inject'; | ||
export { | ||
default as compose | ||
} from './compose'; | ||
export { default as compose } from './compose'; | ||
export { | ||
default as mixin | ||
} from './mixin'; | ||
export { default as mixin } from './mixin'; | ||
//# sourceMappingURL=index.js.map |
@@ -0,4 +1,6 @@ | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
export function inject(component) { | ||
const Type = component.constructor; | ||
var Type = component.constructor; | ||
@@ -8,6 +10,5 @@ return injectType(Type, component); | ||
export function injectType(Type, component) { | ||
const annotation = Type.$inject; | ||
var annotation = Type.$inject; | ||
@@ -18,17 +19,20 @@ if (!annotation) { | ||
const { | ||
injector | ||
} = component.context; | ||
var injector = component.context.injector; | ||
const setupFn = [ ...annotation, function(...args) { | ||
for (const idx in args) { | ||
const name = annotation[idx]; | ||
const value = args[idx]; | ||
var setupFn = [].concat(_toConsumableArray(annotation), [function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
for (var idx in args) { | ||
var name = annotation[idx]; | ||
var value = args[idx]; | ||
component[name] = value; | ||
} | ||
}]; | ||
}]); | ||
injector.invoke(setupFn); | ||
} | ||
} | ||
//# sourceMappingURL=inject.js.map |
@@ -5,3 +5,2 @@ import compose from './compose'; | ||
/** | ||
@@ -15,3 +14,3 @@ * A Component and injection aware mixin mechanism. | ||
Object.keys(mixinDef).forEach(function(key) { | ||
Object.keys(mixinDef).forEach(function (key) { | ||
@@ -22,3 +21,3 @@ if (key === '$inject' || key === '__init') { | ||
const mixinFn = mixinDef[key]; | ||
var mixinFn = mixinDef[key]; | ||
@@ -29,12 +28,9 @@ if (key === 'constructor') { | ||
const componentFn = component[key]; | ||
var componentFn = component[key]; | ||
if (typeof componentFn !== 'undefined') { | ||
if (typeof componentFn !== 'function') { | ||
throw new Error( | ||
`failed to mixin <${ key }>: cannot combine with non-fn component value` | ||
); | ||
throw new Error('failed to mixin <' + key + '>: cannot combine with non-fn component value'); | ||
} | ||
component[key] = compose(component, componentFn, mixinFn); | ||
@@ -54,3 +50,3 @@ } else { | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=mixin.js.map |
@@ -1,32 +0,51 @@ | ||
import { create } from '../model'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
export default class ElementFactory { | ||
constructor() { | ||
this._uid = 12; | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
create(type, attrs = {}) { | ||
if (!attrs.id) { | ||
attrs.id = type + '_' + (this._uid++); | ||
} | ||
import { create as _create } from '../model'; | ||
return create(type, attrs); | ||
} | ||
var ElementFactory = function () { | ||
function ElementFactory() { | ||
_classCallCheck(this, ElementFactory); | ||
createRoot(attrs) { | ||
return this.create('root', attrs); | ||
this._uid = 12; | ||
} | ||
createRow(attrs) { | ||
return this.create('row', attrs); | ||
} | ||
_createClass(ElementFactory, [{ | ||
key: 'create', | ||
value: function create(type) { | ||
var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
createCol(attrs) { | ||
return this.create('col', attrs); | ||
} | ||
if (!attrs.id) { | ||
attrs.id = type + '_' + this._uid++; | ||
} | ||
createCell(attrs) { | ||
return this.create('cell', attrs); | ||
} | ||
return _create(type, attrs); | ||
} | ||
}, { | ||
key: 'createRoot', | ||
value: function createRoot(attrs) { | ||
return this.create('root', attrs); | ||
} | ||
}, { | ||
key: 'createRow', | ||
value: function createRow(attrs) { | ||
return this.create('row', attrs); | ||
} | ||
}, { | ||
key: 'createCol', | ||
value: function createCol(attrs) { | ||
return this.create('col', attrs); | ||
} | ||
}, { | ||
key: 'createCell', | ||
value: function createCell(attrs) { | ||
return this.create('cell', attrs); | ||
} | ||
}]); | ||
} | ||
return ElementFactory; | ||
}(); | ||
export default ElementFactory; | ||
//# sourceMappingURL=ElementFactory.js.map |
@@ -1,3 +0,9 @@ | ||
export default class ElementRegistry { | ||
constructor(eventBus) { | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var ElementRegistry = function () { | ||
function ElementRegistry(eventBus) { | ||
_classCallCheck(this, ElementRegistry); | ||
this._eventBus = eventBus; | ||
@@ -10,44 +16,63 @@ | ||
add(element, type) { | ||
const { id } = element; | ||
_createClass(ElementRegistry, [{ | ||
key: 'add', | ||
value: function add(element, type) { | ||
var id = element.id; | ||
this._elements[id] = element; | ||
} | ||
remove(element) { | ||
const id = element.id || element; | ||
this._elements[id] = element; | ||
} | ||
}, { | ||
key: 'remove', | ||
value: function remove(element) { | ||
var id = element.id || element; | ||
delete this._elements[id]; | ||
} | ||
delete this._elements[id]; | ||
} | ||
}, { | ||
key: 'get', | ||
value: function get(id) { | ||
return this._elements[id]; | ||
} | ||
}, { | ||
key: 'getAll', | ||
value: function getAll() { | ||
return values(this._elements); | ||
} | ||
}, { | ||
key: 'forEach', | ||
value: function forEach(fn) { | ||
values(this._elements).forEach(function (element) { | ||
return fn(element); | ||
}); | ||
} | ||
}, { | ||
key: 'filter', | ||
value: function filter(fn) { | ||
return values(this._elements).filter(function (element) { | ||
return fn(element); | ||
}); | ||
} | ||
}, { | ||
key: 'clear', | ||
value: function clear() { | ||
this._elements = {}; | ||
} | ||
}]); | ||
get(id) { | ||
return this._elements[id]; | ||
} | ||
return ElementRegistry; | ||
}(); | ||
getAll() { | ||
return values(this._elements); | ||
} | ||
export default ElementRegistry; | ||
forEach(fn) { | ||
values(this._elements).forEach(element => fn(element)); | ||
} | ||
filter(fn) { | ||
return values(this._elements).filter(element => fn(element)); | ||
} | ||
ElementRegistry.$inject = ['eventBus']; | ||
clear() { | ||
this._elements = {}; | ||
} | ||
} | ||
ElementRegistry.$inject = [ 'eventBus' ]; | ||
// helpers | ||
function values(obj) { | ||
return Object.keys(obj).map(function(k) { | ||
return Object.keys(obj).map(function (k) { | ||
return obj[k]; | ||
}); | ||
} | ||
} | ||
//# sourceMappingURL=ElementRegistry.js.map |
@@ -8,8 +8,9 @@ import ElementFactory from './ElementFactory'; | ||
export default { | ||
__depends__: [ renderModule ], | ||
__init__: [ 'elementFactory', 'sheet' ], | ||
elementFactory: [ 'type', ElementFactory ], | ||
elementRegistry: [ 'type', ElementRegistry ], | ||
eventBus: [ 'type', EventBus ], | ||
sheet: [ 'type', Sheet ] | ||
}; | ||
__depends__: [renderModule], | ||
__init__: ['elementFactory', 'sheet'], | ||
elementFactory: ['type', ElementFactory], | ||
elementRegistry: ['type', ElementRegistry], | ||
eventBus: ['type', EventBus], | ||
sheet: ['type', Sheet] | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,11 @@ | ||
export default class Sheet { | ||
constructor(elementRegistry, eventBus) { | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Sheet = function () { | ||
function Sheet(elementRegistry, eventBus) { | ||
var _this = this; | ||
_classCallCheck(this, Sheet); | ||
this._elementRegistry = elementRegistry; | ||
@@ -8,192 +16,217 @@ this._eventBus = eventBus; | ||
eventBus.on('table.clear', () => { | ||
this.setRoot(null); | ||
eventBus.on('table.clear', function () { | ||
_this.setRoot(null); | ||
}); | ||
} | ||
setRoot(root) { | ||
if (this._root) { | ||
const oldRoot = this._root; | ||
_createClass(Sheet, [{ | ||
key: 'setRoot', | ||
value: function setRoot(root) { | ||
if (this._root) { | ||
var oldRoot = this._root; | ||
this._eventBus.fire('root.remove', { root: oldRoot }); | ||
this._eventBus.fire('root.remove', { root: oldRoot }); | ||
this._root = null; | ||
this._root = null; | ||
this._eventBus.fire('root.removed', { root: oldRoot }); | ||
} | ||
this._eventBus.fire('root.removed', { root: oldRoot }); | ||
} | ||
if (root) { | ||
this._eventBus.fire('root.add', { root }); | ||
} | ||
if (root) { | ||
this._eventBus.fire('root.add', { root: root }); | ||
} | ||
this._root = root; | ||
this._root = root; | ||
if (root) { | ||
this._eventBus.fire('root.added', { root }); | ||
if (root) { | ||
this._eventBus.fire('root.added', { root: root }); | ||
} | ||
} | ||
} | ||
}, { | ||
key: 'getRoot', | ||
value: function getRoot() { | ||
if (!this._root) { | ||
this.setRoot({ | ||
id: '__implicitroot', | ||
rows: [], | ||
cols: [] | ||
}); | ||
} | ||
getRoot() { | ||
if (!this._root) { | ||
this.setRoot({ | ||
id: '__implicitroot', | ||
rows: [], | ||
cols: [] | ||
}); | ||
return this._root; | ||
} | ||
return this._root; | ||
} | ||
/** | ||
* Add row to sheet. | ||
* | ||
* @param {Object} row - Row. | ||
*/ | ||
}, { | ||
key: 'addRow', | ||
value: function addRow(row, index) { | ||
var _this2 = this; | ||
/** | ||
* Add row to sheet. | ||
* | ||
* @param {Object} row - Row. | ||
*/ | ||
addRow(row, index) { | ||
const root = this.getRoot(); | ||
var root = this.getRoot(); | ||
if (root.cols.length != row.cells.length) { | ||
throw new Error('number of cells is not equal to number of cols'); | ||
} | ||
if (root.cols.length != row.cells.length) { | ||
throw new Error('number of cells is not equal to number of cols'); | ||
} | ||
if (typeof index === 'undefined') { | ||
index = root.rows.length; | ||
} | ||
if (typeof index === 'undefined') { | ||
index = root.rows.length; | ||
} | ||
addAtIndex(index, root.rows, row); | ||
row.root = root; | ||
addAtIndex(index, root.rows, row); | ||
row.root = root; | ||
this._elementRegistry.add(row); | ||
this._elementRegistry.add(row); | ||
row.cells.forEach((cell, idx) => { | ||
this._elementRegistry.add(cell); | ||
row.cells.forEach(function (cell, idx) { | ||
_this2._elementRegistry.add(cell); | ||
cell.row = row; | ||
cell.col = root.cols[idx]; | ||
cell.row = row; | ||
cell.col = root.cols[idx]; | ||
addAtIndex(index, root.cols[idx].cells, cell); | ||
}); | ||
addAtIndex(index, root.cols[idx].cells, cell); | ||
}); | ||
this._eventBus.fire('row.add', { row }); | ||
this._eventBus.fire('row.add', { row: row }); | ||
return row; | ||
} | ||
return row; | ||
} | ||
/** | ||
* Remove row from sheet. | ||
* | ||
* @param {Object|string} row - Row or row ID. | ||
*/ | ||
/** | ||
* Remove row from sheet. | ||
* | ||
* @param {Object|string} row - Row or row ID. | ||
*/ | ||
removeRow(row) { | ||
const root = this.getRoot(); | ||
}, { | ||
key: 'removeRow', | ||
value: function removeRow(row) { | ||
var _this3 = this; | ||
if (typeof row === 'string') { | ||
row = this._elementRegistry.get(row); | ||
} | ||
var root = this.getRoot(); | ||
const index = root.rows.indexOf(row); | ||
if (typeof row === 'string') { | ||
row = this._elementRegistry.get(row); | ||
} | ||
if (index === -1) { | ||
return; | ||
} | ||
var index = root.rows.indexOf(row); | ||
removeAtIndex(index, root.rows); | ||
row.root = undefined; | ||
if (index === -1) { | ||
return; | ||
} | ||
this._elementRegistry.remove(row); | ||
removeAtIndex(index, root.rows); | ||
row.root = undefined; | ||
row.cells.forEach((cell, idx) => { | ||
this._elementRegistry.remove(cell); | ||
this._elementRegistry.remove(row); | ||
cell.col = undefined; | ||
row.cells.forEach(function (cell, idx) { | ||
_this3._elementRegistry.remove(cell); | ||
removeAtIndex(index, root.cols[idx].cells); | ||
}); | ||
cell.col = undefined; | ||
this._eventBus.fire('row.remove', { row }); | ||
} | ||
removeAtIndex(index, root.cols[idx].cells); | ||
}); | ||
/** | ||
* Add col to sheet. | ||
* | ||
* @param {Object} col | ||
* @param {Number} [index] | ||
*/ | ||
addCol(col, index) { | ||
const root = this.getRoot(); | ||
this._eventBus.fire('row.remove', { row: row }); | ||
} | ||
this._elementRegistry.add(col); | ||
/** | ||
* Add col to sheet. | ||
* | ||
* @param {Object} col | ||
* @param {Number} [index] | ||
*/ | ||
if (root.rows.length != col.cells.length) { | ||
throw new Error('number of cells is not equal to number of rows'); | ||
} | ||
}, { | ||
key: 'addCol', | ||
value: function addCol(col, index) { | ||
var _this4 = this; | ||
if (typeof index === 'undefined') { | ||
index = root.cols.length; | ||
} | ||
var root = this.getRoot(); | ||
addAtIndex(index, root.cols, col); | ||
col.root = root; | ||
this._elementRegistry.add(col); | ||
col.cells.forEach((cell, idx) => { | ||
this._elementRegistry.add(cell); | ||
if (root.rows.length != col.cells.length) { | ||
throw new Error('number of cells is not equal to number of rows'); | ||
} | ||
cell.col = col; | ||
cell.row = root.rows[idx]; | ||
if (typeof index === 'undefined') { | ||
index = root.cols.length; | ||
} | ||
addAtIndex(index, root.rows[idx].cells, cell); | ||
}); | ||
addAtIndex(index, root.cols, col); | ||
col.root = root; | ||
this._eventBus.fire('col.add', { col }); | ||
col.cells.forEach(function (cell, idx) { | ||
_this4._elementRegistry.add(cell); | ||
return col; | ||
} | ||
cell.col = col; | ||
cell.row = root.rows[idx]; | ||
/** | ||
* Remove col from sheet. | ||
* | ||
* @param {Object|string} col - Col or col ID. | ||
*/ | ||
removeCol(col) { | ||
addAtIndex(index, root.rows[idx].cells, cell); | ||
}); | ||
const root = this.getRoot(); | ||
this._eventBus.fire('col.add', { col: col }); | ||
if (typeof col === 'string') { | ||
col = this._elementRegistry.get(col); | ||
return col; | ||
} | ||
const index = root.cols.indexOf(col); | ||
/** | ||
* Remove col from sheet. | ||
* | ||
* @param {Object|string} col - Col or col ID. | ||
*/ | ||
if (index === -1) { | ||
return; | ||
} | ||
}, { | ||
key: 'removeCol', | ||
value: function removeCol(col) { | ||
var _this5 = this; | ||
removeAtIndex(index, root.cols); | ||
col.root = undefined; | ||
var root = this.getRoot(); | ||
this._elementRegistry.remove(col); | ||
if (typeof col === 'string') { | ||
col = this._elementRegistry.get(col); | ||
} | ||
col.cells.forEach((cell, idx) => { | ||
this._elementRegistry.remove(cell); | ||
var index = root.cols.indexOf(col); | ||
cell.row = undefined; | ||
if (index === -1) { | ||
return; | ||
} | ||
removeAtIndex(index, root.rows[idx].cells); | ||
}); | ||
removeAtIndex(index, root.cols); | ||
col.root = undefined; | ||
this._eventBus.fire('col.remove', { col }); | ||
} | ||
this._elementRegistry.remove(col); | ||
resized() { | ||
this._eventBus.fire('sheet.resized'); | ||
} | ||
col.cells.forEach(function (cell, idx) { | ||
_this5._elementRegistry.remove(cell); | ||
} | ||
cell.row = undefined; | ||
Sheet.$inject = [ 'elementRegistry', 'eventBus' ]; | ||
removeAtIndex(index, root.rows[idx].cells); | ||
}); | ||
this._eventBus.fire('col.remove', { col: col }); | ||
} | ||
}, { | ||
key: 'resized', | ||
value: function resized() { | ||
this._eventBus.fire('sheet.resized'); | ||
} | ||
}]); | ||
return Sheet; | ||
}(); | ||
export default Sheet; | ||
Sheet.$inject = ['elementRegistry', 'eventBus']; | ||
// helpers ///////////// | ||
@@ -219,2 +252,3 @@ | ||
return array.splice(index, 1); | ||
} | ||
} | ||
//# sourceMappingURL=Sheet.js.map |
@@ -0,28 +1,32 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
import { createVNode, createComponentVNode } from 'inferno'; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
import { Component } from 'inferno'; | ||
import { | ||
assign, | ||
isFunction | ||
} from 'min-dash'; | ||
import { assign, isFunction } from 'min-dash'; | ||
import { | ||
inject | ||
} from '../../../components'; | ||
import { inject } from '../../../components'; | ||
import { | ||
query as domQuery, | ||
matches as domMatches | ||
} from 'min-dom'; | ||
import { query as domQuery, matches as domMatches } from 'min-dom'; | ||
import { | ||
setRange | ||
} from 'selection-ranges'; | ||
import { setRange } from 'selection-ranges'; | ||
var ContextMenuComponent = function (_Component) { | ||
_inherits(ContextMenuComponent, _Component); | ||
export default class ContextMenuComponent extends Component { | ||
function ContextMenuComponent(props, context) { | ||
_classCallCheck(this, ContextMenuComponent); | ||
constructor(props, context) { | ||
super(props, context); | ||
var _this = _possibleConstructorReturn(this, (ContextMenuComponent.__proto__ || Object.getPrototypeOf(ContextMenuComponent)).call(this, props, context)); | ||
this.state = { | ||
_initialiseProps.call(_this); | ||
_this.state = { | ||
isOpen: false, | ||
@@ -35,3 +39,4 @@ position: { | ||
inject(this); | ||
inject(_this); | ||
return _this; | ||
} | ||
@@ -48,8 +53,68 @@ | ||
*/ | ||
open = ({ position, context }) => { | ||
/** | ||
* Closes context menu and resets state. | ||
*/ | ||
_createClass(ContextMenuComponent, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this.eventBus.on('contextMenu.open', this.open); | ||
this.eventBus.on('contextMenu.close', this.close); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
this.eventBus.off('contextMenu.open', this.open); | ||
this.eventBus.off('contextMenu.close', this.close); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _state = this.state, | ||
isOpen = _state.isOpen, | ||
context = _state.context, | ||
position = _state.position; | ||
if (!isOpen) { | ||
return null; | ||
} | ||
var components = this.components.getComponents('context-menu', context); | ||
if (!components.length) { | ||
return null; | ||
} | ||
return createComponentVNode(2, ContextMenu, { | ||
'className': 'context-menu no-deselect', | ||
'context': context, | ||
'position': position, | ||
'offset': context.offset || { x: 0, y: 0 }, | ||
'autoFocus': context.autoFocus !== false, | ||
'autoClose': context.autoClose !== false, | ||
'components': components, | ||
'onClose': this.triggerClose | ||
}); | ||
} | ||
}]); | ||
return ContextMenuComponent; | ||
}(Component); | ||
var _initialiseProps = function _initialiseProps() { | ||
var _this2 = this; | ||
this.open = function (_ref) { | ||
var position = _ref.position, | ||
context = _ref.context; | ||
// always close first | ||
this.close(); | ||
_this2.close(); | ||
this.setState({ | ||
_this2.setState({ | ||
isOpen: true, | ||
@@ -59,11 +124,8 @@ position: position || { x: 0, y: 0 }, | ||
}); | ||
} | ||
}; | ||
/** | ||
* Closes context menu and resets state. | ||
*/ | ||
close = () => { | ||
this.close = function () { | ||
if (this.state.isOpen) { | ||
this.setState({ | ||
if (_this2.state.isOpen) { | ||
_this2.setState({ | ||
context: undefined, | ||
@@ -77,301 +139,239 @@ isOpen: false, | ||
} | ||
} | ||
}; | ||
triggerClose = () => { | ||
this.eventBus.fire('contextMenu.close'); | ||
} | ||
this.triggerClose = function () { | ||
_this2.eventBus.fire('contextMenu.close'); | ||
}; | ||
}; | ||
componentDidMount() { | ||
this.eventBus.on('contextMenu.open', this.open); | ||
this.eventBus.on('contextMenu.close', this.close); | ||
} | ||
export default ContextMenuComponent; | ||
componentWillUnmount() { | ||
this.eventBus.off('contextMenu.open', this.open); | ||
this.eventBus.off('contextMenu.close', this.close); | ||
} | ||
render() { | ||
const { | ||
isOpen, | ||
context, | ||
position | ||
} = this.state; | ||
ContextMenuComponent.$inject = ['eventBus', 'components']; | ||
if (!isOpen) { | ||
return null; | ||
} | ||
/** | ||
* Low-level, stateless context menu holder. | ||
*/ | ||
const components = this.components.getComponents('context-menu', context); | ||
var ContextMenu = function (_Component2) { | ||
_inherits(ContextMenu, _Component2); | ||
if (!components.length) { | ||
return null; | ||
} | ||
function ContextMenu(props, context) { | ||
_classCallCheck(this, ContextMenu); | ||
return ( | ||
<ContextMenu | ||
className="context-menu no-deselect" | ||
context={ context } | ||
position={ position } | ||
offset={ context.offset || { x: 0, y: 0 } } | ||
autoFocus={ context.autoFocus !== false } | ||
autoClose={ context.autoClose !== false } | ||
components={ components } | ||
onClose={ this.triggerClose } /> | ||
); | ||
} | ||
} | ||
var _this3 = _possibleConstructorReturn(this, (ContextMenu.__proto__ || Object.getPrototypeOf(ContextMenu)).call(this, props, context)); | ||
ContextMenuComponent.$inject = [ | ||
'eventBus', | ||
'components' | ||
]; | ||
_this3.onGlobalClick = function (event) { | ||
_this3.checkClose(event.target); | ||
}; | ||
_this3.onGlobalKey = function (event) { | ||
/** | ||
* Low-level, stateless context menu holder. | ||
*/ | ||
class ContextMenu extends Component { | ||
var keyCode = event.which; | ||
constructor(props, context) { | ||
super(props, context); | ||
// ENTER or ESC | ||
if (keyCode === 13 || keyCode === 27) { | ||
event.stopPropagation(); | ||
event.preventDefault(); | ||
inject(this); | ||
} | ||
_this3.close(); | ||
} | ||
}; | ||
close() { | ||
_this3.onFocusChanged = function (event) { | ||
_this3.checkClose(event.target); | ||
}; | ||
const { | ||
onClose | ||
} = this.props; | ||
_this3.setNode = function (node) { | ||
_this3.node = node; | ||
if (isFunction(onClose)) { | ||
onClose(); | ||
} | ||
} | ||
var autoFocus = _this3.props.autoFocus; | ||
/** | ||
* Check whether closing the context menu is necessary | ||
* after selecting the given element. | ||
*/ | ||
checkClose(focusTarget) { | ||
if (node) { | ||
_this3.updatePosition(); | ||
const { | ||
autoClose | ||
} = this.props; | ||
if (autoFocus) { | ||
ensureFocus(node); | ||
} | ||
} | ||
}; | ||
if (!autoClose) { | ||
return; | ||
} | ||
inject(_this3); | ||
return _this3; | ||
} | ||
var node = this.node; | ||
_createClass(ContextMenu, [{ | ||
key: 'close', | ||
value: function close() { | ||
var onClose = this.props.onClose; | ||
if (!node) { | ||
return; | ||
} | ||
if (node === focusTarget) { | ||
return; | ||
if (isFunction(onClose)) { | ||
onClose(); | ||
} | ||
} | ||
if (node.contains(focusTarget)) { | ||
return; | ||
} | ||
/** | ||
* Check whether closing the context menu is necessary | ||
* after selecting the given element. | ||
*/ | ||
this.close(); | ||
} | ||
}, { | ||
key: 'checkClose', | ||
value: function checkClose(focusTarget) { | ||
var autoClose = this.props.autoClose; | ||
/** | ||
* Handle global (window) click event. | ||
*/ | ||
onGlobalClick = (event) => { | ||
this.checkClose(event.target); | ||
} | ||
/** | ||
* Handle global key event. | ||
*/ | ||
onGlobalKey = (event) => { | ||
if (!autoClose) { | ||
return; | ||
} | ||
var keyCode = event.which; | ||
var node = this.node; | ||
// ENTER or ESC | ||
if (keyCode === 13 || keyCode === 27) { | ||
event.stopPropagation(); | ||
event.preventDefault(); | ||
if (!node) { | ||
return; | ||
} | ||
if (node === focusTarget) { | ||
return; | ||
} | ||
if (node.contains(focusTarget)) { | ||
return; | ||
} | ||
this.close(); | ||
} | ||
} | ||
/** | ||
* Handle global (document) focus changed event. | ||
*/ | ||
onFocusChanged = (event) => { | ||
this.checkClose(event.target); | ||
} | ||
/** | ||
* Handle global (window) click event. | ||
*/ | ||
componentDidMount() { | ||
document.addEventListener('focusin', this.onFocusChanged); | ||
document.addEventListener('keydown', this.onGlobalKey); | ||
document.addEventListener('click', this.onGlobalClick); | ||
} | ||
componentWillUnmount() { | ||
document.removeEventListener('focusin', this.onFocusChanged); | ||
document.removeEventListener('keydown', this.onGlobalKey); | ||
document.removeEventListener('click', this.onGlobalClick); | ||
} | ||
/** | ||
* Handle global key event. | ||
*/ | ||
setNode = (node) => { | ||
this.node = node; | ||
const { | ||
autoFocus | ||
} = this.props; | ||
/** | ||
* Handle global (document) focus changed event. | ||
*/ | ||
if (node) { | ||
this.updatePosition(); | ||
if (autoFocus) { | ||
ensureFocus(node); | ||
} | ||
}, { | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
document.addEventListener('focusin', this.onFocusChanged); | ||
document.addEventListener('keydown', this.onGlobalKey); | ||
document.addEventListener('click', this.onGlobalClick); | ||
} | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
document.removeEventListener('focusin', this.onFocusChanged); | ||
document.removeEventListener('keydown', this.onGlobalKey); | ||
document.removeEventListener('click', this.onGlobalClick); | ||
} | ||
}, { | ||
key: 'updatePosition', | ||
/** | ||
* Find best context menu position and re-layout accordingly. | ||
*/ | ||
updatePosition() { | ||
const { | ||
position, | ||
offset | ||
} = this.props; | ||
/** | ||
* Find best context menu position and re-layout accordingly. | ||
*/ | ||
value: function updatePosition() { | ||
var _props = this.props, | ||
position = _props.position, | ||
offset = _props.offset; | ||
const bounds = this.node.getBoundingClientRect(); | ||
if (!position.width) { | ||
position.width = 0; | ||
} | ||
var bounds = this.node.getBoundingClientRect(); | ||
if (!position.height) { | ||
position.height = 0; | ||
} | ||
if (!position.width) { | ||
position.width = 0; | ||
} | ||
const container = this.renderer.getContainer(); | ||
if (!position.height) { | ||
position.height = 0; | ||
} | ||
const containerBounds = container.getBoundingClientRect(); | ||
var container = this.renderer.getContainer(); | ||
if (containerBounds.width > containerBounds.height) { | ||
this.node.classList.add('horizontal'); | ||
this.node.classList.remove('vertical'); | ||
} else { | ||
this.node.classList.add('vertical'); | ||
this.node.classList.remove('horizontal'); | ||
} | ||
var containerBounds = container.getBoundingClientRect(); | ||
const { scrollLeft, scrollTop } = container; | ||
if (containerBounds.width > containerBounds.height) { | ||
this.node.classList.add('horizontal'); | ||
this.node.classList.remove('vertical'); | ||
} else { | ||
this.node.classList.add('vertical'); | ||
this.node.classList.remove('horizontal'); | ||
} | ||
const style = {}; | ||
var scrollLeft = container.scrollLeft, | ||
scrollTop = container.scrollTop; | ||
if (position.x + (position.width / 2) > containerBounds.width / 2) { | ||
let left = position.x | ||
- containerBounds.left | ||
- bounds.width | ||
+ offset.x | ||
+ scrollLeft; | ||
left = clampNumber( | ||
left, | ||
0 + scrollLeft, | ||
containerBounds.width - bounds.width + scrollLeft | ||
); | ||
var style = {}; | ||
style.left = left + 'px'; | ||
} else { | ||
let left = window.scrollX | ||
- containerBounds.left | ||
+ position.x | ||
+ position.width | ||
- offset.x | ||
+ scrollLeft; | ||
if (position.x + position.width / 2 > containerBounds.width / 2) { | ||
var left = position.x - containerBounds.left - bounds.width + offset.x + scrollLeft; | ||
left = clampNumber( | ||
left, | ||
0 + scrollLeft, | ||
containerBounds.width - bounds.width + scrollLeft | ||
); | ||
left = clampNumber(left, 0 + scrollLeft, containerBounds.width - bounds.width + scrollLeft); | ||
style.left = left + 'px'; | ||
} | ||
style.left = left + 'px'; | ||
} else { | ||
var _left = window.scrollX - containerBounds.left + position.x + position.width - offset.x + scrollLeft; | ||
let top; | ||
_left = clampNumber(_left, 0 + scrollLeft, containerBounds.width - bounds.width + scrollLeft); | ||
if (position.y + (position.height / 2) > containerBounds.height / 2) { | ||
top = position.y | ||
- containerBounds.top | ||
- bounds.height | ||
+ offset.y | ||
+ scrollTop; | ||
style.left = _left + 'px'; | ||
} | ||
top = clampNumber( | ||
top, | ||
0 + scrollTop, | ||
containerBounds.height - bounds.height + scrollTop | ||
); | ||
var top = void 0; | ||
style.top = top + 'px'; | ||
} else { | ||
top = window.scrollY | ||
- containerBounds.top | ||
+ position.y | ||
- offset.y | ||
+ scrollTop; | ||
if (position.y + position.height / 2 > containerBounds.height / 2) { | ||
top = position.y - containerBounds.top - bounds.height + offset.y + scrollTop; | ||
top = clampNumber( | ||
top, | ||
0 + scrollTop, | ||
containerBounds.height - bounds.height + scrollTop | ||
); | ||
top = clampNumber(top, 0 + scrollTop, containerBounds.height - bounds.height + scrollTop); | ||
style.top = top + 'px'; | ||
} | ||
style.top = top + 'px'; | ||
} else { | ||
top = window.scrollY - containerBounds.top + position.y - offset.y + scrollTop; | ||
// ensure context menu will always be accessible | ||
style.overflowY = 'auto'; | ||
style.maxHeight = (containerBounds.height - top + scrollTop) + 'px'; | ||
top = clampNumber(top, 0 + scrollTop, containerBounds.height - bounds.height + scrollTop); | ||
assign(this.node.style, style); | ||
} | ||
style.top = top + 'px'; | ||
} | ||
// ensure context menu will always be accessible | ||
style.overflowY = 'auto'; | ||
style.maxHeight = containerBounds.height - top + scrollTop + 'px'; | ||
render() { | ||
assign(this.node.style, style); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _props2 = this.props, | ||
context = _props2.context, | ||
components = _props2.components, | ||
className = _props2.className; | ||
const { | ||
context, | ||
components, | ||
className | ||
} = this.props; | ||
return ( | ||
<div | ||
ref={ this.setNode } | ||
onContextMenu={ e => e.preventDefault() } | ||
className={ className }> | ||
{ | ||
components.map( | ||
(Component, idx) => <Component key={ idx } context={ context } /> | ||
) | ||
return createVNode(1, 'div', className, components.map(function (Component, idx) { | ||
return createComponentVNode(2, Component, { | ||
'context': context | ||
}, idx); | ||
}), 0, { | ||
'onContextMenu': function onContextMenu(e) { | ||
return e.preventDefault(); | ||
} | ||
</div> | ||
); | ||
} | ||
} | ||
}, null, this.setNode); | ||
} | ||
}]); | ||
ContextMenu.$inject = [ | ||
'renderer' | ||
]; | ||
return ContextMenu; | ||
}(Component); | ||
ContextMenu.$inject = ['renderer']; | ||
@@ -384,13 +384,3 @@ // helpers ///////////// | ||
const SELECTABLE_ELEMENTS = ` | ||
input[type=text], | ||
input[type=number], | ||
input[type=button], | ||
input[type=submit], | ||
[contenteditable], | ||
[tabindex], | ||
a[href], | ||
textarea, | ||
button | ||
`; | ||
var SELECTABLE_ELEMENTS = '\n input[type=text],\n input[type=number],\n input[type=button],\n input[type=submit],\n [contenteditable],\n [tabindex],\n a[href],\n textarea,\n button\n'; | ||
@@ -414,2 +404,3 @@ function ensureFocus(el) { | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=ContextMenuComponent.js.map |
@@ -0,26 +1,40 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import ContextMenuComponent from './components/ContextMenuComponent'; | ||
export default class ContextMenu { | ||
constructor(components, eventBus, renderer) { | ||
var ContextMenu = function () { | ||
function ContextMenu(components, eventBus, renderer) { | ||
_classCallCheck(this, ContextMenu); | ||
this._eventBus = eventBus; | ||
components.onGetComponent('table.before', () => ContextMenuComponent); | ||
} | ||
open(position, context) { | ||
this._eventBus.fire('contextMenu.open', { | ||
position, | ||
context | ||
components.onGetComponent('table.before', function () { | ||
return ContextMenuComponent; | ||
}); | ||
} | ||
close() { | ||
this._eventBus.fire('contextMenu.close'); | ||
} | ||
} | ||
_createClass(ContextMenu, [{ | ||
key: 'open', | ||
value: function open(position, context) { | ||
this._eventBus.fire('contextMenu.open', { | ||
position: position, | ||
context: context | ||
}); | ||
} | ||
}, { | ||
key: 'close', | ||
value: function close() { | ||
this._eventBus.fire('contextMenu.close'); | ||
} | ||
}]); | ||
ContextMenu.$inject = [ | ||
'components', | ||
'eventBus', | ||
'renderer' | ||
]; | ||
return ContextMenu; | ||
}(); | ||
export default ContextMenu; | ||
ContextMenu.$inject = ['components', 'eventBus', 'renderer']; | ||
//# sourceMappingURL=ContextMenu.js.map |
import ContextMenu from './ContextMenu'; | ||
export default { | ||
__init__: [ 'contextMenu' ], | ||
contextMenu: [ 'type', ContextMenu ] | ||
}; | ||
__init__: ['contextMenu'], | ||
contextMenu: ['type', ContextMenu] | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -0,172 +1,177 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import { Row, Col } from '../../model'; | ||
import { | ||
closest as domClosest, | ||
event as domEvent | ||
} from 'min-dom'; | ||
import { closest as domClosest, event as domEvent } from 'min-dom'; | ||
const TARGET_SELECTOR = | ||
`.dmn-decision-table-container td, | ||
.dmn-decision-table-container th`; | ||
var TARGET_SELECTOR = '.dmn-decision-table-container td,\n .dmn-decision-table-container th'; | ||
export default class DragAndDrop { | ||
constructor(eventBus, renderer, modeling, sheet) { | ||
this._eventBus = eventBus; | ||
this._renderer = renderer; | ||
this._modeling = modeling; | ||
this._sheet = sheet; | ||
var DragAndDrop = function () { | ||
function DragAndDrop(eventBus, renderer, modeling, sheet) { | ||
var _this = this; | ||
this._dragContext = null; | ||
_classCallCheck(this, DragAndDrop); | ||
eventBus.on('table.destroy', () => { | ||
this._unbindListeners(); | ||
}); | ||
} | ||
this.handleDragOver = function (event) { | ||
_bindListeners() { | ||
domEvent.bind(document, 'dragover', this.handleDragOver); | ||
domEvent.bind(document, 'drop', this.handleDrop); | ||
domEvent.bind(document, 'dragend', this.handleDragEnd); | ||
} | ||
// we're taking over (!) | ||
stopEvent(event); | ||
_unbindListeners() { | ||
domEvent.unbind(document, 'dragover', this.handleDragOver); | ||
domEvent.unbind(document, 'drop', this.handleDrop); | ||
domEvent.unbind(document, 'dragend', this.handleDragEnd); | ||
} | ||
var targetEl = event.target; | ||
_emit(eventName, originalEvent) { | ||
var cellEl = domClosest(targetEl, TARGET_SELECTOR, true); | ||
return this._eventBus.fire(eventName, { | ||
dragContext: this._dragContext, | ||
originalEvent | ||
}); | ||
} | ||
var allowed = !!cellEl; | ||
startDrag(element, event) { | ||
var hoverEl = _this._dragContext.hoverEl; | ||
stopEvent(event, true); | ||
// drag leave | ||
event.dataTransfer.effectAllowed = 'move'; | ||
if (hoverEl && hoverEl !== cellEl) { | ||
_this._emit('dragAndDrop.dragLeave', event); | ||
// QUIRK: Firefox won't fire events unless data was set | ||
if (event.dataTransfer.setData) { | ||
event.dataTransfer.setData('text', '__DUMMY'); | ||
} | ||
// unset target element | ||
_this._dragContext.targetEl = null; | ||
this._dragContext = { | ||
draggedElement: element | ||
}; | ||
// unset hover element | ||
_this._dragContext.hoverEl = null; | ||
} | ||
this._bindListeners(); | ||
if (cellEl) { | ||
this._emit('dragAndDrop.dragStart', event); | ||
} | ||
// drag enter | ||
if (cellEl !== hoverEl) { | ||
handleDragOver = (event) => { | ||
// new hover element | ||
_this._dragContext.hoverEl = cellEl; | ||
// we're taking over (!) | ||
stopEvent(event); | ||
allowed = _this._emit('dragAndDrop.dragEnter', event); | ||
const targetEl = event.target; | ||
if (allowed !== false) { | ||
// new targetEl | ||
_this._dragContext.targetEl = cellEl; | ||
} | ||
} | ||
const cellEl = domClosest(targetEl, TARGET_SELECTOR, true); | ||
// drag over | ||
allowed = _this._emit('dragAndDrop.dragOver', event); | ||
} | ||
let allowed = !!cellEl; | ||
event.dataTransfer.dropEffect = allowed !== false ? 'move' : 'none'; | ||
}; | ||
const { | ||
hoverEl | ||
} = this._dragContext; | ||
this.handleDrop = function (event) { | ||
// drag leave | ||
if (hoverEl && hoverEl !== cellEl) { | ||
this._emit('dragAndDrop.dragLeave', event); | ||
// prevent default drop action | ||
// QUIRK: Firefox will redirect if not prevented | ||
stopEvent(event); | ||
// unset target element | ||
this._dragContext.targetEl = null; | ||
var target = _this._emit('dragAndDrop.drop', event); | ||
// unset hover element | ||
this._dragContext.hoverEl = null; | ||
} | ||
if (target) { | ||
var draggedElement = _this._dragContext.draggedElement; | ||
if (cellEl) { | ||
// drag enter | ||
if (cellEl !== hoverEl) { | ||
if (draggedElement instanceof Row) { | ||
var _sheet$getRoot = _this._sheet.getRoot(), | ||
rows = _sheet$getRoot.rows; | ||
// new hover element | ||
this._dragContext.hoverEl = cellEl; | ||
var index = rows.indexOf(target); | ||
allowed = this._emit('dragAndDrop.dragEnter', event); | ||
_this._modeling.moveRow(draggedElement, index); | ||
} else if (draggedElement instanceof Col) { | ||
var _sheet$getRoot2 = _this._sheet.getRoot(), | ||
cols = _sheet$getRoot2.cols; | ||
if (allowed !== false) { | ||
// new targetEl | ||
this._dragContext.targetEl = cellEl; | ||
var _index = cols.indexOf(target); | ||
_this._modeling.moveCol(draggedElement, _index); | ||
} | ||
} | ||
// drag over | ||
allowed = this._emit('dragAndDrop.dragOver', event); | ||
} | ||
// manually call to drag end needed, as we prevent the default | ||
// browser behavior / drag end handling via | ||
// event.preventDefault(); | ||
_this.handleDragEnd(event); | ||
}; | ||
event.dataTransfer.dropEffect = allowed !== false ? 'move' : 'none'; | ||
} | ||
this.handleDragEnd = function (event) { | ||
handleDrop = (event) => { | ||
// prevent default drop action | ||
stopEvent(event); | ||
// prevent default drop action | ||
// QUIRK: Firefox will redirect if not prevented | ||
stopEvent(event); | ||
_this._unbindListeners(); | ||
_this._emit('dragAndDrop.dragEnd', event); | ||
const target = this._emit('dragAndDrop.drop', event); | ||
_this._dragContext = null; | ||
}; | ||
if (target) { | ||
this._eventBus = eventBus; | ||
this._renderer = renderer; | ||
this._modeling = modeling; | ||
this._sheet = sheet; | ||
const { | ||
draggedElement | ||
} = this._dragContext; | ||
this._dragContext = null; | ||
if (draggedElement instanceof Row) { | ||
const { rows } = this._sheet.getRoot(); | ||
eventBus.on('table.destroy', function () { | ||
_this._unbindListeners(); | ||
}); | ||
} | ||
let index = rows.indexOf(target); | ||
_createClass(DragAndDrop, [{ | ||
key: '_bindListeners', | ||
value: function _bindListeners() { | ||
domEvent.bind(document, 'dragover', this.handleDragOver); | ||
domEvent.bind(document, 'drop', this.handleDrop); | ||
domEvent.bind(document, 'dragend', this.handleDragEnd); | ||
} | ||
}, { | ||
key: '_unbindListeners', | ||
value: function _unbindListeners() { | ||
domEvent.unbind(document, 'dragover', this.handleDragOver); | ||
domEvent.unbind(document, 'drop', this.handleDrop); | ||
domEvent.unbind(document, 'dragend', this.handleDragEnd); | ||
} | ||
}, { | ||
key: '_emit', | ||
value: function _emit(eventName, originalEvent) { | ||
this._modeling.moveRow(draggedElement, index); | ||
} else if (draggedElement instanceof Col) { | ||
const { cols } = this._sheet.getRoot(); | ||
return this._eventBus.fire(eventName, { | ||
dragContext: this._dragContext, | ||
originalEvent: originalEvent | ||
}); | ||
} | ||
}, { | ||
key: 'startDrag', | ||
value: function startDrag(element, event) { | ||
let index = cols.indexOf(target); | ||
stopEvent(event, true); | ||
this._modeling.moveCol(draggedElement, index); | ||
event.dataTransfer.effectAllowed = 'move'; | ||
// QUIRK: Firefox won't fire events unless data was set | ||
if (event.dataTransfer.setData) { | ||
event.dataTransfer.setData('text', '__DUMMY'); | ||
} | ||
} | ||
// manually call to drag end needed, as we prevent the default | ||
// browser behavior / drag end handling via | ||
// event.preventDefault(); | ||
this.handleDragEnd(event); | ||
} | ||
this._dragContext = { | ||
draggedElement: element | ||
}; | ||
handleDragEnd = (event) => { | ||
this._bindListeners(); | ||
// prevent default drop action | ||
stopEvent(event); | ||
this._emit('dragAndDrop.dragStart', event); | ||
} | ||
}]); | ||
this._unbindListeners(); | ||
this._emit('dragAndDrop.dragEnd', event); | ||
return DragAndDrop; | ||
}(); | ||
this._dragContext = null; | ||
} | ||
export default DragAndDrop; | ||
} | ||
DragAndDrop.$inject = [ | ||
'eventBus', | ||
'renderer', | ||
'modeling', | ||
'sheet' | ||
]; | ||
DragAndDrop.$inject = ['eventBus', 'renderer', 'modeling', 'sheet']; | ||
// helpers ///////////////// | ||
@@ -180,2 +185,3 @@ | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=DragAndDrop.js.map |
import DragAndDrop from './DragAndDrop'; | ||
export default { | ||
__init__: [ 'dragAndDrop' ], | ||
dragAndDrop: [ 'type', DragAndDrop ] | ||
}; | ||
__init__: ['dragAndDrop'], | ||
dragAndDrop: ['type', DragAndDrop] | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -0,7 +1,10 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import { forEach } from 'min-dash'; | ||
const NOT_REGISTERED_ERROR = 'is not a registered action', | ||
IS_REGISTERED_ERROR = 'is already registered'; | ||
var NOT_REGISTERED_ERROR = 'is not a registered action', | ||
IS_REGISTERED_ERROR = 'is already registered'; | ||
/** | ||
@@ -15,34 +18,54 @@ * An interface that provides access to modeling actions by decoupling | ||
*/ | ||
export default class EditorActions { | ||
constructor(commandStack, eventBus, modeling, selection) { | ||
var EditorActions = function () { | ||
function EditorActions(commandStack, eventBus, modeling, selection) { | ||
_classCallCheck(this, EditorActions); | ||
this._actions = { | ||
undo() { | ||
undo: function undo() { | ||
commandStack.undo(); | ||
}, | ||
redo() { | ||
redo: function redo() { | ||
commandStack.redo(); | ||
}, | ||
select({ cell }) { | ||
select: function select(_ref) { | ||
var cell = _ref.cell; | ||
selection.select(cell); | ||
}, | ||
deselect() { | ||
deselect: function deselect() { | ||
selection.deselect(); | ||
}, | ||
addRow({ attrs, index }) { | ||
addRow: function addRow(_ref2) { | ||
var attrs = _ref2.attrs, | ||
index = _ref2.index; | ||
modeling.addRow(attrs, index); | ||
}, | ||
removeRow({ row }) { | ||
removeRow: function removeRow(_ref3) { | ||
var row = _ref3.row; | ||
modeling.removeRow(row); | ||
}, | ||
moveRow({ row, index }) { | ||
moveRow: function moveRow(_ref4) { | ||
var row = _ref4.row, | ||
index = _ref4.index; | ||
modeling.moveRow(row, index); | ||
}, | ||
addCol({ attrs, index }) { | ||
addCol: function addCol(_ref5) { | ||
var attrs = _ref5.attrs, | ||
index = _ref5.index; | ||
modeling.addCol(attrs, index); | ||
}, | ||
removeCol({ col }) { | ||
removeCol: function removeCol(_ref6) { | ||
var col = _ref6.col; | ||
modeling.removeCol(col); | ||
}, | ||
moveCol({ col, index }) { | ||
moveCol: function moveCol(_ref7) { | ||
var col = _ref7.col, | ||
index = _ref7.index; | ||
modeling.moveCol(col, index); | ||
@@ -61,73 +84,91 @@ } | ||
*/ | ||
trigger(action, opts) { | ||
if (!this._actions[action]) { | ||
throw error(action, NOT_REGISTERED_ERROR); | ||
_createClass(EditorActions, [{ | ||
key: 'trigger', | ||
value: function trigger(action, opts) { | ||
if (!this._actions[action]) { | ||
throw error(action, NOT_REGISTERED_ERROR); | ||
} | ||
return this._actions[action](opts); | ||
} | ||
return this._actions[action](opts); | ||
} | ||
/** | ||
* Registers a collections of actions. | ||
* The key of the object will be the name of the action. | ||
* | ||
* @param {Object} actions | ||
*/ | ||
/** | ||
* Registers a collections of actions. | ||
* The key of the object will be the name of the action. | ||
* | ||
* @param {Object} actions | ||
*/ | ||
register(actions, listener) { | ||
if (typeof actions === 'string') { | ||
return this._registerAction(actions, listener); | ||
}, { | ||
key: 'register', | ||
value: function register(actions, listener) { | ||
var _this = this; | ||
if (typeof actions === 'string') { | ||
return this._registerAction(actions, listener); | ||
} | ||
forEach(actions, function (listener, action) { | ||
_this._registerAction(action, listener); | ||
}, this); | ||
} | ||
forEach(actions, (listener, action) => { | ||
this._registerAction(action, listener); | ||
}, this); | ||
} | ||
/** | ||
* Registers a listener to an action key | ||
* | ||
* @param {String} action | ||
* @param {Function} listener | ||
*/ | ||
/** | ||
* Registers a listener to an action key | ||
* | ||
* @param {String} action | ||
* @param {Function} listener | ||
*/ | ||
_registerAction(action, listener) { | ||
if (this.isRegistered(action)) { | ||
throw error(action, IS_REGISTERED_ERROR); | ||
}, { | ||
key: '_registerAction', | ||
value: function _registerAction(action, listener) { | ||
if (this.isRegistered(action)) { | ||
throw error(action, IS_REGISTERED_ERROR); | ||
} | ||
this._actions[action] = listener; | ||
} | ||
this._actions[action] = listener; | ||
} | ||
/** | ||
* Unregister an existing action | ||
* | ||
* @param {String} action | ||
*/ | ||
/** | ||
* Unregister an existing action | ||
* | ||
* @param {String} action | ||
*/ | ||
unregister(action) { | ||
if (!this.isRegistered(action)) { | ||
throw error(action, NOT_REGISTERED_ERROR); | ||
}, { | ||
key: 'unregister', | ||
value: function unregister(action) { | ||
if (!this.isRegistered(action)) { | ||
throw error(action, NOT_REGISTERED_ERROR); | ||
} | ||
this._actions[action] = undefined; | ||
} | ||
this._actions[action] = undefined; | ||
} | ||
/** | ||
* Checks wether the given action is registered | ||
* | ||
* @param {String} action | ||
* | ||
* @return {Boolean} | ||
*/ | ||
}, { | ||
key: 'isRegistered', | ||
value: function isRegistered(action) { | ||
return !!this._actions[action]; | ||
} | ||
}]); | ||
/** | ||
* Checks wether the given action is registered | ||
* | ||
* @param {String} action | ||
* | ||
* @return {Boolean} | ||
*/ | ||
isRegistered(action) { | ||
return !!this._actions[action]; | ||
} | ||
} | ||
return EditorActions; | ||
}(); | ||
EditorActions.$inject = [ | ||
'commandStack', | ||
'eventBus', | ||
'modeling', | ||
'selection' | ||
]; | ||
export default EditorActions; | ||
EditorActions.$inject = ['commandStack', 'eventBus', 'modeling', 'selection']; | ||
// helpers ///////////// | ||
@@ -137,2 +178,3 @@ | ||
return new Error(action + ' ' + message); | ||
} | ||
} | ||
//# sourceMappingURL=EditorActions.js.map |
@@ -5,5 +5,6 @@ import Selection from '../selection'; | ||
export default { | ||
__depends__: [ Selection ], | ||
__init__: [ 'editorActions' ], | ||
editorActions: [ 'type', EditorActions ] | ||
}; | ||
__depends__: [Selection], | ||
__init__: ['editorActions'], | ||
editorActions: ['type', EditorActions] | ||
}; | ||
//# sourceMappingURL=index.js.map |
import InteractionEvents from './InteractionEvents'; | ||
export default { | ||
__init__: [ 'interactionEvents' ], | ||
interactionEvents: [ 'type', InteractionEvents ] | ||
}; | ||
__init__: ['interactionEvents'], | ||
interactionEvents: ['type', InteractionEvents] | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,28 +0,9 @@ | ||
import { | ||
closest as domClosest | ||
} from 'min-dom'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
const EVENTS = [ | ||
'click', | ||
'dblclick', | ||
'contextmenu', | ||
'mousedown', | ||
'mouseup', | ||
'mouseenter', | ||
'mouseleave', | ||
'mouseout', | ||
'mouseover', | ||
'mousemove', | ||
'focusin', | ||
'focusout', | ||
'drag', | ||
'dragstart', | ||
'dragend', | ||
'dragover', | ||
'dragenter', | ||
'dragleave', | ||
'drop' | ||
]; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import { closest as domClosest } from 'min-dom'; | ||
var EVENTS = ['click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'mouseout', 'mouseover', 'mousemove', 'focusin', 'focusout', 'drag', 'dragstart', 'dragend', 'dragover', 'dragenter', 'dragleave', 'drop']; | ||
/** | ||
@@ -34,69 +15,85 @@ * Provides interaction events on the table. | ||
*/ | ||
export default class InteractionEvents { | ||
constructor(config, eventBus) { | ||
this._eventBus = eventBus; | ||
this._container = config.container; | ||
var InteractionEvents = function () { | ||
function InteractionEvents(config, eventBus) { | ||
var _this = this; | ||
eventBus.on('table.init', () => { | ||
this._addEventListeners(EVENTS); | ||
}); | ||
_classCallCheck(this, InteractionEvents); | ||
eventBus.on('table.destroy', () => { | ||
this._removeEventListeners(EVENTS); | ||
}); | ||
} | ||
this._handleEvent = function (event) { | ||
var target = event.target, | ||
type = event.type; | ||
_addEventListeners(events) { | ||
const container = this._container; | ||
events.forEach(event => { | ||
container.addEventListener(event, this._handleEvent); | ||
}); | ||
} | ||
var node = findClosestCell(target); | ||
_removeEventListeners(events) { | ||
const container = this._container; | ||
if (!node) { | ||
return; | ||
} | ||
events.forEach(event => { | ||
container.removeEventListener(event, this._handleEvent); | ||
var elementId = node.getAttribute('data-element-id'); | ||
if (elementId) { | ||
var e = _this._eventBus.createEvent({ | ||
id: elementId, | ||
event: event, | ||
node: node, | ||
target: node | ||
}); | ||
_this._eventBus.fire('cell.' + type, e); | ||
if (e.defaultPrevented) { | ||
event.preventDefault(); | ||
} | ||
if (e.cancelBubble) { | ||
event.stopPropagation(); | ||
} | ||
} | ||
}; | ||
this._eventBus = eventBus; | ||
this._container = config.container; | ||
eventBus.on('table.init', function () { | ||
_this._addEventListeners(EVENTS); | ||
}); | ||
eventBus.on('table.destroy', function () { | ||
_this._removeEventListeners(EVENTS); | ||
}); | ||
} | ||
_handleEvent = (event) => { | ||
const { target, type } = event; | ||
_createClass(InteractionEvents, [{ | ||
key: '_addEventListeners', | ||
value: function _addEventListeners(events) { | ||
var _this2 = this; | ||
const node = findClosestCell(target); | ||
var container = this._container; | ||
if (!node) { | ||
return; | ||
events.forEach(function (event) { | ||
container.addEventListener(event, _this2._handleEvent); | ||
}); | ||
} | ||
}, { | ||
key: '_removeEventListeners', | ||
value: function _removeEventListeners(events) { | ||
var _this3 = this; | ||
const elementId = node.getAttribute('data-element-id'); | ||
var container = this._container; | ||
if (elementId) { | ||
const e = this._eventBus.createEvent({ | ||
id: elementId, | ||
event, | ||
node, | ||
target: node | ||
events.forEach(function (event) { | ||
container.removeEventListener(event, _this3._handleEvent); | ||
}); | ||
} | ||
}]); | ||
this._eventBus.fire(`cell.${type}`, e); | ||
return InteractionEvents; | ||
}(); | ||
if (e.defaultPrevented) { | ||
event.preventDefault(); | ||
} | ||
export default InteractionEvents; | ||
if (e.cancelBubble) { | ||
event.stopPropagation(); | ||
} | ||
} | ||
} | ||
} | ||
InteractionEvents.$inject = [ | ||
'config.renderer', | ||
'eventBus' | ||
]; | ||
InteractionEvents.$inject = ['config.renderer', 'eventBus']; | ||
@@ -107,2 +104,3 @@ // helpers ///////////// | ||
return domClosest(element, '[data-element-id]', true); | ||
} | ||
} | ||
//# sourceMappingURL=InteractionEvents.js.map |
@@ -0,8 +1,12 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
* A handler that implements column addition. | ||
*/ | ||
export default class AddColHandler { | ||
var AddColHandler = function () { | ||
function AddColHandler(sheet, elementFactory) { | ||
_classCallCheck(this, AddColHandler); | ||
constructor(sheet, elementFactory) { | ||
this._sheet = sheet; | ||
@@ -12,58 +16,63 @@ this._elementFactory = elementFactory; | ||
/** | ||
* <do> | ||
*/ | ||
execute(context) { | ||
const sheet = this._sheet, | ||
_createClass(AddColHandler, [{ | ||
key: 'execute', | ||
value: function execute(context) { | ||
var sheet = this._sheet, | ||
elementFactory = this._elementFactory, | ||
root = sheet.getRoot(); | ||
let { | ||
col, | ||
index | ||
} = context; | ||
var col = context.col, | ||
index = context.index; | ||
if (typeof index === 'undefined') { | ||
index = context.index = root.cols.length; | ||
} | ||
context.newRoot = root; | ||
if (typeof index === 'undefined') { | ||
index = context.index = root.cols.length; | ||
} | ||
if (!col.cells.length) { | ||
root.rows.forEach((row, idx) => { | ||
const cell = elementFactory.create('cell', { row, col }); | ||
context.newRoot = root; | ||
col.cells[idx] = cell; | ||
}); | ||
if (!col.cells.length) { | ||
root.rows.forEach(function (row, idx) { | ||
var cell = elementFactory.create('cell', { row: row, col: col }); | ||
col.cells[idx] = cell; | ||
}); | ||
} | ||
sheet.addCol(col, index); | ||
return sheet.getRoot(); | ||
} | ||
sheet.addCol(col, index); | ||
/** | ||
* <undo> | ||
*/ | ||
return sheet.getRoot(); | ||
} | ||
}, { | ||
key: 'revert', | ||
value: function revert(context) { | ||
var col = context.col; | ||
/** | ||
* <undo> | ||
*/ | ||
revert(context) { | ||
var sheet = this._sheet; | ||
const { | ||
col | ||
} = context; | ||
sheet.removeCol(col); | ||
const sheet = this._sheet; | ||
return sheet.getRoot(); | ||
} | ||
}]); | ||
sheet.removeCol(col); | ||
return AddColHandler; | ||
}(); | ||
return sheet.getRoot(); | ||
} | ||
export default AddColHandler; | ||
} | ||
AddColHandler.$inject = [ | ||
'sheet', | ||
'elementFactory' | ||
]; | ||
AddColHandler.$inject = ['sheet', 'elementFactory']; | ||
//# sourceMappingURL=AddColHandler.js.map |
@@ -0,8 +1,12 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
* A handler that implements row addition. | ||
*/ | ||
export default class AddRowHandler { | ||
var AddRowHandler = function () { | ||
function AddRowHandler(sheet, elementFactory) { | ||
_classCallCheck(this, AddRowHandler); | ||
constructor(sheet, elementFactory) { | ||
this._sheet = sheet; | ||
@@ -12,58 +16,63 @@ this._elementFactory = elementFactory; | ||
/** | ||
* <do> | ||
*/ | ||
execute(context) { | ||
const sheet = this._sheet, | ||
_createClass(AddRowHandler, [{ | ||
key: 'execute', | ||
value: function execute(context) { | ||
var sheet = this._sheet, | ||
elementFactory = this._elementFactory, | ||
root = sheet.getRoot(); | ||
let { | ||
row, | ||
index | ||
} = context; | ||
var row = context.row, | ||
index = context.index; | ||
if (typeof index === 'undefined') { | ||
index = context.index = root.rows.length; | ||
} | ||
context.newRoot = root; | ||
if (typeof index === 'undefined') { | ||
index = context.index = root.rows.length; | ||
} | ||
if (!row.cells.length) { | ||
root.cols.forEach((col, idx) => { | ||
const cell = elementFactory.create('cell', { row, col }); | ||
context.newRoot = root; | ||
row.cells[idx] = cell; | ||
}); | ||
if (!row.cells.length) { | ||
root.cols.forEach(function (col, idx) { | ||
var cell = elementFactory.create('cell', { row: row, col: col }); | ||
row.cells[idx] = cell; | ||
}); | ||
} | ||
sheet.addRow(row, index); | ||
return sheet.getRoot(); | ||
} | ||
sheet.addRow(row, index); | ||
/** | ||
* <undo> | ||
*/ | ||
return sheet.getRoot(); | ||
} | ||
}, { | ||
key: 'revert', | ||
value: function revert(context) { | ||
var row = context.row; | ||
/** | ||
* <undo> | ||
*/ | ||
revert(context) { | ||
var sheet = this._sheet; | ||
const { | ||
row | ||
} = context; | ||
sheet.removeRow(row); | ||
const sheet = this._sheet; | ||
return sheet.getRoot(); | ||
} | ||
}]); | ||
sheet.removeRow(row); | ||
return AddRowHandler; | ||
}(); | ||
return sheet.getRoot(); | ||
} | ||
export default AddRowHandler; | ||
} | ||
AddRowHandler.$inject = [ | ||
'sheet', | ||
'elementFactory' | ||
]; | ||
AddRowHandler.$inject = ['sheet', 'elementFactory']; | ||
//# sourceMappingURL=AddRowHandler.js.map |
@@ -0,2 +1,5 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
@@ -10,28 +13,39 @@ * A handler that implements cell editing. | ||
*/ | ||
export default class EditCellHandler { | ||
var EditCellHandler = function () { | ||
function EditCellHandler() { | ||
_classCallCheck(this, EditCellHandler); | ||
} | ||
/** | ||
* <do> | ||
*/ | ||
execute(context) { | ||
_createClass(EditCellHandler, [{ | ||
key: "execute", | ||
let { | ||
cell | ||
} = context; | ||
return cell; | ||
} | ||
/** | ||
* <do> | ||
*/ | ||
value: function execute(context) { | ||
var cell = context.cell; | ||
/** | ||
* <undo> | ||
*/ | ||
revert(context) { | ||
const { | ||
cell | ||
} = context; | ||
return cell; | ||
} | ||
return cell; | ||
} | ||
/** | ||
* <undo> | ||
*/ | ||
} | ||
}, { | ||
key: "revert", | ||
value: function revert(context) { | ||
var cell = context.cell; | ||
return cell; | ||
} | ||
}]); | ||
return EditCellHandler; | ||
}(); | ||
export default EditCellHandler; | ||
//# sourceMappingURL=EditCellHandler.js.map |
@@ -0,8 +1,12 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
* A handler that implements col movement. | ||
*/ | ||
export default class MoveColHandler { | ||
var MoveColHandler = function () { | ||
function MoveColHandler(modeling) { | ||
_classCallCheck(this, MoveColHandler); | ||
constructor(modeling) { | ||
this._modeling = modeling; | ||
@@ -14,24 +18,35 @@ } | ||
*/ | ||
preExecute(context) { | ||
let { | ||
col | ||
} = context; | ||
this._modeling.removeCol(col); | ||
} | ||
/** | ||
* <postexecute> | ||
*/ | ||
postExecute(context) { | ||
let { | ||
col, | ||
index | ||
} = context; | ||
_createClass(MoveColHandler, [{ | ||
key: 'preExecute', | ||
value: function preExecute(context) { | ||
var col = context.col; | ||
this._modeling.addCol(col, index); | ||
} | ||
} | ||
this._modeling.removeCol(col); | ||
} | ||
MoveColHandler.$inject = [ 'modeling' ]; | ||
/** | ||
* <postexecute> | ||
*/ | ||
}, { | ||
key: 'postExecute', | ||
value: function postExecute(context) { | ||
var col = context.col, | ||
index = context.index; | ||
this._modeling.addCol(col, index); | ||
} | ||
}]); | ||
return MoveColHandler; | ||
}(); | ||
export default MoveColHandler; | ||
MoveColHandler.$inject = ['modeling']; | ||
//# sourceMappingURL=MoveColHandler.js.map |
@@ -0,8 +1,12 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
* A handler that implements row movement. | ||
*/ | ||
export default class MoveRowHandler { | ||
var MoveRowHandler = function () { | ||
function MoveRowHandler(modeling) { | ||
_classCallCheck(this, MoveRowHandler); | ||
constructor(modeling) { | ||
this._modeling = modeling; | ||
@@ -14,24 +18,35 @@ } | ||
*/ | ||
preExecute(context) { | ||
let { | ||
row | ||
} = context; | ||
this._modeling.removeRow(row); | ||
} | ||
/** | ||
* <postexecute> | ||
*/ | ||
postExecute(context) { | ||
let { | ||
row, | ||
index | ||
} = context; | ||
_createClass(MoveRowHandler, [{ | ||
key: 'preExecute', | ||
value: function preExecute(context) { | ||
var row = context.row; | ||
this._modeling.addRow(row, index); | ||
} | ||
} | ||
this._modeling.removeRow(row); | ||
} | ||
MoveRowHandler.$inject = [ 'modeling' ]; | ||
/** | ||
* <postexecute> | ||
*/ | ||
}, { | ||
key: 'postExecute', | ||
value: function postExecute(context) { | ||
var row = context.row, | ||
index = context.index; | ||
this._modeling.addRow(row, index); | ||
} | ||
}]); | ||
return MoveRowHandler; | ||
}(); | ||
export default MoveRowHandler; | ||
MoveRowHandler.$inject = ['modeling']; | ||
//# sourceMappingURL=MoveRowHandler.js.map |
@@ -0,8 +1,12 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
* A handler that implements column deletion. | ||
*/ | ||
export default class RemoveColHandler { | ||
var RemoveColHandler = function () { | ||
function RemoveColHandler(sheet, elementFactory) { | ||
_classCallCheck(this, RemoveColHandler); | ||
constructor(sheet, elementFactory) { | ||
this._sheet = sheet; | ||
@@ -15,48 +19,53 @@ this._elementFactory = elementFactory; | ||
*/ | ||
execute(context) { | ||
const sheet = this._sheet; | ||
let { | ||
col | ||
} = context; | ||
_createClass(RemoveColHandler, [{ | ||
key: 'execute', | ||
value: function execute(context) { | ||
const root = context.oldRoot = col.root; | ||
var sheet = this._sheet; | ||
// retrieve and remember previous col position | ||
const oldIndex = context.oldIndex = root.cols.indexOf(col); | ||
var col = context.col; | ||
if (oldIndex === -1) { | ||
throw new Error(`col#${col.id} not in sheet`); | ||
var root = context.oldRoot = col.root; | ||
// retrieve and remember previous col position | ||
var oldIndex = context.oldIndex = root.cols.indexOf(col); | ||
if (oldIndex === -1) { | ||
throw new Error('col#' + col.id + ' not in sheet'); | ||
} | ||
sheet.removeCol(col); | ||
return sheet.getRoot(); | ||
} | ||
sheet.removeCol(col); | ||
/** | ||
* <undo> | ||
*/ | ||
return sheet.getRoot(); | ||
} | ||
}, { | ||
key: 'revert', | ||
value: function revert(context) { | ||
var col = context.col, | ||
oldIndex = context.oldIndex; | ||
/** | ||
* <undo> | ||
*/ | ||
revert(context) { | ||
var sheet = this._sheet; | ||
const { | ||
col, | ||
oldIndex | ||
} = context; | ||
sheet.addCol(col, oldIndex); | ||
const sheet = this._sheet; | ||
return sheet.getRoot(); | ||
} | ||
}]); | ||
sheet.addCol(col, oldIndex); | ||
return RemoveColHandler; | ||
}(); | ||
return sheet.getRoot(); | ||
} | ||
export default RemoveColHandler; | ||
} | ||
RemoveColHandler.$inject = [ | ||
'sheet', | ||
'elementFactory' | ||
]; | ||
RemoveColHandler.$inject = ['sheet', 'elementFactory']; | ||
//# sourceMappingURL=RemoveColHandler.js.map |
@@ -0,60 +1,70 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
* A handler that implements row deletion. | ||
*/ | ||
export default class RemoveRowHandler { | ||
var RemoveRowHandler = function () { | ||
function RemoveRowHandler(sheet) { | ||
_classCallCheck(this, RemoveRowHandler); | ||
constructor(sheet) { | ||
this._sheet = sheet; | ||
} | ||
/** | ||
* <do> | ||
*/ | ||
execute(context) { | ||
const sheet = this._sheet, | ||
_createClass(RemoveRowHandler, [{ | ||
key: 'execute', | ||
value: function execute(context) { | ||
var sheet = this._sheet, | ||
root = sheet.getRoot(); | ||
let { | ||
row | ||
} = context; | ||
var row = context.row; | ||
// retrieve and remember previous row position | ||
const oldIndex = context.oldIndex = root.rows.indexOf(row); | ||
// retrieve and remember previous row position | ||
context.oldRoot = row.root; | ||
var oldIndex = context.oldIndex = root.rows.indexOf(row); | ||
if (oldIndex === -1) { | ||
throw new Error(`row#${row.id} not in sheet`); | ||
context.oldRoot = row.root; | ||
if (oldIndex === -1) { | ||
throw new Error('row#' + row.id + ' not in sheet'); | ||
} | ||
sheet.removeRow(row); | ||
return sheet.getRoot(); | ||
} | ||
sheet.removeRow(row); | ||
/** | ||
* <undo> | ||
*/ | ||
return sheet.getRoot(); | ||
} | ||
}, { | ||
key: 'revert', | ||
value: function revert(context) { | ||
var row = context.row, | ||
oldIndex = context.oldIndex; | ||
/** | ||
* <undo> | ||
*/ | ||
revert(context) { | ||
var sheet = this._sheet; | ||
const { | ||
row, | ||
oldIndex | ||
} = context; | ||
sheet.addRow(row, oldIndex); | ||
const sheet = this._sheet; | ||
return sheet.getRoot(); | ||
} | ||
}]); | ||
sheet.addRow(row, oldIndex); | ||
return RemoveRowHandler; | ||
}(); | ||
return sheet.getRoot(); | ||
} | ||
export default RemoveRowHandler; | ||
} | ||
RemoveRowHandler.$inject = [ | ||
'sheet' | ||
]; | ||
RemoveRowHandler.$inject = ['sheet']; | ||
//# sourceMappingURL=RemoveRowHandler.js.map |
@@ -5,7 +5,6 @@ import CommandStack from 'diagram-js/lib/command/CommandStack'; | ||
export default { | ||
__init__: [ | ||
'modeling' | ||
], | ||
modeling: [ 'type', Modeling ], | ||
commandStack: [ 'type', CommandStack ] | ||
}; | ||
__init__: ['modeling'], | ||
modeling: ['type', Modeling], | ||
commandStack: ['type', CommandStack] | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -0,1 +1,7 @@ | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import { forEach } from 'min-dash'; | ||
@@ -13,3 +19,2 @@ | ||
/** | ||
@@ -22,5 +27,9 @@ * The basic modeling entry point. | ||
*/ | ||
export default class Modeling { | ||
constructor(eventBus, elementFactory, commandStack) { | ||
var Modeling = function () { | ||
function Modeling(eventBus, elementFactory, commandStack) { | ||
var _this = this; | ||
_classCallCheck(this, Modeling); | ||
this._eventBus = eventBus; | ||
@@ -30,111 +39,118 @@ this._elementFactory = elementFactory; | ||
eventBus.on('table.init', () => { | ||
eventBus.on('table.init', function () { | ||
// register modeling handlers | ||
registerHandlers(this.getHandlers(), commandStack); | ||
registerHandlers(_this.getHandlers(), commandStack); | ||
}); | ||
} | ||
_createClass(Modeling, [{ | ||
key: 'getHandlers', | ||
value: function getHandlers() { | ||
return Modeling._getHandlers(); | ||
} | ||
}, { | ||
key: '_create', | ||
value: function _create(type, attrs) { | ||
if (attrs instanceof Base) { | ||
return attrs; | ||
} else { | ||
return this._elementFactory.create(type, attrs); | ||
} | ||
} | ||
getHandlers() { | ||
return Modeling._getHandlers(); | ||
} | ||
// public API | ||
}, { | ||
key: 'addRow', | ||
value: function addRow(attrs, index) { | ||
var row = this._create('row', attrs); | ||
static _getHandlers() { | ||
return { | ||
'row.add': AddRowHandler, | ||
'row.remove': RemoveRowHandler, | ||
'row.move': MoveRowHandler, | ||
var context = { | ||
row: row, | ||
index: index | ||
}; | ||
'col.add': AddColHandler, | ||
'col.remove': RemoveColHandler, | ||
'col.move': MoveColHandler, | ||
this._commandStack.execute('row.add', context); | ||
'cell.edit': EditCellHandler | ||
}; | ||
} | ||
return row; | ||
} | ||
}, { | ||
key: 'removeRow', | ||
value: function removeRow(row) { | ||
this._commandStack.execute('row.remove', { row: row }); | ||
} | ||
}, { | ||
key: 'moveRow', | ||
value: function moveRow(row, index) { | ||
var context = { | ||
row: row, | ||
index: index | ||
}; | ||
_create(type, attrs) { | ||
if (attrs instanceof Base) { | ||
return attrs; | ||
} else { | ||
return this._elementFactory.create(type, attrs); | ||
this._commandStack.execute('row.move', context); | ||
} | ||
} | ||
}, { | ||
key: 'addCol', | ||
value: function addCol(attrs, index) { | ||
var col = this._create('col', attrs); | ||
var context = { | ||
col: col, | ||
index: index | ||
}; | ||
// public API | ||
this._commandStack.execute('col.add', context); | ||
addRow(attrs, index) { | ||
const row = this._create('row', attrs); | ||
return col; | ||
} | ||
}, { | ||
key: 'removeCol', | ||
value: function removeCol(col) { | ||
this._commandStack.execute('col.remove', { col: col }); | ||
} | ||
}, { | ||
key: 'moveCol', | ||
value: function moveCol(col, index) { | ||
var context = { | ||
col: col, | ||
index: index | ||
}; | ||
const context = { | ||
row, | ||
index | ||
}; | ||
this._commandStack.execute('col.move', context); | ||
} | ||
}, { | ||
key: 'editCell', | ||
value: function editCell(cell, changedAttrs) { | ||
var context = _extends({ | ||
cell: cell | ||
}, changedAttrs); | ||
this._commandStack.execute('row.add', context); | ||
this._commandStack.execute('cell.edit', context); | ||
} | ||
}], [{ | ||
key: '_getHandlers', | ||
value: function _getHandlers() { | ||
return { | ||
'row.add': AddRowHandler, | ||
'row.remove': RemoveRowHandler, | ||
'row.move': MoveRowHandler, | ||
return row; | ||
} | ||
'col.add': AddColHandler, | ||
'col.remove': RemoveColHandler, | ||
'col.move': MoveColHandler, | ||
removeRow(row) { | ||
this._commandStack.execute('row.remove', { row }); | ||
} | ||
'cell.edit': EditCellHandler | ||
}; | ||
} | ||
}]); | ||
moveRow(row, index) { | ||
const context = { | ||
row, | ||
index | ||
}; | ||
return Modeling; | ||
}(); | ||
this._commandStack.execute('row.move', context); | ||
} | ||
export default Modeling; | ||
addCol(attrs, index) { | ||
const col = this._create('col', attrs); | ||
const context = { | ||
col, | ||
index | ||
}; | ||
Modeling.$inject = ['eventBus', 'elementFactory', 'commandStack']; | ||
this._commandStack.execute('col.add', context); | ||
return col; | ||
} | ||
removeCol(col) { | ||
this._commandStack.execute('col.remove', { col }); | ||
} | ||
moveCol(col, index) { | ||
const context = { | ||
col, | ||
index | ||
}; | ||
this._commandStack.execute('col.move', context); | ||
} | ||
editCell(cell, changedAttrs) { | ||
const context = { | ||
cell, | ||
...changedAttrs | ||
}; | ||
this._commandStack.execute('cell.edit', context); | ||
} | ||
} | ||
Modeling.$inject = [ | ||
'eventBus', | ||
'elementFactory', | ||
'commandStack' | ||
]; | ||
// helpers ///////////// | ||
@@ -150,5 +166,6 @@ | ||
function registerHandlers(handlers, commandStack) { | ||
forEach(handlers, function(handler, id) { | ||
forEach(handlers, function (handler, id) { | ||
commandStack.registerHandler(id, handler); | ||
}); | ||
} | ||
//# sourceMappingURL=Modeling.js.map |
import Rules from 'diagram-js/lib/features/rules'; | ||
export default { | ||
__depends__: [ Rules ] | ||
}; | ||
__depends__: [Rules] | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -5,5 +5,6 @@ import Selection from './Selection'; | ||
export default { | ||
__init__: [ 'selection', 'selectionBehavior' ], | ||
selection: [ 'type', Selection ], | ||
selectionBehavior: [ 'type', SelectionBehavior ] | ||
}; | ||
__init__: ['selection', 'selectionBehavior'], | ||
selection: ['type', Selection], | ||
selectionBehavior: ['type', SelectionBehavior] | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -0,10 +1,17 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import { isString } from 'min-dash'; | ||
/** | ||
* Allows selecting a table cell. Selected cell will be highlighted. | ||
*/ | ||
export default class Selection { | ||
constructor(elementRegistry, eventBus, renderer) { | ||
var Selection = function () { | ||
function Selection(elementRegistry, eventBus, renderer) { | ||
var _this = this; | ||
_classCallCheck(this, Selection); | ||
this._elementRegistry = elementRegistry; | ||
@@ -16,4 +23,4 @@ this._eventBus = eventBus; | ||
eventBus.on('diagram.clear', () => { | ||
this._selection = undefined; | ||
eventBus.on('diagram.clear', function () { | ||
_this._selection = undefined; | ||
}); | ||
@@ -27,58 +34,73 @@ } | ||
*/ | ||
select(element) { | ||
if (isString(element)) { | ||
element = this._elementRegistry.get(element); | ||
} | ||
const oldSelection = this._selection; | ||
_createClass(Selection, [{ | ||
key: 'select', | ||
value: function select(element) { | ||
// don't re-select already selected *Ggg* | ||
if (oldSelection === element) { | ||
return; | ||
if (isString(element)) { | ||
element = this._elementRegistry.get(element); | ||
} | ||
var oldSelection = this._selection; | ||
// don't re-select already selected *Ggg* | ||
if (oldSelection === element) { | ||
return; | ||
} | ||
this._selection = element; | ||
this._eventBus.fire('selection.changed', { | ||
oldSelection: oldSelection, | ||
selection: element | ||
}); | ||
} | ||
this._selection = element; | ||
/** | ||
* Deselect a table cell. | ||
*/ | ||
this._eventBus.fire('selection.changed', { | ||
oldSelection, | ||
selection: element | ||
}); | ||
} | ||
}, { | ||
key: 'deselect', | ||
value: function deselect() { | ||
/** | ||
* Deselect a table cell. | ||
*/ | ||
deselect() { | ||
var oldSelection = this._selection; | ||
const oldSelection = this._selection; | ||
this._selection = undefined; | ||
this._selection = undefined; | ||
this._eventBus.fire('selection.changed', { | ||
oldSelection: oldSelection, | ||
selection: this._selection | ||
}); | ||
} | ||
this._eventBus.fire('selection.changed', { | ||
oldSelection, | ||
selection: this._selection | ||
}); | ||
/** | ||
* Get the selected cell. | ||
*/ | ||
} | ||
}, { | ||
key: 'get', | ||
value: function get() { | ||
return this._selection; | ||
} | ||
/** | ||
* Get the selected cell. | ||
*/ | ||
get() { | ||
return this._selection; | ||
} | ||
/** | ||
* Check if a cell is selected. | ||
*/ | ||
/** | ||
* Check if a cell is selected. | ||
*/ | ||
hasSelection() { | ||
return !!this._selection; | ||
} | ||
} | ||
}, { | ||
key: 'hasSelection', | ||
value: function hasSelection() { | ||
return !!this._selection; | ||
} | ||
}]); | ||
Selection.$inject = [ | ||
'elementRegistry', | ||
'eventBus', | ||
'renderer' | ||
]; | ||
return Selection; | ||
}(); | ||
export default Selection; | ||
Selection.$inject = ['elementRegistry', 'eventBus', 'renderer']; | ||
//# sourceMappingURL=Selection.js.map |
@@ -0,53 +1,58 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
* Selects table cells on on left & right click. | ||
*/ | ||
export default class SelectionBehavior { | ||
var SelectionBehavior = function SelectionBehavior(elementRegistry, eventBus, renderer, selection) { | ||
_classCallCheck(this, SelectionBehavior); | ||
constructor(elementRegistry, eventBus, renderer, selection) { | ||
this._elementRegistry = elementRegistry; | ||
this._renderer = renderer; | ||
this._selection = selection; | ||
this._elementRegistry = elementRegistry; | ||
this._renderer = renderer; | ||
this._selection = selection; | ||
eventBus.on([ 'cell.click', 'cell.contextmenu'], ({ id }) => { | ||
const element = elementRegistry.get(id); | ||
eventBus.on(['cell.click', 'cell.contextmenu'], function (_ref) { | ||
var id = _ref.id; | ||
if (!element) { | ||
return; | ||
} | ||
var element = elementRegistry.get(id); | ||
selection.select(element); | ||
}); | ||
if (!element) { | ||
return; | ||
} | ||
eventBus.on('row.remove', ({ row }) => { | ||
const currentSelection = selection.get(); | ||
selection.select(element); | ||
}); | ||
if (!currentSelection) { | ||
return; | ||
} | ||
eventBus.on('row.remove', function (_ref2) { | ||
var row = _ref2.row; | ||
if (row === currentSelection.row) { | ||
selection.deselect(); | ||
} | ||
}); | ||
var currentSelection = selection.get(); | ||
eventBus.on('col.remove', ({ col }) => { | ||
const currentSelection = selection.get(); | ||
if (!currentSelection) { | ||
return; | ||
} | ||
if (!currentSelection) { | ||
return; | ||
} | ||
if (row === currentSelection.row) { | ||
selection.deselect(); | ||
} | ||
}); | ||
if (col === currentSelection.col) { | ||
selection.deselect(); | ||
} | ||
}); | ||
} | ||
eventBus.on('col.remove', function (_ref3) { | ||
var col = _ref3.col; | ||
} | ||
var currentSelection = selection.get(); | ||
SelectionBehavior.$inject = [ | ||
'elementRegistry', | ||
'eventBus', | ||
'renderer', | ||
'selection' | ||
]; | ||
if (!currentSelection) { | ||
return; | ||
} | ||
if (col === currentSelection.col) { | ||
selection.deselect(); | ||
} | ||
}); | ||
}; | ||
export default SelectionBehavior; | ||
SelectionBehavior.$inject = ['elementRegistry', 'eventBus', 'renderer', 'selection']; | ||
//# sourceMappingURL=SelectionBehavior.js.map |
@@ -1,27 +0,30 @@ | ||
import { assign } from 'min-dash'; | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
export class Base { | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
constructor(attrs) { | ||
assign(this, attrs); | ||
import { assign } from 'min-dash'; | ||
/** | ||
* The object that backs up the shape | ||
* | ||
* @name Base#businessObject | ||
* @type Object | ||
*/ | ||
defineProperty(this, 'businessObject', { | ||
writable: true | ||
}); | ||
} | ||
export var Base = function Base(attrs) { | ||
_classCallCheck(this, Base); | ||
} | ||
assign(this, attrs); | ||
/** | ||
* The object that backs up the shape | ||
* | ||
* @name Base#businessObject | ||
* @type Object | ||
*/ | ||
defineProperty(this, 'businessObject', { | ||
writable: true | ||
}); | ||
}; | ||
export class Root extends Base { | ||
export var Root = function (_Base) { | ||
_inherits(Root, _Base); | ||
constructor(attrs) { | ||
super(attrs); | ||
function Root(attrs) { | ||
_classCallCheck(this, Root); | ||
@@ -34,5 +37,7 @@ /** | ||
*/ | ||
defineProperty(this, 'rows', { | ||
var _this = _possibleConstructorReturn(this, (Root.__proto__ || Object.getPrototypeOf(Root)).call(this, attrs)); | ||
defineProperty(_this, 'rows', { | ||
enumerable: true, | ||
value: this.rows || [] | ||
value: _this.rows || [] | ||
}); | ||
@@ -46,16 +51,18 @@ | ||
*/ | ||
defineProperty(this, 'cols', { | ||
defineProperty(_this, 'cols', { | ||
enumerable: true, | ||
value: this.cols || [] | ||
value: _this.cols || [] | ||
}); | ||
return _this; | ||
} | ||
} | ||
return Root; | ||
}(Base); | ||
export var Row = function (_Base2) { | ||
_inherits(Row, _Base2); | ||
export class Row extends Base { | ||
function Row(attrs) { | ||
_classCallCheck(this, Row); | ||
constructor(attrs) { | ||
super(attrs); | ||
/** | ||
@@ -67,3 +74,5 @@ * Reference to the table | ||
*/ | ||
defineProperty(this, 'root', { | ||
var _this2 = _possibleConstructorReturn(this, (Row.__proto__ || Object.getPrototypeOf(Row)).call(this, attrs)); | ||
defineProperty(_this2, 'root', { | ||
writable: true | ||
@@ -78,16 +87,18 @@ }); | ||
*/ | ||
defineProperty(this, 'cells', { | ||
defineProperty(_this2, 'cells', { | ||
enumerable: true, | ||
value: this.cells || [] | ||
value: _this2.cells || [] | ||
}); | ||
return _this2; | ||
} | ||
} | ||
return Row; | ||
}(Base); | ||
export var Col = function (_Base3) { | ||
_inherits(Col, _Base3); | ||
export class Col extends Base { | ||
function Col(attrs) { | ||
_classCallCheck(this, Col); | ||
constructor(attrs) { | ||
super(attrs); | ||
/** | ||
@@ -99,3 +110,5 @@ * Reference to the table | ||
*/ | ||
defineProperty(this, 'root', { | ||
var _this3 = _possibleConstructorReturn(this, (Col.__proto__ || Object.getPrototypeOf(Col)).call(this, attrs)); | ||
defineProperty(_this3, 'root', { | ||
writable: true | ||
@@ -110,14 +123,17 @@ }); | ||
*/ | ||
defineProperty(this, 'cells', { | ||
defineProperty(_this3, 'cells', { | ||
enumerable: true, | ||
value: this.cells || [] | ||
value: _this3.cells || [] | ||
}); | ||
return _this3; | ||
} | ||
} | ||
return Col; | ||
}(Base); | ||
export class Cell extends Base { | ||
export var Cell = function (_Base4) { | ||
_inherits(Cell, _Base4); | ||
constructor(attrs) { | ||
super(attrs); | ||
function Cell(attrs) { | ||
_classCallCheck(this, Cell); | ||
@@ -130,3 +146,5 @@ /** | ||
*/ | ||
defineProperty(this, 'row', { | ||
var _this4 = _possibleConstructorReturn(this, (Cell.__proto__ || Object.getPrototypeOf(Cell)).call(this, attrs)); | ||
defineProperty(_this4, 'row', { | ||
writable: true | ||
@@ -141,11 +159,12 @@ }); | ||
*/ | ||
defineProperty(this, 'col', { | ||
defineProperty(_this4, 'col', { | ||
writable: true | ||
}); | ||
return _this4; | ||
} | ||
} | ||
return Cell; | ||
}(Base); | ||
const TYPES = { | ||
var TYPES = { | ||
root: Root, | ||
@@ -157,5 +176,4 @@ row: Row, | ||
export function create(type, attrs) { | ||
const Type = TYPES[type]; | ||
var Type = TYPES[type]; | ||
@@ -169,3 +187,2 @@ if (!Type) { | ||
// helpers ///////////// | ||
@@ -175,2 +192,3 @@ | ||
Object.defineProperty(el, prop, options); | ||
} | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -1,79 +0,99 @@ | ||
export default class ChangeSupport { | ||
constructor(eventBus) { | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var ChangeSupport = function () { | ||
function ChangeSupport(eventBus) { | ||
var _this = this; | ||
_classCallCheck(this, ChangeSupport); | ||
this._listeners = {}; | ||
eventBus.on('elements.changed', ({ elements }) => { | ||
this.elementsChanged(elements); | ||
eventBus.on('elements.changed', function (_ref) { | ||
var elements = _ref.elements; | ||
_this.elementsChanged(elements); | ||
}); | ||
eventBus.on('root.remove', context => { | ||
const oldRootId = context.root.id; | ||
eventBus.on('root.remove', function (context) { | ||
var oldRootId = context.root.id; | ||
if (this._listeners[oldRootId]) { | ||
if (_this._listeners[oldRootId]) { | ||
eventBus.once('root.add', context => { | ||
const newRootId = context.root.id; | ||
eventBus.once('root.add', function (context) { | ||
var newRootId = context.root.id; | ||
this._listeners[newRootId] = this._listeners[oldRootId]; | ||
_this._listeners[newRootId] = _this._listeners[oldRootId]; | ||
delete this._listeners[oldRootId]; | ||
delete _this._listeners[oldRootId]; | ||
}); | ||
} | ||
}); | ||
} | ||
elementsChanged(elements) { | ||
const invoked = {}; | ||
_createClass(ChangeSupport, [{ | ||
key: 'elementsChanged', | ||
value: function elementsChanged(elements) { | ||
var invoked = {}; | ||
const elementsLength = elements.length; | ||
var elementsLength = elements.length; | ||
for (let i = 0; i < elementsLength; i++) { | ||
const { id } = elements[i]; | ||
for (var i = 0; i < elementsLength; i++) { | ||
var id = elements[i].id; | ||
if (invoked[id]) { | ||
return; | ||
} | ||
invoked[id] = true; | ||
if (invoked[id]) { | ||
return; | ||
} | ||
const listenersLength = this._listeners[id] && this._listeners[id].length; | ||
invoked[id] = true; | ||
if (listenersLength) { | ||
for (let j = 0; j < listenersLength; j++) { | ||
var listenersLength = this._listeners[id] && this._listeners[id].length; | ||
// listeners might remove themselves before they get called | ||
this._listeners[id][j] && this._listeners[id][j](); | ||
if (listenersLength) { | ||
for (var j = 0; j < listenersLength; j++) { | ||
// listeners might remove themselves before they get called | ||
this._listeners[id][j] && this._listeners[id][j](); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, { | ||
key: 'onElementsChanged', | ||
value: function onElementsChanged(id, listener) { | ||
if (!this._listeners[id]) { | ||
this._listeners[id] = []; | ||
} | ||
onElementsChanged(id, listener) { | ||
if (!this._listeners[id]) { | ||
this._listeners[id] = []; | ||
// avoid push for better performance | ||
this._listeners[id][this._listeners[id].length] = listener; | ||
} | ||
}, { | ||
key: 'offElementsChanged', | ||
value: function offElementsChanged(id, listener) { | ||
if (!this._listeners[id]) { | ||
return; | ||
} | ||
// avoid push for better performance | ||
this._listeners[id][this._listeners[id].length] = listener; | ||
} | ||
if (listener) { | ||
var idx = this._listeners[id].indexOf(listener); | ||
offElementsChanged(id, listener) { | ||
if (!this._listeners[id]) { | ||
return; | ||
if (idx !== -1) { | ||
this._listeners[id].splice(idx, 1); | ||
} | ||
} else { | ||
this._listeners[id].length = 0; | ||
} | ||
} | ||
}]); | ||
if (listener) { | ||
const idx = this._listeners[id].indexOf(listener); | ||
return ChangeSupport; | ||
}(); | ||
if (idx !== -1) { | ||
this._listeners[id].splice(idx, 1); | ||
} | ||
} else { | ||
this._listeners[id].length = 0; | ||
} | ||
} | ||
} | ||
export default ChangeSupport; | ||
ChangeSupport.$inject = [ 'eventBus' ]; | ||
ChangeSupport.$inject = ['eventBus']; | ||
//# sourceMappingURL=ChangeSupport.js.map |
@@ -1,122 +0,134 @@ | ||
import { | ||
isFunction, | ||
isNumber | ||
} from 'min-dash'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
const DEFAULT_PRIORITY = 1000; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import { isFunction, isNumber } from 'min-dash'; | ||
export default class Components { | ||
var DEFAULT_PRIORITY = 1000; | ||
constructor() { | ||
var Components = function () { | ||
function Components() { | ||
_classCallCheck(this, Components); | ||
this._listeners = {}; | ||
} | ||
getComponent(type, context) { | ||
const listeners = this._listeners[type]; | ||
_createClass(Components, [{ | ||
key: 'getComponent', | ||
value: function getComponent(type, context) { | ||
var listeners = this._listeners[type]; | ||
if (!listeners) { | ||
return; | ||
} | ||
if (!listeners) { | ||
return; | ||
} | ||
let component; | ||
var component = void 0; | ||
for (let i = 0; i < listeners.length; i++) { | ||
component = listeners[i].callback(context); | ||
for (var i = 0; i < listeners.length; i++) { | ||
component = listeners[i].callback(context); | ||
if (component) { | ||
break; | ||
if (component) { | ||
break; | ||
} | ||
} | ||
return component; | ||
} | ||
}, { | ||
key: 'getComponents', | ||
value: function getComponents(type, context) { | ||
var listeners = this._listeners[type]; | ||
return component; | ||
} | ||
var components = []; | ||
getComponents(type, context) { | ||
const listeners = this._listeners[type]; | ||
if (!listeners) { | ||
return components; | ||
} | ||
const components = []; | ||
for (var i = 0; i < listeners.length; i++) { | ||
var component = listeners[i].callback(context); | ||
if (!listeners) { | ||
return components; | ||
} | ||
if (component) { | ||
components.push(component); | ||
} | ||
} | ||
for (let i = 0; i < listeners.length; i++) { | ||
const component = listeners[i].callback(context); | ||
if (component) { | ||
components.push(component); | ||
if (!components.length) { | ||
return components; | ||
} | ||
} | ||
if (!components.length) { | ||
return components; | ||
} | ||
}, { | ||
key: 'onGetComponent', | ||
value: function onGetComponent(type, priority, callback) { | ||
if (isFunction(priority)) { | ||
callback = priority; | ||
priority = DEFAULT_PRIORITY; | ||
} | ||
return components; | ||
} | ||
if (!isNumber(priority)) { | ||
throw new Error('priority must be a number'); | ||
} | ||
onGetComponent(type, priority, callback) { | ||
if (isFunction(priority)) { | ||
callback = priority; | ||
priority = DEFAULT_PRIORITY; | ||
} | ||
var listeners = this._getListeners(type); | ||
if (!isNumber(priority)) { | ||
throw new Error('priority must be a number'); | ||
} | ||
var existingListener = void 0, | ||
idx = void 0; | ||
const listeners = this._getListeners(type); | ||
var newListener = { priority: priority, callback: callback }; | ||
let existingListener, | ||
idx; | ||
for (idx = 0; existingListener = listeners[idx]; idx++) { | ||
if (existingListener.priority < priority) { | ||
const newListener = { priority, callback }; | ||
// prepend newListener at before existingListener | ||
listeners.splice(idx, 0, newListener); | ||
return; | ||
} | ||
} | ||
for (idx = 0; (existingListener = listeners[idx]); idx++) { | ||
if (existingListener.priority < priority) { | ||
// prepend newListener at before existingListener | ||
listeners.splice(idx, 0, newListener); | ||
return; | ||
} | ||
listeners.push(newListener); | ||
} | ||
}, { | ||
key: 'offGetComponent', | ||
value: function offGetComponent(type, callback) { | ||
var listeners = this._getListeners(type); | ||
listeners.push(newListener); | ||
} | ||
var listener = void 0, | ||
listenerCallback = void 0, | ||
idx = void 0; | ||
offGetComponent(type, callback) { | ||
const listeners = this._getListeners(type); | ||
if (callback) { | ||
let listener, | ||
listenerCallback, | ||
idx; | ||
// move through listeners from back to front | ||
// and remove matching listeners | ||
for (idx = listeners.length - 1; listener = listeners[idx]; idx--) { | ||
listenerCallback = listener.callback; | ||
if (callback) { | ||
// move through listeners from back to front | ||
// and remove matching listeners | ||
for (idx = listeners.length - 1; (listener = listeners[idx]); idx--) { | ||
listenerCallback = listener.callback; | ||
if (listenerCallback === callback) { | ||
listeners.splice(idx, 1); | ||
if (listenerCallback === callback) { | ||
listeners.splice(idx, 1); | ||
} | ||
} | ||
} else { | ||
// clear listeners | ||
listeners.length = 0; | ||
} | ||
} else { | ||
// clear listeners | ||
listeners.length = 0; | ||
} | ||
} | ||
}, { | ||
key: '_getListeners', | ||
value: function _getListeners(type) { | ||
var listeners = this._listeners[type]; | ||
_getListeners(type) { | ||
let listeners = this._listeners[type]; | ||
if (!listeners) { | ||
this._listeners[type] = listeners = []; | ||
} | ||
if (!listeners) { | ||
this._listeners[type] = listeners = []; | ||
return listeners; | ||
} | ||
}]); | ||
return listeners; | ||
} | ||
} | ||
return Components; | ||
}(); | ||
export default Components; | ||
//# sourceMappingURL=Components.js.map |
@@ -1,70 +0,96 @@ | ||
import { Component } from 'inferno'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
import { createVNode, createComponentVNode } from 'inferno'; | ||
export default class TableComponent extends Component { | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
constructor(props) { | ||
super(props); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
const injector = this._injector = props.injector; | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
this._sheet = injector.get('sheet'); | ||
this._changeSupport = injector.get('changeSupport'); | ||
this._components = injector.get('components'); | ||
import { Component } from 'inferno'; | ||
this.onElementsChanged = this.onElementsChanged.bind(this); | ||
} | ||
var TableComponent = function (_Component) { | ||
_inherits(TableComponent, _Component); | ||
onElementsChanged() { | ||
this.forceUpdate(); | ||
} | ||
function TableComponent(props) { | ||
_classCallCheck(this, TableComponent); | ||
getChildContext() { | ||
return { | ||
changeSupport: this._changeSupport, | ||
components: this._components, | ||
injector: this._injector | ||
}; | ||
} | ||
var _this = _possibleConstructorReturn(this, (TableComponent.__proto__ || Object.getPrototypeOf(TableComponent)).call(this, props)); | ||
componentWillMount() { | ||
const { id } = this._sheet.getRoot(); | ||
var injector = _this._injector = props.injector; | ||
this._changeSupport.onElementsChanged(id, this.onElementsChanged); | ||
_this._sheet = injector.get('sheet'); | ||
_this._changeSupport = injector.get('changeSupport'); | ||
_this._components = injector.get('components'); | ||
_this.onElementsChanged = _this.onElementsChanged.bind(_this); | ||
return _this; | ||
} | ||
componentWillUnmount() { | ||
const { id } = this._sheet.getRoot(); | ||
_createClass(TableComponent, [{ | ||
key: 'onElementsChanged', | ||
value: function onElementsChanged() { | ||
this.forceUpdate(); | ||
} | ||
}, { | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return { | ||
changeSupport: this._changeSupport, | ||
components: this._components, | ||
injector: this._injector | ||
}; | ||
} | ||
}, { | ||
key: 'componentWillMount', | ||
value: function componentWillMount() { | ||
var _sheet$getRoot = this._sheet.getRoot(), | ||
id = _sheet$getRoot.id; | ||
this._changeSupport.offElementsChanged(id, this.onElementsChanged); | ||
} | ||
this._changeSupport.onElementsChanged(id, this.onElementsChanged); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
var _sheet$getRoot2 = this._sheet.getRoot(), | ||
id = _sheet$getRoot2.id; | ||
render() { | ||
const { rows, cols } = this._sheet.getRoot(); | ||
this._changeSupport.offElementsChanged(id, this.onElementsChanged); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _sheet$getRoot3 = this._sheet.getRoot(), | ||
rows = _sheet$getRoot3.rows, | ||
cols = _sheet$getRoot3.cols; | ||
const beforeTableComponents = this._components.getComponents('table.before'); | ||
const afterTableComponents = this._components.getComponents('table.after'); | ||
var beforeTableComponents = this._components.getComponents('table.before'); | ||
var afterTableComponents = this._components.getComponents('table.after'); | ||
const Head = this._components.getComponent('table.head'); | ||
const Body = this._components.getComponent('table.body'); | ||
const Foot = this._components.getComponent('table.foot'); | ||
var Head = this._components.getComponent('table.head'); | ||
var Body = this._components.getComponent('table.body'); | ||
var Foot = this._components.getComponent('table.foot'); | ||
return ( | ||
<div className="tjs-container"> | ||
{ | ||
beforeTableComponents && | ||
beforeTableComponents.map((Component, index) => <Component key={ index } />) | ||
} | ||
<table className="tjs-table"> | ||
{ Head && <Head rows={ rows } cols={ cols } /> } | ||
{ Body && <Body rows={ rows } cols={ cols } /> } | ||
{ Foot && <Foot rows={ rows } cols={ cols } /> } | ||
</table> | ||
{ | ||
afterTableComponents && | ||
afterTableComponents.map((Component, index) => <Component key={ index } />) | ||
} | ||
</div> | ||
); | ||
} | ||
} | ||
return createVNode(1, 'div', 'tjs-container', [beforeTableComponents && beforeTableComponents.map(function (Component, index) { | ||
return createComponentVNode(2, Component, null, index); | ||
}), createVNode(1, 'table', 'tjs-table', [Head && createComponentVNode(2, Head, { | ||
'rows': rows, | ||
'cols': cols | ||
}), Body && createComponentVNode(2, Body, { | ||
'rows': rows, | ||
'cols': cols | ||
}), Foot && createComponentVNode(2, Foot, { | ||
'rows': rows, | ||
'cols': cols | ||
})], 0), afterTableComponents && afterTableComponents.map(function (Component, index) { | ||
return createComponentVNode(2, Component, null, index); | ||
})], 0); | ||
} | ||
}]); | ||
return TableComponent; | ||
}(Component); | ||
export default TableComponent; | ||
//# sourceMappingURL=TableComponent.js.map |
@@ -6,6 +6,7 @@ import ChangeSupport from './ChangeSupport'; | ||
export default { | ||
__init__: [ 'changeSupport', 'components', 'renderer' ], | ||
changeSupport: [ 'type', ChangeSupport ], | ||
components: [ 'type', Components ], | ||
renderer: [ 'type', Renderer ] | ||
}; | ||
__init__: ['changeSupport', 'components', 'renderer'], | ||
changeSupport: ['type', ChangeSupport], | ||
components: ['type', Components], | ||
renderer: ['type', Renderer] | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -0,1 +1,7 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
import { createComponentVNode } from 'inferno'; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import { render } from 'inferno'; | ||
@@ -5,14 +11,18 @@ | ||
export default class Renderer { | ||
var Renderer = function () { | ||
function Renderer(changeSupport, components, config, eventBus, injector) { | ||
_classCallCheck(this, Renderer); | ||
constructor(changeSupport, components, config, eventBus, injector) { | ||
const { container } = config; | ||
var container = config.container; | ||
this._container = container; | ||
eventBus.on('root.added', () => { | ||
render(<TableComponent injector={ injector } />, container); | ||
eventBus.on('root.added', function () { | ||
render(createComponentVNode(2, TableComponent, { | ||
'injector': injector | ||
}), container); | ||
}); | ||
eventBus.on('root.remove', () => { | ||
eventBus.on('root.remove', function () { | ||
render(null, container); | ||
@@ -22,14 +32,16 @@ }); | ||
getContainer() { | ||
return this._container; | ||
} | ||
_createClass(Renderer, [{ | ||
key: 'getContainer', | ||
value: function getContainer() { | ||
return this._container; | ||
} | ||
}]); | ||
} | ||
return Renderer; | ||
}(); | ||
Renderer.$inject = [ | ||
'changeSupport', | ||
'components', | ||
'config.renderer', | ||
'eventBus', | ||
'injector' | ||
]; | ||
export default Renderer; | ||
Renderer.$inject = ['changeSupport', 'components', 'config.renderer', 'eventBus', 'injector']; | ||
//# sourceMappingURL=Renderer.js.map |
@@ -0,1 +1,7 @@ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import { Injector } from 'didi'; | ||
@@ -5,12 +11,15 @@ | ||
var Table = function () { | ||
function Table() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
export default class Table { | ||
_classCallCheck(this, Table); | ||
constructor(options = {}) { | ||
let { | ||
injector | ||
} = options; | ||
var injector = options.injector; | ||
if (!injector) { | ||
let { modules, config } = this._init(options); | ||
var _init2 = this._init(options), | ||
modules = _init2.modules, | ||
config = _init2.config; | ||
@@ -35,36 +44,46 @@ injector = createInjector(config, modules); | ||
*/ | ||
_init(options) { | ||
let { | ||
modules, | ||
...config | ||
} = options; | ||
return { modules, config }; | ||
} | ||
/** | ||
* Destroys the table. This results in removing the attachment from the container. | ||
*/ | ||
destroy() { | ||
const eventBus = this.get('eventBus'); | ||
_createClass(Table, [{ | ||
key: '_init', | ||
value: function _init(options) { | ||
var modules = options.modules, | ||
config = _objectWithoutProperties(options, ['modules']); | ||
eventBus.fire('table.destroy'); | ||
eventBus.fire('diagram.destroy'); | ||
} | ||
return { modules: modules, config: config }; | ||
} | ||
/** | ||
* Clears the table. Should be used to reset the state of any stateful services. | ||
*/ | ||
clear() { | ||
const eventBus = this.get('eventBus'); | ||
/** | ||
* Destroys the table. This results in removing the attachment from the container. | ||
*/ | ||
eventBus.fire('table.clear'); | ||
eventBus.fire('diagram.clear'); | ||
} | ||
}, { | ||
key: 'destroy', | ||
value: function destroy() { | ||
var eventBus = this.get('eventBus'); | ||
} | ||
eventBus.fire('table.destroy'); | ||
eventBus.fire('diagram.destroy'); | ||
} | ||
/** | ||
* Clears the table. Should be used to reset the state of any stateful services. | ||
*/ | ||
}, { | ||
key: 'clear', | ||
value: function clear() { | ||
var eventBus = this.get('eventBus'); | ||
eventBus.fire('table.clear'); | ||
eventBus.fire('diagram.clear'); | ||
} | ||
}]); | ||
return Table; | ||
}(); | ||
// helpers ///////////// | ||
export default Table; | ||
function bootstrap(bootstrapModules) { | ||
@@ -96,3 +115,3 @@ | ||
(m.__init__ || []).forEach(function(c) { | ||
(m.__init__ || []).forEach(function (c) { | ||
components.push(c); | ||
@@ -106,3 +125,3 @@ }); | ||
components.forEach(function(c) { | ||
components.forEach(function (c) { | ||
@@ -124,10 +143,8 @@ try { | ||
function createInjector(config, modules) { | ||
const bootstrapModules = [ | ||
{ | ||
config: [ 'value', config ] | ||
}, | ||
core | ||
].concat(modules || []); | ||
var bootstrapModules = [{ | ||
config: ['value', config] | ||
}, core].concat(modules || []); | ||
return bootstrap(bootstrapModules); | ||
} | ||
//# sourceMappingURL=Table.js.map |
{ | ||
"name": "table-js", | ||
"version": "4.3.3", | ||
"version": "5.0.0-0", | ||
"scripts": { | ||
"all": "npm run lint && npm run test", | ||
"all": "run-s lint test build", | ||
"dev": "karma start --no-single-run --auto-watch --log-level debug", | ||
"lint": "eslint .", | ||
"test": "karma start" | ||
"test": "karma start", | ||
"build": "del lib && babel -s -q -d lib src", | ||
"prepublishOnly": "run-s build" | ||
}, | ||
@@ -15,6 +17,8 @@ "repository": { | ||
"sideEffects": false, | ||
"module": "lib/Table.js", | ||
"main": "./lib/index.js", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.0", | ||
"babel-loader": "^7.1.4", | ||
"babel-plugin-inferno": "^5.0.1", | ||
@@ -24,5 +28,4 @@ "babel-plugin-transform-class-properties": "^6.24.1", | ||
"babel-preset-env": "^1.6.1", | ||
"babelify": "^7.3.0", | ||
"browserify": "^16.1.1", | ||
"chai": "~3.5.0", | ||
"del-cli": "^1.1.0", | ||
"diagram-js": "^2.1.1", | ||
@@ -32,5 +35,5 @@ "eslint": "^4.8.0", | ||
"eslint-plugin-inferno": "^7.4.0", | ||
"inferno": "^5.0.5", | ||
"inferno-test-utils": "^5.0.5", | ||
"karma": "^1.7.1", | ||
"karma-browserify": "^5.2.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
@@ -44,8 +47,11 @@ "karma-firefox-launcher": "^1.0.0", | ||
"karma-spec-reporter": "0.0.26", | ||
"karma-webpack": "^3.0.0", | ||
"mocha": "^4.0.0", | ||
"mocha-test-container-support": "^0.2.0", | ||
"npm-run-all": "^4.1.3", | ||
"puppeteer": "^0.11.0", | ||
"raw-loader": "^0.5.1", | ||
"sinon": "^2.4.1", | ||
"sinon-chai": "^2.14.0", | ||
"watchify": "^3.9.0" | ||
"webpack": "^4.12.1" | ||
}, | ||
@@ -55,3 +61,2 @@ "dependencies": { | ||
"ids": "^0.2.0", | ||
"inferno": "^5.0.5", | ||
"min-dash": "^3.0.0", | ||
@@ -62,9 +67,10 @@ "min-dom": "^3.0.0", | ||
"peerDependencies": { | ||
"diagram-js": ">=0.28 <3" | ||
"diagram-js": ">=0.28 <3", | ||
"inferno": "^5.0.5" | ||
}, | ||
"browserify": { | ||
"transform": [ | ||
"babelify" | ||
"babel": { | ||
"presets": [ | ||
"env" | ||
] | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
> This library exposes ES modules. Use an ES module aware transpiler such as Webpack, Rollup or Browserify + babelify to bundle it for the browser. | ||
# table-js | ||
@@ -2,0 +4,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
218017
98
2427
36
33
2
1
- Removedinferno@^5.0.5