Skip to content

Commit

Permalink
Merge branch '3615-definition-tooltip-dismiss-esc' of https://github.…
Browse files Browse the repository at this point in the history
…com/emyarod/carbon into pr/emyarod/5147
  • Loading branch information
designertyler committed Jan 27, 2020
2 parents 9ea4bd9 + ad2bf18 commit aab6ae7
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 88 deletions.
12 changes: 7 additions & 5 deletions packages/components/docs/migration/migrate-to-10.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@ initial `v10` release.
**IMPORTANT NOTE**: Most of deprecated variables, mixins and functions will be
_removed_ soon after the initial `v10` release.

| `scss` path | v10 |
| ------------------- | ----------------------------------------------------------------------------- |
| `src` | Deprecated in v10, use `scss` instead [Migrate](../../src/migrate-to-10.x.md) |
| `scss/globals` | [Migrate](../../src/globals/scss/migrate-to-10.x.md) |
| `scss/globals/grid` | [Migrate](../../src/globals/scss/grid/migrate-to-10.x.md) |
| `scss` path | v10 |
| -------------------- | ----------------------------------------------------------------------------- |
| `src` | Deprecated in v10, use `scss` instead [Migrate](../../src/migrate-to-10.x.md) |
| `scss/globals` | [Migrate](../../src/globals/scss/migrate-to-10.x.md) |
| `scss/globals/grid` | [Migrate](../../src/globals/scss/grid/migrate-to-10.x.md) |
| `scss/globals/layer` | Deprecated in v10 [Migrate](../../src/globals/scss/migrate-to-10.x.md) |

### Features

| Sass feature | v10 |
| ------------------- | ------- |
| `font-size` mixin | Removed |
| `line-height` mixin | Removed |
| `layer` mixin | Removed |
29 changes: 21 additions & 8 deletions packages/components/docs/sass.md
Original file line number Diff line number Diff line change
Expand Up @@ -20453,6 +20453,7 @@ Progress indicator styles
margin-left: $carbon--spacing-06;
margin-top: rem(28px);
color: $text-01;
text-align: start;
}

//CURRENT STYLING
Expand Down Expand Up @@ -20489,6 +20490,7 @@ Progress indicator styles

//interactive button
.#{$prefix}--progress-step-button {
@include button-reset();
display: flex;
}

Expand Down Expand Up @@ -20547,15 +20549,25 @@ Progress indicator styles
}

.#{$prefix}--progress--vertical .#{$prefix}--progress-step {
padding-bottom: rem(24px);
}

.#{$prefix}--progress--vertical .#{$prefix}--progress-step,
.#{$prefix}--progress--vertical .#{$prefix}--progress-step-button {
display: list-item;
min-height: 6rem;
min-height: 3.625rem;
width: initial;
min-width: initial;
}

svg {
display: inline-block;
margin: 0.1rem 0.5rem;
}
.#{$prefix}--progress--vertical .#{$prefix}--progress-step svg,
.#{$prefix}--progress--vertical .#{$prefix}--progress-step-button svg {
display: inline-block;
margin: 0.1rem 0.5rem;
}

.#{$prefix}--progress--vertical .#{$prefix}--progress-step-button svg {
margin-right: 0.7rem;
}

.#{$prefix}--progress--vertical .#{$prefix}--progress-step--current svg {
Expand All @@ -20565,9 +20577,10 @@ Progress indicator styles
.#{$prefix}--progress--vertical .#{$prefix}--progress-label {
display: inline-block;
width: initial;
max-width: none;
max-width: rem(160px);
vertical-align: top;
margin: 0;
white-space: initial;
}

.#{$prefix}--progress--vertical .#{$prefix}--progress-step .bx--tooltip {
Expand Down Expand Up @@ -22419,11 +22432,11 @@ Text input styles
}
}

.#{$prefix}--text-input--large {
.#{$prefix}--text-input--xl {
height: rem(48px);
}

.#{$prefix}--text-input--small {
.#{$prefix}--text-input--sm {
height: rem(32px);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
margin-left: $carbon--spacing-06;
margin-top: rem(28px);
color: $text-01;
text-align: start;
}

//CURRENT STYLING
Expand Down Expand Up @@ -168,6 +169,7 @@

//interactive button
.#{$prefix}--progress-step-button {
@include button-reset();
display: flex;
}

Expand Down Expand Up @@ -226,15 +228,25 @@
}

