diff --git a/CHANGELOG.md b/CHANGELOG.md index e1a3bfb62..a93f23d32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.40.1] - 2018-12-04 +### Fixed +- Put Input value set in onBlur/onSubmit under a debounce check [#384](https://github.com/plotly/dash-core-components/pull/384) + ## [0.40.0] - 2018-11-28 ### Added - Add Logout button (dash-deployment-server authentication integration) [#388](https://github.com/plotly/dash-core-components/pull/388) diff --git a/dash_core_components/dash_core_components.dev.js b/dash_core_components/dash_core_components.dev.js index 8b33b7509..390d62673 100644 --- a/dash_core_components/dash_core_components.dev.js +++ b/dash_core_components/dash_core_components.dev.js @@ -13138,7 +13138,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var reac /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Input; });\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ \"./node_modules/prop-types/index.js\");\n/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ramda */ \"./node_modules/ramda/index.js\");\n/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ramda__WEBPACK_IMPORTED_MODULE_2__);\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _extends() { _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; }; return _extends.apply(this, arguments); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\n/**\r\n * A basic HTML input control for entering text, numbers, or passwords.\r\n *\r\n * Note that checkbox and radio types are supported through\r\n * the Checklist and RadioItems component. Dates, times, and file uploads\r\n * are also supported through separate components.\r\n */\n\nvar Input =\n/*#__PURE__*/\nfunction (_Component) {\n _inherits(Input, _Component);\n\n function Input(props) {\n var _this;\n\n _classCallCheck(this, Input);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(Input).call(this, props));\n\n if (!props.setProps || props.debounce) {\n _this.state = {\n value: props.value\n };\n }\n\n return _this;\n }\n\n _createClass(Input, [{\n key: \"componentWillReceiveProps\",\n value: function componentWillReceiveProps(nextProps) {\n if (this.props.setProps) {\n this.props = nextProps;\n\n if (this.props.debounce) {\n this.setState({\n value: nextProps.value\n });\n }\n }\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this2 = this;\n\n var _this$props = this.props,\n fireEvent = _this$props.fireEvent,\n setProps = _this$props.setProps,\n type = _this$props.type,\n min = _this$props.min,\n max = _this$props.max,\n debounce = _this$props.debounce;\n\n var _ref = setProps ? debounce ? this.state : this.props : this.state,\n value = _ref.value;\n\n return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(\"input\", _extends({\n onChange: function onChange(e) {\n var newValue = e.target.value;\n\n if (!Object(ramda__WEBPACK_IMPORTED_MODULE_2__[\"isEmpty\"])(min) && Number(newValue) < min || !Object(ramda__WEBPACK_IMPORTED_MODULE_2__[\"isEmpty\"])(max) && Number(newValue) > max) {\n return;\n }\n\n if (fireEvent) {\n fireEvent({\n event: 'change'\n });\n }\n\n if (!debounce && setProps) {\n var castValue = type === 'number' ? Number(newValue) : newValue;\n setProps({\n value: castValue\n });\n } else {\n _this2.setState({\n value: newValue\n });\n }\n },\n onBlur: function onBlur() {\n if (fireEvent) {\n fireEvent({\n event: 'blur'\n });\n }\n\n if (setProps) {\n var castValue = type === 'number' ? Number(value) : value;\n setProps({\n n_blur: _this2.props.n_blur + 1,\n n_blur_timestamp: new Date(),\n value: castValue\n });\n }\n },\n onKeyPress: function onKeyPress(e) {\n if (setProps && e.key === 'Enter') {\n var castValue = type === 'number' ? Number(value) : value;\n setProps({\n n_submit: _this2.props.n_submit + 1,\n n_submit_timestamp: new Date(),\n value: castValue\n });\n }\n },\n value: value\n }, Object(ramda__WEBPACK_IMPORTED_MODULE_2__[\"omit\"])(['debounce', 'fireEvent', 'value', 'n_blur', 'n_blur_timestamp', 'n_submit', 'n_submit_timestamp', 'selectionDirection', 'selectionEnd', 'selectionStart', 'setProps'], this.props)));\n }\n }]);\n\n return Input;\n}(react__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n\nInput.defaultProps = {\n n_blur: 0,\n n_blur_timestamp: -1,\n n_submit: 0,\n n_submit_timestamp: -1,\n debounce: false\n};\nInput.propTypes = {\n /**\r\n * The ID of this component, used to identify dash components\r\n * in callbacks. The ID needs to be unique across all of the\r\n * components in an app.\r\n */\n id: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string,\n\n /**\r\n * The value of the input\r\n */\n value: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.number]),\n\n /**\r\n * The input's inline styles\r\n */\n style: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.object,\n\n /**\r\n * The class of the input element\r\n */\n className: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string,\n\n /**\r\n * If true, changes to input will be sent back to the Dash server only on enter or when losing focus.\r\n * If it's false, it will sent the value back on every change.\r\n */\n debounce: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.bool,\n\n /**\r\n * The type of control to render.\r\n */\n type: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.oneOf([// Only allowing the input types with wide browser compatibility\n 'text', 'number', 'password', 'email', 'range', 'search', 'tel', 'url', 'hidden']),\n\n /**\r\n * This attribute indicates whether the value of the control can be automatically completed by the browser.\r\n */\n autocomplete: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string,\n\n /**\r\n * The element should be automatically focused after the page loaded.\r\n */\n autofocus: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string,\n\n /**\r\n * If true, the input is disabled and can't be clicked on.\r\n */\n disabled: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.bool,\n inputmode: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.oneOf([\n /**\r\n * Alphanumeric, non-prose content such as usernames and passwords.\r\n */\n 'verbatim',\n /**\r\n * Latin-script input in the user's preferred language with typing aids such as text prediction enabled. For human-to-computer communication such as search boxes.\r\n */\n 'latin',\n /**\r\n * As latin, but for human names.\r\n */\n 'latin-name',\n /**\r\n * As latin, but with more aggressive typing aids. For human-to-human communication such as instant messaging or email.\r\n */\n 'latin-prose',\n /**\r\n * As latin-prose, but for the user's secondary languages.\r\n */\n 'full-width-latin',\n /**\r\n * Kana or romaji input, typically hiragana input, using full-width characters, with support for converting to kanji. Intended for Japanese text input.\r\n */\n 'kana',\n /**\r\n * Katakana input, using full-width characters, with support for converting to kanji. Intended for Japanese text input.\r\n */\n 'katakana',\n /**\r\n * Numeric input, including keys for the digits 0 to 9, the user's preferred thousands separator character, and the character for indicating negative numbers. Intended for numeric codes (e.g. credit card numbers). For actual numbers, prefer using type=\"number\"\r\n */\n 'numeric',\n /**\r\n * Telephone input, including asterisk and pound key. Use type=\"tel\" if possible instead.\r\n */\n 'tel',\n /**\r\n * Email input. Use type=\"email\" if possible instead.\r\n */\n 'email',\n /**\r\n * URL input. Use type=\"url\" if possible instead.\r\n */\n 'url']),\n\n /**\r\n * Identifies a list of pre-defined options to suggest to the user.\r\n * The value must be the id of a element in the same document.\r\n * The browser displays only options that are valid values for this\r\n * input element.\r\n * This attribute is ignored when the type attribute's value is\r\n * hidden, checkbox, radio, file, or a button type.\r\n */\n list: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string,\n\n /**\r\n * The maximum (numeric or date-time) value for this item, which must not be less than its minimum (min attribute) value.\r\n */\n max: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.number]),\n\n /**\r\n * If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the maximum number of characters (in UTF-16 code units) that the user can enter. For other control types, it is ignored. It can exceed the value of the size attribute. If it is not specified, the user can enter an unlimited number of characters. Specifying a negative number results in the default behavior (i.e. the user can enter an unlimited number of characters). The constraint is evaluated only when the value of the attribute has been changed.\r\n */\n maxlength: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string,\n\n /**\r\n * The minimum (numeric or date-time) value for this item, which must not be greater than its maximum (max attribute) value.\r\n */\n min: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.number]),\n\n /**\r\n * If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the minimum number of characters (in Unicode code points) that the user can enter. For other control types, it is ignored.\r\n */\n minlength: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string,\n\n /**\r\n * This Boolean attribute indicates whether the user can enter more than one value. This attribute applies when the type attribute is set to email or file, otherwise it is ignored.\r\n */\n multiple: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.bool,\n\n /**\r\n * The name of the control, which is submitted with the form data.\r\n */\n name: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string,\n\n /**\r\n * A regular expression that the control's value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is text, search, tel, url, email, or password, otherwise it is ignored. The regular expression language is the same as JavaScript RegExp algorithm, with the 'u' parameter that makes it treat the pattern as a sequence of unicode code points. The pattern is not surrounded by forward slashes.\r\n */\n pattern: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string,\n\n /**\r\n * A hint to the user of what can be entered in the control . The placeholder text must not contain carriage returns or line-feeds. Note: Do not use the placeholder attribute instead of a