
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
@formsort/custom-question-api
Advanced tools
Helpers for implementing custom questions in Formsort.
Custom questions allow extending the Formsort platform with custom behavior, without needing to rewrite an entire form flow from scratch.
localhost
is best for development).First, install:
npm install --save @formsort/custom-question-api
Then, import the helper functions as needed in your custom question implementation:
import {
getAnswerValue,
getAnswers,
getResponderUuid,
setAnswerValue,
clearAnswerValue,
setQuestionSize,
} from '@formsort/custom-question-api'
getAnswerValue() => Promise<any>
Returns a promise for the current value of the answer this question is collecting. It may be undefined.
The result from getAnswer()
should be used upon initial load: to set the local state of any components for the answer that you are collecting in this question, for the case that the value is already known (for example, the user is returning after a reload, or has reached the step by using the back button).
getAnswers() => Promise<{ [key: string]: any}>
Returns a promise for an object containing all of the answers provided by the receipient thus far in filling out their flow. The keys are the variable names as defined within Formsort.
getResponderUuid() => Promise<string>
Get the current responder's UUID. Useful if you need to look something up about this user that isn't within the Formsort answer set.
setAnswerValue(value: number | string | boolean) => void
Sets the value for this question's answer. If you have Can autoadvance
checked within the Formsort studio settings for this question and this is the last remaining question within the step, the flow will advance to the next step.
clearAnswerValue() => void
Resets the answer for this particular question's answer.
setQuestionSize(width?: number, height?: number) => void
Sets the width and height of the question within Formsort.
To avoid jumpiness, if you know the size of your component beforehand, it's best to set the default width and height within the custom question directly within the Formsort studio. Use setQuestionSize
when you do not know the dimensions of your question component beforehand, and want to make sure that Formsort gives it enough size to render without scrollbars.
For example, if you implement your custom question as a React component, you may want to measure the component once it's rendered and tell Formsort its height and width:
import * as React from 'react';
import {
setQuestionSize
} from '@formsort/custom-question-api';
class MyCustomComponent extends React.Component {
private containerElRef: React.RefObject<HTMLDivElement>;
constructor(props: null) {
super(any);
this.containerElRef = React.createRef<HTMLDivElement>();
}
componentDidMount() {
const containerEl = this.containerElRef!.current;
setQuestionSize(containerEl.offsetWidth, containerEl.offsetHeight);
}
render() {
return (
<div ref={this.containerElRef}>
<h1>My custom component</h1>
</div>
)
}
}
FAQs
Helpers for implementing custom questions in Formsort
The npm package @formsort/custom-question-api receives a total of 151 weekly downloads. As such, @formsort/custom-question-api popularity was classified as not popular.
We found that @formsort/custom-question-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.