@formsort/custom-question-api
Advanced tools
Comparing version 0.0.24 to 0.0.25
import { AnswerSemanticType } from '@formsort/constants'; | ||
declare type AnswerPrimitiveType = number | string | boolean; | ||
declare type AnswerPrimitiveType = number | string | boolean | object; | ||
declare type AnswerType = AnswerPrimitiveType | AnswerPrimitiveType[]; | ||
export declare const setQuestionSize: (width?: number | undefined, height?: number | undefined) => void; | ||
export declare const getAnswerValue: () => Promise<AnswerType>; | ||
export declare const getSemanticAnswerValue: (semanticType: AnswerSemanticType) => Promise<AnswerType>; | ||
export declare const getAnswerValue: <T extends AnswerType = AnswerType>() => Promise<T | undefined>; | ||
export declare const getSemanticAnswerValue: <T extends AnswerType = AnswerType>(semanticType: AnswerSemanticType) => Promise<T>; | ||
export declare const getAllAnswerValues: () => Promise<{ | ||
[key: string]: AnswerType; | ||
[key: string]: string | number | boolean | object | AnswerPrimitiveType[] | undefined; | ||
}>; | ||
export declare const getResponderUuid: () => Promise<string>; | ||
export declare const clearAnswerValue: () => void; | ||
export declare const setAnswerValue: (value: string | number | boolean) => void; | ||
export declare const setAnswerValue: (value: AnswerType) => void; | ||
export {}; |
{ | ||
"name": "@formsort/custom-question-api", | ||
"version": "0.0.24", | ||
"version": "0.0.25", | ||
"description": "Helpers for implementing custom questions in Formsort", | ||
@@ -52,3 +52,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "43ee92db5831a9f38f3019e0e86bb5c541cce432" | ||
"gitHead": "a7b0156bbc2ce661ad75fa222c7edcc40942fa26" | ||
} |
@@ -41,4 +41,4 @@ # @formsort/custom-question-api | ||
getResponderUuid, | ||
setQuestionSize | ||
} from "@formsort/custom-question-api"; | ||
setQuestionSize, | ||
} from '@formsort/custom-question-api'; | ||
``` | ||
@@ -56,6 +56,14 @@ | ||
Optionally, the type of the answer can be defined by passing a generic parameter: | ||
```tsx | ||
getAllAnswerValues() => Promise<{ [key: string]: any}> | ||
getAnswerValue<string>() | ||
``` | ||
The type parameter can be either a number, string, boolean, object, or an array consisting of one of these types. The returned value will still be `undefined` if the answer has not been set. | ||
```tsx | ||
getAllAnswerValues() => 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. | ||
@@ -70,3 +78,3 @@ | ||
```tsx | ||
setAnswerValue(value: number | string | boolean) => void | ||
setAnswerValue(value: number | string | boolean | object) => void | ||
``` | ||
@@ -100,3 +108,3 @@ | ||
``` | ||
```tsx | ||
setQuestionSize(width?: number, height?: number) => void | ||
@@ -112,4 +120,4 @@ ``` | ||
```tsx | ||
import React, { useEffect, useRef } from "react"; | ||
import { setQuestionSize } from "@formsort/custom-question-api"; | ||
import React, { useEffect, useRef } from 'react'; | ||
import { setQuestionSize } from '@formsort/custom-question-api'; | ||
@@ -120,3 +128,3 @@ const MyCustomComponent = () => { | ||
useEffect(() => { | ||
const containerEl = this.containerElRef.current; | ||
const containerEl = containerElRef.current; | ||
if (!containerEl) { | ||
@@ -139,4 +147,4 @@ return; | ||
```tsx | ||
import * as React from "react"; | ||
import { setQuestionSize } from "@formsort/custom-question-api"; | ||
import * as React from 'react'; | ||
import { setQuestionSize } from '@formsort/custom-question-api'; | ||
@@ -143,0 +151,0 @@ class MyCustomComponent extends React.Component { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14428
165
1