@flourish/controls
Advanced tools
Comparing version 5.0.3 to 6.0.0
{ | ||
"name": "@flourish/controls", | ||
"version": "5.0.3", | ||
"version": "6.0.0", | ||
"description": "Switchable dropdown/buttons/slider control", | ||
@@ -5,0 +5,0 @@ "main": "controls.js", |
@@ -58,23 +58,2 @@ # Flourish controls | ||
You can also pass in optional functions for getting parsing and formatting functions. The former is required if you want to use user input and the user is using "," as the decimal separator. The latter is required if you want to format numbers to use "," as a decimal separator. For example: | ||
``` js | ||
import initLocalization from "@flourish/number-localization"; | ||
import initFormatter from "@flourish/number-formatter"; | ||
import state from "../core/state"; | ||
localization = initLocalization(state.localization); | ||
formatter = initFormatter(state.formatting); | ||
function getParser() { | ||
return localization.getParser(); | ||
} | ||
function getFormatter() { | ||
return formatter(localization.getFormatterFunction()); | ||
} | ||
var buttons_control = init(state.buttons_control, getParser, getFormatter); | ||
``` | ||
Add an on change handler to each controls instance: `buttons_control.on("change", update);`. This is usually done in the `draw` function. | ||
@@ -106,2 +85,10 @@ | ||
### `format(formatterFunction)` | ||
Specify an output formatter to format the contents of the control. This takes a function from the `@flourish/formatters` module. | ||
### `getNode()` | ||
Returns the container of the control that has been created. It will have a class of `"fl-controls-container"` | ||
### `getSortedIndex()` | ||
@@ -127,2 +114,6 @@ | ||
### `parse(parserFunction)` | ||
Specify a function to parse the contents of the control. This takes a function from the `@flourish/localization` or `@flourish/interpreter` module. | ||
### `remove()` | ||
@@ -144,5 +135,5 @@ | ||
### getNode() | ||
### `visible([boolean])` | ||
Returns the container of the control that has been created. It will have a class of `"fl-controls-container"` | ||
Set the visibility of the control | ||
@@ -149,0 +140,0 @@ |
@@ -1,3 +0,5 @@ | ||
# 5.0.3 | ||
* Fix play button disappearing in slider | ||
# 6.0.0 | ||
* Add .visible() method | ||
* Rename .formatter() to .format() [BREAKING] | ||
* Rename .parser() to .parse() [BREAKING] | ||
@@ -4,0 +6,0 @@ # 5.0.2 |
@@ -20,3 +20,3 @@ import { select, event as d3_event } from "d3-selection"; | ||
button_obj.update = function(sorted_options) { | ||
button_obj.update = function(sorted_options, visible) { | ||
if (!control_obj.n_options || state.control_type !== "buttons") { | ||
@@ -60,4 +60,2 @@ hideControl(); | ||
showControl(); | ||
buttons.merge(buttons_enter) | ||
@@ -69,3 +67,4 @@ .classed("selected", function(d) { return d.options_index === index; }) | ||
showControl(); | ||
if (visible) showControl(); | ||
else hideControl(); | ||
}; | ||
@@ -72,0 +71,0 @@ |
@@ -46,3 +46,3 @@ import { select } from "d3-selection"; | ||
dropdown_obj.update = function(sorted_options) { | ||
dropdown_obj.update = function(sorted_options, visible) { | ||
var dropdown_font_size = window.getComputedStyle(dropdown.node()).fontSize; | ||
@@ -73,3 +73,4 @@ if (!control_obj.n_options || state.control_type !== "dropdown") { | ||
showControl(longest_text_width); | ||
if (visible) showControl(longest_text_width); | ||
else hideControl(); | ||
@@ -76,0 +77,0 @@ return dropdown_obj; |
@@ -95,3 +95,3 @@ import { select } from "d3-selection"; | ||
var holder_width = slider_holder.node().getBoundingClientRect().width; | ||
var button_width = state.slider_play_button ? handle_radius * 2 : 0; | ||
var button_width = slider_play_button.node().getBoundingClientRect().width; | ||
slider_div | ||
@@ -147,3 +147,3 @@ .style("width", Math.max((holder_width - button_width), 1) + "px") | ||
slider_obj.update = function(_sorted_options) { | ||
slider_obj.update = function(_sorted_options, visible) { | ||
sorted_options = _sorted_options; | ||
@@ -155,3 +155,4 @@ if (!control_obj.n_options || state.control_type !== "slider") { | ||
showControl(); | ||
if (visible) showControl(); | ||
else hideControl(); | ||
@@ -158,0 +159,0 @@ var n_options = control_obj.n_options; |
@@ -57,2 +57,3 @@ import { select } from "d3-selection"; | ||
var formatter = defaultFormatter; | ||
var visible = true; | ||
var options = []; | ||
@@ -83,5 +84,5 @@ var sorted_options = []; | ||
container_title.node().style.display = (state.control_title === "") ? "none" : "inline-block"; | ||
slider_obj.update(sorted_options); // Do slider first in case we're stopping playing | ||
dropdown_obj.update(sorted_options); | ||
buttons_obj.update(sorted_options); | ||
slider_obj.update(sorted_options, visible); // Do slider first in case we're stopping playing | ||
dropdown_obj.update(sorted_options, visible); | ||
buttons_obj.update(sorted_options, visible); | ||
}; | ||
@@ -162,3 +163,3 @@ | ||
control_obj.parser = function (value) { | ||
control_obj.parse = function (value) { | ||
if (value === undefined) return parser; | ||
@@ -170,3 +171,3 @@ if (value === null) parser = defaultParser; | ||
control_obj.formatter = function (value) { | ||
control_obj.format = function (value) { | ||
if (value === undefined) return formatter; | ||
@@ -178,2 +179,9 @@ if (value === null) formatter = defaultFormatter; | ||
control_obj.visible = function (value) { | ||
if (value === undefined) return visible; | ||
if (value === null) visible = true; | ||
else visible = value; | ||
return control_obj; | ||
}; | ||
control_obj.update = function() { | ||
@@ -180,0 +188,0 @@ getRemToPx(); |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
5369
0
206418
27
142