-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scribe for Questionnaire #9584
Closed
Closed
Scribe for Questionnaire #9584
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cc09a00
Scribe for Questionnaire
shivankacker 5455150
added cui support for shadcn components
shivankacker 2a55a9e
fix merge conflicts
shivankacker 71fb36b
structured inputs
shivankacker cc2e16f
fix merge conflicts
shivankacker 470571b
Merge branch 'form-field-v1' of https://github.com/ohcnetwork/care_fe…
shivankacker 0be90e6
fix merge conflicts
shivankacker 35876be
support for other fields
shivankacker efa2f47
finishing up
shivankacker 719ab94
rebase to develop
shivankacker b964266
cleanup
shivankacker fd7c909
changed state on injection
shivankacker a279cd2
Update Prompts; Add env
gigincg 77e7e1b
Merge branch 'develop' into form-field-scribe
gigincg b85c900
Merge branch 'develop' into form-field-scribe
gigincg bd5d914
Minor CHanges
gigincg 53e37a9
Fix Issues with AllergyQuestion
gigincg 3908e18
Merge branch 'develop' into form-field-scribe
gigincg ab34a7f
Merge branch 'develop' into form-field-scribe
gigincg 7cc5e59
Working Demo
gigincg fef419a
fix merge conflicts
shivankacker 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useCallback, useState } from "react"; | ||
|
||
import { useValueInjection } from "./useValueInjectionObserver"; | ||
|
||
export default function ScribeStructuredInput<T = unknown>(props: { | ||
name: string; | ||
prompt: string; | ||
example: unknown; | ||
value: T; | ||
onChange: (value: T | undefined) => void; | ||
className?: string; | ||
children: React.ReactNode; | ||
}) { | ||
const { name, prompt, example, value, onChange, children, className } = props; | ||
const [element, setElement] = useState<HTMLElement | null>(null); | ||
|
||
const callbackRef = useCallback( | ||
(node: HTMLElement | null) => setElement(node), | ||
[], | ||
); | ||
|
||
useValueInjection<T>({ | ||
targetElement: element, | ||
onChange, | ||
}); | ||
|
||
return ( | ||
<div | ||
ref={callbackRef} | ||
data-scribe-structured-input | ||
data-scribe-name={name} | ||
data-scribe-prompt={prompt} | ||
data-scribe-example={JSON.stringify(example)} | ||
data-scribe-value={JSON.stringify(value)} | ||
className={className} | ||
> | ||
{children} | ||
</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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitelist or sanitize user-driven updates.
prompt
suggests user instructions for editing structured data. Make sure your application defends against malicious or malformed data (e.g., unexpected property injection). Proper server-side validations are essential.