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 |
---|---|---|---|---|---|---|---|
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 |
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 |
handleToggleSection = (event, name) => {
if (typeof onToggleSection === 'function') {
return onToggleSection(event, name);
}
return setActiveNames(name);
} | 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 | handleToggleSection | javascript | nexxtway/react-rainbow | src/components/Accordion/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Accordion/index.js | MIT |
handleToggleSection = (event, name) => {
if (typeof onToggleSection === 'function') {
return onToggleSection(event, name);
}
return setActiveNames(name);
} | 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 | handleToggleSection | javascript | nexxtway/react-rainbow | src/components/Accordion/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Accordion/index.js | MIT |
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);
}
} | 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 | selectAccordionSection | javascript | nexxtway/react-rainbow | src/components/Accordion/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Accordion/index.js | MIT |
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);
}
} | 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 | selectAccordionSection | javascript | nexxtway/react-rainbow | src/components/Accordion/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Accordion/index.js | MIT |
handleKeyPressed = event => {
if (keyHandlerMap[event.keyCode]) {
event.preventDefault();
return keyHandlerMap[event.keyCode]();
}
return null;
} | 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 | handleKeyPressed | javascript | nexxtway/react-rainbow | src/components/Accordion/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Accordion/index.js | MIT |
handleKeyPressed = event => {
if (keyHandlerMap[event.keyCode]) {
event.preventDefault();
return keyHandlerMap[event.keyCode]();
}
return null;
} | 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 | handleKeyPressed | 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 |
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 |
resolveActiveNamesWhenMultiple = () => {
if (activeNames === undefined) {
return [currentName];
}
if (isInArray(activeNames, currentName)) {
return activeNames.filter(element => element !== currentName);
}
return [...activeNames, currentName];
} | An AccordionSection is single section that is nested in the Accordion component.
@category Layout | resolveActiveNamesWhenMultiple | javascript | nexxtway/react-rainbow | src/components/AccordionSection/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/index.js | MIT |
resolveActiveNamesWhenMultiple = () => {
if (activeNames === undefined) {
return [currentName];
}
if (isInArray(activeNames, currentName)) {
return activeNames.filter(element => element !== currentName);
}
return [...activeNames, currentName];
} | An AccordionSection is single section that is nested in the Accordion component.
@category Layout | resolveActiveNamesWhenMultiple | javascript | nexxtway/react-rainbow | src/components/AccordionSection/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/index.js | MIT |
resolveActiveNames = () => {
if (multiple) {
return resolveActiveNamesWhenMultiple();
}
if (currentName === activeNames) {
return '';
}
return currentName;
} | An AccordionSection is single section that is nested in the Accordion component.
@category Layout | resolveActiveNames | javascript | nexxtway/react-rainbow | src/components/AccordionSection/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/index.js | MIT |
resolveActiveNames = () => {
if (multiple) {
return resolveActiveNamesWhenMultiple();
}
if (currentName === activeNames) {
return '';
}
return currentName;
} | An AccordionSection is single section that is nested in the Accordion component.
@category Layout | resolveActiveNames | javascript | nexxtway/react-rainbow | src/components/AccordionSection/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/index.js | MIT |
handleToggleSection = event => {
if (!disabled) {
privateOnToggleSection(event, resolveActiveNames());
}
} | An AccordionSection is single section that is nested in the Accordion component.
@category Layout | handleToggleSection | javascript | nexxtway/react-rainbow | src/components/AccordionSection/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/index.js | MIT |
handleToggleSection = event => {
if (!disabled) {
privateOnToggleSection(event, resolveActiveNames());
}
} | An AccordionSection is single section that is nested in the Accordion component.
@category Layout | handleToggleSection | javascript | nexxtway/react-rainbow | src/components/AccordionSection/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/index.js | MIT |
handleFocusSection = () => {
if (!disabled) {
privateOnFocusSection(currentName);
}
} | An AccordionSection is single section that is nested in the Accordion component.
@category Layout | handleFocusSection | javascript | nexxtway/react-rainbow | src/components/AccordionSection/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/index.js | MIT |
handleFocusSection = () => {
if (!disabled) {
privateOnFocusSection(currentName);
}
} | An AccordionSection is single section that is nested in the Accordion component.
@category Layout | handleFocusSection | javascript | nexxtway/react-rainbow | src/components/AccordionSection/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/index.js | MIT |
handleKeyPressed = event => {
if (!disabled) {
privateOnKeyPressed(event);
}
} | An AccordionSection is single section that is nested in the Accordion component.
@category Layout | handleKeyPressed | javascript | nexxtway/react-rainbow | src/components/AccordionSection/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/index.js | MIT |
handleKeyPressed = event => {
if (!disabled) {
privateOnKeyPressed(event);
}
} | An AccordionSection is single section that is nested in the Accordion component.
@category Layout | handleKeyPressed | javascript | nexxtway/react-rainbow | src/components/AccordionSection/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/AccordionSection/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new AccordionSection page object.
@constructor
@param {string} rootElement - The selector of the AccordoinSection root element. | constructor | 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 |
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 |
get summary() {
return this.root.then(root => root.$('[data-id="accordion-section-summary"]'));
} | Create a new AccordionSection page object.
@constructor
@param {string} rootElement - The selector of the AccordoinSection root element. | summary | 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 |
get content() {
return this.root.then(root => root.$('[data-id="accordion-section-content"]'));
} | Create a new AccordionSection page object.
@constructor
@param {string} rootElement - The selector of the AccordoinSection root element. | content | 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 |
get label() {
return this.root.then(root => root.$('[data-id="accordion-section-label"]'));
} | Create a new AccordionSection page object.
@constructor
@param {string} rootElement - The selector of the AccordoinSection root element. | label | 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 |
get htmlElementRef() {
return this.buttonRef;
} | Returns the ref of the HTML button element.
@public | htmlElementRef | javascript | nexxtway/react-rainbow | src/components/Button/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Button/index.js | MIT |
isDisabled() {
const { disabled, isLoading } = this.props;
return disabled || isLoading;
} | Returns the ref of the HTML button element.
@public | isDisabled | javascript | nexxtway/react-rainbow | src/components/Button/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Button/index.js | MIT |
render() {
const {
style,
label,
children,
tabIndex,
onFocus,
onBlur,
onClick,
onMouseEnter,
onMouseLeave,
title,
type,
ariaHaspopup,
id,
isLoading,
variant,
shaded,
ariaPressed,
ariaControls,
ariaExpanded,
onKeyDown,
form,
className,
size,
borderRadius,
} = this.props;
return (
<StyledButton
data-id="button-element"
id={id}
className={className}
style={style}
variant={variant}
isLoading={isLoading}
shaded={shaded}
disabled={this.isDisabled()}
tabIndex={tabIndex}
onFocus={onFocus}
onBlur={onBlur}
onClick={onClick}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
title={title}
type={type}
aria-haspopup={ariaHaspopup}
aria-controls={ariaControls}
aria-expanded={ariaExpanded}
aria-pressed={ariaPressed}
onKeyDown={onKeyDown}
form={form}
ref={this.buttonRef}
size={size}
borderRadius={borderRadius}
>
<Content variant={variant} label={label} isLoading={isLoading} size={size}>
{children}
</Content>
</StyledButton>
);
} | Sets blur on the element.
@public | render | 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 |
getErrorMessageId() {
const { error } = this.props;
if (error) {
return this.errorMessageId;
}
return undefined;
} | ButtonGroupPicker can be used to group related options. The ButtonGroupPicker will control the selected state of its child ButtonOption.
@category Form | getErrorMessageId | javascript | nexxtway/react-rainbow | src/components/ButtonGroupPicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonGroupPicker/index.js | MIT |
getContext() {
const { multiple, size, value, variant } = this.props;
return {
onChange: this.handleOnChange,
values: value,
type: multiple ? 'checkbox' : 'radio',
name: this.groupNameId,
ariaDescribedBy: this.getErrorMessageId(),
size,
variant,
};
} | ButtonGroupPicker can be used to group related options. The ButtonGroupPicker will control the selected state of its child ButtonOption.
@category Form | getContext | javascript | nexxtway/react-rainbow | src/components/ButtonGroupPicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonGroupPicker/index.js | MIT |
handleOnChange(event) {
const { value: eventValue, checked } = event.target;
const { value, multiple, onChange } = this.props;
if (!multiple) {
return onChange(eventValue);
}
if (checked && Array.isArray(value)) {
return onChange(value.concat([eventValue]));
}
if (checked && !Array.isArray(value)) {
return onChange([eventValue]);
}
return onChange(value.filter(valueId => valueId !== eventValue));
} | ButtonGroupPicker can be used to group related options. The ButtonGroupPicker will control the selected state of its child ButtonOption.
@category Form | handleOnChange | javascript | nexxtway/react-rainbow | src/components/ButtonGroupPicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonGroupPicker/index.js | MIT |
render() {
const {
id,
className,
style,
label,
children,
error,
bottomHelpText,
required,
labelAlignment,
hideLabel,
variant,
borderRadius,
} = this.props;
const context = this.getContext();
return (
<StyledContainer
id={id}
className={className}
style={style}
borderRadius={borderRadius}
>
<RenderIf isTrue={label}>
<Label
label={label}
labelAlignment={labelAlignment}
hideLabel={hideLabel}
required={required}
as="legend"
/>
</RenderIf>
<StyledButtonGroup variant={variant} borderRadius={borderRadius}>
<Provider value={context}>{children}</Provider>
</StyledButtonGroup>
<RenderIf isTrue={bottomHelpText}>
<StyledHelpText>{bottomHelpText}</StyledHelpText>
</RenderIf>
<RenderIf isTrue={error}>
<StyledErrorText id={this.getErrorMessageId()}>{error}</StyledErrorText>
</RenderIf>
</StyledContainer>
);
} | ButtonGroupPicker can be used to group related options. The ButtonGroupPicker will control the selected state of its child ButtonOption.
@category Form | render | javascript | nexxtway/react-rainbow | src/components/ButtonGroupPicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonGroupPicker/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new ButtonGroupPicker page object.
@constructor
@param {string} rootElement - The selector of the ButtonGroupPicker root element. | constructor | 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 root() {
return $(this.rootElement);
} | Create a new ButtonGroupPicker page object.
@constructor
@param {string} rootElement - The selector of the ButtonGroupPicker root element. | root | 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 |
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 |
handleMouseEnter = event => {
onMouseEnter();
mouseEnterInProps(event);
} | @deprecated Backward compatibility only. Use `htmlElementRef` instead. | handleMouseEnter | javascript | nexxtway/react-rainbow | src/components/ButtonIcon/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonIcon/index.js | MIT |
handleMouseEnter = event => {
onMouseEnter();
mouseEnterInProps(event);
} | @deprecated Backward compatibility only. Use `htmlElementRef` instead. | handleMouseEnter | javascript | nexxtway/react-rainbow | src/components/ButtonIcon/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonIcon/index.js | MIT |
handleMouseLeave = event => {
onMouseLeave();
mouseLeaveInProps(event);
} | @deprecated Backward compatibility only. Use `htmlElementRef` instead. | handleMouseLeave | javascript | nexxtway/react-rainbow | src/components/ButtonIcon/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonIcon/index.js | MIT |
handleMouseLeave = event => {
onMouseLeave();
mouseLeaveInProps(event);
} | @deprecated Backward compatibility only. Use `htmlElementRef` instead. | handleMouseLeave | javascript | nexxtway/react-rainbow | src/components/ButtonIcon/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonIcon/index.js | MIT |
handleOnFocus = event => {
onFocus();
focusInProps(event);
} | @deprecated Backward compatibility only. Use `htmlElementRef` instead. | handleOnFocus | javascript | nexxtway/react-rainbow | src/components/ButtonIcon/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonIcon/index.js | MIT |
handleOnFocus = event => {
onFocus();
focusInProps(event);
} | @deprecated Backward compatibility only. Use `htmlElementRef` instead. | handleOnFocus | javascript | nexxtway/react-rainbow | src/components/ButtonIcon/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonIcon/index.js | MIT |
handleOnBlur = event => {
onBlur();
blurInProps(event);
} | @deprecated Backward compatibility only. Use `htmlElementRef` instead. | handleOnBlur | javascript | nexxtway/react-rainbow | src/components/ButtonIcon/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonIcon/index.js | MIT |
handleOnBlur = event => {
onBlur();
blurInProps(event);
} | @deprecated Backward compatibility only. Use `htmlElementRef` instead. | handleOnBlur | 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 |
async getItem(itemPosition) {
return this.primitiveMenu.getItem(itemPosition);
} | Returns a new MenuItem 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/ButtonMenu/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonMenu/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/ButtonMenu/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonMenu/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/ButtonMenu/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ButtonMenu/pageObject/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new ButtonOption page object.
@constructor
@param {string} rootElement - The selector of the Radio root element. | constructor | 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 |
get root() {
return $(this.rootElement);
} | Create a new ButtonOption page object.
@constructor
@param {string} rootElement - The selector of the Radio root element. | root | 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 |
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 |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new PageCalendar page object.
@constructor
@param {string} rootElement - The selector of the PageCalendar root element. | constructor | 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 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 isNextMonthButtonFocused() {
const buttonEl = (await $(this.rootElement).$$('button[data-id=button-icon-element]'))[1];
return (await buttonEl.isExisting()) && (await buttonEl.isFocused());
} | Returns true when the next month button element is disabled.
@method
@returns {bool} | isNextMonthButtonFocused | 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 isLeftMonthDayEnabled(day) {
const buttonEl = await $(this.rootElement)
.$$('table[role=grid]')[0]
.$(`button=${day}`);
return buttonEl.isExisting();
} | Returns true when the specific day element in left month is selected.
@method
@returns {string} | isLeftMonthDayEnabled | 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 getRightSelectedMonth() {
return $(this.rootElement)
.$$('h3[data-id=month]')[1]
.getText();
} | Returns the text of the selected left month element.
@method
@returns {string} | getRightSelectedMonth | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.