.#{$prefix}--progress--vertical .#{$prefix}--progress-step {
padding-bottom: rem(24px);
}

.#{$prefix}--progress--vertical .#{$prefix}--progress-step,
.#{$prefix}--progress--vertical .#{$prefix}--progress-step-button {
display: list-item;
min-height: 6rem;
min-height: 3.625rem;
width: initial;
min-width: initial;
}

svg {
display: inline-block;
margin: 0.1rem 0.5rem;
}
.#{$prefix}--progress--vertical .#{$prefix}--progress-step svg,
.#{$prefix}--progress--vertical .#{$prefix}--progress-step-button svg {
display: inline-block;
margin: 0.1rem 0.5rem;
}

.#{$prefix}--progress--vertical .#{$prefix}--progress-step-button svg {
margin-right: 0.7rem;
}

.#{$prefix}--progress--vertical .#{$prefix}--progress-step--current svg {
Expand All @@ -244,9 +256,10 @@
.#{$prefix}--progress--vertical .#{$prefix}--progress-label {
display: inline-block;
width: initial;
max-width: none;
max-width: rem(160px);
vertical-align: top;
margin: 0;
white-space: initial;
}

.#{$prefix}--progress--vertical .#{$prefix}--progress-step .bx--tooltip {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
}
}

.#{$prefix}--text-input--large {
.#{$prefix}--text-input--xl {
height: rem(48px);
}

.#{$prefix}--text-input--small {
.#{$prefix}--text-input--sm {
height: rem(32px);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/globals/scss/migrate-to-10.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ No change

## `_layer.scss`

No change
- Removed, replaced with `box-shadow` mixin

### Internal

