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