From 45566db218ced7a9a2498c9c954e6e40fdc8551d Mon Sep 17 00:00:00 2001 From: Jake Zatecky Date: Mon, 27 Feb 2017 20:51:11 -0500 Subject: [PATCH] Release v0.4.2 --- CHANGELOG.md | 2 +- examples/dist/index.js | 666 ++++++++++++++++++++++++++++++---------- examples/dist/style.css | 5 +- package.json | 2 +- 4 files changed, 510 insertions(+), 165 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea8e56d8..d2b2f7b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # CHANGELOG -## v0.4.2 (TBA) +## [v0.4.2](https://github.com/jakezatecky/react-checkbox-tree/compare/v0.4.1...v0.4.) (2016-02-27) ## Bug Fixes diff --git a/examples/dist/index.js b/examples/dist/index.js index b65e0575..a242076b 100644 --- a/examples/dist/index.js +++ b/examples/dist/index.js @@ -73,7 +73,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 183); +/******/ return __webpack_require__(__webpack_require__.s = 191); /******/ }) /************************************************************************/ /******/ ([ @@ -545,7 +545,7 @@ module.exports = shouldUseNative() ? Object.assign : function (target, source) { var _prodInvariant = __webpack_require__(3); var DOMProperty = __webpack_require__(13); -var ReactDOMComponentFlags = __webpack_require__(61); +var ReactDOMComponentFlags = __webpack_require__(62); var invariant = __webpack_require__(1); @@ -1201,9 +1201,9 @@ module.exports = emptyFunction; var _prodInvariant = __webpack_require__(3), _assign = __webpack_require__(4); -var CallbackQueue = __webpack_require__(59); +var CallbackQueue = __webpack_require__(60); var PooledClass = __webpack_require__(14); -var ReactFeatureFlags = __webpack_require__(64); +var ReactFeatureFlags = __webpack_require__(65); var ReactReconciler = __webpack_require__(19); var Transaction = __webpack_require__(29); @@ -2107,7 +2107,7 @@ var warning = __webpack_require__(2); var canDefineProperty = __webpack_require__(51); var hasOwnProperty = Object.prototype.hasOwnProperty; -var REACT_ELEMENT_TYPE = __webpack_require__(79); +var REACT_ELEMENT_TYPE = __webpack_require__(80); var RESERVED_PROPS = { key: true, @@ -2504,7 +2504,7 @@ var DOMNamespaces = __webpack_require__(34); var setInnerHTML = __webpack_require__(31); var createMicrosoftUnsafeLocalFunction = __webpack_require__(41); -var setTextContent = __webpack_require__(77); +var setTextContent = __webpack_require__(78); var ELEMENT_NODE_TYPE = 1; var DOCUMENT_FRAGMENT_NODE_TYPE = 11; @@ -2816,7 +2816,7 @@ var createFactory = ReactElement.createFactory; var cloneElement = ReactElement.cloneElement; if (process.env.NODE_ENV !== 'production') { - var ReactElementValidator = __webpack_require__(80); + var ReactElementValidator = __webpack_require__(81); createElement = ReactElementValidator.createElement; createFactory = ReactElementValidator.createFactory; cloneElement = ReactElementValidator.cloneElement; @@ -2924,8 +2924,8 @@ var EventPluginRegistry = __webpack_require__(26); var EventPluginUtils = __webpack_require__(35); var ReactErrorUtils = __webpack_require__(39); -var accumulateInto = __webpack_require__(71); -var forEachAccumulated = __webpack_require__(72); +var accumulateInto = __webpack_require__(72); +var forEachAccumulated = __webpack_require__(73); var invariant = __webpack_require__(1); /** @@ -3205,8 +3205,8 @@ module.exports = EventPluginHub; var EventPluginHub = __webpack_require__(22); var EventPluginUtils = __webpack_require__(35); -var accumulateInto = __webpack_require__(71); -var forEachAccumulated = __webpack_require__(72); +var accumulateInto = __webpack_require__(72); +var forEachAccumulated = __webpack_require__(73); var warning = __webpack_require__(2); var getListener = EventPluginHub.getListener; @@ -3724,7 +3724,7 @@ var _assign = __webpack_require__(4); var EventPluginRegistry = __webpack_require__(26); var ReactEventEmitterMixin = __webpack_require__(133); -var ViewportMetrics = __webpack_require__(70); +var ViewportMetrics = __webpack_require__(71); var getVendorPrefixedEventName = __webpack_require__(169); var isEventSupported = __webpack_require__(45); @@ -4054,7 +4054,7 @@ module.exports = ReactBrowserEventEmitter; var SyntheticUIEvent = __webpack_require__(25); -var ViewportMetrics = __webpack_require__(70); +var ViewportMetrics = __webpack_require__(71); var getEventModifierState = __webpack_require__(43); @@ -4672,7 +4672,7 @@ var ReactInstrumentation = __webpack_require__(8); var createMicrosoftUnsafeLocalFunction = __webpack_require__(41); var setInnerHTML = __webpack_require__(31); -var setTextContent = __webpack_require__(77); +var setTextContent = __webpack_require__(78); function getNodeAfter(parentNode, node) { // Special case for text components, which return [open, close] comments @@ -5220,7 +5220,7 @@ module.exports = KeyEscapeUtils; var _prodInvariant = __webpack_require__(3); var React = __webpack_require__(20); -var ReactPropTypesSecret = __webpack_require__(69); +var ReactPropTypesSecret = __webpack_require__(70); var invariant = __webpack_require__(1); var warning = __webpack_require__(2); @@ -6730,6 +6730,111 @@ module.exports = getIteratorFn; "use strict"; +var randomFromSeed = __webpack_require__(189); + +var ORIGINAL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-'; +var alphabet; +var previousSeed; + +var shuffled; + +function reset() { + shuffled = false; +} + +function setCharacters(_alphabet_) { + if (!_alphabet_) { + if (alphabet !== ORIGINAL) { + alphabet = ORIGINAL; + reset(); + } + return; + } + + if (_alphabet_ === alphabet) { + return; + } + + if (_alphabet_.length !== ORIGINAL.length) { + throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. You submitted ' + _alphabet_.length + ' characters: ' + _alphabet_); + } + + var unique = _alphabet_.split('').filter(function(item, ind, arr){ + return ind !== arr.lastIndexOf(item); + }); + + if (unique.length) { + throw new Error('Custom alphabet for shortid must be ' + ORIGINAL.length + ' unique characters. These characters were not unique: ' + unique.join(', ')); + } + + alphabet = _alphabet_; + reset(); +} + +function characters(_alphabet_) { + setCharacters(_alphabet_); + return alphabet; +} + +function setSeed(seed) { + randomFromSeed.seed(seed); + if (previousSeed !== seed) { + reset(); + previousSeed = seed; + } +} + +function shuffle() { + if (!alphabet) { + setCharacters(ORIGINAL); + } + + var sourceArray = alphabet.split(''); + var targetArray = []; + var r = randomFromSeed.nextValue(); + var characterIndex; + + while (sourceArray.length > 0) { + r = randomFromSeed.nextValue(); + characterIndex = Math.floor(r * sourceArray.length); + targetArray.push(sourceArray.splice(characterIndex, 1)[0]); + } + return targetArray.join(''); +} + +function getShuffled() { + if (shuffled) { + return shuffled; + } + shuffled = shuffle(); + return shuffled; +} + +/** + * lookup shuffled letter + * @param index + * @returns {string} + */ +function lookup(index) { + var alphabetShuffled = getShuffled(); + return alphabetShuffled[index]; +} + +module.exports = { + characters: characters, + seed: setSeed, + lookup: lookup, + shuffled: getShuffled +}; + + +/***/ }), +/* 54 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + Object.defineProperty(exports, "__esModule", { value: true }); @@ -6742,17 +6847,17 @@ var _react = __webpack_require__(17); var _react2 = _interopRequireDefault(_react); -var _TreeNode = __webpack_require__(85); +var _shortid = __webpack_require__(183); -var _TreeNode2 = _interopRequireDefault(_TreeNode); +var _shortid2 = _interopRequireDefault(_shortid); -var _nodeShape = __webpack_require__(54); +var _TreeNode = __webpack_require__(86); -var _nodeShape2 = _interopRequireDefault(_nodeShape); +var _TreeNode2 = _interopRequireDefault(_TreeNode); -var _uniqueDomId = __webpack_require__(86); +var _nodeShape = __webpack_require__(55); -var _uniqueDomId2 = _interopRequireDefault(_uniqueDomId); +var _nodeShape2 = _interopRequireDefault(_nodeShape); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -6775,7 +6880,7 @@ var Tree = function (_React$Component) { _this.onCheck = _this.onCheck.bind(_this); _this.onExpand = _this.onExpand.bind(_this); - _this.id = (0, _uniqueDomId2.default)('rct'); + _this.id = 'rct-' + _shortid2.default.generate(); return _this; } @@ -6990,9 +7095,7 @@ var Tree = function (_React$Component) { }(_react2.default.Component); Tree.propTypes = { - nodes: _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.oneOfType([_react2.default.PropTypes.shape(_nodeShape2.default), _react2.default.PropTypes.shape(_extends({}, _nodeShape2.default, { - children: _react2.default.PropTypes.arrayOf(_nodeShape2.default) - }))])).isRequired, + nodes: _react2.default.PropTypes.arrayOf(_nodeShape2.default).isRequired, checked: _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.string), expanded: _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.string), @@ -7015,7 +7118,7 @@ Tree.defaultProps = { exports.default = Tree; /***/ }), -/* 54 */ +/* 55 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7025,19 +7128,34 @@ Object.defineProperty(exports, "__esModule", { value: true }); +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 _react = __webpack_require__(17); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -exports.default = { - value: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.number]), - title: _react2.default.PropTypes.string +var nodeShape = { + value: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.number]).isRequired, + label: _react2.default.PropTypes.string.isRequired +}; + +var legacyShape = { + value: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.number]).isRequired, + title: _react2.default.PropTypes.string.isRequired }; +var nodeShapeWithChildren = _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.shape(nodeShape), _react2.default.PropTypes.shape(legacyShape), _react2.default.PropTypes.shape(_extends({}, nodeShape, { + children: _react2.default.PropTypes.arrayOf(nodeShape).isRequired +})), _react2.default.PropTypes.shape(_extends({}, legacyShape, { + children: _react2.default.PropTypes.arrayOf(nodeShape).isRequired +}))]); + +exports.default = nodeShapeWithChildren; + /***/ }), -/* 55 */ +/* 56 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7127,7 +7245,7 @@ module.exports = EventListener; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 56 */ +/* 57 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7159,7 +7277,7 @@ function focusNode(node) { module.exports = focusNode; /***/ }), -/* 57 */ +/* 58 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7199,7 +7317,7 @@ function getActiveElement() /*?DOMElement*/{ module.exports = getActiveElement; /***/ }), -/* 58 */ +/* 59 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7352,7 +7470,7 @@ var CSSProperty = { module.exports = CSSProperty; /***/ }), -/* 59 */ +/* 60 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7477,7 +7595,7 @@ module.exports = PooledClass.addPoolingTo(CallbackQueue); /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 60 */ +/* 61 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7720,7 +7838,7 @@ module.exports = DOMPropertyOperations; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 61 */ +/* 62 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7743,7 +7861,7 @@ var ReactDOMComponentFlags = { module.exports = ReactDOMComponentFlags; /***/ }), -/* 62 */ +/* 63 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7949,7 +8067,7 @@ module.exports = ReactDOMSelect; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 63 */ +/* 64 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -7984,7 +8102,7 @@ ReactEmptyComponent.injection = ReactEmptyComponentInjection; module.exports = ReactEmptyComponent; /***/ }), -/* 64 */ +/* 65 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8011,7 +8129,7 @@ var ReactFeatureFlags = { module.exports = ReactFeatureFlags; /***/ }), -/* 65 */ +/* 66 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8085,7 +8203,7 @@ module.exports = ReactHostComponent; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 66 */ +/* 67 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8104,8 +8222,8 @@ module.exports = ReactHostComponent; var ReactDOMSelection = __webpack_require__(124); var containsNode = __webpack_require__(89); -var focusNode = __webpack_require__(56); -var getActiveElement = __webpack_require__(57); +var focusNode = __webpack_require__(57); +var getActiveElement = __webpack_require__(58); function isInDocument(node) { return containsNode(document.documentElement, node); @@ -8214,7 +8332,7 @@ var ReactInputSelection = { module.exports = ReactInputSelection; /***/ }), -/* 67 */ +/* 68 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8240,7 +8358,7 @@ var ReactCurrentOwner = __webpack_require__(11); var ReactDOMComponentTree = __webpack_require__(5); var ReactDOMContainerInfo = __webpack_require__(116); var ReactDOMFeatureFlags = __webpack_require__(118); -var ReactFeatureFlags = __webpack_require__(64); +var ReactFeatureFlags = __webpack_require__(65); var ReactInstanceMap = __webpack_require__(24); var ReactInstrumentation = __webpack_require__(8); var ReactMarkupChecksum = __webpack_require__(138); @@ -8249,7 +8367,7 @@ var ReactUpdateQueue = __webpack_require__(40); var ReactUpdates = __webpack_require__(10); var emptyObject = __webpack_require__(21); -var instantiateReactComponent = __webpack_require__(75); +var instantiateReactComponent = __webpack_require__(76); var invariant = __webpack_require__(1); var setInnerHTML = __webpack_require__(31); var shouldUpdateReactComponent = __webpack_require__(46); @@ -8758,7 +8876,7 @@ module.exports = ReactMount; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 68 */ +/* 69 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8804,7 +8922,7 @@ module.exports = ReactNodeTypes; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 69 */ +/* 70 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8826,7 +8944,7 @@ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; module.exports = ReactPropTypesSecret; /***/ }), -/* 70 */ +/* 71 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8858,7 +8976,7 @@ var ViewportMetrics = { module.exports = ViewportMetrics; /***/ }), -/* 71 */ +/* 72 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8922,7 +9040,7 @@ module.exports = accumulateInto; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 72 */ +/* 73 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8958,7 +9076,7 @@ function forEachAccumulated(arr, cb, scope) { module.exports = forEachAccumulated; /***/ }), -/* 73 */ +/* 74 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -8974,7 +9092,7 @@ module.exports = forEachAccumulated; -var ReactNodeTypes = __webpack_require__(68); +var ReactNodeTypes = __webpack_require__(69); function getHostComponentFromComposite(inst) { var type; @@ -8993,7 +9111,7 @@ function getHostComponentFromComposite(inst) { module.exports = getHostComponentFromComposite; /***/ }), -/* 74 */ +/* 75 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9031,7 +9149,7 @@ function getTextContentAccessor() { module.exports = getTextContentAccessor; /***/ }), -/* 75 */ +/* 76 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9051,8 +9169,8 @@ var _prodInvariant = __webpack_require__(3), _assign = __webpack_require__(4); var ReactCompositeComponent = __webpack_require__(113); -var ReactEmptyComponent = __webpack_require__(63); -var ReactHostComponent = __webpack_require__(65); +var ReactEmptyComponent = __webpack_require__(64); +var ReactHostComponent = __webpack_require__(66); var getNextDebugID = __webpack_require__(167); var invariant = __webpack_require__(1); @@ -9165,7 +9283,7 @@ module.exports = instantiateReactComponent; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 76 */ +/* 77 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9221,7 +9339,7 @@ function isTextInputElement(elem) { module.exports = isTextInputElement; /***/ }), -/* 77 */ +/* 78 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9278,7 +9396,7 @@ if (ExecutionEnvironment.canUseDOM) { module.exports = setTextContent; /***/ }), -/* 78 */ +/* 79 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9460,7 +9578,7 @@ module.exports = traverseAllChildren; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 79 */ +/* 80 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9485,7 +9603,7 @@ var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol module.exports = REACT_ELEMENT_TYPE; /***/ }), -/* 80 */ +/* 81 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9725,7 +9843,7 @@ module.exports = ReactElementValidator; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), -/* 81 */ +/* 82 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9747,7 +9865,7 @@ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; module.exports = ReactPropTypesSecret; /***/ }), -/* 82 */ +/* 83 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9763,7 +9881,7 @@ var _react = __webpack_require__(17); var _react2 = _interopRequireDefault(_react); -var _Tree = __webpack_require__(53); +var _Tree = __webpack_require__(54); var _Tree2 = _interopRequireDefault(_Tree); @@ -9887,7 +10005,7 @@ var BasicExample = function (_React$Component) { exports.default = BasicExample; /***/ }), -/* 83 */ +/* 84 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9903,7 +10021,7 @@ var _react = __webpack_require__(17); var _react2 = _interopRequireDefault(_react); -var _Tree = __webpack_require__(53); +var _Tree = __webpack_require__(54); var _Tree2 = _interopRequireDefault(_Tree); @@ -10028,7 +10146,7 @@ var PessimisticToggleExample = function (_React$Component) { exports.default = PessimisticToggleExample; /***/ }), -/* 84 */ +/* 85 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10038,7 +10156,7 @@ module.exports = __webpack_require__(114); /***/ }), -/* 85 */ +/* 86 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10054,7 +10172,7 @@ var _react = __webpack_require__(17); var _react2 = _interopRequireDefault(_react); -var _nodeShape = __webpack_require__(54); +var _nodeShape = __webpack_require__(55); var _nodeShape2 = _interopRequireDefault(_nodeShape); @@ -10111,16 +10229,29 @@ var TreeNode = function (_React$Component) { }, { key: 'renderCollapseIcon', value: function renderCollapseIcon() { - if (this.props.rawChildren === null) { - return _react2.default.createElement('i', { className: 'fa' }); - } - if (!this.props.expanded) { return _react2.default.createElement('i', { className: 'fa fa-chevron-right' }); } return _react2.default.createElement('i', { className: 'fa fa-chevron-down' }); } + }, { + key: 'renderCollapseButton', + value: function renderCollapseButton() { + if (this.props.rawChildren === null) { + return _react2.default.createElement( + 'span', + { className: 'rct-collapse' }, + _react2.default.createElement('i', { className: 'fa' }) + ); + } + + return _react2.default.createElement( + 'button', + { 'aria-label': 'Toggle', className: 'rct-collapse rct-collapse-btn', title: 'Toggle', onClick: this.onExpand }, + this.renderCollapseIcon() + ); + } }, { key: 'renderCheckboxIcon', value: function renderCheckboxIcon() { @@ -10137,15 +10268,15 @@ var TreeNode = function (_React$Component) { }, { key: 'renderNodeIcon', value: function renderNodeIcon() { - if (this.props.rawChildren !== null) { - if (!this.props.expanded) { - return _react2.default.createElement('i', { className: 'fa fa-folder-o' }); - } + if (this.props.rawChildren === null) { + return _react2.default.createElement('i', { className: 'fa fa-file-o' }); + } - return _react2.default.createElement('i', { className: 'fa fa-folder-open-o' }); + if (!this.props.expanded) { + return _react2.default.createElement('i', { className: 'fa fa-folder-o' }); } - return _react2.default.createElement('i', { className: 'fa fa-file-o' }); + return _react2.default.createElement('i', { className: 'fa fa-folder-open-o' }); } }, { key: 'renderChildren', @@ -10173,11 +10304,7 @@ var TreeNode = function (_React$Component) { _react2.default.createElement( 'span', { className: 'rct-text' }, - _react2.default.createElement( - 'button', - { 'aria-label': 'Toggle', className: 'rct-collapse', title: 'Toggle', onClick: this.onExpand }, - this.renderCollapseIcon() - ), + this.renderCollapseButton(), _react2.default.createElement( 'label', { htmlFor: inputId }, @@ -10218,7 +10345,7 @@ TreeNode.propTypes = { onExpand: _react2.default.PropTypes.func.isRequired, children: _react2.default.PropTypes.node, - rawChildren: _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.shape(_nodeShape2.default)) + rawChildren: _react2.default.PropTypes.arrayOf(_nodeShape2.default) }; TreeNode.defaultProps = { children: null, @@ -10226,46 +10353,6 @@ TreeNode.defaultProps = { }; exports.default = TreeNode; -/***/ }), -/* 86 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); -var autoId = 0; - -/** - * Return a unique DOM ID for an element on the document. - * - * @param {string} prefix - * - * @return {string} - */ -function uniqueDomId() { - var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'unique'; - - var findingId = true; - var id = ''; - - while (findingId) { - id = prefix + '-' + autoId; - - if (document.getElementById(id) === null) { - findingId = false; - } - - autoId += 1; - } - - return id; -} - -exports.default = uniqueDomId; - /***/ }), /* 87 */ /***/ (function(module, exports, __webpack_require__) { @@ -11101,7 +11188,7 @@ module.exports = ARIADOMPropertyConfig; var ReactDOMComponentTree = __webpack_require__(5); -var focusNode = __webpack_require__(56); +var focusNode = __webpack_require__(57); var AutoFocusUtils = { focusDOMComponent: function () { @@ -11518,7 +11605,7 @@ module.exports = BeforeInputEventPlugin; -var CSSProperty = __webpack_require__(58); +var CSSProperty = __webpack_require__(59); var ExecutionEnvironment = __webpack_require__(6); var ReactInstrumentation = __webpack_require__(8); @@ -11742,7 +11829,7 @@ var SyntheticEvent = __webpack_require__(12); var getEventTarget = __webpack_require__(44); var isEventSupported = __webpack_require__(45); -var isTextInputElement = __webpack_require__(76); +var isTextInputElement = __webpack_require__(77); var eventTypes = { change: { @@ -12253,7 +12340,7 @@ var _assign = __webpack_require__(4); var PooledClass = __webpack_require__(14); -var getTextContentAccessor = __webpack_require__(74); +var getTextContentAccessor = __webpack_require__(75); /** * This helper class stores information about text content of a target node, @@ -12568,10 +12655,10 @@ module.exports = HTMLDOMPropertyConfig; var ReactReconciler = __webpack_require__(19); -var instantiateReactComponent = __webpack_require__(75); +var instantiateReactComponent = __webpack_require__(76); var KeyEscapeUtils = __webpack_require__(36); var shouldUpdateReactComponent = __webpack_require__(46); -var traverseAllChildren = __webpack_require__(78); +var traverseAllChildren = __webpack_require__(79); var warning = __webpack_require__(2); var ReactComponentTreeHook; @@ -12770,7 +12857,7 @@ var ReactCurrentOwner = __webpack_require__(11); var ReactErrorUtils = __webpack_require__(39); var ReactInstanceMap = __webpack_require__(24); var ReactInstrumentation = __webpack_require__(8); -var ReactNodeTypes = __webpack_require__(68); +var ReactNodeTypes = __webpack_require__(69); var ReactReconciler = __webpack_require__(19); if (process.env.NODE_ENV !== 'production') { @@ -13673,13 +13760,13 @@ module.exports = ReactCompositeComponent; var ReactDOMComponentTree = __webpack_require__(5); var ReactDefaultInjection = __webpack_require__(131); -var ReactMount = __webpack_require__(67); +var ReactMount = __webpack_require__(68); var ReactReconciler = __webpack_require__(19); var ReactUpdates = __webpack_require__(10); var ReactVersion = __webpack_require__(146); var findDOMNode = __webpack_require__(163); -var getHostComponentFromComposite = __webpack_require__(73); +var getHostComponentFromComposite = __webpack_require__(74); var renderSubtreeIntoContainer = __webpack_require__(171); var warning = __webpack_require__(2); @@ -13796,15 +13883,15 @@ var CSSPropertyOperations = __webpack_require__(104); var DOMLazyTree = __webpack_require__(18); var DOMNamespaces = __webpack_require__(34); var DOMProperty = __webpack_require__(13); -var DOMPropertyOperations = __webpack_require__(60); +var DOMPropertyOperations = __webpack_require__(61); var EventPluginHub = __webpack_require__(22); var EventPluginRegistry = __webpack_require__(26); var ReactBrowserEventEmitter = __webpack_require__(27); -var ReactDOMComponentFlags = __webpack_require__(61); +var ReactDOMComponentFlags = __webpack_require__(62); var ReactDOMComponentTree = __webpack_require__(5); var ReactDOMInput = __webpack_require__(120); var ReactDOMOption = __webpack_require__(123); -var ReactDOMSelect = __webpack_require__(62); +var ReactDOMSelect = __webpack_require__(63); var ReactDOMTextarea = __webpack_require__(126); var ReactInstrumentation = __webpack_require__(8); var ReactMultiChild = __webpack_require__(139); @@ -14963,7 +15050,7 @@ module.exports = ReactDOMIDOperations; var _prodInvariant = __webpack_require__(3), _assign = __webpack_require__(4); -var DOMPropertyOperations = __webpack_require__(60); +var DOMPropertyOperations = __webpack_require__(61); var LinkedValueUtils = __webpack_require__(37); var ReactDOMComponentTree = __webpack_require__(5); var ReactUpdates = __webpack_require__(10); @@ -15396,7 +15483,7 @@ var _assign = __webpack_require__(4); var React = __webpack_require__(20); var ReactDOMComponentTree = __webpack_require__(5); -var ReactDOMSelect = __webpack_require__(62); +var ReactDOMSelect = __webpack_require__(63); var warning = __webpack_require__(2); var didWarnInvalidOptionChildren = false; @@ -15524,7 +15611,7 @@ module.exports = ReactDOMOption; var ExecutionEnvironment = __webpack_require__(6); var getNodeForCharacterOffset = __webpack_require__(168); -var getTextContentAccessor = __webpack_require__(74); +var getTextContentAccessor = __webpack_require__(75); /** * While `isCollapsed` is available on the Selection object and `collapsed` @@ -16930,7 +17017,7 @@ module.exports = ReactEventEmitterMixin; var _assign = __webpack_require__(4); -var EventListener = __webpack_require__(55); +var EventListener = __webpack_require__(56); var ExecutionEnvironment = __webpack_require__(6); var PooledClass = __webpack_require__(14); var ReactDOMComponentTree = __webpack_require__(5); @@ -17131,9 +17218,9 @@ var DOMProperty = __webpack_require__(13); var EventPluginHub = __webpack_require__(22); var EventPluginUtils = __webpack_require__(35); var ReactComponentEnvironment = __webpack_require__(38); -var ReactEmptyComponent = __webpack_require__(63); +var ReactEmptyComponent = __webpack_require__(64); var ReactBrowserEventEmitter = __webpack_require__(27); -var ReactHostComponent = __webpack_require__(65); +var ReactHostComponent = __webpack_require__(66); var ReactUpdates = __webpack_require__(10); var ReactInjection = { @@ -17853,10 +17940,10 @@ module.exports = ReactPropTypeLocationNames; var _assign = __webpack_require__(4); -var CallbackQueue = __webpack_require__(59); +var CallbackQueue = __webpack_require__(60); var PooledClass = __webpack_require__(14); var ReactBrowserEventEmitter = __webpack_require__(27); -var ReactInputSelection = __webpack_require__(66); +var ReactInputSelection = __webpack_require__(67); var ReactInstrumentation = __webpack_require__(8); var Transaction = __webpack_require__(29); var ReactUpdateQueue = __webpack_require__(40); @@ -18699,11 +18786,11 @@ module.exports = SVGDOMPropertyConfig; var EventPropagators = __webpack_require__(23); var ExecutionEnvironment = __webpack_require__(6); var ReactDOMComponentTree = __webpack_require__(5); -var ReactInputSelection = __webpack_require__(66); +var ReactInputSelection = __webpack_require__(67); var SyntheticEvent = __webpack_require__(12); -var getActiveElement = __webpack_require__(57); -var isTextInputElement = __webpack_require__(76); +var getActiveElement = __webpack_require__(58); +var isTextInputElement = __webpack_require__(77); var shallowEqual = __webpack_require__(32); var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11; @@ -18895,7 +18982,7 @@ module.exports = SelectEventPlugin; var _prodInvariant = __webpack_require__(3); -var EventListener = __webpack_require__(55); +var EventListener = __webpack_require__(56); var EventPropagators = __webpack_require__(23); var ReactDOMComponentTree = __webpack_require__(5); var SyntheticAnimationEvent = __webpack_require__(150); @@ -19672,7 +19759,7 @@ module.exports = adler32; var _prodInvariant = __webpack_require__(3); var ReactPropTypeLocationNames = __webpack_require__(141); -var ReactPropTypesSecret = __webpack_require__(69); +var ReactPropTypesSecret = __webpack_require__(70); var invariant = __webpack_require__(1); var warning = __webpack_require__(2); @@ -19762,7 +19849,7 @@ module.exports = checkReactTypeSpec; -var CSSProperty = __webpack_require__(58); +var CSSProperty = __webpack_require__(59); var warning = __webpack_require__(2); var isUnitlessNumber = CSSProperty.isUnitlessNumber; @@ -19853,7 +19940,7 @@ var ReactCurrentOwner = __webpack_require__(11); var ReactDOMComponentTree = __webpack_require__(5); var ReactInstanceMap = __webpack_require__(24); -var getHostComponentFromComposite = __webpack_require__(73); +var getHostComponentFromComposite = __webpack_require__(74); var invariant = __webpack_require__(1); var warning = __webpack_require__(2); @@ -19915,7 +20002,7 @@ module.exports = findDOMNode; var KeyEscapeUtils = __webpack_require__(36); -var traverseAllChildren = __webpack_require__(78); +var traverseAllChildren = __webpack_require__(79); var warning = __webpack_require__(2); var ReactComponentTreeHook; @@ -20390,7 +20477,7 @@ module.exports = quoteAttributeValueForBrowser; -var ReactMount = __webpack_require__(67); +var ReactMount = __webpack_require__(68); module.exports = ReactMount.renderSubtreeIntoContainer; @@ -21521,7 +21608,7 @@ var ReactElement = __webpack_require__(15); */ var createDOMFactory = ReactElement.createFactory; if (process.env.NODE_ENV !== 'production') { - var ReactElementValidator = __webpack_require__(80); + var ReactElementValidator = __webpack_require__(81); createDOMFactory = ReactElementValidator.createFactory; } @@ -21690,7 +21777,7 @@ module.exports = ReactDOMFactories; var ReactElement = __webpack_require__(15); var ReactPropTypeLocationNames = __webpack_require__(50); -var ReactPropTypesSecret = __webpack_require__(81); +var ReactPropTypesSecret = __webpack_require__(82); var emptyFunction = __webpack_require__(9); var getIteratorFn = __webpack_require__(52); @@ -22197,7 +22284,7 @@ module.exports = '15.4.2'; var _prodInvariant = __webpack_require__(16); var ReactPropTypeLocationNames = __webpack_require__(50); -var ReactPropTypesSecret = __webpack_require__(81); +var ReactPropTypesSecret = __webpack_require__(82); var invariant = __webpack_require__(1); var warning = __webpack_require__(2); @@ -22334,7 +22421,7 @@ module.exports = onlyChild; var _prodInvariant = __webpack_require__(16); var ReactCurrentOwner = __webpack_require__(11); -var REACT_ELEMENT_TYPE = __webpack_require__(79); +var REACT_ELEMENT_TYPE = __webpack_require__(80); var getIteratorFn = __webpack_require__(52); var invariant = __webpack_require__(1); @@ -22502,20 +22589,275 @@ module.exports = traverseAllChildren; "use strict"; +module.exports = __webpack_require__(186); + + +/***/ }), +/* 184 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var alphabet = __webpack_require__(53); + +/** + * Decode the id to get the version and worker + * Mainly for debugging and testing. + * @param id - the shortid-generated id. + */ +function decode(id) { + var characters = alphabet.shuffled(); + return { + version: characters.indexOf(id.substr(0, 1)) & 0x0f, + worker: characters.indexOf(id.substr(1, 1)) & 0x0f + }; +} + +module.exports = decode; + + +/***/ }), +/* 185 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var randomByte = __webpack_require__(188); + +function encode(lookup, number) { + var loopCounter = 0; + var done; + + var str = ''; + + while (!done) { + str = str + lookup( ( (number >> (4 * loopCounter)) & 0x0f ) | randomByte() ); + done = number < (Math.pow(16, loopCounter + 1 ) ); + loopCounter++; + } + return str; +} + +module.exports = encode; + + +/***/ }), +/* 186 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var alphabet = __webpack_require__(53); +var encode = __webpack_require__(185); +var decode = __webpack_require__(184); +var isValid = __webpack_require__(187); + +// Ignore all milliseconds before a certain time to reduce the size of the date entropy without sacrificing uniqueness. +// This number should be updated every year or so to keep the generated id short. +// To regenerate `new Date() - 0` and bump the version. Always bump the version! +var REDUCE_TIME = 1459707606518; + +// don't change unless we change the algos or REDUCE_TIME +// must be an integer and less than 16 +var version = 6; + +// if you are using cluster or multiple servers use this to make each instance +// has a unique value for worker +// Note: I don't know if this is automatically set when using third +// party cluster solutions such as pm2. +var clusterWorkerId = __webpack_require__(190) || 0; + +// Counter is used when shortid is called multiple times in one second. +var counter; + +// Remember the last time shortid was called in case counter is needed. +var previousSeconds; + +/** + * Generate unique id + * Returns string id + */ +function generate() { + + var str = ''; + + var seconds = Math.floor((Date.now() - REDUCE_TIME) * 0.001); + + if (seconds === previousSeconds) { + counter++; + } else { + counter = 0; + previousSeconds = seconds; + } + + str = str + encode(alphabet.lookup, version); + str = str + encode(alphabet.lookup, clusterWorkerId); + if (counter > 0) { + str = str + encode(alphabet.lookup, counter); + } + str = str + encode(alphabet.lookup, seconds); + + return str; +} + + +/** + * Set the seed. + * Highly recommended if you don't want people to try to figure out your id schema. + * exposed as shortid.seed(int) + * @param seed Integer value to seed the random alphabet. ALWAYS USE THE SAME SEED or you might get overlaps. + */ +function seed(seedValue) { + alphabet.seed(seedValue); + return module.exports; +} + +/** + * Set the cluster worker or machine id + * exposed as shortid.worker(int) + * @param workerId worker must be positive integer. Number less than 16 is recommended. + * returns shortid module so it can be chained. + */ +function worker(workerId) { + clusterWorkerId = workerId; + return module.exports; +} + +/** + * + * sets new characters to use in the alphabet + * returns the shuffled alphabet + */ +function characters(newCharacters) { + if (newCharacters !== undefined) { + alphabet.characters(newCharacters); + } + + return alphabet.shuffled(); +} + + +// Export all other functions as properties of the generate function +module.exports = generate; +module.exports.generate = generate; +module.exports.seed = seed; +module.exports.worker = worker; +module.exports.characters = characters; +module.exports.decode = decode; +module.exports.isValid = isValid; + + +/***/ }), +/* 187 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var alphabet = __webpack_require__(53); + +function isShortId(id) { + if (!id || typeof id !== 'string' || id.length < 6 ) { + return false; + } + + var characters = alphabet.characters(); + var len = id.length; + for(var i = 0; i < len;i++) { + if (characters.indexOf(id[i]) === -1) { + return false; + } + } + return true; +} + +module.exports = isShortId; + + +/***/ }), +/* 188 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var crypto = typeof window === 'object' && (window.crypto || window.msCrypto); // IE 11 uses window.msCrypto + +function randomByte() { + if (!crypto || !crypto.getRandomValues) { + return Math.floor(Math.random() * 256) & 0x30; + } + var dest = new Uint8Array(1); + crypto.getRandomValues(dest); + return dest[0] & 0x30; +} + +module.exports = randomByte; + + +/***/ }), +/* 189 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +// Found this seed-based random generator somewhere +// Based on The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu) + +var seed = 1; + +/** + * return a random number based on a seed + * @param seed + * @returns {number} + */ +function getNextValue() { + seed = (seed * 9301 + 49297) % 233280; + return seed/(233280.0); +} + +function setSeed(_seed_) { + seed = _seed_; +} + +module.exports = { + nextValue: getNextValue, + seed: setSeed +}; + + +/***/ }), +/* 190 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +module.exports = 0; + + +/***/ }), +/* 191 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + var _react = __webpack_require__(17); var _react2 = _interopRequireDefault(_react); -var _reactDom = __webpack_require__(84); +var _reactDom = __webpack_require__(85); var _reactDom2 = _interopRequireDefault(_reactDom); -var _BasicExample = __webpack_require__(82); +var _BasicExample = __webpack_require__(83); var _BasicExample2 = _interopRequireDefault(_BasicExample); -var _PessimisticToggleExample = __webpack_require__(83); +var _PessimisticToggleExample = __webpack_require__(84); var _PessimisticToggleExample2 = _interopRequireDefault(_PessimisticToggleExample); diff --git a/examples/dist/style.css b/examples/dist/style.css index 8a944ec9..8c1661b5 100644 --- a/examples/dist/style.css +++ b/examples/dist/style.css @@ -55,13 +55,16 @@ .rct-collapse { border: 0; background: none; - cursor: pointer; padding: 0; line-height: normal; color: inherit; font-size: 12px; } +.rct-collapse.rct-collapse-btn { + cursor: pointer; +} + .rct-collapse .fa-chevron-right, .rct-collapse .fa-chevron-down { text-align: center; diff --git a/package.json b/package.json index 0d755ec7..040fdcc3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-checkbox-tree", - "version": "0.4.1", + "version": "0.4.2", "description": "React component for checkbox trees.", "author": "Jake Zatecky", "license": "MIT",