├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitignore ├── CNAME ├── README.md ├── bower.json ├── dist ├── react-cheat-sheet.js └── react-cheat-sheet.min.js ├── example └── src │ ├── .gitignore │ ├── example.js │ ├── example.less │ └── index.html ├── gulpfile.js ├── lib ├── ReactCheatSheet.js ├── ReferenceItem.js ├── assignSharedDefaults.js ├── data.js ├── data │ ├── ReactDOM.js │ ├── ReactDOM_Server.js │ ├── React_Lifecycle.js │ ├── React_PropTypes.js │ ├── React_Spec.js │ └── React_TopLevel.js ├── styles.js └── vendor │ └── Prism.js ├── package.json └── src ├── ReactCheatSheet.js ├── ReferenceItem.js ├── assignSharedDefaults.js ├── data.js ├── data ├── ReactDOM.js ├── ReactDOM_Server.js ├── React_Lifecycle.js ├── React_PropTypes.js ├── React_Spec.js └── React_TopLevel.js ├── styles.js └── vendor └── Prism.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs 2 | # editorconfig.org 3 | root = true 4 | 5 | [*] 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = false 9 | insert_final_newline = true 10 | indent_style = tab 11 | 12 | [*.json] 13 | indent_style = space 14 | indent_size = 2 15 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | .publish/* 2 | dist/* 3 | example/dist/* 4 | lib/* 5 | node_modules/* 6 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "env": { 4 | "browser": true, 5 | "node": true 6 | }, 7 | "plugins": [ 8 | "react" 9 | ], 10 | "rules": { 11 | "curly": [2, "multi-line"], 12 | "quotes": [2, "single", "avoid-escape"], 13 | "react/display-name": 0, 14 | "react/jsx-boolean-value": 1, 15 | "react/jsx-quotes": 1, 16 | "react/jsx-no-undef": 1, 17 | "react/jsx-sort-props": 0, 18 | "react/jsx-sort-prop-types": 1, 19 | "react/jsx-uses-react": 1, 20 | "react/jsx-uses-vars": 1, 21 | "react/no-did-mount-set-state": 1, 22 | "react/no-did-update-set-state": 1, 23 | "react/no-multi-comp": 1, 24 | "react/no-unknown-property": 1, 25 | "react/prop-types": 1, 26 | "react/react-in-jsx-scope": 1, 27 | "react/self-closing-comp": 1, 28 | "react/wrap-multilines": 1, 29 | "semi": 2, 30 | "strict": 0 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Coverage tools 11 | lib-cov 12 | coverage 13 | coverage.html 14 | .cover* 15 | 16 | # Dependency directory 17 | node_modules 18 | 19 | # Example build directory 20 | example/dist 21 | .publish 22 | 23 | # Editor and other tmp files 24 | *.swp 25 | *.un~ 26 | *.iml 27 | *.ipr 28 | *.iws 29 | *.sublime-* 30 | .idea/ 31 | *.DS_Store 32 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | reactcheatsheet.com 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React Cheat Sheet 2 | 3 | __COMPONENT DESCRIPTION GOES HERE__ 4 | 5 | 6 | ## Demo & Examples 7 | 8 | Live demo: [chantastic.github.io/react-cheat-sheet](http://chantastic.github.io/react-cheat-sheet/) 9 | 10 | To build the examples locally, run: 11 | 12 | ``` 13 | npm install 14 | npm start 15 | ``` 16 | 17 | Then open [`localhost:8000`](http://localhost:8000) in a browser. 18 | 19 | 20 | ## Installation 21 | 22 | The easiest way to use react-cheat-sheet is to install it from NPM and include it in your own React build process (using [Browserify](http://browserify.org), [Webpack](http://webpack.github.io/), etc). 23 | 24 | You can also use the standalone build by including `dist/react-cheat-sheet.js` in your page. If you use this, make sure you have already included React, and it is available as a global variable. 25 | 26 | ``` 27 | npm install react-cheat-sheet --save 28 | ``` 29 | 30 | 31 | ## Usage 32 | 33 | __EXPLAIN USAGE HERE__ 34 | 35 | ``` 36 | var ReactCheatSheet = require('react-cheat-sheet'); 37 | 38 | Example 39 | ``` 40 | 41 | ### Properties 42 | 43 | * __DOCUMENT PROPERTIES HERE__ 44 | 45 | ### Notes 46 | 47 | __ADDITIONAL USAGE NOTES__ 48 | 49 | 50 | ## Development (`src`, `lib` and the build process) 51 | 52 | **NOTE:** The source code for the component is in `src`. A transpiled CommonJS version (generated with Babel) is available in `lib` for use with node.js, browserify and webpack. A UMD bundle is also built to `dist`, which can be included without the need for any build system. 53 | 54 | To build, watch and serve the examples (which will also watch the component source), run `npm start`. If you just want to watch changes to `src` and rebuild `lib`, run `npm run watch` (this is useful if you are working with `npm link`). 55 | 56 | ## License 57 | 58 | __PUT LICENSE HERE__ 59 | 60 | Copyright (c) 2015 Michael Chan. 61 | 62 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-cheat-sheet", 3 | "version": "0.0.1", 4 | "description": "React Cheat Sheet", 5 | "main": "dist/react-cheat-sheet.min.js", 6 | "homepage": "https://github.com/chantastic/react-cheat-sheet", 7 | "authors": [ 8 | "Michael Chan" 9 | ], 10 | "moduleType": [ 11 | "amd", 12 | "globals", 13 | "node" 14 | ], 15 | "keywords": [ 16 | "react", 17 | "react-component" 18 | ], 19 | "license": "MIT", 20 | "ignore": [ 21 | ".editorconfig", 22 | ".gitignore", 23 | "package.json", 24 | "src", 25 | "node_modules", 26 | "example", 27 | "test" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /dist/react-cheat-sheet.js: -------------------------------------------------------------------------------- 1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ReactCheatSheet = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 4 | * Build: `lodash modern modularize exports="npm" -o ./` 5 | * Copyright 2012-2015 The Dojo Foundation 6 | * Based on Underscore.js 1.7.0 7 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 8 | * Available under MIT license 9 | */ 10 | 11 | /** 12 | * A specialized version of `_.filter` for arrays without support for callback 13 | * shorthands or `this` binding. 14 | * 15 | * @private 16 | * @param {Array} array The array to iterate over. 17 | * @param {Function} predicate The function invoked per iteration. 18 | * @returns {Array} Returns the new filtered array. 19 | */ 20 | function arrayFilter(array, predicate) { 21 | var index = -1, 22 | length = array.length, 23 | resIndex = -1, 24 | result = []; 25 | 26 | while (++index < length) { 27 | var value = array[index]; 28 | if (predicate(value, index, array)) { 29 | result[++resIndex] = value; 30 | } 31 | } 32 | return result; 33 | } 34 | 35 | module.exports = arrayFilter; 36 | 37 | },{}],2:[function(require,module,exports){ 38 | /** 39 | * lodash 3.3.1 (Custom Build) 40 | * Build: `lodash modern modularize exports="npm" -o ./` 41 | * Copyright 2012-2015 The Dojo Foundation 42 | * Based on Underscore.js 1.8.3 43 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 44 | * Available under MIT license 45 | */ 46 | var baseIsEqual = require('lodash._baseisequal'), 47 | bindCallback = require('lodash._bindcallback'), 48 | isArray = require('lodash.isarray'), 49 | pairs = require('lodash.pairs'); 50 | 51 | /** Used to match property names within property paths. */ 52 | var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/, 53 | reIsPlainProp = /^\w*$/, 54 | rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g; 55 | 56 | /** Used to match backslashes in property paths. */ 57 | var reEscapeChar = /\\(\\)?/g; 58 | 59 | /** 60 | * Converts `value` to a string if it's not one. An empty string is returned 61 | * for `null` or `undefined` values. 62 | * 63 | * @private 64 | * @param {*} value The value to process. 65 | * @returns {string} Returns the string. 66 | */ 67 | function baseToString(value) { 68 | return value == null ? '' : (value + ''); 69 | } 70 | 71 | /** 72 | * The base implementation of `_.callback` which supports specifying the 73 | * number of arguments to provide to `func`. 74 | * 75 | * @private 76 | * @param {*} [func=_.identity] The value to convert to a callback. 77 | * @param {*} [thisArg] The `this` binding of `func`. 78 | * @param {number} [argCount] The number of arguments to provide to `func`. 79 | * @returns {Function} Returns the callback. 80 | */ 81 | function baseCallback(func, thisArg, argCount) { 82 | var type = typeof func; 83 | if (type == 'function') { 84 | return thisArg === undefined 85 | ? func 86 | : bindCallback(func, thisArg, argCount); 87 | } 88 | if (func == null) { 89 | return identity; 90 | } 91 | if (type == 'object') { 92 | return baseMatches(func); 93 | } 94 | return thisArg === undefined 95 | ? property(func) 96 | : baseMatchesProperty(func, thisArg); 97 | } 98 | 99 | /** 100 | * The base implementation of `get` without support for string paths 101 | * and default values. 102 | * 103 | * @private 104 | * @param {Object} object The object to query. 105 | * @param {Array} path The path of the property to get. 106 | * @param {string} [pathKey] The key representation of path. 107 | * @returns {*} Returns the resolved value. 108 | */ 109 | function baseGet(object, path, pathKey) { 110 | if (object == null) { 111 | return; 112 | } 113 | if (pathKey !== undefined && pathKey in toObject(object)) { 114 | path = [pathKey]; 115 | } 116 | var index = 0, 117 | length = path.length; 118 | 119 | while (object != null && index < length) { 120 | object = object[path[index++]]; 121 | } 122 | return (index && index == length) ? object : undefined; 123 | } 124 | 125 | /** 126 | * The base implementation of `_.isMatch` without support for callback 127 | * shorthands and `this` binding. 128 | * 129 | * @private 130 | * @param {Object} object The object to inspect. 131 | * @param {Array} matchData The propery names, values, and compare flags to match. 132 | * @param {Function} [customizer] The function to customize comparing objects. 133 | * @returns {boolean} Returns `true` if `object` is a match, else `false`. 134 | */ 135 | function baseIsMatch(object, matchData, customizer) { 136 | var index = matchData.length, 137 | length = index, 138 | noCustomizer = !customizer; 139 | 140 | if (object == null) { 141 | return !length; 142 | } 143 | object = toObject(object); 144 | while (index--) { 145 | var data = matchData[index]; 146 | if ((noCustomizer && data[2]) 147 | ? data[1] !== object[data[0]] 148 | : !(data[0] in object) 149 | ) { 150 | return false; 151 | } 152 | } 153 | while (++index < length) { 154 | data = matchData[index]; 155 | var key = data[0], 156 | objValue = object[key], 157 | srcValue = data[1]; 158 | 159 | if (noCustomizer && data[2]) { 160 | if (objValue === undefined && !(key in object)) { 161 | return false; 162 | } 163 | } else { 164 | var result = customizer ? customizer(objValue, srcValue, key) : undefined; 165 | if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) { 166 | return false; 167 | } 168 | } 169 | } 170 | return true; 171 | } 172 | 173 | /** 174 | * The base implementation of `_.matches` which does not clone `source`. 175 | * 176 | * @private 177 | * @param {Object} source The object of property values to match. 178 | * @returns {Function} Returns the new function. 179 | */ 180 | function baseMatches(source) { 181 | var matchData = getMatchData(source); 182 | if (matchData.length == 1 && matchData[0][2]) { 183 | var key = matchData[0][0], 184 | value = matchData[0][1]; 185 | 186 | return function(object) { 187 | if (object == null) { 188 | return false; 189 | } 190 | return object[key] === value && (value !== undefined || (key in toObject(object))); 191 | }; 192 | } 193 | return function(object) { 194 | return baseIsMatch(object, matchData); 195 | }; 196 | } 197 | 198 | /** 199 | * The base implementation of `_.matchesProperty` which does not clone `srcValue`. 200 | * 201 | * @private 202 | * @param {string} path The path of the property to get. 203 | * @param {*} srcValue The value to compare. 204 | * @returns {Function} Returns the new function. 205 | */ 206 | function baseMatchesProperty(path, srcValue) { 207 | var isArr = isArray(path), 208 | isCommon = isKey(path) && isStrictComparable(srcValue), 209 | pathKey = (path + ''); 210 | 211 | path = toPath(path); 212 | return function(object) { 213 | if (object == null) { 214 | return false; 215 | } 216 | var key = pathKey; 217 | object = toObject(object); 218 | if ((isArr || !isCommon) && !(key in object)) { 219 | object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); 220 | if (object == null) { 221 | return false; 222 | } 223 | key = last(path); 224 | object = toObject(object); 225 | } 226 | return object[key] === srcValue 227 | ? (srcValue !== undefined || (key in object)) 228 | : baseIsEqual(srcValue, object[key], undefined, true); 229 | }; 230 | } 231 | 232 | /** 233 | * The base implementation of `_.property` without support for deep paths. 234 | * 235 | * @private 236 | * @param {string} key The key of the property to get. 237 | * @returns {Function} Returns the new function. 238 | */ 239 | function baseProperty(key) { 240 | return function(object) { 241 | return object == null ? undefined : object[key]; 242 | }; 243 | } 244 | 245 | /** 246 | * A specialized version of `baseProperty` which supports deep paths. 247 | * 248 | * @private 249 | * @param {Array|string} path The path of the property to get. 250 | * @returns {Function} Returns the new function. 251 | */ 252 | function basePropertyDeep(path) { 253 | var pathKey = (path + ''); 254 | path = toPath(path); 255 | return function(object) { 256 | return baseGet(object, path, pathKey); 257 | }; 258 | } 259 | 260 | /** 261 | * The base implementation of `_.slice` without an iteratee call guard. 262 | * 263 | * @private 264 | * @param {Array} array The array to slice. 265 | * @param {number} [start=0] The start position. 266 | * @param {number} [end=array.length] The end position. 267 | * @returns {Array} Returns the slice of `array`. 268 | */ 269 | function baseSlice(array, start, end) { 270 | var index = -1, 271 | length = array.length; 272 | 273 | start = start == null ? 0 : (+start || 0); 274 | if (start < 0) { 275 | start = -start > length ? 0 : (length + start); 276 | } 277 | end = (end === undefined || end > length) ? length : (+end || 0); 278 | if (end < 0) { 279 | end += length; 280 | } 281 | length = start > end ? 0 : ((end - start) >>> 0); 282 | start >>>= 0; 283 | 284 | var result = Array(length); 285 | while (++index < length) { 286 | result[index] = array[index + start]; 287 | } 288 | return result; 289 | } 290 | 291 | /** 292 | * Gets the propery names, values, and compare flags of `object`. 293 | * 294 | * @private 295 | * @param {Object} object The object to query. 296 | * @returns {Array} Returns the match data of `object`. 297 | */ 298 | function getMatchData(object) { 299 | var result = pairs(object), 300 | length = result.length; 301 | 302 | while (length--) { 303 | result[length][2] = isStrictComparable(result[length][1]); 304 | } 305 | return result; 306 | } 307 | 308 | /** 309 | * Checks if `value` is a property name and not a property path. 310 | * 311 | * @private 312 | * @param {*} value The value to check. 313 | * @param {Object} [object] The object to query keys on. 314 | * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 315 | */ 316 | function isKey(value, object) { 317 | var type = typeof value; 318 | if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') { 319 | return true; 320 | } 321 | if (isArray(value)) { 322 | return false; 323 | } 324 | var result = !reIsDeepProp.test(value); 325 | return result || (object != null && value in toObject(object)); 326 | } 327 | 328 | /** 329 | * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 330 | * 331 | * @private 332 | * @param {*} value The value to check. 333 | * @returns {boolean} Returns `true` if `value` if suitable for strict 334 | * equality comparisons, else `false`. 335 | */ 336 | function isStrictComparable(value) { 337 | return value === value && !isObject(value); 338 | } 339 | 340 | /** 341 | * Converts `value` to an object if it's not one. 342 | * 343 | * @private 344 | * @param {*} value The value to process. 345 | * @returns {Object} Returns the object. 346 | */ 347 | function toObject(value) { 348 | return isObject(value) ? value : Object(value); 349 | } 350 | 351 | /** 352 | * Converts `value` to property path array if it's not one. 353 | * 354 | * @private 355 | * @param {*} value The value to process. 356 | * @returns {Array} Returns the property path array. 357 | */ 358 | function toPath(value) { 359 | if (isArray(value)) { 360 | return value; 361 | } 362 | var result = []; 363 | baseToString(value).replace(rePropName, function(match, number, quote, string) { 364 | result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); 365 | }); 366 | return result; 367 | } 368 | 369 | /** 370 | * Gets the last element of `array`. 371 | * 372 | * @static 373 | * @memberOf _ 374 | * @category Array 375 | * @param {Array} array The array to query. 376 | * @returns {*} Returns the last element of `array`. 377 | * @example 378 | * 379 | * _.last([1, 2, 3]); 380 | * // => 3 381 | */ 382 | function last(array) { 383 | var length = array ? array.length : 0; 384 | return length ? array[length - 1] : undefined; 385 | } 386 | 387 | /** 388 | * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. 389 | * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 390 | * 391 | * @static 392 | * @memberOf _ 393 | * @category Lang 394 | * @param {*} value The value to check. 395 | * @returns {boolean} Returns `true` if `value` is an object, else `false`. 396 | * @example 397 | * 398 | * _.isObject({}); 399 | * // => true 400 | * 401 | * _.isObject([1, 2, 3]); 402 | * // => true 403 | * 404 | * _.isObject(1); 405 | * // => false 406 | */ 407 | function isObject(value) { 408 | // Avoid a V8 JIT bug in Chrome 19-20. 409 | // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. 410 | var type = typeof value; 411 | return !!value && (type == 'object' || type == 'function'); 412 | } 413 | 414 | /** 415 | * This method returns the first argument provided to it. 416 | * 417 | * @static 418 | * @memberOf _ 419 | * @category Utility 420 | * @param {*} value Any value. 421 | * @returns {*} Returns `value`. 422 | * @example 423 | * 424 | * var object = { 'user': 'fred' }; 425 | * 426 | * _.identity(object) === object; 427 | * // => true 428 | */ 429 | function identity(value) { 430 | return value; 431 | } 432 | 433 | /** 434 | * Creates a function that returns the property value at `path` on a 435 | * given object. 436 | * 437 | * @static 438 | * @memberOf _ 439 | * @category Utility 440 | * @param {Array|string} path The path of the property to get. 441 | * @returns {Function} Returns the new function. 442 | * @example 443 | * 444 | * var objects = [ 445 | * { 'a': { 'b': { 'c': 2 } } }, 446 | * { 'a': { 'b': { 'c': 1 } } } 447 | * ]; 448 | * 449 | * _.map(objects, _.property('a.b.c')); 450 | * // => [2, 1] 451 | * 452 | * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c'); 453 | * // => [1, 2] 454 | */ 455 | function property(path) { 456 | return isKey(path) ? baseProperty(path) : basePropertyDeep(path); 457 | } 458 | 459 | module.exports = baseCallback; 460 | 461 | },{"lodash._baseisequal":5,"lodash._bindcallback":6,"lodash.isarray":10,"lodash.pairs":13}],3:[function(require,module,exports){ 462 | /** 463 | * lodash 3.0.4 (Custom Build) 464 | * Build: `lodash modern modularize exports="npm" -o ./` 465 | * Copyright 2012-2015 The Dojo Foundation 466 | * Based on Underscore.js 1.8.3 467 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 468 | * Available under MIT license 469 | */ 470 | var keys = require('lodash.keys'); 471 | 472 | /** 473 | * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) 474 | * of an array-like value. 475 | */ 476 | var MAX_SAFE_INTEGER = 9007199254740991; 477 | 478 | /** 479 | * The base implementation of `_.forEach` without support for callback 480 | * shorthands and `this` binding. 481 | * 482 | * @private 483 | * @param {Array|Object|string} collection The collection to iterate over. 484 | * @param {Function} iteratee The function invoked per iteration. 485 | * @returns {Array|Object|string} Returns `collection`. 486 | */ 487 | var baseEach = createBaseEach(baseForOwn); 488 | 489 | /** 490 | * The base implementation of `baseForIn` and `baseForOwn` which iterates 491 | * over `object` properties returned by `keysFunc` invoking `iteratee` for 492 | * each property. Iteratee functions may exit iteration early by explicitly 493 | * returning `false`. 494 | * 495 | * @private 496 | * @param {Object} object The object to iterate over. 497 | * @param {Function} iteratee The function invoked per iteration. 498 | * @param {Function} keysFunc The function to get the keys of `object`. 499 | * @returns {Object} Returns `object`. 500 | */ 501 | var baseFor = createBaseFor(); 502 | 503 | /** 504 | * The base implementation of `_.forOwn` without support for callback 505 | * shorthands and `this` binding. 506 | * 507 | * @private 508 | * @param {Object} object The object to iterate over. 509 | * @param {Function} iteratee The function invoked per iteration. 510 | * @returns {Object} Returns `object`. 511 | */ 512 | function baseForOwn(object, iteratee) { 513 | return baseFor(object, iteratee, keys); 514 | } 515 | 516 | /** 517 | * The base implementation of `_.property` without support for deep paths. 518 | * 519 | * @private 520 | * @param {string} key The key of the property to get. 521 | * @returns {Function} Returns the new function. 522 | */ 523 | function baseProperty(key) { 524 | return function(object) { 525 | return object == null ? undefined : object[key]; 526 | }; 527 | } 528 | 529 | /** 530 | * Creates a `baseEach` or `baseEachRight` function. 531 | * 532 | * @private 533 | * @param {Function} eachFunc The function to iterate over a collection. 534 | * @param {boolean} [fromRight] Specify iterating from right to left. 535 | * @returns {Function} Returns the new base function. 536 | */ 537 | function createBaseEach(eachFunc, fromRight) { 538 | return function(collection, iteratee) { 539 | var length = collection ? getLength(collection) : 0; 540 | if (!isLength(length)) { 541 | return eachFunc(collection, iteratee); 542 | } 543 | var index = fromRight ? length : -1, 544 | iterable = toObject(collection); 545 | 546 | while ((fromRight ? index-- : ++index < length)) { 547 | if (iteratee(iterable[index], index, iterable) === false) { 548 | break; 549 | } 550 | } 551 | return collection; 552 | }; 553 | } 554 | 555 | /** 556 | * Creates a base function for `_.forIn` or `_.forInRight`. 557 | * 558 | * @private 559 | * @param {boolean} [fromRight] Specify iterating from right to left. 560 | * @returns {Function} Returns the new base function. 561 | */ 562 | function createBaseFor(fromRight) { 563 | return function(object, iteratee, keysFunc) { 564 | var iterable = toObject(object), 565 | props = keysFunc(object), 566 | length = props.length, 567 | index = fromRight ? length : -1; 568 | 569 | while ((fromRight ? index-- : ++index < length)) { 570 | var key = props[index]; 571 | if (iteratee(iterable[key], key, iterable) === false) { 572 | break; 573 | } 574 | } 575 | return object; 576 | }; 577 | } 578 | 579 | /** 580 | * Gets the "length" property value of `object`. 581 | * 582 | * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) 583 | * that affects Safari on at least iOS 8.1-8.3 ARM64. 584 | * 585 | * @private 586 | * @param {Object} object The object to query. 587 | * @returns {*} Returns the "length" value. 588 | */ 589 | var getLength = baseProperty('length'); 590 | 591 | /** 592 | * Checks if `value` is a valid array-like length. 593 | * 594 | * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength). 595 | * 596 | * @private 597 | * @param {*} value The value to check. 598 | * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 599 | */ 600 | function isLength(value) { 601 | return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 602 | } 603 | 604 | /** 605 | * Converts `value` to an object if it's not one. 606 | * 607 | * @private 608 | * @param {*} value The value to process. 609 | * @returns {Object} Returns the object. 610 | */ 611 | function toObject(value) { 612 | return isObject(value) ? value : Object(value); 613 | } 614 | 615 | /** 616 | * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. 617 | * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 618 | * 619 | * @static 620 | * @memberOf _ 621 | * @category Lang 622 | * @param {*} value The value to check. 623 | * @returns {boolean} Returns `true` if `value` is an object, else `false`. 624 | * @example 625 | * 626 | * _.isObject({}); 627 | * // => true 628 | * 629 | * _.isObject([1, 2, 3]); 630 | * // => true 631 | * 632 | * _.isObject(1); 633 | * // => false 634 | */ 635 | function isObject(value) { 636 | // Avoid a V8 JIT bug in Chrome 19-20. 637 | // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. 638 | var type = typeof value; 639 | return !!value && (type == 'object' || type == 'function'); 640 | } 641 | 642 | module.exports = baseEach; 643 | 644 | },{"lodash.keys":12}],4:[function(require,module,exports){ 645 | /** 646 | * lodash 3.0.0 (Custom Build) 647 | * Build: `lodash modern modularize exports="npm" -o ./` 648 | * Copyright 2012-2015 The Dojo Foundation 649 | * Based on Underscore.js 1.7.0 650 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 651 | * Available under MIT license 652 | */ 653 | var baseEach = require('lodash._baseeach'); 654 | 655 | /** 656 | * The base implementation of `_.filter` without support for callback 657 | * shorthands or `this` binding. 658 | * 659 | * @private 660 | * @param {Array|Object|string} collection The collection to iterate over. 661 | * @param {Function} predicate The function invoked per iteration. 662 | * @returns {Array} Returns the new filtered array. 663 | */ 664 | function baseFilter(collection, predicate) { 665 | var result = []; 666 | baseEach(collection, function(value, index, collection) { 667 | if (predicate(value, index, collection)) { 668 | result.push(value); 669 | } 670 | }); 671 | return result; 672 | } 673 | 674 | module.exports = baseFilter; 675 | 676 | },{"lodash._baseeach":3}],5:[function(require,module,exports){ 677 | /** 678 | * lodash 3.0.7 (Custom Build) 679 | * Build: `lodash modern modularize exports="npm" -o ./` 680 | * Copyright 2012-2015 The Dojo Foundation 681 | * Based on Underscore.js 1.8.3 682 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 683 | * Available under MIT license 684 | */ 685 | var isArray = require('lodash.isarray'), 686 | isTypedArray = require('lodash.istypedarray'), 687 | keys = require('lodash.keys'); 688 | 689 | /** `Object#toString` result references. */ 690 | var argsTag = '[object Arguments]', 691 | arrayTag = '[object Array]', 692 | boolTag = '[object Boolean]', 693 | dateTag = '[object Date]', 694 | errorTag = '[object Error]', 695 | numberTag = '[object Number]', 696 | objectTag = '[object Object]', 697 | regexpTag = '[object RegExp]', 698 | stringTag = '[object String]'; 699 | 700 | /** 701 | * Checks if `value` is object-like. 702 | * 703 | * @private 704 | * @param {*} value The value to check. 705 | * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 706 | */ 707 | function isObjectLike(value) { 708 | return !!value && typeof value == 'object'; 709 | } 710 | 711 | /** Used for native method references. */ 712 | var objectProto = Object.prototype; 713 | 714 | /** Used to check objects for own properties. */ 715 | var hasOwnProperty = objectProto.hasOwnProperty; 716 | 717 | /** 718 | * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) 719 | * of values. 720 | */ 721 | var objToString = objectProto.toString; 722 | 723 | /** 724 | * A specialized version of `_.some` for arrays without support for callback 725 | * shorthands and `this` binding. 726 | * 727 | * @private 728 | * @param {Array} array The array to iterate over. 729 | * @param {Function} predicate The function invoked per iteration. 730 | * @returns {boolean} Returns `true` if any element passes the predicate check, 731 | * else `false`. 732 | */ 733 | function arraySome(array, predicate) { 734 | var index = -1, 735 | length = array.length; 736 | 737 | while (++index < length) { 738 | if (predicate(array[index], index, array)) { 739 | return true; 740 | } 741 | } 742 | return false; 743 | } 744 | 745 | /** 746 | * The base implementation of `_.isEqual` without support for `this` binding 747 | * `customizer` functions. 748 | * 749 | * @private 750 | * @param {*} value The value to compare. 751 | * @param {*} other The other value to compare. 752 | * @param {Function} [customizer] The function to customize comparing values. 753 | * @param {boolean} [isLoose] Specify performing partial comparisons. 754 | * @param {Array} [stackA] Tracks traversed `value` objects. 755 | * @param {Array} [stackB] Tracks traversed `other` objects. 756 | * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 757 | */ 758 | function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { 759 | if (value === other) { 760 | return true; 761 | } 762 | if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { 763 | return value !== value && other !== other; 764 | } 765 | return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); 766 | } 767 | 768 | /** 769 | * A specialized version of `baseIsEqual` for arrays and objects which performs 770 | * deep comparisons and tracks traversed objects enabling objects with circular 771 | * references to be compared. 772 | * 773 | * @private 774 | * @param {Object} object The object to compare. 775 | * @param {Object} other The other object to compare. 776 | * @param {Function} equalFunc The function to determine equivalents of values. 777 | * @param {Function} [customizer] The function to customize comparing objects. 778 | * @param {boolean} [isLoose] Specify performing partial comparisons. 779 | * @param {Array} [stackA=[]] Tracks traversed `value` objects. 780 | * @param {Array} [stackB=[]] Tracks traversed `other` objects. 781 | * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 782 | */ 783 | function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) { 784 | var objIsArr = isArray(object), 785 | othIsArr = isArray(other), 786 | objTag = arrayTag, 787 | othTag = arrayTag; 788 | 789 | if (!objIsArr) { 790 | objTag = objToString.call(object); 791 | if (objTag == argsTag) { 792 | objTag = objectTag; 793 | } else if (objTag != objectTag) { 794 | objIsArr = isTypedArray(object); 795 | } 796 | } 797 | if (!othIsArr) { 798 | othTag = objToString.call(other); 799 | if (othTag == argsTag) { 800 | othTag = objectTag; 801 | } else if (othTag != objectTag) { 802 | othIsArr = isTypedArray(other); 803 | } 804 | } 805 | var objIsObj = objTag == objectTag, 806 | othIsObj = othTag == objectTag, 807 | isSameTag = objTag == othTag; 808 | 809 | if (isSameTag && !(objIsArr || objIsObj)) { 810 | return equalByTag(object, other, objTag); 811 | } 812 | if (!isLoose) { 813 | var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 814 | othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 815 | 816 | if (objIsWrapped || othIsWrapped) { 817 | return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); 818 | } 819 | } 820 | if (!isSameTag) { 821 | return false; 822 | } 823 | // Assume cyclic values are equal. 824 | // For more information on detecting circular references see https://es5.github.io/#JO. 825 | stackA || (stackA = []); 826 | stackB || (stackB = []); 827 | 828 | var length = stackA.length; 829 | while (length--) { 830 | if (stackA[length] == object) { 831 | return stackB[length] == other; 832 | } 833 | } 834 | // Add `object` and `other` to the stack of traversed objects. 835 | stackA.push(object); 836 | stackB.push(other); 837 | 838 | var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB); 839 | 840 | stackA.pop(); 841 | stackB.pop(); 842 | 843 | return result; 844 | } 845 | 846 | /** 847 | * A specialized version of `baseIsEqualDeep` for arrays with support for 848 | * partial deep comparisons. 849 | * 850 | * @private 851 | * @param {Array} array The array to compare. 852 | * @param {Array} other The other array to compare. 853 | * @param {Function} equalFunc The function to determine equivalents of values. 854 | * @param {Function} [customizer] The function to customize comparing arrays. 855 | * @param {boolean} [isLoose] Specify performing partial comparisons. 856 | * @param {Array} [stackA] Tracks traversed `value` objects. 857 | * @param {Array} [stackB] Tracks traversed `other` objects. 858 | * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 859 | */ 860 | function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { 861 | var index = -1, 862 | arrLength = array.length, 863 | othLength = other.length; 864 | 865 | if (arrLength != othLength && !(isLoose && othLength > arrLength)) { 866 | return false; 867 | } 868 | // Ignore non-index properties. 869 | while (++index < arrLength) { 870 | var arrValue = array[index], 871 | othValue = other[index], 872 | result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; 873 | 874 | if (result !== undefined) { 875 | if (result) { 876 | continue; 877 | } 878 | return false; 879 | } 880 | // Recursively compare arrays (susceptible to call stack limits). 881 | if (isLoose) { 882 | if (!arraySome(other, function(othValue) { 883 | return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); 884 | })) { 885 | return false; 886 | } 887 | } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) { 888 | return false; 889 | } 890 | } 891 | return true; 892 | } 893 | 894 | /** 895 | * A specialized version of `baseIsEqualDeep` for comparing objects of 896 | * the same `toStringTag`. 897 | * 898 | * **Note:** This function only supports comparing values with tags of 899 | * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 900 | * 901 | * @private 902 | * @param {Object} value The object to compare. 903 | * @param {Object} other The other object to compare. 904 | * @param {string} tag The `toStringTag` of the objects to compare. 905 | * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 906 | */ 907 | function equalByTag(object, other, tag) { 908 | switch (tag) { 909 | case boolTag: 910 | case dateTag: 911 | // Coerce dates and booleans to numbers, dates to milliseconds and booleans 912 | // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. 913 | return +object == +other; 914 | 915 | case errorTag: 916 | return object.name == other.name && object.message == other.message; 917 | 918 | case numberTag: 919 | // Treat `NaN` vs. `NaN` as equal. 920 | return (object != +object) 921 | ? other != +other 922 | : object == +other; 923 | 924 | case regexpTag: 925 | case stringTag: 926 | // Coerce regexes to strings and treat strings primitives and string 927 | // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details. 928 | return object == (other + ''); 929 | } 930 | return false; 931 | } 932 | 933 | /** 934 | * A specialized version of `baseIsEqualDeep` for objects with support for 935 | * partial deep comparisons. 936 | * 937 | * @private 938 | * @param {Object} object The object to compare. 939 | * @param {Object} other The other object to compare. 940 | * @param {Function} equalFunc The function to determine equivalents of values. 941 | * @param {Function} [customizer] The function to customize comparing values. 942 | * @param {boolean} [isLoose] Specify performing partial comparisons. 943 | * @param {Array} [stackA] Tracks traversed `value` objects. 944 | * @param {Array} [stackB] Tracks traversed `other` objects. 945 | * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 946 | */ 947 | function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) { 948 | var objProps = keys(object), 949 | objLength = objProps.length, 950 | othProps = keys(other), 951 | othLength = othProps.length; 952 | 953 | if (objLength != othLength && !isLoose) { 954 | return false; 955 | } 956 | var index = objLength; 957 | while (index--) { 958 | var key = objProps[index]; 959 | if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) { 960 | return false; 961 | } 962 | } 963 | var skipCtor = isLoose; 964 | while (++index < objLength) { 965 | key = objProps[index]; 966 | var objValue = object[key], 967 | othValue = other[key], 968 | result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined; 969 | 970 | // Recursively compare objects (susceptible to call stack limits). 971 | if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) { 972 | return false; 973 | } 974 | skipCtor || (skipCtor = key == 'constructor'); 975 | } 976 | if (!skipCtor) { 977 | var objCtor = object.constructor, 978 | othCtor = other.constructor; 979 | 980 | // Non `Object` object instances with different constructors are not equal. 981 | if (objCtor != othCtor && 982 | ('constructor' in object && 'constructor' in other) && 983 | !(typeof objCtor == 'function' && objCtor instanceof objCtor && 984 | typeof othCtor == 'function' && othCtor instanceof othCtor)) { 985 | return false; 986 | } 987 | } 988 | return true; 989 | } 990 | 991 | /** 992 | * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. 993 | * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 994 | * 995 | * @static 996 | * @memberOf _ 997 | * @category Lang 998 | * @param {*} value The value to check. 999 | * @returns {boolean} Returns `true` if `value` is an object, else `false`. 1000 | * @example 1001 | * 1002 | * _.isObject({}); 1003 | * // => true 1004 | * 1005 | * _.isObject([1, 2, 3]); 1006 | * // => true 1007 | * 1008 | * _.isObject(1); 1009 | * // => false 1010 | */ 1011 | function isObject(value) { 1012 | // Avoid a V8 JIT bug in Chrome 19-20. 1013 | // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. 1014 | var type = typeof value; 1015 | return !!value && (type == 'object' || type == 'function'); 1016 | } 1017 | 1018 | module.exports = baseIsEqual; 1019 | 1020 | },{"lodash.isarray":10,"lodash.istypedarray":11,"lodash.keys":12}],6:[function(require,module,exports){ 1021 | /** 1022 | * lodash 3.0.1 (Custom Build) 1023 | * Build: `lodash modern modularize exports="npm" -o ./` 1024 | * Copyright 2012-2015 The Dojo Foundation 1025 | * Based on Underscore.js 1.8.3 1026 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 1027 | * Available under MIT license 1028 | */ 1029 | 1030 | /** 1031 | * A specialized version of `baseCallback` which only supports `this` binding 1032 | * and specifying the number of arguments to provide to `func`. 1033 | * 1034 | * @private 1035 | * @param {Function} func The function to bind. 1036 | * @param {*} thisArg The `this` binding of `func`. 1037 | * @param {number} [argCount] The number of arguments to provide to `func`. 1038 | * @returns {Function} Returns the callback. 1039 | */ 1040 | function bindCallback(func, thisArg, argCount) { 1041 | if (typeof func != 'function') { 1042 | return identity; 1043 | } 1044 | if (thisArg === undefined) { 1045 | return func; 1046 | } 1047 | switch (argCount) { 1048 | case 1: return function(value) { 1049 | return func.call(thisArg, value); 1050 | }; 1051 | case 3: return function(value, index, collection) { 1052 | return func.call(thisArg, value, index, collection); 1053 | }; 1054 | case 4: return function(accumulator, value, index, collection) { 1055 | return func.call(thisArg, accumulator, value, index, collection); 1056 | }; 1057 | case 5: return function(value, other, key, object, source) { 1058 | return func.call(thisArg, value, other, key, object, source); 1059 | }; 1060 | } 1061 | return function() { 1062 | return func.apply(thisArg, arguments); 1063 | }; 1064 | } 1065 | 1066 | /** 1067 | * This method returns the first argument provided to it. 1068 | * 1069 | * @static 1070 | * @memberOf _ 1071 | * @category Utility 1072 | * @param {*} value Any value. 1073 | * @returns {*} Returns `value`. 1074 | * @example 1075 | * 1076 | * var object = { 'user': 'fred' }; 1077 | * 1078 | * _.identity(object) === object; 1079 | * // => true 1080 | */ 1081 | function identity(value) { 1082 | return value; 1083 | } 1084 | 1085 | module.exports = bindCallback; 1086 | 1087 | },{}],7:[function(require,module,exports){ 1088 | /** 1089 | * lodash 3.9.1 (Custom Build) 1090 | * Build: `lodash modern modularize exports="npm" -o ./` 1091 | * Copyright 2012-2015 The Dojo Foundation 1092 | * Based on Underscore.js 1.8.3 1093 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 1094 | * Available under MIT license 1095 | */ 1096 | 1097 | /** `Object#toString` result references. */ 1098 | var funcTag = '[object Function]'; 1099 | 1100 | /** Used to detect host constructors (Safari > 5). */ 1101 | var reIsHostCtor = /^\[object .+?Constructor\]$/; 1102 | 1103 | /** 1104 | * Checks if `value` is object-like. 1105 | * 1106 | * @private 1107 | * @param {*} value The value to check. 1108 | * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 1109 | */ 1110 | function isObjectLike(value) { 1111 | return !!value && typeof value == 'object'; 1112 | } 1113 | 1114 | /** Used for native method references. */ 1115 | var objectProto = Object.prototype; 1116 | 1117 | /** Used to resolve the decompiled source of functions. */ 1118 | var fnToString = Function.prototype.toString; 1119 | 1120 | /** Used to check objects for own properties. */ 1121 | var hasOwnProperty = objectProto.hasOwnProperty; 1122 | 1123 | /** 1124 | * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) 1125 | * of values. 1126 | */ 1127 | var objToString = objectProto.toString; 1128 | 1129 | /** Used to detect if a method is native. */ 1130 | var reIsNative = RegExp('^' + 1131 | fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') 1132 | .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 1133 | ); 1134 | 1135 | /** 1136 | * Gets the native function at `key` of `object`. 1137 | * 1138 | * @private 1139 | * @param {Object} object The object to query. 1140 | * @param {string} key The key of the method to get. 1141 | * @returns {*} Returns the function if it's native, else `undefined`. 1142 | */ 1143 | function getNative(object, key) { 1144 | var value = object == null ? undefined : object[key]; 1145 | return isNative(value) ? value : undefined; 1146 | } 1147 | 1148 | /** 1149 | * Checks if `value` is classified as a `Function` object. 1150 | * 1151 | * @static 1152 | * @memberOf _ 1153 | * @category Lang 1154 | * @param {*} value The value to check. 1155 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. 1156 | * @example 1157 | * 1158 | * _.isFunction(_); 1159 | * // => true 1160 | * 1161 | * _.isFunction(/abc/); 1162 | * // => false 1163 | */ 1164 | function isFunction(value) { 1165 | // The use of `Object#toString` avoids issues with the `typeof` operator 1166 | // in older versions of Chrome and Safari which return 'function' for regexes 1167 | // and Safari 8 equivalents which return 'object' for typed array constructors. 1168 | return isObject(value) && objToString.call(value) == funcTag; 1169 | } 1170 | 1171 | /** 1172 | * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. 1173 | * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 1174 | * 1175 | * @static 1176 | * @memberOf _ 1177 | * @category Lang 1178 | * @param {*} value The value to check. 1179 | * @returns {boolean} Returns `true` if `value` is an object, else `false`. 1180 | * @example 1181 | * 1182 | * _.isObject({}); 1183 | * // => true 1184 | * 1185 | * _.isObject([1, 2, 3]); 1186 | * // => true 1187 | * 1188 | * _.isObject(1); 1189 | * // => false 1190 | */ 1191 | function isObject(value) { 1192 | // Avoid a V8 JIT bug in Chrome 19-20. 1193 | // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. 1194 | var type = typeof value; 1195 | return !!value && (type == 'object' || type == 'function'); 1196 | } 1197 | 1198 | /** 1199 | * Checks if `value` is a native function. 1200 | * 1201 | * @static 1202 | * @memberOf _ 1203 | * @category Lang 1204 | * @param {*} value The value to check. 1205 | * @returns {boolean} Returns `true` if `value` is a native function, else `false`. 1206 | * @example 1207 | * 1208 | * _.isNative(Array.prototype.push); 1209 | * // => true 1210 | * 1211 | * _.isNative(_); 1212 | * // => false 1213 | */ 1214 | function isNative(value) { 1215 | if (value == null) { 1216 | return false; 1217 | } 1218 | if (isFunction(value)) { 1219 | return reIsNative.test(fnToString.call(value)); 1220 | } 1221 | return isObjectLike(value) && reIsHostCtor.test(value); 1222 | } 1223 | 1224 | module.exports = getNative; 1225 | 1226 | },{}],8:[function(require,module,exports){ 1227 | /** 1228 | * lodash 3.1.1 (Custom Build) 1229 | * Build: `lodash modern modularize exports="npm" -o ./` 1230 | * Copyright 2012-2015 The Dojo Foundation 1231 | * Based on Underscore.js 1.8.3 1232 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 1233 | * Available under MIT license 1234 | */ 1235 | var arrayFilter = require('lodash._arrayfilter'), 1236 | baseCallback = require('lodash._basecallback'), 1237 | baseFilter = require('lodash._basefilter'), 1238 | isArray = require('lodash.isarray'); 1239 | 1240 | /** 1241 | * Iterates over elements of `collection`, returning an array of all elements 1242 | * `predicate` returns truthy for. The predicate is bound to `thisArg` and 1243 | * invoked with three arguments: (value, index|key, collection). 1244 | * 1245 | * If a property name is provided for `predicate` the created `_.property` 1246 | * style callback returns the property value of the given element. 1247 | * 1248 | * If a value is also provided for `thisArg` the created `_.matchesProperty` 1249 | * style callback returns `true` for elements that have a matching property 1250 | * value, else `false`. 1251 | * 1252 | * If an object is provided for `predicate` the created `_.matches` style 1253 | * callback returns `true` for elements that have the properties of the given 1254 | * object, else `false`. 1255 | * 1256 | * @static 1257 | * @memberOf _ 1258 | * @alias select 1259 | * @category Collection 1260 | * @param {Array|Object|string} collection The collection to iterate over. 1261 | * @param {Function|Object|string} [predicate=_.identity] The function invoked 1262 | * per iteration. 1263 | * @param {*} [thisArg] The `this` binding of `predicate`. 1264 | * @returns {Array} Returns the new filtered array. 1265 | * @example 1266 | * 1267 | * _.filter([4, 5, 6], function(n) { 1268 | * return n % 2 == 0; 1269 | * }); 1270 | * // => [4, 6] 1271 | * 1272 | * var users = [ 1273 | * { 'user': 'barney', 'age': 36, 'active': true }, 1274 | * { 'user': 'fred', 'age': 40, 'active': false } 1275 | * ]; 1276 | * 1277 | * // using the `_.matches` callback shorthand 1278 | * _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user'); 1279 | * // => ['barney'] 1280 | * 1281 | * // using the `_.matchesProperty` callback shorthand 1282 | * _.pluck(_.filter(users, 'active', false), 'user'); 1283 | * // => ['fred'] 1284 | * 1285 | * // using the `_.property` callback shorthand 1286 | * _.pluck(_.filter(users, 'active'), 'user'); 1287 | * // => ['barney'] 1288 | */ 1289 | function filter(collection, predicate, thisArg) { 1290 | var func = isArray(collection) ? arrayFilter : baseFilter; 1291 | predicate = baseCallback(predicate, thisArg, 3); 1292 | return func(collection, predicate); 1293 | } 1294 | 1295 | module.exports = filter; 1296 | 1297 | },{"lodash._arrayfilter":1,"lodash._basecallback":2,"lodash._basefilter":4,"lodash.isarray":10}],9:[function(require,module,exports){ 1298 | /** 1299 | * lodash 3.0.4 (Custom Build) 1300 | * Build: `lodash modern modularize exports="npm" -o ./` 1301 | * Copyright 2012-2015 The Dojo Foundation 1302 | * Based on Underscore.js 1.8.3 1303 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 1304 | * Available under MIT license 1305 | */ 1306 | 1307 | /** 1308 | * Checks if `value` is object-like. 1309 | * 1310 | * @private 1311 | * @param {*} value The value to check. 1312 | * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 1313 | */ 1314 | function isObjectLike(value) { 1315 | return !!value && typeof value == 'object'; 1316 | } 1317 | 1318 | /** Used for native method references. */ 1319 | var objectProto = Object.prototype; 1320 | 1321 | /** Used to check objects for own properties. */ 1322 | var hasOwnProperty = objectProto.hasOwnProperty; 1323 | 1324 | /** Native method references. */ 1325 | var propertyIsEnumerable = objectProto.propertyIsEnumerable; 1326 | 1327 | /** 1328 | * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) 1329 | * of an array-like value. 1330 | */ 1331 | var MAX_SAFE_INTEGER = 9007199254740991; 1332 | 1333 | /** 1334 | * The base implementation of `_.property` without support for deep paths. 1335 | * 1336 | * @private 1337 | * @param {string} key The key of the property to get. 1338 | * @returns {Function} Returns the new function. 1339 | */ 1340 | function baseProperty(key) { 1341 | return function(object) { 1342 | return object == null ? undefined : object[key]; 1343 | }; 1344 | } 1345 | 1346 | /** 1347 | * Gets the "length" property value of `object`. 1348 | * 1349 | * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) 1350 | * that affects Safari on at least iOS 8.1-8.3 ARM64. 1351 | * 1352 | * @private 1353 | * @param {Object} object The object to query. 1354 | * @returns {*} Returns the "length" value. 1355 | */ 1356 | var getLength = baseProperty('length'); 1357 | 1358 | /** 1359 | * Checks if `value` is array-like. 1360 | * 1361 | * @private 1362 | * @param {*} value The value to check. 1363 | * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 1364 | */ 1365 | function isArrayLike(value) { 1366 | return value != null && isLength(getLength(value)); 1367 | } 1368 | 1369 | /** 1370 | * Checks if `value` is a valid array-like length. 1371 | * 1372 | * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). 1373 | * 1374 | * @private 1375 | * @param {*} value The value to check. 1376 | * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 1377 | */ 1378 | function isLength(value) { 1379 | return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 1380 | } 1381 | 1382 | /** 1383 | * Checks if `value` is classified as an `arguments` object. 1384 | * 1385 | * @static 1386 | * @memberOf _ 1387 | * @category Lang 1388 | * @param {*} value The value to check. 1389 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. 1390 | * @example 1391 | * 1392 | * _.isArguments(function() { return arguments; }()); 1393 | * // => true 1394 | * 1395 | * _.isArguments([1, 2, 3]); 1396 | * // => false 1397 | */ 1398 | function isArguments(value) { 1399 | return isObjectLike(value) && isArrayLike(value) && 1400 | hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); 1401 | } 1402 | 1403 | module.exports = isArguments; 1404 | 1405 | },{}],10:[function(require,module,exports){ 1406 | /** 1407 | * lodash 3.0.4 (Custom Build) 1408 | * Build: `lodash modern modularize exports="npm" -o ./` 1409 | * Copyright 2012-2015 The Dojo Foundation 1410 | * Based on Underscore.js 1.8.3 1411 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 1412 | * Available under MIT license 1413 | */ 1414 | 1415 | /** `Object#toString` result references. */ 1416 | var arrayTag = '[object Array]', 1417 | funcTag = '[object Function]'; 1418 | 1419 | /** Used to detect host constructors (Safari > 5). */ 1420 | var reIsHostCtor = /^\[object .+?Constructor\]$/; 1421 | 1422 | /** 1423 | * Checks if `value` is object-like. 1424 | * 1425 | * @private 1426 | * @param {*} value The value to check. 1427 | * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 1428 | */ 1429 | function isObjectLike(value) { 1430 | return !!value && typeof value == 'object'; 1431 | } 1432 | 1433 | /** Used for native method references. */ 1434 | var objectProto = Object.prototype; 1435 | 1436 | /** Used to resolve the decompiled source of functions. */ 1437 | var fnToString = Function.prototype.toString; 1438 | 1439 | /** Used to check objects for own properties. */ 1440 | var hasOwnProperty = objectProto.hasOwnProperty; 1441 | 1442 | /** 1443 | * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) 1444 | * of values. 1445 | */ 1446 | var objToString = objectProto.toString; 1447 | 1448 | /** Used to detect if a method is native. */ 1449 | var reIsNative = RegExp('^' + 1450 | fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') 1451 | .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 1452 | ); 1453 | 1454 | /* Native method references for those with the same name as other `lodash` methods. */ 1455 | var nativeIsArray = getNative(Array, 'isArray'); 1456 | 1457 | /** 1458 | * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) 1459 | * of an array-like value. 1460 | */ 1461 | var MAX_SAFE_INTEGER = 9007199254740991; 1462 | 1463 | /** 1464 | * Gets the native function at `key` of `object`. 1465 | * 1466 | * @private 1467 | * @param {Object} object The object to query. 1468 | * @param {string} key The key of the method to get. 1469 | * @returns {*} Returns the function if it's native, else `undefined`. 1470 | */ 1471 | function getNative(object, key) { 1472 | var value = object == null ? undefined : object[key]; 1473 | return isNative(value) ? value : undefined; 1474 | } 1475 | 1476 | /** 1477 | * Checks if `value` is a valid array-like length. 1478 | * 1479 | * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). 1480 | * 1481 | * @private 1482 | * @param {*} value The value to check. 1483 | * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 1484 | */ 1485 | function isLength(value) { 1486 | return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 1487 | } 1488 | 1489 | /** 1490 | * Checks if `value` is classified as an `Array` object. 1491 | * 1492 | * @static 1493 | * @memberOf _ 1494 | * @category Lang 1495 | * @param {*} value The value to check. 1496 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. 1497 | * @example 1498 | * 1499 | * _.isArray([1, 2, 3]); 1500 | * // => true 1501 | * 1502 | * _.isArray(function() { return arguments; }()); 1503 | * // => false 1504 | */ 1505 | var isArray = nativeIsArray || function(value) { 1506 | return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; 1507 | }; 1508 | 1509 | /** 1510 | * Checks if `value` is classified as a `Function` object. 1511 | * 1512 | * @static 1513 | * @memberOf _ 1514 | * @category Lang 1515 | * @param {*} value The value to check. 1516 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. 1517 | * @example 1518 | * 1519 | * _.isFunction(_); 1520 | * // => true 1521 | * 1522 | * _.isFunction(/abc/); 1523 | * // => false 1524 | */ 1525 | function isFunction(value) { 1526 | // The use of `Object#toString` avoids issues with the `typeof` operator 1527 | // in older versions of Chrome and Safari which return 'function' for regexes 1528 | // and Safari 8 equivalents which return 'object' for typed array constructors. 1529 | return isObject(value) && objToString.call(value) == funcTag; 1530 | } 1531 | 1532 | /** 1533 | * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. 1534 | * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 1535 | * 1536 | * @static 1537 | * @memberOf _ 1538 | * @category Lang 1539 | * @param {*} value The value to check. 1540 | * @returns {boolean} Returns `true` if `value` is an object, else `false`. 1541 | * @example 1542 | * 1543 | * _.isObject({}); 1544 | * // => true 1545 | * 1546 | * _.isObject([1, 2, 3]); 1547 | * // => true 1548 | * 1549 | * _.isObject(1); 1550 | * // => false 1551 | */ 1552 | function isObject(value) { 1553 | // Avoid a V8 JIT bug in Chrome 19-20. 1554 | // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. 1555 | var type = typeof value; 1556 | return !!value && (type == 'object' || type == 'function'); 1557 | } 1558 | 1559 | /** 1560 | * Checks if `value` is a native function. 1561 | * 1562 | * @static 1563 | * @memberOf _ 1564 | * @category Lang 1565 | * @param {*} value The value to check. 1566 | * @returns {boolean} Returns `true` if `value` is a native function, else `false`. 1567 | * @example 1568 | * 1569 | * _.isNative(Array.prototype.push); 1570 | * // => true 1571 | * 1572 | * _.isNative(_); 1573 | * // => false 1574 | */ 1575 | function isNative(value) { 1576 | if (value == null) { 1577 | return false; 1578 | } 1579 | if (isFunction(value)) { 1580 | return reIsNative.test(fnToString.call(value)); 1581 | } 1582 | return isObjectLike(value) && reIsHostCtor.test(value); 1583 | } 1584 | 1585 | module.exports = isArray; 1586 | 1587 | },{}],11:[function(require,module,exports){ 1588 | /** 1589 | * lodash 3.0.2 (Custom Build) 1590 | * Build: `lodash modern modularize exports="npm" -o ./` 1591 | * Copyright 2012-2015 The Dojo Foundation 1592 | * Based on Underscore.js 1.8.3 1593 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 1594 | * Available under MIT license 1595 | */ 1596 | 1597 | /** `Object#toString` result references. */ 1598 | var argsTag = '[object Arguments]', 1599 | arrayTag = '[object Array]', 1600 | boolTag = '[object Boolean]', 1601 | dateTag = '[object Date]', 1602 | errorTag = '[object Error]', 1603 | funcTag = '[object Function]', 1604 | mapTag = '[object Map]', 1605 | numberTag = '[object Number]', 1606 | objectTag = '[object Object]', 1607 | regexpTag = '[object RegExp]', 1608 | setTag = '[object Set]', 1609 | stringTag = '[object String]', 1610 | weakMapTag = '[object WeakMap]'; 1611 | 1612 | var arrayBufferTag = '[object ArrayBuffer]', 1613 | float32Tag = '[object Float32Array]', 1614 | float64Tag = '[object Float64Array]', 1615 | int8Tag = '[object Int8Array]', 1616 | int16Tag = '[object Int16Array]', 1617 | int32Tag = '[object Int32Array]', 1618 | uint8Tag = '[object Uint8Array]', 1619 | uint8ClampedTag = '[object Uint8ClampedArray]', 1620 | uint16Tag = '[object Uint16Array]', 1621 | uint32Tag = '[object Uint32Array]'; 1622 | 1623 | /** Used to identify `toStringTag` values of typed arrays. */ 1624 | var typedArrayTags = {}; 1625 | typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 1626 | typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 1627 | typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 1628 | typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 1629 | typedArrayTags[uint32Tag] = true; 1630 | typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 1631 | typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = 1632 | typedArrayTags[dateTag] = typedArrayTags[errorTag] = 1633 | typedArrayTags[funcTag] = typedArrayTags[mapTag] = 1634 | typedArrayTags[numberTag] = typedArrayTags[objectTag] = 1635 | typedArrayTags[regexpTag] = typedArrayTags[setTag] = 1636 | typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; 1637 | 1638 | /** 1639 | * Checks if `value` is object-like. 1640 | * 1641 | * @private 1642 | * @param {*} value The value to check. 1643 | * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 1644 | */ 1645 | function isObjectLike(value) { 1646 | return !!value && typeof value == 'object'; 1647 | } 1648 | 1649 | /** Used for native method references. */ 1650 | var objectProto = Object.prototype; 1651 | 1652 | /** 1653 | * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) 1654 | * of values. 1655 | */ 1656 | var objToString = objectProto.toString; 1657 | 1658 | /** 1659 | * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) 1660 | * of an array-like value. 1661 | */ 1662 | var MAX_SAFE_INTEGER = 9007199254740991; 1663 | 1664 | /** 1665 | * Checks if `value` is a valid array-like length. 1666 | * 1667 | * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength). 1668 | * 1669 | * @private 1670 | * @param {*} value The value to check. 1671 | * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 1672 | */ 1673 | function isLength(value) { 1674 | return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 1675 | } 1676 | 1677 | /** 1678 | * Checks if `value` is classified as a typed array. 1679 | * 1680 | * @static 1681 | * @memberOf _ 1682 | * @category Lang 1683 | * @param {*} value The value to check. 1684 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. 1685 | * @example 1686 | * 1687 | * _.isTypedArray(new Uint8Array); 1688 | * // => true 1689 | * 1690 | * _.isTypedArray([]); 1691 | * // => false 1692 | */ 1693 | function isTypedArray(value) { 1694 | return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; 1695 | } 1696 | 1697 | module.exports = isTypedArray; 1698 | 1699 | },{}],12:[function(require,module,exports){ 1700 | /** 1701 | * lodash 3.1.2 (Custom Build) 1702 | * Build: `lodash modern modularize exports="npm" -o ./` 1703 | * Copyright 2012-2015 The Dojo Foundation 1704 | * Based on Underscore.js 1.8.3 1705 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 1706 | * Available under MIT license 1707 | */ 1708 | var getNative = require('lodash._getnative'), 1709 | isArguments = require('lodash.isarguments'), 1710 | isArray = require('lodash.isarray'); 1711 | 1712 | /** Used to detect unsigned integer values. */ 1713 | var reIsUint = /^\d+$/; 1714 | 1715 | /** Used for native method references. */ 1716 | var objectProto = Object.prototype; 1717 | 1718 | /** Used to check objects for own properties. */ 1719 | var hasOwnProperty = objectProto.hasOwnProperty; 1720 | 1721 | /* Native method references for those with the same name as other `lodash` methods. */ 1722 | var nativeKeys = getNative(Object, 'keys'); 1723 | 1724 | /** 1725 | * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) 1726 | * of an array-like value. 1727 | */ 1728 | var MAX_SAFE_INTEGER = 9007199254740991; 1729 | 1730 | /** 1731 | * The base implementation of `_.property` without support for deep paths. 1732 | * 1733 | * @private 1734 | * @param {string} key The key of the property to get. 1735 | * @returns {Function} Returns the new function. 1736 | */ 1737 | function baseProperty(key) { 1738 | return function(object) { 1739 | return object == null ? undefined : object[key]; 1740 | }; 1741 | } 1742 | 1743 | /** 1744 | * Gets the "length" property value of `object`. 1745 | * 1746 | * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) 1747 | * that affects Safari on at least iOS 8.1-8.3 ARM64. 1748 | * 1749 | * @private 1750 | * @param {Object} object The object to query. 1751 | * @returns {*} Returns the "length" value. 1752 | */ 1753 | var getLength = baseProperty('length'); 1754 | 1755 | /** 1756 | * Checks if `value` is array-like. 1757 | * 1758 | * @private 1759 | * @param {*} value The value to check. 1760 | * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 1761 | */ 1762 | function isArrayLike(value) { 1763 | return value != null && isLength(getLength(value)); 1764 | } 1765 | 1766 | /** 1767 | * Checks if `value` is a valid array-like index. 1768 | * 1769 | * @private 1770 | * @param {*} value The value to check. 1771 | * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 1772 | * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 1773 | */ 1774 | function isIndex(value, length) { 1775 | value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; 1776 | length = length == null ? MAX_SAFE_INTEGER : length; 1777 | return value > -1 && value % 1 == 0 && value < length; 1778 | } 1779 | 1780 | /** 1781 | * Checks if `value` is a valid array-like length. 1782 | * 1783 | * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). 1784 | * 1785 | * @private 1786 | * @param {*} value The value to check. 1787 | * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 1788 | */ 1789 | function isLength(value) { 1790 | return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 1791 | } 1792 | 1793 | /** 1794 | * A fallback implementation of `Object.keys` which creates an array of the 1795 | * own enumerable property names of `object`. 1796 | * 1797 | * @private 1798 | * @param {Object} object The object to query. 1799 | * @returns {Array} Returns the array of property names. 1800 | */ 1801 | function shimKeys(object) { 1802 | var props = keysIn(object), 1803 | propsLength = props.length, 1804 | length = propsLength && object.length; 1805 | 1806 | var allowIndexes = !!length && isLength(length) && 1807 | (isArray(object) || isArguments(object)); 1808 | 1809 | var index = -1, 1810 | result = []; 1811 | 1812 | while (++index < propsLength) { 1813 | var key = props[index]; 1814 | if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) { 1815 | result.push(key); 1816 | } 1817 | } 1818 | return result; 1819 | } 1820 | 1821 | /** 1822 | * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. 1823 | * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 1824 | * 1825 | * @static 1826 | * @memberOf _ 1827 | * @category Lang 1828 | * @param {*} value The value to check. 1829 | * @returns {boolean} Returns `true` if `value` is an object, else `false`. 1830 | * @example 1831 | * 1832 | * _.isObject({}); 1833 | * // => true 1834 | * 1835 | * _.isObject([1, 2, 3]); 1836 | * // => true 1837 | * 1838 | * _.isObject(1); 1839 | * // => false 1840 | */ 1841 | function isObject(value) { 1842 | // Avoid a V8 JIT bug in Chrome 19-20. 1843 | // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. 1844 | var type = typeof value; 1845 | return !!value && (type == 'object' || type == 'function'); 1846 | } 1847 | 1848 | /** 1849 | * Creates an array of the own enumerable property names of `object`. 1850 | * 1851 | * **Note:** Non-object values are coerced to objects. See the 1852 | * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) 1853 | * for more details. 1854 | * 1855 | * @static 1856 | * @memberOf _ 1857 | * @category Object 1858 | * @param {Object} object The object to query. 1859 | * @returns {Array} Returns the array of property names. 1860 | * @example 1861 | * 1862 | * function Foo() { 1863 | * this.a = 1; 1864 | * this.b = 2; 1865 | * } 1866 | * 1867 | * Foo.prototype.c = 3; 1868 | * 1869 | * _.keys(new Foo); 1870 | * // => ['a', 'b'] (iteration order is not guaranteed) 1871 | * 1872 | * _.keys('hi'); 1873 | * // => ['0', '1'] 1874 | */ 1875 | var keys = !nativeKeys ? shimKeys : function(object) { 1876 | var Ctor = object == null ? undefined : object.constructor; 1877 | if ((typeof Ctor == 'function' && Ctor.prototype === object) || 1878 | (typeof object != 'function' && isArrayLike(object))) { 1879 | return shimKeys(object); 1880 | } 1881 | return isObject(object) ? nativeKeys(object) : []; 1882 | }; 1883 | 1884 | /** 1885 | * Creates an array of the own and inherited enumerable property names of `object`. 1886 | * 1887 | * **Note:** Non-object values are coerced to objects. 1888 | * 1889 | * @static 1890 | * @memberOf _ 1891 | * @category Object 1892 | * @param {Object} object The object to query. 1893 | * @returns {Array} Returns the array of property names. 1894 | * @example 1895 | * 1896 | * function Foo() { 1897 | * this.a = 1; 1898 | * this.b = 2; 1899 | * } 1900 | * 1901 | * Foo.prototype.c = 3; 1902 | * 1903 | * _.keysIn(new Foo); 1904 | * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 1905 | */ 1906 | function keysIn(object) { 1907 | if (object == null) { 1908 | return []; 1909 | } 1910 | if (!isObject(object)) { 1911 | object = Object(object); 1912 | } 1913 | var length = object.length; 1914 | length = (length && isLength(length) && 1915 | (isArray(object) || isArguments(object)) && length) || 0; 1916 | 1917 | var Ctor = object.constructor, 1918 | index = -1, 1919 | isProto = typeof Ctor == 'function' && Ctor.prototype === object, 1920 | result = Array(length), 1921 | skipIndexes = length > 0; 1922 | 1923 | while (++index < length) { 1924 | result[index] = (index + ''); 1925 | } 1926 | for (var key in object) { 1927 | if (!(skipIndexes && isIndex(key, length)) && 1928 | !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 1929 | result.push(key); 1930 | } 1931 | } 1932 | return result; 1933 | } 1934 | 1935 | module.exports = keys; 1936 | 1937 | },{"lodash._getnative":7,"lodash.isarguments":9,"lodash.isarray":10}],13:[function(require,module,exports){ 1938 | /** 1939 | * lodash 3.0.1 (Custom Build) 1940 | * Build: `lodash modern modularize exports="npm" -o ./` 1941 | * Copyright 2012-2015 The Dojo Foundation 1942 | * Based on Underscore.js 1.8.3 1943 | * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 1944 | * Available under MIT license 1945 | */ 1946 | var keys = require('lodash.keys'); 1947 | 1948 | /** 1949 | * Converts `value` to an object if it's not one. 1950 | * 1951 | * @private 1952 | * @param {*} value The value to process. 1953 | * @returns {Object} Returns the object. 1954 | */ 1955 | function toObject(value) { 1956 | return isObject(value) ? value : Object(value); 1957 | } 1958 | 1959 | /** 1960 | * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. 1961 | * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 1962 | * 1963 | * @static 1964 | * @memberOf _ 1965 | * @category Lang 1966 | * @param {*} value The value to check. 1967 | * @returns {boolean} Returns `true` if `value` is an object, else `false`. 1968 | * @example 1969 | * 1970 | * _.isObject({}); 1971 | * // => true 1972 | * 1973 | * _.isObject([1, 2, 3]); 1974 | * // => true 1975 | * 1976 | * _.isObject(1); 1977 | * // => false 1978 | */ 1979 | function isObject(value) { 1980 | // Avoid a V8 JIT bug in Chrome 19-20. 1981 | // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. 1982 | var type = typeof value; 1983 | return !!value && (type == 'object' || type == 'function'); 1984 | } 1985 | 1986 | /** 1987 | * Creates a two dimensional array of the key-value pairs for `object`, 1988 | * e.g. `[[key1, value1], [key2, value2]]`. 1989 | * 1990 | * @static 1991 | * @memberOf _ 1992 | * @category Object 1993 | * @param {Object} object The object to query. 1994 | * @returns {Array} Returns the new array of key-value pairs. 1995 | * @example 1996 | * 1997 | * _.pairs({ 'barney': 36, 'fred': 40 }); 1998 | * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed) 1999 | */ 2000 | function pairs(object) { 2001 | object = toObject(object); 2002 | 2003 | var index = -1, 2004 | props = keys(object), 2005 | length = props.length, 2006 | result = Array(length); 2007 | 2008 | while (++index < length) { 2009 | var key = props[index]; 2010 | result[index] = [key, object[key]]; 2011 | } 2012 | return result; 2013 | } 2014 | 2015 | module.exports = pairs; 2016 | 2017 | },{"lodash.keys":12}],14:[function(require,module,exports){ 2018 | (function (global){ 2019 | 'use strict'; 2020 | 2021 | Object.defineProperty(exports, '__esModule', { 2022 | value: true 2023 | }); 2024 | 2025 | 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; }; 2026 | 2027 | 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; }; })(); 2028 | 2029 | var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; 2030 | 2031 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 2032 | 2033 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 2034 | 2035 | 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; } 2036 | 2037 | var _react = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null); 2038 | 2039 | var _react2 = _interopRequireDefault(_react); 2040 | 2041 | var _styles = require('./styles'); 2042 | 2043 | var _lodashFilter = require('lodash.filter'); 2044 | 2045 | var _lodashFilter2 = _interopRequireDefault(_lodashFilter); 2046 | 2047 | var _dataJs = require('./data.js'); 2048 | 2049 | var _dataJs2 = _interopRequireDefault(_dataJs); 2050 | 2051 | var _ReferenceItemJs = require('./ReferenceItem.js'); 2052 | 2053 | var _ReferenceItemJs2 = _interopRequireDefault(_ReferenceItemJs); 2054 | 2055 | function filterResults(predicate, _data) { 2056 | return (0, _lodashFilter2['default'])(_data, function (_ref) { 2057 | var name = _ref.name; 2058 | 2059 | return name.match(new RegExp(predicate, 'i')); 2060 | }); 2061 | } 2062 | 2063 | var inputStyle = { 2064 | width: "50%", 2065 | padding: 10, 2066 | fontSize: "1em", 2067 | borderRadius: 2, 2068 | border: "1px solid #aaa", 2069 | color: "black" 2070 | }; 2071 | 2072 | var ReactCheatSheet = (function (_Component) { 2073 | _inherits(ReactCheatSheet, _Component); 2074 | 2075 | function ReactCheatSheet(props) { 2076 | var _this = this; 2077 | 2078 | _classCallCheck(this, ReactCheatSheet); 2079 | 2080 | _get(Object.getPrototypeOf(ReactCheatSheet.prototype), 'constructor', this).call(this, props); 2081 | 2082 | this.state = { 2083 | predicate: '' 2084 | }; 2085 | 2086 | this.handleChange = function () { 2087 | _this.setState({ predicate: _this.searchInput.getDOMNode().value }); 2088 | }; 2089 | } 2090 | 2091 | _createClass(ReactCheatSheet, [{ 2092 | key: 'render', 2093 | value: function render() { 2094 | var _this2 = this; 2095 | 2096 | var noResults = function noResults() { 2097 | return _react2['default'].createElement( 2098 | 'article', 2099 | { style: _extends({}, _styles.article) }, 2100 | _react2['default'].createElement( 2101 | 'h2', 2102 | null, 2103 | 'No results' 2104 | ) 2105 | ); 2106 | }; 2107 | 2108 | var results = function results() { 2109 | return _this2.filteredResults.map(_ReferenceItemJs2['default']); 2110 | }; 2111 | 2112 | return _react2['default'].createElement( 2113 | 'main', 2114 | null, 2115 | _react2['default'].createElement( 2116 | 'label', 2117 | null, 2118 | _react2['default'].createElement('input', { 2119 | autoFocus: true, 2120 | type: 'text', 2121 | style: inputStyle, 2122 | placeholder: 'Filter by name', 2123 | value: this.state.predicate, 2124 | ref: function (c) { 2125 | return _this2.searchInput = c; 2126 | }, 2127 | onChange: this.handleChange 2128 | }), 2129 | _react2['default'].createElement( 2130 | 'div', 2131 | null, 2132 | _react2['default'].createElement( 2133 | 'small', 2134 | { style: { color: "#999" } }, 2135 | '* using case-insensitive regex match' 2136 | ) 2137 | ) 2138 | ), 2139 | _react2['default'].createElement( 2140 | 'section', 2141 | null, 2142 | this.filteredResults.length ? results() : noResults() 2143 | ) 2144 | ); 2145 | } 2146 | }, { 2147 | key: 'filteredResults', 2148 | get: function get() { 2149 | return filterResults(this.state.predicate, _dataJs2['default']); 2150 | } 2151 | }]); 2152 | 2153 | return ReactCheatSheet; 2154 | })(_react.Component); 2155 | 2156 | exports['default'] = ReactCheatSheet; 2157 | module.exports = exports['default']; 2158 | 2159 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 2160 | },{"./ReferenceItem.js":15,"./data.js":17,"./styles":24,"lodash.filter":8}],15:[function(require,module,exports){ 2161 | (function (global){ 2162 | 'use strict'; 2163 | 2164 | Object.defineProperty(exports, '__esModule', { 2165 | value: true 2166 | }); 2167 | 2168 | 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; }; 2169 | 2170 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 2171 | 2172 | var _react = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null); 2173 | 2174 | var _react2 = _interopRequireDefault(_react); 2175 | 2176 | var _styles = require('./styles'); 2177 | 2178 | var _vendorPrism = require('./vendor/Prism'); 2179 | 2180 | var _vendorPrism2 = _interopRequireDefault(_vendorPrism); 2181 | 2182 | var styles = { 2183 | root: _extends({}, _styles.article, { 2184 | borderBottom: '1px solid #333' 2185 | }), 2186 | header: { 2187 | overflowY: 'scroll' 2188 | }, 2189 | module: { 2190 | marginLeft: '.5em', 2191 | fontSize: '1em', 2192 | color: '#aaa', 2193 | fontWeight: 'normal' 2194 | }, 2195 | example: { 2196 | position: 'relative', 2197 | overflow: 'hidden', 2198 | overflowX: 'scroll', 2199 | backgroundColor: 'rgb(40, 44, 52)', 2200 | color: 'white', 2201 | padding: 20, 2202 | borderRadius: 2 2203 | }, 2204 | exampleColorCode: { 2205 | position: 'absolute', 2206 | left: 0, 2207 | top: 0, 2208 | height: '100%', 2209 | width: 4 2210 | }, 2211 | code: { 2212 | fontFamily: "Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace" 2213 | }, 2214 | reference: { 2215 | textAlign: 'right' 2216 | } 2217 | }; 2218 | 2219 | var ReferenceItem = function ReferenceItem(_ref) { 2220 | var name = _ref.name; 2221 | var module = _ref.module; 2222 | var href = _ref.reference; 2223 | var example = _ref.example; 2224 | var backgroundColor = _ref.color; 2225 | return _react2['default'].createElement( 2226 | 'article', 2227 | { style: styles.root }, 2228 | _react2['default'].createElement( 2229 | 'h2', 2230 | { style: styles.header }, 2231 | name, 2232 | _react2['default'].createElement( 2233 | 'span', 2234 | { style: styles.module }, 2235 | module 2236 | ) 2237 | ), 2238 | _react2['default'].createElement( 2239 | 'pre', 2240 | { style: styles.example }, 2241 | _react2['default'].createElement( 2242 | 'code', 2243 | { style: styles.code }, 2244 | _react2['default'].createElement( 2245 | _vendorPrism2['default'], 2246 | null, 2247 | example 2248 | ) 2249 | ), 2250 | _react2['default'].createElement('div', { style: _extends({ backgroundColor: backgroundColor }, styles.exampleColorCode) }) 2251 | ), 2252 | _react2['default'].createElement( 2253 | 'div', 2254 | { style: styles.reference }, 2255 | href && _react2['default'].createElement( 2256 | 'a', 2257 | { href: href, target: '_blank' }, 2258 | 'Read more →' 2259 | ) 2260 | ) 2261 | ); 2262 | }; 2263 | 2264 | exports['default'] = ReferenceItem; 2265 | module.exports = exports['default']; 2266 | 2267 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 2268 | },{"./styles":24,"./vendor/Prism":25}],16:[function(require,module,exports){ 2269 | "use strict"; 2270 | 2271 | Object.defineProperty(exports, "__esModule", { 2272 | value: true 2273 | }); 2274 | 2275 | 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; }; 2276 | 2277 | exports["default"] = function (collection, defaults) { 2278 | return collection.map(function (el) { 2279 | return _extends({}, el, defaults); 2280 | }); 2281 | }; 2282 | 2283 | module.exports = exports["default"]; 2284 | 2285 | },{}],17:[function(require,module,exports){ 2286 | 'use strict'; 2287 | 2288 | Object.defineProperty(exports, '__esModule', { 2289 | value: true 2290 | }); 2291 | 2292 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 2293 | 2294 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } 2295 | 2296 | var _dataReactDOM = require('./data/ReactDOM'); 2297 | 2298 | var _dataReactDOM2 = _interopRequireDefault(_dataReactDOM); 2299 | 2300 | var _dataReactDOM_Server = require('./data/ReactDOM_Server'); 2301 | 2302 | var _dataReactDOM_Server2 = _interopRequireDefault(_dataReactDOM_Server); 2303 | 2304 | var _dataReact_TopLevel = require('./data/React_TopLevel'); 2305 | 2306 | var _dataReact_TopLevel2 = _interopRequireDefault(_dataReact_TopLevel); 2307 | 2308 | var _dataReact_Spec = require('./data/React_Spec'); 2309 | 2310 | var _dataReact_Spec2 = _interopRequireDefault(_dataReact_Spec); 2311 | 2312 | var _dataReact_Lifecycle = require('./data/React_Lifecycle'); 2313 | 2314 | var _dataReact_Lifecycle2 = _interopRequireDefault(_dataReact_Lifecycle); 2315 | 2316 | var _dataReact_PropTypes = require('./data/React_PropTypes'); 2317 | 2318 | var _dataReact_PropTypes2 = _interopRequireDefault(_dataReact_PropTypes); 2319 | 2320 | exports['default'] = [].concat(_toConsumableArray(_dataReactDOM2['default']), _toConsumableArray(_dataReactDOM_Server2['default']), _toConsumableArray(_dataReact_TopLevel2['default']), _toConsumableArray(_dataReact_Spec2['default']), _toConsumableArray(_dataReact_Lifecycle2['default']), _toConsumableArray(_dataReact_PropTypes2['default'])); 2321 | module.exports = exports['default']; 2322 | 2323 | },{"./data/ReactDOM":18,"./data/ReactDOM_Server":19,"./data/React_Lifecycle":20,"./data/React_PropTypes":21,"./data/React_Spec":22,"./data/React_TopLevel":23}],18:[function(require,module,exports){ 2324 | 'use strict'; 2325 | 2326 | Object.defineProperty(exports, '__esModule', { 2327 | value: true 2328 | }); 2329 | 2330 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 2331 | 2332 | var _assignSharedDefaults = require('../assignSharedDefaults'); 2333 | 2334 | var _assignSharedDefaults2 = _interopRequireDefault(_assignSharedDefaults); 2335 | 2336 | var data = [{ 2337 | name: 'render', 2338 | example: 'ReactDOM.render(, document.getElementById(\'MyComponent\');', 2339 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdom.render' 2340 | }, { 2341 | name: 'findDOMNode', 2342 | example: 'ReactDOM.findDOMNode(componentRef);', 2343 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdom.finddomnode' 2344 | }, { 2345 | name: 'unmountComponentAtNode', 2346 | example: 'ReactDOM.unmountComponentAtNode(document.getElementById(\'MyComponent\'))', 2347 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdom.unmountcomponentatnode' 2348 | }]; 2349 | 2350 | exports['default'] = (0, _assignSharedDefaults2['default'])(data, { module: 'react-dom', color: '#85144b' }); 2351 | module.exports = exports['default']; 2352 | 2353 | },{"../assignSharedDefaults":16}],19:[function(require,module,exports){ 2354 | 'use strict'; 2355 | 2356 | Object.defineProperty(exports, '__esModule', { 2357 | value: true 2358 | }); 2359 | 2360 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 2361 | 2362 | var _assignSharedDefaults = require('../assignSharedDefaults'); 2363 | 2364 | var _assignSharedDefaults2 = _interopRequireDefault(_assignSharedDefaults); 2365 | 2366 | var data = [{ 2367 | name: 'renderToString', 2368 | example: 'ReactDOMServer.renderToString();', 2369 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring' 2370 | }, { 2371 | name: 'renderStaticMarkup', 2372 | example: 'ReactDOMServer.renderToStaticMarkup();', 2373 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostaticmarkup' 2374 | }]; 2375 | 2376 | exports['default'] = (0, _assignSharedDefaults2['default'])(data, { module: 'react-dom', color: '#85144b' }); 2377 | module.exports = exports['default']; 2378 | 2379 | },{"../assignSharedDefaults":16}],20:[function(require,module,exports){ 2380 | 'use strict'; 2381 | 2382 | Object.defineProperty(exports, '__esModule', { 2383 | value: true 2384 | }); 2385 | 2386 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 2387 | 2388 | var _assignSharedDefaults = require('../assignSharedDefaults'); 2389 | 2390 | var _assignSharedDefaults2 = _interopRequireDefault(_assignSharedDefaults); 2391 | 2392 | var data = [{ 2393 | name: 'componentWillMount', 2394 | example: 'componentWillMount: function () {\n // invoked once, before initial \'render\'\n}', 2395 | reference: 'http://facebook.github.io/react/docs/component-specs.html#mounting-componentwillmount' 2396 | }, { 2397 | name: 'componentDidMount', 2398 | example: 'componentDidMount: function () {\n // invoked once (client-only), after initial \'render\'\n // good for AJAX, setTimeout, setInterval\n}', 2399 | reference: 'http://facebook.github.io/react/docs/component-specs.html#mounting-componentdidmount' 2400 | }, { 2401 | name: 'componentWillReceiveProps', 2402 | example: 'componentWillReceiveProps: function (nextProps) {\n // invoked when component is receiving props, not for initial \'render\'\n}', 2403 | reference: 'http://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops' 2404 | }, { 2405 | name: 'shouldComponentUpdate', 2406 | example: 'shouldComponentUpdate: function (nextProps, nextState) {\n // invoked before rendering with new props, not for initial \'render\'\n}', 2407 | reference: 'http://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate' 2408 | }, { 2409 | name: 'componentWillUpdate', 2410 | example: 'componentWillUpdate: function (nextProps, nextState) {\n // invoked immediately before rendering with new props or state, not for initial \'render\'\n // CANNOT CALL setState(). see componentWillReceiveProps\n}', 2411 | reference: 'http://facebook.github.io/react/docs/component-specs.html#updating-componentwillupdate' 2412 | }, { 2413 | name: 'componentDidUpdate', 2414 | example: 'componentDidUpdate: function (nextProps, nextState) {\n // invoked immediately after DOM updates, not for initial \'render\'\n}', 2415 | reference: 'http://facebook.github.io/react/docs/component-specs.html#updating-componentdidupdate' 2416 | }, { 2417 | name: 'componentWillUnmount', 2418 | example: 'componentWillUnmount: function () {\n // invoked immediately before a component is unmounted from the DOM\n}', 2419 | reference: 'http://facebook.github.io/react/docs/component-specs.html#unmounting-componentwillunmount' 2420 | }]; 2421 | 2422 | exports['default'] = (0, _assignSharedDefaults2['default'])(data, { module: 'react', color: '#ff851b' }); 2423 | module.exports = exports['default']; 2424 | 2425 | },{"../assignSharedDefaults":16}],21:[function(require,module,exports){ 2426 | 'use strict'; 2427 | 2428 | Object.defineProperty(exports, '__esModule', { 2429 | value: true 2430 | }); 2431 | 2432 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 2433 | 2434 | var _assignSharedDefaults = require('../assignSharedDefaults'); 2435 | 2436 | var _assignSharedDefaults2 = _interopRequireDefault(_assignSharedDefaults); 2437 | 2438 | var data = [{ 2439 | name: 'PropTypes.array', 2440 | example: '{\n optionalArray: React.PropTypes.array,\n requiredArray: React.PropTypes.array.isRequired\n}' 2441 | }, { 2442 | name: 'PropTypes.bool', 2443 | example: '{\n optionalBoolean: React.PropTypes.bool,\n requiredBoolean: React.PropTypes.bool.isRequired\n}' 2444 | }, { 2445 | name: 'PropTypes.func', 2446 | example: '{\n optionalFunction: React.PropTypes.func,\n requiredFunction: React.PropTypes.func.isRequired\n}' 2447 | }, { 2448 | name: 'PropTypes.number', 2449 | example: '{\n optionalNumber: React.PropTypes.number,\n requiredNumber: React.PropTypes.number.isRequired\n}' 2450 | }, { 2451 | name: 'PropTypes.object', 2452 | example: '{\n optionalObject: React.PropTypes.object,\n requiredObject: React.PropTypes.object.isRequired\n}' 2453 | }, { 2454 | name: 'PropTypes.string', 2455 | example: '{\n optionalString: React.PropTypes.string,\n requiredString: React.PropTypes.string.isRequired\n}' 2456 | }, { 2457 | name: 'PropTypes.node', 2458 | example: '{\n optionalNode: React.PropTypes.node,\n requiredNode: React.PropTypes.node.isRequired\n};\n\n// anything that can be rendered' 2459 | }, { 2460 | name: 'PropTypes.element', 2461 | example: '{\n optionalElement: React.PropTypes.element,\n requiredElement: React.PropTypes.element.isRequired\n}' 2462 | }, { 2463 | name: 'PropTypes.instanceOf', 2464 | example: '{\n optionalClass: React.PropTypes.instanceOf(MyClass),\n requiredClass: React.PropTypes.instanceOf(MyClass).isRequired\n}' 2465 | }, { 2466 | name: 'PropTypes.oneOf', 2467 | example: '{\n optionalEnum: React.PropTypes.oneOf([\'Thing 1\', \'Thing 2\']),\n optionalEnum: React.PropTypes.oneOf([\'Thing 1\', \'Thing 2\']).isRequired\n}' 2468 | }, { 2469 | name: 'PropTypes.oneOfType', 2470 | example: '{\n optionalUnion: React.PropTypes.oneOfType([\n React.PropTypes.bool,\n React.PropTypes.string\n ]),\n\n requiredUnion: React.PropTypes.oneOfType([\n React.PropTypes.bool,\n React.PropTypes.string\n ]).isRequired,\n}' 2471 | }, { 2472 | name: 'PropTypes.arrayOf', 2473 | example: '{\n optionalArrayOf: React.PropTypes.arrayOf(React.PropTypes.string),\n requiredArrayOf: React.PropTypes.arrayOf(React.PropTypes.string).isRequired\n}' 2474 | }, { 2475 | name: 'PropTypes.objectOf', 2476 | example: '{\n optionalObjectOf: React.PropTypes.objectOf(React.PropTypes.string),\n requiredObjectOf: React.PropTypes.objectOf(React.PropTypes.string).isRequired\n}\n\n// Type of property values' 2477 | }, { 2478 | name: 'PropTypes.shape', 2479 | example: '{\n optionalObjectWithShape: React.PropTypes.shape({\n age: React.PropTypes.number,\n name: React.PropTypes.string\n }),\n\n requiredObjectWithShape: React.PropTypes.shape({\n age: React.PropTypes.number,\n name: React.PropTypes.string\n }).isRequired,\n\n requiredObjectWithRequiredShape: React.PropTypes.shape({\n age: React.PropTypes.number.isRequired,\n name: React.PropTypes.string.isRequired\n }).isRequired,\n}' 2480 | }, { 2481 | name: 'PropTypes.any', 2482 | example: '{\n requiredAny: React.PropTypes.any.isRequired\n}' 2483 | }]; 2484 | 2485 | exports['default'] = (0, _assignSharedDefaults2['default'])(data, { module: 'react', color: '#f012be', reference: 'https://facebook.github.io/react/docs/reusable-components.html#prop-validation' }); 2486 | module.exports = exports['default']; 2487 | 2488 | },{"../assignSharedDefaults":16}],22:[function(require,module,exports){ 2489 | 'use strict'; 2490 | 2491 | Object.defineProperty(exports, '__esModule', { 2492 | value: true 2493 | }); 2494 | 2495 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 2496 | 2497 | var _assignSharedDefaults = require('../assignSharedDefaults'); 2498 | 2499 | var _assignSharedDefaults2 = _interopRequireDefault(_assignSharedDefaults); 2500 | 2501 | var data = [{ 2502 | name: 'render', 2503 | example: 'render: function () {\n return
;\n}', 2504 | reference: 'http://facebook.github.io/react/docs/component-specs.html#render' 2505 | }, { 2506 | name: 'getInitialState', 2507 | example: 'getInitialState: function () {\n return { key: value };\n}\n\n// not available with React.Component', 2508 | reference: 'http://facebook.github.io/react/docs/component-specs.html#getinitialstate' 2509 | }, { 2510 | name: 'getDefaultProps', 2511 | example: 'getDefaultProps: function () {\n return { key: value };\n}\n\n// not available with React.Component', 2512 | reference: 'http://facebook.github.io/react/docs/component-specs.html#getdefaultprops' 2513 | }, { 2514 | name: 'propTypes', 2515 | example: 'propTypes: function () {\n myProp: React.PropTypes.bool\n}\n\n// not available with React.Component', 2516 | reference: 'http://facebook.github.io/react/docs/component-specs.html#proptypes' 2517 | }, { 2518 | name: 'mixins', 2519 | example: 'mixins: [ AMixinObject, AnotherMixinObject ];\n\n// not available in React.Component', 2520 | reference: 'http://facebook.github.io/react/docs/component-specs.html#mixins' 2521 | }, { 2522 | name: 'statics', 2523 | example: 'statics: {\n customMethod: function(foo) {\n return foo === \'bar\';\n }\n}', 2524 | reference: 'http://facebook.github.io/react/docs/component-specs.html#statics' 2525 | }, { 2526 | name: 'displayName', 2527 | example: 'displayName: "MyComponent"', 2528 | reference: 'http://facebook.github.io/react/docs/component-specs.html#displayname' 2529 | }]; 2530 | 2531 | exports['default'] = (0, _assignSharedDefaults2['default'])(data, { module: 'react', color: '#3d9970' }); 2532 | module.exports = exports['default']; 2533 | 2534 | },{"../assignSharedDefaults":16}],23:[function(require,module,exports){ 2535 | 'use strict'; 2536 | 2537 | Object.defineProperty(exports, '__esModule', { 2538 | value: true 2539 | }); 2540 | 2541 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 2542 | 2543 | var _assignSharedDefaults = require('../assignSharedDefaults'); 2544 | 2545 | var _assignSharedDefaults2 = _interopRequireDefault(_assignSharedDefaults); 2546 | 2547 | var data = [{ 2548 | name: 'Component', 2549 | example: '// ES2015\n\nclass MyComponent extends React.Component {\n render () {\n return
;\n }\n}\n', 2550 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.component' 2551 | }, { 2552 | name: 'createClass', 2553 | example: 'var MyComponent = React.createClass({\n render: function () {\n return
;\n }\n});', 2554 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.createclass' 2555 | }, { 2556 | name: 'createElement', 2557 | example: 'React.createElement(\'div\', props, ...children); // String\n\nReact.createElement(MyComponent, props, ...children); // ReactClass type', 2558 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.createelement' 2559 | }, { 2560 | name: 'cloneElement', 2561 | example: 'React.cloneElement(element, props, ...children);', 2562 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.cloneelement' 2563 | }, { 2564 | name: 'createFactory', 2565 | example: 'React.createFactory(\'div\'); // String;\n\nReact.createFactory(MyComponentClass); // ReactClass type', 2566 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.createfactory' 2567 | }, { 2568 | name: 'isValidElement', 2569 | example: 'React.isValidElement(MyComponent);', 2570 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.isvalidelement' 2571 | }, { 2572 | name: 'Children.map', 2573 | example: 'React.Children.map(this.props.children, (child, i) => {\n return child;\n})', 2574 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.map' 2575 | }, { 2576 | name: 'Children.forEach', 2577 | example: 'React.Children.forEach(this.props.children, (child, i) => {\n console.log(child + \' at index: \' + i);\n})', 2578 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.foreach' 2579 | }, { 2580 | name: 'Children.count', 2581 | example: 'React.Children.count(this.props.children);', 2582 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.count' 2583 | }, { 2584 | name: 'Children.only', 2585 | example: 'none', 2586 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.only' 2587 | }, { 2588 | name: 'Children.toArray', 2589 | example: 'none', 2590 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.toarray' 2591 | }]; 2592 | 2593 | exports['default'] = (0, _assignSharedDefaults2['default'])(data, { module: 'react', color: '#ffdc00' }); 2594 | module.exports = exports['default']; 2595 | 2596 | },{"../assignSharedDefaults":16}],24:[function(require,module,exports){ 2597 | 'use strict'; 2598 | 2599 | Object.defineProperty(exports, '__esModule', { 2600 | value: true 2601 | }); 2602 | exports['default'] = { 2603 | article: { 2604 | paddingTop: '1em', 2605 | paddingBottom: '1em' 2606 | } 2607 | }; 2608 | module.exports = exports['default']; 2609 | 2610 | },{}],25:[function(require,module,exports){ 2611 | (function (global){ 2612 | /** 2613 | * Prism: Lightweight, robust, elegant syntax highlighting 2614 | * MIT license http://www.opensource.org/licenses/mit-license.php/ 2615 | * @author Lea Verou http://lea.verou.me 2616 | * 2617 | * @providesModule Prism 2618 | * @jsx React.DOM 2619 | */ 2620 | 2621 | 'use strict'; 2622 | 2623 | var React = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null); 2624 | 2625 | // Private helper vars 2626 | var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; 2627 | 2628 | var _ = { 2629 | util: { 2630 | type: function type(o) { 2631 | return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1]; 2632 | }, 2633 | 2634 | // Deep clone a language definition (e.g. to extend it) 2635 | clone: function clone(o) { 2636 | var type = _.util.type(o); 2637 | 2638 | switch (type) { 2639 | case 'Object': 2640 | var clone = {}; 2641 | 2642 | for (var key in o) { 2643 | if (o.hasOwnProperty(key)) { 2644 | clone[key] = _.util.clone(o[key]); 2645 | } 2646 | } 2647 | 2648 | return clone; 2649 | 2650 | case 'Array': 2651 | return o.slice(); 2652 | } 2653 | 2654 | return o; 2655 | } 2656 | }, 2657 | 2658 | languages: { 2659 | extend: function extend(id, redef) { 2660 | var lang = _.util.clone(_.languages[id]); 2661 | 2662 | for (var key in redef) { 2663 | lang[key] = redef[key]; 2664 | } 2665 | 2666 | return lang; 2667 | }, 2668 | 2669 | // Insert a token before another token in a language literal 2670 | insertBefore: function insertBefore(inside, before, insert, root) { 2671 | root = root || _.languages; 2672 | var grammar = root[inside]; 2673 | var ret = {}; 2674 | 2675 | for (var token in grammar) { 2676 | 2677 | if (grammar.hasOwnProperty(token)) { 2678 | 2679 | if (token == before) { 2680 | 2681 | for (var newToken in insert) { 2682 | 2683 | if (insert.hasOwnProperty(newToken)) { 2684 | ret[newToken] = insert[newToken]; 2685 | } 2686 | } 2687 | } 2688 | 2689 | ret[token] = grammar[token]; 2690 | } 2691 | } 2692 | 2693 | return root[inside] = ret; 2694 | }, 2695 | 2696 | // Traverse a language definition with Depth First Search 2697 | DFS: function DFS(o, callback) { 2698 | for (var i in o) { 2699 | callback.call(o, i, o[i]); 2700 | 2701 | if (_.util.type(o) === 'Object') { 2702 | _.languages.DFS(o[i], callback); 2703 | } 2704 | } 2705 | } 2706 | }, 2707 | 2708 | tokenize: function tokenize(text, grammar, language) { 2709 | var Token = _.Token; 2710 | 2711 | var strarr = [text]; 2712 | 2713 | var rest = grammar.rest; 2714 | 2715 | if (rest) { 2716 | for (var token in rest) { 2717 | grammar[token] = rest[token]; 2718 | } 2719 | 2720 | delete grammar.rest; 2721 | } 2722 | 2723 | tokenloop: for (var token in grammar) { 2724 | if (!grammar.hasOwnProperty(token) || !grammar[token]) { 2725 | continue; 2726 | } 2727 | 2728 | var pattern = grammar[token], 2729 | inside = pattern.inside, 2730 | lookbehind = !!pattern.lookbehind, 2731 | lookbehindLength = 0; 2732 | 2733 | pattern = pattern.pattern || pattern; 2734 | 2735 | for (var i = 0; i < strarr.length; i++) { 2736 | // Don’t cache length as it changes during the loop 2737 | 2738 | var str = strarr[i]; 2739 | 2740 | if (strarr.length > text.length) { 2741 | // Something went terribly wrong, ABORT, ABORT! 2742 | break tokenloop; 2743 | } 2744 | 2745 | if (str instanceof Token) { 2746 | continue; 2747 | } 2748 | 2749 | pattern.lastIndex = 0; 2750 | 2751 | var match = pattern.exec(str); 2752 | 2753 | if (match) { 2754 | if (lookbehind) { 2755 | lookbehindLength = match[1].length; 2756 | } 2757 | 2758 | var from = match.index - 1 + lookbehindLength, 2759 | match = match[0].slice(lookbehindLength), 2760 | len = match.length, 2761 | to = from + len, 2762 | before = str.slice(0, from + 1), 2763 | after = str.slice(to + 1); 2764 | 2765 | var args = [i, 1]; 2766 | 2767 | if (before) { 2768 | args.push(before); 2769 | } 2770 | 2771 | var wrapped = new Token(token, inside ? _.tokenize(match, inside) : match); 2772 | 2773 | args.push(wrapped); 2774 | 2775 | if (after) { 2776 | args.push(after); 2777 | } 2778 | 2779 | Array.prototype.splice.apply(strarr, args); 2780 | } 2781 | } 2782 | } 2783 | 2784 | return strarr; 2785 | }, 2786 | 2787 | hooks: { 2788 | all: {}, 2789 | 2790 | add: function add(name, callback) { 2791 | var hooks = _.hooks.all; 2792 | 2793 | hooks[name] = hooks[name] || []; 2794 | 2795 | hooks[name].push(callback); 2796 | }, 2797 | 2798 | run: function run(name, env) { 2799 | var callbacks = _.hooks.all[name]; 2800 | 2801 | if (!callbacks || !callbacks.length) { 2802 | return; 2803 | } 2804 | 2805 | for (var i = 0, callback; callback = callbacks[i++];) { 2806 | callback(env); 2807 | } 2808 | } 2809 | } 2810 | }; 2811 | 2812 | var Token = _.Token = function (type, content) { 2813 | this.type = type; 2814 | this.content = content; 2815 | }; 2816 | 2817 | Token.reactify = function (o) { 2818 | if (typeof o == 'string') { 2819 | return o; 2820 | } 2821 | 2822 | if (Array.isArray(o)) { 2823 | return o.map(function (element) { 2824 | return Token.reactify(element); 2825 | }); 2826 | } 2827 | 2828 | var attributes = { 2829 | className: 'token ' + o.type 2830 | }; 2831 | if (o.type == 'comment') { 2832 | attributes.spellcheck = true; 2833 | } 2834 | 2835 | return React.DOM.span(attributes, Token.reactify(o.content)); 2836 | }; 2837 | 2838 | _.languages.markup = { 2839 | 'comment': /<!--[\w\W]*?-->/g, 2840 | 'prolog': /<\?.+?\?>/, 2841 | 'doctype': /<!DOCTYPE.+?>/, 2842 | 'cdata': /<!\[CDATA\[[\w\W]*?]]>/i, 2843 | 'tag': { 2844 | pattern: /<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi, 2845 | inside: { 2846 | 'tag': { 2847 | pattern: /^<\/?[\w:-]+/i, 2848 | inside: { 2849 | 'punctuation': /^<\/?/, 2850 | 'namespace': /^[\w-]+?:/ 2851 | } 2852 | }, 2853 | 'attr-value': { 2854 | pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi, 2855 | inside: { 2856 | 'punctuation': /=|>|"/g 2857 | } 2858 | }, 2859 | 'punctuation': /\/?>/g, 2860 | 'attr-name': { 2861 | pattern: /[\w:-]+/g, 2862 | inside: { 2863 | 'namespace': /^[\w-]+?:/ 2864 | } 2865 | } 2866 | 2867 | } 2868 | }, 2869 | 'entity': /&#?[\da-z]{1,8};/gi 2870 | }; 2871 | 2872 | _.languages.css = { 2873 | 'comment': /\/\*[\w\W]*?\*\//g, 2874 | 'atrule': { 2875 | pattern: /@[\w-]+?.*?(;|(?=\s*{))/gi, 2876 | inside: { 2877 | 'punctuation': /[;:]/g 2878 | } 2879 | }, 2880 | 'url': /url\((["']?).*?\1\)/gi, 2881 | 'selector': /[^\{\}\s][^\{\};]*(?=\s*\{)/g, 2882 | 'property': /(\b|\B)[\w-]+(?=\s*:)/ig, 2883 | 'string': /("|')(\\?.)*?\1/g, 2884 | 'important': /\B!important\b/gi, 2885 | 'ignore': /&(lt|gt|amp);/gi, 2886 | 'punctuation': /[\{\};:]/g 2887 | }; 2888 | 2889 | _.languages.insertBefore('markup', 'tag', { 2890 | 'style': { 2891 | pattern: /(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/ig, 2892 | inside: { 2893 | 'tag': { 2894 | pattern: /(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/ig, 2895 | inside: _.languages.markup.tag.inside 2896 | }, 2897 | rest: _.languages.css 2898 | } 2899 | } 2900 | }); 2901 | 2902 | _.languages.clike = { 2903 | 'comment': { 2904 | pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g, 2905 | lookbehind: true 2906 | }, 2907 | 'string': /("|')(\\?.)*?\1/g, 2908 | 'class-name': { 2909 | pattern: /((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/ig, 2910 | lookbehind: true, 2911 | inside: { 2912 | punctuation: /(\.|\\)/ 2913 | } 2914 | }, 2915 | 'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/g, 2916 | 'boolean': /\b(true|false)\b/g, 2917 | 'function': { 2918 | pattern: /[a-z0-9_]+\(/ig, 2919 | inside: { 2920 | punctuation: /\(/ 2921 | } 2922 | }, 2923 | 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g, 2924 | 'operator': /[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%/g, 2925 | 'ignore': /&(lt|gt|amp);/gi, 2926 | 'punctuation': /[{}[\];(),.:]/g 2927 | }; 2928 | 2929 | _.languages.javascript = _.languages.extend('clike', { 2930 | 'keyword': /\b(class|extends|var|let|if|else|while|do|for|return|in|instanceof|function|get|set|new|with|typeof|try|throw|catch|finally|null|break|continue|this)\b/g, 2931 | 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?|NaN|-?Infinity)\b/g 2932 | }); 2933 | 2934 | _.languages.insertBefore('javascript', 'keyword', { 2935 | 'regex': { 2936 | pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g, 2937 | lookbehind: true 2938 | } 2939 | }); 2940 | 2941 | _.languages.insertBefore('markup', 'tag', { 2942 | 'script': { 2943 | pattern: /(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/ig, 2944 | inside: { 2945 | 'tag': { 2946 | pattern: /(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/ig, 2947 | inside: _.languages.markup.tag.inside 2948 | }, 2949 | rest: _.languages.javascript 2950 | } 2951 | } 2952 | }); 2953 | 2954 | var Prism = React.createClass({ 2955 | displayName: 'Prism', 2956 | 2957 | statics: { 2958 | _: _ 2959 | }, 2960 | getDefaultProps: function getDefaultProps() { 2961 | return { 2962 | language: 'javascript' 2963 | }; 2964 | }, 2965 | render: function render() { 2966 | var grammar = _.languages[this.props.language]; 2967 | return React.createElement( 2968 | 'div', 2969 | { className: 'language-' + this.props.language }, 2970 | Token.reactify(_.tokenize(this.props.children, grammar)) 2971 | ); 2972 | } 2973 | }); 2974 | 2975 | module.exports = Prism; 2976 | 2977 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 2978 | },{}]},{},[14])(14) 2979 | }); -------------------------------------------------------------------------------- /dist/react-cheat-sheet.min.js: -------------------------------------------------------------------------------- 1 | !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.ReactCheatSheet=e()}}(function(){return function e(t,n,r){function o(i,c){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!c&&l)return l(i,!0);if(a)return a(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var s=n[i]={exports:{}};t[i][0].call(s.exports,function(e){var n=t[i][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;ir;)e=e[t[r++]];return r&&r==o?e:void 0}}function i(e,t,n){var r=t.length,o=r,a=!n;if(null==e)return!o;for(e=h(e);r--;){var i=t[r];if(a&&i[2]?i[1]!==e[i[0]]:!(i[0]in e))return!1}for(;++rt&&(t=-t>o?0:o+t),n=void 0===n||n>o?o:+n||0,0>n&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(o);++r-1&&e%1==0&&p>=e}function l(e){return u(e)?e:Object(e)}function u(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}var s=e("lodash.keys"),p=9007199254740991,f=a(r),d=i(),m=o("length");t.exports=f},{"lodash.keys":12}],4:[function(e,t,n){function r(e,t){var n=[];return o(e,function(e,r,o){t(e,r,o)&&n.push(e)}),n}var o=e("lodash._baseeach");t.exports=r},{"lodash._baseeach":3}],5:[function(e,t,n){function r(e){return!!e&&"object"==typeof e}function o(e,t){for(var n=-1,r=e.length;++nu))return!1;for(;++l-1&&e%1==0&&p>=e}function c(e){return r(e)&&a(e)&&u.call(e,"callee")&&!s.call(e,"callee")}var l=Object.prototype,u=l.hasOwnProperty,s=l.propertyIsEnumerable,p=9007199254740991,f=o("length");t.exports=c},{}],10:[function(e,t,n){function r(e){return!!e&&"object"==typeof e}function o(e,t){var n=null==e?void 0:e[t];return l(n)?n:void 0}function a(e){return"number"==typeof e&&e>-1&&e%1==0&&b>=e}function i(e){return c(e)&&h.call(e)==s}function c(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function l(e){return null==e?!1:i(e)?y.test(d.call(e)):r(e)&&p.test(e)}var u="[object Array]",s="[object Function]",p=/^\[object .+?Constructor\]$/,f=Object.prototype,d=Function.prototype.toString,m=f.hasOwnProperty,h=f.toString,y=RegExp("^"+d.call(m).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),g=o(Array,"isArray"),b=9007199254740991,v=g||function(e){return r(e)&&a(e.length)&&h.call(e)==u};t.exports=v},{}],11:[function(e,t,n){function r(e){return!!e&&"object"==typeof e}function o(e){return"number"==typeof e&&e>-1&&e%1==0&&E>=e}function a(e){return r(e)&&o(e.length)&&!!M[S.call(e)]}var i="[object Arguments]",c="[object Array]",l="[object Boolean]",u="[object Date]",s="[object Error]",p="[object Function]",f="[object Map]",d="[object Number]",m="[object Object]",h="[object RegExp]",y="[object Set]",g="[object String]",b="[object WeakMap]",v="[object ArrayBuffer]",R="[object Float32Array]",x="[object Float64Array]",j="[object Int8Array]",w="[object Int16Array]",P="[object Int32Array]",O="[object Uint8Array]",k="[object Uint8ClampedArray]",T="[object Uint16Array]",_="[object Uint32Array]",M={};M[R]=M[x]=M[j]=M[w]=M[P]=M[O]=M[k]=M[T]=M[_]=!0,M[i]=M[c]=M[v]=M[l]=M[u]=M[s]=M[p]=M[f]=M[d]=M[m]=M[h]=M[y]=M[g]=M[b]=!1;var C=Object.prototype,S=C.toString,E=9007199254740991;t.exports=a},{}],12:[function(e,t,n){function r(e){return function(t){return null==t?void 0:t[e]}}function o(e){return null!=e&&i(b(e))}function a(e,t){return e="number"==typeof e||d.test(e)?+e:-1,t=null==t?g:t,e>-1&&e%1==0&&t>e}function i(e){return"number"==typeof e&&e>-1&&e%1==0&&g>=e}function c(e){for(var t=u(e),n=t.length,r=n&&e.length,o=!!r&&i(r)&&(f(e)||p(e)),c=-1,l=[];++c0;++r, document.getElementById('MyComponent');",reference:"http://facebook.github.io/react/docs/top-level-api.html#reactdom.render"},{name:"findDOMNode",example:"ReactDOM.findDOMNode(componentRef);",reference:"http://facebook.github.io/react/docs/top-level-api.html#reactdom.finddomnode"},{name:"unmountComponentAtNode",example:"ReactDOM.unmountComponentAtNode(document.getElementById('MyComponent'))",reference:"http://facebook.github.io/react/docs/top-level-api.html#reactdom.unmountcomponentatnode"}];n["default"]=a["default"](i,{module:"react-dom",color:"#85144b"}),t.exports=n["default"]},{"../assignSharedDefaults":16}],19:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var o=e("../assignSharedDefaults"),a=r(o),i=[{name:"renderToString",example:"ReactDOMServer.renderToString();",reference:"http://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring"},{name:"renderStaticMarkup",example:"ReactDOMServer.renderToStaticMarkup();",reference:"http://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostaticmarkup"}];n["default"]=a["default"](i,{module:"react-dom",color:"#85144b"}),t.exports=n["default"]},{"../assignSharedDefaults":16}],20:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var o=e("../assignSharedDefaults"),a=r(o),i=[{name:"componentWillMount",example:"componentWillMount: function () {\n // invoked once, before initial 'render'\n}",reference:"http://facebook.github.io/react/docs/component-specs.html#mounting-componentwillmount"},{name:"componentDidMount",example:"componentDidMount: function () {\n // invoked once (client-only), after initial 'render'\n // good for AJAX, setTimeout, setInterval\n}",reference:"http://facebook.github.io/react/docs/component-specs.html#mounting-componentdidmount"},{name:"componentWillReceiveProps",example:"componentWillReceiveProps: function (nextProps) {\n // invoked when component is receiving props, not for initial 'render'\n}",reference:"http://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops"},{name:"shouldComponentUpdate",example:"shouldComponentUpdate: function (nextProps, nextState) {\n // invoked before rendering with new props, not for initial 'render'\n}",reference:"http://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate"},{name:"componentWillUpdate",example:"componentWillUpdate: function (nextProps, nextState) {\n // invoked immediately before rendering with new props or state, not for initial 'render'\n // CANNOT CALL setState(). see componentWillReceiveProps\n}",reference:"http://facebook.github.io/react/docs/component-specs.html#updating-componentwillupdate"},{name:"componentDidUpdate",example:"componentDidUpdate: function (nextProps, nextState) {\n // invoked immediately after DOM updates, not for initial 'render'\n}",reference:"http://facebook.github.io/react/docs/component-specs.html#updating-componentdidupdate"},{name:"componentWillUnmount",example:"componentWillUnmount: function () {\n // invoked immediately before a component is unmounted from the DOM\n}",reference:"http://facebook.github.io/react/docs/component-specs.html#unmounting-componentwillunmount"}];n["default"]=a["default"](i,{module:"react",color:"#ff851b"}),t.exports=n["default"]},{"../assignSharedDefaults":16}],21:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var o=e("../assignSharedDefaults"),a=r(o),i=[{name:"PropTypes.array",example:"{\n optionalArray: React.PropTypes.array,\n requiredArray: React.PropTypes.array.isRequired\n}"},{name:"PropTypes.bool",example:"{\n optionalBoolean: React.PropTypes.bool,\n requiredBoolean: React.PropTypes.bool.isRequired\n}"},{name:"PropTypes.func",example:"{\n optionalFunction: React.PropTypes.func,\n requiredFunction: React.PropTypes.func.isRequired\n}"},{name:"PropTypes.number",example:"{\n optionalNumber: React.PropTypes.number,\n requiredNumber: React.PropTypes.number.isRequired\n}"},{name:"PropTypes.object",example:"{\n optionalObject: React.PropTypes.object,\n requiredObject: React.PropTypes.object.isRequired\n}"},{name:"PropTypes.string",example:"{\n optionalString: React.PropTypes.string,\n requiredString: React.PropTypes.string.isRequired\n}"},{name:"PropTypes.node",example:"{\n optionalNode: React.PropTypes.node,\n requiredNode: React.PropTypes.node.isRequired\n};\n\n// anything that can be rendered"},{name:"PropTypes.element",example:"{\n optionalElement: React.PropTypes.element,\n requiredElement: React.PropTypes.element.isRequired\n}"},{name:"PropTypes.instanceOf",example:"{\n optionalClass: React.PropTypes.instanceOf(MyClass),\n requiredClass: React.PropTypes.instanceOf(MyClass).isRequired\n}"},{name:"PropTypes.oneOf",example:"{\n optionalEnum: React.PropTypes.oneOf(['Thing 1', 'Thing 2']),\n optionalEnum: React.PropTypes.oneOf(['Thing 1', 'Thing 2']).isRequired\n}"},{name:"PropTypes.oneOfType",example:"{\n optionalUnion: React.PropTypes.oneOfType([\n React.PropTypes.bool,\n React.PropTypes.string\n ]),\n\n requiredUnion: React.PropTypes.oneOfType([\n React.PropTypes.bool,\n React.PropTypes.string\n ]).isRequired,\n}"},{name:"PropTypes.arrayOf",example:"{\n optionalArrayOf: React.PropTypes.arrayOf(React.PropTypes.string),\n requiredArrayOf: React.PropTypes.arrayOf(React.PropTypes.string).isRequired\n}"},{name:"PropTypes.objectOf",example:"{\n optionalObjectOf: React.PropTypes.objectOf(React.PropTypes.string),\n requiredObjectOf: React.PropTypes.objectOf(React.PropTypes.string).isRequired\n}\n\n// Type of property values"},{name:"PropTypes.shape",example:"{\n optionalObjectWithShape: React.PropTypes.shape({\n age: React.PropTypes.number,\n name: React.PropTypes.string\n }),\n\n requiredObjectWithShape: React.PropTypes.shape({\n age: React.PropTypes.number,\n name: React.PropTypes.string\n }).isRequired,\n\n requiredObjectWithRequiredShape: React.PropTypes.shape({\n age: React.PropTypes.number.isRequired,\n name: React.PropTypes.string.isRequired\n }).isRequired,\n}"},{name:"PropTypes.any",example:"{\n requiredAny: React.PropTypes.any.isRequired\n}"}];n["default"]=a["default"](i,{module:"react",color:"#f012be",reference:"https://facebook.github.io/react/docs/reusable-components.html#prop-validation"}),t.exports=n["default"]},{"../assignSharedDefaults":16}],22:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var o=e("../assignSharedDefaults"),a=r(o),i=[{name:"render",example:"render: function () {\n return
;\n}",reference:"http://facebook.github.io/react/docs/component-specs.html#render"},{name:"getInitialState",example:"getInitialState: function () {\n return { key: value };\n}\n\n// not available with React.Component",reference:"http://facebook.github.io/react/docs/component-specs.html#getinitialstate"},{name:"getDefaultProps",example:"getDefaultProps: function () {\n return { key: value };\n}\n\n// not available with React.Component",reference:"http://facebook.github.io/react/docs/component-specs.html#getdefaultprops"},{name:"propTypes",example:"propTypes: function () {\n myProp: React.PropTypes.bool\n}\n\n// not available with React.Component",reference:"http://facebook.github.io/react/docs/component-specs.html#proptypes"},{name:"mixins",example:"mixins: [ AMixinObject, AnotherMixinObject ];\n\n// not available in React.Component",reference:"http://facebook.github.io/react/docs/component-specs.html#mixins"},{name:"statics",example:"statics: {\n customMethod: function(foo) {\n return foo === 'bar';\n }\n}",reference:"http://facebook.github.io/react/docs/component-specs.html#statics"},{name:"displayName",example:'displayName: "MyComponent"',reference:"http://facebook.github.io/react/docs/component-specs.html#displayname"}];n["default"]=a["default"](i,{module:"react",color:"#3d9970"}),t.exports=n["default"]},{"../assignSharedDefaults":16}],23:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var o=e("../assignSharedDefaults"),a=r(o),i=[{name:"Component",example:"// ES2015\n\nclass MyComponent extends React.Component {\n render () {\n return
;\n }\n}\n",reference:"http://facebook.github.io/react/docs/top-level-api.html#react.component"},{name:"createClass",example:"var MyComponent = React.createClass({\n render: function () {\n return
;\n }\n});",reference:"http://facebook.github.io/react/docs/top-level-api.html#react.createclass"},{name:"createElement",example:"React.createElement('div', props, ...children); // String\n\nReact.createElement(MyComponent, props, ...children); // ReactClass type",reference:"http://facebook.github.io/react/docs/top-level-api.html#react.createelement"},{name:"cloneElement",example:"React.cloneElement(element, props, ...children);",reference:"http://facebook.github.io/react/docs/top-level-api.html#react.cloneelement"},{name:"createFactory",example:"React.createFactory('div'); // String;\n\nReact.createFactory(MyComponentClass); // ReactClass type",reference:"http://facebook.github.io/react/docs/top-level-api.html#react.createfactory"},{name:"isValidElement",example:"React.isValidElement(MyComponent);",reference:"http://facebook.github.io/react/docs/top-level-api.html#react.isvalidelement"},{name:"Children.map",example:"React.Children.map(this.props.children, (child, i) => {\n return child;\n})",reference:"http://facebook.github.io/react/docs/top-level-api.html#react.children.map"},{name:"Children.forEach",example:"React.Children.forEach(this.props.children, (child, i) => {\n console.log(child + ' at index: ' + i);\n})",reference:"http://facebook.github.io/react/docs/top-level-api.html#react.children.foreach"},{name:"Children.count",example:"React.Children.count(this.props.children);",reference:"http://facebook.github.io/react/docs/top-level-api.html#react.children.count"},{name:"Children.only",example:"none",reference:"http://facebook.github.io/react/docs/top-level-api.html#react.children.only"},{name:"Children.toArray",example:"none",reference:"http://facebook.github.io/react/docs/top-level-api.html#react.children.toarray"}];n["default"]=a["default"](i,{module:"react",color:"#ffdc00"}),t.exports=n["default"]},{"../assignSharedDefaults":16}],24:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n["default"]={article:{paddingTop:"1em",paddingBottom:"1em"}},t.exports=n["default"]},{}],25:[function(e,t,n){(function(e){"use strict";var n="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,r={util:{type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function i(e){var t=r.util.type(e);switch(t){case"Object":var i={};for(var n in e)e.hasOwnProperty(n)&&(i[n]=r.util.clone(e[n]));return i;case"Array":return e.slice()}return e}},languages:{extend:function(e,t){var n=r.util.clone(r.languages[e]);for(var o in t)n[o]=t[o];return n},insertBefore:function(e,t,n,o){o=o||r.languages;var a=o[e],i={};for(var c in a)if(a.hasOwnProperty(c)){if(c==t)for(var l in n)n.hasOwnProperty(l)&&(i[l]=n[l]);i[c]=a[c]}return o[e]=i},DFS:function(e,t){for(var n in e)t.call(e,n,e[n]),"Object"===r.util.type(e)&&r.languages.DFS(e[n],t)}},tokenize:function(e,t,n){var o=r.Token,a=[e],i=t.rest;if(i){for(var c in i)t[c]=i[c];delete t.rest}e:for(var c in t)if(t.hasOwnProperty(c)&&t[c]){var l=t[c],u=l.inside,s=!!l.lookbehind,p=0;l=l.pattern||l;for(var f=0;fe.length)break e;if(!(d instanceof o)){l.lastIndex=0;var m=l.exec(d);if(m){s&&(p=m[1].length);var h=m.index-1+p,m=m[0].slice(p),y=m.length,g=h+y,b=d.slice(0,h+1),v=d.slice(g+1),R=[f,1];b&&R.push(b);var x=new o(c,u?r.tokenize(m,u):m);R.push(x),v&&R.push(v),Array.prototype.splice.apply(a,R)}}}}return a},hooks:{all:{},add:function(e,t){var n=r.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=r.hooks.all[e];if(n&&n.length)for(var o,a=0;o=n[a++];)o(t)}}},o=r.Token=function(e,t){this.type=e,this.content=t};o.reactify=function(e){if("string"==typeof e)return e;if(Array.isArray(e))return e.map(function(e){return o.reactify(e)});var t={className:"token "+e.type};return"comment"==e.type&&(t.spellcheck=!0),n.DOM.span(t,o.reactify(e.content))},r.languages.markup={comment:/<!--[\w\W]*?-->/g,prolog:/<\?.+?\?>/,doctype:/<!DOCTYPE.+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,inside:{punctuation:/=|>|"/g}},punctuation:/\/?>/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/&#?[\da-z]{1,8};/gi},r.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*{))/gi,inside:{punctuation:/[;:]/g}},url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/g,property:/(\b|\B)[\w-]+(?=\s*:)/gi,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,ignore:/&(lt|gt|amp);/gi,punctuation:/[\{\};:]/g},r.languages.insertBefore("markup","tag",{style:{pattern:/(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/gi,inside:{tag:{pattern:/(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/gi,inside:r.languages.markup.tag.inside},rest:r.languages.css}}}),r.languages.clike={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g,lookbehind:!0},string:/("|')(\\?.)*?\1/g,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/gi,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,"function":{pattern:/[a-z0-9_]+\(/gi,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%/g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g},r.languages.javascript=r.languages.extend("clike",{keyword:/\b(class|extends|var|let|if|else|while|do|for|return|in|instanceof|function|get|set|new|with|typeof|try|throw|catch|finally|null|break|continue|this)\b/g,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?|NaN|-?Infinity)\b/g}),r.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,lookbehind:!0}}),r.languages.insertBefore("markup","tag",{script:{pattern:/(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/gi, 2 | inside:{tag:{pattern:/(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/gi,inside:r.languages.markup.tag.inside},rest:r.languages.javascript}}});var a=n.createClass({displayName:"Prism",statics:{_:r},getDefaultProps:function(){return{language:"javascript"}},render:function(){var e=r.languages[this.props.language];return n.createElement("div",{className:"language-"+this.props.language},o.reactify(r.tokenize(this.props.children,e)))}});t.exports=a}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[14])(14)}); -------------------------------------------------------------------------------- /example/src/.gitignore: -------------------------------------------------------------------------------- 1 | ## This file is here to ensure it is included in the gh-pages branch, 2 | ## when `gulp deploy` is used to push updates to the demo site. 3 | 4 | # Dependency directory 5 | node_modules 6 | -------------------------------------------------------------------------------- /example/src/example.js: -------------------------------------------------------------------------------- 1 | var React = require('react'); 2 | var ReactCheatSheet = require('react-cheat-sheet'); 3 | 4 | React.render(, document.getElementById('app')); 5 | -------------------------------------------------------------------------------- /example/src/example.less: -------------------------------------------------------------------------------- 1 | .sans-serif { 2 | font-family: 'avenir next', avenir, helvetica, 'helvetica neue', arial, sans-serif; 3 | } 4 | 5 | /* prism theme */ 6 | 7 | .language-javascript { 8 | color: #dbdee4; 9 | 10 | .token { 11 | &.string { color: #98c379 } 12 | &.comment { 13 | color: #5c6370; 14 | font-style: italic; 15 | } 16 | &.class-name { color: #e5c07b } 17 | &.keyword { color: #c678dd } 18 | &.operator { color: #e06c75 } 19 | &.function *:first-child { color: #56b6c2 } 20 | &.punctuation ~ &.keyword { color: green } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /example/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | React Cheat Sheet 4 | 5 | 6 | 7 | 8 |
12 |

