-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Align with the new design in form for inline error display (#1683)
* validation ui refine * revert expression err message show logic * use format-message for err message * Add twoSettingField * refactor editable field to use mergeStyleSets * clean up ExpressionWidget * add missing format message * correct usage of format message * update focus border style for rich editor * validate LG and LU on mount in form needed to get error UI * fix form editor overflow issues
- Loading branch information
1 parent
a470770
commit 997df62
Showing
16 changed files
with
264 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
.ObjectItem .ObjectItemField { | ||
flex: 1; | ||
overflow: hidden; | ||
padding: 0px 18px; | ||
margin: 10px 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/twoSettingFields.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* eslint-disable format-message/literal-pattern */ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
/** @jsx jsx */ | ||
import { jsx } from '@emotion/core'; | ||
import React, { useState } from 'react'; | ||
import formatMessage from 'format-message'; | ||
import { FieldProps } from '@bfcomposer/react-jsonschema-form'; | ||
import { MicrosoftInputDialog } from '@bfc/shared'; | ||
|
||
import { TextWidget } from '../../widgets'; | ||
|
||
import { field, settingsFieldHalf, settingsFields, settingsFieldFull, settingsFieldValidation } from './styles'; | ||
import { PromptFieldChangeHandler, GetSchema, InputDialogKeys } from './types'; | ||
|
||
interface TwoSettingFieldsProps extends FieldProps<MicrosoftInputDialog> { | ||
onChange: PromptFieldChangeHandler; | ||
getSchema: GetSchema; | ||
fields: { [key: string]: InputDialogKeys | string }[]; | ||
} | ||
export const TwoSettingFields: React.FC<TwoSettingFieldsProps> = props => { | ||
const { fields, formData, idSchema, getSchema, onChange, errorSchema } = props; | ||
const [errorMessage, setErrorMessage] = useState<JSX.Element | string | undefined>(); | ||
|
||
const onValidate = (err?: JSX.Element | string) => { | ||
setErrorMessage(err); | ||
}; | ||
|
||
return ( | ||
<div css={settingsFields}> | ||
{fields.map((settingField, index) => ( | ||
<div key={index} css={[field, settingsFieldHalf]}> | ||
<TextWidget | ||
onChange={onChange(settingField.name as InputDialogKeys)} | ||
schema={getSchema(settingField.name as InputDialogKeys)} | ||
id={idSchema[settingField.name].__id} | ||
value={formData[settingField.name]} | ||
label={formatMessage(settingField.title as string)} | ||
formContext={props.formContext} | ||
rawErrors={errorSchema[settingField.name] && errorSchema[settingField.name].__errors} | ||
hiddenErrMessage={true} | ||
onValidate={onValidate} | ||
/> | ||
</div> | ||
))} | ||
<div css={[field, settingsFieldFull, settingsFieldValidation]}>{errorMessage}</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
Composer/packages/extensions/obiformeditor/src/Form/fields/RecognizerField/styles.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Composer/packages/extensions/obiformeditor/src/Form/fields/RecognizerField/styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { css } from '@emotion/core'; | ||
|
||
// offset ObjectField's margin | ||
export const regexEditorContainer = css` | ||
margin: 0 -18px -26px -18px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.