UNPKG

@porsche-design-system/components-react

Version:

Porsche Design System is a component library designed to help developers create the best experience for software or services distributed by Dr. Ing. h.c. F. Porsche AG.

26 lines (23 loc) 1.56 kB
"use client"; import { jsx } from 'react/jsx-runtime'; import { forwardRef, useRef } from 'react'; import { useEventCallback, usePrefix, useTheme, useBrowserLayoutEffect, useMergedClass } from '../../hooks.mjs'; import { syncRef } from '../../utils.mjs'; const PTextFieldWrapper = /*#__PURE__*/ forwardRef(({ actionIcon, actionLoading = false, description = '', hideLabel = false, label = '', message = '', onAction, showCharacterCount, showCounter = true, showPasswordToggle = true, state = 'none', submitButton = true, theme, unit = '', unitPosition = 'prefix', className, ...rest }, ref) => { const elementRef = useRef(undefined); useEventCallback(elementRef, 'action', onAction); const WebComponentTag = usePrefix('p-text-field-wrapper'); const propsToSync = [actionIcon, actionLoading, description, hideLabel, label, message, showCharacterCount, showCounter, showPasswordToggle, state, submitButton, theme || useTheme(), unit, unitPosition]; useBrowserLayoutEffect(() => { const { current } = elementRef; ['actionIcon', 'actionLoading', 'description', 'hideLabel', 'label', 'message', 'showCharacterCount', 'showCounter', 'showPasswordToggle', 'state', 'submitButton', 'theme', 'unit', 'unitPosition'].forEach((propName, i) => (current[propName] = propsToSync[i])); }, propsToSync); const props = { ...rest, class: useMergedClass(elementRef, className), ref: syncRef(elementRef, ref) }; // @ts-ignore return jsx(WebComponentTag, { ...props }); }); export { PTextFieldWrapper };