Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d5205a1
[EuiFormControlLayout] Added `isInvalid` prop
Mar 18, 2022
5c72a7a
Padded the `isInvalid` through for some form controls
Mar 18, 2022
a5ad055
Finalized new padding mixin
Mar 18, 2022
8c6a12d
Added a `getFormControlClassNameForIconCount` localized service for c…
Mar 18, 2022
0b1f4a1
Change className output from rendering component-specific to generic …
Mar 18, 2022
2b71e2f
Updating form control usage & styles
Mar 18, 2022
32f3f1e
Fix docs
Mar 18, 2022
fce7b90
REVERT ME: Docs toggles all on
Mar 18, 2022
8a27ecf
Moved service into form_control_layout folder and added tests
Mar 18, 2022
1ac2973
[EuiFormControlLayout] Added `isDropdown` to create and control the a…
Mar 21, 2022
811231f
[EuiColorPicker] Fix usage of EuiFormControlLayout to not double
Mar 21, 2022
8ab25ba
Remove no longer necessary prop comment
Mar 21, 2022
89faf54
Fix Sass import location
Mar 22, 2022
fdca711
Layout docs
Mar 22, 2022
dd3bdac
[EuiSelect] & [EuiSuperSelect] Update to new EuiFormControlLayout props
Mar 22, 2022
2bfd32e
Merge remote-tracking branch 'upstream/main' into form_controls/inval…
Mar 22, 2022
d723d95
[EuiValidatableControl] Add `aria-invalid`
Mar 22, 2022
2effa61
Clean up and CL
Mar 22, 2022
d91bb12
cl again
Mar 22, 2022
d7f83c8
Moved invalid icon to be second to last from dropdown arrow
Mar 23, 2022
2ffd108
Fix math for compress icon spacing/padding
Mar 23, 2022
524cda5
Update src/components/form/form_control_layout/_num_icons.test.ts
cchaos Mar 30, 2022
f3cdc9d
Merge branch 'elastic:main' into form_controls/invalid_icon
cchaos Mar 30, 2022
03a88af
Revert "REVERT ME: Docs toggles all on"
Mar 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src-docs/src/views/color_picker/kitchen_sink.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default () => {
return (
<React.Fragment>
{/* DisplayToggles wrapper for Docs only */}
<DisplayToggles canLoading={false} canPrepend={true} canAppend={true}>
<DisplayToggles canLoading={false} canPrepend canAppend canClear>
<EuiColorPicker color={color} onChange={setColor} />
</DisplayToggles>
<EuiSpacer />
Expand Down
64 changes: 24 additions & 40 deletions src-docs/src/views/form_controls/display_toggles.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { cloneElement, useState, Fragment } from 'react';
import PropTypes from 'prop-types';

import {
EuiFlexGroup,
Expand All @@ -13,18 +12,19 @@ import {
} from '../../../../src/components';

export const DisplayToggles = ({
canIsDisabled,
canDisabled,
canReadOnly,
canLoading,
canCompressed,
canFullWidth,
canPrepend,
canAppend,
canInvalid,
canIsDisabled = false,
canDisabled = true,
canReadOnly = true,
canLoading = true,
canCompressed = true,
canFullWidth = true,
canInvalid = true,
canPrepend = false,
canAppend = false,
canClear = false,
children,
extras,
spacerSize,
spacerSize = 'l',
}) => {
const [disabled, setDisabled] = useState(false);
const [readOnly, setReadOnly] = useState(false);
Expand All @@ -35,6 +35,7 @@ export const DisplayToggles = ({
const [append, setAppend] = useState(false);
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const [invalid, setInvalid] = useState(false);
const [isClearable, setIsClearable] = useState(false);

const canProps = {};
if (canDisabled) canProps.disabled = disabled;
Expand All @@ -46,6 +47,7 @@ export const DisplayToggles = ({
if (canPrepend && prepend) canProps.prepend = 'Prepend';
if (canAppend && append) canProps.append = 'Append';
if (canInvalid) canProps.isInvalid = invalid;
if (canClear) canProps.isClearable = isClearable;

return (
<Fragment>
Expand Down Expand Up @@ -135,7 +137,7 @@ export const DisplayToggles = ({
compressed{' '}
<EuiToolTip content="Compressed usages are very specific. Click to view full compressed documentation">
<a href="#/forms/compressed-forms">
<EuiIcon type="help" />
<EuiIcon type="help" aria-label="help" />
</a>
</EuiToolTip>
</span>
Expand Down Expand Up @@ -165,6 +167,16 @@ export const DisplayToggles = ({
/>
</EuiFlexItem>
)}
{canClear && (
<EuiFlexItem grow={false}>
<EuiSwitch
compressed
label={'clearable'}
checked={isClearable}
onChange={(e) => setIsClearable(e.target.checked)}
/>
</EuiFlexItem>
)}
{extras &&
extras.map((extra, index) => {
return (
Expand All @@ -179,31 +191,3 @@ export const DisplayToggles = ({
</Fragment>
);
};

DisplayToggles.propTypes = {
canIsDisabled: PropTypes.bool,
canDisabled: PropTypes.bool,
canReadOnly: PropTypes.bool,
canLoading: PropTypes.bool,
canCompressed: PropTypes.bool,
canFullWidth: PropTypes.bool,
canPrepend: PropTypes.bool,
canAppend: PropTypes.bool,
canInvalid: PropTypes.bool,
extras: PropTypes.arrayOf(PropTypes.node),
// Manually building the spacer array to avoid having to import Spacer into codesandbox
spacerSize: PropTypes.oneOf(['xs', 's', 'm', 'l', 'xl', 'xxl']),
};

DisplayToggles.defaultProps = {
canIsDisabled: false,
canDisabled: true,
canReadOnly: true,
canLoading: true,
canCompressed: true,
canFullWidth: true,
canInvalid: true,
canPrepend: false,
canAppend: false,
spacerSize: 'l',
};
Original file line number Diff line number Diff line change
@@ -1,193 +1,144 @@
import React, { Fragment } from 'react';
import React from 'react';

import {
EuiFormControlLayout,
EuiSpacer,
EuiFormLabel,
EuiButtonEmpty,
EuiText,
} from '../../../../src/components';
import { useGeneratedHtmlId } from '../../../../src/services';
useGeneratedHtmlId,
useEuiTheme,
EuiFieldText,
} from '../../../../src';

export default () => {
const { euiTheme } = useEuiTheme();
const labelInputId = useGeneratedHtmlId({ prefix: 'labelInput' });
const readOnlyInputId = useGeneratedHtmlId({ prefix: 'readOnlyInput' });

return (
<Fragment>
<div
css={{
display: 'inline-flex',
flexWrap: 'wrap',
gap: euiTheme.size.l,
}}
>
<EuiFormControlLayout icon="search">
<input
type="text"
className="euiFieldText"
<EuiFieldText
type="search"
controlOnly
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout isLoading>
<input
<EuiFieldText
type="text"
className="euiFieldText"
controlOnly
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout clear={{ onClick: () => {} }}>
<input
<EuiFieldText
type="text"
className="euiFieldText"
controlOnly
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout isLoading clear={{ onClick: () => {} }}>
<input
<EuiFormControlLayout isInvalid>
<EuiFieldText
type="text"
className="euiFieldText"
controlOnly
isInvalid
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout isLoading icon="search">
<input
type="text"
className="euiFieldText"
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout
isLoading
icon={{ type: 'arrowDown', side: 'right' }}
>
<input
type="text"
className="euiFieldText"
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout clear={{ onClick: () => {} }} icon="search">
<input
type="text"
className="euiFieldText"
<EuiFieldText
type="search"
controlOnly
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout
clear={{ onClick: () => {} }}
icon={{ type: 'arrowDown', side: 'right' }}
>
<input
<EuiFormControlLayout isLoading isDropdown>
<EuiFieldText
type="text"
className="euiFieldText"
controlOnly
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout
isLoading
clear={{ onClick: () => {} }}
icon="search"
isDropdown
icon={{ type: 'stopFilled', color: 'success', side: 'left' }}
>
<input
<EuiFieldText
type="text"
className="euiFieldText"
controlOnly
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout
isLoading
clear={{ onClick: () => {} }}
icon={{ type: 'arrowDown', side: 'right' }}
icon={{ type: 'bolt', side: 'right' }}
isDropdown
>
<input
<EuiFieldText
type="text"
className="euiFieldText"
controlOnly
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout
isLoading
clear={{ onClick: () => {} }}
icon="search"
>
<input
type="text"
className="euiFieldText"
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout
prepend={<EuiFormLabel htmlFor={labelInputId}>Label</EuiFormLabel>}
>
<input
<EuiFieldText
type="text"
className="euiFieldText euiFieldText--inGroup"
className="euiFieldText--inGroup"
controlOnly
id={labelInputId}
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout
readOnly
prepend={
<EuiFormLabel htmlFor={readOnlyInputId}>Read only</EuiFormLabel>
}
append={<EuiButtonEmpty size="xs">Button</EuiButtonEmpty>}
>
<input
<EuiFieldText
type="text"
className="euiFieldText euiFieldText--inGroup"
className="euiFieldText--inGroup"
id={readOnlyInputId}
controlOnly
readOnly
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout
append={
<EuiText size="xs">
<strong>%</strong>
</EuiText>
}
>
<input
<EuiFieldText
type="number"
className="euiFieldNumber euiFieldNumber--inGroup"
className="euiFieldNumber--inGroup"
controlOnly
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>

<EuiSpacer size="m" />

<EuiFormControlLayout
isLoading
clear={{ onClick: () => {} }}
Expand All @@ -197,12 +148,13 @@ export default () => {
</EuiButtonEmpty>
}
>
<input
<EuiFieldText
type="text"
className="euiFieldText euiFieldText--inGroup"
className="euiFieldText--inGroup"
controlOnly
aria-label="Use aria labels when no actual label is in use"
/>
</EuiFormControlLayout>
</Fragment>
</div>
);
};
Loading