-
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.
Merge branch 'master' into luhan/updateSchema
- Loading branch information
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.