import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","inputRef","inputMaxLength","value","renderValue","onInputFocus","onInputBlur","inputAutoFocus","inputTabIndex","inputAriaLabel","onInputKeyDown","onInputKeyDownCapture","onInputChange","onInputKeyUp","onInputKeyUpCapture","disabled","style","size","placeholder","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import React,{forwardRef,useCallback,useEffect,useRef,useState}from"react";import{useComponentSize}from"../../../hooks/useComponentSize";import{useForkRef}from"../../../hooks/useForkRef";import{useMutableRef}from"../../../hooks/useMutableRef";import{cnFieldArrayValueInlineControl}from"./cnFieldArrayValueInlineControl";var gapMap={l:"calc(var(--space-3xs) + var(--space-2xs))",m:"var(--space-2xs)",s:"var(--space-3xs)",xs:"var(--space-3xs)"},verticalPaddingMap={l:"var(--space-xs)",m:"calc(var(--space-xs) - var(--space-3xs))",s:"var(--space-2xs)",xs:"var(--space-3xs)"},inputHeightMap={l:"var(--space-2xl)",m:"calc(var(--space-2xl) - var(--space-2xs))",s:"var(--space-xl)",xs:"var(--space-l)"},FieldArrayValueInlineControlRender=function(a,b){var c,d,e=a.className,f=a.inputRef,g=a.inputMaxLength,h=a.value,i=void 0===h?[]:h,j=a.renderValue,k=a.onInputFocus,l=a.onInputBlur,m=a.inputAutoFocus,n=a.inputTabIndex,o=a.inputAriaLabel,p=a.onInputKeyDown,q=a.onInputKeyDownCapture,r=a.onInputChange,s=a.onInputKeyUp,t=a.onInputKeyUpCapture,u=a.disabled,v=a.style,w=a.size,x=void 0===w?"m":w,y=a.placeholder,z=a.onCopy,A=a.onCopyCapture,B=a.onCut,C=a.onCutCapture,D=a.onPaste,E=a.onPasteCapture,F=_objectWithoutProperties(a,_excluded),G=useState(""),H=_slicedToArray(G,2),I=H[0],J=H[1],K=useMutableRef(r),L=useRef(null),M=useRef(null),N=useCallback(function(a){var b;J(a.target.value),null===(b=K.current)||void 0===b?void 0:b.call(K,a)},[]),O=useComponentSize(L),P=O.width;return useEffect(function(){var a;J((null===(a=M.current)||void 0===a?void 0:a.value)||"")},[null===(c=M.current)||void 0===c?void 0:c.value]),React.createElement("div",Object.assign({},F,{className:cnFieldArrayValueInlineControl(null,[e]),ref:b,style:_objectSpread(_objectSpread({},v),{},(d={},_defineProperty(d,"--field-array-value-inline-control-items-gap",gapMap[x]),_defineProperty(d,"--field-array-value-inline-control-input-min-width","".concat(P,"px")),_defineProperty(d,"--field-array-value-inline-control-vertical-padding","".concat(verticalPaddingMap[x])),_defineProperty(d,"--field-array-value-inline-control-input-height","".concat(inputHeightMap[x])),d))}),i.map(j),React.createElement("input",{className:cnFieldArrayValueInlineControl("Input"),onChange:N,ref:useForkRef([M,f]),maxLength:g,onFocus:k,onBlur:l,autoFocus:m,tabIndex:n,"aria-label":o,onKeyDown:p,onKeyDownCapture:q,onKeyUp:s,onKeyUpCapture:t,disabled:u,type:"text",placeholder:i.length?void 0:y,onCopy:z,onCopyCapture:A,onCut:B,onCutCapture:C,onPaste:D,onPasteCapture:E}),React.createElement("div",{ref:L,className:cnFieldArrayValueInlineControl("HelperInputFakeElement")},I))};export var FieldArrayValueInlineControl=forwardRef(FieldArrayValueInlineControlRender);
//# sourceMappingURL=FieldArrayValueInlineControl.js.map