Type Alias: LunaticState
LunaticState =
object
Defined in: src/use-lunatic/type.ts:247
Return type of useLunatic.
Allow to operate the survey.
Properties
Property | Type | Description | Defined in |
---|---|---|---|
compileControls | () => object | Allow to fetch controls. | src/use-lunatic/type.ts:283 |
currentErrors? | object | Errors in the current page / iteration. | src/use-lunatic/type.ts:268 |
errors? | object | Errors in the survey. | src/use-lunatic/type.ts:266 |
getChangedData | (reset? ) => LunaticData | Get data that have changed since last reset. Returns the same thing as getData() . | src/use-lunatic/type.ts:338 |
getComponents | () => LunaticComponentProps [] | Components to display in the current page. Return an array with the various components' properties. The orchestrator has to handle how they are displayed, using the componentType property to select the appropriate component. Examples // using LunaticComponents import { useLunatic, LunaticComponents } from '@inseefr/lunatic'; function App({ source, data }) { const { getComponents, Provider } = useLunatic(source, data, {}); const components = getComponents(); return ( <Provider> <LunaticComponents components={components} /> </Provider> ); } // using custom components import { useLunatic, LunaticComponents } from '@inseefr/lunatic'; const customCompoonents = { Input: MyCustomInput, InputNumber: MyCustomInputNumber, }; function App({ source, data }) { const { getComponents, Provider } = useLunatic(source, data, {}); const components = getComponents(); return ( <Provider> <LunaticComponents components={components} slots={customComponents} /> </Provider> ); } See LunaticComponents | src/use-lunatic/type.ts:331 |
getData | (withRefreshedCalculated , variableNames? ) => LunaticData | Get data collected by the survey. | src/use-lunatic/type.ts:333 |
goNextPage | () => void | Navigate to the next page. | src/use-lunatic/type.ts:279 |
goPreviousPage | () => void | Navigate to the previous page. | src/use-lunatic/type.ts:281 |
goToPage | (page ) => void | Navigate to a specific page. | src/use-lunatic/type.ts:272 |
handleChanges | LunaticChangesHandler | Change several variable values. Be careful when using this function. In most cases, you don't need this function. It's used directly by the components (and available as a props.) - With only one change or with serveral changes Example handleChanges([{name: "MY_VAR", value: "new value"}]) handleChanges([ {name: "MY_VAR", value: "new value"}, {name: "MY_VAR_2", value: "new value 2"} ]) | src/use-lunatic/type.ts:360 |
hasPageResponse | () => boolean | Return true as soon as the current page has at least one answer. | src/use-lunatic/type.ts:342 |
isFirstPage | boolean | Whether or not we're on the survey first page. | src/use-lunatic/type.ts:262 |
isInLoop | boolean | Whether or not we're in a loop. | src/use-lunatic/type.ts:258 |
isLastPage | boolean | Whether or not we're on the survey last page (we reached maxPage ). | src/use-lunatic/type.ts:264 |
loopVariables | string [] | Current loop's variables. | src/use-lunatic/type.ts:260 |
modalErrors? | Record <string , LunaticError []> | Errors in modal. | src/use-lunatic/type.ts:270 |
overview | InterpretedLunaticOverviewItem [] | - | src/use-lunatic/type.ts:250 |
pager | LunaticPager | Current pager. | src/use-lunatic/type.ts:249 |
pageTag | PageTag | Current page numerotation. | src/use-lunatic/type.ts:252 |
Provider | FunctionComponent <PropsWithChildren > | Necessary component that must wraps LunaticComponents to make the library works. | src/use-lunatic/type.ts:256 |
resetChangedData | () => void | Empty the store of changed variables. | src/use-lunatic/type.ts:340 |
updatedAt | number | Date of the last handleChange function call. | src/use-lunatic/type.ts:254 |