Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.108/Grid/Grid.es",["module","exports","require","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/table","liferay!frontend-js-react-web$react","../FieldBase/ReactFieldBase.es","../hooks/useSyncValue.es"],(function(e,a,l){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.default=void 0;var t=l("@frontend-taglib-clay$clayui/form"),n=c(l("@frontend-taglib-clay$clayui/table")),r=c(l("liferay!frontend-js-react-web$react")),o=l("../FieldBase/ReactFieldBase.es"),u=l("../hooks/useSyncValue.es");function c(e){return e&&e.__esModule?e:{default:e}}function d(e,a){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);a&&(t=t.filter((function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}))),l.push.apply(l,t)}return l}function i(e){for(var a=1;a<arguments.length;a++){var l=null!=arguments[a]?arguments[a]:{};a%2?d(Object(l),!0).forEach((function(a){s(e,a,l[a])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):d(Object(l)).forEach((function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(l,a))}))}return e}function s(e,a,l){return a in e?Object.defineProperty(e,a,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[a]=l,e}function f(){return(f=Object.assign||function(e){for(var a=1;a<arguments.length;a++){var l=arguments[a];for(var t in l)Object.prototype.hasOwnProperty.call(l,t)&&(e[t]=l[t])}return e}).apply(this,arguments)}function m(e,a){if(null==e)return{};var l,t,n=function(e,a){if(null==e)return{};var l,t,n={},r=Object.keys(e);for(t=0;t<r.length;t++)l=r[t],a.indexOf(l)>=0||(n[l]=e[l]);return n}(e,a);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(t=0;t<r.length;t++)l=r[t],a.indexOf(l)>=0||Object.prototype.propertyIsEnumerable.call(e,l)&&(n[l]=e[l])}return n}const e=({columns:e})=>r.default.createElement(n.default.Head,null,r.default.createElement(n.default.Row,null,r.default.createElement(n.default.Cell,{headingCell:!0}),e.map(((e,a)=>r.default.createElement(n.default.Cell,{headingCell:!0,key:"column-".concat(e.value,"-").concat(a)},e.label))))),b=({columns:e,disabled:a,name:l,onBlur:o,onChange:u,onFocus:c,row:d,value:i})=>{const s=Liferay.Language.get("column"),f=Liferay.Language.get("row");return e.map(((e,m)=>r.default.createElement(n.default.Cell,{key:"cell-".concat(e.value,"-").concat(m)},r.default.createElement(t.ClayRadio,{"aria-label":"".concat(f,": ").concat(d.label,", ").concat(s,": ").concat(e.label),checked:e.value===i[d.value],className:"form-builder-grid-field","data-name":d.value,disabled:a,name:l,onBlur:o,onChange:u,onFocus:c,value:e.value}))))},v=a=>{let{columns:l=[{label:"col1",value:"fieldId"}],disabled:t,name:o,onBlur:u,onChange:c,onFocus:d,rows:i=[{label:"row",value:"jehf"}],value:s}=a,y=m(a,["columns","disabled","name","onBlur","onChange","onFocus","rows","value"]);return r.default.createElement("div",f({className:"table-responsive"},y),!t&&i.map(((e,a)=>{const l=s[e.value]?"".concat(e.value,";").concat(s[e.value]):"";return r.default.createElement("input",{key:"row-".concat(e.value,"-").concat(a),name:o,type:"hidden",value:l})})),r.default.createElement(n.default,{striped:!0},r.default.createElement(e,{columns:l}),r.default.createElement(n.default.Body,null,i.map(((e,a)=>r.default.createElement(n.default.Row,{key:"row-".concat(e.value,"-").concat(a),name:e.value},r.default.createElement(n.default.Cell,null,e.label),r.default.createElement(b,{columns:l,disabled:t,name:"".concat(o,"_").concat(e.value),onBlur:u,onChange:c,onFocus:d,row:e,value:s})))))))},p=e=>{let{columns:a,name:l,readOnly:t,rows:n,onChange:c,onFocus:d,onBlur:s,value:y={}}=e,b=m(e,["columns","name","readOnly","rows","onChange","onFocus","onBlur","value"]);const[p,g]=(0,u.useSyncValue)(y,!1);return r.default.createElement(o.FieldBase,f({name:l,readOnly:t},b),r.default.createElement(v,{columns:a,disabled:t,name:l,onBlur:s,onChange:e=>{const{target:a}=e,l={[a.dataset.name]:a.value},t=i(i({},p),l);g(t),c(e,t)},onFocus:d,rows:n,value:p}))};p.displayName="Grid";var y=p;a.default=y}}));
//# sourceMappingURL=Grid.es.js.map