Expand Down
1 change: 0 additions & 1 deletion packages/react/.storybook/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ $prefix: 'bx';
@import '~carbon-components/scss/globals/scss/theme';
@import '~carbon-components/scss/globals/scss/mixins';
@import '~carbon-components/scss/globals/scss/layout';
@import '~carbon-components/scss/globals/scss/layer';
@import '~carbon-components/scss/globals/scss/spacing';
@import '~carbon-components/scss/globals/scss/typography';
@import '~carbon-components/scss/globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
Expand Down
6 changes: 5 additions & 1 deletion packages/react/src/components/DataTable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,14 @@ export default class DataTable extends React.Component {
*
* @param {Event} event
*/
handleOnInputValueChange = event => {
handleOnInputValueChange = (event, defaultValue) => {
if (event.target) {
this.setState({ filterInputValue: event.target.value });
}

if (defaultValue) {
this.setState({ filterInputValue: defaultValue });
}
};

render() {
Expand Down
30 changes: 30 additions & 0 deletions packages/react/src/components/DataTable/TableExpandHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import cx from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import { ChevronRight16 } from '@carbon/icons-react';
import { settings } from 'carbon-components';
Expand All @@ -19,6 +20,7 @@ const TableExpandHeader = ({
isExpanded,
onExpand,
expandIconDescription,
children,
...rest
}) => {
const className = cx(`${prefix}--table-expand`, headerClassName);
Expand All @@ -42,8 +44,36 @@ const TableExpandHeader = ({
/>
</button>
)}
{children}
</th>
);
};

TableExpandHeader.propTypes = {
className: PropTypes.string,
children: PropTypes.node,

/**
* Specify the string read by a voice reader when the expand trigger is
* focused
*/
ariaLabel: PropTypes.string.isRequired,

/**
* Specify whether this row is expanded or not. This helps coordinate data
* attributes so that `TableExpandRow` and `TableExapndedRow` work together
*/
isExpanded: PropTypes.bool.isRequired,

/**
* Hook for when a listener initiates a request to expand the given row
*/
onExpand: PropTypes.func.isRequired,

/**
* The description of the chevron right icon, to be put in its SVG `<title>` element.
*/
expandIconDescription: PropTypes.string,
};

export default TableExpandHeader;
33 changes: 26 additions & 7 deletions packages/react/src/components/DataTable/TableToolbarSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,32 @@ const TableToolbarSearch = ({
...rest
}) => {
const { current: controlled } = useRef(expandedProp !== undefined);
const [expandedState, setExpandedState] = useState(defaultExpanded);
const [expandedState, setExpandedState] = useState(
defaultExpanded || defaultValue
);
const expanded = controlled ? expandedProp : expandedState;
const searchRef = useRef(null);
const [value, setValue] = useState('');
const [value, setValue] = useState(defaultValue || '');
const uniqueId = useMemo(getInstanceId, []);

const [focusTarget, setFocusTarget] = useState(null);

useEffect(() => {
if (!controlled && expandedState && searchRef.current) {
searchRef.current.querySelector('input').focus();
if (focusTarget) {
focusTarget.current.querySelector('input').focus();
setFocusTarget(null);
}
}, [controlled, expandedState]);
}, [focusTarget]);

useEffect(
() => {
if (defaultValue) {
onChangeProp('', defaultValue);
}
},
//eslint-disable-next-line react-hooks/exhaustive-deps
[]
);

const searchContainerClasses = cx({
[searchContainerClass]: searchContainerClass,
Expand All @@ -71,6 +86,11 @@ const TableToolbarSearch = ({
}
};

const onClick = e => {
setFocusTarget(searchRef);
handleExpand(e, true);
};

const onChange = e => {
setValue(e.target.value);
if (onChangeProp) {
Expand All @@ -83,15 +103,14 @@ const TableToolbarSearch = ({
tabIndex={expandedState ? '-1' : tabIndex}
role="search"
ref={searchRef}
onClick={event => handleExpand(event, true)}
onClick={event => onClick(event)}
onFocus={event => handleExpand(event, true)}
onBlur={event => !value && handleExpand(event, false)}
className={searchContainerClasses}>
<Search
size="sm"
tabIndex={expandedState ? tabIndex : '-1'}
className={className}
defaultValue={defaultValue}
value={value}
id={typeof id !== 'undefined' ? id : uniqueId.toString()}
aria-hidden={!expanded}
Expand Down
28 changes: 16 additions & 12 deletions packages/react/src/components/MultiSelect/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import isEqual from 'lodash.isequal';
import { settings } from 'carbon-components';
import { WarningFilled16 } from '@carbon/icons-react';
import ListBox, { PropTypes as ListBoxPropTypes } from '../ListBox';
import Checkbox from '../Checkbox';
import Selection from '../../internal/Selection';
import { sortingPropTypes } from './MultiSelectPropTypes';
import { defaultItemToString } from './tools/itemToString';
Expand Down Expand Up @@ -357,7 +356,10 @@ export default class MultiSelect extends React.Component {
/>
</ListBox.Field>
{isOpen && (
<ListBox.Menu aria-labelledby={`${labelId}`} id={id}>
<ListBox.Menu
aria-multiselectable="true"
aria-labelledby={`${labelId}`}
id={id}>
{sortItems(items, {
selectedItems: {
top: selectedItems,
Expand All @@ -378,19 +380,21 @@ export default class MultiSelect extends React.Component {
<ListBox.MenuItem
key={itemProps.id}
isActive={isChecked}
role="option"
aria-selected={isChecked}
tabIndex={-1}
isHighlighted={highlightedIndex === index}
title={itemText}
{...itemProps}>
<Checkbox
id={`${itemProps.id}__checkbox`}
title={useTitleInItem ? itemText : null}
name={itemText}
checked={isChecked}
disabled={disabled}
readOnly={true}
tabIndex="-1"
labelText={itemText}
/>
<div className={`${prefix}--checkbox-wrapper`}>
<span
title={useTitleInItem ? itemText : null}
className={`${prefix}--checkbox-label`}
data-contained-checkbox-state={isChecked}
id={`${itemProps.id}__checkbox`}>
{itemText}
</span>
</div>
</ListBox.MenuItem>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';
import { storiesOf } from '@storybook/react';
import { withKnobs, number } from '@storybook/addon-knobs';
import { withKnobs, number, boolean, text } from '@storybook/addon-knobs';
import { action } from '@storybook/addon-actions';
import { ProgressIndicator, ProgressStep } from '../ProgressIndicator';
import ProgressIndicatorSkeleton from '../ProgressIndicator/ProgressIndicator.Skeleton';
Expand All @@ -22,9 +22,10 @@ storiesOf('ProgressIndicator', module)
'Default',
() => (
<ProgressIndicator
vertical={boolean('Vertical', false)}
currentIndex={number('Current progress (currentIndex)', 1)}>
<ProgressStep
label="First step"
label={text('Label', 'First step')}
description="Step 1: Getting started with Carbon Design System"
secondaryLabel="Optional label"
/>
Expand Down
Loading

0 comments on commit aab6ae7

Please sign in to comment.