@flourish/controls
Advanced tools
Comparing version 0.3.1 to 0.4.0-prerelease.1
{ | ||
"name": "@flourish/controls", | ||
"version": "0.3.1", | ||
"version": "0.4.0-prerelease.1", | ||
"description": "Switchable dropdown/buttons/slider control", | ||
@@ -5,0 +5,0 @@ "main": "controls.js", |
@@ -60,6 +60,8 @@ import { select } from "d3-selection"; | ||
output_obj.index = function(index) { | ||
if (index === undefined) return props.index; | ||
if (!Number.isFinite(index)) throw TypeError("index must be a number greater than or equal to 0."); | ||
if (index < 0) throw RangeError("index must be greater than or equal to 0."); | ||
props.index = Math.floor(index); | ||
if (index === undefined) return props.n_options ? props.index : null; | ||
if (index !== null) { | ||
if (!Number.isFinite(index)) throw TypeError("index must be a number greater than or equal to 0."); | ||
if (index < 0) throw RangeError("index must be greater than or equal to 0."); | ||
props.index = Math.floor(index); | ||
} | ||
return output_obj; | ||
@@ -83,3 +85,3 @@ }; | ||
Object.defineProperty(props, "value", { | ||
get: function() { return props.options[props.index]; }, | ||
get: function() { return props.n_options ? props.options[props.index] : null; }, | ||
set: function() { console.warn("Nothing changed: value is read only"); } | ||
@@ -90,5 +92,7 @@ }); | ||
if (value === undefined) return props.value; | ||
var index = props.options.indexOf(value); | ||
if (index !== -1) props.index = index; | ||
else console.warn("Nothing changed: value not in options list"); | ||
if (value !== null) { | ||
var index = props.options.indexOf(value); | ||
if (index !== -1) props.index = index; | ||
else console.warn("Nothing changed: value not in options list"); | ||
} | ||
return output_obj; | ||
@@ -95,0 +99,0 @@ }; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
131292
3986