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 |
---|---|---|---|---|---|---|---|
ShowIf = ({ id, className, style, isTrue, inAnimation, outAnimation, children }) => {
const [animation, setAnimation] = useState();
const [isVisible, setIsVisible] = useState(isTrue);
const [dimensions, setDimensions] = useState();
const ref = useRef();
useLayoutEffect(() => {
if (isTrue) {
const rect = getElementBoundingClientRect(ref.current);
setDimensions(rect);
setIsVisible(true);
setAnimation(`${inAnimation}In`);
} else {
setAnimation(`${outAnimation}Out`);
}
}, [isTrue, inAnimation, outAnimation]);
const handleAnimationEnd = event => {
if (event.animationName.includes('Out')) {
setIsVisible(false);
}
};
return (
<AnimatedContainer
id={id}
className={className}
style={style}
animation={animation}
isVisible={isVisible}
dimensions={dimensions}
onAnimationEnd={handleAnimationEnd}
ref={ref}
>
{children}
</AnimatedContainer>
);
} | A component that shows its contents when a condition is met. Works similar to `RenderIf`,
but `ShowIf` does not remove the elements from the DOM, and animates the content in and out. | ShowIf | javascript | nexxtway/react-rainbow | src/components/ShowIf/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ShowIf/index.js | MIT |
handleAnimationEnd = event => {
if (event.animationName.includes('Out')) {
setIsVisible(false);
}
} | A component that shows its contents when a condition is met. Works similar to `RenderIf`,
but `ShowIf` does not remove the elements from the DOM, and animates the content in and out. | handleAnimationEnd | javascript | nexxtway/react-rainbow | src/components/ShowIf/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ShowIf/index.js | MIT |
handleAnimationEnd = event => {
if (event.animationName.includes('Out')) {
setIsVisible(false);
}
} | A component that shows its contents when a condition is met. Works similar to `RenderIf`,
but `ShowIf` does not remove the elements from the DOM, and animates the content in and out. | handleAnimationEnd | javascript | nexxtway/react-rainbow | src/components/ShowIf/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/ShowIf/index.js | MIT |
function Sidebar(props) {
const {
ariaLabel,
style,
selectedItem,
onSelect,
className,
children,
id,
hideSelectedItemIndicator,
} = props;
const context = {
selectedItem,
onSelect,
hideSelectedItemIndicator,
};
return (
<StyledNav id={id} className={className} style={style} aria-label={ariaLabel}>
<Provider value={context}>
<StyledUl>{children}</StyledUl>
</Provider>
</StyledNav>
);
} | The Sidebar component is a vertical bar that holds a list of SidebarItems.
It helps users to jump from one site section to another without re-rendering the entire content on the page.
Note that you have to compose the Sidebar with the SidebarItem component.
@category Layout | Sidebar | javascript | nexxtway/react-rainbow | src/components/Sidebar/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Sidebar/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new Sidebar page object
@constructor
@param {string} rootElement - The selector if the Sidebar root element. | constructor | javascript | nexxtway/react-rainbow | src/components/Sidebar/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Sidebar/pageObject/index.js | MIT |
async getItem(itemPosition) {
const items = await $(this.rootElement).$$('li[data-id="sidebar-item-li"]');
if (items[itemPosition]) {
return new PageSidebarItem(
`${this.rootElement} li[data-id="sidebar-item-li"]:nth-child(${itemPosition + 1})`,
);
}
return null;
} | Return a new SidebarItem page object of the element in item position.
@method
@param {number} itemPosition - The base 0 index of the sidebar item | getItem | javascript | nexxtway/react-rainbow | src/components/Sidebar/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Sidebar/pageObject/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new SidebarItem page object.
@constructor
@param {string} rootElement - The selector of the SidebarItem root element. | constructor | javascript | nexxtway/react-rainbow | src/components/SidebarItem/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/SidebarItem/pageObject/index.js | MIT |
async isActive() {
return $(this.rootElement)
.$('[aria-current="page"]')
.isExisting();
} | Return true when the sidebar item is active
@method
@returns {bool} | isActive | javascript | nexxtway/react-rainbow | src/components/SidebarItem/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/SidebarItem/pageObject/index.js | MIT |
constructor(props) {
super(props);
this.sliderId = uniqueId('slider-id');
this.errorMessageId = uniqueId('error-message');
this.sliderRef = React.createRef();
} | An input range slider lets the user specify a numeric value which must be between
two specified values.
@category Form | constructor | javascript | nexxtway/react-rainbow | src/components/Slider/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Slider/index.js | MIT |
getAriaDescribedBy() {
const { error } = this.props;
if (error) {
return this.errorMessageId;
}
return undefined;
} | An input range slider lets the user specify a numeric value which must be between
two specified values.
@category Form | getAriaDescribedBy | javascript | nexxtway/react-rainbow | src/components/Slider/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Slider/index.js | MIT |
render() {
const {
label,
value,
name,
min,
max,
step,
error,
disabled,
onBlur,
onChange,
onClick,
onFocus,
style,
className,
labelAlignment,
hideLabel,
required,
} = this.props;
const valueWidth = Math.max(`${max}`.length, `${min}`.length) + 1;
return (
<StyledContainer className={className} style={style}>
<RenderIf isTrue={label}>
<StyledLabel
label={label}
labelAlignment={labelAlignment}
hideLabel={hideLabel}
inputId={this.sliderId}
required={required}
/>
</RenderIf>
<StyledSlider>
<StyledInputRange
id={this.sliderId}
type="range"
name={name}
value={value}
min={min}
max={max}
step={step}
aria-describedby={this.getAriaDescribedBy()}
disabled={disabled}
required={required}
onClick={onClick}
onChange={onChange}
onBlur={onBlur}
onFocus={onFocus}
ref={this.sliderRef}
/>
<StyledValue width={valueWidth} aria-hidden>
{value}
</StyledValue>
</StyledSlider>
<RenderIf isTrue={error}>
<ErrorText id={this.errorMessageId}>{error}</ErrorText>
</RenderIf>
</StyledContainer>
);
} | Sets blur on the element.
@public | render | javascript | nexxtway/react-rainbow | src/components/Slider/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Slider/index.js | MIT |
function Spinner(props) {
const { className, style, assistiveText, isVisible, size, variant, type, children } = props;
const currentSize = getSizeValue(size);
if (isVisible) {
if (type === 'arc') {
return (
<StyledSpinnerContainer className={className} style={style}>
<StyledArcSpinner
viewBox={`${0} ${0} ${currentSize} ${currentSize}`}
size={size}
variant={variant}
>
<circle
className="path"
cx={currentSize / 2}
cy={currentSize / 2}
r={(currentSize - 3) / 2}
fill="none"
strokeWidth="3"
/>
</StyledArcSpinner>
<StyledChildContainer>{children}</StyledChildContainer>
<AssistiveText text={assistiveText} />
</StyledSpinnerContainer>
);
}
return (
<StyledCircleSpinner className={className} size={size} variant={variant} style={style}>
<div />
<div />
<div />
<div />
<div />
<div />
<div />
<div />
<StyledChildContainer>{children}</StyledChildContainer>
<AssistiveText text={assistiveText} />
</StyledCircleSpinner>
);
}
return null;
} | Spinners should be shown when retrieving data or performing slow,
help to reassure the user that the system is actively retrieving data. | Spinner | javascript | nexxtway/react-rainbow | src/components/Spinner/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Spinner/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new StrongPasswordInput page object.
@constructor
@param {string} rootElement - The selector of the StrongPasswordInput root element. | constructor | javascript | nexxtway/react-rainbow | src/components/StrongPasswordInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/StrongPasswordInput/pageObject/index.js | MIT |
async hasFocusInput() {
return $(this.rootElement)
.$('input')
.isFocused();
} | Returns true when the input element has focus.
@method
@returns {bool} | hasFocusInput | javascript | nexxtway/react-rainbow | src/components/StrongPasswordInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/StrongPasswordInput/pageObject/index.js | MIT |
async setValue(value) {
await $(this.rootElement)
.$('input')
.setValue(value);
} | Type in the input element.
@method
@param {string} value - The value to type in the input element. | setValue | javascript | nexxtway/react-rainbow | src/components/StrongPasswordInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/StrongPasswordInput/pageObject/index.js | MIT |
async getValue() {
return $(this.rootElement)
.$('input')
.getValue();
} | Get the value typed in the input element.
@method
@returns {string} | getValue | javascript | nexxtway/react-rainbow | src/components/StrongPasswordInput/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/StrongPasswordInput/pageObject/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new Tab page object.
@constructor
@param {string} rootElement - The selector of the Tab root element. | constructor | javascript | nexxtway/react-rainbow | src/components/Tab/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tab/pageObject/index.js | MIT |
async hasFocus() {
return $(this.rootElement)
.$('button[role="tab"]')
.isFocused();
} | Returns true when the tab item has focus.
@method
@returns {bool} | hasFocus | javascript | nexxtway/react-rainbow | src/components/Tab/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tab/pageObject/index.js | MIT |
async isSelected() {
return !!(await $(this.rootElement)
.$('button[role="tab"]')
.getAttribute('data-active'));
} | Returns true when the tab item is selected.
@method
@returns {bool} | isSelected | javascript | nexxtway/react-rainbow | src/components/Tab/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tab/pageObject/index.js | MIT |
async isVisibleWithinViewport() {
return $(this.rootElement)
.$('button[role="tab"]')
.isDisplayedInViewport();
} | Returns true when the tab item is visible in the viewport.
@method
@returns {bool} | isVisibleWithinViewport | javascript | nexxtway/react-rainbow | src/components/Tab/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tab/pageObject/index.js | MIT |
async getLabelText() {
return $(this.rootElement).getText();
} | Returns the text of the tab item.
@method
@returns {string} | getLabelText | javascript | nexxtway/react-rainbow | src/components/Tab/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tab/pageObject/index.js | MIT |
constructor(props) {
super(props);
const {
children,
showCheckboxColumn,
keyField,
data,
showRowNumberColumn,
rowNumberOffset,
maxRowSelection,
minColumnWidth,
maxColumnWidth,
selectedRows,
variant,
} = props;
this.state = {
columns: getColumns({
children,
showCheckboxColumn,
showRowNumberColumn,
rowNumberOffset,
minColumnWidth,
maxColumnWidth,
variant,
}),
tableWidth: undefined,
rows: getRows({
keyField,
rows: normalizeData(data),
maxRowSelection: maxRowSelection && Number(maxRowSelection),
selectedRowsKeys: {},
}),
bulkSelection: 'none',
};
const { rows } = this.state;
this.indexes = getIndexes(rows);
this.selectedRowsKeys = getSelectedRowKeysFromSelectedRows(selectedRows, this.indexes);
this.tableId = uniqueId('table');
this.tableContainerRef = React.createRef();
this.resizeTarget = React.createRef();
this.handleSort = this.handleSort.bind(this);
this.handleResize = this.handleResize.bind(this);
this.updateColumnsAndTableWidth = this.updateColumnsAndTableWidth.bind(this);
this.handleSelectRow = this.handleSelectRow.bind(this);
this.handleDeselectRow = this.handleDeselectRow.bind(this);
this.handleSelectAllRows = this.handleSelectAllRows.bind(this);
this.handleDeselectAllRows = this.handleDeselectAllRows.bind(this);
this.scrollableY = React.createRef();
} | A table lists a collection of data that makes sense when displays them in rows and columns.
The data contained in a table is easier to read due to the format, so it can be useful to sort,
search, and filter your data.
@category DataView | constructor | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
componentDidMount() {
this.widthObserver = new ResizeSensor(
this.resizeTarget.current,
debounce(this.updateColumnsAndTableWidth, 200),
);
this.updateRows();
this.updateColumnsAndTableWidth();
} | A table lists a collection of data that makes sense when displays them in rows and columns.
The data contained in a table is easier to read due to the format, so it can be useful to sort,
search, and filter your data.
@category DataView | componentDidMount | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
componentDidUpdate(prevProps) {
const {
children: prevChildren,
showCheckboxColumn: prevShowCheckboxColumn,
maxRowSelection: prevMaxRowSelection,
selectedRows: prevSelectedRows,
data: prevData,
minColumnWidth: prevMinColumnWidth,
maxColumnWidth: prevMaxColumnWidth,
} = prevProps;
const {
children,
showCheckboxColumn,
showRowNumberColumn,
rowNumberOffset,
maxRowSelection,
selectedRows,
data,
keyField,
minColumnWidth,
maxColumnWidth,
onRowSelection,
variant,
} = this.props;
const prevColumns = getColumns({
children: prevChildren,
showCheckboxColumn: prevShowCheckboxColumn,
showRowNumberColumn,
rowNumberOffset,
minColumnWidth: prevMinColumnWidth,
maxColumnWidth: prevMaxColumnWidth,
variant,
});
const currentColumns = getColumns({
children,
showCheckboxColumn,
showRowNumberColumn,
rowNumberOffset,
minColumnWidth,
maxColumnWidth,
variant,
});
const isNotSameMaxRowSelection = prevMaxRowSelection !== maxRowSelection;
const isNotSameData = data !== prevData;
if (isNotSameMaxRowSelection || isNotSameData) {
this.updateRows();
}
if (isNotSameColumns(prevColumns, currentColumns)) {
this.updateColumnsAndTableWidth(currentColumns);
}
const isNotSameSelectedRows = prevSelectedRows !== selectedRows;
if (isNotSameSelectedRows) {
const selectedRowsKeysLength = Object.keys(this.selectedRowsKeys).length;
if (selectedRowsKeysLength !== selectedRows.length) {
this.selectedRowsKeys = getSelectedRowKeysFromSelectedRows(
selectedRows,
this.indexes,
);
const updatedRows = getRows({
keyField,
rows: normalizeData(data),
maxRowSelection,
selectedRowsKeys: this.selectedRowsKeys,
});
onRowSelection(this.getSelectedRows(updatedRows));
this.updateRows();
}
}
} | A table lists a collection of data that makes sense when displays them in rows and columns.
The data contained in a table is easier to read due to the format, so it can be useful to sort,
search, and filter your data.
@category DataView | componentDidUpdate | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
getTableWidthFromDom() {
const containerElement = this.tableContainerRef.current;
if (containerElement) {
return containerElement.offsetWidth;
}
return 0;
} | A table lists a collection of data that makes sense when displays them in rows and columns.
The data contained in a table is easier to read due to the format, so it can be useful to sort,
search, and filter your data.
@category DataView | getTableWidthFromDom | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
getSelectedRows(rows) {
const { data } = this.props;
return normalizeData(data).filter((item, index) => rows[index].isSelected);
} | A table lists a collection of data that makes sense when displays them in rows and columns.
The data contained in a table is easier to read due to the format, so it can be useful to sort,
search, and filter your data.
@category DataView | getSelectedRows | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
getMaxRowSelection() {
const { maxRowSelection, data } = this.props;
const rowsLength = normalizeData(data).length;
const maxRowSelectionNumber = Number(maxRowSelection);
if (!isValidMaxRowSelection(maxRowSelection, rowsLength)) {
return rowsLength;
}
return maxRowSelectionNumber;
} | A table lists a collection of data that makes sense when displays them in rows and columns.
The data contained in a table is easier to read due to the format, so it can be useful to sort,
search, and filter your data.
@category DataView | getMaxRowSelection | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
scrollTop() {
this.scrollableY.current.scrollTop = 0;
} | It will scroll to the top of the Y scrollable container.
@public | scrollTop | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
updateRows() {
const { keyField, selectedRows, onRowSelection, data } = this.props;
const maxRowSelection = this.getMaxRowSelection();
const newRows = getRows({
keyField,
rows: normalizeData(data),
maxRowSelection,
selectedRowsKeys: this.selectedRowsKeys,
});
this.indexes = getIndexes(newRows);
const selectedRowsKeysLength = Object.keys(this.selectedRowsKeys).length;
const currentSelectedRows = this.getSelectedRows(newRows);
const isNotSameSelectedRowsWithNewData =
selectedRowsKeysLength !== currentSelectedRows.length;
if (isNotSameSelectedRowsWithNewData) {
onRowSelection(currentSelectedRows);
this.selectedRowsKeys = getSelectedRowKeys(currentSelectedRows, keyField);
}
this.setState({
rows: getRowsWithInitalSelectedRows({
rows: newRows,
selectedRows,
maxRowSelection,
indexes: this.indexes,
selectedRowsKeys: this.selectedRowsKeys,
}),
bulkSelection: getBulkSelectionState({
maxRowSelection,
selectedRowsKeys: this.selectedRowsKeys,
}),
});
} | It will scroll to the top of the Y scrollable container.
@public | updateRows | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
updateColumnsAndTableWidth(newColumns) {
const { columns } = this.state;
const { minColumnWidth, maxColumnWidth } = this.props;
const domTableWidth = this.getTableWidthFromDom();
const minColWidth = Number(minColumnWidth) || 50;
const maxColWidth = Number(maxColumnWidth) || Infinity;
const updatedColumns = getUpdatedColumns({
columns: newColumns || columns,
domTableWidth,
minColumnWidth: minColWidth,
maxColumnWidth: maxColWidth,
});
this.setState({
columns: updatedColumns,
});
if (this.hasFlexibleColumns()) {
this.setState({
tableWidth: getTableWidth(updatedColumns),
});
}
} | It will scroll to the top of the Y scrollable container.
@public | updateColumnsAndTableWidth | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
handleSelectAllRows() {
const { onRowSelection } = this.props;
const { rows } = this.state;
const maxRowSelection = this.getMaxRowSelection();
this.selectedRowsKeys = {};
const updatedRows = getUpdatedRowsWhenSelectAll({
rows,
maxRowSelection,
selectedRowsKeys: this.selectedRowsKeys,
});
const bulkSelection = getBulkSelectionState({
maxRowSelection,
selectedRowsKeys: this.selectedRowsKeys,
});
this.setState({
rows: updatedRows,
bulkSelection,
});
onRowSelection(this.getSelectedRows(updatedRows));
} | It will scroll to the top of the Y scrollable container.
@public | handleSelectAllRows | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
handleDeselectAllRows() {
const { onRowSelection } = this.props;
const { rows } = this.state;
this.selectedRowsKeys = {};
const updatedRows = getUpdatedRowsWhenDeselectAll(rows);
const bulkSelection = getBulkSelectionState({
maxRowSelection: this.getMaxRowSelection(),
selectedRowsKeys: this.selectedRowsKeys,
});
this.setState({
rows: updatedRows,
bulkSelection,
});
onRowSelection(this.getSelectedRows(updatedRows));
} | It will scroll to the top of the Y scrollable container.
@public | handleDeselectAllRows | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
handleSelectRow(event, isMultiple, rowKeyValue) {
const { onRowSelection } = this.props;
const { indexes } = this;
const { rows } = this.state;
const maxRowSelection = this.getMaxRowSelection();
if (maxRowSelection > 1) {
const updatedRows = getUpdatedRowsWhenSelect({
maxRowSelection,
rows,
indexes,
isMultiple,
rowKeyValue,
lastSelectedRowKey: this.lastSelectedRowKey,
selectedRowsKeys: this.selectedRowsKeys,
});
const bulkSelection = getBulkSelectionState({
maxRowSelection,
selectedRowsKeys: this.selectedRowsKeys,
});
this.setState({
rows: updatedRows,
bulkSelection,
});
onRowSelection(this.getSelectedRows(updatedRows));
} else {
this.selectedRowsKeys = {};
this.selectedRowsKeys[rowKeyValue] = true;
const updatedRows = getUpdatedRowsWhenSelect({
maxRowSelection,
rows,
rowKeyValue,
selectedRowsKeys: this.selectedRowsKeys,
});
this.setState({
rows: updatedRows,
});
onRowSelection(this.getSelectedRows(updatedRows));
}
this.lastSelectedRowKey = rowKeyValue;
} | It will scroll to the top of the Y scrollable container.
@public | handleSelectRow | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
handleDeselectRow(event, isMultiple, rowKeyValue) {
const { onRowSelection } = this.props;
const { indexes } = this;
const { rows } = this.state;
const maxRowSelection = this.getMaxRowSelection();
const updatedRows = getUpdatedRowsWhenDeselect({
maxRowSelection,
rows,
indexes,
isMultiple,
rowKeyValue,
lastSelectedRowKey: this.lastSelectedRowKey,
selectedRowsKeys: this.selectedRowsKeys,
});
const bulkSelection = getBulkSelectionState({
maxRowSelection,
selectedRowsKeys: this.selectedRowsKeys,
});
this.setState({
rows: updatedRows,
bulkSelection,
});
this.lastSelectedRowKey = rowKeyValue;
onRowSelection(this.getSelectedRows(updatedRows));
} | It will scroll to the top of the Y scrollable container.
@public | handleDeselectRow | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
hasFlexibleColumns() {
const { columns } = this.state;
return columns.some(column => column.isResized !== true);
} | It will scroll to the top of the Y scrollable container.
@public | hasFlexibleColumns | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
handleResize(widthDelta, colIndex) {
const { columns, tableWidth } = this.state;
if (widthDelta !== 0) {
this.setState({
columns: getResizedColumns({ columns, colIndex, widthDelta }),
tableWidth: tableWidth + widthDelta,
});
}
} | It will scroll to the top of the Y scrollable container.
@public | handleResize | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
handleSort(event, field, sortDirection) {
const { onSort, sortedBy } = this.props;
const nextSortDirection = getNextSortDirection(field, sortedBy, sortDirection);
onSort(event, field, nextSortDirection);
} | It will scroll to the top of the Y scrollable container.
@public | handleSort | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
render() {
const {
id,
data,
sortedBy,
sortDirection,
defaultSortDirection,
resizeColumnDisabled,
rowNumberOffset,
minColumnWidth,
maxColumnWidth,
style,
className,
isLoading,
emptyIcon,
emptyTitle,
emptyDescription,
keyField,
hideTableHeader,
variant,
} = this.props;
const { columns, tableWidth, rows, bulkSelection } = this.state;
const tableStyles = {
width: tableWidth,
};
const maxRowSelection = this.getMaxRowSelection();
const minColWidth = Number(minColumnWidth) || 50;
const maxColWidth = Number(maxColumnWidth) || 5000;
const isEmpty = data.length === 0;
const theme = { variant, hideTableHeader, isEmpty };
if (keyField && typeof keyField === 'string') {
return (
<StyledContainer id={id} className={className} style={style}>
<div ref={this.resizeTarget} />
<ThemeProvider theme={theme}>
<StyledContainer>
<StyledScrollableX ref={this.tableContainerRef}>
<StyledScrollableY
isEmpty={isEmpty}
isLoading={isLoading}
ref={this.scrollableY}
style={tableStyles}
>
<StyledTable style={tableStyles}>
<StyledThead>
<tr>
<Head
columns={columns}
sortedBy={sortedBy}
sortDirection={sortDirection}
defaultSortDirection={defaultSortDirection}
resizeColumnDisabled={resizeColumnDisabled}
minColumnWidth={minColWidth}
maxColumnWidth={maxColWidth}
onSort={this.handleSort}
onResize={this.handleResize}
onSelectAllRows={this.handleSelectAllRows}
onDeselectAllRows={this.handleDeselectAllRows}
tableId={this.tableId}
maxRowSelection={maxRowSelection}
bulkSelection={bulkSelection}
/>
</tr>
</StyledThead>
<StyledTableBody rowNumberOffset={rowNumberOffset}>
<Body
data={normalizeData(data)}
columns={columns}
rows={rows}
tableId={this.tableId}
isLoading={isLoading}
emptyIcon={emptyIcon}
emptyTitle={emptyTitle}
emptyDescription={emptyDescription}
onSelectRow={this.handleSelectRow}
onDeselectRow={this.handleDeselectRow}
/>
</StyledTableBody>
</StyledTable>
</StyledScrollableY>
</StyledScrollableX>
</StyledContainer>
</ThemeProvider>
</StyledContainer>
);
}
console.error('The "keyField" is a required prop of the Table component.');
return null;
} | It will scroll to the top of the Y scrollable container.
@public | render | javascript | nexxtway/react-rainbow | src/components/Table/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new Table page object.
@constructor
@param {string} rootElement - The selector of the Table root element. | constructor | javascript | nexxtway/react-rainbow | src/components/Table/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/pageObject/index.js | MIT |
async selectAllRows() {
const headCheckbox = await $(this.rootElement)
.$('thead')
.$(HEAD_CHECKBOX_INPUT_SELECTOR);
if (
!(await headCheckbox.isSelected()) &&
!(await headCheckbox.getAttribute('indeterminate'))
) {
await $(this.rootElement)
.$('thead')
.$(HEAD_CHECKBOX_LABEL_SELECTOR)
.click();
}
} | Clicks the head checkbox to select the maximum selectable rows.
@method | selectAllRows | javascript | nexxtway/react-rainbow | src/components/Table/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/pageObject/index.js | MIT |
async deselectAllRows() {
const headCheckbox = await $(this.rootElement)
.$('thead')
.$(HEAD_CHECKBOX_INPUT_SELECTOR);
if (
(await headCheckbox.isSelected()) ||
(await headCheckbox.getAttribute('indeterminate'))
) {
await $(this.rootElement)
.$('thead')
.$(HEAD_CHECKBOX_LABEL_SELECTOR)
.click();
}
} | Clicks the head checkbox to deselect all selected rows.
@method | deselectAllRows | javascript | nexxtway/react-rainbow | src/components/Table/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/pageObject/index.js | MIT |
async getRow(rowPosition) {
const rows = await $(this.rootElement).$$('tbody > tr[data-id="table_body-row"]');
if (rows[rowPosition]) {
return new PageTableRow(
`${this.rootElement} tr[data-id="table_body-row"]:nth-child(${rowPosition + 1})`,
);
}
return null;
} | Returns a new Row page object of the row in the position passed.
@method
@param {number} rowPosition - The base 0 index of the row item. | getRow | javascript | nexxtway/react-rainbow | src/components/Table/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/pageObject/index.js | MIT |
async waitUntilDataIsLoaded() {
await browser.waitUntil(
async () =>
!(await $(this.rootElement)
.$('div[data-id="table_body--loading"]')
.isDisplayed()) &&
(await $(this.rootElement)
.$('tr[data-id="table_body-row"]')
.isDisplayed()),
);
} | Wait until the data is loaded.
@method | waitUntilDataIsLoaded | javascript | nexxtway/react-rainbow | src/components/Table/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/pageObject/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new Row page object.
@constructor
@param {string} rootElement - The selector of the Row root element. | constructor | javascript | nexxtway/react-rainbow | src/components/Table/pageObject/row.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/pageObject/row.js | MIT |
async selectRow() {
if (!(await this.isRowSelected())) {
await $(this.rootElement)
.$(CHECKBOX_LABEL_SELECTOR)
.click();
}
} | Clicks the row to select.
@method | selectRow | javascript | nexxtway/react-rainbow | src/components/Table/pageObject/row.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/pageObject/row.js | MIT |
async deselectRow() {
if (await this.isRowSelected()) {
await $(this.rootElement)
.$(CHECKBOX_LABEL_SELECTOR)
.click();
}
} | Clicks the row to select.
@method | deselectRow | javascript | nexxtway/react-rainbow | src/components/Table/pageObject/row.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/pageObject/row.js | MIT |
async isRowSelected() {
return $(this.rootElement)
.$(CHECKBOX_INPUT_SELECTOR)
.isSelected();
} | Returns true when the row is selected.
@method
@returns {bool} | isRowSelected | javascript | nexxtway/react-rainbow | src/components/Table/pageObject/row.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/pageObject/row.js | MIT |
async isRowSelectionDisabled() {
return !(await $(this.rootElement)
.$(CHECKBOX_INPUT_SELECTOR)
.isEnabled());
} | Returns true when the row input is disabled.
@method
@returns {bool} | isRowSelectionDisabled | javascript | nexxtway/react-rainbow | src/components/Table/pageObject/row.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Table/pageObject/row.js | MIT |
constructor(props) {
super(props);
const { data, pageSize } = props;
this.state = {
activePage: 1,
pageItems: getPageItems({
data,
activePage: 1,
pageSize,
}),
};
this.handleChange = this.handleChange.bind(this);
this.handleSelectChange = this.handleSelectChange.bind(this);
this.table = React.createRef();
} | This component implements a client-side pagination experience. Basically,
it wires up the Table and the Pagination components in a composed manner
and keeps the internal state of the active page based on a new prop pageSize.
@category DataView | constructor | javascript | nexxtway/react-rainbow | src/components/TableWithBrowserPagination/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TableWithBrowserPagination/index.js | MIT |
componentDidUpdate(prevProps) {
const { data, pageSize } = this.props;
if (prevProps.data !== data || prevProps.pageSize !== pageSize) {
this.updateData();
}
} | This component implements a client-side pagination experience. Basically,
it wires up the Table and the Pagination components in a composed manner
and keeps the internal state of the active page based on a new prop pageSize.
@category DataView | componentDidUpdate | javascript | nexxtway/react-rainbow | src/components/TableWithBrowserPagination/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TableWithBrowserPagination/index.js | MIT |
updateData() {
const { data, pageSize } = this.props;
const { activePage } = this.state;
const totalPages = Math.ceil(data.length / pageSize);
const nextActivePage = activePage <= totalPages ? activePage : 1;
this.setState({
activePage: nextActivePage,
pageItems: getPageItems({
data,
activePage: nextActivePage,
pageSize,
}),
});
} | This component implements a client-side pagination experience. Basically,
it wires up the Table and the Pagination components in a composed manner
and keeps the internal state of the active page based on a new prop pageSize.
@category DataView | updateData | javascript | nexxtway/react-rainbow | src/components/TableWithBrowserPagination/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TableWithBrowserPagination/index.js | MIT |
moveToPage(page) {
const { data, pageSize } = this.props;
this.setState({
activePage: page,
pageItems: getPageItems({
data,
activePage: page,
pageSize,
}),
});
this.table.current.scrollTop();
} | This component implements a client-side pagination experience. Basically,
it wires up the Table and the Pagination components in a composed manner
and keeps the internal state of the active page based on a new prop pageSize.
@category DataView | moveToPage | javascript | nexxtway/react-rainbow | src/components/TableWithBrowserPagination/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TableWithBrowserPagination/index.js | MIT |
handleSelectChange(event) {
const page = Number(event.target.value);
this.moveToPage(page);
} | This component implements a client-side pagination experience. Basically,
it wires up the Table and the Pagination components in a composed manner
and keeps the internal state of the active page based on a new prop pageSize.
@category DataView | handleSelectChange | javascript | nexxtway/react-rainbow | src/components/TableWithBrowserPagination/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TableWithBrowserPagination/index.js | MIT |
render() {
const {
style,
className,
paginationAlignment,
pageSize,
data,
children,
variant,
...rest
} = this.props;
const { activePage, pageItems } = this.state;
const pages = Math.ceil(data.length / pageSize);
const showPagination = pages > 1;
const paginationVariant = variant === 'listview' ? 'shaded' : 'default';
return (
<StyledContainer className={className} style={style}>
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
<StyledTable data={pageItems} {...rest} ref={this.table} variant={variant}>
{children}
</StyledTable>
<RenderIf isTrue={showPagination}>
<StyledPaginationContainer
paginationAlignment={paginationAlignment}
variant={variant}
>
<Pagination
pages={pages}
activePage={activePage}
onChange={this.handleChange}
variant={paginationVariant}
/>
<RenderIf isTrue={pages > 6}>
<StyledSelectContainer>
<StyledSelect
onChange={this.handleSelectChange}
value={activePage}
variant={variant}
>
<Options pages={pages} />
</StyledSelect>
</StyledSelectContainer>
</RenderIf>
</StyledPaginationContainer>
</RenderIf>
</StyledContainer>
);
} | This component implements a client-side pagination experience. Basically,
it wires up the Table and the Pagination components in a composed manner
and keeps the internal state of the active page based on a new prop pageSize.
@category DataView | render | javascript | nexxtway/react-rainbow | src/components/TableWithBrowserPagination/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TableWithBrowserPagination/index.js | MIT |
constructor(props) {
super(props);
this.state = {
key: Date.now(),
areButtonsVisible: false,
};
this.isFirstTime = true;
this.tabsetRef = React.createRef();
this.resizeTarget = React.createRef();
this.registerTab = this.registerTab.bind(this);
this.unRegisterTab = this.unRegisterTab.bind(this);
this.updateTab = this.updateTab.bind(this);
this.handleKeyPressed = this.handleKeyPressed.bind(this);
this.handleLeftButtonClick = this.handleLeftButtonClick.bind(this);
this.handleRightButtonClick = this.handleRightButtonClick.bind(this);
this.updateButtonsVisibility = this.updateButtonsVisibility.bind(this);
this.handleSelect = this.handleSelect.bind(this);
this.keyHandlerMap = {
[RIGHT_KEY]: () => this.selectTab(RIGHT_SIDE),
[LEFT_KEY]: () => this.selectTab(LEFT_SIDE),
};
this.tabsetChildren = [];
} | Tabs make it easy to explore and switch between different views.
@category Layout | constructor | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
componentDidMount() {
this.widthObserver = new ResizeSensor(
this.resizeTarget.current,
debounce(this.updateButtonsVisibility, 100),
);
} | Tabs make it easy to explore and switch between different views.
@category Layout | componentDidMount | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
componentDidUpdate(prevProp) {
const { children } = this.props;
const { isFirstTime } = this;
const areAllChildrenRegistered = children.length === this.tabsetChildren.length;
if (isNotSameChildren(children, prevProp.children)) {
this.updateButtonsVisibility();
}
if (areAllChildrenRegistered && isFirstTime) {
this.updateButtonsVisibility();
this.isFirstTime = false;
}
} | Tabs make it easy to explore and switch between different views.
@category Layout | componentDidUpdate | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
setAsSelectedTab(tabIndex) {
this.tabsetChildren[tabIndex].ref.click();
this.tabsetChildren[tabIndex].ref.focus();
} | Tabs make it easy to explore and switch between different views.
@category Layout | setAsSelectedTab | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
updateButtonsVisibility() {
const { areButtonsVisible, variant } = this.state;
const tabset = this.tabsetRef.current;
const { offsetWidth: resizeWidth } = this.resizeTarget.current;
const { scrollWidth, scrollLeft, offsetWidth: tabsetWidth } = tabset;
const childrenTotalWidth = getChildrenTotalWidth(this.tabsetChildren);
const buttonWidth = areButtonsVisible ? 94 : 0;
const padding = resizeWidth - tabsetWidth - buttonWidth;
const delta = variant === 'line' ? 0 : 1;
const showButtons = childrenTotalWidth > resizeWidth - padding + delta;
this.screenWidth = window.innerWidth;
this.scrollLeft = scrollLeft;
this.maxScroll = scrollWidth - tabsetWidth;
this.tabsetWidth = tabsetWidth;
this.setState({ areButtonsVisible: showButtons });
} | Tabs make it easy to explore and switch between different views.
@category Layout | updateButtonsVisibility | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
handleKeyPressed(event) {
if (this.keyHandlerMap[event.keyCode]) {
return this.keyHandlerMap[event.keyCode]();
}
return null;
} | Tabs make it easy to explore and switch between different views.
@category Layout | handleKeyPressed | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
selectTab(side) {
const { activeTabName } = this.props;
const { tabsetChildren } = this;
const activeTabIndex = getTabIndexFromName(tabsetChildren, activeTabName);
if (activeTabIndex === tabsetChildren.length - 1 && side === RIGHT_SIDE) {
this.setAsSelectedTab(0);
} else if (activeTabIndex === 0 && side === LEFT_SIDE) {
this.setAsSelectedTab(tabsetChildren.length - 1);
} else {
this.setAsSelectedTab(activeTabIndex + side);
}
} | Tabs make it easy to explore and switch between different views.
@category Layout | selectTab | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
isLeftButtonDisabled() {
const { activeTabName } = this.props;
const { tabsetChildren } = this;
const { screenWidth, scrollLeft } = this;
return getLeftButtonDisabledState({
activeTabName,
tabsetChildren,
screenWidth,
scrollLeft,
});
} | Tabs make it easy to explore and switch between different views.
@category Layout | isLeftButtonDisabled | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
isRightButtonDisabled() {
const { activeTabName } = this.props;
const { tabsetChildren } = this;
const { screenWidth, scrollLeft, maxScroll } = this;
return getRightButtonDisabledState({
activeTabName,
tabsetChildren,
screenWidth,
scrollLeft,
maxScroll,
});
} | Tabs make it easy to explore and switch between different views.
@category Layout | isRightButtonDisabled | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
handleRightButtonClick() {
const { screenWidth, tabsetWidth, scrollLeft } = this;
if (screenWidth > 600) {
return this.tabsetRef.current.scrollTo(scrollLeft + tabsetWidth, 0);
}
return this.selectTab(RIGHT_SIDE);
} | Tabs make it easy to explore and switch between different views.
@category Layout | handleRightButtonClick | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
handleLeftButtonClick() {
const { screenWidth, tabsetWidth, scrollLeft } = this;
if (screenWidth > 600) {
return this.tabsetRef.current.scrollTo(scrollLeft - tabsetWidth, 0);
}
return this.selectTab(LEFT_SIDE);
} | Tabs make it easy to explore and switch between different views.
@category Layout | handleLeftButtonClick | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
updateTab(tab, nameToUpdate) {
const { tabsetChildren } = this;
const newTabsetChildren = getUpdatedTabsetChildren(tabsetChildren, tab, nameToUpdate);
this.tabsetChildren = newTabsetChildren;
this.setState({ key: Date.now() });
} | Tabs make it easy to explore and switch between different views.
@category Layout | updateTab | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
registerTab(tab) {
const { tabsetChildren } = this;
const [...nodes] = getChildTabNodes(this.tabsetRef.current);
const newChildrenRefs = insertChildOrderly(tabsetChildren, tab, nodes);
this.tabsetChildren = newChildrenRefs;
this.setState({ key: Date.now() });
} | Tabs make it easy to explore and switch between different views.
@category Layout | registerTab | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
unRegisterTab(tabName) {
const { tabsetChildren } = this;
const newTabsetChildren = tabsetChildren.filter(tab => tab.name !== tabName);
this.tabsetChildren = newTabsetChildren;
this.setState({ key: Date.now() });
} | Tabs make it easy to explore and switch between different views.
@category Layout | unRegisterTab | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
scrollToSelectedTab(name) {
const { tabsetChildren } = this;
const tabset = this.tabsetRef.current;
const { scrollLeft, offsetWidth: tabsetWidth } = tabset;
const tabIndex = getTabIndexFromName(tabsetChildren, name);
const isFirstTab = tabIndex === 0;
if (isFirstTab) {
this.tabsetRef.current.scrollTo(0, 0);
} else {
const totalWidthUpToCurrentTab = getChildrenTotalWidthUpToClickedTab(
tabsetChildren,
tabIndex + 1,
);
const totalWidthUpToPrevTab = getChildrenTotalWidthUpToClickedTab(
tabsetChildren,
tabIndex,
);
const tabsetWidthUpToCurrentTab = tabsetWidth + scrollLeft;
const isCurrentTabOutOfViewOnRightSide =
totalWidthUpToCurrentTab > tabsetWidthUpToCurrentTab - 20;
const isCurrentTabOutOfViewOnLeftSide = scrollLeft > totalWidthUpToPrevTab;
if (isCurrentTabOutOfViewOnLeftSide) {
this.tabsetRef.current.scrollTo(totalWidthUpToPrevTab, 0);
}
if (isCurrentTabOutOfViewOnRightSide) {
const moveScroll = totalWidthUpToCurrentTab - tabsetWidthUpToCurrentTab + 20;
this.tabsetRef.current.scrollTo(scrollLeft + moveScroll, 0);
}
}
} | Tabs make it easy to explore and switch between different views.
@category Layout | scrollToSelectedTab | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
handleSelect(event, name) {
const { onSelect } = this.props;
this.scrollToSelectedTab(name);
onSelect(event, name);
} | Tabs make it easy to explore and switch between different views.
@category Layout | handleSelect | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
render() {
const { activeTabName, fullWidth, variant, children, style, className, id } = this.props;
const { areButtonsVisible } = this.state;
const { screenWidth } = this;
const showButtons = areButtonsVisible || screenWidth < 600;
const context = {
activeTabName,
onSelect: this.handleSelect,
privateRegisterTab: this.registerTab,
privateUnRegisterTab: this.unRegisterTab,
privateUpdateTab: this.updateTab,
fullWidth,
variant,
};
return (
<StyledContainer variant={variant} className={className} style={style} id={id}>
<StyledObserver ref={this.resizeTarget} />
<StyledTabset variant={variant}>
<StyledInnerContainer
fullWidth={fullWidth}
role="tablist"
onKeyDown={this.handleKeyPressed}
onScroll={this.updateButtonsVisibility}
ref={this.tabsetRef}
>
<Provider value={context}>{children}</Provider>
</StyledInnerContainer>
<RenderIf isTrue={showButtons}>
<StyledButtonGroup>
<StyledButtonIcon
icon={<LeftThinChevron />}
disabled={this.isLeftButtonDisabled()}
onClick={this.handleLeftButtonClick}
assistiveText="previus tab button"
variant="border-filled"
/>
<StyledButtonIcon
icon={<RightThinChevron />}
disabled={this.isRightButtonDisabled()}
onClick={this.handleRightButtonClick}
assistiveText="next tab button"
variant="border-filled"
/>
</StyledButtonGroup>
</RenderIf>
</StyledTabset>
</StyledContainer>
);
} | Tabs make it easy to explore and switch between different views.
@category Layout | render | javascript | nexxtway/react-rainbow | src/components/Tabset/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new Tabset page object.
@constructor
@param {string} rootElement - The selector of the Tabset root element. | constructor | javascript | nexxtway/react-rainbow | src/components/Tabset/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/pageObject/index.js | MIT |
async getItem(itemPosition) {
const items = await $(this.rootElement).$$('li[role="presentation"]');
if (items[itemPosition]) {
return new PageTab(
`${this.rootElement} li[role="presentation"]:nth-child(${itemPosition + 1})`,
);
}
return null;
} | Returns a new Tab page object of the element in item position.
@method
@param {number} itemPosition - The base 0 index of the tab item. | getItem | javascript | nexxtway/react-rainbow | src/components/Tabset/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/pageObject/index.js | MIT |
async isButtonsVisible() {
const buttons = await $(this.rootElement).$$(BUTTON_SELECTOR);
if (buttons && buttons.length) {
return browser.waitUntil(
async () => (await buttons[0].isDisplayed()) && (await buttons[1].isDisplayed()),
);
}
return false;
} | Returns true when buttons are visible.
@method
@returns {bool} | isButtonsVisible | javascript | nexxtway/react-rainbow | src/components/Tabset/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/pageObject/index.js | MIT |
async isLeftButtonEnabled() {
return $(this.rootElement)
.$$(BUTTON_SELECTOR)[0]
.isEnabled();
} | Returns true when the left button is enabled.
@method
@returns {bool} | isLeftButtonEnabled | javascript | nexxtway/react-rainbow | src/components/Tabset/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/pageObject/index.js | MIT |
async isRightButtonEnabled() {
return $(this.rootElement)
.$$(BUTTON_SELECTOR)[1]
.isEnabled();
} | Returns true when the right button is enabled.
@method
@returns {bool} | isRightButtonEnabled | javascript | nexxtway/react-rainbow | src/components/Tabset/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/pageObject/index.js | MIT |
async clickLeftButton() {
return $(this.rootElement)
.$$(BUTTON_SELECTOR)[0]
.click();
} | Click the left button.
@method
@returns {bool} | clickLeftButton | javascript | nexxtway/react-rainbow | src/components/Tabset/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/pageObject/index.js | MIT |
async clickRightButton() {
return $(this.rootElement)
.$$(BUTTON_SELECTOR)[1]
.click();
} | Click the right button.
@method
@returns {bool} | clickRightButton | javascript | nexxtway/react-rainbow | src/components/Tabset/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Tabset/pageObject/index.js | MIT |
constructor(props) {
super(props);
this.textareaRef = React.createRef();
this.textareaId = uniqueId('textarea');
this.inlineTextLabelId = uniqueId('inline-text-label');
this.errorMessageId = uniqueId('error-message');
this.updateFocus = this.updateFocus.bind(this);
this.state = {
isFocused: false,
};
} | Textarea inputs are used for freeform data entry.
@category Form | constructor | javascript | nexxtway/react-rainbow | src/components/Textarea/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Textarea/index.js | MIT |
componentDidMount() {
const { grow } = this.props;
if (grow) {
return autosize(this.textareaRef.current);
}
return null;
} | Textarea inputs are used for freeform data entry.
@category Form | componentDidMount | javascript | nexxtway/react-rainbow | src/components/Textarea/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Textarea/index.js | MIT |
getInlineTextLabelId() {
const { bottomHelpText } = this.props;
if (bottomHelpText) {
return this.inlineTextLabelId;
}
return undefined;
} | Textarea inputs are used for freeform data entry.
@category Form | getInlineTextLabelId | javascript | nexxtway/react-rainbow | src/components/Textarea/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Textarea/index.js | MIT |
getErrorMessageId() {
const { error } = this.props;
if (error) {
return this.errorMessageId;
}
return undefined;
} | Textarea inputs are used for freeform data entry.
@category Form | getErrorMessageId | javascript | nexxtway/react-rainbow | src/components/Textarea/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Textarea/index.js | MIT |
updateFocus(isFocused, handler) {
return (...args) => {
this.setState({ isFocused });
handler(...args);
};
} | Sets blur on the element.
@public | updateFocus | javascript | nexxtway/react-rainbow | src/components/Textarea/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Textarea/index.js | MIT |
render() {
const {
style,
className,
onChange,
onClick,
onFocus,
onBlur,
onKeyDown,
onPaste,
value,
readOnly,
label,
error,
placeholder,
disabled,
maxLength,
minLength,
bottomHelpText,
required,
rows,
id,
labelAlignment,
hideLabel,
name,
header,
footer,
variant,
size,
borderRadius,
} = this.props;
const { isFocused } = this.state;
return (
<StyledContainer className={className} style={style} id={id}>
<Label
label={label}
labelAlignment={labelAlignment}
hideLabel={hideLabel}
required={required}
inputId={this.textareaId}
readOnly={readOnly}
size={size}
id={this.getInlineTextLabelId()}
/>
<StyledTextareaContainer
error={error}
readOnly={readOnly}
disabled={disabled}
variant={variant}
isFocused={isFocused}
borderRadius={borderRadius}
>
<RenderIf isTrue={header}>{header}</RenderIf>
<StyledTextarea
error={error}
id={this.textareaId}
name={name}
placeholder={placeholder}
disabled={disabled}
required={required}
maxLength={maxLength}
minLength={minLength}
onChange={onChange}
onClick={onClick}
onFocus={this.updateFocus(true, onFocus)}
onBlur={this.updateFocus(false, onBlur)}
onKeyDown={onKeyDown}
onPaste={onPaste}
readOnly={readOnly}
rows={rows}
value={value}
aria-labelledby={this.getInlineTextLabelId()}
aria-describedby={this.getErrorMessageId()}
ref={this.textareaRef}
size={size}
/>
<RenderIf isTrue={footer}>{footer}</RenderIf>
</StyledTextareaContainer>
<RenderIf isTrue={bottomHelpText}>
<StyledBottomHelp>{bottomHelpText}</StyledBottomHelp>
</RenderIf>
<RenderIf isTrue={error}>
<StyledError id={this.getErrorMessageId()}>{error}</StyledError>
</RenderIf>
</StyledContainer>
);
} | Sets blur on the element.
@public | render | javascript | nexxtway/react-rainbow | src/components/Textarea/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Textarea/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new Textarea page object.
@constructor
@param {string} rootElement - The selector of the Textarea root element. | constructor | javascript | nexxtway/react-rainbow | src/components/Textarea/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Textarea/pageObject/index.js | MIT |
async hasFocusTextarea() {
return $(this.rootElement)
.$('textarea')
.isFocused();
} | Returns true when the textarea element has focus.
@method
@returns {bool} | hasFocusTextarea | javascript | nexxtway/react-rainbow | src/components/Textarea/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Textarea/pageObject/index.js | MIT |
async setValue(value) {
await $(this.rootElement)
.$('textarea')
.setValue(value);
} | It set a value in the textarea.
@method
@param {string} values - The value to set in the textarea. | setValue | javascript | nexxtway/react-rainbow | src/components/Textarea/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Textarea/pageObject/index.js | MIT |
async getValue() {
return $(this.rootElement)
.$('textarea')
.getValue();
} | It get the value of the textarea.
@method
@returns {string} | getValue | javascript | nexxtway/react-rainbow | src/components/Textarea/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/Textarea/pageObject/index.js | MIT |
function TimelineMarker(props) {
const context = useContext(ActivityTimelineContext);
if (context) {
// eslint-disable-next-line react/jsx-props-no-spreading
return <AccordionTimelineMarker {...props} />;
}
// eslint-disable-next-line react/jsx-props-no-spreading
return <BasicTimelineMarker {...props} />;
} | The TimelineMarker displays one event of an item's timeline. It's generally used to compose the ActivityTimeline component.
@category Layout | TimelineMarker | javascript | nexxtway/react-rainbow | src/components/TimelineMarker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimelineMarker/index.js | MIT |
getTriggerInputValue = () => {
return getInputValue(value, placeholder, hour24);
} | A TimePicker is used to input a time by displaying an interface the user can interact with.
@category Form | getTriggerInputValue | javascript | nexxtway/react-rainbow | src/components/TimePicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/index.js | MIT |
getTriggerInputValue = () => {
return getInputValue(value, placeholder, hour24);
} | A TimePicker is used to input a time by displaying an interface the user can interact with.
@category Form | getTriggerInputValue | javascript | nexxtway/react-rainbow | src/components/TimePicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/index.js | MIT |
handleKeyDown = event => {
const { keyCode } = event;
const shouldOpenModal = (keyCode === ENTER_KEY || keyCode === SPACE_KEY) && !readOnly;
if (shouldOpenModal) {
setIsOpen(true);
}
} | A TimePicker is used to input a time by displaying an interface the user can interact with.
@category Form | handleKeyDown | javascript | nexxtway/react-rainbow | src/components/TimePicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/index.js | MIT |
handleKeyDown = event => {
const { keyCode } = event;
const shouldOpenModal = (keyCode === ENTER_KEY || keyCode === SPACE_KEY) && !readOnly;
if (shouldOpenModal) {
setIsOpen(true);
}
} | A TimePicker is used to input a time by displaying an interface the user can interact with.
@category Form | handleKeyDown | javascript | nexxtway/react-rainbow | src/components/TimePicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/index.js | MIT |
handleClick = event => {
if (!readOnly) {
setIsOpen(true);
onClick(event);
}
} | A TimePicker is used to input a time by displaying an interface the user can interact with.
@category Form | handleClick | javascript | nexxtway/react-rainbow | src/components/TimePicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/index.js | MIT |
handleClick = event => {
if (!readOnly) {
setIsOpen(true);
onClick(event);
}
} | A TimePicker is used to input a time by displaying an interface the user can interact with.
@category Form | handleClick | javascript | nexxtway/react-rainbow | src/components/TimePicker/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/index.js | MIT |
constructor(rootElement) {
this.rootElement = rootElement;
} | Create a new TimePicker page object.
@constructor
@param {string} rootElement - The selector of the TimePicker root element. | constructor | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async clickUpButton() {
await $(timePickerModalId)
.$('button[id="time-picker_up-button"]')
.click();
} | Clicks the up button element.
@method | clickUpButton | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async clickDownButton() {
await $(timePickerModalId)
.$('button[id="time-picker_down-button"]')
.click();
} | Clicks the down button element.
@method | clickDownButton | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async clickCancelButton() {
await $(timePickerModalId)
.$('button[id="time-picker_cancel-button"]')
.click();
} | Clicks the cancel button element.
@method | clickCancelButton | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
async clickOkButton() {
await $(timePickerModalId)
.$('button[id="time-picker_ok-button"]')
.click();
} | Clicks the OK button element.
@method | clickOkButton | javascript | nexxtway/react-rainbow | src/components/TimePicker/pageObject/index.js | https://github.com/nexxtway/react-rainbow/blob/master/src/components/TimePicker/pageObject/index.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.