@hig/slider
Advanced tools
Comparing version 0.2.0-alpha.2eb35b95 to 0.2.0-alpha.48c93906
@@ -1,5 +0,526 @@ | ||
import { Range } from 'hig-react'; | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import cx from 'classnames'; | ||
Range.displayName = "Slider"; | ||
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; }; | ||
export default Range; | ||
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"); } } | ||
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; } | ||
var Input = function (_Component) { | ||
_inherits(Input, _Component); | ||
function Input() { | ||
_classCallCheck(this, Input); | ||
return _possibleConstructorReturn(this, (Input.__proto__ || Object.getPrototypeOf(Input)).apply(this, arguments)); | ||
} | ||
_createClass(Input, [{ | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
min = _props.min, | ||
max = _props.max, | ||
value = _props.value; | ||
return React.createElement("input", _extends({ | ||
className: "hig__slider__input", | ||
type: "range", | ||
"aria-valuemin": min, | ||
"aria-valuemax": max, | ||
"aria-valuenow": value | ||
}, this.props)); | ||
} | ||
}]); | ||
return Input; | ||
}(Component); | ||
Input.propTypes = { | ||
/** | ||
* Prevents user actions on the field | ||
*/ | ||
disabled: PropTypes.bool, | ||
/** | ||
* HTML ID attribute | ||
*/ | ||
id: PropTypes.string, | ||
/** | ||
* Minimum value of the slider | ||
*/ | ||
min: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Maximum value of the slider | ||
*/ | ||
max: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Name of the field when submitted with a form | ||
*/ | ||
name: PropTypes.string, | ||
/** | ||
* Called when user moves focus from the field | ||
*/ | ||
onBlur: PropTypes.func, | ||
/** | ||
* Called after user changes the value of the field | ||
*/ | ||
onChange: PropTypes.func, | ||
/** | ||
* Called when user puts focus onto the field | ||
*/ | ||
onFocus: PropTypes.func, | ||
/** | ||
* Called as user changes the value of the field | ||
*/ | ||
onInput: PropTypes.func, | ||
/** | ||
* The granularity of each step on the slider | ||
*/ | ||
step: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Value of the field | ||
*/ | ||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]) | ||
}; | ||
Input.__docgenInfo = { | ||
"description": "", | ||
"displayName": "Input", | ||
"props": { | ||
"disabled": { | ||
"type": { | ||
"name": "bool" | ||
}, | ||
"required": false, | ||
"description": "Prevents user actions on the field" | ||
}, | ||
"id": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "HTML ID attribute" | ||
}, | ||
"min": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Minimum value of the slider" | ||
}, | ||
"max": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Maximum value of the slider" | ||
}, | ||
"name": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "Name of the field when submitted with a form" | ||
}, | ||
"onBlur": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called when user moves focus from the field" | ||
}, | ||
"onChange": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called after user changes the value of the field" | ||
}, | ||
"onFocus": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called when user puts focus onto the field" | ||
}, | ||
"onInput": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called as user changes the value of the field" | ||
}, | ||
"step": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "The granularity of each step on the slider" | ||
}, | ||
"value": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Value of the field" | ||
} | ||
} | ||
}; | ||
var _createClass$1 = 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$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn$1(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$1(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; } | ||
function generatedId() { | ||
return "slider-" + Math.floor(Math.random() * 100000, 5); | ||
} | ||
var Slider = function (_Component) { | ||
_inherits$1(Slider, _Component); | ||
function Slider() { | ||
var _ref; | ||
var _temp, _this, _ret; | ||
_classCallCheck$1(this, Slider); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn$1(this, (_ref = Slider.__proto__ || Object.getPrototypeOf(Slider)).call.apply(_ref, [this].concat(args))), _this), _this.state = { | ||
value: _this.props.defaultValue || _this.props.value | ||
}, _this.handleChange = function (event) { | ||
_this.setState({ value: event.target.value }); | ||
if (_this.props.onChange) _this.props.onChange(event); | ||
}, _temp), _possibleConstructorReturn$1(_this, _ret); | ||
} | ||
_createClass$1(Slider, [{ | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
id = _props.id, | ||
name = _props.name, | ||
label = _props.label, | ||
instructions = _props.instructions, | ||
required = _props.required, | ||
disabled = _props.disabled, | ||
min = _props.min, | ||
max = _props.max, | ||
step = _props.step, | ||
onBlur = _props.onBlur, | ||
onFocus = _props.onFocus, | ||
onInput = _props.onInput; | ||
var value = this.state.value; | ||
return React.createElement( | ||
"div", | ||
{ | ||
className: cx("hig__slider", { | ||
"hig__slider--disabled": disabled, | ||
"hig__slider--required": required | ||
}) | ||
}, | ||
React.createElement( | ||
"div", | ||
{ | ||
className: "hig__slider__wrapper", | ||
"data-range-min": min, | ||
"data-range-max": max | ||
}, | ||
React.createElement( | ||
"span", | ||
{ className: "hig__slider__current-value" }, | ||
value | ||
), | ||
React.createElement(Input, { | ||
id: id, | ||
onChange: this.handleChange, | ||
disabled: disabled, | ||
name: name, | ||
min: min, | ||
max: max, | ||
step: step, | ||
value: value, | ||
onBlur: onBlur, | ||
onFocus: onFocus, | ||
onInput: onInput | ||
}), | ||
label && React.createElement( | ||
"label", | ||
{ htmlFor: id, className: "hig__slider__label" }, | ||
label | ||
) | ||
), | ||
instructions && React.createElement( | ||
"p", | ||
{ className: "hig__slider__instructions" }, | ||
instructions | ||
), | ||
required && React.createElement( | ||
"p", | ||
{ className: "hig__slider__required-notice" }, | ||
required | ||
) | ||
); | ||
} | ||
}]); | ||
return Slider; | ||
}(Component); | ||
Slider.propTypes = { | ||
/** | ||
* Initial value of the field. User action will override | ||
*/ | ||
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Prevents user actions on the field | ||
*/ | ||
disabled: PropTypes.bool, | ||
/** | ||
* HTML ID attribute | ||
*/ | ||
id: PropTypes.string, | ||
/** | ||
* Instructional text for the field | ||
*/ | ||
instructions: PropTypes.string, | ||
/** | ||
* Text describing what the field represents | ||
*/ | ||
label: PropTypes.string, | ||
/** | ||
* Minimum value of the slider | ||
*/ | ||
min: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Maximum value of the slider | ||
*/ | ||
max: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Name of the field when submitted with a form | ||
*/ | ||
name: PropTypes.string, | ||
/** | ||
* Called when user moves focus from the field | ||
*/ | ||
onBlur: PropTypes.func, | ||
/** | ||
* Called after user changes the value of the field | ||
*/ | ||
onChange: PropTypes.func, | ||
/** | ||
* Called when user puts focus onto the field | ||
*/ | ||
onFocus: PropTypes.func, | ||
/** | ||
* Called as user changes the value of the field | ||
*/ | ||
onInput: PropTypes.func, | ||
/** | ||
* Text describing why the field is required | ||
*/ | ||
required: PropTypes.string, | ||
/** | ||
* The granularity of each step on the slider | ||
*/ | ||
step: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Value of the field | ||
*/ | ||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]) | ||
}; | ||
Slider.defaultProps = { | ||
id: generatedId(), | ||
min: "0", | ||
max: "100", | ||
step: "1" | ||
}; | ||
Slider.__docgenInfo = { | ||
"description": "", | ||
"displayName": "Slider", | ||
"props": { | ||
"defaultValue": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Initial value of the field. User action will override" | ||
}, | ||
"disabled": { | ||
"type": { | ||
"name": "bool" | ||
}, | ||
"required": false, | ||
"description": "Prevents user actions on the field" | ||
}, | ||
"id": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "HTML ID attribute", | ||
"defaultValue": { | ||
"value": "generatedId()", | ||
"computed": true | ||
} | ||
}, | ||
"instructions": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "Instructional text for the field" | ||
}, | ||
"label": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "Text describing what the field represents" | ||
}, | ||
"min": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Minimum value of the slider", | ||
"defaultValue": { | ||
"value": "\"0\"", | ||
"computed": false | ||
} | ||
}, | ||
"max": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Maximum value of the slider", | ||
"defaultValue": { | ||
"value": "\"100\"", | ||
"computed": false | ||
} | ||
}, | ||
"name": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "Name of the field when submitted with a form" | ||
}, | ||
"onBlur": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called when user moves focus from the field" | ||
}, | ||
"onChange": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called after user changes the value of the field" | ||
}, | ||
"onFocus": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called when user puts focus onto the field" | ||
}, | ||
"onInput": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called as user changes the value of the field" | ||
}, | ||
"required": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "Text describing why the field is required" | ||
}, | ||
"step": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "The granularity of each step on the slider", | ||
"defaultValue": { | ||
"value": "\"1\"", | ||
"computed": false | ||
} | ||
}, | ||
"value": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Value of the field" | ||
} | ||
} | ||
}; | ||
export default Slider; |
@@ -5,6 +5,530 @@ 'use strict'; | ||
var higReact = require('hig-react'); | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
higReact.Range.displayName = "Slider"; | ||
var React = require('react'); | ||
var React__default = _interopDefault(React); | ||
var PropTypes = _interopDefault(require('prop-types')); | ||
var cx = _interopDefault(require('classnames')); | ||
exports.default = higReact.Range; | ||
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"); } } | ||
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; } | ||
var Input = function (_Component) { | ||
_inherits(Input, _Component); | ||
function Input() { | ||
_classCallCheck(this, Input); | ||
return _possibleConstructorReturn(this, (Input.__proto__ || Object.getPrototypeOf(Input)).apply(this, arguments)); | ||
} | ||
_createClass(Input, [{ | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
min = _props.min, | ||
max = _props.max, | ||
value = _props.value; | ||
return React__default.createElement("input", _extends({ | ||
className: "hig__slider__input", | ||
type: "range", | ||
"aria-valuemin": min, | ||
"aria-valuemax": max, | ||
"aria-valuenow": value | ||
}, this.props)); | ||
} | ||
}]); | ||
return Input; | ||
}(React.Component); | ||
Input.propTypes = { | ||
/** | ||
* Prevents user actions on the field | ||
*/ | ||
disabled: PropTypes.bool, | ||
/** | ||
* HTML ID attribute | ||
*/ | ||
id: PropTypes.string, | ||
/** | ||
* Minimum value of the slider | ||
*/ | ||
min: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Maximum value of the slider | ||
*/ | ||
max: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Name of the field when submitted with a form | ||
*/ | ||
name: PropTypes.string, | ||
/** | ||
* Called when user moves focus from the field | ||
*/ | ||
onBlur: PropTypes.func, | ||
/** | ||
* Called after user changes the value of the field | ||
*/ | ||
onChange: PropTypes.func, | ||
/** | ||
* Called when user puts focus onto the field | ||
*/ | ||
onFocus: PropTypes.func, | ||
/** | ||
* Called as user changes the value of the field | ||
*/ | ||
onInput: PropTypes.func, | ||
/** | ||
* The granularity of each step on the slider | ||
*/ | ||
step: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Value of the field | ||
*/ | ||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]) | ||
}; | ||
Input.__docgenInfo = { | ||
"description": "", | ||
"displayName": "Input", | ||
"props": { | ||
"disabled": { | ||
"type": { | ||
"name": "bool" | ||
}, | ||
"required": false, | ||
"description": "Prevents user actions on the field" | ||
}, | ||
"id": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "HTML ID attribute" | ||
}, | ||
"min": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Minimum value of the slider" | ||
}, | ||
"max": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Maximum value of the slider" | ||
}, | ||
"name": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "Name of the field when submitted with a form" | ||
}, | ||
"onBlur": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called when user moves focus from the field" | ||
}, | ||
"onChange": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called after user changes the value of the field" | ||
}, | ||
"onFocus": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called when user puts focus onto the field" | ||
}, | ||
"onInput": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called as user changes the value of the field" | ||
}, | ||
"step": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "The granularity of each step on the slider" | ||
}, | ||
"value": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Value of the field" | ||
} | ||
} | ||
}; | ||
var _createClass$1 = 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$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn$1(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$1(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; } | ||
function generatedId() { | ||
return "slider-" + Math.floor(Math.random() * 100000, 5); | ||
} | ||
var Slider = function (_Component) { | ||
_inherits$1(Slider, _Component); | ||
function Slider() { | ||
var _ref; | ||
var _temp, _this, _ret; | ||
_classCallCheck$1(this, Slider); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = _possibleConstructorReturn$1(this, (_ref = Slider.__proto__ || Object.getPrototypeOf(Slider)).call.apply(_ref, [this].concat(args))), _this), _this.state = { | ||
value: _this.props.defaultValue || _this.props.value | ||
}, _this.handleChange = function (event) { | ||
_this.setState({ value: event.target.value }); | ||
if (_this.props.onChange) _this.props.onChange(event); | ||
}, _temp), _possibleConstructorReturn$1(_this, _ret); | ||
} | ||
_createClass$1(Slider, [{ | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
id = _props.id, | ||
name = _props.name, | ||
label = _props.label, | ||
instructions = _props.instructions, | ||
required = _props.required, | ||
disabled = _props.disabled, | ||
min = _props.min, | ||
max = _props.max, | ||
step = _props.step, | ||
onBlur = _props.onBlur, | ||
onFocus = _props.onFocus, | ||
onInput = _props.onInput; | ||
var value = this.state.value; | ||
return React__default.createElement( | ||
"div", | ||
{ | ||
className: cx("hig__slider", { | ||
"hig__slider--disabled": disabled, | ||
"hig__slider--required": required | ||
}) | ||
}, | ||
React__default.createElement( | ||
"div", | ||
{ | ||
className: "hig__slider__wrapper", | ||
"data-range-min": min, | ||
"data-range-max": max | ||
}, | ||
React__default.createElement( | ||
"span", | ||
{ className: "hig__slider__current-value" }, | ||
value | ||
), | ||
React__default.createElement(Input, { | ||
id: id, | ||
onChange: this.handleChange, | ||
disabled: disabled, | ||
name: name, | ||
min: min, | ||
max: max, | ||
step: step, | ||
value: value, | ||
onBlur: onBlur, | ||
onFocus: onFocus, | ||
onInput: onInput | ||
}), | ||
label && React__default.createElement( | ||
"label", | ||
{ htmlFor: id, className: "hig__slider__label" }, | ||
label | ||
) | ||
), | ||
instructions && React__default.createElement( | ||
"p", | ||
{ className: "hig__slider__instructions" }, | ||
instructions | ||
), | ||
required && React__default.createElement( | ||
"p", | ||
{ className: "hig__slider__required-notice" }, | ||
required | ||
) | ||
); | ||
} | ||
}]); | ||
return Slider; | ||
}(React.Component); | ||
Slider.propTypes = { | ||
/** | ||
* Initial value of the field. User action will override | ||
*/ | ||
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Prevents user actions on the field | ||
*/ | ||
disabled: PropTypes.bool, | ||
/** | ||
* HTML ID attribute | ||
*/ | ||
id: PropTypes.string, | ||
/** | ||
* Instructional text for the field | ||
*/ | ||
instructions: PropTypes.string, | ||
/** | ||
* Text describing what the field represents | ||
*/ | ||
label: PropTypes.string, | ||
/** | ||
* Minimum value of the slider | ||
*/ | ||
min: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Maximum value of the slider | ||
*/ | ||
max: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Name of the field when submitted with a form | ||
*/ | ||
name: PropTypes.string, | ||
/** | ||
* Called when user moves focus from the field | ||
*/ | ||
onBlur: PropTypes.func, | ||
/** | ||
* Called after user changes the value of the field | ||
*/ | ||
onChange: PropTypes.func, | ||
/** | ||
* Called when user puts focus onto the field | ||
*/ | ||
onFocus: PropTypes.func, | ||
/** | ||
* Called as user changes the value of the field | ||
*/ | ||
onInput: PropTypes.func, | ||
/** | ||
* Text describing why the field is required | ||
*/ | ||
required: PropTypes.string, | ||
/** | ||
* The granularity of each step on the slider | ||
*/ | ||
step: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
/** | ||
* Value of the field | ||
*/ | ||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]) | ||
}; | ||
Slider.defaultProps = { | ||
id: generatedId(), | ||
min: "0", | ||
max: "100", | ||
step: "1" | ||
}; | ||
Slider.__docgenInfo = { | ||
"description": "", | ||
"displayName": "Slider", | ||
"props": { | ||
"defaultValue": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Initial value of the field. User action will override" | ||
}, | ||
"disabled": { | ||
"type": { | ||
"name": "bool" | ||
}, | ||
"required": false, | ||
"description": "Prevents user actions on the field" | ||
}, | ||
"id": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "HTML ID attribute", | ||
"defaultValue": { | ||
"value": "generatedId()", | ||
"computed": true | ||
} | ||
}, | ||
"instructions": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "Instructional text for the field" | ||
}, | ||
"label": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "Text describing what the field represents" | ||
}, | ||
"min": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Minimum value of the slider", | ||
"defaultValue": { | ||
"value": "\"0\"", | ||
"computed": false | ||
} | ||
}, | ||
"max": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Maximum value of the slider", | ||
"defaultValue": { | ||
"value": "\"100\"", | ||
"computed": false | ||
} | ||
}, | ||
"name": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "Name of the field when submitted with a form" | ||
}, | ||
"onBlur": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called when user moves focus from the field" | ||
}, | ||
"onChange": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called after user changes the value of the field" | ||
}, | ||
"onFocus": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called when user puts focus onto the field" | ||
}, | ||
"onInput": { | ||
"type": { | ||
"name": "func" | ||
}, | ||
"required": false, | ||
"description": "Called as user changes the value of the field" | ||
}, | ||
"required": { | ||
"type": { | ||
"name": "string" | ||
}, | ||
"required": false, | ||
"description": "Text describing why the field is required" | ||
}, | ||
"step": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "The granularity of each step on the slider", | ||
"defaultValue": { | ||
"value": "\"1\"", | ||
"computed": false | ||
} | ||
}, | ||
"value": { | ||
"type": { | ||
"name": "union", | ||
"value": [{ | ||
"name": "string" | ||
}, { | ||
"name": "number" | ||
}] | ||
}, | ||
"required": false, | ||
"description": "Value of the field" | ||
} | ||
} | ||
}; | ||
exports.default = Slider; |
{ | ||
"name": "@hig/slider", | ||
"version": "0.2.0-alpha.2eb35b95", | ||
"version": "0.2.0-alpha.48c93906", | ||
"description": "HIG Slider", | ||
@@ -22,5 +22,3 @@ "author": "Autodesk Inc.", | ||
"classnames": "^2.2.5", | ||
"hig-react": "0.30.0-alpha.2eb35b95", | ||
"prop-types": "^15.6.1", | ||
"react-lifecycles-compat": "^3.0.2" | ||
"prop-types": "^15.6.1" | ||
}, | ||
@@ -31,7 +29,7 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@hig/babel-preset": "0.2.0-alpha.2eb35b95", | ||
"@hig/eslint-config": "0.2.0-alpha.2eb35b95", | ||
"@hig/scripts": "0.2.0-alpha.2eb35b95", | ||
"@hig/semantic-release-config": "0.2.0-alpha.2eb35b95", | ||
"@hig/styles": "0.2.0-alpha.2eb35b95" | ||
"@hig/babel-preset": "0.2.0-alpha.48c93906", | ||
"@hig/eslint-config": "0.2.0-alpha.48c93906", | ||
"@hig/scripts": "0.2.0-alpha.48c93906", | ||
"@hig/semantic-release-config": "0.2.0-alpha.48c93906", | ||
"@hig/styles": "^0.1.1" | ||
}, | ||
@@ -38,0 +36,0 @@ "scripts": { |
@@ -29,6 +29,6 @@ # Slider | ||
required="Age is required." | ||
minValue={21} | ||
maxValue={99} | ||
min={21} | ||
max={99} | ||
step={1} | ||
/> | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
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
3
42019
1344
1
- Removedhig-react@0.30.0-alpha.2eb35b95
- Removedreact-lifecycles-compat@^3.0.2
- Removed@babel/runtime@7.26.0(transitive)
- Removed@hig/avatar@0.2.0-alpha.2eb35b95(transitive)
- Removed@hig/icon@0.2.0-alpha.2eb35b95(transitive)
- Removed@hig/icon-button@0.2.0-alpha.2eb35b95(transitive)
- Removed@hig/icons@0.2.0-alpha.2eb35b95(transitive)
- Removed@hig/timestamp@0.2.0-alpha.2eb35b95(transitive)
- Removed@hig/typography@0.2.0-alpha.2eb35b95(transitive)
- Removedasap@2.0.6(transitive)
- Removedcore-js@1.2.7(transitive)
- Removedcreate-react-class@15.7.0(transitive)
- Removeddom-helpers@3.4.0(transitive)
- Removedencoding@0.1.13(transitive)
- Removedfbjs@0.8.18(transitive)
- Removedhig-interface@0.2.0-alpha.2eb35b95(transitive)
- Removedhig-react@0.30.0-alpha.2eb35b95(transitive)
- Removedhig-vanilla@0.2.0-alpha.2eb35b95(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedisomorphic-fetch@2.2.1(transitive)
- Removednode-fetch@1.7.3(transitive)
- Removedpromise@7.3.1(transitive)
- Removedreact@15.7.018.3.1(transitive)
- Removedreact-dom@15.7.018.3.1(transitive)
- Removedreact-flip-move@3.0.5(transitive)
- Removedreact-lifecycles-compat@3.0.4(transitive)
- Removedreact-transition-group@2.9.0(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedscheduler@0.23.2(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedua-parser-js@0.7.39(transitive)
- Removedwhatwg-fetch@3.6.20(transitive)