code
stringlengths
28
313k
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
74
language
stringclasses
1 value
repo
stringlengths
5
60
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
is_ambiguous = function () { return typeof (AMBIGUITIES[timezone_name]) !== 'undefined'; }
Checks if it is possible that the timezone is ambiguous.
is_ambiguous
javascript
Serhioromano/bootstrap-calendar
components/jstimezonedetect/jstz.js
https://github.com/Serhioromano/bootstrap-calendar/blob/master/components/jstimezonedetect/jstz.js
MIT
function buildEventsUrl(events_url, data) { var separator, key, url; url = events_url; separator = (events_url.indexOf('?') < 0) ? '?' : '&'; for(key in data) { url += separator + key + '=' + encodeURIComponent(data[key]); separator = '&'; } return url; }
Bootstrap based calendar full view. https://github.com/Serhioromano/bootstrap-calendar User: Sergey Romanov <[email protected]>
buildEventsUrl
javascript
Serhioromano/bootstrap-calendar
js/calendar.js
https://github.com/Serhioromano/bootstrap-calendar/blob/master/js/calendar.js
MIT
function _getPathFromNpm () { return new Promise((resolve) => { exec('npm config --global get prefix', (err, stdout) => { if (err) { resolve(null) } else { const npmPath = stdout.replace(/\n/, '') debug(`PowerShell: _getPathFromNpm() resolving with: ${npmPath}`) resolve(npmPath) } }) }) }
Attempts to get npm's path by calling out to "npm config" @returns {Promise.<string>} - Promise that resolves with the found path (or null if not found)
_getPathFromNpm
javascript
felixrieseberg/npm-windows-upgrade
src/find-npm.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/find-npm.js
MIT
function _getPathFromPowerShell () { return new Promise(resolve => { const psArgs = 'Get-Command npm | Select-Object -ExpandProperty Definition' const args = [ '-NoProfile', '-NoLogo', psArgs ] const child = spawn('powershell.exe', args) let stdout = [] let stderr = [] child.stdout.on('data', (data) => { debug(`PowerShell: Stdout received: ${data.toString()}`) stdout.push(data.toString()) }) child.stderr.on('data', (data) => { debug(`PowerShell: Stderr received: ${data.toString()}`) stderr.push(data.toString()) }) child.on('exit', () => { const cmdPath = (stdout[0] && stdout[0].trim) ? stdout[0].trim() : null if (stderr.length === 0 && cmdPath && cmdPath.slice(cmdPath.length - 7) === 'npm.cmd') { // We're probably installed in a location like C:\Program Files\nodejs\npm.cmd, // meaning that we should not use the global prefix installation location const npmPath = cmdPath.slice(0, cmdPath.length - 8) debug(`PowerShell: _getPathFromPowerShell() resolving with: ${npmPath}`) resolve(npmPath) } else { resolve(null) } }) child.stdin.end() }) }
Attempts to get npm's path by calling out to "Get-Command npm" @returns {Promise.<string>} - Promise that resolves with the found path (or null if not found)
_getPathFromPowerShell
javascript
felixrieseberg/npm-windows-upgrade
src/find-npm.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/find-npm.js
MIT
function _getPath () { return Promise.all([_getPathFromPowerShell(), _getPathFromNpm()]) .then((results) => { const fromNpm = results[1] || '' const fromPowershell = results[0] || '' // Quickly check if there's an npm folder in there const fromPowershellPath = path.join(fromPowershell, 'node_modules', 'npm') const fromNpmPath = path.join(fromNpm, 'node_modules', 'npm') const isFromPowershell = utils.isPathAccessible(fromPowershellPath) const isFromNpm = utils.isPathAccessible(fromNpmPath) // Found in... // Powershell: -> return powershell path // npm: -> return npm path // nowhere: -> return powershell path if (isFromPowershell) { return { path: fromPowershell, message: strings.npmFoundIn(fromPowershell, fromNpm, fromPowershell) } } else if (isFromNpm) { return { path: fromNpm, message: strings.npmFoundIn(fromPowershell, fromNpm, fromNpm) } } else { return { path: fromPowershell, message: strings.npmNotFoundGuessing(fromPowershell, fromNpm, fromPowershell) } } }) }
Attempts to get the current installation location of npm by looking up the global prefix. Prefer PowerShell, be falls back to npm's opinion @return {Promise.<string>} - NodeJS installation path
_getPath
javascript
felixrieseberg/npm-windows-upgrade
src/find-npm.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/find-npm.js
MIT
function _checkPath (npmPath) { return new Promise((resolve, reject) => { if (npmPath) { fs.lstat(npmPath, (err, stats) => { if (err || !stats || (stats.isDirectory && !stats.isDirectory())) { reject(new Error(strings.givenPathNotValid(npmPath))) } else { resolve({ path: npmPath, message: strings.givenPathValid(npmPath) }) } }) } else { reject(new Error('Called _checkPath() with insufficient parameters')) } }) }
Attempts to get npm's path by calling out to "npm config" @param {string} npmPath - Input path if given by user @returns {Promise.<string>}
_checkPath
javascript
felixrieseberg/npm-windows-upgrade
src/find-npm.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/find-npm.js
MIT
function findNpm (npmPath) { if (npmPath) { return _checkPath(npmPath) } else { return _getPath() } }
Finds npm - either by checking a given path, or by asking the system for the location @param {string} npmPath - Input path if given by user @returns {Promise.<string>}
findNpm
javascript
felixrieseberg/npm-windows-upgrade
src/find-npm.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/find-npm.js
MIT
function runUpgrade (version, npmPath) { return new Promise((resolve, reject) => { const scriptPath = path.resolve(__dirname, '../powershell/upgrade-npm.ps1') const psArgs = npmPath === null ? `& {& '${scriptPath}' -version '${version}' }` : `& {& '${scriptPath}' -version '${version}' -NodePath '${npmPath}' }` const args = [ '-ExecutionPolicy', 'Bypass', '-NoProfile', '-NoLogo', psArgs ] if (process.env.DEBUG) { args.push('-debug') } let stdout = [] let stderr = [] let child try { child = spawn('powershell.exe', args) } catch (error) { return reject(error) } child.stdout.on('data', (data) => { debug('PowerShell: Stdout received: ' + data.toString()) stdout.push(data.toString()) }) child.stderr.on('data', (data) => { debug('PowerShell: Stderr received: ' + data.toString()) stderr.push(data.toString()) }) child.on('exit', () => resolve({ stderr, stdout })) child.stdin.end() }) }
Executes the PS1 script upgrading npm @param {string} version - The version to be installed (npm install npm@{version}) @param {string} npmPath - Path to Node installation (optional) @return {Promise.<stderr[], stdout[]>} - stderr and stdout received from the PS1 process
runUpgrade
javascript
felixrieseberg/npm-windows-upgrade
src/powershell.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/powershell.js
MIT
function runSimpleUpgrade (version) { return new Promise((resolve) => { let npmCommand = (version) ? `npm install -g npm@${version}` : 'npm install -g npm' let stdout = [] let stderr = [] let child try { child = spawn('powershell.exe', [ '-NoProfile', '-NoLogo', npmCommand ]) } catch (error) { // This is dirty, but the best way for us to try/catch right now resolve({ error }) } child.stdout.on('data', (data) => stdout.push(data.toString())) child.stderr.on('data', (data) => stderr.push(data.toString())) child.on('exit', () => resolve({ stderr, stdout })) child.stdin.end() }) }
Executes 'npm install -g npm' upgrading npm @param {string} version - The version to be installed (npm install npm@{version}) @return {Promise.<stderr[], stdout[]>} - stderr and stdout received from the PS1 process
runSimpleUpgrade
javascript
felixrieseberg/npm-windows-upgrade
src/powershell.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/powershell.js
MIT
async ensureInternet () { if (this.options.dnsCheck !== false) { const isOnline = await utils.checkInternetConnection() if (!isOnline) { utils.exit(1, strings.noInternet) } } }
Executes the upgrader's "let's check the user's internet" logic, eventually quietly resolving or quitting the process with an error if the connection is not sufficient
ensureInternet
javascript
felixrieseberg/npm-windows-upgrade
src/upgrader.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/upgrader.js
MIT
async ensureExecutionPolicy () { if (this.options.executionPolicyCheck !== false) { try { const isExecutable = await utils.checkExecutionPolicy() if (!isExecutable) { utils.exit(1, strings.noExecutionPolicy) } } catch (err) { utils.exit(1, strings.executionPolicyCheckError, err) } } }
Executes the upgrader's "let's check the user's powershell execution policy" logic, eventually quietly resolving or quitting the process with an error if the policy is not sufficient
ensureExecutionPolicy
javascript
felixrieseberg/npm-windows-upgrade
src/upgrader.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/upgrader.js
MIT
async wasUpgradeSuccessful () { this.installedVersion = await versions.getInstalledNPMVersion() return (this.installedVersion === this.options.npmVersion) }
Checks if the upgrade was successful @return {boolean} - was the upgrade successful?
wasUpgradeSuccessful
javascript
felixrieseberg/npm-windows-upgrade
src/upgrader.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/upgrader.js
MIT
async chooseVersion () { if (!this.options.npmVersion) { const availableVersions = await versions.getAvailableNPMVersions() const versionList = [{ type: 'list', name: 'version', message: 'Which version do you want to install?', choices: availableVersions.reverse() }] this.options.npmVersion = await inquirer.prompt(versionList) .then(answer => answer.version) } if (this.options.npmVersion === 'latest') { this.options.npmVersion = await versions.getLatestNPMVersion() } }
Executes the upgrader's "let's have the user choose a version" logic
chooseVersion
javascript
felixrieseberg/npm-windows-upgrade
src/upgrader.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/upgrader.js
MIT
async choosePath () { try { const npmPaths = await findNpm(this.options.npmPath) this.log(npmPaths.message) this.options.npmPath = npmPaths.path debug(`Upgrader: Chosen npm path: ${this.options.npmPath}`) } catch (err) { utils.exit(1, err) } }
Executes the upgrader's "let's find npm" logic
choosePath
javascript
felixrieseberg/npm-windows-upgrade
src/upgrader.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/upgrader.js
MIT
async upgradeSimple () { this.spinner = new Spinner(`${strings.startingUpgradeSimple} %s`) if (this.options.spinner === false) { console.log(strings.startingUpgradeSimple) } else { this.spinner.start() } const output = await powershell.runSimpleUpgrade(this.options.npmVersion) this.spinner.stop(false) console.log('\n') if (output.error) { throw output.error } }
Attempts a simple upgrade, eventually calling npm install -g npm @param {string} version - Version that should be installed @private
upgradeSimple
javascript
felixrieseberg/npm-windows-upgrade
src/upgrader.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/upgrader.js
MIT
async upgradeComplex () { this.spinner = new Spinner(`${strings.startingUpgradeComplex} %s`) if (this.options.spinner === false) { console.log(strings.startingUpgradeComplex) } else { this.spinner.start() } const output = await powershell.runUpgrade(this.options.npmVersion, this.options.npmPath) this.spinner.stop(false) console.log('\n') // If we failed to elevate to administrative rights, we have to abort. if (output.stdout[0] && output.stdout[0].includes('NOTADMIN')) { utils.exit(1, strings.noAdmin) } }
Upgrades npm in the correct directory, securing and reapplying existing configuration @param {string} version - Version that should be installed @param {string} npmPath - Path where npm should be installed @private
upgradeComplex
javascript
felixrieseberg/npm-windows-upgrade
src/upgrader.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/upgrader.js
MIT
log (message) { if (!this.options.quiet) { console.log(message) } }
Logs a message to console, unless the user specified quiet mode @param {string} message - message to log @private
log
javascript
felixrieseberg/npm-windows-upgrade
src/upgrader.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/upgrader.js
MIT
logUpgradeFailure (...errors) { // Uh-oh, something didn't work as it should have. versions.getVersions().then((debugVersions) => { let info if (this.options.npmVersion && this.installedVersion) { info = `You wanted to install npm ${this.options.npmVersion}, but the installed version is ${this.installedVersion}.\n\n` info += 'A common reason is an attempted "npm install npm" or "npm upgrade npm". ' info += 'As of today, the only solution is to completely uninstall and then reinstall Node.js. ' info += 'For a small tutorial, please see https://github.com/felixrieseberg/npm-windows-upgrade#fix-an-attempted-upgrade.\n' } else if (this.options.npmVersion) { info = `You wanted to install npm ${this.options.npmVersion}, but we could not confirm that the installation succeeded.` } else { info = 'We encountered an error during installation.\n' } info += '\nPlease consider reporting your trouble to https://aka.ms/npm-issues.' console.log(chalk.red(info)) console.log(chalk.bold('\nDebug Information:\n')) console.log(debugVersions) if (errors && errors.length && errors.length > 0) console.log('Here is the error:') // If we just got an error string (we shouldn't handle that) if (typeof errors !== 'string') { console.log('\n' + errors + '\n') return process.exit(1) } for (let i = 0; i < errors.length; i++) { console.log('\n' + errors[i] + '\n') } setTimeout(() => { process.exit(1) }, 1000) }) }
If the whole upgrade failed, we use this method to log a detailed trace with versions - all to make it easier for users to create meaningful issues. @param errors {array} - AS many errors as found
logUpgradeFailure
javascript
felixrieseberg/npm-windows-upgrade
src/upgrader.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/upgrader.js
MIT
function exit (status, ...messages) { if (messages) { messages.forEach(message => console.log(message)) } process.exit(status) }
Exits the process with a given status, logging a given message before exiting. @param {number} status - exit status @param {string} messages - message to log
exit
javascript
felixrieseberg/npm-windows-upgrade
src/utils.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/utils.js
MIT
function checkInternetConnection () { return new Promise((resolve) => { require('dns').lookup('microsoft.com', (err) => { if (err && err.code === 'ENOTFOUND') { resolve(false) } else { resolve(true) } }) }) }
Checks for an active Internet connection by doing a DNS lookup of Microsoft.com. @return {Promise.<boolean>} - True if lookup succeeded (or if we skip the test)
checkInternetConnection
javascript
felixrieseberg/npm-windows-upgrade
src/utils.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/utils.js
MIT
function checkExecutionPolicy () { return new Promise((resolve, reject) => { let output = [] let child try { debug('Powershell: Attempting to spawn PowerShell child') child = spawn('powershell.exe', ['-NoProfile', '-NoLogo', 'Get-ExecutionPolicy']) } catch (error) { debug('Powershell: Could not spawn PowerShell child') reject(error) } child.stdout.on('data', (data) => { debug('PowerShell: Stdout received: ' + data.toString()) output.push(data.toString()) }) child.stderr.on('data', (data) => { debug('PowerShell: Stderr received: ' + data.toString()) output.push(data.toString()) }) child.on('exit', () => { const linesHit = output.filter((line) => line.includes('Unrestricted') || line.includes('RemoteSigned') || line.includes('Bypass')) const unrestricted = (linesHit.length > 0) if (!unrestricted) { debug('PowerShell: Resolving restricted (false)') resolve(false) } else { debug('PowerShell: Resolving unrestricted (true)') resolve(true) } }) child.stdin.end() }) }
Checks the current Windows PS1 execution policy. The upgrader requires an unrestricted policy. @return {Promise.<boolean>} - True if unrestricted, false if it isn't
checkExecutionPolicy
javascript
felixrieseberg/npm-windows-upgrade
src/utils.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/utils.js
MIT
function isPathAccessible (filePath) { try { fs.accessSync(filePath) debug(`Utils: isPathAccessible(): ${filePath} exists`) return true } catch (err) { debug(`Utils: isPathAccessible(): ${filePath} does not exist`) return false } }
Checks if a path exists @param filePath - file path to check @returns {boolean} - does the file path exist?
isPathAccessible
javascript
felixrieseberg/npm-windows-upgrade
src/utils.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/utils.js
MIT
function getInstalledNPMVersion () { return new Promise((resolve, reject) => { let nodeVersion exec('npm -v', (err, stdout) => { if (err) { reject(new Error('Could not determine npm version.')) } else { nodeVersion = stdout.replace(/\n/, '') resolve(nodeVersion) } }) }) }
Gets the currently installed version of npm (npm -v) @return {Promise.<string>} - Installed version of npm
getInstalledNPMVersion
javascript
felixrieseberg/npm-windows-upgrade
src/versions.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/versions.js
MIT
function getAvailableNPMVersions () { return new Promise((resolve, reject) => { exec('npm view npm versions --json', (err, stdout) => { if (err) { let error = 'We could not show latest available versions. Try running this script again ' error += 'with the version you want to install (npm-windows-upgrade --npm-version 3.0.0)' return reject(error) } resolve(JSON.parse(stdout)) }) }) }
Fetches the published versions of npm from the npm registry @return {Promise.<versions[]>} - Array of the available versions
getAvailableNPMVersions
javascript
felixrieseberg/npm-windows-upgrade
src/versions.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/versions.js
MIT
function getLatestNPMVersion () { return new Promise((resolve, reject) => { exec('npm show npm version', (err, stdout) => { if (err) { let error = 'We could not show latest available versions. Try running this script again ' error += 'with the version you want to install (npm-windows-upgrade --npm-version 3.0.0)' return reject(error) } let latest = stdout.replace(/(\r\n|\n|\r)/gm, '') resolve(latest.trim()) }) }) }
Fetches the published versions of npm from the npm registry @return {Promise.<version>} - Array of the available versions
getLatestNPMVersion
javascript
felixrieseberg/npm-windows-upgrade
src/versions.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/versions.js
MIT
function _getWindowsVersion () { return new Promise((resolve, reject) => { const command = 'systeminfo | findstr /B /C:"OS Name" /C:"OS Version"' exec(command, (error, stdout) => { if (error) { reject(error) } else { resolve(stdout) } }) }) }
Get the current name and version of Windows
_getWindowsVersion
javascript
felixrieseberg/npm-windows-upgrade
src/versions.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/versions.js
MIT
async function getVersions () { let versions = process.versions let prettyVersions = [] versions.os = process.platform + ' ' + process.arch for (let variable in versions) { if (versions.hasOwnProperty(variable)) { prettyVersions.push(`${variable}: ${versions[variable]}`) } } try { const windowsVersion = await _getWindowsVersion() prettyVersions.push(windowsVersion.replace(/ +/g, ' ')) } catch (error) { // Do nothing, we're okay with this failing. // Most common reason is we're not on an english // Windows. } return prettyVersions.join(' | ') }
Get installed versions of virtually everything important
getVersions
javascript
felixrieseberg/npm-windows-upgrade
src/versions.js
https://github.com/felixrieseberg/npm-windows-upgrade/blob/master/src/versions.js
MIT
Accordion = props => { const { id, children, style, className, activeSectionNames, multiple, onToggleSection } = props; const containerRef = useRef(); const [activeNames, setActiveNames] = useState(activeSectionNames); const [currentSection, setCurrentSection] = useState(); const { childrenRegistered, register, unregister } = useChildrenRegisterRef({ containerRef, selector: SELECTOR, }); useEffect(() => { if (activeSectionNames !== activeNames) { setActiveNames(activeSectionNames); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [activeSectionNames]); const handleToggleSection = (event, name) => { if (typeof onToggleSection === 'function') { return onToggleSection(event, name); } return setActiveNames(name); }; const setAsSelectAccordionSection = accordionSectionIndex => { childrenRegistered[accordionSectionIndex].focusButton(); }; const selectAccordionSection = side => { const accordionSectionIndex = childrenRegistered.findIndex( section => section.id === currentSection, ); if (accordionSectionIndex === childrenRegistered.length - 1 && side === RIGHT_SIDE) { setAsSelectAccordionSection(0); } else if (accordionSectionIndex === 0 && side === LEFT_SIDE) { setAsSelectAccordionSection(childrenRegistered.length - 1); } else { setAsSelectAccordionSection(accordionSectionIndex + side); } }; const keyHandlerMap = { [RIGHT_KEY]: () => selectAccordionSection(RIGHT_SIDE), [LEFT_KEY]: () => selectAccordionSection(LEFT_SIDE), [DOWN_KEY]: () => selectAccordionSection(RIGHT_SIDE), [UP_KEY]: () => selectAccordionSection(LEFT_SIDE), }; const handleKeyPressed = event => { if (keyHandlerMap[event.keyCode]) { event.preventDefault(); return keyHandlerMap[event.keyCode](); } return null; }; const context = { activeNames, multiple, privateOnToggleSection: handleToggleSection, privateOnFocusSection: setCurrentSection, privateRegisterAccordionSection: register, privateUnregisterAccordionSection: unregister, privateOnKeyPressed: handleKeyPressed, }; return ( <StyledUl ref={containerRef} id={id} className={className} style={style}> <Provider value={context}>{children}</Provider> </StyledUl> ); }
An Accordion is a collection of vertically stacked sections with multiple content areas. Allows a user to toggle the display of a section of content. @category Layout
Accordion
javascript
nexxtway/react-rainbow
src/components/Accordion/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Accordion/index.js
MIT
constructor(rootElement) { this.rootElement = rootElement; }
Create a new Accordion page object. @constructor @param {string} rootElement - The selector of the Accordion root element.
constructor
javascript
nexxtway/react-rainbow
src/components/Accordion/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Accordion/pageObject/index.js
MIT
async getItem(itemPosition) { const items = await $(this.rootElement).$$('[data-id="accordion-section-li"]'); if (items[itemPosition]) { return new PageAccordionSection( `${this.rootElement} [data-id="accordion-section-li"]:nth-child(${itemPosition + 1})`, ); } return null; }
Returns a new AccordionSection page object of the element in item position. @method @param {number} itemPosition - The base 0 index of the accordion section.
getItem
javascript
nexxtway/react-rainbow
src/components/Accordion/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Accordion/pageObject/index.js
MIT
AccordionSection = props => { const { style, disabled, children, label, icon, assistiveText, className, variant, name, } = props; const { activeNames, multiple, privateOnToggleSection, privateOnFocusSection, privateRegisterAccordionSection, privateUnregisterAccordionSection, privateOnKeyPressed, } = useContext(AccordionContext) ?? contextDefault; const containerRef = useRef(); const buttonRef = useRef(); const uniqueName = useUniqueIdentifier('accordion-section'); const accordionDetailsId = useUniqueIdentifier('accordion-section-details'); const currentName = name || uniqueName; useEffect(() => { if (!disabled) { privateRegisterAccordionSection({ id: currentName, ref: containerRef.current, focusButton: () => buttonRef.current.focus(), }); } return () => { if (!disabled) { privateUnregisterAccordionSection(currentName); } }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const isExpanded = getIsExpanded({ multiple, activeNames, currentName }); const resolveActiveNamesWhenMultiple = () => { if (activeNames === undefined) { return [currentName]; } if (isInArray(activeNames, currentName)) { return activeNames.filter(element => element !== currentName); } return [...activeNames, currentName]; }; const resolveActiveNames = () => { if (multiple) { return resolveActiveNamesWhenMultiple(); } if (currentName === activeNames) { return ''; } return currentName; }; const handleToggleSection = event => { if (!disabled) { privateOnToggleSection(event, resolveActiveNames()); } }; const handleFocusSection = () => { if (!disabled) { privateOnFocusSection(currentName); } }; const handleKeyPressed = event => { if (!disabled) { privateOnKeyPressed(event); } }; return ( <StyledLi data-id="accordion-section-li" className={className} style={style} disabled={disabled} variant={variant} isExpanded={isExpanded} ref={containerRef} > <StyledSummary data-id="accordion-section-summary" isExpanded={isExpanded} variant={variant} disabled={disabled} onClick={handleToggleSection} onFocus={handleFocusSection} onKeyDown={handleKeyPressed} aria-controls={accordionDetailsId} aria-expanded={isExpanded} type="button" ref={buttonRef} > <RightArrow isExpanded={isExpanded} disabled={disabled} /> <AssistiveText text={assistiveText} /> <StyledHeading disabled={disabled}> <RenderIf isTrue={icon}> <StyledIcon>{icon}</StyledIcon> </RenderIf> <RenderIf isTrue={label}> <StyledSpan data-id="accordion-section-label">{label}</StyledSpan> </RenderIf> </StyledHeading> </StyledSummary> <StyledContent data-id="accordion-section-content" aria-hidden={!isExpanded} isCollapsed={!isExpanded} id={accordionDetailsId} > {children} </StyledContent> </StyledLi> ); }
An AccordionSection is single section that is nested in the Accordion component. @category Layout
AccordionSection
javascript
nexxtway/react-rainbow
src/components/AccordionSection/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/index.js
MIT
get root() { return $(this.rootElement); }
Create a new AccordionSection page object. @constructor @param {string} rootElement - The selector of the AccordoinSection root element.
root
javascript
nexxtway/react-rainbow
src/components/AccordionSection/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/pageObject/index.js
MIT
async clickButton() { const elem = await this.summary; return elem.click(); }
Clicks the button icon element. @method
clickButton
javascript
nexxtway/react-rainbow
src/components/AccordionSection/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/pageObject/index.js
MIT
async hasFocusButton() { const elem = await this.summary; return elem.isFocused(); }
Returns true when the button icon has focus. @method @returns {bool}
hasFocusButton
javascript
nexxtway/react-rainbow
src/components/AccordionSection/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/pageObject/index.js
MIT
async isExpanded() { const elem = await this.content; return elem.isDisplayed(); }
Returns true when the accordion section is expanded, false otherwise. @method @returns {bool}
isExpanded
javascript
nexxtway/react-rainbow
src/components/AccordionSection/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/pageObject/index.js
MIT
async getLabel() { const elem = await this.label; return elem.getText(); }
Returns the label of the accordion section. @method @returns {string}
getLabel
javascript
nexxtway/react-rainbow
src/components/AccordionSection/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/pageObject/index.js
MIT
function ActivityTimeline(props) { const { variant, ...rest } = props; if (variant === 'accordion') { // eslint-disable-next-line react/jsx-props-no-spreading return <AccordionTimeline {...rest} />; } // eslint-disable-next-line react/jsx-props-no-spreading return <BasicTimeline {...rest} />; }
The ActivityTimeline displays each of any item's upcoming, current, and past activities in chronological order (ascending or descending). Notice that ActivityTimeline and TimelineMarker components are related and should be implemented together. @category Layout
ActivityTimeline
javascript
nexxtway/react-rainbow
src/components/ActivityTimeline/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/ActivityTimeline/index.js
MIT
function Application(props) { const { children, className, style, locale, theme } = props; const contextValue = { locale: useLocale(locale) }; const [normalizedTheme, setTheme] = useState(() => normalizeTheme(theme)); useEffect(() => { setTheme(normalizeTheme(theme)); }, [theme]); return ( <Provider value={contextValue}> <ThemeProvider theme={normalizedTheme}> <div className={className} style={style}> <RainbowLegacyStyles /> {children} </div> </ThemeProvider> </Provider> ); }
This component is used to setup the React Rainbow context for a tree. Usually, this component will wrap an app's root component so that the entire app will be within the configured context. @category Layout
Application
javascript
nexxtway/react-rainbow
src/components/Application/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Application/index.js
MIT
function Avatar(props) { const { className, style, size, assistiveText, backgroundColor, ...rest } = props; return ( <StyledContainer className={className} style={style} size={size} backgroundColor={backgroundColor} > {/* eslint-disable-next-line react/jsx-props-no-spreading */} <AvatarContent {...rest} assistiveText={assistiveText} /> <AssistiveText text={assistiveText} /> </StyledContainer> ); }
An avatar component represents an object or entity
Avatar
javascript
nexxtway/react-rainbow
src/components/Avatar/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Avatar/index.js
MIT
function AvatarGroup(props) { const { size, className, style, avatars, maxAvatars, showCounter } = props; return ( <StyledContainer className={className} style={style} size={size}> <RenderIf isTrue={showCounter}> <Counter size={size} avatars={avatars} maxAvatars={maxAvatars} /> </RenderIf> <Avatars size={size} avatars={avatars} showCounter={showCounter} maxAvatars={maxAvatars} /> </StyledContainer> ); }
An AvatarGroup is an element that communicates to the user that there are many entities associated to an item.
AvatarGroup
javascript
nexxtway/react-rainbow
src/components/AvatarGroup/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AvatarGroup/index.js
MIT
get htmlElementRef() { return this.avatarButtonRef; }
Returns the ref of the HTML button element. @public
htmlElementRef
javascript
nexxtway/react-rainbow
src/components/AvatarMenu/avatarButton.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AvatarMenu/avatarButton.js
MIT
render() { const { title, tabIndex, onClick, onFocus, onBlur, disabled, assistiveText, ariaHaspopup, src, initials, icon, avatarSize, initialsVariant, avatarBackgroundColor, } = this.props; return ( <StyledButton data-id="avatar-menu-button" tabIndex={tabIndex} onFocus={onFocus} onBlur={onBlur} disabled={disabled} onClick={onClick} title={title} aria-haspopup={ariaHaspopup} ref={this.avatarButtonRef} > <Avatar src={src} icon={icon} initials={initials} size={avatarSize} initialsVariant={initialsVariant} title={title} assistiveText={assistiveText} ariaHaspopup onFocus={onFocus} onBlur={onBlur} backgroundColor={avatarBackgroundColor} /> </StyledButton> ); }
Sets blur on the element. @public
render
javascript
nexxtway/react-rainbow
src/components/AvatarMenu/avatarButton.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AvatarMenu/avatarButton.js
MIT
function AvatarMenu(props) { const { src, initials, icon, avatarSize, initialsVariant, title, assistiveText, disabled, tabIndex, onClick, onFocus, onBlur, children, ...rest } = props; return ( <PrimitiveMenu // eslint-disable-next-line react/jsx-props-no-spreading {...rest} src={src} icon={icon} initials={initials} disabled={disabled} tabIndex={tabIndex} avatarSize={avatarSize} initialsVariant={initialsVariant} title={title} assistiveText={assistiveText} onClick={onClick} onFocus={onFocus} onBlur={onBlur} trigger={AvatarButton} > {children} </PrimitiveMenu> ); }
A Avatar Menu offers a list of actions or functions that a user can access.
AvatarMenu
javascript
nexxtway/react-rainbow
src/components/AvatarMenu/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AvatarMenu/index.js
MIT
constructor(rootElement) { this.rootElement = rootElement; this.primitiveMenu = new PagePrimitiveMenu( `${rootElement} button[data-id="avatar-menu-button"]`, ); }
Create a new AvatarMenu page object. @constructor @param {string} rootElement - The selector of the AvatarMenu root element.
constructor
javascript
nexxtway/react-rainbow
src/components/AvatarMenu/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AvatarMenu/pageObject/index.js
MIT
async getItem(itemPosition) { return this.primitiveMenu.getItem(itemPosition); }
Returns a new AvatarMenu page object of the element in item position. @method @param {number} itemPosition - The base 0 index of the MenuItem.
getItem
javascript
nexxtway/react-rainbow
src/components/AvatarMenu/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AvatarMenu/pageObject/index.js
MIT
async isOpen() { return this.primitiveMenu.isDropdownOpen(); }
Returns true when the menu is open, false otherwise. @method @returns {bool}
isOpen
javascript
nexxtway/react-rainbow
src/components/AvatarMenu/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AvatarMenu/pageObject/index.js
MIT
async hasFocusButton() { return this.primitiveMenu.hasFocusTrigger(); }
Returns true when the button element has focus. @method @returns {bool}
hasFocusButton
javascript
nexxtway/react-rainbow
src/components/AvatarMenu/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/AvatarMenu/pageObject/index.js
MIT
function Badge(props) { const { className, style, label, title, children, variant, size, borderRadius } = props; if (children === null && label === null) { return null; } return ( <StyledContainer className={className} style={style} variant={variant} title={title} size={size} borderRadius={borderRadius} > <Content label={label}>{children}</Content> </StyledContainer> ); }
Badges are labels that hold small amounts of information.
Badge
javascript
nexxtway/react-rainbow
src/components/Badge/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Badge/index.js
MIT
function Breadcrumb(props) { const { href, label, onClick, disabled, className, style } = props; return ( <StyledLi className={className} style={style}> <RenderIf isTrue={href}> <StyledAnchor disabled={disabled} href={href} aria-disabled={!!disabled}> {label} </StyledAnchor> </RenderIf> <RenderIf isTrue={onClick && !href}> <StyledButton disabled={disabled} onClick={onClick} aria-disabled={!!disabled}> {label} </StyledButton> </RenderIf> </StyledLi> ); }
An item in the hierarchy path of the page the user is on. @category Layout
Breadcrumb
javascript
nexxtway/react-rainbow
src/components/Breadcrumb/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Breadcrumb/index.js
MIT
function Breadcrumbs(props) { const { children, className, style } = props; return ( <StyledNav aria-label="Breadcrumbs" style={style} className={className}> <StyledOl>{children}</StyledOl> </StyledNav> ); }
Breadcrumbs are used to note the path of a record and help the user to navigate back to the parent. @category Layout
Breadcrumbs
javascript
nexxtway/react-rainbow
src/components/Breadcrumbs/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Breadcrumbs/index.js
MIT
constructor(props) { super(props); this.buttonRef = React.createRef(); }
Buttons are clickable items used to perform an action.
constructor
javascript
nexxtway/react-rainbow
src/components/Button/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Button/index.js
MIT
function ButtonGroup(props) { const { className, style, children, variant, borderRadius } = props; return ( <StyledContainer className={className} style={style} role="group" variant={variant} borderRadius={borderRadius} > {children} </StyledContainer> ); }
Button groups are used to bunch together buttons with similar actions
ButtonGroup
javascript
nexxtway/react-rainbow
src/components/ButtonGroup/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonGroup/index.js
MIT
constructor(props) { super(props); const { name } = this.props; this.groupNameId = name || uniqueId('options'); this.errorMessageId = uniqueId('error-message'); this.handleOnChange = this.handleOnChange.bind(this); }
ButtonGroupPicker can be used to group related options. The ButtonGroupPicker will control the selected state of its child ButtonOption. @category Form
constructor
javascript
nexxtway/react-rainbow
src/components/ButtonGroupPicker/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonGroupPicker/index.js
MIT
async getItem(itemPosition) { const items = await $(this.rootElement).$$('label'); if (items[itemPosition]) { return new PageButtonOption(`${this.rootElement} label:nth-child(${itemPosition + 1})`); } return null; }
Returns a new ButtonOption page object of the element in item position. @method @param {number} itemPosition - The base 0 index of the radio.
getItem
javascript
nexxtway/react-rainbow
src/components/ButtonGroupPicker/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonGroupPicker/pageObject/index.js
MIT
get htmlElementRef() { return buttonRef; }
ButtonIcons provide the user with a visual iconography that is typically used to invoke an event or action.
htmlElementRef
javascript
nexxtway/react-rainbow
src/components/ButtonIcon/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonIcon/index.js
MIT
get buttonRef() { return buttonRef; }
@deprecated Backward compatibility only. Use `htmlElementRef` instead.
buttonRef
javascript
nexxtway/react-rainbow
src/components/ButtonIcon/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonIcon/index.js
MIT
function ButtonMenu(props) { const { label, icon, iconPosition, buttonSize, title, assistiveText, buttonVariant, buttonShaded, disabled, tabIndex, onClick, onFocus, onBlur, children, ...rest } = props; return ( <PrimitiveMenu // eslint-disable-next-line react/jsx-props-no-spreading {...rest} label={label} icon={icon} iconPosition={iconPosition} size={buttonSize} assistiveText={assistiveText} disabled={disabled} tabIndex={tabIndex} variant={buttonVariant} shaded={buttonShaded} title={title} onClick={onClick} onFocus={onFocus} onBlur={onBlur} trigger={ButtonTrigger} > {children} </PrimitiveMenu> ); }
A Button Menu offers a list of actions or functions that a user can access.
ButtonMenu
javascript
nexxtway/react-rainbow
src/components/ButtonMenu/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonMenu/index.js
MIT
constructor(rootElement) { this.rootElement = rootElement; this.primitiveMenu = new PagePrimitiveMenu(`${rootElement} button`); }
Create a new ButtonMenu page object. @constructor @param {string} rootElement - The selector of the ButtonMenu root element.
constructor
javascript
nexxtway/react-rainbow
src/components/ButtonMenu/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonMenu/pageObject/index.js
MIT
get input() { return this.root.then(root => root.$('input')); }
Create a new ButtonOption page object. @constructor @param {string} rootElement - The selector of the Radio root element.
input
javascript
nexxtway/react-rainbow
src/components/ButtonOption/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonOption/pageObject/index.js
MIT
async hasFocus() { return (await this.input).isFocused(); }
Returns true when the ButtonOption has the focus. @method @returns {bool}
hasFocus
javascript
nexxtway/react-rainbow
src/components/ButtonOption/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonOption/pageObject/index.js
MIT
async isChecked() { return (await this.input).isSelected(); }
Returns true when the ButtonOption is checked. @method @returns {bool}
isChecked
javascript
nexxtway/react-rainbow
src/components/ButtonOption/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonOption/pageObject/index.js
MIT
function Calendar(props) { const { locale, selectionType, variant, value, onChange, ...rest } = props; const currentLocale = useLocale(locale); const currentValue = useCurrentDateFromValue(value); const range = useRangeFromValue(value, selectionType); const handleChange = useCallback( newValue => { if (selectionType === 'single') return onChange(newValue); const result = buildNewRangeFromValue(newValue, range); return onChange(result.range); }, [selectionType, onChange, range], ); if (variant === 'double') return ( <DoubleCalendar locale={currentLocale} value={currentValue} selectedRange={range} selectionType={selectionType} onChange={handleChange} {...rest} /> ); return ( <SingleCalendar locale={currentLocale} value={currentValue} selectedRange={range} selectionType={selectionType} onChange={handleChange} {...rest} /> ); }
Calendar provide a simple way to select a single date.
Calendar
javascript
nexxtway/react-rainbow
src/components/Calendar/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/index.js
MIT
async clickPrevMonthButton() { await $(this.rootElement) .$$('button[data-id=button-icon-element]')[0] .click(); }
Clicks the previous month button element. @method
clickPrevMonthButton
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async clickNextMonthButton() { await $(this.rootElement) .$$('button[data-id=button-icon-element]')[1] .click(); }
Clicks the next month button element. @method
clickNextMonthButton
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async isPrevMonthButtonDisabled() { const buttonEl = (await $(this.rootElement).$$('button[data-id=button-icon-element]'))[0]; return !(await buttonEl.isEnabled()); }
Returns true when the previous month button element is disabled. @method @returns {bool}
isPrevMonthButtonDisabled
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async isNextMonthButtonDisabled() { const buttonEl = (await $(this.rootElement).$$('button[data-id=button-icon-element]'))[1]; return !(await buttonEl.isEnabled()); }
Returns true when the next month button element is disabled. @method @returns {bool}
isNextMonthButtonDisabled
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async isPrevMonthButtonFocused() { const buttonEl = (await $(this.rootElement).$$('button[data-id=button-icon-element]'))[0]; return (await buttonEl.isExisting()) && (await buttonEl.isFocused()); }
Returns true when the previous month button element has focus. @method @returns {bool}
isPrevMonthButtonFocused
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async clickLeftMonthSelectYear() { await $(this.rootElement) .$$('select')[0] .click(); }
Clicks the select year element on the left month. @method
clickLeftMonthSelectYear
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async clickLeftMonthDay(day) { const buttonEl = await $(this.rootElement) .$$('table[role=grid]')[0] .$(`button=${day}`); if (await buttonEl.isExisting()) { await buttonEl.scrollIntoView(); await buttonEl.click(); } }
Clicks the specific enabled day button element on the left month. @method
clickLeftMonthDay
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async getLeftSelectedMonth() { return $(this.rootElement) .$$('h3[data-id=month]')[0] .getText(); }
Returns the text of the selected left month element. @method @returns {string}
getLeftSelectedMonth
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async getLeftMonthSelectedYear() { return $(this.rootElement) .$$('select')[0] .getValue(); }
Returns the value of the left select year element. @method @returns {string}
getLeftMonthSelectedYear
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async getLeftMonthSelectedDay() { const day = await $(this.rootElement) .$$('table[role=grid]')[0] .$('button[data-selected=true]'); if (await day.isExisting()) return day.getText(); return undefined; }
Returns the text of the current selected day element on the left month. @method @returns {string}
getLeftMonthSelectedDay
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async setLeftMonthYear(value) { await $(this.rootElement) .$$('select')[0] .selectByVisibleText(value); }
Set the value of the year select element @method @param {string}
setLeftMonthYear
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async isLeftMonthDayFocused(day) { const buttonEl = await $(this.rootElement) .$$('table[role=grid]')[0] .$(`button=${day}`); return (await buttonEl.isExisting()) && (await buttonEl.isFocused()); }
Returns true when the specific day button element on the left month has focus. @method @returns {bool}
isLeftMonthDayFocused
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async isLeftMonthDaySelected(day) { const buttonEl = await $(this.rootElement) .$$('table[role=grid]')[0] .$(`button=${day}`); return ( (await buttonEl.isExisting()) && (await buttonEl.getAttribute('data-selected')) === 'true' ); }
Returns true when the specific day element in left month is selected. @method @returns {string}
isLeftMonthDaySelected
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async isLeftYearSelectFocused() { const selectEl = (await $(this.rootElement).$$('select'))[0]; return (await selectEl.isExisting()) && (await selectEl.isFocused()); }
Returns true when the year select element in left month has focus. @method @returns {bool}
isLeftYearSelectFocused
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async clickRightMonthSelectYear() { await $(this.rootElement) .$$('select')[1] .click(); }
Clicks the select year element on the right month. @method
clickRightMonthSelectYear
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async clickRightMonthDay(day) { const buttonEl = await $(this.rootElement) .$$('table[role=grid]')[1] .$(`button=${day}`); if (await buttonEl.isExisting()) { await buttonEl.scrollIntoView(); await buttonEl.click(); } }
Clicks the specific enabled day button element on the right month. @method
clickRightMonthDay
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async setRightMonthYear(value) { await $(this.rootElement) .$$('select')[1] .selectByVisibleText(value); }
Set the value of the right select year element @method @param {string}
setRightMonthYear
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async isRightMonthDayFocused(day) { const buttonEl = await $(this.rootElement) .$$('table[role=grid]')[1] .$(`button=${day}`); return (await buttonEl.isExisting()) && (await buttonEl.isFocused()); }
Returns true when the specific day button element on the right month has focus. @method @returns {bool}
isRightMonthDayFocused
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async isRightMonthDaySelected(day) { const buttonEl = await $(this.rootElement) .$$('table[role=grid]')[1] .$(`button=${day}`); return ( (await buttonEl.isExisting()) && (await buttonEl.getAttribute('data-selected')) === 'true' ); }
Returns true when the specific day element in right month is selected. @method @returns {string}
isRightMonthDaySelected
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async isRightYearSelectFocused() { const selectEl = (await $(this.rootElement).$$('select'))[1]; return (await selectEl.isExisting()) && (await selectEl.isFocused()); }
Returns true when the year select element in right month has focus. @method @returns {bool}
isRightYearSelectFocused
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/doubleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/doubleCalendar.js
MIT
async clickSelectYear() { await $(this.rootElement) .$('select') .click(); }
Clicks the select year element. @method
clickSelectYear
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/singleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.js
MIT
async clickDay(day) { const buttonEl = await $(this.rootElement) .$('table') .$(`button=${day}`); if (await buttonEl.isExisting()) await buttonEl.click(); }
Clicks the specific enabled day button element. @method
clickDay
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/singleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.js
MIT
async getSelectedMonth() { return $(this.rootElement) .$('h3[data-id=month]') .getText(); }
Returns the text of the current selected month element. @method @returns {string}
getSelectedMonth
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/singleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.js
MIT
async getSelectedYear() { return $(this.rootElement) .$('select') .getValue(); }
Returns the value of the select year element. @method @returns {string}
getSelectedYear
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/singleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.js
MIT
async getSelectedDay() { return $(this.rootElement) .$('button[data-selected=true]') .getText(); }
Returns the text of the current selected day element. @method @returns {string}
getSelectedDay
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/singleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.js
MIT
async isDaySelected(day) { const buttonEl = await $(this.rootElement) .$('table') .$(`button=${day}`); return ( (await buttonEl.isExisting()) && (await buttonEl.getAttribute('data-selected')) === 'true' ); }
Returns true when the specific day element is selected. @method @returns {string}
isDaySelected
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/singleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.js
MIT
async isDayFocused(day) { const buttonEl = await $(this.rootElement) .$('table') .$(`button=${day}`); // eslint-disable-next-line no-return-await return (await buttonEl.isExisting()) && (await buttonEl.isFocused()); }
Returns true when the specific day button element has focus. @method @returns {bool}
isDayFocused
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/singleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.js
MIT
async isNextMonthButtonFocused() { const buttonEl = (await $(this.rootElement).$$('button[data-id=button-icon-element]'))[1]; // eslint-disable-next-line no-return-await return (await buttonEl.isExisting()) && (await buttonEl.isFocused()); }
Returns true when the next month button element has focus. @method @returns {bool}
isNextMonthButtonFocused
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/singleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.js
MIT
async isYearSelectFocused() { const selectEl = await $(this.rootElement).$('select'); // eslint-disable-next-line no-return-await return (await selectEl.isExisting()) && (await selectEl.isFocused()); }
Returns true when the year select element has focus. @method @returns {bool}
isYearSelectFocused
javascript
nexxtway/react-rainbow
src/components/Calendar/pageObject/singleCalendar.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.js
MIT
function Card(props) { const { id, className, style, actions, children, footer, title, icon, isLoading } = props; const hasHeader = icon || title || actions; const showFooter = !!(footer && !isLoading); return ( <StyledContainer id={id} className={className} style={style} hasHeader={hasHeader}> <Header actions={actions} title={title} icon={icon} /> <CardBoddy isLoading={isLoading}>{children}</CardBoddy> <RenderIf isTrue={showFooter}> <StyledFooter>{footer}</StyledFooter> </RenderIf> </StyledContainer> ); }
Cards are used to apply a container around a related grouping of information. @category Layout
Card
javascript
nexxtway/react-rainbow
src/components/Card/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Card/index.js
MIT
CarouselCard = props => { const { children, id, className, style, scrollDuration, disableAutoScroll, disableAutoRefresh, } = props; const containerRef = useRef(); const listRef = useRef(); const animationTimeoutRef = useRef(); const [isAnimationPaused, setIsAnimationPaused] = useState(disableAutoScroll); const [activeItem, setActiveItem] = useState(); const prevActiveItem = usePrevious(activeItem); const { childrenRegistered, register, unregister } = useChildrenRegister({ containerRef: listRef, selector: SELECTOR, }); useEffect(() => { if (childrenRegistered[0] && childrenRegistered[0].id !== activeItem) { setActiveItem(childrenRegistered[0].id); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [childrenRegistered]); useEffect(() => { if (!isAnimationPaused) { animationTimeoutRef.current = setTimeout(() => { const selectedItemIndex = getItemIndex(childrenRegistered, activeItem); const isLastItem = selectedItemIndex === childrenRegistered.length - 1; const nextItem = isLastItem ? 0 : selectedItemIndex + 1; if (isLastItem && disableAutoRefresh) { setIsAnimationPaused(true); } else if (childrenRegistered[nextItem]) { setActiveItem(childrenRegistered[nextItem].id); } }, scrollDuration * 1000); } return () => { if (animationTimeoutRef.current) { clearTimeout(animationTimeoutRef.current); } }; }, [activeItem, childrenRegistered, disableAutoRefresh, isAnimationPaused, scrollDuration]); const handleSelect = childId => { setActiveItem(childId); setIsAnimationPaused(true); }; const containerStyle = { height: getHeight(containerRef.current), ...style }; const context = { childrenRegistered, activeItem, prevActiveItem, isAnimationPaused, register, unregister, }; return ( <StyledContainer className={className} style={containerStyle} id={id} ref={containerRef}> <StyledAutoplay> <AnimationButton onClick={() => setIsAnimationPaused(!isAnimationPaused)} isAnimationPaused={isAnimationPaused} /> </StyledAutoplay> <StyledImagesUl ref={listRef}> <Provider value={context}>{children}</Provider> </StyledImagesUl> <Indicators carouselChildren={childrenRegistered} onSelect={handleSelect} selectedItem={activeItem} /> </StyledContainer> ); }
A carouselCard allows multiple pieces of featured content to occupy an allocated amount of space.
CarouselCard
javascript
nexxtway/react-rainbow
src/components/CarouselCard/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/CarouselCard/index.js
MIT
async getIndicatorItem(itemPosition) { const items = await $(this.rootElement).$$('li[role="presentation"]'); if (items[itemPosition]) { return new PageCarouselCardIndicator( `${this.rootElement} li[role="presentation"]:nth-child(${itemPosition + 1})`, ); } return null; }
Returns a new Indicator page object of the element in item position. @method @param {number} itemPosition - The base 0 index of the indicator item.
getIndicatorItem
javascript
nexxtway/react-rainbow
src/components/CarouselCard/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/CarouselCard/pageObject/index.js
MIT
async getImageItem(itemPosition) { const items = await $(this.rootElement).$$('li[role="tabpanel"]'); if (items[itemPosition]) { return new PageCarouselImage( `${this.rootElement} li[role="tabpanel"]:nth-child(${itemPosition + 1})`, ); } return null; }
Returns a new CarouselImage page object of the element in item position. @method @param {number} itemPosition - The base 0 index of the CarouselImage item.
getImageItem
javascript
nexxtway/react-rainbow
src/components/CarouselCard/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/CarouselCard/pageObject/index.js
MIT
async hasFocus() { return $(this.rootElement) .$('button') .isFocused(); }
Returns true when the indicator item has focus. @method @returns {bool}
hasFocus
javascript
nexxtway/react-rainbow
src/components/CarouselCard/pageObject/indicator.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/CarouselCard/pageObject/indicator.js
MIT
async isSelected() { return ( (await $(this.rootElement) .$('button') .getAttribute('aria-selected')) === 'true' ); }
Returns true when the indicator is selected. @method @returns {bool}
isSelected
javascript
nexxtway/react-rainbow
src/components/CarouselCard/pageObject/indicator.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/CarouselCard/pageObject/indicator.js
MIT
async getHeaderText() { return $(this.rootElement) .$('[title="Imagen Header"]') .getHTML(false); }
Returns the header of the CarouselImage. @method @returns {string}
getHeaderText
javascript
nexxtway/react-rainbow
src/components/CarouselImage/pageObject/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/CarouselImage/pageObject/index.js
MIT
constructor(props) { super(props); this.chartRef = React.createRef(); this.datasets = {}; this.registerDataset = this.registerDataset.bind(this); this.unregisterDataset = this.unregisterDataset.bind(this); this.updateDataset = this.updateDataset.bind(this); }
A chart is a graphical representation of data. Charts allow users to better understand and predict current and future data. The Chart component is based on Charts.js, an open source HTML5 based charting library. You can learn more about it here: @category DataView
constructor
javascript
nexxtway/react-rainbow
src/components/Chart/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/Chart/index.js
MIT
constructor(props) { super(props); this.errorMessageId = uniqueId('error-message'); this.groupNameId = props.name || uniqueId('options'); this.handleOnChange = this.handleOnChange.bind(this); }
A checkable input that communicates if an option is true, false or indeterminate. @category Form
constructor
javascript
nexxtway/react-rainbow
src/components/CheckboxGroup/index.js
https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxGroup/index.js
MIT