This repository was archived by the owner on Jul 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 375
feat: Adds UI pivotFieldsets to UI Options #4265
Merged
a-b-r-o-w-n
merged 6 commits into
microsoft:main
from
tdurnford:feature/pivot-field-sets
Sep 30, 2020
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8dcae8b
pivot field sets
tdurnford edc8fb0
Merge branch 'main' into feature/pivot-field-sets
tdurnford e1334ce
add jsx
tdurnford 01cf73b
Merge branch 'main' into feature/pivot-field-sets
tdurnford 24fc7ea
updated type
tdurnford 589b4a7
Merge branch 'main' into feature/pivot-field-sets
tdurnford File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Composer/packages/adaptive-form/src/AdaptiveFormContext.ts
This file contains hidden or 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,16 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { createContext, useContext } from 'react'; | ||
| import { JSONSchema7 } from '@bfc/extension-client'; | ||
|
|
||
| interface IAdaptiveFormContext { | ||
| focusedTab?: string; | ||
| baseSchema: JSONSchema7; | ||
| onFocusedTab?: (_: string) => void; | ||
| } | ||
|
|
||
| export const AdaptiveFormContext = createContext<IAdaptiveFormContext>({ baseSchema: {} }); | ||
| export const useAdaptiveFormContext = () => useContext(AdaptiveFormContext); | ||
|
|
||
| export default AdaptiveFormContext; | ||
This file contains hidden or 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 hidden or 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
52 changes: 52 additions & 0 deletions
52
Composer/packages/adaptive-form/src/components/fields/PivotFieldsets.tsx
This file contains hidden or 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,52 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import React from 'react'; | ||
| import { FieldProps } from '@bfc/extension-client'; | ||
| import { IPivotStyles, Pivot, PivotItem, PivotLinkSize } from 'office-ui-fabric-react/lib/components/Pivot'; | ||
|
|
||
| import { getFieldsets } from '../../utils'; | ||
| import { useAdaptiveFormContext } from '../../AdaptiveFormContext'; | ||
|
|
||
| import { ObjectField } from './ObjectField'; | ||
|
|
||
| const styles: { tabs: Partial<IPivotStyles> } = { | ||
| tabs: { | ||
| root: { | ||
| display: 'flex', | ||
| padding: '0 18px', | ||
| }, | ||
| link: { | ||
| flex: 1, | ||
| }, | ||
| linkIsSelected: { | ||
| flex: 1, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| const PivotFieldsets: React.FC<FieldProps<object>> = (props) => { | ||
| const { schema, uiOptions: baseUiOptions, value } = props; | ||
| const { focusedTab, onFocusedTab: handleFocusTab } = useAdaptiveFormContext(); | ||
| const fieldsets = getFieldsets(schema, baseUiOptions, value); | ||
|
|
||
| const handleTabChange = (item?: PivotItem) => { | ||
| if (item?.props.itemKey && handleFocusTab) { | ||
| handleFocusTab(item.props.itemKey); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div> | ||
| <Pivot linkSize={PivotLinkSize.large} selectedKey={focusedTab} styles={styles.tabs} onLinkClick={handleTabChange}> | ||
| {fieldsets.map(({ schema, uiOptions, title, itemKey }) => ( | ||
| <PivotItem key={itemKey} headerText={typeof title === 'function' ? title(value) : title} itemKey={itemKey}> | ||
| <ObjectField {...props} schema={schema} uiOptions={uiOptions} /> | ||
| </PivotItem> | ||
| ))} | ||
| </Pivot> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export { PivotFieldsets }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
47 changes: 47 additions & 0 deletions
47
Composer/packages/ui-plugins/prompts/src/ExpectedResponsesField.tsx
This file contains hidden or 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,47 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import React from 'react'; | ||
| import { FieldLabel, useAdaptiveFormContext } from '@bfc/adaptive-form'; | ||
| import { FieldProps, useRecognizerConfig, useShellApi } from '@bfc/extension-client'; | ||
| import formatMessage from 'format-message'; | ||
| import { LuMetaData, LuType } from '@bfc/shared'; | ||
|
|
||
| const expectedResponsesPlaceholder = () => | ||
| formatMessage(`> add some expected user responses: | ||
| > - Please remind me to '{itemTitle=buy milk}' | ||
| > - remind me to '{itemTitle}' | ||
| > - add '{itemTitle}' to my todo list | ||
| > | ||
| > entity definitions: | ||
| > @ ml itemTitle | ||
| `); | ||
|
|
||
| const ExpectedResponsesField: React.FC<FieldProps> = (props) => { | ||
| const { id, description } = props; | ||
| const { designerId } = useShellApi(); | ||
| const { currentRecognizer } = useRecognizerConfig(); | ||
| const { baseSchema: schema } = useAdaptiveFormContext(); | ||
|
|
||
| const { const: $kind } = schema?.properties?.$kind as { const: string }; | ||
|
|
||
| const intentName = new LuMetaData(new LuType($kind).toString(), designerId).toString(); | ||
| const label = formatMessage('Expected responses (intent: #{intentName})', { intentName }); | ||
|
|
||
| const Editor = currentRecognizer?.intentEditor; | ||
|
|
||
| return Editor ? ( | ||
| <React.Fragment> | ||
| <FieldLabel description={description} id={id} label={label} /> | ||
| <Editor | ||
| {...props} | ||
| placeholder={expectedResponsesPlaceholder()} | ||
| schema={schema} | ||
| value={intentName} | ||
| onChange={() => {}} | ||
| /> | ||
| </React.Fragment> | ||
| ) : null; | ||
| }; | ||
|
|
||
| export { ExpectedResponsesField }; |
28 changes: 0 additions & 28 deletions
28
Composer/packages/ui-plugins/prompts/src/PromptField/BotAsks.tsx
This file was deleted.
Oops, something went wrong.
76 changes: 0 additions & 76 deletions
76
Composer/packages/ui-plugins/prompts/src/PromptField/ChoiceInputSettings.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.