Liferay.Loader.define("data-engine-js-components-web@1.0.86/js/custom/form/FormFieldSettings.es",["module","exports","require","liferay!frontend-js-react-web$react","../../core/actions/eventTypes.es","../../core/config/initialConfigState.es","../../core/config/initialState.es","../../core/hooks/useConfig.es","../../core/hooks/useForm.es","../../core/reducers/index.es","../../utils/parseProps.es","./eventTypes","./reducers/index.es"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.FormFieldSettings=FormFieldSettings;var o=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var i=o?Object.getOwnPropertyDescriptor(e,n):null;i&&(i.get||i.set)?Object.defineProperty(r,n,i):r[n]=e[n]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),n=r("../../core/actions/eventTypes.es"),i=r("../../core/config/initialConfigState.es"),c=r("../../core/config/initialState.es"),a=r("../../core/hooks/useConfig.es"),s=r("../../core/hooks/useForm.es"),u=r("../../core/reducers/index.es"),d=r("../../utils/parseProps.es"),l=r("./eventTypes"),f=r("./reducers/index.es");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _objectWithoutProperties(e,t){if(null==e)return{};var r,o,n=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,o,n={},i=Object.keys(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const StateSync=({defaultLanguageId:e,editingLanguageId:t,focusedField:r,formBuilder:i,objectFields:c,pages:a,rules:u})=>{const d=(0,s.useForm)();return(0,o.useEffect)((()=>{d({payload:u,type:l.EVENT_TYPES.RULES.UPDATE})}),[d,u]),(0,o.useEffect)((()=>{d({payload:a,type:n.EVENT_TYPES.PAGE.UPDATE})}),[d,a]),(0,o.useEffect)((()=>{d({payload:{defaultLanguageId:e,editingLanguageId:t},type:n.EVENT_TYPES.LANGUAGE.CHANGE})}),[d,e,t]),(0,o.useEffect)((()=>{d({payload:{objectFields:c},type:l.EVENT_TYPES.OBJECT.FIELDS_CHANGE})}),[d,c]),(0,o.useEffect)((()=>{d({payload:{focusedField:r},type:l.EVENT_TYPES.FORM_BUILDER.FOCUSED_FIELD.CHANGE})}),[d,r]),(0,o.useEffect)((()=>{d({payload:i,type:l.EVENT_TYPES.FORM_BUILDER.PAGES.UPDATE})}),[d,i]),null};function FormFieldSettings(e){let{children:t,onAction:r}=e,n=_objectWithoutProperties(e,["children","onAction"]);const{config:l,state:p}=(0,d.parseProps)(n);return o.default.createElement(a.ConfigProvider,{config:l,initialConfig:i.INITIAL_CONFIG_STATE},o.default.createElement(s.FormProvider,{initialState:_objectSpread(_objectSpread({},c.INITIAL_STATE),{},{formBuilder:{focusedField:{},pages:[]}}),onAction:r,reducers:[u.activePageReducer,u.fieldReducer,f.formBuilderReducer,u.languageReducer,f.objectFieldsReducer,u.pagesStructureReducer,u.pageValidationReducer,f.paginationReducer,f.rulesReducer],value:p},o.default.createElement(StateSync,p),t))}FormFieldSettings.displayName="FormFieldSettings"}}));
//# sourceMappingURL=FormFieldSettings.es.js.map