Aller au contenu principal

Type Alias: LunaticState

LunaticState = object

Defined in: src/use-lunatic/type.ts:299

Return type of useLunatic.

Allow to operate the survey.

Properties​

PropertyTypeDescriptionDefined in
compileControls() => objectAllow to fetch controls.src/use-lunatic/type.ts:337
currentErrors?objectErrors in the current page / iteration.src/use-lunatic/type.ts:322
errors?objectErrors in the survey.src/use-lunatic/type.ts:320
getChangedData(reset?) => LunaticDataGet data that have changed since last reset. Returns the same thing as getData().src/use-lunatic/type.ts:392
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 LunaticComponentssrc/use-lunatic/type.ts:385
getData(withRefreshedCalculated, variableNames?) => LunaticDataGet data collected by the survey.src/use-lunatic/type.ts:387
getMultimode() => Record<string, boolean>Return the multimode state *src/use-lunatic/type.ts:416
goNextPage() => voidNavigate to the next page.src/use-lunatic/type.ts:333
goPreviousPage() => voidNavigate to the previous page.src/use-lunatic/type.ts:335
goToPage(page) => voidNavigate to a specific page.src/use-lunatic/type.ts:326
handleChangesLunaticChangesHandlerChange 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:414
hasPageResponse() => booleanReturn true as soon as the current page has at least one answer.src/use-lunatic/type.ts:396
isFirstPagebooleanWhether or not we're on the survey first page.src/use-lunatic/type.ts:316
isInLoopbooleanWhether or not we're in a loop.src/use-lunatic/type.ts:310
isLastPagebooleanWhether or not we're on the survey last page (we reached maxPage).src/use-lunatic/type.ts:318
loopVariablesstring[]Current loop's variables.src/use-lunatic/type.ts:312
modalErrors?Record<string, LunaticError[]>Errors in modal.src/use-lunatic/type.ts:324
overviewInterpretedLunaticOverviewItem[]-src/use-lunatic/type.ts:302
pagerLunaticPagerCurrent pager.src/use-lunatic/type.ts:301
pageTagPageTagCurrent page numerotation.src/use-lunatic/type.ts:304
ProviderFunctionComponent<PropsWithChildren>Necessary component that must wraps LunaticComponents to make the library works.src/use-lunatic/type.ts:308
resetChangedData() => voidEmpty the store of changed variables.src/use-lunatic/type.ts:394
roundaboutLoopVariablesstring[]Current roundabout loop's variables.src/use-lunatic/type.ts:314
updatedAtnumberDate of the last handleChange function call.src/use-lunatic/type.ts:306