From 422ace34533002dbaa9f01ddf19eb127eaf0699f Mon Sep 17 00:00:00 2001 From: Trombitas Sandor Date: Wed, 17 Oct 2018 09:18:52 +0300 Subject: [PATCH 1/6] chore: Update package.json dependencies --- package.json | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 29267b33..7f3d3ea4 100644 --- a/package.json +++ b/package.json @@ -46,20 +46,20 @@ "react-infinite-scroll-component": "^4.0.2" }, "devDependencies": { - "@babel/plugin-syntax-jsx": "^7.0.0-beta.46", - "@babel/preset-stage-3": "^7.0.0-beta.46", + "@babel/plugin-syntax-jsx": "7.0.0-beta.46", + "@babel/preset-stage-3": "7.0.0-beta.46", "@commitlint/cli": "^7.0.0", "@commitlint/config-conventional": "^7.0.0", - "ava": "^1.0.0-beta.4", - "babel-core": "^6.24.1", - "babel-eslint": "^8.0.0", - "babel-loader": "^7.1.2", - "babel-plugin-istanbul": "^4.1.3", - "babel-plugin-transform-class-properties": "^6.24.1", - "babel-plugin-transform-react-remove-prop-types": "^0.4.13", - "babel-preset-es2015": "^6.24.1", - "babel-preset-react": "^6.24.1", - "babel-preset-stage-0": "^6.24.1", + "ava": "1.0.0-beta.4", + "babel-core": "6.24.1", + "babel-eslint": "8.0.0", + "babel-loader": "7.1.2", + "babel-plugin-istanbul": "4.1.3", + "babel-plugin-transform-class-properties": "6.24.1", + "babel-plugin-transform-react-remove-prop-types": "0.4.13", + "babel-preset-es2015": "6.24.1", + "babel-preset-react": "6.24.1", + "babel-preset-stage-0": "6.24.1", "commitizen": "^2.9.6", "conventional-changelog-cli": "^2.0.5", "coveralls": "^3.0.0", @@ -94,7 +94,6 @@ "react": "^16.0.0", "react-dom": "^16.0.0", "react-story": "^0.0.10", - "release-it": "^7.6.1", "rimraf": "^2.6.1", "sinon": "^5.0.0", "style-loader": "^0.20.1", From 04174e137d448a21e4d0f7590aca95f84c277136 Mon Sep 17 00:00:00 2001 From: Trombitas Sandor Date: Wed, 17 Oct 2018 09:23:16 +0300 Subject: [PATCH 2/6] feat: Add disabled prop to Input and DropdownTreeSelect --- __snapshots__/src/input/index.test.js.md | 22 ++++++++++++++++++++- __snapshots__/src/input/index.test.js.snap | Bin 853 -> 920 bytes docs/src/stories/Options/index.js | 7 +++++-- src/index.js | 9 +++++++-- src/index.test.js | 8 ++++++++ src/input/index.js | 4 +++- src/input/index.test.js | 5 +++++ 7 files changed, 49 insertions(+), 6 deletions(-) diff --git a/__snapshots__/src/input/index.test.js.md b/__snapshots__/src/input/index.test.js.md index fc13f138..ead12066 100644 --- a/__snapshots__/src/input/index.test.js.md +++ b/__snapshots__/src/input/index.test.js.md @@ -107,4 +107,24 @@ Generated by [AVA](https://ava.li). type="text" /> - + Snapshot 1 + + \ No newline at end of file diff --git a/__snapshots__/src/input/index.test.js.snap b/__snapshots__/src/input/index.test.js.snap index b6c87606195af26edc07bd848a090e1e6cf4afc6..08175e6481558cb3136abe72dc92992c8d2ee9f6 100644 GIT binary patch literal 920 zcmV;J184j}RzVeA=H0u;n|tkYiH~A*@GSO zkpQN>Llp=ys2WDZ*nw@rNx>PGqkc(oMu_0maN=RG#RCQ+5COV@KHvsWi8%*mqO#3i ziHjWAa=;TH2`{~Ax7(Pdvj`U>%pzQZ@ngEYL~D@_N}Ic3(U?KFjCNE&SY}hg9)cHp zWkFS&gdj=xST(`#lqFT8Q{zv8Z#U2j^aGD@dRnq%m=Lkk9fZjRXyrY$u7O+ofq6r&OCU%#*bn#+@Zpm_VgyO=fI-}7+A%V&*sUGfX8!S4k(2K zwu?(e;3Xv-)eJF;3^B5%laYMO&051pUKTt=*1yZOxkI>fgmBXkT+VD;R3b#YBEsbu zx56^@T?i?4qM-PRAwp?b7Q93Z$vzU%qt=O`kV;%Gm%*6RVqvoULb^1BtH6MDARA4g zb$?XxYEnqS){K{A8gt)4+)*&-00KbR%DwS9mpr8qY@o+L*)ZrwwjH8-JpW@wL{*_X4$HQ;7`Y)~KN%(L_n{ z|67Uh$HBk{C_oH2Y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ories/Options/index.js index 4b2af8ed..a8bb6b00 100644 --- a/docs/src/stories/Options/index.js +++ b/docs/src/stories/Options/index.js @@ -14,7 +14,8 @@ class WithOptions extends PureComponent { clearSearchOnChange: false, keepTreeOnSearch: false, simpleSelect: false, - showPartiallySelected: false + showPartiallySelected: false, + disabled: false } } @@ -33,7 +34,7 @@ class WithOptions extends PureComponent { } render() { - const { clearSearchOnChange, keepTreeOnSearch, simpleSelect, showPartiallySelected } = this.state + const { clearSearchOnChange, keepTreeOnSearch, simpleSelect, showPartiallySelected, disabled } = this.state return (
@@ -51,6 +52,7 @@ class WithOptions extends PureComponent { +
diff --git a/src/index.js b/src/index.js index 4ef4abe3..bfd8ac11 100644 --- a/src/index.js +++ b/src/index.js @@ -34,7 +34,8 @@ class DropdownTreeSelect extends Component { onBlur: PropTypes.func, simpleSelect: PropTypes.bool, noMatchesText: PropTypes.string, - showPartiallySelected: PropTypes.bool + showPartiallySelected: PropTypes.bool, + disabled: PropTypes.bool } static defaultProps = { @@ -84,6 +85,9 @@ class DropdownTreeSelect extends Component { handleClick = () => { this.setState(prevState => { + if (this.props.disabled) { + return { showDropdown: false } + } // keep dropdown active when typing in search box const showDropdown = this.keepDropdownActive || !prevState.showDropdown @@ -175,7 +179,7 @@ class DropdownTreeSelect extends Component { render() { const dropdownTriggerClassname = cx({ 'dropdown-trigger': true, - arrow: true, + arrow: !this.props.disabled, top: this.state.showDropdown, bottom: !this.state.showDropdown }) @@ -199,6 +203,7 @@ class DropdownTreeSelect extends Component { onFocus={this.onInputFocus} onBlur={this.onInputBlur} onTagRemove={this.onTagRemove} + disabled={this.props.disabled} /> {this.state.showDropdown && ( diff --git a/src/index.test.js b/src/index.test.js index 7d2ebc52..6f309393 100644 --- a/src/index.test.js +++ b/src/index.test.js @@ -129,6 +129,14 @@ test('toggles dropdown', t => { t.false(wrapper.state().showDropdown) }) +test('doesn\'t toggle dropdown if it\'s disabled', t => { + const { tree } = t.context + const wrapper = mount() + t.false(wrapper.state().showDropdown) + wrapper.instance().handleClick() + t.false(wrapper.state().showDropdown) +}) + test('keeps dropdown active on focus', t => { const { tree } = t.context const wrapper = shallow() diff --git a/src/input/index.js b/src/input/index.js index 5194f4f5..ba80d4cb 100644 --- a/src/input/index.js +++ b/src/input/index.js @@ -25,7 +25,8 @@ class Input extends PureComponent { onFocus: PropTypes.func, onBlur: PropTypes.func, onTagRemove: PropTypes.func, - inputRef: PropTypes.func + inputRef: PropTypes.func, + disabled: PropTypes.bool } constructor(props) { @@ -47,6 +48,7 @@ class Input extends PureComponent {
  • { t.snapshot(wrapper) }) + +test('should render disabled input', t => { + const wrapper = toJson(shallow()) + t.snapshot(wrapper) +}) From 8dbba10dcd091479634f2a1bf85c7fe9a29a5a36 Mon Sep 17 00:00:00 2001 From: Trombitas Sandor Date: Wed, 17 Oct 2018 09:31:02 +0300 Subject: [PATCH 3/6] chore: Rebuild bundle.js --- docs/bundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/bundle.js b/docs/bundle.js index 5ce97bbd..ee6db254 100644 --- a/docs/bundle.js +++ b/docs/bundle.js @@ -1 +1 @@ -!function(e){var a={};function l(n){if(a[n])return a[n].exports;var r=a[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,l),r.l=!0,r.exports}l.m=e,l.c=a,l.d=function(e,a,n){l.o(e,a)||Object.defineProperty(e,a,{configurable:!1,enumerable:!0,get:n})},l.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},l.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(a,"a",a),a},l.o=function(e,a){return Object.prototype.hasOwnProperty.call(e,a)},l.p="",l(l.s=54)}([function(module,exports,__webpack_require__){"use strict";eval("\n\nif (true) {\n module.exports = __webpack_require__(125);\n} else {}\n\n\n//# sourceURL=webpack:///./node_modules/react/index.js?")},function(module,exports,__webpack_require__){eval("/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nif (false) { var throwOnDirectAccess, isValidElement, REACT_ELEMENT_TYPE; } else {\n // By explicitly using `prop-types` you are opting into new production behavior.\n // http://fb.me/prop-types-in-prod\n module.exports = __webpack_require__(83)();\n}\n\n\n//# sourceURL=webpack:///./node_modules/prop-types/index.js?")},function(module,exports,__webpack_require__){eval("/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nif (false) { var throwOnDirectAccess, isValidElement, REACT_ELEMENT_TYPE; } else {\n // By explicitly using `prop-types` you are opting into new production behavior.\n // http://fb.me/prop-types-in-prod\n module.exports = __webpack_require__(113)();\n}\n\n\n//# sourceURL=webpack:///./node_modules/react-router/node_modules/prop-types/index.js?")},function(module,exports,__webpack_require__){"use strict";eval("/**\n * Copyright 2014-2015, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n\n\n/**\n * Similar to invariant but only logs a warning if the condition is not met.\n * This can be used to log issues in development environments in critical\n * paths. Removing the logging code for production environments will keep the\n * same logic and follow the same code paths.\n */\n\nvar warning = function() {};\n\nif (false) {}\n\nmodule.exports = warning;\n\n\n//# sourceURL=webpack:///./node_modules/warning/browser.js?")},function(module,exports,__webpack_require__){eval("/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nif (false) { var throwOnDirectAccess, isValidElement, REACT_ELEMENT_TYPE; } else {\n // By explicitly using `prop-types` you are opting into new production behavior.\n // http://fb.me/prop-types-in-prod\n module.exports = __webpack_require__(115)();\n}\n\n\n//# sourceURL=webpack:///./node_modules/react-router-dom/node_modules/prop-types/index.js?")},function(module,exports,__webpack_require__){"use strict";eval("/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\n\n/**\n * Use invariant() to assert state which your program assumes to be true.\n *\n * Provide sprintf-style format (only %s is supported) and arguments\n * to provide information about what broke and what you were\n * expecting.\n *\n * The invariant message will be stripped in production, but the invariant\n * will remain to ensure logic does not differ in production.\n */\n\nvar invariant = function(condition, format, a, b, c, d, e, f) {\n if (false) {}\n\n if (!condition) {\n var error;\n if (format === undefined) {\n error = new Error(\n 'Minified exception occurred; use the non-minified dev environment ' +\n 'for the full error message and additional helpful warnings.'\n );\n } else {\n var args = [a, b, c, d, e, f];\n var argIndex = 0;\n error = new Error(\n format.replace(/%s/g, function() { return args[argIndex++]; })\n );\n error.name = 'Invariant Violation';\n }\n\n error.framesToPop = 1; // we don't care about invariant's own frame\n throw error;\n }\n};\n\nmodule.exports = invariant;\n\n\n//# sourceURL=webpack:///./node_modules/invariant/browser.js?")},function(module,exports,__webpack_require__){eval('/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n\nvar stylesInDom = {};\n\nvar\tmemoize = function (fn) {\n\tvar memo;\n\n\treturn function () {\n\t\tif (typeof memo === "undefined") memo = fn.apply(this, arguments);\n\t\treturn memo;\n\t};\n};\n\nvar isOldIE = memoize(function () {\n\t// Test for IE <= 9 as proposed by Browserhacks\n\t// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805\n\t// Tests for existence of standard globals is to allow style-loader\n\t// to operate correctly into non-standard environments\n\t// @see https://github.com/webpack-contrib/style-loader/issues/177\n\treturn window && document && document.all && !window.atob;\n});\n\nvar getTarget = function (target) {\n return document.querySelector(target);\n};\n\nvar getElement = (function (fn) {\n\tvar memo = {};\n\n\treturn function(target) {\n // If passing function in options, then use it for resolve "head" element.\n // Useful for Shadow Root style i.e\n // {\n // insertInto: function () { return document.querySelector("#foo").shadowRoot }\n // }\n if (typeof target === \'function\') {\n return target();\n }\n if (typeof memo[target] === "undefined") {\n\t\t\tvar styleTarget = getTarget.call(this, target);\n\t\t\t// Special case to return head of iframe instead of iframe itself\n\t\t\tif (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {\n\t\t\t\ttry {\n\t\t\t\t\t// This will throw an exception if access to iframe is blocked\n\t\t\t\t\t// due to cross-origin restrictions\n\t\t\t\t\tstyleTarget = styleTarget.contentDocument.head;\n\t\t\t\t} catch(e) {\n\t\t\t\t\tstyleTarget = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tmemo[target] = styleTarget;\n\t\t}\n\t\treturn memo[target]\n\t};\n})();\n\nvar singleton = null;\nvar\tsingletonCounter = 0;\nvar\tstylesInsertedAtTop = [];\n\nvar\tfixUrls = __webpack_require__(73);\n\nmodule.exports = function(list, options) {\n\tif (typeof DEBUG !== "undefined" && DEBUG) {\n\t\tif (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");\n\t}\n\n\toptions = options || {};\n\n\toptions.attrs = typeof options.attrs === "object" ? options.attrs : {};\n\n\t// Force single-tag solution on IE6-9, which has a hard limit on the # of