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 getRightMonthSelectedYear() {
return $(this.rootElement)
.$$('select')[1]
.getValue();
} | Returns the value of the left select year element.
@method
@returns {string} | getRightMonthSelectedYear | 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 getRightMonthSelectedDay() {
const day = await $(this.rootElement)
.$$('table[role=grid]')[1]
.$('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} | getRightMonthSelectedDay | 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 isRightMonthDayEnabled(day) {
const buttonEl = await $(this.rootElement)
.$$('table[role=grid]')[1]
.$(`button=${day}`);
return buttonEl.isExisting();
} | Returns true when the specific day element in right month is selected.
@method
@returns {string} | isRightMonthDayEnabled | 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 |
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/singleCalendar.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.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/singleCalendar.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.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/singleCalendar.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.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 isDayEnabled(day) {
const spanEl = await $(this.rootElement)
.$('table')
.$(`button=${day}`);
return spanEl.isExisting();
} | Returns true when the specific day element is selected.
@method
@returns {string} | isDayEnabled | 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 setYear(value) {
await $(this.rootElement)
.$('select')
.selectByVisibleText(value);
} | Set the value of the year select element
@method
@param {string} | setYear | 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 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/singleCalendar.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.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/singleCalendar.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Calendar/pageObject/singleCalendar.js | MIT |
async isPrevMonthButtonFocused() {
const buttonEl = (await $(this.rootElement).$$('button[data-id=button-icon-element]'))[0];
// eslint-disable-next-line no-return-await
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/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 |
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 |
handleSelect = childId => {
setActiveItem(childId);
setIsAnimationPaused(true);
} | A carouselCard allows multiple pieces of featured content to occupy an allocated amount of space. | handleSelect | javascript | nexxtway/react-rainbow | src/components/CarouselCard/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CarouselCard/index.js | MIT |
handleSelect = childId => {
setActiveItem(childId);
setIsAnimationPaused(true);
} | A carouselCard allows multiple pieces of featured content to occupy an allocated amount of space. | handleSelect | javascript | nexxtway/react-rainbow | src/components/CarouselCard/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CarouselCard/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new CarouselCard page object.
@constructor
@param {string} rootElement - The selector of the CarouselCard root element. | constructor | 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 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 |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new Indicator page object.
@constructor
@param {string} rootElement - The selector of the Indicator root element. | constructor | 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 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 |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new CarouselImage page object.
@constructor
@param {string} rootElement - The selector of the CarouselImage root element. | constructor | 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 |
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 |
updateChart() {
const { labels, type, ...conditions } = this.props;
this.chartInstance.config.type = type;
this.chartInstance.data.labels = labels;
this.chartInstance.data.datasets = Object.values(this.datasets);
this.chartInstance.options = resolveOptions({ type, ...conditions });
this.chartInstance.update();
} | 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 | updateChart | javascript | nexxtway/react-rainbow | src/components/Chart/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Chart/index.js | MIT |
registerDataset(id, dataset) {
this.datasets[id] = dataset;
this.updateChart();
} | 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 | registerDataset | javascript | nexxtway/react-rainbow | src/components/Chart/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Chart/index.js | MIT |
unregisterDataset(id) {
const { [id]: remove, ...rest } = this.datasets;
this.datasets = rest;
this.chartInstance.update();
} | 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 | unregisterDataset | javascript | nexxtway/react-rainbow | src/components/Chart/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Chart/index.js | MIT |
updateDataset(id, dataset) {
const keys = Object.keys(dataset);
keys.forEach(key => {
this.datasets[id][key] = dataset[key];
});
this.updateChart();
} | 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 | updateDataset | javascript | nexxtway/react-rainbow | src/components/Chart/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Chart/index.js | MIT |
renderChart() {
unregisterGlobalPlugins(ChartJS);
const { type, labels, plugins, ...conditions } = this.props;
const node = this.chartRef.current;
this.chartInstance = new ChartJS(node, {
type,
data: {
labels,
},
plugins: plugins || null,
options: resolveOptions({ type, plugins, ...conditions }),
});
} | 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 | renderChart | javascript | nexxtway/react-rainbow | src/components/Chart/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Chart/index.js | MIT |
render() {
const { style, className, children } = this.props;
const context = {
registerDataset: this.registerDataset,
unregisterDataset: this.unregisterDataset,
updateDataset: this.updateDataset,
};
return (
<ChartContext.Provider value={context}>
<StyledContainer className={className} style={style}>
<canvas ref={this.chartRef} />
<DatasetContainer>{children}</DatasetContainer>
</StyledContainer>
</ChartContext.Provider>
);
} | 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 | render | 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 |
getErrorMessageId() {
const { error } = this.props;
if (error) {
return this.errorMessageId;
}
return undefined;
} | A checkable input that communicates if an option is true, false or indeterminate.
@category Form | getErrorMessageId | javascript | nexxtway/react-rainbow | src/components/CheckboxGroup/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxGroup/index.js | MIT |
getValue() {
const { value } = this.props;
if (typeof value === 'string') {
return [];
}
return value;
} | A checkable input that communicates if an option is true, false or indeterminate.
@category Form | getValue | javascript | nexxtway/react-rainbow | src/components/CheckboxGroup/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxGroup/index.js | MIT |
handleOnChange(event) {
const { value, checked } = event.target;
const { value: values, onChange } = this.props;
if (checked && Array.isArray(values)) {
return onChange(values.concat([value]));
}
if (checked && !Array.isArray(values)) {
return onChange([value]);
}
return onChange(values.filter(valueId => valueId !== value));
} | A checkable input that communicates if an option is true, false or indeterminate.
@category Form | handleOnChange | javascript | nexxtway/react-rainbow | src/components/CheckboxGroup/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxGroup/index.js | MIT |
render() {
const {
id,
options,
required,
label,
labelAlignment,
hideLabel,
error,
style,
className,
orientation,
} = this.props;
return (
<StyledFieldset id={id} className={className} style={style}>
<RenderIf isTrue={label}>
<StyledLabel
label={label}
labelAlignment={labelAlignment}
hideLabel={hideLabel}
required={required}
forwardedAs="legend"
/>
</RenderIf>
<StyledContentContainer orientation={orientation}>
<CheckboxList
values={this.getValue()}
options={options}
onChange={this.handleOnChange}
name={this.groupNameId}
describedBy={this.getErrorMessageId()}
error={error}
/>
</StyledContentContainer>
<RenderIf isTrue={error}>
<StyledTextError id={this.getErrorMessageId()}>{error}</StyledTextError>
</RenderIf>
</StyledFieldset>
);
} | A checkable input that communicates if an option is true, false or indeterminate.
@category Form | render | javascript | nexxtway/react-rainbow | src/components/CheckboxGroup/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxGroup/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new Checkbox page object.
@constructor
@param {string} rootElement - The selector of the Checkbox root element. | constructor | javascript | nexxtway/react-rainbow | src/components/CheckboxGroup/pageObject/checkbox.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxGroup/pageObject/checkbox.js | MIT |
async hasFocus() {
return $(this.rootElement)
.$('input[type="checkbox"]')
.isFocused();
} | Returns true when the checkbox has the focus.
@method
@returns {bool} | hasFocus | javascript | nexxtway/react-rainbow | src/components/CheckboxGroup/pageObject/checkbox.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxGroup/pageObject/checkbox.js | MIT |
async isChecked() {
return $(this.rootElement)
.$('input[type="checkbox"]')
.isSelected();
} | Returns true when the checkbox is checked.
@method
@returns {bool} | isChecked | javascript | nexxtway/react-rainbow | src/components/CheckboxGroup/pageObject/checkbox.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxGroup/pageObject/checkbox.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new CheckboxGroup page object.
@constructor
@param {string} rootElement - The selector of the CheckboxGroup root element. | constructor | javascript | nexxtway/react-rainbow | src/components/CheckboxGroup/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxGroup/pageObject/index.js | MIT |
async getItem(itemPosition) {
const items = await $(this.rootElement).$$('[data-id="input-checkbox_container"]');
if (items[itemPosition]) {
return new PageCheckboxItem(
`${
this.rootElement
} [data-id="input-checkboxgroup_container"]:nth-child(${itemPosition + 1})`,
);
}
return null;
} | Returns a new Checkbox page object of the element in item position.
@method
@param {number} itemPosition - The base 0 index of the checkbox. | getItem | javascript | nexxtway/react-rainbow | src/components/CheckboxGroup/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxGroup/pageObject/index.js | MIT |
constructor(props) {
super(props);
this.checkboxToggleRef = React.createRef();
this.inputIndentifier = props.name || uniqueId('checkbox-toggle');
} | Checkbox toggle is a checkable input that communicates if an option is true,
false or indeterminate.
@category Form | constructor | javascript | nexxtway/react-rainbow | src/components/CheckboxToggle/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxToggle/index.js | MIT |
render() {
const {
style,
className,
disabled,
label,
value,
onChange,
onFocus,
onBlur,
onClick,
id,
labelAlignment,
} = this.props;
return (
<StyledLabelContainer
labelAlignment={labelAlignment}
id={id}
className={className}
style={style}
>
<HiddenElement
as="input"
type="checkbox"
name={this.inputIndentifier}
value={this.inputIndentifier}
aria-describedby={this.inputIndentifier}
checked={value}
onChange={onChange}
onFocus={onFocus}
onBlur={onBlur}
onClick={onClick}
disabled={disabled}
ref={this.checkboxToggleRef}
/>
<span
id={this.inputIndentifier}
className="rainbow-checkbox-toggle_faux-container"
aria-live="assertive"
>
<span className="rainbow-checkbox-toggle_faux" />
</span>
<RenderIf isTrue={label}>
<StyledLabel labelAlignment={labelAlignment}>{label}</StyledLabel>
</RenderIf>
</StyledLabelContainer>
);
} | Sets blur on the element.
@public | render | javascript | nexxtway/react-rainbow | src/components/CheckboxToggle/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxToggle/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new CheckboxToggle page object.
@constructor
@param {string} rootElement - The selector of the CheckboxToggle root element. | constructor | javascript | nexxtway/react-rainbow | src/components/CheckboxToggle/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxToggle/pageObject/index.js | MIT |
async isChecked() {
return !!(await $(this.rootElement)
.$('input')
.isSelected());
} | Returns true when the input element is checked.
@method
@returns {bool} | isChecked | javascript | nexxtway/react-rainbow | src/components/CheckboxToggle/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CheckboxToggle/pageObject/index.js | MIT |
function Chip(props) {
const { label, onDelete, variant, title, className, style, size, borderRadius } = props;
const sizeButton = sizesMap[size] || sizesMap.medium;
return (
<StyledContainer
className={className}
style={style}
variant={variant}
title={title}
size={size}
borderRadius={borderRadius}
>
<TruncatedText>{label}</TruncatedText>
<RenderIf isTrue={onDelete}>
<StyledButtonIcon
variant={variant}
icon={<CloseIcon />}
size={sizeButton}
title="Close"
onClick={onDelete}
assistiveText="Remove"
/>
</RenderIf>
</StyledContainer>
);
} | A Chip displays a label that can be removed from view. | Chip | javascript | nexxtway/react-rainbow | src/components/Chip/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Chip/index.js | MIT |
handleOnChange = (inputValue, index) => {
const newValue = getNormalizedValue(inputValue, index, value);
const hasValueChanged = newValue !== valueProp;
if (hasValueChanged) {
onChange(newValue);
}
} | The CodeInput is an element that allows to fill a list of numbers, suitable for code validations.
@category Form | handleOnChange | javascript | nexxtway/react-rainbow | src/components/CodeInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/index.js | MIT |
handleOnChange = (inputValue, index) => {
const newValue = getNormalizedValue(inputValue, index, value);
const hasValueChanged = newValue !== valueProp;
if (hasValueChanged) {
onChange(newValue);
}
} | The CodeInput is an element that allows to fill a list of numbers, suitable for code validations.
@category Form | handleOnChange | javascript | nexxtway/react-rainbow | src/components/CodeInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/index.js | MIT |
handleOnFocus = (event, index) => {
if (focusedIndex !== index) {
setFocus(inputRef);
}
onFocus(event);
} | The CodeInput is an element that allows to fill a list of numbers, suitable for code validations.
@category Form | handleOnFocus | javascript | nexxtway/react-rainbow | src/components/CodeInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/index.js | MIT |
handleOnFocus = (event, index) => {
if (focusedIndex !== index) {
setFocus(inputRef);
}
onFocus(event);
} | The CodeInput is an element that allows to fill a list of numbers, suitable for code validations.
@category Form | handleOnFocus | javascript | nexxtway/react-rainbow | src/components/CodeInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new PageCodeInput page object.
@constructor
@param {string} rootElement - The selector of the PageCodeInput root element. | constructor | javascript | nexxtway/react-rainbow | src/components/CodeInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/pageObject/index.js | MIT |
async type(key) {
const focusedInput = await this.getFocusedInput();
if (focusedInput) {
await focusedInput.setValue(key);
}
} | Create a new PageCodeInput page object.
@constructor
@param {string} rootElement - The selector of the PageCodeInput root element. | type | javascript | nexxtway/react-rainbow | src/components/CodeInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/pageObject/index.js | MIT |
async click() {
const focusedInput = await this.getFocusedInput();
if (focusedInput) {
await focusedInput.click();
}
} | Triggers a click over the focused input
@method
@param {string} inputIndex - The index of the input | click | javascript | nexxtway/react-rainbow | src/components/CodeInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/pageObject/index.js | MIT |
async clickInputAtIndex(inputIndex) {
const input = await this.getInputAtIndex(inputIndex);
if (input) {
await input.click();
}
} | Triggers a click over the input via their index (position in the input array)
@method
@param {string} inputIndex - The index of the input | clickInputAtIndex | javascript | nexxtway/react-rainbow | src/components/CodeInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/pageObject/index.js | MIT |
async getFocusedIndex() {
const focusedInput = await this.getFocusedInput();
if (focusedInput) {
return focusedInput.index;
}
return undefined;
} | Returns the index of the current input focused or -1 if not found any
@method | getFocusedIndex | javascript | nexxtway/react-rainbow | src/components/CodeInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/pageObject/index.js | MIT |
async getFocusedValue() {
const focusedInput = await this.getFocusedInput();
if (focusedInput) {
return focusedInput.getValue();
}
return undefined;
} | Returns the value of the current input focused or -1 if not found any
@method | getFocusedValue | javascript | nexxtway/react-rainbow | src/components/CodeInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/pageObject/index.js | MIT |
async getInputValueAtIndex(inputIndex) {
const input = await this.getInputAtIndex(inputIndex);
if (input) {
return input.getValue();
}
return undefined;
} | Returns the value of the input via their index (position in the input array)
@method
@param {string} inputIndex - The index of the input | getInputValueAtIndex | javascript | nexxtway/react-rainbow | src/components/CodeInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/pageObject/index.js | MIT |
async getFocusedInput() {
const inputs = await $(this.rootElement).$$('input');
const focusedInputs = await Promise.all(inputs.map(async input => input.isFocused()));
return inputs.find((input, index) => focusedInputs[index]);
} | Returns the value of the input via their index (position in the input array)
@method
@param {string} inputIndex - The index of the input | getFocusedInput | javascript | nexxtway/react-rainbow | src/components/CodeInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/pageObject/index.js | MIT |
async getInputAtIndex(inputIndex) {
const input = (await $(this.rootElement).$$('input'))[inputIndex];
if (input) {
return input;
}
return undefined;
} | Returns the value of the input via their index (position in the input array)
@method
@param {string} inputIndex - The index of the input | getInputAtIndex | javascript | nexxtway/react-rainbow | src/components/CodeInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/CodeInput/pageObject/index.js | MIT |
ColorInput = props => {
const {
id,
className,
style,
value,
onChange,
defaultColors,
variant,
onClick,
label,
labelAlignment,
hideLabel,
required,
readOnly,
disabled,
error,
tabIndex,
name,
placeholder,
bottomHelpText,
onFocus: focusInProps,
onBlur: blurInProps,
size,
borderRadius,
} = useReduxForm(props);
const [isOpen, setIsOpen] = useState(false);
const [colorValue, setColorValue] = useState(getColorValue(value));
const [sampleColor, setSampleColor] = useState(value);
const pickerRef = useRef();
const containerRef = useRef();
const triggerRef = useRef();
const alphaInputRef = useRef();
const inputRef = useRef();
const inputId = useUniqueIdentifier('color-input');
const errorMessageId = useErrorMessageId(error);
const labelId = useLabelId(label);
const [focusIndex, setFocusIndex] = useFocusIndex(
containerRef,
triggerRef,
inputRef,
alphaInputRef,
);
useOutsideClick(
containerRef,
() => {
setFocusIndex(-1);
},
focusIndex > -1,
);
useOutsideClick(
pickerRef,
event => {
if (
event.target !== triggerRef.current &&
!triggerRef.current.contains(event.target) &&
!pickerRef.current.contains(event.target)
) {
setIsOpen(false);
}
},
isOpen,
);
useScrollingIntent({
callback: () => setIsOpen(false),
isListening: isOpen,
triggerElementRef: () => triggerRef,
threshold: 5,
});
useWindowResize(() => setIsOpen(false), isOpen);
const onBlur = useCallback(() => {
const { hex } = value;
if (!isHexColor(hex)) setSampleColor(undefined);
blurInProps(value);
}, [value, blurInProps]);
const onFocus = useCallback(() => focusInProps(value), [value, focusInProps]);
const handleFocus = useHandleFocus({ focusIndex, onFocus, setFocusIndex, value });
const handleBlur = useHandleBlur({ focusIndex, onBlur, value });
const handleClick = event => {
if (focusIndex === 1) {
setFocusIndex(0);
} else {
setFocusIndex(1);
}
event.preventDefault();
if (isOpen) setIsOpen(false);
else setIsOpen(true);
return onClick(event);
};
const handleChange = event => {
const eventValue = event.target.value;
const { alpha } = value;
const hex = getHexString(eventValue);
const isValid = isHexColor(hex);
const newValue = { hex, alpha, isValid };
if (isValid) {
setSampleColor(newValue);
setColorValue(getColorValue(newValue));
}
onChange(newValue);
};
const handleAlphaChange = event => {
if (!event.target.value) {
onChange({ ...value, alpha: null });
return;
}
let alpha = Number.parseInt(event.target.value || '0', 10);
if (alpha > 100) alpha = 100;
else if (alpha < 0) alpha = 0;
alpha /= 100;
const newValue = { ...value, alpha };
setSampleColor(newValue);
setColorValue(getColorValue(newValue));
if (!Number.isNaN(alpha)) onChange(newValue);
};
const handleColorChange = color => {
const { hex, rgba } = color;
const newValue = { hex, alpha: rgba[3], isValid: isHexColor(hex) };
setColorValue(color);
setSampleColor(newValue);
onChange(newValue);
};
const isFocus = focusIndex > -1 || isOpen;
const inputValue =
(value && value.hex) || value.hex === '' ? value.hex.replace('#', '') : '000000';
const alphaValue =
(value && value.alpha) || value.alpha === 0 ? Math.round(value.alpha * 100) : '';
return (
<StyledContainer id={id} className={className} style={style} ref={containerRef}>
<Label
label={label}
labelAlignment={labelAlignment}
hideLabel={hideLabel}
required={required}
inputId={inputId}
readOnly={readOnly}
id={labelId}
size={size}
/>
<StyledInputContainer
disabled={disabled}
readOnly={readOnly}
error={error}
isFocus={isFocus}
borderRadius={borderRadius}
size={size}
>
<StyledTrigger
ref={triggerRef}
onClick={handleClick}
onFocus={event => handleFocus(event, 0)}
onBlur={handleBlur}
tabIndex={tabIndex}
disabled={disabled}
type="button"
>
<StyledFlagContainer disabled={disabled}>
<ColorSample value={sampleColor} size={size} />
<StyledIndicator error={error} disabled={disabled} />
</StyledFlagContainer>
<AssistiveText text="pick color" />
</StyledTrigger>
<ColorInputContainer>
<StyledIconContainer>#</StyledIconContainer>
<StyledInput
id={inputId}
ref={inputRef}
name={name}
type="text"
value={inputValue}
placeholder={placeholder}
tabIndex={tabIndex}
onFocus={event => handleFocus(event, 2)}
onBlur={handleBlur}
onClick={onClick}
onChange={handleChange}
disabled={disabled}
readOnly={readOnly}
required={required}
aria-labelledby={labelId}
aria-describedby={errorMessageId}
error={error}
isFocus={isFocus}
size={size}
/>
</ColorInputContainer>
<StyledAlpha disabled={disabled}>
<StyledAlphaInput
type="number"
min="0"
max="100"
ref={alphaInputRef}
onFocus={event => handleFocus(event, 3)}
onBlur={handleBlur}
onChange={handleAlphaChange}
value={alphaValue}
size={size}
/>
%
</StyledAlpha>
</StyledInputContainer>
<RenderIf isTrue={bottomHelpText}>
<HelpText alignSelf="center">{bottomHelpText}</HelpText>
</RenderIf>
<RenderIf isTrue={error}>
<ErrorText alignSelf="center" id={errorMessageId}>
{error}
</ErrorText>
</RenderIf>
<InternalOverlay isVisible={isOpen} triggerElementRef={() => triggerRef}>
<div ref={pickerRef}>
<StyledCard borderRadius={borderRadius}>
<StyledContent>
<ColorPicker
value={colorValue}
defaultColors={defaultColors}
variant={variant}
onChange={handleColorChange}
/>
</StyledContent>
</StyledCard>
</div>
</InternalOverlay>
</StyledContainer>
);
} | Provides a color input with an improved color picker.
@category Form | ColorInput | javascript | nexxtway/react-rainbow | src/components/ColorInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorInput/index.js | MIT |
ColorInput = props => {
const {
id,
className,
style,
value,
onChange,
defaultColors,
variant,
onClick,
label,
labelAlignment,
hideLabel,
required,
readOnly,
disabled,
error,
tabIndex,
name,
placeholder,
bottomHelpText,
onFocus: focusInProps,
onBlur: blurInProps,
size,
borderRadius,
} = useReduxForm(props);
const [isOpen, setIsOpen] = useState(false);
const [colorValue, setColorValue] = useState(getColorValue(value));
const [sampleColor, setSampleColor] = useState(value);
const pickerRef = useRef();
const containerRef = useRef();
const triggerRef = useRef();
const alphaInputRef = useRef();
const inputRef = useRef();
const inputId = useUniqueIdentifier('color-input');
const errorMessageId = useErrorMessageId(error);
const labelId = useLabelId(label);
const [focusIndex, setFocusIndex] = useFocusIndex(
containerRef,
triggerRef,
inputRef,
alphaInputRef,
);
useOutsideClick(
containerRef,
() => {
setFocusIndex(-1);
},
focusIndex > -1,
);
useOutsideClick(
pickerRef,
event => {
if (
event.target !== triggerRef.current &&
!triggerRef.current.contains(event.target) &&
!pickerRef.current.contains(event.target)
) {
setIsOpen(false);
}
},
isOpen,
);
useScrollingIntent({
callback: () => setIsOpen(false),
isListening: isOpen,
triggerElementRef: () => triggerRef,
threshold: 5,
});
useWindowResize(() => setIsOpen(false), isOpen);
const onBlur = useCallback(() => {
const { hex } = value;
if (!isHexColor(hex)) setSampleColor(undefined);
blurInProps(value);
}, [value, blurInProps]);
const onFocus = useCallback(() => focusInProps(value), [value, focusInProps]);
const handleFocus = useHandleFocus({ focusIndex, onFocus, setFocusIndex, value });
const handleBlur = useHandleBlur({ focusIndex, onBlur, value });
const handleClick = event => {
if (focusIndex === 1) {
setFocusIndex(0);
} else {
setFocusIndex(1);
}
event.preventDefault();
if (isOpen) setIsOpen(false);
else setIsOpen(true);
return onClick(event);
};
const handleChange = event => {
const eventValue = event.target.value;
const { alpha } = value;
const hex = getHexString(eventValue);
const isValid = isHexColor(hex);
const newValue = { hex, alpha, isValid };
if (isValid) {
setSampleColor(newValue);
setColorValue(getColorValue(newValue));
}
onChange(newValue);
};
const handleAlphaChange = event => {
if (!event.target.value) {
onChange({ ...value, alpha: null });
return;
}
let alpha = Number.parseInt(event.target.value || '0', 10);
if (alpha > 100) alpha = 100;
else if (alpha < 0) alpha = 0;
alpha /= 100;
const newValue = { ...value, alpha };
setSampleColor(newValue);
setColorValue(getColorValue(newValue));
if (!Number.isNaN(alpha)) onChange(newValue);
};
const handleColorChange = color => {
const { hex, rgba } = color;
const newValue = { hex, alpha: rgba[3], isValid: isHexColor(hex) };
setColorValue(color);
setSampleColor(newValue);
onChange(newValue);
};
const isFocus = focusIndex > -1 || isOpen;
const inputValue =
(value && value.hex) || value.hex === '' ? value.hex.replace('#', '') : '000000';
const alphaValue =
(value && value.alpha) || value.alpha === 0 ? Math.round(value.alpha * 100) : '';
return (
<StyledContainer id={id} className={className} style={style} ref={containerRef}>
<Label
label={label}
labelAlignment={labelAlignment}
hideLabel={hideLabel}
required={required}
inputId={inputId}
readOnly={readOnly}
id={labelId}
size={size}
/>
<StyledInputContainer
disabled={disabled}
readOnly={readOnly}
error={error}
isFocus={isFocus}
borderRadius={borderRadius}
size={size}
>
<StyledTrigger
ref={triggerRef}
onClick={handleClick}
onFocus={event => handleFocus(event, 0)}
onBlur={handleBlur}
tabIndex={tabIndex}
disabled={disabled}
type="button"
>
<StyledFlagContainer disabled={disabled}>
<ColorSample value={sampleColor} size={size} />
<StyledIndicator error={error} disabled={disabled} />
</StyledFlagContainer>
<AssistiveText text="pick color" />
</StyledTrigger>
<ColorInputContainer>
<StyledIconContainer>#</StyledIconContainer>
<StyledInput
id={inputId}
ref={inputRef}
name={name}
type="text"
value={inputValue}
placeholder={placeholder}
tabIndex={tabIndex}
onFocus={event => handleFocus(event, 2)}
onBlur={handleBlur}
onClick={onClick}
onChange={handleChange}
disabled={disabled}
readOnly={readOnly}
required={required}
aria-labelledby={labelId}
aria-describedby={errorMessageId}
error={error}
isFocus={isFocus}
size={size}
/>
</ColorInputContainer>
<StyledAlpha disabled={disabled}>
<StyledAlphaInput
type="number"
min="0"
max="100"
ref={alphaInputRef}
onFocus={event => handleFocus(event, 3)}
onBlur={handleBlur}
onChange={handleAlphaChange}
value={alphaValue}
size={size}
/>
%
</StyledAlpha>
</StyledInputContainer>
<RenderIf isTrue={bottomHelpText}>
<HelpText alignSelf="center">{bottomHelpText}</HelpText>
</RenderIf>
<RenderIf isTrue={error}>
<ErrorText alignSelf="center" id={errorMessageId}>
{error}
</ErrorText>
</RenderIf>
<InternalOverlay isVisible={isOpen} triggerElementRef={() => triggerRef}>
<div ref={pickerRef}>
<StyledCard borderRadius={borderRadius}>
<StyledContent>
<ColorPicker
value={colorValue}
defaultColors={defaultColors}
variant={variant}
onChange={handleColorChange}
/>
</StyledContent>
</StyledCard>
</div>
</InternalOverlay>
</StyledContainer>
);
} | Provides a color input with an improved color picker.
@category Form | ColorInput | javascript | nexxtway/react-rainbow | src/components/ColorInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorInput/index.js | MIT |
handleClick = event => {
if (focusIndex === 1) {
setFocusIndex(0);
} else {
setFocusIndex(1);
}
event.preventDefault();
if (isOpen) setIsOpen(false);
else setIsOpen(true);
return onClick(event);
} | Provides a color input with an improved color picker.
@category Form | handleClick | javascript | nexxtway/react-rainbow | src/components/ColorInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorInput/index.js | MIT |
handleClick = event => {
if (focusIndex === 1) {
setFocusIndex(0);
} else {
setFocusIndex(1);
}
event.preventDefault();
if (isOpen) setIsOpen(false);
else setIsOpen(true);
return onClick(event);
} | Provides a color input with an improved color picker.
@category Form | handleClick | javascript | nexxtway/react-rainbow | src/components/ColorInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorInput/index.js | MIT |
handleChange = event => {
const eventValue = event.target.value;
const { alpha } = value;
const hex = getHexString(eventValue);
const isValid = isHexColor(hex);
const newValue = { hex, alpha, isValid };
if (isValid) {
setSampleColor(newValue);
setColorValue(getColorValue(newValue));
}
onChange(newValue);
} | Provides a color input with an improved color picker.
@category Form | handleChange | javascript | nexxtway/react-rainbow | src/components/ColorInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorInput/index.js | MIT |
handleChange = event => {
const eventValue = event.target.value;
const { alpha } = value;
const hex = getHexString(eventValue);
const isValid = isHexColor(hex);
const newValue = { hex, alpha, isValid };
if (isValid) {
setSampleColor(newValue);
setColorValue(getColorValue(newValue));
}
onChange(newValue);
} | Provides a color input with an improved color picker.
@category Form | handleChange | javascript | nexxtway/react-rainbow | src/components/ColorInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorInput/index.js | MIT |
handleAlphaChange = event => {
if (!event.target.value) {
onChange({ ...value, alpha: null });
return;
}
let alpha = Number.parseInt(event.target.value || '0', 10);
if (alpha > 100) alpha = 100;
else if (alpha < 0) alpha = 0;
alpha /= 100;
const newValue = { ...value, alpha };
setSampleColor(newValue);
setColorValue(getColorValue(newValue));
if (!Number.isNaN(alpha)) onChange(newValue);
} | Provides a color input with an improved color picker.
@category Form | handleAlphaChange | javascript | nexxtway/react-rainbow | src/components/ColorInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorInput/index.js | MIT |
handleAlphaChange = event => {
if (!event.target.value) {
onChange({ ...value, alpha: null });
return;
}
let alpha = Number.parseInt(event.target.value || '0', 10);
if (alpha > 100) alpha = 100;
else if (alpha < 0) alpha = 0;
alpha /= 100;
const newValue = { ...value, alpha };
setSampleColor(newValue);
setColorValue(getColorValue(newValue));
if (!Number.isNaN(alpha)) onChange(newValue);
} | Provides a color input with an improved color picker.
@category Form | handleAlphaChange | javascript | nexxtway/react-rainbow | src/components/ColorInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorInput/index.js | MIT |
handleColorChange = color => {
const { hex, rgba } = color;
const newValue = { hex, alpha: rgba[3], isValid: isHexColor(hex) };
setColorValue(color);
setSampleColor(newValue);
onChange(newValue);
} | Provides a color input with an improved color picker.
@category Form | handleColorChange | javascript | nexxtway/react-rainbow | src/components/ColorInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorInput/index.js | MIT |
handleColorChange = color => {
const { hex, rgba } = color;
const newValue = { hex, alpha: rgba[3], isValid: isHexColor(hex) };
setColorValue(color);
setSampleColor(newValue);
onChange(newValue);
} | Provides a color input with an improved color picker.
@category Form | handleColorChange | javascript | nexxtway/react-rainbow | src/components/ColorInput/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorInput/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new PageColorPicker page object.
@constructor
@param {string} rootElement - The selector of the PageColorPicker root element. | constructor | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async getSaturationPointer() {
return $(this.rootElement).$('button');
} | Return the saturation pointer button element.
@method
@returns {object} | getSaturationPointer | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async clickSaturation() {
await (await this.getSaturationPointer()).click();
} | Triggers a click over the saturation pointer button element.
@method | clickSaturation | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async getHueInput() {
return $(this.rootElement).$('input[type=range]');
} | Return the hue input element.
@method
@returns {object} | getHueInput | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async clickHue() {
await (await this.getHueInput()).click();
} | Triggers a click over the hue input element.
@method | clickHue | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async getHexInput() {
return $(this.rootElement).$('input[type=text]');
} | Return the hex input element.
@method
@returns {object} | getHexInput | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async getRgbaInput(index) {
return (await $(this.rootElement).$$('input[type=number]'))[index];
} | Return the rgba input element for index.
@method
@param {number} index
@returns {object} | getRgbaInput | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async getDefaultColorsInput() {
return $(this.rootElement).$('input[type=radio]');
} | Return the default colors input element.
@method
@returns {object} | getDefaultColorsInput | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async getDefaultColorsLabel() {
const id = await (await this.getDefaultColorsInput()).getAttribute('id');
return $(this.rootElement).$(`label[for="${id}"]`);
} | Returns the default colors label element.
@method
@returns {object} | getDefaultColorsLabel | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async clickDefaultColors() {
await (await this.getDefaultColorsLabel()).click();
} | Triggers a click over the default colors label element.
@method | clickDefaultColors | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async getColor() {
return (await this.getHexInput()).getValue();
} | Return hex color from hex input.
@method
@returns {string} | getColor | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async getAlpha() {
return (await this.getRgbaInput(3)).getValue();
} | Return hex color from hex input.
@method
@returns {string} | getAlpha | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async isSaturationFocused() {
const buttonEl = await this.getSaturationPointer();
return (await buttonEl.isExisting()) && (await buttonEl.isFocused());
} | Returns true when the saturation pointer button element has focus.
@method
@returns {bool} | isSaturationFocused | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async isHueFocused() {
const rangeEl = await this.getHueInput();
return (await rangeEl.isExisting()) && (await rangeEl.isFocused());
} | Returns true when the hue input element has focus.
@method
@returns {bool} | isHueFocused | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async isAlphaFocused() {
const rangeEl = (await $(this.rootElement).$$('input[type=range]'))[1];
return (await rangeEl.isExisting()) && (await rangeEl.isFocused());
} | Returns true when the alpha input element has focus.
@method
@returns {bool} | isAlphaFocused | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async isHexFocused() {
const inputEl = await this.getHexInput();
return (await inputEl.isExisting()) && (await inputEl.isFocused());
} | Returns true when the hex input element has focus.
@method
@returns {bool} | isHexFocused | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async isRgbaFocused(index = 0) {
const inputEl = await this.getRgbaInput(index);
return (await inputEl.isExisting()) && (await inputEl.isFocused());
} | Returns true when the rgba input element has focus.
@method
* @param {number} index
@returns {bool} | isRgbaFocused | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
async isDefaultColorsFocused() {
const inputEl = await this.getDefaultColorsInput();
return (await inputEl.isExisting()) && (await inputEl.isFocused());
} | Returns true when the default colors input element has focus.
@method
@returns {bool} | isDefaultColorsFocused | javascript | nexxtway/react-rainbow | src/components/ColorPicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ColorPicker/pageObject/index.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.