code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function incrementingRunsFrom(list) { list = list.concat([Infinity]);// use Infinity to ensure any nontrivial (length >= 2) run ends before the end of the loop var runs = []; var start = null; var prev = null; for (var i = 0; i < list.length; i++) { var current = list[i]; if (start === null) { // first element starts a trivial run start = current; } else if (prev + 1 !== current) { // run ended if (start !== prev) { // run is nontrivial runs.push([start, prev]); } // start new run start = current; } // else: the run continues prev = current; } return runs; }
Given a sorted array of integers, this finds all contiguous runs where each item is incremented by 1 from the next. For example: [0, 2, 3, 5] has one such run: [2, 3] [0, 2, 3, 4, 6, 8, 9, 11] has two such runs: [2, 3, 4], [8, 9] [0, 2, 4] has no runs. @param {integer[]} list Sorted array of integers @returns {Array.<Array.<integer>>} Array of pairs of start and end values of runs
incrementingRunsFrom
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
function getBrowserWindowObject() { var theWindow = null; try { /* eslint-disable-next-line no-undef */ theWindow = window; } catch (e) { // deliberately do nothing // empty } return theWindow; }
@returns {(Window|null)} The browser window object, or null if this is not running in a browser environment
getBrowserWindowObject
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
function versionsIn(strings) { return strings.map(function (str) { var match = str.match(/^\d+\.\d+\.\d+$/); return match ? match[0] : null; }).filter(function (match) { return match !== null; }); }
@returns {(Window|null)} The browser window object, or null if this is not running in a browser environment
versionsIn
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
function versionInLinkedElement($, element) { var elem = $(element); var urlAttr = tagNameOf(element) === 'LINK' ? 'href' : 'src'; var pathSegments = parseUrl(elem.attr(urlAttr)).pathname.split('/'); var versions = versionsIn(pathSegments); if (!versions.length) { return null; } var version = versions[versions.length - 1]; return version; }
@returns {(Window|null)} The browser window object, or null if this is not running in a browser environment
versionInLinkedElement
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
function jqueryPluginVersions(jQuery) { /* istanbul ignore next */ return PLUGINS.map(function (pluginName) { var plugin = jQuery.fn[pluginName]; if (!plugin) { return undefined; } var constructor = plugin.Constructor; if (!constructor) { return undefined; } return constructor.VERSION; }).filter(function (version) { return typeof version !== 'undefined'; }).sort(semver.compare); }
@returns {(Window|null)} The browser window object, or null if this is not running in a browser environment
jqueryPluginVersions
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
function bootstrapScriptsIn($) { var longhands = $('script[src*="bootstrap.js"]').filter(function (i, script) { var url = $(script).attr('src'); var filename = filenameFromUrl(url); return filename === 'bootstrap.js'; }); var minifieds = $('script[src*="bootstrap.min.js"]').filter(function (i, script) { var url = $(script).attr('src'); var filename = filenameFromUrl(url); return filename === 'bootstrap.min.js'; }); return { longhands: longhands, minifieds: minifieds }; }
@returns {(Window|null)} The browser window object, or null if this is not running in a browser environment
bootstrapScriptsIn
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
function LintError(id, message, elements) { this.id = id; this.url = WIKI_URL + id; this.message = message; this.elements = elements || cheerio(''); }
@param {integer} id Unique string ID for this type of lint error. Of the form "E###" (e.g. "E123"). @param {string} message Human-readable string describing the error @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document @class
LintError
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
function LintWarning(id, message, elements) { this.id = id; this.url = WIKI_URL + id; this.message = message; this.elements = elements || cheerio(''); }
@param {integer} id Unique string ID for this type of lint warning. Of the form "W###" (e.g. "W123"). @param {string} message Human-readable string describing the warning @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document @class
LintWarning
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
function addLinter(id, linter) { if (allLinters[id]) { /* istanbul ignore next */ throw new Error('Linter already registered with ID: ' + id); } var Problem = null; if (id[0] === 'E') { Problem = LintError; } else if (id[0] === 'W') { Problem = LintWarning; } else { /* istanbul ignore next */ throw new Error('Invalid linter ID: ' + id); } function linterWrapper($, reporter) { function specializedReporter(message, elements) { reporter(new Problem(id, message, elements)); } linter($, specializedReporter); } linterWrapper.id = id; allLinters[id] = linterWrapper; }
@param {integer} id Unique string ID for this type of lint warning. Of the form "W###" (e.g. "W123"). @param {string} message Human-readable string describing the warning @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document @class
addLinter
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
function linterWrapper($, reporter) { function specializedReporter(message, elements) { reporter(new Problem(id, message, elements)); } linter($, specializedReporter); }
@param {integer} id Unique string ID for this type of lint warning. Of the form "W###" (e.g. "W123"). @param {string} message Human-readable string describing the warning @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document @class
linterWrapper
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
function specializedReporter(message, elements) { reporter(new Problem(id, message, elements)); }
@param {integer} id Unique string ID for this type of lint warning. Of the form "W###" (e.g. "W123"). @param {string} message Human-readable string describing the warning @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document @class
specializedReporter
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
reporter = function (lint) { var background = 'background: #' + (lint.id[0] === 'W' ? 'f0ad4e' : 'd9534f') + '; color: #ffffff;'; if (!seenLint) { if (alertOnFirstProblem) { /* eslint-disable-next-line no-alert, no-undef */ window.alert('bootlint found errors in this document! See the JavaScript console for details.'); } seenLint = true; } if (lint.elements.length) { console.warn('bootlint: %c ' + lint.id + ' ', background, lint.message + ' Documentation: ' + lint.url, lint.elements); } else { console.warn('bootlint: %c ' + lint.id + ' ', background, lint.message + ' Documentation: ' + lint.url); } errorCount++; }
Lints the HTML of the current document. If there are any lint warnings, one general notification message will be window.alert()-ed to the user. Each warning will be output individually using console.warn(). @param {string[]} disabledIds Array of string IDs of linters to disable @param {object} [alertOpts] Options object to configure alert()ing @param {boolean} [alertOpts.hasProblems=true] Show one alert() when the first lint problem is found? @param {boolean} [alertOpts.problemFree=true] Show one alert() at the end of linting if the page has no lint problems? @returns {undefined} Nothing
reporter
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
function parse(urlStr) { var anchor = document.createElement('a'); anchor.href = urlStr; var urlObj = {}; URL_PROPERTIES.forEach(function (property) { urlObj[property] = anchor[property]; }); return urlObj; }
@param {string} urlStr URL to parse @returns {object} Object with fields representing the various parts of the parsed URL.
parse
javascript
twbs/bootlint
dist/browser/bootlint.js
https://github.com/twbs/bootlint/blob/master/dist/browser/bootlint.js
MIT
function sortedColumnClasses(classes) { // extract column classes var colClasses = []; while (true) { var match = COL_REGEX.exec(classes); if (!match) { break; } var colClass = match[0]; colClasses.push(colClass); classes = withoutClass(classes, colClass); } colClasses.sort(compareColumnClasses); return classes + ' ' + colClasses.join(' '); }
Moves any grid column classes to the end of the class string and sorts the grid classes by ascending screen size. @param {string} classes The "class" attribute of a DOM node @returns {string} The processed "class" attribute value
sortedColumnClasses
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function width2screensFor(classes) { var width = null; var width2screens = {}; while (true) { var match = COL_REGEX_G.exec(classes); if (!match) { break; } var screen = match[1]; width = match[2]; var screens = width2screens[width]; if (!screens) { screens = width2screens[width] = []; } screens.push(SCREEN2NUM[screen]); } for (width in width2screens) { if (Object.prototype.hasOwnProperty.call(width2screens, 'width')) { width2screens[width].sort(compareNums); } } return width2screens; }
@param {string} classes The "class" attribute of a DOM node @returns {Object.<string, integer[]>} Object mapping grid column widths (1 thru 12) to sorted arrays of screen size numbers (see SCREEN2NUM) Widths not used in the classes will not have an entry in the object.
width2screensFor
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function incrementingRunsFrom(list) { list = list.concat([Infinity]);// use Infinity to ensure any nontrivial (length >= 2) run ends before the end of the loop var runs = []; var start = null; var prev = null; for (var i = 0; i < list.length; i++) { var current = list[i]; if (start === null) { // first element starts a trivial run start = current; } else if (prev + 1 !== current) { // run ended if (start !== prev) { // run is nontrivial runs.push([start, prev]); } // start new run start = current; } // else: the run continues prev = current; } return runs; }
Given a sorted array of integers, this finds all contiguous runs where each item is incremented by 1 from the next. For example: [0, 2, 3, 5] has one such run: [2, 3] [0, 2, 3, 4, 6, 8, 9, 11] has two such runs: [2, 3, 4], [8, 9] [0, 2, 4] has no runs. @param {integer[]} list Sorted array of integers @returns {Array.<Array.<integer>>} Array of pairs of start and end values of runs
incrementingRunsFrom
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function getBrowserWindowObject() { var theWindow = null; try { /* eslint-disable-next-line no-undef */ theWindow = window; } catch (e) { // deliberately do nothing // empty } return theWindow; }
@returns {(Window|null)} The browser window object, or null if this is not running in a browser environment
getBrowserWindowObject
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function versionsIn(strings) { return strings.map(function (str) { var match = str.match(/^\d+\.\d+\.\d+$/); return match ? match[0] : null; }).filter(function (match) { return match !== null; }); }
@returns {(Window|null)} The browser window object, or null if this is not running in a browser environment
versionsIn
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function versionInLinkedElement($, element) { var elem = $(element); var urlAttr = tagNameOf(element) === 'LINK' ? 'href' : 'src'; var pathSegments = parseUrl(elem.attr(urlAttr)).pathname.split('/'); var versions = versionsIn(pathSegments); if (!versions.length) { return null; } var version = versions[versions.length - 1]; return version; }
@returns {(Window|null)} The browser window object, or null if this is not running in a browser environment
versionInLinkedElement
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function jqueryPluginVersions(jQuery) { /* istanbul ignore next */ return PLUGINS.map(function (pluginName) { var plugin = jQuery.fn[pluginName]; if (!plugin) { return undefined; } var constructor = plugin.Constructor; if (!constructor) { return undefined; } return constructor.VERSION; }).filter(function (version) { return typeof version !== 'undefined'; }).sort(semver.compare); }
@returns {(Window|null)} The browser window object, or null if this is not running in a browser environment
jqueryPluginVersions
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function bootstrapScriptsIn($) { var longhands = $('script[src*="bootstrap.js"]').filter(function (i, script) { var url = $(script).attr('src'); var filename = filenameFromUrl(url); return filename === 'bootstrap.js'; }); var minifieds = $('script[src*="bootstrap.min.js"]').filter(function (i, script) { var url = $(script).attr('src'); var filename = filenameFromUrl(url); return filename === 'bootstrap.min.js'; }); return { longhands: longhands, minifieds: minifieds }; }
@returns {(Window|null)} The browser window object, or null if this is not running in a browser environment
bootstrapScriptsIn
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function LintError(id, message, elements) { this.id = id; this.url = WIKI_URL + id; this.message = message; this.elements = elements || cheerio(''); }
@param {integer} id Unique string ID for this type of lint error. Of the form "E###" (e.g. "E123"). @param {string} message Human-readable string describing the error @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document @class
LintError
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function LintWarning(id, message, elements) { this.id = id; this.url = WIKI_URL + id; this.message = message; this.elements = elements || cheerio(''); }
@param {integer} id Unique string ID for this type of lint warning. Of the form "W###" (e.g. "W123"). @param {string} message Human-readable string describing the warning @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document @class
LintWarning
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function addLinter(id, linter) { if (allLinters[id]) { /* istanbul ignore next */ throw new Error('Linter already registered with ID: ' + id); } var Problem = null; if (id[0] === 'E') { Problem = LintError; } else if (id[0] === 'W') { Problem = LintWarning; } else { /* istanbul ignore next */ throw new Error('Invalid linter ID: ' + id); } function linterWrapper($, reporter) { function specializedReporter(message, elements) { reporter(new Problem(id, message, elements)); } linter($, specializedReporter); } linterWrapper.id = id; allLinters[id] = linterWrapper; }
@param {integer} id Unique string ID for this type of lint warning. Of the form "W###" (e.g. "W123"). @param {string} message Human-readable string describing the warning @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document @class
addLinter
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function linterWrapper($, reporter) { function specializedReporter(message, elements) { reporter(new Problem(id, message, elements)); } linter($, specializedReporter); }
@param {integer} id Unique string ID for this type of lint warning. Of the form "W###" (e.g. "W123"). @param {string} message Human-readable string describing the warning @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document @class
linterWrapper
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function specializedReporter(message, elements) { reporter(new Problem(id, message, elements)); }
@param {integer} id Unique string ID for this type of lint warning. Of the form "W###" (e.g. "W123"). @param {string} message Human-readable string describing the warning @param {jQuery} elements jQuery or Cheerio collection of referenced DOM elements pointing to all problem locations in the document @class
specializedReporter
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
reporter = function (lint) { var background = 'background: #' + (lint.id[0] === 'W' ? 'f0ad4e' : 'd9534f') + '; color: #ffffff;'; if (!seenLint) { if (alertOnFirstProblem) { /* eslint-disable-next-line no-alert, no-undef */ window.alert('bootlint found errors in this document! See the JavaScript console for details.'); } seenLint = true; } if (lint.elements.length) { console.warn('bootlint: %c ' + lint.id + ' ', background, lint.message + ' Documentation: ' + lint.url, lint.elements); } else { console.warn('bootlint: %c ' + lint.id + ' ', background, lint.message + ' Documentation: ' + lint.url); } errorCount++; }
Lints the HTML of the current document. If there are any lint warnings, one general notification message will be window.alert()-ed to the user. Each warning will be output individually using console.warn(). @param {string[]} disabledIds Array of string IDs of linters to disable @param {object} [alertOpts] Options object to configure alert()ing @param {boolean} [alertOpts.hasProblems=true] Show one alert() when the first lint problem is found? @param {boolean} [alertOpts.problemFree=true] Show one alert() at the end of linting if the page has no lint problems? @returns {undefined} Nothing
reporter
javascript
twbs/bootlint
src/bootlint.js
https://github.com/twbs/bootlint/blob/master/src/bootlint.js
MIT
function Location(line, column) { this.line = line; this.column = column; }
Represents a location within a source code file. @param {integer} line A 0-based line index @param {integer} column A 0-based column index @class
Location
javascript
twbs/bootlint
src/location.js
https://github.com/twbs/bootlint/blob/master/src/location.js
MIT
function LocationIndex(string) { // ensure newline termination if (string[string.length - 1] !== '\n') { string += '\n'; } this._stringLength = string.length; /* * Each triple in _lineStartEndTriples consists of: * [0], the 0-based line index of the line the triple represents * [1], the 0-based code unit index (into the string) of the start of the line (inclusive) * [2], the 0-based code unit index (into the string) of the start of the next line (or the length of the string, if it is the last line) * A line starts with a non-newline character, * and always ends in a newline character, unless it is the very last line in the string. */ this._lineStartEndTriples = [[0, 0]]; var nextLineIndex = 1; var charIndex = 0; while (charIndex < string.length) { charIndex = string.indexOf('\n', charIndex); if (charIndex === -1) { /* istanbul ignore next */ break; } charIndex++;// go past the newline this._lineStartEndTriples[this._lineStartEndTriples.length - 1].push(charIndex); this._lineStartEndTriples.push([nextLineIndex, charIndex]); nextLineIndex++; } this._lineStartEndTriples.pop(); }
Maps code unit indices into the string to line numbers and column numbers. @param {string} string String to construct the index for @class
LocationIndex
javascript
twbs/bootlint
src/location.js
https://github.com/twbs/bootlint/blob/master/src/location.js
MIT
function parse(urlStr) { var anchor = document.createElement('a'); anchor.href = urlStr; var urlObj = {}; URL_PROPERTIES.forEach(function (property) { urlObj[property] = anchor[property]; }); return urlObj; }
@param {string} urlStr URL to parse @returns {object} Object with fields representing the various parts of the parsed URL.
parse
javascript
twbs/bootlint
src/url.js
https://github.com/twbs/bootlint/blob/master/src/url.js
MIT
invalid = function invalid() { _this8.setState(function () { return { data: _this8.store.get(), reset: false }; }); return; }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
invalid
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
beforeSaveCellCB = function beforeSaveCellCB(result) { _this8.body.cancelEditCell(); if (result || result === undefined) { _this8.editCell(newVal, rowIndex, colIndex); } else { invalid(); } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
beforeSaveCellCB
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
afterHandleAddRow = function afterHandleAddRow(errMsg) { if (isAsync) { _this9.toolbar.afterHandleSaveBtnClick(errMsg); } else { return errMsg; } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
afterHandleAddRow
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
afterAddRowCB = function afterAddRowCB(errMsg) { if (typeof errMsg !== 'undefined' && errMsg !== '') return afterHandleAddRow(errMsg); if (_this9.allowRemote(_Const2.default.REMOTE_INSERT_ROW)) { if (_this9.props.options.afterInsertRow) { _this9.props.options.afterInsertRow(newObj); } return afterHandleAddRow(); } try { _this9.store.add(newObj); } catch (e) { return afterHandleAddRow(e.message); } _this9._handleAfterAddingRow(newObj, false); return afterHandleAddRow(); }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
afterAddRowCB
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function getIteratorFn(maybeIterable) { var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); if (typeof iteratorFn === 'function') { return iteratorFn; } }
Returns the iterator method function contained on the iterable object. Be sure to invoke the function with the iterable as context: var iteratorFn = getIteratorFn(myIterable); if (iteratorFn) { var iterator = iteratorFn.call(myIterable); ... } @param {?object} maybeIterable @return {?function}
getIteratorFn
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function PropTypeError(message) { this.message = message; this.stack = ''; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
PropTypeError
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function createChainableTypeChecker(validate) { if (process.env.NODE_ENV !== 'production') { var manualPropTypeCallCache = {}; var manualPropTypeWarningCount = 0; } function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { componentName = componentName || ANONYMOUS; propFullName = propFullName || propName; if (secret !== ReactPropTypesSecret) { if (throwOnDirectAccess) { // New behavior only for users of `prop-types` package invariant( false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types' ); } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') { // Old behavior for people using React.PropTypes var cacheKey = componentName + ':' + propName; if ( !manualPropTypeCallCache[cacheKey] && // Avoid spamming the console because they are often not actionable except for lib authors manualPropTypeWarningCount < 3 ) { warning( false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName ); manualPropTypeCallCache[cacheKey] = true; manualPropTypeWarningCount++; } } } if (props[propName] == null) { if (isRequired) { if (props[propName] === null) { return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); } return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); } return null; } else { return validate(props, propName, componentName, location, propFullName); } } var chainedCheckType = checkType.bind(null, false); chainedCheckType.isRequired = checkType.bind(null, true); return chainedCheckType; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
createChainableTypeChecker
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { componentName = componentName || ANONYMOUS; propFullName = propFullName || propName; if (secret !== ReactPropTypesSecret) { if (throwOnDirectAccess) { // New behavior only for users of `prop-types` package invariant( false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types' ); } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') { // Old behavior for people using React.PropTypes var cacheKey = componentName + ':' + propName; if ( !manualPropTypeCallCache[cacheKey] && // Avoid spamming the console because they are often not actionable except for lib authors manualPropTypeWarningCount < 3 ) { warning( false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName ); manualPropTypeCallCache[cacheKey] = true; manualPropTypeWarningCount++; } } } if (props[propName] == null) { if (isRequired) { if (props[propName] === null) { return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); } return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); } return null; } else { return validate(props, propName, componentName, location, propFullName); } }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
checkType
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function createPrimitiveTypeChecker(expectedType) { function validate(props, propName, componentName, location, propFullName, secret) { var propValue = props[propName]; var propType = getPropType(propValue); if (propType !== expectedType) { // `propValue` being instance of, say, date/regexp, pass the 'object' // check, but we can offer a more precise error message here rather than // 'of type `object`'. var preciseType = getPreciseType(propValue); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); } return null; } return createChainableTypeChecker(validate); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
createPrimitiveTypeChecker
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function validate(props, propName, componentName, location, propFullName, secret) { var propValue = props[propName]; var propType = getPropType(propValue); if (propType !== expectedType) { // `propValue` being instance of, say, date/regexp, pass the 'object' // check, but we can offer a more precise error message here rather than // 'of type `object`'. var preciseType = getPreciseType(propValue); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); } return null; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
validate
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function createAnyTypeChecker() { return createChainableTypeChecker(emptyFunction.thatReturnsNull); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
createAnyTypeChecker
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function createArrayOfTypeChecker(typeChecker) { function validate(props, propName, componentName, location, propFullName) { if (typeof typeChecker !== 'function') { return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); } var propValue = props[propName]; if (!Array.isArray(propValue)) { var propType = getPropType(propValue); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); } for (var i = 0; i < propValue.length; i++) { var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); if (error instanceof Error) { return error; } } return null; } return createChainableTypeChecker(validate); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
createArrayOfTypeChecker
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function validate(props, propName, componentName, location, propFullName) { if (typeof typeChecker !== 'function') { return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); } var propValue = props[propName]; if (!Array.isArray(propValue)) { var propType = getPropType(propValue); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); } for (var i = 0; i < propValue.length; i++) { var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); if (error instanceof Error) { return error; } } return null; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
validate
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function createElementTypeChecker() { function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; if (!isValidElement(propValue)) { var propType = getPropType(propValue); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); } return null; } return createChainableTypeChecker(validate); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
createElementTypeChecker
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; if (!isValidElement(propValue)) { var propType = getPropType(propValue); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); } return null; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
validate
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function createInstanceTypeChecker(expectedClass) { function validate(props, propName, componentName, location, propFullName) { if (!(props[propName] instanceof expectedClass)) { var expectedClassName = expectedClass.name || ANONYMOUS; var actualClassName = getClassName(props[propName]); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); } return null; } return createChainableTypeChecker(validate); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
createInstanceTypeChecker
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function validate(props, propName, componentName, location, propFullName) { if (!(props[propName] instanceof expectedClass)) { var expectedClassName = expectedClass.name || ANONYMOUS; var actualClassName = getClassName(props[propName]); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); } return null; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
validate
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function createEnumTypeChecker(expectedValues) { if (!Array.isArray(expectedValues)) { process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0; return emptyFunction.thatReturnsNull; } function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; for (var i = 0; i < expectedValues.length; i++) { if (is(propValue, expectedValues[i])) { return null; } } var valuesString = JSON.stringify(expectedValues); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); } return createChainableTypeChecker(validate); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
createEnumTypeChecker
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; for (var i = 0; i < expectedValues.length; i++) { if (is(propValue, expectedValues[i])) { return null; } } var valuesString = JSON.stringify(expectedValues); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
validate
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function createObjectOfTypeChecker(typeChecker) { function validate(props, propName, componentName, location, propFullName) { if (typeof typeChecker !== 'function') { return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); } var propValue = props[propName]; var propType = getPropType(propValue); if (propType !== 'object') { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); } for (var key in propValue) { if (propValue.hasOwnProperty(key)) { var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); if (error instanceof Error) { return error; } } } return null; } return createChainableTypeChecker(validate); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
createObjectOfTypeChecker
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function validate(props, propName, componentName, location, propFullName) { if (typeof typeChecker !== 'function') { return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); } var propValue = props[propName]; var propType = getPropType(propValue); if (propType !== 'object') { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); } for (var key in propValue) { if (propValue.hasOwnProperty(key)) { var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); if (error instanceof Error) { return error; } } } return null; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
validate
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function createUnionTypeChecker(arrayOfTypeCheckers) { if (!Array.isArray(arrayOfTypeCheckers)) { process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; return emptyFunction.thatReturnsNull; } for (var i = 0; i < arrayOfTypeCheckers.length; i++) { var checker = arrayOfTypeCheckers[i]; if (typeof checker !== 'function') { warning( false, 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + 'received %s at index %s.', getPostfixForTypeWarning(checker), i ); return emptyFunction.thatReturnsNull; } } function validate(props, propName, componentName, location, propFullName) { for (var i = 0; i < arrayOfTypeCheckers.length; i++) { var checker = arrayOfTypeCheckers[i]; if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) { return null; } } return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); } return createChainableTypeChecker(validate); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
createUnionTypeChecker
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function validate(props, propName, componentName, location, propFullName) { for (var i = 0; i < arrayOfTypeCheckers.length; i++) { var checker = arrayOfTypeCheckers[i]; if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) { return null; } } return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
validate
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function createNodeChecker() { function validate(props, propName, componentName, location, propFullName) { if (!isNode(props[propName])) { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); } return null; } return createChainableTypeChecker(validate); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
createNodeChecker
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function validate(props, propName, componentName, location, propFullName) { if (!isNode(props[propName])) { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); } return null; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
validate
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function createShapeTypeChecker(shapeTypes) { function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; var propType = getPropType(propValue); if (propType !== 'object') { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); } for (var key in shapeTypes) { var checker = shapeTypes[key]; if (!checker) { continue; } var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); if (error) { return error; } } return null; } return createChainableTypeChecker(validate); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
createShapeTypeChecker
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; var propType = getPropType(propValue); if (propType !== 'object') { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); } for (var key in shapeTypes) { var checker = shapeTypes[key]; if (!checker) { continue; } var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); if (error) { return error; } } return null; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
validate
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function createStrictShapeTypeChecker(shapeTypes) { function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; var propType = getPropType(propValue); if (propType !== 'object') { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); } // We need to check all keys in case some are required but missing from // props. var allKeys = assign({}, props[propName], shapeTypes); for (var key in allKeys) { var checker = shapeTypes[key]; if (!checker) { return new PropTypeError( 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') ); } var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); if (error) { return error; } } return null; } return createChainableTypeChecker(validate); }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
createStrictShapeTypeChecker
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; var propType = getPropType(propValue); if (propType !== 'object') { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); } // We need to check all keys in case some are required but missing from // props. var allKeys = assign({}, props[propName], shapeTypes); for (var key in allKeys) { var checker = shapeTypes[key]; if (!checker) { return new PropTypeError( 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') ); } var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); if (error) { return error; } } return null; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
validate
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function isNode(propValue) { switch (typeof propValue) { case 'number': case 'string': case 'undefined': return true; case 'boolean': return !propValue; case 'object': if (Array.isArray(propValue)) { return propValue.every(isNode); } if (propValue === null || isValidElement(propValue)) { return true; } var iteratorFn = getIteratorFn(propValue); if (iteratorFn) { var iterator = iteratorFn.call(propValue); var step; if (iteratorFn !== propValue.entries) { while (!(step = iterator.next()).done) { if (!isNode(step.value)) { return false; } } } else { // Iterator will provide entry [k,v] tuples rather than values. while (!(step = iterator.next()).done) { var entry = step.value; if (entry) { if (!isNode(entry[1])) { return false; } } } } } else { return false; } return true; default: return false; } }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
isNode
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function isSymbol(propType, propValue) { // Native Symbol. if (propType === 'symbol') { return true; } // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' if (propValue['@@toStringTag'] === 'Symbol') { return true; } // Fallback for non-spec compliant Symbols which are polyfilled. if (typeof Symbol === 'function' && propValue instanceof Symbol) { return true; } return false; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
isSymbol
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function getPropType(propValue) { var propType = typeof propValue; if (Array.isArray(propValue)) { return 'array'; } if (propValue instanceof RegExp) { // Old webkits (at least until Android 4.0) return 'function' rather than // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ // passes PropTypes.object. return 'object'; } if (isSymbol(propType, propValue)) { return 'symbol'; } return propType; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
getPropType
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function getPreciseType(propValue) { if (typeof propValue === 'undefined' || propValue === null) { return '' + propValue; } var propType = getPropType(propValue); if (propType === 'object') { if (propValue instanceof Date) { return 'date'; } else if (propValue instanceof RegExp) { return 'regexp'; } } return propType; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
getPreciseType
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function getPostfixForTypeWarning(value) { var type = getPreciseType(value); switch (type) { case 'array': case 'object': return 'an ' + type; case 'boolean': case 'date': case 'regexp': return 'a ' + type; default: return type; } }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
getPostfixForTypeWarning
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function getClassName(propValue) { if (!propValue.constructor || !propValue.constructor.name) { return ANONYMOUS; } return propValue.constructor.name; }
We use an Error-like object for backward compatibility as people may call PropTypes directly and inspect their output. However, we don't use real Errors anymore. We don't inspect their stack anyway, and creating them is prohibitively expensive if they are created too often, such as what happens in oneOfType() for any type before the one that matched.
getClassName
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function invariant(condition, format, a, b, c, d, e, f) { validateFormat(format); if (!condition) { var error; if (format === undefined) { error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); } else { var args = [a, b, c, d, e, f]; var argIndex = 0; error = new Error(format.replace(/%s/g, function () { return args[argIndex++]; })); error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } }
Use invariant() to assert state which your program assumes to be true. Provide sprintf-style format (only %s is supported) and arguments to provide information about what broke and what you were expecting. The invariant message will be stripped in production, but the invariant will remain to ensure logic does not differ in production.
invariant
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
printWarning = function printWarning(format) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } var argIndex = 0; var message = 'Warning: ' + format.replace(/%s/g, function () { return args[argIndex++]; }); if (typeof console !== 'undefined') { console.error(message); } try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch (x) {} }
Similar to invariant but only logs a warning if the condition is not met. This can be used to log issues in development environments in critical paths. Removing the logging code for production environments will keep the same logic and follow the same code paths.
printWarning
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
function checkPropTypes(typeSpecs, values, location, componentName, getStack) { if (process.env.NODE_ENV !== 'production') { for (var typeSpecName in typeSpecs) { if (typeSpecs.hasOwnProperty(typeSpecName)) { var error; // Prop type validation may throw. In case they do, we don't want to // fail the render phase where it didn't fail before. So we log it. // After these have been cleaned up, we'll let them throw. try { // This is intentionally an invariant that gets caught. It's the same // behavior as without this statement except with a better message. invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]); error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); } catch (ex) { error = ex; } warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error); if (error instanceof Error && !(error.message in loggedTypeFailures)) { // Only monitor this failure once because there tends to be a lot of the // same error. loggedTypeFailures[error.message] = true; var stack = getStack ? getStack() : ''; warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : ''); } } } } }
Assert that the values match with the type specs. Error messages are memorized and will only be shown once. @param {object} typeSpecs Map of name to a ReactPropType @param {object} values Runtime values that need to be type-checked @param {string} location e.g. "prop", "context", "child context" @param {string} componentName Name of the component for error messages. @param {?Function} getStack Returns the component stack. @private
checkPropTypes
javascript
AllenFang/react-bootstrap-table
dist/react-bootstrap-table.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/dist/react-bootstrap-table.js
MIT
isRemoteDataSource(props) { const { remote } = (props || this.props); return remote === true || Util.isFunction(remote); }
Returns true if in the current configuration, the datagrid should load its data remotely. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
isRemoteDataSource
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
allowRemote(action, props) { const { remote } = (props || this.props); if (typeof remote === 'function') { const remoteObj = remote(Const.REMOTE); return remoteObj[action]; } else { return remote; } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
allowRemote
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
render() { const style = { height: this.props.height, maxHeight: this.props.maxHeight }; const columns = this.getColumnsDescription(this.props); const sortList = this.store.getSortInfo(); const pagination = this.renderPagination(); const toolBar = this.renderToolBar(); const tableFilter = this.renderTableFilter(columns); const isSelectAll = this.isSelectAll(); const expandColumnOptions = this.props.expandColumnOptions; if (typeof expandColumnOptions.expandColumnBeforeSelectColumn === 'undefined') { expandColumnOptions.expandColumnBeforeSelectColumn = true; } const colGroups = Util.renderColGroup(columns, this.props.selectRow, expandColumnOptions, this.props.version); const tableFooter = this.renderTableFooter(this.props.footerData, this.state.data, columns, colGroups); let sortIndicator = this.props.options.sortIndicator; if (typeof this.props.options.sortIndicator === 'undefined') sortIndicator = true; const { paginationPosition = Const.PAGINATION_POS_BOTTOM } = this.props.options; const showPaginationOnTop = paginationPosition !== Const.PAGINATION_POS_BOTTOM; const showPaginationOnBottom = paginationPosition !== Const.PAGINATION_POS_TOP; const selectRow = { ...this.props.selectRow }; if (this.props.cellEdit && this.props.cellEdit.mode !== Const.CELL_EDIT_NONE) { selectRow.clickToSelect = false; } const { toolbarPosition = Const.TOOLBAR_POS_TOP } = this.props.options; const showToolbarOnTop = toolbarPosition !== Const.TOOLBAR_POS_BOTTOM; const showToolbarOnBottom = toolbarPosition !== Const.TOOLBAR_POS_TOP; const { hideRowOnExpand = false } = this.props.options; return ( <div className={ classSet('react-bs-table-container', this.props.className, this.props.containerClass) } style={ this.props.containerStyle }> { showToolbarOnTop ? toolBar : null } { showPaginationOnTop ? pagination : null } <div ref={ node => this.table = node } className={ classSet('react-bs-table', { 'react-bs-table-bordered': this.props.bordered }, this.props.tableContainerClass) } style={ { ...style, ...this.props.tableStyle } } onMouseEnter={ this.handleMouseEnter } onMouseLeave={ this.handleMouseLeave }> <TableHeader ref={ node => this.header = node } version={ this.props.version } colGroups={ colGroups } headerContainerClass={ this.props.headerContainerClass } tableHeaderClass={ this.props.tableHeaderClass } style={ this.props.headerStyle } rowSelectType={ this.props.selectRow.mode } customComponent={ this.props.selectRow.customComponent } hideSelectColumn={ this.props.selectRow.hideSelectColumn } sortList={ sortList } sortIndicator={ sortIndicator } onSort={ this.handleSort } onSelectAllRow={ this.handleSelectAllRow } bordered={ this.props.bordered } condensed={ this.props.condensed } isFiltered={ this.filter ? true : false } isSelectAll={ isSelectAll } reset={ this.state.reset } expandColumnVisible={ expandColumnOptions.expandColumnVisible } expandColumnComponent={ expandColumnOptions.expandColumnComponent } expandedColumnHeaderComponent={ expandColumnOptions.expandedColumnHeaderComponent } noAnyExpand={ this.state.expanding.length === 0 } expandAll={ this.props.options.expandAll } toggleExpandAllChilds={ this.toggleExpandAllChilds } expandColumnBeforeSelectColumn={ expandColumnOptions.expandColumnBeforeSelectColumn }> { this.props.children } </TableHeader> <TableBody ref={ node => this.body = node } bodyContainerClass={ this.props.bodyContainerClass } tableBodyClass={ this.props.tableBodyClass } style={ { ...style, ...this.props.bodyStyle } } data={ this.state.data } version={ this.props.version } expandComponent={ this.props.expandComponent } expandableRow={ this.props.expandableRow } expandRowBgColor={ this.props.options.expandRowBgColor } expandBy={ this.props.options.expandBy || Const.EXPAND_BY_ROW } expandBodyClass={ this.props.options.expandBodyClass } expandParentClass={ this.props.options.expandParentClass } columns={ columns } trClassName={ this.props.trClassName } trStyle={ this.props.trStyle } striped={ this.props.striped } bordered={ this.props.bordered } hover={ this.props.hover } keyField={ this.store.getKeyField() } condensed={ this.props.condensed } selectRow={ selectRow } expandColumnOptions={ this.props.expandColumnOptions } cellEdit={ this.props.cellEdit } selectedRowKeys={ this.state.selectedRowKeys } onRowClick={ this.handleRowClick } onRowDoubleClick={ this.handleRowDoubleClick } onRowMouseOver={ this.handleRowMouseOver } onRowMouseOut={ this.handleRowMouseOut } onSelectRow={ this.handleSelectRow } noDataText={ this.props.options.noDataText } withoutNoDataText={ this.props.options.withoutNoDataText } expanding={ this.state.expanding } onExpand={ this.handleExpandRow } onlyOneExpanding={ this.props.options.onlyOneExpanding } beforeShowError={ this.props.options.beforeShowError } keyBoardNav={ this.props.keyBoardNav } onNavigateCell={ this.handleNavigateCell } x={ this.state.x } y={ this.state.y } withoutTabIndex={ this.props.withoutTabIndex } hideRowOnExpand={ hideRowOnExpand } onEditCell={ this.handleEditCell } /> { tableFooter } </div> { tableFilter } { showPaginationOnBottom ? pagination : null } { showToolbarOnBottom ? toolBar : null } { this.props.renderAlert ? <Alert stack={ { limit: 3 } } /> : null } </div> ); }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
render
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
isSelectAll() { if (this.store.isEmpty()) return false; const { selectRow: { unselectable, onlyUnselectVisible } } = this.props; const keyField = this.store.getKeyField(); const allRowKeys = onlyUnselectVisible ? this.store.get().map(r => r[keyField]) : this.store.getAllRowkey(); let defaultSelectRowKeys = this.store.getSelectedRowKeys(); if (onlyUnselectVisible) { defaultSelectRowKeys = defaultSelectRowKeys.filter(x => x !== allRowKeys); } if (defaultSelectRowKeys.length === 0) return false; let match = 0; let noFound = 0; let unSelectableCnt = 0; defaultSelectRowKeys.forEach(selected => { if (allRowKeys.indexOf(selected) !== -1) match++; else noFound++; if (unselectable && unselectable.indexOf(selected) !== -1) unSelectableCnt++; }); if (noFound === defaultSelectRowKeys.length) return false; if (match === allRowKeys.length) { return true; } else { if (unselectable && match <= unSelectableCnt && unSelectableCnt === unselectable.length) return false; else return 'indeterminate'; } // return (match === allRowKeys.length) ? true : 'indeterminate'; }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
isSelectAll
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
cleanSelected() { this.store.setSelectedRowKey([]); this.setState(() => { return { selectedRowKeys: [], reset: false }; }); }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
cleanSelected
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
cleanSort() { this.store.cleanSortInfo(); this.setState(() => { return { reset: false }; }); }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
cleanSort
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
toggleExpandAllChilds() { const { expanding } = this.state; if (expanding.length > 0) { this.setState(() => { return { expanding: [], reset: false }; }); } else { this.setState(() => { return { expanding: this.store.getAllRowkey(), reset: false }; }); } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
toggleExpandAllChilds
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
invalid = () => { this.setState(() => { return { data: this.store.get(), reset: false }; }); return; }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
invalid
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
invalid = () => { this.setState(() => { return { data: this.store.get(), reset: false }; }); return; }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
invalid
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
beforeSaveCellCB = result => { this.body.cancelEditCell(); if (result || result === undefined) { this.editCell(newVal, rowIndex, colIndex); } else { invalid(); } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
beforeSaveCellCB
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
beforeSaveCellCB = result => { this.body.cancelEditCell(); if (result || result === undefined) { this.editCell(newVal, rowIndex, colIndex); } else { invalid(); } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
beforeSaveCellCB
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
editCell(newVal, rowIndex, colIndex) { const { onCellEdit } = this.props.options; const { afterSaveCell } = this.props.cellEdit; const columns = this.getColumnsDescription(this.props); const fieldName = columns[colIndex].name; const props = { rowIndex, colIndex }; if (onCellEdit) { newVal = onCellEdit(this.state.data[rowIndex], fieldName, newVal); } if (this.allowRemote(Const.REMOTE_CELL_EDIT)) { if (afterSaveCell) { afterSaveCell(this.state.data[rowIndex], fieldName, newVal, props); } return; } const result = this.store.edit(newVal, rowIndex, fieldName).get(); this.setState(() => { return { data: result, reset: false }; }); if (afterSaveCell) { afterSaveCell(this.state.data[rowIndex], fieldName, newVal, props); } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
editCell
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
handleAddRowAtBegin(newObj) { try { this.store.addAtBegin(newObj); } catch (e) { return e; } this._handleAfterAddingRow(newObj, true); }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
handleAddRowAtBegin
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
afterHandleAddRow = errMsg => { if (isAsync) { this.toolbar.afterHandleSaveBtnClick(errMsg); } else { return errMsg; } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
afterHandleAddRow
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
afterHandleAddRow = errMsg => { if (isAsync) { this.toolbar.afterHandleSaveBtnClick(errMsg); } else { return errMsg; } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
afterHandleAddRow
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
afterAddRowCB = errMsg => { if (typeof errMsg !== 'undefined' && errMsg !== '') return afterHandleAddRow(errMsg); if (this.allowRemote(Const.REMOTE_INSERT_ROW)) { if (this.props.options.afterInsertRow) { this.props.options.afterInsertRow(newObj); } return afterHandleAddRow(); } try { this.store.add(newObj); } catch (e) { return afterHandleAddRow(e.message); } this._handleAfterAddingRow(newObj, false); return afterHandleAddRow(); }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
afterAddRowCB
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
afterAddRowCB = errMsg => { if (typeof errMsg !== 'undefined' && errMsg !== '') return afterHandleAddRow(errMsg); if (this.allowRemote(Const.REMOTE_INSERT_ROW)) { if (this.props.options.afterInsertRow) { this.props.options.afterInsertRow(newObj); } return afterHandleAddRow(); } try { this.store.add(newObj); } catch (e) { return afterHandleAddRow(e.message); } this._handleAfterAddingRow(newObj, false); return afterHandleAddRow(); }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
afterAddRowCB
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
getSizePerPage() { return this.state.sizePerPage; }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
getSizePerPage
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
getCurrentPage() { return this.state.currPage; }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
getCurrentPage
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
getTableDataIgnorePaging() { return this.store.getCurrentDisplayData(); }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
getTableDataIgnorePaging
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
deleteRow(dropRowKeys) { const dropRow = this.store.getRowByKey(dropRowKeys); const { onDeleteRow, afterDeleteRow, pageStartIndex } = this.props.options; if (onDeleteRow) { onDeleteRow(dropRowKeys, dropRow); } this.store.setSelectedRowKey([]); // clear selected row key if (this.allowRemote(Const.REMOTE_DROP_ROW)) { if (afterDeleteRow) { afterDeleteRow(dropRowKeys, dropRow); } return; } this.store.remove(dropRowKeys); // remove selected Row let result; if (this.props.pagination) { // debugger; const { sizePerPage } = this.state; const currLastPage = Math.ceil(this.store.getDataNum() / sizePerPage); let { currPage } = this.state; if (currPage > currLastPage) currPage = currLastPage; // console.log(Util.getNormalizedPage(currPage)); result = this.store.page(Util.getNormalizedPage(pageStartIndex, currPage), sizePerPage).get(); this.setState(() => { return { data: result, selectedRowKeys: this.store.getSelectedRowKeys(), currPage, reset: false }; }); } else { result = this.store.get(); this.setState(() => { return { data: result, reset: false, selectedRowKeys: this.store.getSelectedRowKeys() }; }); } if (afterDeleteRow) { afterDeleteRow(dropRowKeys, dropRow); } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
deleteRow
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
renderPagination() { if (this.props.pagination) { let dataSize; if (this.allowRemote(Const.REMOTE_PAGE)) { dataSize = this.props.fetchInfo.dataTotalSize; } else { dataSize = this.store.getDataNum(); } const { options } = this.props; const withFirstAndLast = options.withFirstAndLast === undefined ? true : options.withFirstAndLast; if (Math.ceil(dataSize / this.state.sizePerPage) <= 1 && this.props.ignoreSinglePage) return null; return ( <div className='react-bs-table-pagination'> <PaginationList ref={ node => this.pagination = node } version={ this.props.version } withFirstAndLast={ withFirstAndLast } alwaysShowAllBtns={ options.alwaysShowAllBtns } currPage={ this.state.currPage } changePage={ this.handlePaginationData } sizePerPage={ this.state.sizePerPage } sizePerPageList={ options.sizePerPageList || Const.SIZE_PER_PAGE_LIST } pageStartIndex={ options.pageStartIndex } paginationShowsTotal={ options.paginationShowsTotal } paginationSize={ options.paginationSize || Const.PAGINATION_SIZE } dataSize={ dataSize } onSizePerPageList={ options.onSizePerPageList } prePage={ options.prePage || Const.PRE_PAGE } nextPage={ options.nextPage || Const.NEXT_PAGE } firstPage={ options.firstPage || Const.FIRST_PAGE } lastPage={ options.lastPage || Const.LAST_PAGE } prePageTitle={ options.prePageTitle || Const.PRE_PAGE_TITLE } nextPageTitle={ options.nextPageTitle || Const.NEXT_PAGE_TITLE } firstPageTitle={ options.firstPageTitle || Const.FIRST_PAGE_TITLE } lastPageTitle={ options.lastPageTitle || Const.LAST_PAGE_TITLE } hideSizePerPage={ options.hideSizePerPage } sizePerPageDropDown={ options.sizePerPageDropDown } hidePageListOnlyOnePage={ options.hidePageListOnlyOnePage } paginationPanel={ options.paginationPanel } keepSizePerPageState={ options.keepSizePerPageState } open={ false }/> </div> ); } return null; }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
renderPagination
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
renderToolBar() { const { exportCSV, selectRow, insertRow, deleteRow, search, children, keyField } = this.props; const enableShowOnlySelected = selectRow && selectRow.showOnlySelected; const print = typeof this.props.options.printToolBar === 'undefined' ? true : this.props.options.printToolBar; if (enableShowOnlySelected || insertRow || deleteRow || search || exportCSV || this.props.options.searchPanel || this.props.options.btnGroup || this.props.options.toolBar) { let columns; if (Array.isArray(children)) { columns = children.filter(_ => _ != null).map((column, r) => { if (!column) return; const { props } = column; const isKey = props.isKey || keyField === props.dataField; return { isKey, name: props.headerText || props.children, field: props.dataField, hiddenOnInsert: props.hiddenOnInsert, keyValidator: props.keyValidator, customInsertEditor: props.customInsertEditor, // when you want same auto generate value and not allow edit, example ID field autoValue: props.autoValue || false, // for create editor, no params for column.editable() indicate that editor for new row editable: props.editable && (Util.isFunction(props.editable === 'function')) ? props.editable() : props.editable, format: props.dataFormat ? function(value) { return props.dataFormat(value, null, props.formatExtraData, r).replace(/<.*?>/g, ''); } : false }; }); } else { columns = [ { name: children.props.headerText || children.props.children, field: children.props.dataField, editable: children.props.editable, customInsertEditor: children.props.customInsertEditor, hiddenOnInsert: children.props.hiddenOnInsert, keyValidator: children.props.keyValidator } ]; } return ( <div className={ `react-bs-table-tool-bar ${ print ? '' : 'hidden-print' }` }> <ToolBar ref={ node => this.toolbar = node } version={ this.props.version } defaultSearch={ this.props.options.defaultSearch } clearSearch={ this.props.options.clearSearch } searchPosition={ this.props.options.searchPosition } searchDelayTime={ this.props.options.searchDelayTime } enableInsert={ insertRow } enableDelete={ deleteRow } enableSearch={ search } enableExportCSV={ exportCSV } enableShowOnlySelected={ enableShowOnlySelected } columns={ columns } searchPlaceholder={ this.props.searchPlaceholder } exportCSVText={ this.props.options.exportCSVText } insertText={ this.props.options.insertText } deleteText={ this.props.options.deleteText } saveText= { this.props.options.saveText } closeText= { this.props.options.closeText } ignoreEditable={ this.props.options.ignoreEditable } onAddRow={ this.handleAddRow } onDropRow={ this.handleDropRow } onSearch={ this.handleSearch } onExportCSV={ this.handleExportCSV } onShowOnlySelected={ this.handleShowOnlySelected } insertModalHeader={ this.props.options.insertModalHeader } insertModalFooter={ this.props.options.insertModalFooter } insertModalBody={ this.props.options.insertModalBody } insertModal={ this.props.options.insertModal } insertBtn={ this.props.options.insertBtn } deleteBtn={ this.props.options.deleteBtn } showSelectedOnlyBtn={ this.props.options.showSelectedOnlyBtn } exportCSVBtn={ this.props.options.exportCSVBtn } clearSearchBtn={ this.props.options.clearSearchBtn } searchField={ this.props.options.searchField } searchPanel={ this.props.options.searchPanel } btnGroup={ this.props.options.btnGroup } toolBar={ this.props.options.toolBar } reset={ this.state.reset } isValidKey={ this.store.isValidKey } insertFailIndicator={ this.props.options.insertFailIndicator || Const.INSERT_FAIL_INDICATOR } /> </div> ); } else { return null; } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
renderToolBar
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
renderTableFilter(columns) { if (this.props.columnFilter) { return ( <TableFilter columns={ columns } rowSelectType={ this.props.selectRow.mode } onFilter={ this.handleFilterData }/> ); } else { return null; } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
renderTableFilter
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
renderTableFooter(footerData, footerFormatterReturnData, columns, colGroups) { if (this.props.footer) { let hideSelectColumn = true; const { mode } = this.props.selectRow; const isSelectRowDefined = Util.isSelectRowDefined(mode); if (isSelectRowDefined) { hideSelectColumn = this.props.selectRow.hideSelectColumn; } return ( <TableFooter ref={ node => this.footer = node } columns={ columns } colGroups={ colGroups } footerFormatterReturnData={ footerFormatterReturnData } tableFooterClass={ this.props.tableFooterClass } style={ this.props.headerStyle } hideSelectColumn={ hideSelectColumn } expandColumnVisible={ this.props.expandColumnOptions.expandColumnVisible } bordered={ this.props.bordered } condensed={ this.props.condensed } isFiltered={ this.filter ? true : false } showStickyColumn={ this.props.showStickyColumn }> { footerData } </TableFooter> ); } return null; }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
renderTableFooter
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
_adjustTable() { this._adjustHeight(); if (!this.props.printable) { this._adjustHeaderWidth(); } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
_adjustTable
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
_adjustHeaderWidth() { const header = this.header.getHeaderColGrouop(); const tbody = this.body.tbody; const bodyHeader = this.body.getHeaderColGrouop(); const firstRow = tbody.childNodes[0]; const isScroll = tbody.parentNode.getBoundingClientRect().height > tbody.parentNode.parentNode.getBoundingClientRect().height; const scrollBarWidth = isScroll ? Util.getScrollBarWidth() : 0; if (firstRow && this.store.getDataNum()) { if (isScroll || this.isVerticalScroll !== isScroll) { const cells = firstRow.childNodes; for (let i = 0; i < cells.length; i++) { const cell = cells[i]; const computedStyle = window.getComputedStyle(cell); let width = parseFloat(computedStyle.width.replace('px', '')); if (this.isIE) { const paddingLeftWidth = parseFloat(computedStyle.paddingLeft.replace('px', '')); const paddingRightWidth = parseFloat(computedStyle.paddingRight.replace('px', '')); const borderRightWidth = parseFloat(computedStyle.borderRightWidth.replace('px', '')); const borderLeftWidth = parseFloat(computedStyle.borderLeftWidth.replace('px', '')); width = width + paddingLeftWidth + paddingRightWidth + borderRightWidth + borderLeftWidth; } const lastPadding = (cells.length - 1 === i ? scrollBarWidth : 0); if (width <= 0) { width = 120; cell.width = width + lastPadding + 'px'; } const result = width + lastPadding + 'px'; header[i].style.width = result; header[i].style.minWidth = result; if (cells.length - 1 === i) { bodyHeader[i].style.width = width + 'px'; bodyHeader[i].style.minWidth = width + 'px'; } else { bodyHeader[i].style.width = result; bodyHeader[i].style.minWidth = result; } } } } else { for (const i in bodyHeader) { if (bodyHeader.hasOwnProperty(i)) { const child = bodyHeader[i]; if (child.style) { if (child.style.width) { header[i].style.width = child.style.width; } if (child.style.minWidth) { header[i].style.minWidth = child.style.minWidth; } } } } } this.isVerticalScroll = isScroll; }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
_adjustHeaderWidth
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
_adjustHeight() { const { height } = this.props; let { maxHeight } = this.props; if ((typeof height === 'number' && !isNaN(height)) || height.indexOf('%') === -1) { this.body.container.style.height = parseFloat(height, 10) - this.header.container.offsetHeight + 'px'; } if (maxHeight) { maxHeight = typeof maxHeight === 'number' ? maxHeight : parseInt(maxHeight.replace('px', ''), 10); this.body.container.style.maxHeight = maxHeight - this.header.container.offsetHeight + 'px'; } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
_adjustHeight
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
_handleAfterAddingRow(newObj, atTheBeginning) { let result; if (this.props.pagination) { // if pagination is enabled and inserting row at the end, // change page to the last page // otherwise, change it to the first page const { sizePerPage } = this.state; if (atTheBeginning) { const { pageStartIndex } = this.props.options; result = this.store.page(Util.getNormalizedPage(pageStartIndex), sizePerPage).get(); this.setState(() => { return { data: result, currPage: Util.getFirstPage(pageStartIndex), reset: false }; }); } else { const currLastPage = Math.ceil(this.store.getDataNum() / sizePerPage); result = this.store.page(currLastPage, sizePerPage).get(); this.setState(() => { return { data: result, currPage: currLastPage, reset: false }; }); } } else { result = this.store.get(); this.setState(() => { return { data: result, reset: false }; }); } if (this.props.options.afterInsertRow) { this.props.options.afterInsertRow(newObj); } }
Returns true if this action can be handled remote store From #990, Sometimes, we need some actions as remote, some actions are handled by default so function will tell you the target action is can be handled as remote or not. @param {String} [action] Required. @param {Object} [props] Optional. If not given, this.props will be used @return {Boolean}
_handleAfterAddingRow
javascript
AllenFang/react-bootstrap-table
src/BootstrapTable.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/BootstrapTable.js
MIT
render() { this.clickNum = 0; const { selectRow, row, isSelected, className, index, hidden } = this.props; let { style } = this.props; let backgroundColor = null; let selectRowClass = null; if (selectRow) { backgroundColor = Utils.isFunction(selectRow.bgColor) ? selectRow.bgColor(row, isSelected) : ( isSelected ? selectRow.bgColor : null); selectRowClass = Utils.isFunction(selectRow.className) ? selectRow.className(row, isSelected) : ( isSelected ? selectRow.className : null); } if (Utils.isFunction(style)) { style = style(row, index); } else { style = { ...style } || {}; } // the bgcolor of row selection always overwrite the bgcolor defined by global. if (style && backgroundColor && isSelected) { style.backgroundColor = backgroundColor; } const trCss = { style: { ...style }, className: classSet(selectRowClass, className) }; return ( <tr { ...trCss } onMouseOver={ this.rowMouseOver } onMouseOut={ this.rowMouseOut } onClick={ this.rowClick } hidden={ hidden } onDoubleClick={ this.rowDoubleClick }>{ this.props.children }</tr> ); }
if clickToSelectAndEditCell is enabled, there should be a delay to prevent a selection changed when user dblick to edit cell on same row but different cell
render
javascript
AllenFang/react-bootstrap-table
src/TableRow.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/TableRow.js
MIT
filterArray(targetVal, filterVal) { // case insensitive return filterVal.indexOf(targetVal) > -1; }
Filter if targetVal is contained in filterVal.
filterArray
javascript
AllenFang/react-bootstrap-table
src/store/TableDataStore.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/store/TableDataStore.js
MIT
search(searchText) { if (searchText.trim() === '') { this.filteredData = null; this.isOnFilter = false; this.searchText = null; if (this.filterObj) this._filter(this.data); } else { let source = this.data; this.searchText = searchText; if (this.filterObj) { this._filter(source); source = this.filteredData; } this._search(source); } }
Filter if targetVal is contained in filterVal.
search
javascript
AllenFang/react-bootstrap-table
src/store/TableDataStore.js
https://github.com/AllenFang/react-bootstrap-table/blob/master/src/store/TableDataStore.js
MIT