Skip to content

Commit

Permalink
Merge branch 'master' into 7647-link-02-token
Browse files Browse the repository at this point in the history
  • Loading branch information
tay1orjones authored Feb 10, 2021
2 parents 3b7f511 + 9a08838 commit aa230ed
Show file tree
Hide file tree
Showing 47 changed files with 218 additions and 203 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/resolve-patch-bef242007a-ca4e21815c.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 5 additions & 1 deletion config/eslint-config-carbon/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

module.exports = {
parser: 'babel-eslint',
extends: ['eslint:recommended', require.resolve('./plugins/jsdoc')],
extends: [
'eslint:recommended',
require.resolve('./rules/best-practices'),
require.resolve('./plugins/jsdoc'),
],
rules: {
// Handle cases where we are destructuring but may not be using the initial
// variables
Expand Down
15 changes: 15 additions & 0 deletions config/eslint-config-carbon/rules/best-practices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright IBM Corp. 2018, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = {
rules: {
// @see https://eslint.org/docs/rules/curly
curly: 'error',
},
};
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"dependencies": {
"@carbon/cli-reporter": "^10.4.0",
"@octokit/plugin-retry": "^2.2.0",
"@octokit/plugin-retry": "^3.0.7",
"@octokit/plugin-throttling": "^2.6.0",
"@octokit/rest": "^16.28.1",
"@rollup/plugin-babel": "^5.2.2",
Expand Down
12 changes: 9 additions & 3 deletions packages/cli/src/commands/sassdoc/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ function createAnchorLink(name, heading) {
function createMarkdownItem(item) {
let str = '';

if (!item.context) return '';
if (!item.context) {
return '';
}

let status = item.access === 'public' ? '✅' : '❌';

Expand Down Expand Up @@ -160,9 +162,13 @@ $${item.context.name}: ${item.context.value};

if (item.parameter) {
item.parameter.forEach((param) => {
if (paramStr) paramStr += `, `;
if (paramStr) {
paramStr += `, `;
}
paramStr += `$${param.name}`;
if (param.default) paramStr += `: ${param.default}`;
if (param.default) {
paramStr += `: ${param.default}`;
}
});
}

Expand Down
4 changes: 3 additions & 1 deletion packages/components/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ const convertToESMGulpPlugin = () =>
}),
],
onwarn: (warning, handle) => {
if (warning.code !== 'EMPTY_BUNDLE') handle(warning);
if (warning.code !== 'EMPTY_BUNDLE') {
handle(warning);
}
},
})
.then((bundle) => bundle.generate({ format: 'esm' }))
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"jasmine-core": "^3.0.0",
"karma": "^4.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.0",
"karma-coverage": "^2.0.3",
"karma-firefox-launcher": "^2.1.0",
"karma-html2js-preprocessor": "^1.1.0",
"karma-ie-launcher": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@
background-color: $ui-03;
}

.#{$prefix}--data-table.#{$prefix}--data-table--sort th {
padding: 0;
}

.#{$prefix}--data-table.#{$prefix}--data-table--sort .#{$prefix}--table-sort {
padding-left: $spacing-05;
}

