From 13c662355d7f3c9add4680883f4c2280e3c2608e Mon Sep 17 00:00:00 2001
From: Anish Aggarwal
Date: Mon, 9 Mar 2020 14:53:27 +0530
Subject: [PATCH 01/11] added renderForm prop to EuiForm
---
CHANGELOG.md | 1 +
src-docs/src/views/form_layouts/form_rows.js | 2 +-
src/components/form/form.test.tsx | 6 ++++
src/components/form/form.tsx | 29 ++++++++++++++++++--
4 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 04ca018c2f7..48e8421041c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)
+- Added a renderForm prop to `EuiForm` to render a `
),
props: {
diff --git a/src/components/form/form.tsx b/src/components/form/form.tsx
index 4a2cbce5820..f7f5000b6a6 100644
--- a/src/components/form/form.tsx
+++ b/src/components/form/form.tsx
@@ -1,17 +1,14 @@
-import React, {
- FunctionComponent,
- ReactNode,
- HTMLAttributes,
- FormEvent,
-} from 'react';
+import React, { FunctionComponent, ReactNode, HTMLAttributes } from 'react';
import classNames from 'classnames';
import { EuiCallOut } from '../call_out';
import { EuiI18n } from '../i18n';
-import { CommonProps } from '../common';
+import { CommonProps, ExclusiveUnion } from '../common';
export type EuiFormProps = CommonProps &
- HTMLAttributes &
- HTMLAttributes & {
+ ExclusiveUnion<
+ HTMLAttributes,
+ HTMLAttributes
+ > & {
isInvalid?: boolean;
/**
* Which HTML element to render
@@ -26,7 +23,6 @@ export const EuiForm: FunctionComponent = ({
isInvalid,
error,
component = 'div',
- onSubmit,
...rest
}) => {
const classes = classNames('euiForm', className);
@@ -65,20 +61,10 @@ export const EuiForm: FunctionComponent = ({
);
}
- const relObj: {
- onSubmit?:
- | (((event: FormEvent) => void) &
- ((event: FormEvent) => void))
- | undefined;
- } = {};
-
- if (component === 'form') {
- relObj.onSubmit = onSubmit;
- }
const Element = component;
return (
-
+
{optionalErrorAlert}
{children}
From d9fa948219732b97e12ef7efa35ed87c78318a36 Mon Sep 17 00:00:00 2001
From: Anish Aggarwal
Date: Thu, 12 Mar 2020 10:04:07 +0530
Subject: [PATCH 10/11] fixed errors
---
CHANGELOG.md | 1 -
.../form/__snapshots__/form.test.tsx.snap | 2 +-
src/components/form/form.tsx | 13 +++++++++----
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 001bf6ac861..27ed058ab33 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,7 +3,6 @@
- Exported `dateFormatAliases` as a part of the public API ([#3043](https://github.com/elastic/eui/pull/3043))
- Exported `EuiTextProps` type definition ([#3039](https://github.com/elastic/eui/pull/3039))
- Added a `component` prop to `EuiForm` to render a `