- Form elements will automatically flex to a max-width of{' '}
- 400px. You can optionally pass the{' '}
- fullWidth prop to the row and form control to
- expand to their container. This should be done rarely and usually you
- will only need it for isolated controls like search bars and sliders.
-
+ <>
+
+ Form elements will automatically flex to a max-width of{' '}
+ 400px. You can optionally pass the{' '}
+ fullWidth prop to the row and form control to
+ expand to their container. This should be done rarely and usually
+ you will only need it for isolated controls like search bars and
+ sliders.
+
+
Date: Fri, 9 Sep 2022 21:01:27 -0500
Subject: [PATCH 03/10] remove unnecessary text
---
src-docs/src/views/form_layouts/form_layouts_example.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-docs/src/views/form_layouts/form_layouts_example.js b/src-docs/src/views/form_layouts/form_layouts_example.js
index 05e0a53fbf4..b66fd87d6d4 100644
--- a/src-docs/src/views/form_layouts/form_layouts_example.js
+++ b/src-docs/src/views/form_layouts/form_layouts_example.js
@@ -103,7 +103,7 @@ export const FormLayoutsExample = {
`,
},
{
- title: 'Full-width (manual)',
+ title: 'Full-width',
text: (
<>
From 737645068e1a111b67378bdf0b4b71793f8e0dee Mon Sep 17 00:00:00 2001
From: spalger
Date: Fri, 9 Sep 2022 21:11:13 -0500
Subject: [PATCH 04/10] update changelog verbiage
---
upcoming_changelogs/6229.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/upcoming_changelogs/6229.md b/upcoming_changelogs/6229.md
index 4392d1524c4..b3383eddaed 100644
--- a/upcoming_changelogs/6229.md
+++ b/upcoming_changelogs/6229.md
@@ -1 +1 @@
-- Added support for `fullWidth` prop on EuiForm, which will be applied to all form elements rendered within
+- Added support for `fullWidth` prop on EuiForm, which will be the default for all rows/controls within
From fa97aa7a2a59453da3e174ef7de55d4a9e9fbdae Mon Sep 17 00:00:00 2001
From: spalger
Date: Sat, 10 Sep 2022 04:12:21 +0000
Subject: [PATCH 05/10] define default values for docs which can't be
determined by react-view anymore
---
.../described_form_group/described_form_group.tsx | 4 ++++
src/components/form/field_number/field_number.tsx | 9 +++++++++
.../form/field_password/field_password.tsx | 6 ++++++
src/components/form/field_search/field_search.tsx | 5 +++++
src/components/form/field_text/field_text.tsx | 5 +++++
src/components/form/file_picker/file_picker.tsx | 5 +++++
src/components/form/form.tsx | 1 +
.../form_control_layout/form_control_layout.tsx | 5 +++++
src/components/form/form_row/form_row.tsx | 5 +++++
src/components/form/range/dual_range.tsx | 5 +++++
src/components/form/range/range.tsx | 5 +++++
src/components/form/range/range_wrapper.tsx | 5 +++++
src/components/form/select/select.tsx | 10 ++++++++++
.../form/super_select/super_select_control.tsx | 14 ++++++++++++++
src/components/form/text_area/text_area.tsx | 6 ++++++
15 files changed, 90 insertions(+)
diff --git a/src/components/form/described_form_group/described_form_group.tsx b/src/components/form/described_form_group/described_form_group.tsx
index a71635a637f..5546587adc4 100644
--- a/src/components/form/described_form_group/described_form_group.tsx
+++ b/src/components/form/described_form_group/described_form_group.tsx
@@ -30,18 +30,21 @@ export type EuiDescribedFormGroupProps = CommonProps &
children?: ReactNode;
/**
* Passed to `EuiFlexGroup`.
+ * @default l
*/
gutterSize?: EuiFlexGroupGutterSize;
/**
* Expand to fill 100% of the parent.
* Defaults to `fullWidth` prop of ``.
* Default max-width is 800px.
+ * @default false
*/
fullWidth?: boolean;
/**
* Width ratio of description column compared to field column.
* Can be used in conjunction with `fullWidth` and
* may require `fullWidth` to be applied to child elements.
+ * @default half
*/
ratio?: 'half' | 'third' | 'quarter';
/**
@@ -50,6 +53,7 @@ export type EuiDescribedFormGroupProps = CommonProps &
title: EuiTitleProps['children'];
/**
* Adjust the visual `size` of the EuiTitle that wraps `title`.
+ * @default xs
*/
titleSize?: EuiTitleSize;
/**
diff --git a/src/components/form/field_number/field_number.tsx b/src/components/form/field_number/field_number.tsx
index 07feafaed1c..777e287f379 100644
--- a/src/components/form/field_number/field_number.tsx
+++ b/src/components/form/field_number/field_number.tsx
@@ -28,7 +28,15 @@ export type EuiFieldNumberProps = Omit<
CommonProps & {
icon?: IconType;
isInvalid?: boolean;
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
+ /**
+ * @default false
+ */
isLoading?: boolean;
readOnly?: boolean;
min?: number;
@@ -61,6 +69,7 @@ export type EuiFieldNumberProps = Omit<
/**
* when `true` creates a shorter height input
+ * @default false
*/
compressed?: boolean;
};
diff --git a/src/components/form/field_password/field_password.tsx b/src/components/form/field_password/field_password.tsx
index 772e522de2e..461385f1558 100644
--- a/src/components/form/field_password/field_password.tsx
+++ b/src/components/form/field_password/field_password.tsx
@@ -33,6 +33,11 @@ export type EuiFieldPasswordProps = Omit<
> &
CommonProps & {
isInvalid?: boolean;
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
isLoading?: boolean;
compressed?: boolean;
@@ -55,6 +60,7 @@ export type EuiFieldPasswordProps = Omit<
* Change the `type` of input for manually handling obfuscation.
* The `dual` option adds the ability to toggle the obfuscation of the input by
* adding an icon button as the first `append` element
+ * @default password
*/
type?: 'password' | 'text' | 'dual';
diff --git a/src/components/form/field_search/field_search.tsx b/src/components/form/field_search/field_search.tsx
index 525e34b3741..b3c9bc595ef 100644
--- a/src/components/form/field_search/field_search.tsx
+++ b/src/components/form/field_search/field_search.tsx
@@ -29,6 +29,11 @@ export interface EuiFieldSearchProps
placeholder?: string;
value?: string;
isInvalid?: boolean;
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
isLoading?: boolean;
/**
diff --git a/src/components/form/field_text/field_text.tsx b/src/components/form/field_text/field_text.tsx
index 1c6e6a04c01..5c75564de71 100644
--- a/src/components/form/field_text/field_text.tsx
+++ b/src/components/form/field_text/field_text.tsx
@@ -23,6 +23,11 @@ export type EuiFieldTextProps = InputHTMLAttributes &
CommonProps & {
icon?: EuiFormControlLayoutProps['icon'];
isInvalid?: boolean;
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
isLoading?: boolean;
readOnly?: boolean;
diff --git a/src/components/form/file_picker/file_picker.tsx b/src/components/form/file_picker/file_picker.tsx
index 80c7f5efdd4..ea68af5751d 100644
--- a/src/components/form/file_picker/file_picker.tsx
+++ b/src/components/form/file_picker/file_picker.tsx
@@ -53,6 +53,11 @@ export interface EuiFilePickerProps
* `large` for taller size
*/
display?: EuiFilePickerDisplay;
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
isInvalid?: boolean;
isLoading?: boolean;
diff --git a/src/components/form/form.tsx b/src/components/form/form.tsx
index e7da31e41a1..a3d653f72d1 100644
--- a/src/components/form/form.tsx
+++ b/src/components/form/form.tsx
@@ -40,6 +40,7 @@ export type EuiFormProps = CommonProps &
* default to taking up 100% of the width of their continer. You
* can specify `fullWidth={false}` on individual rows/controls to
* disable this behavior for specific components.
+ * @default false
*/
fullWidth?: boolean;
};
diff --git a/src/components/form/form_control_layout/form_control_layout.tsx b/src/components/form/form_control_layout/form_control_layout.tsx
index 827a81cd628..c585be791ac 100644
--- a/src/components/form/form_control_layout/form_control_layout.tsx
+++ b/src/components/form/form_control_layout/form_control_layout.tsx
@@ -43,6 +43,11 @@ export type EuiFormControlLayoutProps = CommonProps &
children?: ReactNode;
icon?: EuiFormControlLayoutIconsProps['icon'];
clear?: EuiFormControlLayoutIconsProps['clear'];
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
isLoading?: boolean;
isDisabled?: boolean;
diff --git a/src/components/form/form_row/form_row.tsx b/src/components/form/form_row/form_row.tsx
index fdf5b09ec43..e8b19680f9b 100644
--- a/src/components/form/form_row/form_row.tsx
+++ b/src/components/form/form_row/form_row.tsx
@@ -57,6 +57,11 @@ type EuiFormRowCommonProps = CommonProps & {
*/
display?: EuiFormRowDisplayKeys;
hasEmptyLabelSpace?: boolean;
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
/**
* IDs of additional elements that should be part of children's `aria-describedby`
diff --git a/src/components/form/range/dual_range.tsx b/src/components/form/range/dual_range.tsx
index 16f955e5ecd..d986f6ad7fa 100644
--- a/src/components/form/range/dual_range.tsx
+++ b/src/components/form/range/dual_range.tsx
@@ -56,6 +56,11 @@ export interface EuiDualRangeProps
| React.KeyboardEvent
| React.KeyboardEvent
) => void;
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
isInvalid?: boolean;
/**
diff --git a/src/components/form/range/range.tsx b/src/components/form/range/range.tsx
index 2b49ee1810e..81f74f33f93 100644
--- a/src/components/form/range/range.tsx
+++ b/src/components/form/range/range.tsx
@@ -30,6 +30,11 @@ export interface EuiRangeProps
Omit {
compressed?: boolean;
readOnly?: boolean;
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
id?: string;
/**
diff --git a/src/components/form/range/range_wrapper.tsx b/src/components/form/range/range_wrapper.tsx
index bf20a88bbe4..ceb7bf9f261 100644
--- a/src/components/form/range/range_wrapper.tsx
+++ b/src/components/form/range/range_wrapper.tsx
@@ -14,6 +14,11 @@ import { useFormContext } from '../eui_form_context';
export interface EuiRangeWrapperProps
extends CommonProps,
HTMLAttributes {
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
compressed?: boolean;
}
diff --git a/src/components/form/select/select.tsx b/src/components/form/select/select.tsx
index 1d280cd3a95..cd75d3fc560 100644
--- a/src/components/form/select/select.tsx
+++ b/src/components/form/select/select.tsx
@@ -32,13 +32,22 @@ export type EuiSelectProps = Omit<
'value'
> &
CommonProps & {
+ /**
+ * @default []
+ */
options?: EuiSelectOption[];
isInvalid?: boolean;
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
isLoading?: boolean;
/**
* Simulates no selection by creating an empty, selected, hidden first option
+ * @default false
*/
hasNoInitialSelection?: boolean;
inputRef?: Ref;
@@ -46,6 +55,7 @@ export type EuiSelectProps = Omit<
/**
* when `true` creates a shorter height input
+ * @default false
*/
compressed?: boolean;
diff --git a/src/components/form/super_select/super_select_control.tsx b/src/components/form/super_select/super_select_control.tsx
index 283b3d4e554..5f892b4f377 100644
--- a/src/components/form/super_select/super_select_control.tsx
+++ b/src/components/form/super_select/super_select_control.tsx
@@ -36,9 +36,23 @@ export interface EuiSuperSelectOption {
export interface EuiSuperSelectControlProps
extends CommonProps,
Omit, 'value'> {
+ /**
+ * @default false
+ */
compressed?: boolean;
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
+ /**
+ * @default false
+ */
isInvalid?: boolean;
+ /**
+ * @default false
+ */
isLoading?: boolean;
readOnly?: boolean;
diff --git a/src/components/form/text_area/text_area.tsx b/src/components/form/text_area/text_area.tsx
index 648c0bc25e8..e9ee50fa4be 100644
--- a/src/components/form/text_area/text_area.tsx
+++ b/src/components/form/text_area/text_area.tsx
@@ -15,11 +15,17 @@ import { useFormContext } from '../eui_form_context';
export type EuiTextAreaProps = TextareaHTMLAttributes &
CommonProps & {
isInvalid?: boolean;
+ /**
+ * Expand to fill 100% of the parent.
+ * Defaults to `fullWidth` prop of ``.
+ * @default false
+ */
fullWidth?: boolean;
compressed?: boolean;
/**
* Which direction, if at all, should the textarea resize
+ * @default vertical
*/
resize?: keyof typeof resizeToClassNameMap;
From 53950f9abe9b2905085021d8b258c809c94062e6 Mon Sep 17 00:00:00 2001
From: spalger
Date: Tue, 27 Sep 2022 19:15:29 -0500
Subject: [PATCH 06/10] add dedicated docs example for fullWidth via context
---
.../form_layouts/form_layouts_example.js | 50 ++++++++++++------
.../form_layouts/full_width_via_context.js | 51 +++++++++++++++++++
2 files changed, 86 insertions(+), 15 deletions(-)
create mode 100644 src-docs/src/views/form_layouts/full_width_via_context.js
diff --git a/src-docs/src/views/form_layouts/form_layouts_example.js b/src-docs/src/views/form_layouts/form_layouts_example.js
index b66fd87d6d4..c47ad96f90e 100644
--- a/src-docs/src/views/form_layouts/form_layouts_example.js
+++ b/src-docs/src/views/form_layouts/form_layouts_example.js
@@ -25,6 +25,9 @@ const describedFormGroupRatioSource = require('!!raw-loader!./described_form_gro
import FullWidth from './full_width';
const fullWidthSource = require('!!raw-loader!./full_width');
+import FullWidthViaContext from './full_width_via_context';
+const fullWidthViaContextSource = require('!!raw-loader!./full_width_via_context');
+
import Inline from './inline';
const inlineSource = require('!!raw-loader!./inline');
@@ -105,21 +108,13 @@ export const FormLayoutsExample = {
{
title: 'Full-width',
text: (
- <>
-
- Form elements will automatically flex to a max-width of{' '}
- 400px. You can optionally pass the{' '}
- fullWidth prop to the row and form control to
- expand to their container. This should be done rarely and usually
- you will only need it for isolated controls like search bars and
- sliders.
-
-
- To set all the row and controls in a form to{' '}
- fullWidth, specify the prop on the root{' '}
- EuiForm component.
-
- >
+
+ Form elements will automatically flex to a max-width of{' '}
+ 400px. You can optionally pass the{' '}
+ fullWidth prop to the row and form control to
+ expand to their container. This should be done rarely and usually you
+ will only need it for isolated controls like search bars and sliders.
+
),
props: {
EuiFormRow,
@@ -138,6 +133,31 @@ export const FormLayoutsExample = {
>
`,
+ },
+ {
+ title: 'Global Full-width',
+ text: (
+
+ To set all the row and controls in a form to{' '}
+ fullWidth, specify the prop on the root{' '}
+ EuiForm component.
+
+ ),
+ props: {
+ EuiForm,
+ },
+ demo: ,
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: fullWidthViaContextSource,
+ },
+ ],
+ snippet: `
+
+
+
+`,
},
{
title: 'Inline',
diff --git a/src-docs/src/views/form_layouts/full_width_via_context.js b/src-docs/src/views/form_layouts/full_width_via_context.js
new file mode 100644
index 00000000000..eb5af28f994
--- /dev/null
+++ b/src-docs/src/views/form_layouts/full_width_via_context.js
@@ -0,0 +1,51 @@
+import React from 'react';
+
+import {
+ EuiForm,
+ EuiFieldSearch,
+ EuiRange,
+ EuiTextArea,
+ EuiFormRow,
+ EuiFlexGroup,
+ EuiFlexItem,
+ EuiSpacer,
+ EuiButton,
+} from '../../../../src/components';
+
+export default () => (
+ {
+ e.preventDefault();
+ }}
+ >
+
+
+
+
+
+ Search
+
+
+
+
+
+
+
+
+
+
+
+
+
+);
From 301afc4a7528ad755362661e45ab580a6d02a95f Mon Sep 17 00:00:00 2001
From: spalger
Date: Wed, 28 Sep 2022 01:30:31 +0000
Subject: [PATCH 07/10] expand and customize the example a bit more
---
.../form_layouts/full_width_via_context.js | 51 ---------
.../form_layouts/full_width_via_context.tsx | 101 ++++++++++++++++++
2 files changed, 101 insertions(+), 51 deletions(-)
delete mode 100644 src-docs/src/views/form_layouts/full_width_via_context.js
create mode 100644 src-docs/src/views/form_layouts/full_width_via_context.tsx
diff --git a/src-docs/src/views/form_layouts/full_width_via_context.js b/src-docs/src/views/form_layouts/full_width_via_context.js
deleted file mode 100644
index eb5af28f994..00000000000
--- a/src-docs/src/views/form_layouts/full_width_via_context.js
+++ /dev/null
@@ -1,51 +0,0 @@
-import React from 'react';
-
-import {
- EuiForm,
- EuiFieldSearch,
- EuiRange,
- EuiTextArea,
- EuiFormRow,
- EuiFlexGroup,
- EuiFlexItem,
- EuiSpacer,
- EuiButton,
-} from '../../../../src/components';
-
-export default () => (
- {
- e.preventDefault();
- }}
- >
-
-
-
-
-
- Search
-
-
-
-
-
-
-
-
-
-
-
-
-
-);
diff --git a/src-docs/src/views/form_layouts/full_width_via_context.tsx b/src-docs/src/views/form_layouts/full_width_via_context.tsx
new file mode 100644
index 00000000000..8974b9a088a
--- /dev/null
+++ b/src-docs/src/views/form_layouts/full_width_via_context.tsx
@@ -0,0 +1,101 @@
+import React from 'react';
+
+import {
+ EuiForm,
+ EuiFieldSearch,
+ EuiRange,
+ EuiTextArea,
+ EuiFormRow,
+ EuiFlexGroup,
+ EuiFlexItem,
+ EuiSpacer,
+ EuiDescribedFormGroup,
+ EuiSelect,
+ EuiFilePicker,
+ EuiButton,
+} from '../../../../src/components';
+
+export default () => {
+ const [range, setRange] = React.useState(42);
+
+ return (
+ {
+ e.preventDefault();
+ }}
+ >
+
+
+
+
+
+ Search
+
+
+
+
+
+
+ {
+ if (e.target instanceof HTMLInputElement) {
+ setRange(Number.parseInt(e.target.value, 10));
+ }
+ }}
+ />
+
+
+
+
+ Works with all form controls and layout components}
+ description={
+ <>
+
+ Any component that supports the fullWidth
prop that
+ is.
+
+
+ Make sure it is appropriate at all of the widths that the
+ container can take. There are many situations where a full-width
+ form is inappropriate.
+
+ >
+ }
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
From bca771ec5c023f308c587d1e17fe1b67818352b6 Mon Sep 17 00:00:00 2001
From: spalger
Date: Wed, 28 Sep 2022 14:01:01 +0000
Subject: [PATCH 08/10] remove snapshot test, just validate fullWidth class
exists
---
.../__snapshots__/dual_range.test.tsx.snap | 34 -------------------
src/components/form/range/dual_range.test.tsx | 10 +++++-
2 files changed, 9 insertions(+), 35 deletions(-)
diff --git a/src/components/form/range/__snapshots__/dual_range.test.tsx.snap b/src/components/form/range/__snapshots__/dual_range.test.tsx.snap
index c2013a095ce..62be3a9f356 100644
--- a/src/components/form/range/__snapshots__/dual_range.test.tsx.snap
+++ b/src/components/form/range/__snapshots__/dual_range.test.tsx.snap
@@ -52,40 +52,6 @@ exports[`EuiDualRange allows value prop to accept numbers 1`] = `