UNPKG

koval-ui

Version:

React components collection with minimalistic design. Supports theming, layout, and input validation.

1 lines 1.31 kB
{"version":3,"file":"FormReducer.cjs","sources":["../../../../src/lib/Form/FormReducer.ts"],"sourcesContent":["/**\n * Action names collection\n * @example\n * import { Actions } from './FormReducer';\n * dispatch({ type: Actions.FORM_SET_PRISTINE})\n * */\nexport enum Actions {\n FORM_SET_PRISTINE = 'FORM_SET_PRISTINE',\n}\n\n/** Form state type */\nexport type FormState = {\n /** Defines if form is rendered or was reset to pristine state */\n pristine: boolean;\n};\n\nexport const initialState = {\n pristine: true,\n} as FormState;\n\nexport type FormAction = {\n /** Action name */\n type: Actions;\n pristine: boolean;\n};\n\nexport const FormReducer = (state = initialState, action: FormAction): FormState => {\n switch (action.type) {\n case Actions.FORM_SET_PRISTINE: {\n return {\n ...state,\n pristine: action.pristine,\n };\n }\n default:\n return state;\n }\n};\n"],"names":["Actions","initialState","FormReducer","state","action"],"mappings":"6FAMY,IAAAA,GAAAA,IACRA,EAAA,kBAAoB,oBADZA,IAAAA,GAAA,CAAA,CAAA,EAUL,MAAMC,EAAe,CACxB,SAAU,EACd,EAQaC,EAAc,CAACC,EAAQF,EAAcG,IAAkC,CAChF,OAAQA,EAAO,KAAM,CACjB,IAAK,oBACM,MAAA,CACH,GAAGD,EACH,SAAUC,EAAO,QACrB,EAEJ,QACW,OAAAD,CAAA,CAEnB"}