-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add dynamic choices to Choice Prompt (#1777)
* Update validation and choice array ui * Updated string array * Updated regex pattern * Updated array styles * Style cleanup * Fixed string array test * Fixed ObjectArray tests * Updated request header object * Small change to custom object field * Fixed styling * Updated dialogs * Fix margin issue * Updated callback dependencies * Added error message * Updated callback dependencies * Fixed margin issues * Fixed styles * Fixed transparent border issue * Created Dyncamic and Static Choices components * Added Static Choices * Added ExpressionWidget to Dynamic Choice and updated IChoice type
- Loading branch information
1 parent
7594a26
commit ce75811
Showing
9 changed files
with
363 additions
and
244 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
38 changes: 38 additions & 0 deletions
38
...kages/extensions/obiformeditor/src/Form/fields/PromptField/ChoiceInput/DynamicChoices.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,38 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
/** @jsx jsx */ | ||
import { jsx } from '@emotion/core'; | ||
import React from 'react'; | ||
import { IChoice } from '@bfc/shared'; | ||
import { JSONSchema6 } from 'json-schema'; | ||
|
||
import { ExpressionWidget } from '../../../widgets/ExpressionWidget'; | ||
import { FormContext } from '../../../types'; | ||
|
||
interface DynamicChoicesProps { | ||
formContext: FormContext; | ||
formData?: any; | ||
onChange?: (value: IChoice) => void; | ||
schema: JSONSchema6; | ||
} | ||
|
||
export const DynamicChoices: React.FC<DynamicChoicesProps> = props => { | ||
const { | ||
formContext, | ||
formData = '', | ||
onChange, | ||
schema, | ||
schema: { description }, | ||
} = props; | ||
return ( | ||
<ExpressionWidget | ||
formContext={formContext} | ||
onChange={(_, value = '') => onChange && onChange(value)} | ||
options={{ hideLabel: true }} | ||
placeholder={description} | ||
value={formData} | ||
schema={schema} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.