Aller au contenu principal

Type Alias: LunaticState

LunaticState = object

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

Return type of useLunatic.

Allow to operate the survey.

Properties

PropertyTypeDescriptionDefined in
compileControls() => objectAllow to fetch controls.src/use-lunatic/type.ts:283
currentErrors?objectErrors in the current page / iteration.src/use-lunatic/type.ts:268
errors?objectErrors in the survey.src/use-lunatic/type.ts:266
getChangedData(reset?) => LunaticDataGet 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 LunaticComponentssrc/use-lunatic/type.ts:331
getData(withRefreshedCalculated, variableNames?) => LunaticDataGet data collected by the survey.src/use-lunatic/type.ts:333
goNextPage() => voidNavigate to the next page.src/use-lunatic/type.ts:279
goPreviousPage() => voidNavigate to the previous page.src/use-lunatic/type.ts:281
goToPage(page) => voidNavigate to a specific page.src/use-lunatic/type.ts:272
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:360
hasPageResponse() => booleanReturn true as soon as the current page has at least one answer.src/use-lunatic/type.ts:342
isFirstPagebooleanWhether or not we're on the survey first page.src/use-lunatic/type.ts:262
isInLoopbooleanWhether or not we're in a loop.src/use-lunatic/type.ts:258
isLastPagebooleanWhether or not we're on the survey last page (we reached maxPage).src/use-lunatic/type.ts:264
loopVariablesstring[]Current loop's variables.src/use-lunatic/type.ts:260
modalErrors?Record<string, LunaticError[]>Errors in modal.src/use-lunatic/type.ts:270
overviewInterpretedLunaticOverviewItem[]-src/use-lunatic/type.ts:250
pagerLunaticPagerCurrent pager.src/use-lunatic/type.ts:249
pageTagPageTagCurrent page numerotation.src/use-lunatic/type.ts:252
ProviderFunctionComponent<PropsWithChildren>Necessary component that must wraps LunaticComponents to make the library works.src/use-lunatic/type.ts:256
resetChangedData() => voidEmpty the store of changed variables.src/use-lunatic/type.ts:340
updatedAtnumberDate of the last handleChange function call.src/use-lunatic/type.ts:254