React Cheat Sheet

13 | 14 |
15 | 16 | 19 |
20 | 21 | 22 | 23 | 33 | 34 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var initGulpTasks = require('react-component-gulp-tasks'); 3 | 4 | /** 5 | * Tasks are added by the react-component-gulp-tasks package 6 | * 7 | * See https://github.com/JedWatson/react-component-gulp-tasks 8 | * for documentation. 9 | * 10 | * You can also add your own additional gulp tasks if you like. 11 | */ 12 | 13 | var taskConfig = { 14 | 15 | component: { 16 | name: 'ReactCheatSheet', 17 | dependencies: [ 18 | 'classnames', 19 | 'react', 20 | 'react/addons' 21 | ], 22 | lib: 'lib' 23 | }, 24 | 25 | example: { 26 | src: 'example/src', 27 | dist: 'example/dist', 28 | files: [ 29 | 'index.html', 30 | '.gitignore' 31 | ], 32 | scripts: [ 33 | 'example.js' 34 | ], 35 | less: [ 36 | 'example.less' 37 | ] 38 | } 39 | 40 | }; 41 | 42 | initGulpTasks(gulp, taskConfig); 43 | -------------------------------------------------------------------------------- /lib/ReactCheatSheet.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { 4 | value: true 5 | }); 6 | 7 | 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; }; 8 | 9 | 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; }; })(); 10 | 11 | var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; 12 | 13 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 14 | 15 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } 16 | 17 | 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; } 18 | 19 | var _react = require('react'); 20 | 21 | var _react2 = _interopRequireDefault(_react); 22 | 23 | var _styles = require('./styles'); 24 | 25 | var _lodashFilter = require('lodash.filter'); 26 | 27 | var _lodashFilter2 = _interopRequireDefault(_lodashFilter); 28 | 29 | var _dataJs = require('./data.js'); 30 | 31 | var _dataJs2 = _interopRequireDefault(_dataJs); 32 | 33 | var _ReferenceItemJs = require('./ReferenceItem.js'); 34 | 35 | var _ReferenceItemJs2 = _interopRequireDefault(_ReferenceItemJs); 36 | 37 | function filterResults(predicate, _data) { 38 | return (0, _lodashFilter2['default'])(_data, function (_ref) { 39 | var name = _ref.name; 40 | 41 | return name.match(new RegExp(predicate, 'i')); 42 | }); 43 | } 44 | 45 | var inputStyle = { 46 | width: "50%", 47 | padding: 10, 48 | fontSize: "1em", 49 | borderRadius: 2, 50 | border: "1px solid #aaa", 51 | color: "black" 52 | }; 53 | 54 | var ReactCheatSheet = (function (_Component) { 55 | _inherits(ReactCheatSheet, _Component); 56 | 57 | function ReactCheatSheet(props) { 58 | var _this = this; 59 | 60 | _classCallCheck(this, ReactCheatSheet); 61 | 62 | _get(Object.getPrototypeOf(ReactCheatSheet.prototype), 'constructor', this).call(this, props); 63 | 64 | this.state = { 65 | predicate: '' 66 | }; 67 | 68 | this.handleChange = function () { 69 | _this.setState({ predicate: _this.searchInput.getDOMNode().value }); 70 | }; 71 | } 72 | 73 | _createClass(ReactCheatSheet, [{ 74 | key: 'render', 75 | value: function render() { 76 | var _this2 = this; 77 | 78 | var noResults = function noResults() { 79 | return _react2['default'].createElement( 80 | 'article', 81 | { style: _extends({}, _styles.article) }, 82 | _react2['default'].createElement( 83 | 'h2', 84 | null, 85 | 'No results' 86 | ) 87 | ); 88 | }; 89 | 90 | var results = function results() { 91 | return _this2.filteredResults.map(_ReferenceItemJs2['default']); 92 | }; 93 | 94 | return _react2['default'].createElement( 95 | 'main', 96 | null, 97 | _react2['default'].createElement( 98 | 'label', 99 | null, 100 | _react2['default'].createElement('input', { 101 | autoFocus: true, 102 | type: 'text', 103 | style: inputStyle, 104 | placeholder: 'Filter by name', 105 | value: this.state.predicate, 106 | ref: function (c) { 107 | return _this2.searchInput = c; 108 | }, 109 | onChange: this.handleChange 110 | }), 111 | _react2['default'].createElement( 112 | 'div', 113 | null, 114 | _react2['default'].createElement( 115 | 'small', 116 | { style: { color: "#999" } }, 117 | '* using case-insensitive regex match' 118 | ) 119 | ) 120 | ), 121 | _react2['default'].createElement( 122 | 'section', 123 | null, 124 | this.filteredResults.length ? results() : noResults() 125 | ) 126 | ); 127 | } 128 | }, { 129 | key: 'filteredResults', 130 | get: function get() { 131 | return filterResults(this.state.predicate, _dataJs2['default']); 132 | } 133 | }]); 134 | 135 | return ReactCheatSheet; 136 | })(_react.Component); 137 | 138 | exports['default'] = ReactCheatSheet; 139 | module.exports = exports['default']; -------------------------------------------------------------------------------- /lib/ReferenceItem.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { 4 | value: true 5 | }); 6 | 7 | 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; }; 8 | 9 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 10 | 11 | var _react = require('react'); 12 | 13 | var _react2 = _interopRequireDefault(_react); 14 | 15 | var _styles = require('./styles'); 16 | 17 | var _vendorPrism = require('./vendor/Prism'); 18 | 19 | var _vendorPrism2 = _interopRequireDefault(_vendorPrism); 20 | 21 | var styles = { 22 | root: _extends({}, _styles.article, { 23 | borderBottom: '1px solid #333' 24 | }), 25 | header: { 26 | overflowY: 'scroll' 27 | }, 28 | module: { 29 | marginLeft: '.5em', 30 | fontSize: '1em', 31 | color: '#aaa', 32 | fontWeight: 'normal' 33 | }, 34 | example: { 35 | position: 'relative', 36 | overflow: 'hidden', 37 | overflowX: 'scroll', 38 | backgroundColor: 'rgb(40, 44, 52)', 39 | color: 'white', 40 | padding: 20, 41 | borderRadius: 2 42 | }, 43 | exampleColorCode: { 44 | position: 'absolute', 45 | left: 0, 46 | top: 0, 47 | height: '100%', 48 | width: 4 49 | }, 50 | code: { 51 | fontFamily: "Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace" 52 | }, 53 | reference: { 54 | textAlign: 'right' 55 | } 56 | }; 57 | 58 | var ReferenceItem = function ReferenceItem(_ref) { 59 | var name = _ref.name; 60 | var module = _ref.module; 61 | var href = _ref.reference; 62 | var example = _ref.example; 63 | var backgroundColor = _ref.color; 64 | return _react2['default'].createElement( 65 | 'article', 66 | { style: styles.root }, 67 | _react2['default'].createElement( 68 | 'h2', 69 | { style: styles.header }, 70 | name, 71 | _react2['default'].createElement( 72 | 'span', 73 | { style: styles.module }, 74 | module 75 | ) 76 | ), 77 | _react2['default'].createElement( 78 | 'pre', 79 | { style: styles.example }, 80 | _react2['default'].createElement( 81 | 'code', 82 | { style: styles.code }, 83 | _react2['default'].createElement( 84 | _vendorPrism2['default'], 85 | null, 86 | example 87 | ) 88 | ), 89 | _react2['default'].createElement('div', { style: _extends({ backgroundColor: backgroundColor }, styles.exampleColorCode) }) 90 | ), 91 | _react2['default'].createElement( 92 | 'div', 93 | { style: styles.reference }, 94 | href && _react2['default'].createElement( 95 | 'a', 96 | { href: href, target: '_blank' }, 97 | 'Read more →' 98 | ) 99 | ) 100 | ); 101 | }; 102 | 103 | exports['default'] = ReferenceItem; 104 | module.exports = exports['default']; -------------------------------------------------------------------------------- /lib/assignSharedDefaults.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | 7 | 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; }; 8 | 9 | exports["default"] = function (collection, defaults) { 10 | return collection.map(function (el) { 11 | return _extends({}, el, defaults); 12 | }); 13 | }; 14 | 15 | module.exports = exports["default"]; -------------------------------------------------------------------------------- /lib/data.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { 4 | value: true 5 | }); 6 | 7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 8 | 9 | function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } 10 | 11 | var _dataReactDOM = require('./data/ReactDOM'); 12 | 13 | var _dataReactDOM2 = _interopRequireDefault(_dataReactDOM); 14 | 15 | var _dataReactDOM_Server = require('./data/ReactDOM_Server'); 16 | 17 | var _dataReactDOM_Server2 = _interopRequireDefault(_dataReactDOM_Server); 18 | 19 | var _dataReact_TopLevel = require('./data/React_TopLevel'); 20 | 21 | var _dataReact_TopLevel2 = _interopRequireDefault(_dataReact_TopLevel); 22 | 23 | var _dataReact_Spec = require('./data/React_Spec'); 24 | 25 | var _dataReact_Spec2 = _interopRequireDefault(_dataReact_Spec); 26 | 27 | var _dataReact_Lifecycle = require('./data/React_Lifecycle'); 28 | 29 | var _dataReact_Lifecycle2 = _interopRequireDefault(_dataReact_Lifecycle); 30 | 31 | var _dataReact_PropTypes = require('./data/React_PropTypes'); 32 | 33 | var _dataReact_PropTypes2 = _interopRequireDefault(_dataReact_PropTypes); 34 | 35 | exports['default'] = [].concat(_toConsumableArray(_dataReactDOM2['default']), _toConsumableArray(_dataReactDOM_Server2['default']), _toConsumableArray(_dataReact_TopLevel2['default']), _toConsumableArray(_dataReact_Spec2['default']), _toConsumableArray(_dataReact_Lifecycle2['default']), _toConsumableArray(_dataReact_PropTypes2['default'])); 36 | module.exports = exports['default']; -------------------------------------------------------------------------------- /lib/data/ReactDOM.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { 4 | value: true 5 | }); 6 | 7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 8 | 9 | var _assignSharedDefaults = require('../assignSharedDefaults'); 10 | 11 | var _assignSharedDefaults2 = _interopRequireDefault(_assignSharedDefaults); 12 | 13 | var data = [{ 14 | name: 'render', 15 | example: 'ReactDOM.render(, document.getElementById(\'MyComponent\');', 16 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdom.render' 17 | }, { 18 | name: 'findDOMNode', 19 | example: 'ReactDOM.findDOMNode(componentRef);', 20 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdom.finddomnode' 21 | }, { 22 | name: 'unmountComponentAtNode', 23 | example: 'ReactDOM.unmountComponentAtNode(document.getElementById(\'MyComponent\'))', 24 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdom.unmountcomponentatnode' 25 | }]; 26 | 27 | exports['default'] = (0, _assignSharedDefaults2['default'])(data, { module: 'react-dom', color: '#85144b' }); 28 | module.exports = exports['default']; -------------------------------------------------------------------------------- /lib/data/ReactDOM_Server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { 4 | value: true 5 | }); 6 | 7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 8 | 9 | var _assignSharedDefaults = require('../assignSharedDefaults'); 10 | 11 | var _assignSharedDefaults2 = _interopRequireDefault(_assignSharedDefaults); 12 | 13 | var data = [{ 14 | name: 'renderToString', 15 | example: 'ReactDOMServer.renderToString();', 16 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring' 17 | }, { 18 | name: 'renderStaticMarkup', 19 | example: 'ReactDOMServer.renderToStaticMarkup();', 20 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostaticmarkup' 21 | }]; 22 | 23 | exports['default'] = (0, _assignSharedDefaults2['default'])(data, { module: 'react-dom', color: '#85144b' }); 24 | module.exports = exports['default']; -------------------------------------------------------------------------------- /lib/data/React_Lifecycle.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { 4 | value: true 5 | }); 6 | 7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 8 | 9 | var _assignSharedDefaults = require('../assignSharedDefaults'); 10 | 11 | var _assignSharedDefaults2 = _interopRequireDefault(_assignSharedDefaults); 12 | 13 | var data = [{ 14 | name: 'componentWillMount', 15 | example: 'componentWillMount: function () {\n // invoked once, before initial \'render\'\n}', 16 | reference: 'http://facebook.github.io/react/docs/component-specs.html#mounting-componentwillmount' 17 | }, { 18 | name: 'componentDidMount', 19 | example: 'componentDidMount: function () {\n // invoked once (client-only), after initial \'render\'\n // good for AJAX, setTimeout, setInterval\n}', 20 | reference: 'http://facebook.github.io/react/docs/component-specs.html#mounting-componentdidmount' 21 | }, { 22 | name: 'componentWillReceiveProps', 23 | example: 'componentWillReceiveProps: function (nextProps) {\n // invoked when component is receiving props, not for initial \'render\'\n}', 24 | reference: 'http://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops' 25 | }, { 26 | name: 'shouldComponentUpdate', 27 | example: 'shouldComponentUpdate: function (nextProps, nextState) {\n // invoked before rendering with new props, not for initial \'render\'\n}', 28 | reference: 'http://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate' 29 | }, { 30 | name: 'componentWillUpdate', 31 | example: 'componentWillUpdate: function (nextProps, nextState) {\n // invoked immediately before rendering with new props or state, not for initial \'render\'\n // CANNOT CALL setState(). see componentWillReceiveProps\n}', 32 | reference: 'http://facebook.github.io/react/docs/component-specs.html#updating-componentwillupdate' 33 | }, { 34 | name: 'componentDidUpdate', 35 | example: 'componentDidUpdate: function (nextProps, nextState) {\n // invoked immediately after DOM updates, not for initial \'render\'\n}', 36 | reference: 'http://facebook.github.io/react/docs/component-specs.html#updating-componentdidupdate' 37 | }, { 38 | name: 'componentWillUnmount', 39 | example: 'componentWillUnmount: function () {\n // invoked immediately before a component is unmounted from the DOM\n}', 40 | reference: 'http://facebook.github.io/react/docs/component-specs.html#unmounting-componentwillunmount' 41 | }]; 42 | 43 | exports['default'] = (0, _assignSharedDefaults2['default'])(data, { module: 'react', color: '#ff851b' }); 44 | module.exports = exports['default']; -------------------------------------------------------------------------------- /lib/data/React_PropTypes.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { 4 | value: true 5 | }); 6 | 7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 8 | 9 | var _assignSharedDefaults = require('../assignSharedDefaults'); 10 | 11 | var _assignSharedDefaults2 = _interopRequireDefault(_assignSharedDefaults); 12 | 13 | var data = [{ 14 | name: 'PropTypes.array', 15 | example: '{\n optionalArray: React.PropTypes.array,\n requiredArray: React.PropTypes.array.isRequired\n}' 16 | }, { 17 | name: 'PropTypes.bool', 18 | example: '{\n optionalBoolean: React.PropTypes.bool,\n requiredBoolean: React.PropTypes.bool.isRequired\n}' 19 | }, { 20 | name: 'PropTypes.func', 21 | example: '{\n optionalFunction: React.PropTypes.func,\n requiredFunction: React.PropTypes.func.isRequired\n}' 22 | }, { 23 | name: 'PropTypes.number', 24 | example: '{\n optionalNumber: React.PropTypes.number,\n requiredNumber: React.PropTypes.number.isRequired\n}' 25 | }, { 26 | name: 'PropTypes.object', 27 | example: '{\n optionalObject: React.PropTypes.object,\n requiredObject: React.PropTypes.object.isRequired\n}' 28 | }, { 29 | name: 'PropTypes.string', 30 | example: '{\n optionalString: React.PropTypes.string,\n requiredString: React.PropTypes.string.isRequired\n}' 31 | }, { 32 | name: 'PropTypes.node', 33 | example: '{\n optionalNode: React.PropTypes.node,\n requiredNode: React.PropTypes.node.isRequired\n};\n\n// anything that can be rendered' 34 | }, { 35 | name: 'PropTypes.element', 36 | example: '{\n optionalElement: React.PropTypes.element,\n requiredElement: React.PropTypes.element.isRequired\n}' 37 | }, { 38 | name: 'PropTypes.instanceOf', 39 | example: '{\n optionalClass: React.PropTypes.instanceOf(MyClass),\n requiredClass: React.PropTypes.instanceOf(MyClass).isRequired\n}' 40 | }, { 41 | name: 'PropTypes.oneOf', 42 | example: '{\n optionalEnum: React.PropTypes.oneOf([\'Thing 1\', \'Thing 2\']),\n optionalEnum: React.PropTypes.oneOf([\'Thing 1\', \'Thing 2\']).isRequired\n}' 43 | }, { 44 | name: 'PropTypes.oneOfType', 45 | example: '{\n optionalUnion: React.PropTypes.oneOfType([\n React.PropTypes.bool,\n React.PropTypes.string\n ]),\n\n requiredUnion: React.PropTypes.oneOfType([\n React.PropTypes.bool,\n React.PropTypes.string\n ]).isRequired,\n}' 46 | }, { 47 | name: 'PropTypes.arrayOf', 48 | example: '{\n optionalArrayOf: React.PropTypes.arrayOf(React.PropTypes.string),\n requiredArrayOf: React.PropTypes.arrayOf(React.PropTypes.string).isRequired\n}' 49 | }, { 50 | name: 'PropTypes.objectOf', 51 | example: '{\n optionalObjectOf: React.PropTypes.objectOf(React.PropTypes.string),\n requiredObjectOf: React.PropTypes.objectOf(React.PropTypes.string).isRequired\n}\n\n// Type of property values' 52 | }, { 53 | name: 'PropTypes.shape', 54 | example: '{\n optionalObjectWithShape: React.PropTypes.shape({\n age: React.PropTypes.number,\n name: React.PropTypes.string\n }),\n\n requiredObjectWithShape: React.PropTypes.shape({\n age: React.PropTypes.number,\n name: React.PropTypes.string\n }).isRequired,\n\n requiredObjectWithRequiredShape: React.PropTypes.shape({\n age: React.PropTypes.number.isRequired,\n name: React.PropTypes.string.isRequired\n }).isRequired,\n}' 55 | }, { 56 | name: 'PropTypes.any', 57 | example: '{\n requiredAny: React.PropTypes.any.isRequired\n}' 58 | }]; 59 | 60 | exports['default'] = (0, _assignSharedDefaults2['default'])(data, { module: 'react', color: '#f012be', reference: 'https://facebook.github.io/react/docs/reusable-components.html#prop-validation' }); 61 | module.exports = exports['default']; -------------------------------------------------------------------------------- /lib/data/React_Spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { 4 | value: true 5 | }); 6 | 7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 8 | 9 | var _assignSharedDefaults = require('../assignSharedDefaults'); 10 | 11 | var _assignSharedDefaults2 = _interopRequireDefault(_assignSharedDefaults); 12 | 13 | var data = [{ 14 | name: 'render', 15 | example: 'render: function () {\n return
;\n}', 16 | reference: 'http://facebook.github.io/react/docs/component-specs.html#render' 17 | }, { 18 | name: 'getInitialState', 19 | example: 'getInitialState: function () {\n return { key: value };\n}\n\n// not available with React.Component', 20 | reference: 'http://facebook.github.io/react/docs/component-specs.html#getinitialstate' 21 | }, { 22 | name: 'getDefaultProps', 23 | example: 'getDefaultProps: function () {\n return { key: value };\n}\n\n// not available with React.Component', 24 | reference: 'http://facebook.github.io/react/docs/component-specs.html#getdefaultprops' 25 | }, { 26 | name: 'propTypes', 27 | example: 'propTypes: function () {\n myProp: React.PropTypes.bool\n}\n\n// not available with React.Component', 28 | reference: 'http://facebook.github.io/react/docs/component-specs.html#proptypes' 29 | }, { 30 | name: 'mixins', 31 | example: 'mixins: [ AMixinObject, AnotherMixinObject ];\n\n// not available in React.Component', 32 | reference: 'http://facebook.github.io/react/docs/component-specs.html#mixins' 33 | }, { 34 | name: 'statics', 35 | example: 'statics: {\n customMethod: function(foo) {\n return foo === \'bar\';\n }\n}', 36 | reference: 'http://facebook.github.io/react/docs/component-specs.html#statics' 37 | }, { 38 | name: 'displayName', 39 | example: 'displayName: "MyComponent"', 40 | reference: 'http://facebook.github.io/react/docs/component-specs.html#displayname' 41 | }]; 42 | 43 | exports['default'] = (0, _assignSharedDefaults2['default'])(data, { module: 'react', color: '#3d9970' }); 44 | module.exports = exports['default']; -------------------------------------------------------------------------------- /lib/data/React_TopLevel.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { 4 | value: true 5 | }); 6 | 7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 8 | 9 | var _assignSharedDefaults = require('../assignSharedDefaults'); 10 | 11 | var _assignSharedDefaults2 = _interopRequireDefault(_assignSharedDefaults); 12 | 13 | var data = [{ 14 | name: 'Component', 15 | example: '// ES2015\n\nclass MyComponent extends React.Component {\n render () {\n return
;\n }\n}\n', 16 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.component' 17 | }, { 18 | name: 'createClass', 19 | example: 'var MyComponent = React.createClass({\n render: function () {\n return
;\n }\n});', 20 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.createclass' 21 | }, { 22 | name: 'createElement', 23 | example: 'React.createElement(\'div\', props, ...children); // String\n\nReact.createElement(MyComponent, props, ...children); // ReactClass type', 24 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.createelement' 25 | }, { 26 | name: 'cloneElement', 27 | example: 'React.cloneElement(element, props, ...children);', 28 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.cloneelement' 29 | }, { 30 | name: 'createFactory', 31 | example: 'React.createFactory(\'div\'); // String;\n\nReact.createFactory(MyComponentClass); // ReactClass type', 32 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.createfactory' 33 | }, { 34 | name: 'isValidElement', 35 | example: 'React.isValidElement(MyComponent);', 36 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.isvalidelement' 37 | }, { 38 | name: 'Children.map', 39 | example: 'React.Children.map(this.props.children, (child, i) => {\n return child;\n})', 40 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.map' 41 | }, { 42 | name: 'Children.forEach', 43 | example: 'React.Children.forEach(this.props.children, (child, i) => {\n console.log(child + \' at index: \' + i);\n})', 44 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.foreach' 45 | }, { 46 | name: 'Children.count', 47 | example: 'React.Children.count(this.props.children);', 48 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.count' 49 | }, { 50 | name: 'Children.only', 51 | example: 'none', 52 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.only' 53 | }, { 54 | name: 'Children.toArray', 55 | example: 'none', 56 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.toarray' 57 | }]; 58 | 59 | exports['default'] = (0, _assignSharedDefaults2['default'])(data, { module: 'react', color: '#ffdc00' }); 60 | module.exports = exports['default']; -------------------------------------------------------------------------------- /lib/styles.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { 4 | value: true 5 | }); 6 | exports['default'] = { 7 | article: { 8 | paddingTop: '1em', 9 | paddingBottom: '1em' 10 | } 11 | }; 12 | module.exports = exports['default']; -------------------------------------------------------------------------------- /lib/vendor/Prism.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Prism: Lightweight, robust, elegant syntax highlighting 3 | * MIT license http://www.opensource.org/licenses/mit-license.php/ 4 | * @author Lea Verou http://lea.verou.me 5 | * 6 | * @providesModule Prism 7 | * @jsx React.DOM 8 | */ 9 | 10 | 'use strict'; 11 | 12 | var React = require('react'); 13 | 14 | // Private helper vars 15 | var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; 16 | 17 | var _ = { 18 | util: { 19 | type: function type(o) { 20 | return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1]; 21 | }, 22 | 23 | // Deep clone a language definition (e.g. to extend it) 24 | clone: function clone(o) { 25 | var type = _.util.type(o); 26 | 27 | switch (type) { 28 | case 'Object': 29 | var clone = {}; 30 | 31 | for (var key in o) { 32 | if (o.hasOwnProperty(key)) { 33 | clone[key] = _.util.clone(o[key]); 34 | } 35 | } 36 | 37 | return clone; 38 | 39 | case 'Array': 40 | return o.slice(); 41 | } 42 | 43 | return o; 44 | } 45 | }, 46 | 47 | languages: { 48 | extend: function extend(id, redef) { 49 | var lang = _.util.clone(_.languages[id]); 50 | 51 | for (var key in redef) { 52 | lang[key] = redef[key]; 53 | } 54 | 55 | return lang; 56 | }, 57 | 58 | // Insert a token before another token in a language literal 59 | insertBefore: function insertBefore(inside, before, insert, root) { 60 | root = root || _.languages; 61 | var grammar = root[inside]; 62 | var ret = {}; 63 | 64 | for (var token in grammar) { 65 | 66 | if (grammar.hasOwnProperty(token)) { 67 | 68 | if (token == before) { 69 | 70 | for (var newToken in insert) { 71 | 72 | if (insert.hasOwnProperty(newToken)) { 73 | ret[newToken] = insert[newToken]; 74 | } 75 | } 76 | } 77 | 78 | ret[token] = grammar[token]; 79 | } 80 | } 81 | 82 | return root[inside] = ret; 83 | }, 84 | 85 | // Traverse a language definition with Depth First Search 86 | DFS: function DFS(o, callback) { 87 | for (var i in o) { 88 | callback.call(o, i, o[i]); 89 | 90 | if (_.util.type(o) === 'Object') { 91 | _.languages.DFS(o[i], callback); 92 | } 93 | } 94 | } 95 | }, 96 | 97 | tokenize: function tokenize(text, grammar, language) { 98 | var Token = _.Token; 99 | 100 | var strarr = [text]; 101 | 102 | var rest = grammar.rest; 103 | 104 | if (rest) { 105 | for (var token in rest) { 106 | grammar[token] = rest[token]; 107 | } 108 | 109 | delete grammar.rest; 110 | } 111 | 112 | tokenloop: for (var token in grammar) { 113 | if (!grammar.hasOwnProperty(token) || !grammar[token]) { 114 | continue; 115 | } 116 | 117 | var pattern = grammar[token], 118 | inside = pattern.inside, 119 | lookbehind = !!pattern.lookbehind, 120 | lookbehindLength = 0; 121 | 122 | pattern = pattern.pattern || pattern; 123 | 124 | for (var i = 0; i < strarr.length; i++) { 125 | // Don’t cache length as it changes during the loop 126 | 127 | var str = strarr[i]; 128 | 129 | if (strarr.length > text.length) { 130 | // Something went terribly wrong, ABORT, ABORT! 131 | break tokenloop; 132 | } 133 | 134 | if (str instanceof Token) { 135 | continue; 136 | } 137 | 138 | pattern.lastIndex = 0; 139 | 140 | var match = pattern.exec(str); 141 | 142 | if (match) { 143 | if (lookbehind) { 144 | lookbehindLength = match[1].length; 145 | } 146 | 147 | var from = match.index - 1 + lookbehindLength, 148 | match = match[0].slice(lookbehindLength), 149 | len = match.length, 150 | to = from + len, 151 | before = str.slice(0, from + 1), 152 | after = str.slice(to + 1); 153 | 154 | var args = [i, 1]; 155 | 156 | if (before) { 157 | args.push(before); 158 | } 159 | 160 | var wrapped = new Token(token, inside ? _.tokenize(match, inside) : match); 161 | 162 | args.push(wrapped); 163 | 164 | if (after) { 165 | args.push(after); 166 | } 167 | 168 | Array.prototype.splice.apply(strarr, args); 169 | } 170 | } 171 | } 172 | 173 | return strarr; 174 | }, 175 | 176 | hooks: { 177 | all: {}, 178 | 179 | add: function add(name, callback) { 180 | var hooks = _.hooks.all; 181 | 182 | hooks[name] = hooks[name] || []; 183 | 184 | hooks[name].push(callback); 185 | }, 186 | 187 | run: function run(name, env) { 188 | var callbacks = _.hooks.all[name]; 189 | 190 | if (!callbacks || !callbacks.length) { 191 | return; 192 | } 193 | 194 | for (var i = 0, callback; callback = callbacks[i++];) { 195 | callback(env); 196 | } 197 | } 198 | } 199 | }; 200 | 201 | var Token = _.Token = function (type, content) { 202 | this.type = type; 203 | this.content = content; 204 | }; 205 | 206 | Token.reactify = function (o) { 207 | if (typeof o == 'string') { 208 | return o; 209 | } 210 | 211 | if (Array.isArray(o)) { 212 | return o.map(function (element) { 213 | return Token.reactify(element); 214 | }); 215 | } 216 | 217 | var attributes = { 218 | className: 'token ' + o.type 219 | }; 220 | if (o.type == 'comment') { 221 | attributes.spellcheck = true; 222 | } 223 | 224 | return React.DOM.span(attributes, Token.reactify(o.content)); 225 | }; 226 | 227 | _.languages.markup = { 228 | 'comment': /<!--[\w\W]*?-->/g, 229 | 'prolog': /<\?.+?\?>/, 230 | 'doctype': /<!DOCTYPE.+?>/, 231 | 'cdata': /<!\[CDATA\[[\w\W]*?]]>/i, 232 | 'tag': { 233 | pattern: /<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi, 234 | inside: { 235 | 'tag': { 236 | pattern: /^<\/?[\w:-]+/i, 237 | inside: { 238 | 'punctuation': /^<\/?/, 239 | 'namespace': /^[\w-]+?:/ 240 | } 241 | }, 242 | 'attr-value': { 243 | pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi, 244 | inside: { 245 | 'punctuation': /=|>|"/g 246 | } 247 | }, 248 | 'punctuation': /\/?>/g, 249 | 'attr-name': { 250 | pattern: /[\w:-]+/g, 251 | inside: { 252 | 'namespace': /^[\w-]+?:/ 253 | } 254 | } 255 | 256 | } 257 | }, 258 | 'entity': /&#?[\da-z]{1,8};/gi 259 | }; 260 | 261 | _.languages.css = { 262 | 'comment': /\/\*[\w\W]*?\*\//g, 263 | 'atrule': { 264 | pattern: /@[\w-]+?.*?(;|(?=\s*{))/gi, 265 | inside: { 266 | 'punctuation': /[;:]/g 267 | } 268 | }, 269 | 'url': /url\((["']?).*?\1\)/gi, 270 | 'selector': /[^\{\}\s][^\{\};]*(?=\s*\{)/g, 271 | 'property': /(\b|\B)[\w-]+(?=\s*:)/ig, 272 | 'string': /("|')(\\?.)*?\1/g, 273 | 'important': /\B!important\b/gi, 274 | 'ignore': /&(lt|gt|amp);/gi, 275 | 'punctuation': /[\{\};:]/g 276 | }; 277 | 278 | _.languages.insertBefore('markup', 'tag', { 279 | 'style': { 280 | pattern: /(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/ig, 281 | inside: { 282 | 'tag': { 283 | pattern: /(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/ig, 284 | inside: _.languages.markup.tag.inside 285 | }, 286 | rest: _.languages.css 287 | } 288 | } 289 | }); 290 | 291 | _.languages.clike = { 292 | 'comment': { 293 | pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g, 294 | lookbehind: true 295 | }, 296 | 'string': /("|')(\\?.)*?\1/g, 297 | 'class-name': { 298 | pattern: /((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/ig, 299 | lookbehind: true, 300 | inside: { 301 | punctuation: /(\.|\\)/ 302 | } 303 | }, 304 | 'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/g, 305 | 'boolean': /\b(true|false)\b/g, 306 | 'function': { 307 | pattern: /[a-z0-9_]+\(/ig, 308 | inside: { 309 | punctuation: /\(/ 310 | } 311 | }, 312 | 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g, 313 | 'operator': /[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%/g, 314 | 'ignore': /&(lt|gt|amp);/gi, 315 | 'punctuation': /[{}[\];(),.:]/g 316 | }; 317 | 318 | _.languages.javascript = _.languages.extend('clike', { 319 | 'keyword': /\b(class|extends|var|let|if|else|while|do|for|return|in|instanceof|function|get|set|new|with|typeof|try|throw|catch|finally|null|break|continue|this)\b/g, 320 | 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?|NaN|-?Infinity)\b/g 321 | }); 322 | 323 | _.languages.insertBefore('javascript', 'keyword', { 324 | 'regex': { 325 | pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g, 326 | lookbehind: true 327 | } 328 | }); 329 | 330 | _.languages.insertBefore('markup', 'tag', { 331 | 'script': { 332 | pattern: /(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/ig, 333 | inside: { 334 | 'tag': { 335 | pattern: /(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/ig, 336 | inside: _.languages.markup.tag.inside 337 | }, 338 | rest: _.languages.javascript 339 | } 340 | } 341 | }); 342 | 343 | var Prism = React.createClass({ 344 | displayName: 'Prism', 345 | 346 | statics: { 347 | _: _ 348 | }, 349 | getDefaultProps: function getDefaultProps() { 350 | return { 351 | language: 'javascript' 352 | }; 353 | }, 354 | render: function render() { 355 | var grammar = _.languages[this.props.language]; 356 | return React.createElement( 357 | 'div', 358 | { className: 'language-' + this.props.language }, 359 | Token.reactify(_.tokenize(this.props.children, grammar)) 360 | ); 361 | } 362 | }); 363 | 364 | module.exports = Prism; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-cheat-sheet", 3 | "version": "0.0.1", 4 | "description": "React Cheat Sheet", 5 | "main": "lib/ReactCheatSheet.js", 6 | "author": "Michael Chan", 7 | "homepage": "https://github.com/chantastic/react-cheat-sheet", 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/chantastic/react-cheat-sheet.git" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/chantastic/react-cheat-sheet/issues" 14 | }, 15 | "dependencies": { 16 | "classnames": "^2.1.2" 17 | }, 18 | "devDependencies": { 19 | "babel-eslint": "^3.1.14", 20 | "eslint": "^0.22.1", 21 | "eslint-plugin-react": "^2.5.0", 22 | "gulp": "^3.9.0", 23 | "lodash.filter": "^3.1.1", 24 | "react": ">=0.13.3", 25 | "react-component-gulp-tasks": "^0.7.0" 26 | }, 27 | "peerDependencies": { 28 | "react": ">=0.13.3" 29 | }, 30 | "browserify-shim": { 31 | "react": "global:React" 32 | }, 33 | "scripts": { 34 | "build": "gulp clean && NODE_ENV=production gulp build", 35 | "examples": "gulp dev:server", 36 | "lint": "eslint ./; true", 37 | "publish:site": "gulp publish:examples", 38 | "release": "gulp release", 39 | "start": "gulp dev", 40 | "test": "echo \"no tests yet\" && exit 0", 41 | "watch": "gulp watch:lib" 42 | }, 43 | "keywords": [ 44 | "react", 45 | "react-component" 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /src/ReactCheatSheet.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { article as articleStyle } from './styles'; 3 | import filter from 'lodash.filter'; 4 | import data from './data.js'; 5 | import ReferenceItem from './ReferenceItem.js'; 6 | 7 | function filterResults (predicate, _data) { 8 | return filter(_data, (({name}) => { 9 | return name.match(new RegExp(predicate, 'i')); 10 | })); 11 | } 12 | 13 | const inputStyle = { 14 | width: "100%", 15 | padding: 10, 16 | fontSize: "1em", 17 | borderRadius: 2, 18 | border: "1px solid #aaa", 19 | boxSizing: "border-box", 20 | color: "black", 21 | } 22 | 23 | class ReactCheatSheet extends Component { 24 | constructor (props) { 25 | super(props); 26 | 27 | this.state = { 28 | predicate: '' 29 | }; 30 | 31 | this.handleChange = () => { 32 | this.setState({ predicate: this.searchInput.getDOMNode().value }); 33 | }; 34 | } 35 | 36 | get filteredResults () { 37 | return filterResults(this.state.predicate, data); 38 | } 39 | 40 | render () { 41 | const noResults = () => ( 42 |
43 |

No results

44 |
45 | ); 46 | 47 | const results = () => ( 48 | this.filteredResults.map(ReferenceItem) 49 | ); 50 | 51 | return ( 52 |
53 | 67 | 68 |
69 | {(this.filteredResults.length) 70 | ? results() 71 | : noResults() 72 | } 73 |
74 |
75 | ); 76 | } 77 | } 78 | 79 | export default ReactCheatSheet; 80 | -------------------------------------------------------------------------------- /src/ReferenceItem.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { article as articleStyle } from './styles'; 3 | import Prism from './vendor/Prism'; 4 | 5 | const styles = { 6 | root: { 7 | ...articleStyle, 8 | borderBottom: '1px solid #aaa' 9 | }, 10 | header: { 11 | overflowY: 'scroll' 12 | }, 13 | module: { 14 | marginLeft: '.5em', 15 | fontSize: '1em', 16 | color: '#aaa', 17 | fontWeight: 'normal', 18 | }, 19 | example: { 20 | position: 'relative', 21 | overflow: 'hidden', 22 | overflowX: 'scroll', 23 | backgroundColor: 'rgb(40, 44, 52)', 24 | color: 'white', 25 | padding: 20, 26 | borderRadius: 2, 27 | }, 28 | exampleColorCode: { 29 | position: 'absolute', 30 | left: 0, 31 | top: 0, 32 | height: '100%', 33 | width: 4 34 | }, 35 | code: { 36 | fontFamily: "Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace", 37 | }, 38 | reference: { 39 | textAlign: 'right' 40 | } 41 | }; 42 | 43 | const ReferenceItem = ({name, module, reference: href, example, color: backgroundColor}) => ( 44 |
45 |

46 | {name} 47 | {module} 48 |

49 | 50 |
51 |       {example}
52 |       
53 |
54 | 55 |
56 | {(href) && Read more →} 57 |
58 |
59 | ); 60 | 61 | export default ReferenceItem; 62 | -------------------------------------------------------------------------------- /src/assignSharedDefaults.js: -------------------------------------------------------------------------------- 1 | export default function (collection, defaults) { 2 | return collection.map(el => { 3 | return { ...el, ...defaults }; 4 | }); 5 | } 6 | -------------------------------------------------------------------------------- /src/data.js: -------------------------------------------------------------------------------- 1 | import ReactDOM from './data/ReactDOM'; 2 | import ReactDOMServer from './data/ReactDOM_Server'; 3 | import ReactTopLevel from './data/React_TopLevel'; 4 | import ReactSpec from './data/React_Spec'; 5 | import ReactLifecycle from './data/React_Lifecycle'; 6 | import ReactPropTypes from './data/React_PropTypes'; 7 | 8 | export default [ 9 | ...ReactDOM, 10 | ...ReactDOMServer, 11 | ...ReactTopLevel, 12 | ...ReactSpec, 13 | ...ReactLifecycle, 14 | ...ReactPropTypes, 15 | ]; 16 | -------------------------------------------------------------------------------- /src/data/ReactDOM.js: -------------------------------------------------------------------------------- 1 | import extendWithDefaults from '../assignSharedDefaults'; 2 | 3 | const data = [ 4 | { 5 | name: 'render', 6 | example: `ReactDOM.render(, document.getElementById('MyComponent');`, 7 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdom.render' 8 | }, 9 | { 10 | name: 'findDOMNode', 11 | example: `ReactDOM.findDOMNode(componentRef);`, 12 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdom.finddomnode', 13 | }, 14 | { 15 | name: 'unmountComponentAtNode', 16 | example: `ReactDOM.unmountComponentAtNode(document.getElementById('MyComponent'))`, 17 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdom.unmountcomponentatnode', 18 | }, 19 | ]; 20 | 21 | export default extendWithDefaults(data, { module: 'react-dom', color: '#85144b' }); 22 | -------------------------------------------------------------------------------- /src/data/ReactDOM_Server.js: -------------------------------------------------------------------------------- 1 | import extendWithDefaults from '../assignSharedDefaults'; 2 | 3 | const data = [ 4 | { 5 | name: 'renderToString', 6 | example: `ReactDOMServer.renderToString();`, 7 | reference: `http://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring`, 8 | }, 9 | { 10 | name: 'renderStaticMarkup', 11 | example: `ReactDOMServer.renderToStaticMarkup();`, 12 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostaticmarkup', 13 | }, 14 | ]; 15 | 16 | export default extendWithDefaults(data, { module: 'react-dom', color: '#85144b' }); 17 | -------------------------------------------------------------------------------- /src/data/React_Lifecycle.js: -------------------------------------------------------------------------------- 1 | import extendWithDefaults from '../assignSharedDefaults'; 2 | 3 | const data = [ 4 | { 5 | name: 'componentWillMount', 6 | example: `componentWillMount: function () { 7 | // invoked once, before initial 'render' 8 | }`, 9 | reference: 'http://facebook.github.io/react/docs/component-specs.html#mounting-componentwillmount', 10 | }, 11 | { 12 | name: 'componentDidMount', 13 | example: `componentDidMount: function () { 14 | // invoked once (client-only), after initial 'render' 15 | // good for AJAX, setTimeout, setInterval 16 | }`, 17 | reference: 'http://facebook.github.io/react/docs/component-specs.html#mounting-componentdidmount', 18 | }, 19 | { 20 | name: 'componentWillReceiveProps', 21 | example: `componentWillReceiveProps: function (nextProps) { 22 | // invoked when component is receiving props, not for initial 'render' 23 | }`, 24 | reference: 'http://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops', 25 | }, 26 | { 27 | name: 'shouldComponentUpdate', 28 | example: `shouldComponentUpdate: function (nextProps, nextState) { 29 | // invoked before rendering with new props, not for initial 'render' 30 | }`, 31 | reference: 'http://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate', 32 | }, 33 | { 34 | name: 'componentWillUpdate', 35 | example: `componentWillUpdate: function (nextProps, nextState) { 36 | // invoked immediately before rendering with new props or state, not for initial 'render' 37 | // CANNOT CALL setState(). see componentWillReceiveProps 38 | }`, 39 | reference: 'http://facebook.github.io/react/docs/component-specs.html#updating-componentwillupdate', 40 | }, 41 | { 42 | name: 'componentDidUpdate', 43 | example: `componentDidUpdate: function (nextProps, nextState) { 44 | // invoked immediately after DOM updates, not for initial 'render' 45 | }`, 46 | reference: 'http://facebook.github.io/react/docs/component-specs.html#updating-componentdidupdate', 47 | }, 48 | { 49 | name: 'componentWillUnmount', 50 | example: `componentWillUnmount: function () { 51 | // invoked immediately before a component is unmounted from the DOM 52 | }`, 53 | reference: 'http://facebook.github.io/react/docs/component-specs.html#unmounting-componentwillunmount', 54 | }, 55 | ]; 56 | 57 | export default extendWithDefaults(data, { module: 'react', color: '#ff851b' }); 58 | -------------------------------------------------------------------------------- /src/data/React_PropTypes.js: -------------------------------------------------------------------------------- 1 | import extendWithDefaults from '../assignSharedDefaults'; 2 | 3 | const data = [ 4 | { 5 | name: 'PropTypes.array', 6 | example: `{ 7 | optionalArray: React.PropTypes.array, 8 | requiredArray: React.PropTypes.array.isRequired 9 | }`, 10 | }, 11 | { 12 | name: 'PropTypes.bool', 13 | example: `{ 14 | optionalBoolean: React.PropTypes.bool, 15 | requiredBoolean: React.PropTypes.bool.isRequired 16 | }`, 17 | }, 18 | { 19 | name: 'PropTypes.func', 20 | example: `{ 21 | optionalFunction: React.PropTypes.func, 22 | requiredFunction: React.PropTypes.func.isRequired 23 | }`, 24 | }, 25 | { 26 | name: 'PropTypes.number', 27 | example: `{ 28 | optionalNumber: React.PropTypes.number, 29 | requiredNumber: React.PropTypes.number.isRequired 30 | }`, 31 | }, 32 | { 33 | name: 'PropTypes.object', 34 | example: `{ 35 | optionalObject: React.PropTypes.object, 36 | requiredObject: React.PropTypes.object.isRequired 37 | }`, 38 | }, 39 | { 40 | name: 'PropTypes.string', 41 | example: `{ 42 | optionalString: React.PropTypes.string, 43 | requiredString: React.PropTypes.string.isRequired 44 | }`, 45 | }, 46 | { 47 | name: 'PropTypes.node', 48 | example: `{ 49 | optionalNode: React.PropTypes.node, 50 | requiredNode: React.PropTypes.node.isRequired 51 | }; 52 | 53 | // anything that can be rendered`, 54 | }, 55 | { 56 | name: 'PropTypes.element', 57 | example: `{ 58 | optionalElement: React.PropTypes.element, 59 | requiredElement: React.PropTypes.element.isRequired 60 | }`, 61 | }, 62 | { 63 | name: 'PropTypes.instanceOf', 64 | example: `{ 65 | optionalClass: React.PropTypes.instanceOf(MyClass), 66 | requiredClass: React.PropTypes.instanceOf(MyClass).isRequired 67 | }`, 68 | }, 69 | { 70 | name: 'PropTypes.oneOf', 71 | example: `{ 72 | optionalEnum: React.PropTypes.oneOf(['Thing 1', 'Thing 2']), 73 | optionalEnum: React.PropTypes.oneOf(['Thing 1', 'Thing 2']).isRequired 74 | }`, 75 | }, 76 | { 77 | name: 'PropTypes.oneOfType', 78 | example: `{ 79 | optionalUnion: React.PropTypes.oneOfType([ 80 | React.PropTypes.bool, 81 | React.PropTypes.string 82 | ]), 83 | 84 | requiredUnion: React.PropTypes.oneOfType([ 85 | React.PropTypes.bool, 86 | React.PropTypes.string 87 | ]).isRequired, 88 | }`, 89 | }, 90 | { 91 | name: 'PropTypes.arrayOf', 92 | example: `{ 93 | optionalArrayOf: React.PropTypes.arrayOf(React.PropTypes.string), 94 | requiredArrayOf: React.PropTypes.arrayOf(React.PropTypes.string).isRequired 95 | }`, 96 | }, 97 | { 98 | name: 'PropTypes.objectOf', 99 | example: `{ 100 | optionalObjectOf: React.PropTypes.objectOf(React.PropTypes.string), 101 | requiredObjectOf: React.PropTypes.objectOf(React.PropTypes.string).isRequired 102 | } 103 | 104 | // Type of property values`, 105 | }, 106 | { 107 | name: 'PropTypes.shape', 108 | example: `{ 109 | optionalObjectWithShape: React.PropTypes.shape({ 110 | age: React.PropTypes.number, 111 | name: React.PropTypes.string 112 | }), 113 | 114 | requiredObjectWithShape: React.PropTypes.shape({ 115 | age: React.PropTypes.number, 116 | name: React.PropTypes.string 117 | }).isRequired, 118 | 119 | requiredObjectWithRequiredShape: React.PropTypes.shape({ 120 | age: React.PropTypes.number.isRequired, 121 | name: React.PropTypes.string.isRequired 122 | }).isRequired, 123 | }`, 124 | }, 125 | { 126 | name: 'PropTypes.any', 127 | example: `{ 128 | requiredAny: React.PropTypes.any.isRequired 129 | }`, 130 | }, 131 | ]; 132 | 133 | export default extendWithDefaults(data, { module: 'react', color: '#f012be', reference: 'https://facebook.github.io/react/docs/reusable-components.html#prop-validation' }); 134 | -------------------------------------------------------------------------------- /src/data/React_Spec.js: -------------------------------------------------------------------------------- 1 | import extendWithDefaults from '../assignSharedDefaults'; 2 | 3 | const data = [ 4 | { 5 | name: 'render', 6 | example: `render: function () { 7 | return
; 8 | }`, 9 | reference: 'http://facebook.github.io/react/docs/component-specs.html#render', 10 | }, 11 | { 12 | name: 'getInitialState', 13 | example: `getInitialState: function () { 14 | return { key: value }; 15 | } 16 | 17 | // not available with React.Component`, 18 | reference: 'http://facebook.github.io/react/docs/component-specs.html#getinitialstate', 19 | }, 20 | { 21 | name: 'getDefaultProps', 22 | example: `getDefaultProps: function () { 23 | return { key: value }; 24 | } 25 | 26 | // not available with React.Component`, 27 | reference: 'http://facebook.github.io/react/docs/component-specs.html#getdefaultprops', 28 | }, 29 | { 30 | name: 'propTypes', 31 | example: `propTypes: function () { 32 | myProp: React.PropTypes.bool 33 | } 34 | 35 | // not available with React.Component`, 36 | reference: 'http://facebook.github.io/react/docs/component-specs.html#proptypes', 37 | }, 38 | { 39 | name: 'mixins', 40 | example: `mixins: [ AMixinObject, AnotherMixinObject ]; 41 | 42 | // not available in React.Component`, 43 | reference: 'http://facebook.github.io/react/docs/component-specs.html#mixins', 44 | }, 45 | { 46 | name: 'statics', 47 | example: `statics: { 48 | customMethod: function(foo) { 49 | return foo === 'bar'; 50 | } 51 | }`, 52 | reference: 'http://facebook.github.io/react/docs/component-specs.html#statics', 53 | }, 54 | { 55 | name: 'displayName', 56 | example: `displayName: "MyComponent"`, 57 | reference: 'http://facebook.github.io/react/docs/component-specs.html#displayname', 58 | }, 59 | ]; 60 | 61 | export default extendWithDefaults(data, { module: 'react', color: '#3d9970' }); 62 | -------------------------------------------------------------------------------- /src/data/React_TopLevel.js: -------------------------------------------------------------------------------- 1 | import extendWithDefaults from '../assignSharedDefaults'; 2 | 3 | const data = [ 4 | { 5 | name: 'Component', 6 | example: `// ES2015 7 | 8 | class MyComponent extends React.Component { 9 | render () { 10 | return
; 11 | } 12 | } 13 | `, 14 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.component', 15 | }, 16 | { 17 | name: 'createClass', 18 | example: `var MyComponent = React.createClass({ 19 | render: function () { 20 | return
; 21 | } 22 | });`, 23 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.createclass', 24 | }, 25 | { 26 | name: 'createElement', 27 | example: `React.createElement('div', props, ...children); // String 28 | 29 | React.createElement(MyComponent, props, ...children); // ReactClass type`, 30 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.createelement', 31 | }, 32 | { 33 | name: 'cloneElement', 34 | example: `React.cloneElement(element, props, ...children);`, 35 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.cloneelement', 36 | }, 37 | { 38 | name: 'createFactory', 39 | example: `React.createFactory('div'); // String; 40 | 41 | React.createFactory(MyComponentClass); // ReactClass type`, 42 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.createfactory', 43 | }, 44 | { 45 | name: 'isValidElement', 46 | example: `React.isValidElement(MyComponent);`, 47 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.isvalidelement', 48 | }, 49 | { 50 | name: 'Children.map', 51 | example: `React.Children.map(this.props.children, (child, i) => { 52 | return child; 53 | })`, 54 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.map', 55 | }, 56 | { 57 | name: 'Children.forEach', 58 | example: `React.Children.forEach(this.props.children, (child, i) => { 59 | console.log(child + ' at index: ' + i); 60 | })`, 61 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.foreach', 62 | }, 63 | { 64 | name: 'Children.count', 65 | example: `React.Children.count(this.props.children);`, 66 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.count', 67 | }, 68 | { 69 | name: 'Children.only', 70 | example: `none`, 71 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.only', 72 | }, 73 | { 74 | name: 'Children.toArray', 75 | example: `none`, 76 | reference: 'http://facebook.github.io/react/docs/top-level-api.html#react.children.toarray', 77 | } 78 | ]; 79 | 80 | export default extendWithDefaults(data, { module: 'react', color: '#ffdc00' }); 81 | -------------------------------------------------------------------------------- /src/styles.js: -------------------------------------------------------------------------------- 1 | export default { 2 | article: { 3 | paddingTop: '1em', 4 | paddingBottom: '1em', 5 | } 6 | }; 7 | -------------------------------------------------------------------------------- /src/vendor/Prism.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Prism: Lightweight, robust, elegant syntax highlighting 3 | * MIT license http://www.opensource.org/licenses/mit-license.php/ 4 | * @author Lea Verou http://lea.verou.me 5 | * 6 | * @providesModule Prism 7 | * @jsx React.DOM 8 | */ 9 | 10 | var React = require('react'); 11 | 12 | // Private helper vars 13 | var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; 14 | 15 | var _ = { 16 | util: { 17 | type: function (o) { 18 | return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1]; 19 | }, 20 | 21 | // Deep clone a language definition (e.g. to extend it) 22 | clone: function (o) { 23 | var type = _.util.type(o); 24 | 25 | switch (type) { 26 | case 'Object': 27 | var clone = {}; 28 | 29 | for (var key in o) { 30 | if (o.hasOwnProperty(key)) { 31 | clone[key] = _.util.clone(o[key]); 32 | } 33 | } 34 | 35 | return clone; 36 | 37 | case 'Array': 38 | return o.slice(); 39 | } 40 | 41 | return o; 42 | } 43 | }, 44 | 45 | languages: { 46 | extend: function (id, redef) { 47 | var lang = _.util.clone(_.languages[id]); 48 | 49 | for (var key in redef) { 50 | lang[key] = redef[key]; 51 | } 52 | 53 | return lang; 54 | }, 55 | 56 | // Insert a token before another token in a language literal 57 | insertBefore: function (inside, before, insert, root) { 58 | root = root || _.languages; 59 | var grammar = root[inside]; 60 | var ret = {}; 61 | 62 | for (var token in grammar) { 63 | 64 | if (grammar.hasOwnProperty(token)) { 65 | 66 | if (token == before) { 67 | 68 | for (var newToken in insert) { 69 | 70 | if (insert.hasOwnProperty(newToken)) { 71 | ret[newToken] = insert[newToken]; 72 | } 73 | } 74 | } 75 | 76 | ret[token] = grammar[token]; 77 | } 78 | } 79 | 80 | return root[inside] = ret; 81 | }, 82 | 83 | // Traverse a language definition with Depth First Search 84 | DFS: function(o, callback) { 85 | for (var i in o) { 86 | callback.call(o, i, o[i]); 87 | 88 | if (_.util.type(o) === 'Object') { 89 | _.languages.DFS(o[i], callback); 90 | } 91 | } 92 | } 93 | }, 94 | 95 | tokenize: function(text, grammar, language) { 96 | var Token = _.Token; 97 | 98 | var strarr = [text]; 99 | 100 | var rest = grammar.rest; 101 | 102 | if (rest) { 103 | for (var token in rest) { 104 | grammar[token] = rest[token]; 105 | } 106 | 107 | delete grammar.rest; 108 | } 109 | 110 | tokenloop: for (var token in grammar) { 111 | if(!grammar.hasOwnProperty(token) || !grammar[token]) { 112 | continue; 113 | } 114 | 115 | var pattern = grammar[token], 116 | inside = pattern.inside, 117 | lookbehind = !!pattern.lookbehind, 118 | lookbehindLength = 0; 119 | 120 | pattern = pattern.pattern || pattern; 121 | 122 | for (var i=0; i text.length) { 127 | // Something went terribly wrong, ABORT, ABORT! 128 | break tokenloop; 129 | } 130 | 131 | if (str instanceof Token) { 132 | continue; 133 | } 134 | 135 | pattern.lastIndex = 0; 136 | 137 | var match = pattern.exec(str); 138 | 139 | if (match) { 140 | if(lookbehind) { 141 | lookbehindLength = match[1].length; 142 | } 143 | 144 | var from = match.index - 1 + lookbehindLength, 145 | match = match[0].slice(lookbehindLength), 146 | len = match.length, 147 | to = from + len, 148 | before = str.slice(0, from + 1), 149 | after = str.slice(to + 1); 150 | 151 | var args = [i, 1]; 152 | 153 | if (before) { 154 | args.push(before); 155 | } 156 | 157 | var wrapped = new Token(token, inside? _.tokenize(match, inside) : match); 158 | 159 | args.push(wrapped); 160 | 161 | if (after) { 162 | args.push(after); 163 | } 164 | 165 | Array.prototype.splice.apply(strarr, args); 166 | } 167 | } 168 | } 169 | 170 | return strarr; 171 | }, 172 | 173 | hooks: { 174 | all: {}, 175 | 176 | add: function (name, callback) { 177 | var hooks = _.hooks.all; 178 | 179 | hooks[name] = hooks[name] || []; 180 | 181 | hooks[name].push(callback); 182 | }, 183 | 184 | run: function (name, env) { 185 | var callbacks = _.hooks.all[name]; 186 | 187 | if (!callbacks || !callbacks.length) { 188 | return; 189 | } 190 | 191 | for (var i=0, callback; callback = callbacks[i++];) { 192 | callback(env); 193 | } 194 | } 195 | } 196 | }; 197 | 198 | var Token = _.Token = function(type, content) { 199 | this.type = type; 200 | this.content = content; 201 | }; 202 | 203 | Token.reactify = function(o) { 204 | if (typeof o == 'string') { 205 | return o; 206 | } 207 | 208 | if (Array.isArray(o)) { 209 | return o.map(function(element) { 210 | return Token.reactify(element); 211 | }); 212 | } 213 | 214 | var attributes = { 215 | className: 'token ' + o.type 216 | } 217 | if (o.type == 'comment') { 218 | attributes.spellcheck = true; 219 | } 220 | 221 | return React.DOM.span(attributes, Token.reactify(o.content)); 222 | }; 223 | 224 | _.languages.markup = { 225 | 'comment': /<!--[\w\W]*?-->/g, 226 | 'prolog': /<\?.+?\?>/, 227 | 'doctype': /<!DOCTYPE.+?>/, 228 | 'cdata': /<!\[CDATA\[[\w\W]*?]]>/i, 229 | 'tag': { 230 | pattern: /<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi, 231 | inside: { 232 | 'tag': { 233 | pattern: /^<\/?[\w:-]+/i, 234 | inside: { 235 | 'punctuation': /^<\/?/, 236 | 'namespace': /^[\w-]+?:/ 237 | } 238 | }, 239 | 'attr-value': { 240 | pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi, 241 | inside: { 242 | 'punctuation': /=|>|"/g 243 | } 244 | }, 245 | 'punctuation': /\/?>/g, 246 | 'attr-name': { 247 | pattern: /[\w:-]+/g, 248 | inside: { 249 | 'namespace': /^[\w-]+?:/ 250 | } 251 | } 252 | 253 | } 254 | }, 255 | 'entity': /&#?[\da-z]{1,8};/gi 256 | }; 257 | 258 | _.languages.css = { 259 | 'comment': /\/\*[\w\W]*?\*\//g, 260 | 'atrule': { 261 | pattern: /@[\w-]+?.*?(;|(?=\s*{))/gi, 262 | inside: { 263 | 'punctuation': /[;:]/g 264 | } 265 | }, 266 | 'url': /url\((["']?).*?\1\)/gi, 267 | 'selector': /[^\{\}\s][^\{\};]*(?=\s*\{)/g, 268 | 'property': /(\b|\B)[\w-]+(?=\s*:)/ig, 269 | 'string': /("|')(\\?.)*?\1/g, 270 | 'important': /\B!important\b/gi, 271 | 'ignore': /&(lt|gt|amp);/gi, 272 | 'punctuation': /[\{\};:]/g 273 | }; 274 | 275 | _.languages.insertBefore('markup', 'tag', { 276 | 'style': { 277 | pattern: /(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/ig, 278 | inside: { 279 | 'tag': { 280 | pattern: /(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/ig, 281 | inside: _.languages.markup.tag.inside 282 | }, 283 | rest: _.languages.css 284 | } 285 | } 286 | }); 287 | 288 | _.languages.clike = { 289 | 'comment': { 290 | pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g, 291 | lookbehind: true 292 | }, 293 | 'string': /("|')(\\?.)*?\1/g, 294 | 'class-name': { 295 | pattern: /((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/ig, 296 | lookbehind: true, 297 | inside: { 298 | punctuation: /(\.|\\)/ 299 | } 300 | }, 301 | 'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/g, 302 | 'boolean': /\b(true|false)\b/g, 303 | 'function': { 304 | pattern: /[a-z0-9_]+\(/ig, 305 | inside: { 306 | punctuation: /\(/ 307 | } 308 | }, 309 | 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g, 310 | 'operator': /[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%/g, 311 | 'ignore': /&(lt|gt|amp);/gi, 312 | 'punctuation': /[{}[\];(),.:]/g 313 | }; 314 | 315 | _.languages.javascript = _.languages.extend('clike', { 316 | 'keyword': /\b(class|extends|var|let|if|else|while|do|for|return|in|instanceof|function|get|set|new|with|typeof|try|throw|catch|finally|null|break|continue|this)\b/g, 317 | 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?|NaN|-?Infinity)\b/g 318 | }); 319 | 320 | _.languages.insertBefore('javascript', 'keyword', { 321 | 'regex': { 322 | pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g, 323 | lookbehind: true 324 | } 325 | }); 326 | 327 | _.languages.insertBefore('markup', 'tag', { 328 | 'script': { 329 | pattern: /(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/ig, 330 | inside: { 331 | 'tag': { 332 | pattern: /(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/ig, 333 | inside: _.languages.markup.tag.inside 334 | }, 335 | rest: _.languages.javascript 336 | } 337 | } 338 | }); 339 | 340 | var Prism = React.createClass({ 341 | statics: { 342 | _: _ 343 | }, 344 | getDefaultProps: function() { 345 | return { 346 | language: 'javascript' 347 | }; 348 | }, 349 | render: function() { 350 | var grammar = _.languages[this.props.language]; 351 | return ( 352 |
353 | {Token.reactify(_.tokenize(this.props.children, grammar))} 354 |
355 | ); 356 | } 357 | }) 358 | 359 | module.exports = Prism; 360 | --------------------------------------------------------------------------------