Skip to content

Commit

Permalink
Merge branch 'release/2.0.0-rc.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
BigFatDog committed Mar 25, 2018
2 parents a1f4233 + a17164b commit 96ae83e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vizart-core",
"version": "2.0.0-rc.3",
"version": "2.0.0-rc.4",
"description": "Core Components for VizArt",
"main": "dist/vizart-core.js",
"module": "dist/vizart-core.mjs",
Expand Down
4 changes: 2 additions & 2 deletions src/api/options.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { mergeOptions } from '../options';
import merge from '../options/merge';

const apiOptions = state => ({
options(opt) {
state._options = mergeOptions(state._options, opt);
state._options = merge(state._options, opt);
return state._options;
},
});
Expand Down
15 changes: 14 additions & 1 deletion src/api/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,29 @@ import { dispatch } from 'd3-dispatch';
import uuid from '../util/uuid';
import isMobile from '../util/isMobile';
import assignContainerBound from '../util/measureContainer';
import mergeBase from '../options/mergeBase';

const StandardDispatchers = {
Rendered: 'rendered',
};

const initOpt = (userOpt, composer) => {
const { opt } = composer;

if (typeof opt === 'function') {
return opt(userOpt);
} else if (Array.isArray(opt)){
return mergeBase(...opt, userOpt);
} else {
return mergeBase(opt, userOpt);
}
}

const initState = (containerId, opt, composers) => ({
_isMobileSize: isMobile(),
_id: uuid(),
_listeners: dispatch(Object.values(StandardDispatchers)),
_options: assignContainerBound(containerId, composers.opt(opt)),
_options: assignContainerBound(containerId, initOpt(opt, composers)),
_data: [],
_color: null,
_container: null,
Expand Down
4 changes: 1 addition & 3 deletions src/options/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export { default as mergeBase } from './mergeBase';
export { default as mergeOptions } from './mergeOptions';
export { default as BaseOptions } from './BaseOptions';
export { default as mergeOptions } from './mergeBase';
export { default as DefaultSequentialColor } from './DefaultSequentialColor';
export { default as DefaultCategoricalColor } from './DefaultCategoricalColor';
4 changes: 2 additions & 2 deletions src/options/mergeOptions.js → src/options/merge.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import mergeWith from 'lodash-es/mergeWith';
import MergeCustomizer from './MergeCustomizer';

const mergeOptions = (target, source) => {
const merge = (target, source) => {
if (source === undefined || source === null) return target;

mergeWith(target, source, MergeCustomizer);

return target;
};

export default mergeOptions;
export default merge;
8 changes: 4 additions & 4 deletions src/options/mergeBase.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import BaseOptions from './BaseOptions';
import mergeOptions from './mergeOptions';
import merge from './merge';

const mergeBase = (...opts) => {
const mergeOptions = (...opts) => {
const base = Object.assign({}, BaseOptions);

for (let o of opts) {
mergeOptions(base, o);
merge(base, o);
}

return base;
};

export default mergeBase;
export default mergeOptions;

0 comments on commit 96ae83e

Please sign in to comment.