Comparing version 0.14.0 to 0.14.1
130
lib/rule.js
@@ -49,27 +49,99 @@ "use strict"; | ||
}, | ||
(0, _formula.IF)(config.hasOwnProperty("renderFunction"), function () { | ||
return config.renderFunction(config, f, depth, renderRule); | ||
}, function () { | ||
_react2.default.createElement( | ||
"span", | ||
null, | ||
_react2.default.createElement( | ||
"span", | ||
{ className: "xander-rules-function-begin" }, | ||
config.renderFunctionBegin(config, f, depth) | ||
), | ||
_react2.default.createElement( | ||
"div", | ||
{ className: "xander-rules-args" }, | ||
f.args.map(function (d) { | ||
return config.renderRule(config, d, depth + 1); | ||
}) | ||
), | ||
_react2.default.createElement( | ||
"span", | ||
{ className: "xander-rules-function-end " }, | ||
config.renderFunctionEnd(config, f, depth) | ||
) | ||
) | ||
); | ||
} | ||
function renderOperator(config, o, depth) { | ||
var subtype = o.subtype, | ||
operands = o.operands; | ||
return _react2.default.createElement( | ||
"div", | ||
{ | ||
style: (config.renderOperatorStyle || function () {})(o, depth), | ||
className: "xander-rules-section xander-rules-operator" | ||
}, | ||
(0, _formula.IF)(operands.length === 1, function () { | ||
return _react2.default.createElement( | ||
"span", | ||
null, | ||
"div", | ||
{ | ||
style: (config.renderOperatorStyle || function () {})(o, depth), | ||
className: "xander-rules-operator" | ||
}, | ||
_react2.default.createElement( | ||
"span", | ||
{ className: "xander-rules-function-begin" }, | ||
"config.renderFunctionBegin(config, f, depth)," | ||
{ | ||
style: (config.renderPrefixStyle || function () {})(o, depth), | ||
className: "xander-rules-operator-" + subtype | ||
}, | ||
(0, _formula.IF)(subtype == "prefix-minus", config.labelPrefixMINUS || "-", subtype == "prefix-plus", config.labelPrefixPLUS || "+") | ||
), | ||
_react2.default.createElement( | ||
"div", | ||
{ className: "xander-rules-args" }, | ||
f.args.map(function (d) { | ||
return renderRule(config, d, depth + 1); | ||
}) | ||
"span", | ||
{ | ||
className: "xander-rules-rhs", | ||
style: (config.renderRHSStyle || function () {})(o, depth) | ||
}, | ||
config.renderRule(config, operands[0], depth + 1) | ||
) | ||
); | ||
}, operands.length === 2, function () { | ||
return _react2.default.createElement( | ||
"div", | ||
{ | ||
style: (config.renderOperatorStyle || function () {})(o, depth), | ||
className: "xander-rules-operator" | ||
}, | ||
_react2.default.createElement( | ||
"span", | ||
{ | ||
style: (config.renderLHSStyle || function () {})(o, depth), | ||
className: "xander-rules-lhs" | ||
}, | ||
renderRule(config, operands[0], depth + 1) | ||
), | ||
" ", | ||
_react2.default.createElement( | ||
"span", | ||
{ className: "xander-rules-function-end " }, | ||
config.renderFunctionEnd(config, f, depth) | ||
{ | ||
style: (config.rendeInfixStyle || function () {})(o, depth), | ||
className: "xander-rules-operator-" + subtype | ||
}, | ||
(0, _formula.IF)(subtype == "infix-eq", config.labelEQ || "=", subtype == "infix-ne", config.labelNE || "<>", subtype == "infix-gt", config.labelGT || "<", subtype == "infix-gte", config.labelGTE || "<=", subtype == "infix-lt", config.labelLE || ">", subtype == "infix-lte", config.labelLTE || ">=", subtype == "infix-add", config.labelADD || "+", subtype == "infix-subtract", config.labelSUB || "-", subtype == "infix-multiply", config.labelMUL || "*", subtype == "infix-divide", config.labelDIV || "/", subtype == "infix-power", config.labelMUL || "^", subtype == "infix-concat", config.labelMUL || "&", config.labelDefault || "huh?") | ||
), | ||
" ", | ||
_react2.default.createElement( | ||
"span", | ||
{ | ||
style: (config.renderRHSStyle || function () {})(o, depth), | ||
className: "xander-rules-rhs" | ||
}, | ||
renderRule(config, operands[1], depth + 1) | ||
) | ||
); | ||
}) | ||
}, _react2.default.createElement( | ||
"div", | ||
null, | ||
"unexpected number of operands!" | ||
)) | ||
); | ||
@@ -93,3 +165,9 @@ } | ||
}, | ||
(0, _formula.IF)(subtype === "string", config.renderString(value), subtype === "number", config.renderNumber(value), subtype === "boolean", config.renderBoolean(value), subtype === "array", function () { | ||
(0, _formula.IF)(subtype === "string", function () { | ||
return config.renderString(value); | ||
}, subtype === "number", function () { | ||
return config.renderNumber(value); | ||
}, subtype === "boolean", function () { | ||
return config.renderBoolean(value); | ||
}, subtype === "array", function () { | ||
return _react2.default.createElement( | ||
@@ -106,3 +184,3 @@ "span", | ||
}, | ||
renderRule(d, depth + 1) | ||
config.renderRule(config, d, depth + 1) | ||
); | ||
@@ -112,3 +190,3 @@ }), | ||
); | ||
}, "error: unknown operand") | ||
}, "Other") | ||
); | ||
@@ -126,3 +204,3 @@ } | ||
"(", | ||
renderRule(g.exp, depth + 1), | ||
config.renderRule(g.exp, depth + 1), | ||
")" | ||
@@ -161,13 +239,3 @@ ); | ||
}, | ||
(0, _formula.IF)(config.hasOwnProperty("renderVariable"), function () { | ||
return config.renderVariable(v, depth); | ||
}, function () { | ||
return _react2.default.createElement( | ||
"span", | ||
null, | ||
scope, | ||
scope ? "" : null, | ||
name | ||
); | ||
}) | ||
_formula.WALKERCONFIGDEFAULT.renderVariable(config, v, depth) | ||
); | ||
@@ -192,3 +260,5 @@ } | ||
var newConfig = (0, _formula.ASSIGN)(_formula.WALKERCONFIGDEFAULT, { | ||
visit: function visit() {}, | ||
renderRule: renderRule, | ||
renderOperator: renderOperator, | ||
renderVariable: renderVariable, | ||
@@ -195,0 +265,0 @@ renderRange: renderRange, |
{ | ||
"name": "xander", | ||
"version": "0.14.0", | ||
"version": "0.14.1", | ||
"description": "Single page app framework", | ||
@@ -32,3 +32,3 @@ "repository": "git+https://github.com/FormBucket/xander.git", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"peerDependencies" : { | ||
"react": "^15.6.2 || ^16.0.0" | ||
@@ -38,4 +38,4 @@ }, | ||
"fluxury": "^3.1.0", | ||
"formula": "^3.4.2" | ||
"formula": "^3.5.0" | ||
} | ||
} |
54822
1232
Updatedformula@^3.5.0