@wordpress/components
Version:
UI components for WordPress.
1 lines • 2.27 kB
Source Map (JSON)
{"version":3,"file":"input-control.cjs","names":["useRef","useMergeRefs","ControlWithError","InputControl","forwardRef"],"sources":["../../../src/validated-form-controls/components/input-control.tsx"],"sourcesContent":["import { forwardRef, useRef } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\nimport { ControlWithError } from '@wordpress/ui';\nimport type { ValidatedControlProps } from './types';\nimport InputControl from '../../input-control';\n\nconst UnforwardedValidatedInputControl = (\n\t{\n\t\trequired,\n\t\tcustomValidity,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: React.ComponentProps< typeof InputControl > & ValidatedControlProps,\n\tforwardedRef: React.ForwardedRef< HTMLInputElement >\n) => {\n\tdeprecated( 'wp.components.privateApis.ValidatedInputControl', {\n\t\tsince: '7.2',\n\t\talternative: 'ValidatedInputControl from @wordpress/ui',\n\t\thint: 'This private API will be completely removed within a few Gutenberg plugin releases.',\n\t} );\n\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\tconst mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );\n\n\treturn (\n\t\t<ControlWithError\n\t\t\tclassName=\"components-validated-control\"\n\t\t\trequired={ required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tgetValidityTarget={ () => validityTargetRef.current }\n\t\t>\n\t\t\t<InputControl ref={ mergedRefs } { ...restProps } />\n\t\t</ControlWithError>\n\t);\n};\n\nexport const ValidatedInputControl = forwardRef(\n\tUnforwardedValidatedInputControl\n);\nValidatedInputControl.displayName = 'ValidatedInputControl';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,oCACL,EACC,UACA,gBACA,kBACA,GAAG,aAEJ,iBACI;CACJ,CAAA,GAAA,sBAAA,QAAA,CAAY,mDAAmD;EAC9D,OAAO;EACP,aAAa;EACb,MAAM;CACP,CAAE;CAEF,MAAM,qBAAA,GAAoBA,mBAAAA,OAAAA,CAA4B,IAAK;CAC3D,MAAM,cAAA,GAAaC,mBAAAA,aAAAA,CAAc,CAAE,cAAc,iBAAkB,CAAE;CAErE,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,kBAAD;EACC,WAAU;EACC;EACQ;EACF;EACjB,yBAA0B,kBAAkB;EAE5C,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,SAAD;GAAc,KAAM;GAAa,GAAK;EAAa,CAAA;CAClC,CAAA;AAEpB;AAEA,MAAa,yBAAA,GAAwBC,mBAAAA,WAAAA,CACpC,gCACD;AACA,sBAAsB,cAAc"}