{"version":3,"file":"formEvents.mjs","names":["FormChangeEvent","target","value","T","name","type","checked","currentTarget","FormFocusEvent","createChangeEvent","isCheckboxType","Boolean","undefined","createFocusEvent","FormInputProps","onChange","event","onBlur","onFocus","disabled","required"],"sources":["../../../../src/UI/fluent-web-components/utils/formEvents.ts"],"sourcesContent":["/**\n * Shared utilities for normalizing Stencil CustomEvents to React-compatible form events.\n * This allows components to work seamlessly with form libraries like react-final-form,\n * formik, and react-hook-form without requiring adapters.\n */\n\n/**\n * Normalized change event that mimics React.ChangeEvent<HTMLInputElement>\n * Compatible with form libraries that expect event.target.value\n */\nexport interface FormChangeEvent<T = string> {\n  target: {\n    value: T;\n    name?: string;\n    type?: string;\n    checked?: boolean;\n  };\n  currentTarget: {\n    value: T;\n    name?: string;\n    type?: string;\n    checked?: boolean;\n  };\n  type: 'change';\n}\n\n/**\n * Normalized focus/blur event that mimics React.FocusEvent\n * Compatible with form libraries that expect onBlur/onFocus handlers\n */\nexport interface FormFocusEvent {\n  target: {\n    name?: string;\n  };\n  type: 'blur' | 'focus';\n}\n\n/**\n * Creates a normalized change event from a value.\n * Use this to transform Stencil CustomEvent.detail into a form-library-compatible event.\n *\n * @example\n * // For text inputs\n * onValueChanged={(e) => onChange?.(createChangeEvent(e.detail, name, 'text'))}\n *\n * @example\n * // For checkboxes\n * onValueChanged={(e) => onChange?.(createChangeEvent(e.detail, name, 'checkbox'))}\n */\nexport function createChangeEvent<T = string>(\n  value: T,\n  name?: string,\n  type?: string\n): FormChangeEvent<T> {\n  const isCheckboxType = type === 'checkbox' || type === 'switch' || type === 'radio';\n  return {\n    target: {\n      value,\n      name,\n      type,\n      checked: isCheckboxType ? Boolean(value) : undefined,\n    },\n    currentTarget: {\n      value,\n      name,\n      type,\n      checked: isCheckboxType ? Boolean(value) : undefined,\n    },\n    type: 'change',\n  };\n}\n\n/**\n * Creates a normalized focus/blur event.\n * Use this to transform Stencil focus/blur CustomEvents into form-library-compatible events.\n *\n * @example\n * onInputBlur={() => onBlur?.(createFocusEvent('blur', name))}\n */\nexport function createFocusEvent(\n  type: 'blur' | 'focus',\n  name?: string\n): FormFocusEvent {\n  return {\n    target: { name },\n    type,\n  };\n}\n\n/**\n * Props interface for components that support form integration.\n * Extend this for consistent form props across all input components.\n */\nexport interface FormInputProps<T = string> {\n  /** Field name for form state management */\n  name?: string;\n  /** Current value */\n  value?: T;\n  /** Called when value changes - compatible with form libraries */\n  onChange?: (event: FormChangeEvent<T>) => void;\n  /** Called when input loses focus - compatible with form libraries */\n  onBlur?: (event: FormFocusEvent) => void;\n  /** Called when input gains focus */\n  onFocus?: (event: FormFocusEvent) => void;\n  /** Whether the field is disabled */\n  disabled?: boolean;\n  /** Whether the field is required */\n  required?: boolean;\n}\n"],"mappings":";;;;;;;;;;;;;AAiDA,SAAgBS,kBACdP,OACAE,MACAC,MACoB;CACpB,MAAMK,iBAAiBL,SAAS,cAAcA,SAAS,YAAYA,SAAS;AAC5E,QAAO;EACLJ,QAAQ;GACNC;GACAE;GACAC;GACAC,SAASI,iBAAiBC,QAAQT,MAAM,GAAGU,KAAAA;GAC5C;EACDL,eAAe;GACbL;GACAE;GACAC;GACAC,SAASI,iBAAiBC,QAAQT,MAAM,GAAGU,KAAAA;GAC5C;EACDP,MAAM;EACP;;;;;;;;;AAUH,SAAgBQ,iBACdR,MACAD,MACgB;AAChB,QAAO;EACLH,QAAQ,EAAEG,MAAM;EAChBC;EACD"}