Skip to content

Commit

Permalink
[NO_TICKET] Export form components (#959)
Browse files Browse the repository at this point in the history
* Export FormControl and InlineError

* Export TextInput and Select

* Add comments warning developers
  • Loading branch information
bernardwang authored Mar 4, 2021
1 parent b576cc1 commit fc485c2
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/design-system/src/components/Dropdown/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';

/**
* <Select> is an internal component used by <Dropdown>, which wraps it and handles common form controls like labels, error messages, etc
* <Select> is also exported for advanced design system use cases, where the internal component can be leveraged to build custom form components
* As an internal component, it's subject to more breaking changes. Exercise caution using <Select> outside of those special cases
*/
export class Select extends React.PureComponent {
constructor(props) {
super(props);
Expand Down
1 change: 1 addition & 0 deletions packages/design-system/src/components/Dropdown/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as Dropdown } from './Dropdown';
export { default as Select } from './Select';
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import classNames from 'classnames';
import { errorPlacementDefault } from '../flags';
import uniqueId from 'lodash.uniqueid';

/**
* <FormControl> is an internal component used form components (i.e <TextField>, <Dropdown>, <DateField>, <MonthPicker>)
* It contains logic shared across form components, handling form labels, errors, id generation, and other shared props
* <FormControl> is also exported for advanced design system use cases, where the internal component can be leveraged to build custom form components
* As an internal component, it's subject to more breaking changes. Exercise caution using <FormControl> outside of those special cases
*/

interface FormControlRenderProps {
id: string;
labelId: string;
Expand Down
1 change: 1 addition & 0 deletions packages/design-system/src/components/FormControl/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as FormControl } from './FormControl';
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React from 'react';
import classNames from 'classnames';

/**
* <InlineError> is an internal component used by <FormLabel> and <FormControl>
* <InlineError> is also exported for advanced design system use cases, where the internal component can be leveraged to build custom form components
*/

interface InlineErrorProps {
children?: React.ReactNode;
className?: string;
Expand Down
1 change: 1 addition & 0 deletions packages/design-system/src/components/InlineError/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as InlineError } from './InlineError';
5 changes: 5 additions & 0 deletions packages/design-system/src/components/TextField/TextInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';

/**
* <TextInput> is an internal component used by <TextField>, which wraps it and handles shared form UI like labels, error messages, etc
* <TextInput> is also exported for advanced design system use cases, where the internal component can be leveraged to build custom form components
* As an internal component, it's subject to more breaking changes. Exercise caution using <TextInput> outside of those special cases
*/
export function TextInput(props) {
const {
ariaLabel,
Expand Down
1 change: 1 addition & 0 deletions packages/design-system/src/components/TextField/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as TextField } from './TextField';
export { default as TextInput } from './TextInput';
export { maskValue, unmaskValue } from './maskHelpers';
3 changes: 0 additions & 3 deletions packages/design-system/src/components/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ function getDirectories(paths) {

const ignoredComponents = [
'DateInput',
'FormControl',
'Mask',
'ReviewLink',
'Select',
'Step',
'SubStep',
'StepLink',
'Tab',
'TextInput',
'WrapperDiv',
'VerticalNavItem',
'VerticalNavItemLabel',
Expand Down
2 changes: 2 additions & 0 deletions packages/design-system/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ export * from './ChoiceList';
export * from './DateField';
export * from './Dialog';
export * from './Dropdown';
export * from './FormControl';
export * from './FormLabel';
export * from './HelpDrawer';
export * from './InlineError';
export * from './MonthPicker';
export * from './Review';
export * from './SkipNav';
Expand Down

0 comments on commit fc485c2

Please sign in to comment.