.#{$prefix}--data-table th:last-of-type {
// Do not use `position: relative`, as its behavior is undefined for many table elements: https://www.w3.org/TR/CSS21/visuren.html#propdef-position
position: static;
Expand Down
8 changes: 6 additions & 2 deletions packages/components/tests/pure-modules-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ describe('ES modules', () => {
terser.terser(),
],
onwarn: (warning, handle) => {
if (warning.code !== 'EMPTY_BUNDLE') handle(warning);
if (warning.code !== 'EMPTY_BUNDLE') {
handle(warning);
}
},
treeshake: {
annotations: false,
Expand Down Expand Up @@ -103,7 +105,9 @@ describe('ES modules', () => {
terser.terser(),
],
onwarn: (warning, handle) => {
if (warning.code !== 'EMPTY_BUNDLE') handle(warning);
if (warning.code !== 'EMPTY_BUNDLE') {
handle(warning);
}
},
treeshake: {
annotations: false,
Expand Down
11 changes: 8 additions & 3 deletions packages/icon-build-helpers/src/builders/plugins/virtual.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ module.exports = function virtual(modules) {
name: 'virtual',

resolveId(id, importer) {
if (id in modules) return PREFIX + id;
if (id in modules) {
return PREFIX + id;
}

if (importer) {
if (importer.startsWith(PREFIX))
if (importer.startsWith(PREFIX)) {
importer = importer.slice(PREFIX.length);
}
const resolved = path.resolve(path.dirname(importer), id);
if (resolvedIds.has(resolved)) return PREFIX + resolved;
if (resolvedIds.has(resolved)) {
return PREFIX + resolved;
}
}
},

Expand Down
17 changes: 13 additions & 4 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,12 @@ Map {
],
"type": "oneOf",
},
"warn": Object {
"type": "bool",
},
"warnText": Object {
"type": "node",
},
},
},
"ComposedModal" => Object {
Expand Down Expand Up @@ -1396,7 +1402,8 @@ Map {
"persistent": Object {
"type": "bool",
},
"placeHolderText": Object {
"placeHolderText": [Function],
"placeholder": Object {
"type": "string",
},
"searchContainerClass": Object {
Expand Down Expand Up @@ -1987,7 +1994,8 @@ Map {
"persistent": Object {
"type": "bool",
},
"placeHolderText": Object {
"placeHolderText": [Function],
"placeholder": Object {
"type": "string",
},
"searchContainerClass": Object {
Expand Down Expand Up @@ -4524,7 +4532,7 @@ Map {
"defaultProps": Object {
"closeButtonLabelText": "Clear search input",
"onChange": [Function],
"placeHolderText": "",
"placeholder": "",
"type": "text",
},
"propTypes": Object {
Expand Down Expand Up @@ -4566,7 +4574,8 @@ Map {
"onKeyDown": Object {
"type": "func",
},
"placeHolderText": Object {
"placeHolderText": [Function],
"placeholder": Object {
"type": "string",
},
"size": Object {
Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/components/ComboBox/ComboBox-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ const props = () => ({
direction: select('Dropdown direction (direction)', directions, 'bottom'),
onChange: action('onChange'),
onToggleClick: action('onClick'),
warn: boolean('Show warning state (warn)', false),
warnText: text(
'Warning state text (warnText)',
'This mode may perform worse on older machines'
),
});

export const Playground = () => (
Expand Down
31 changes: 28 additions & 3 deletions packages/react/src/components/ComboBox/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import Downshift from 'downshift';
import PropTypes from 'prop-types';
import React from 'react';
import { settings } from 'carbon-components';
import { Checkmark16, WarningFilled16 } from '@carbon/icons-react';
import {
Checkmark16,
WarningAltFilled16,
WarningFilled16,
} from '@carbon/icons-react';
import ListBox, { PropTypes as ListBoxPropTypes } from '../ListBox';
import { match, keys } from '../../internal/keyboard';
import setupGetInstanceId from '../../tools/setupGetInstanceId';
Expand Down Expand Up @@ -199,6 +203,16 @@ export default class ComboBox extends React.Component {
* Currently supports either the default type, or an inline variant
*/
type: ListBoxPropTypes.ListBoxType,

/**
* Specify whether the control is currently in warning state
*/
warn: PropTypes.bool,

/**
* Provide the text that is displayed when the control is in warning state
*/
warnText: PropTypes.node,
};

static defaultProps = {
Expand Down Expand Up @@ -331,10 +345,14 @@ export default class ComboBox extends React.Component {
onToggleClick, // eslint-disable-line no-unused-vars
downshiftProps,
direction,
warn,
warnText,
...rest
} = this.props;
const showWarning = !invalid && warn;
const className = cx(`${prefix}--combo-box`, containerClassName, {
[`${prefix}--list-box--up`]: direction === 'top',
[`${prefix}--combo-box--warning`]: showWarning,
});
const titleClasses = cx(`${prefix}--label`, {
[`${prefix}--label--disabled`]: disabled,
Expand Down Expand Up @@ -390,7 +408,9 @@ export default class ComboBox extends React.Component {
invalidText={invalidText}
isOpen={isOpen}
light={light}
size={size}>
size={size}
warn={warn}
warnText={warnText}>
<ListBox.Field
{...getToggleButtonProps({
disabled,
Expand Down Expand Up @@ -423,6 +443,11 @@ export default class ComboBox extends React.Component {
className={`${prefix}--list-box__invalid-icon`}
/>
)}
{showWarning && (
<WarningAltFilled16
className={`${prefix}--list-box__invalid-icon ${prefix}--list-box__invalid-icon--warning`}
/>
)}
{inputValue && (
<ListBox.Selection
clearSelection={clearSelection}
Expand Down Expand Up @@ -470,7 +495,7 @@ export default class ComboBox extends React.Component {
</ListBox.Menu>
)}
</ListBox>
{helperText && !invalid && (
{helperText && !invalid && !warn && (
<div id={comboBoxHelperId} className={helperClasses}>
{helperText}
</div>
Expand Down
17 changes: 14 additions & 3 deletions packages/react/src/components/DataTable/TableToolbarSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const TableToolbarSearch = ({
onChange: onChangeProp,
translateWithId: t,
placeHolderText,
placeholder,
labelText,
expanded: expandedProp,
defaultExpanded,
Expand Down Expand Up @@ -124,8 +125,10 @@ const TableToolbarSearch = ({
value={value}
id={typeof id !== 'undefined' ? id : uniqueId.toString()}
labelText={labelText || t('carbon.table.toolbar.search.label')}
placeHolderText={
placeHolderText || t('carbon.table.toolbar.search.placeholder')
placeholder={
placeHolderText ||
placeholder ||
t('carbon.table.toolbar.search.placeholder')
}
onChange={onChange}
{...rest}
Expand Down Expand Up @@ -192,10 +195,18 @@ TableToolbarSearch.propTypes = {
*/
persistent: PropTypes.bool,

/**
* Deprecated in favor of `placeholder`
*/
placeHolderText: deprecate(
PropTypes.string,
`\nThe prop \`placeHolderText\` for TableToolbarSearch has been deprecated in favor of \`placeholder\`. Please use \`placeholder\` instead.`
),

/**
* Provide an optional placeholder text for the Search component
*/
placeHolderText: PropTypes.string,
placeholder: PropTypes.string,

/**
* Provide an optional className for the overal container of the Search
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2298,7 +2298,7 @@ exports[`DataTable should render 1`] = `
id="custom-id"
labelText="Filter table"
onChange={[Function]}
placeHolderText="Filter table"
placeholder="Filter table"
size="sm"
tabIndex="0"
type="text"
Expand Down Expand Up @@ -3303,7 +3303,7 @@ exports[`DataTable sticky header should render 1`] = `
id="custom-id"
labelText="Filter table"
onChange={[Function]}
placeHolderText="Filter table"
placeholder="Filter table"
size="sm"
tabIndex="0"
type="text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exports[`DataTable.TableToolbarSearch should render 1`] = `
id="custom-id"
labelText="Filter table"
onChange={[Function]}
placeHolderText="Filter table"
placeholder="Filter table"
size="sm"
tabIndex="-1"
type="text"
Expand Down
4 changes: 3 additions & 1 deletion packages/react/src/components/DataTable/tools/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export const defaultFilterRows = ({
rowIds.filter((rowId) =>
headers.some(({ key }) => {
const id = getCellId(rowId, key);
if (typeof cellsById[id].value === 'boolean') return false;
if (typeof cellsById[id].value === 'boolean') {
return false;
}
return ('' + cellsById[id].value)
.toLowerCase()
.includes(inputValue.toLowerCase());
Expand Down
4 changes: 3 additions & 1 deletion packages/react/src/components/DatePicker/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ const carbonFlatpickrMonthSelectPlugin = (config) => (fp) => {
return;
}
fp.monthElements.forEach((elem) => {
if (!elem.parentNode) return;
if (!elem.parentNode) {
return;
}
elem.parentNode.removeChild(elem);
});
fp.monthElements.splice(
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Form/Form-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export const Default = () => (
{...searchProps}
id="search-1"
labelText="Search"
placeHolderText="Search"
placeholder="Search"
/>
</FormGroup>

Expand Down
Loading

0 comments on commit aa230ed

Please sign in to comment.