{"version":3,"file":"Field-8ed03060.cjs","sources":["../../node_modules/@mui/base/FormControl/FormControlContext.js","../../node_modules/@mui/base/FormControl/formControlClasses.js","../../node_modules/@mui/base/FormControl/FormControl.js","../src/Form/Field.tsx"],"sourcesContent":["import * as React from 'react';\n/**\n * @ignore - internal component.\n */\nconst FormControlContext = /*#__PURE__*/React.createContext(undefined);\nif (process.env.NODE_ENV !== 'production') {\n  FormControlContext.displayName = 'FormControlContext';\n}\nexport { FormControlContext };","import { generateUtilityClass } from '../generateUtilityClass';\nimport { generateUtilityClasses } from '../generateUtilityClasses';\nconst COMPONENT_NAME = 'FormControl';\nexport function getFormControlUtilityClass(slot) {\n  return generateUtilityClass(COMPONENT_NAME, slot);\n}\nexport const formControlClasses = generateUtilityClasses(COMPONENT_NAME, ['root', 'disabled', 'error', 'filled', 'focused', 'required']);","'use client';\n\nimport _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nconst _excluded = [\"defaultValue\", \"children\", \"disabled\", \"error\", \"onChange\", \"required\", \"slotProps\", \"slots\", \"value\"];\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport useControlled from '@mui/utils/useControlled';\nimport { FormControlContext } from './FormControlContext';\nimport { getFormControlUtilityClass } from './formControlClasses';\nimport { useSlotProps } from '../utils';\nimport { unstable_composeClasses as composeClasses } from '../composeClasses';\nimport { useClassNamesOverride } from '../utils/ClassNameConfigurator';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction hasValue(value) {\n  return value != null && !(Array.isArray(value) && value.length === 0) && value !== '';\n}\nfunction useUtilityClasses(ownerState) {\n  const {\n    disabled,\n    error,\n    filled,\n    focused,\n    required\n  } = ownerState;\n  const slots = {\n    root: ['root', disabled && 'disabled', focused && 'focused', error && 'error', filled && 'filled', required && 'required']\n  };\n  return composeClasses(slots, useClassNamesOverride(getFormControlUtilityClass));\n}\n\n/**\n * Provides context such as filled/focused/error/required for form inputs.\n * Relying on the context provides high flexibility and ensures that the state always stays\n * consistent across the children of the `FormControl`.\n * This context is used by the following components:\n *\n * *   FormLabel\n * *   FormHelperText\n * *   Input\n * *   InputLabel\n *\n * You can find one composition example below and more going to [the demos](https://mui.com/material-ui/react-text-field/#components).\n *\n * ```jsx\n * <FormControl>\n *   <InputLabel htmlFor=\"my-input\">Email address</InputLabel>\n *   <Input id=\"my-input\" aria-describedby=\"my-helper-text\" />\n *   <FormHelperText id=\"my-helper-text\">We'll never share your email.</FormHelperText>\n * </FormControl>\n * ```\n *\n * ⚠️ Only one `Input` can be used within a FormControl because it create visual inconsistencies.\n * For instance, only one input can be focused at the same time, the state shouldn't be shared.\n *\n * Demos:\n *\n * - [Form Control](https://mui.com/base-ui/react-form-control/)\n * - [Input](https://mui.com/joy-ui/react-input/)\n * - [Checkbox](https://mui.com/material-ui/react-checkbox/)\n * - [Radio Group](https://mui.com/material-ui/react-radio-button/)\n * - [Switch](https://mui.com/material-ui/react-switch/)\n * - [Text Field](https://mui.com/material-ui/react-text-field/)\n *\n * API:\n *\n * - [FormControl API](https://mui.com/base-ui/react-form-control/components-api/#form-control)\n */\nconst FormControl = /*#__PURE__*/React.forwardRef(function FormControl(props, forwardedRef) {\n  var _slots$root;\n  const {\n      defaultValue,\n      children,\n      disabled = false,\n      error = false,\n      onChange,\n      required = false,\n      slotProps = {},\n      slots = {},\n      value: incomingValue\n    } = props,\n    other = _objectWithoutPropertiesLoose(props, _excluded);\n  const [value, setValue] = useControlled({\n    controlled: incomingValue,\n    default: defaultValue,\n    name: 'FormControl',\n    state: 'value'\n  });\n  const filled = hasValue(value);\n  const [focusedState, setFocused] = React.useState(false);\n  const focused = focusedState && !disabled;\n  React.useEffect(() => setFocused(isFocused => disabled ? false : isFocused), [disabled]);\n  const ownerState = _extends({}, props, {\n    disabled,\n    error,\n    filled,\n    focused,\n    required\n  });\n  const childContext = React.useMemo(() => {\n    return {\n      disabled,\n      error,\n      filled,\n      focused,\n      onBlur: () => {\n        setFocused(false);\n      },\n      onChange: event => {\n        setValue(event.target.value);\n        onChange == null || onChange(event);\n      },\n      onFocus: () => {\n        setFocused(true);\n      },\n      required,\n      value: value != null ? value : ''\n    };\n  }, [disabled, error, filled, focused, onChange, required, setValue, value]);\n  const classes = useUtilityClasses(ownerState);\n  const renderChildren = () => {\n    if (typeof children === 'function') {\n      return children(childContext);\n    }\n    return children;\n  };\n  const Root = (_slots$root = slots.root) != null ? _slots$root : 'div';\n  const rootProps = useSlotProps({\n    elementType: Root,\n    externalSlotProps: slotProps.root,\n    externalForwardedProps: other,\n    additionalProps: {\n      ref: forwardedRef,\n      children: renderChildren()\n    },\n    ownerState,\n    className: classes.root\n  });\n  return /*#__PURE__*/_jsx(FormControlContext.Provider, {\n    value: childContext,\n    children: /*#__PURE__*/_jsx(Root, _extends({}, rootProps))\n  });\n});\nprocess.env.NODE_ENV !== \"production\" ? FormControl.propTypes /* remove-proptypes */ = {\n  // ┌────────────────────────────── Warning ──────────────────────────────┐\n  // │ These PropTypes are generated from the TypeScript type definitions. │\n  // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │\n  // └─────────────────────────────────────────────────────────────────────┘\n  /**\n   * The content of the component.\n   */\n  children: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.node, PropTypes.func]),\n  /**\n   * Class name applied to the root element.\n   */\n  className: PropTypes.string,\n  /**\n   * @ignore\n   */\n  defaultValue: PropTypes.any,\n  /**\n   * If `true`, the label, input and helper text should be displayed in a disabled state.\n   * @default false\n   */\n  disabled: PropTypes.bool,\n  /**\n   * If `true`, the label is displayed in an error state.\n   * @default false\n   */\n  error: PropTypes.bool,\n  /**\n   * Callback fired when the form element's value is modified.\n   */\n  onChange: PropTypes.func,\n  /**\n   * If `true`, the label will indicate that the `input` is required.\n   * @default false\n   */\n  required: PropTypes.bool,\n  /**\n   * The props used for each slot inside the FormControl.\n   * @default {}\n   */\n  slotProps: PropTypes.shape({\n    root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])\n  }),\n  /**\n   * The components used for each slot inside the FormControl.\n   * Either a string to use a HTML element or a component.\n   * @default {}\n   */\n  slots: PropTypes.shape({\n    root: PropTypes.elementType\n  }),\n  /**\n   * The value of the form element.\n   */\n  value: PropTypes.any\n} : void 0;\nexport { FormControl };","import { FormControl, type FormControlProps } from '@mui/base/FormControl';\nimport clsx from 'clsx';\nimport {\n  createContext,\n  forwardRef,\n  type PropsWithChildren,\n  type Ref,\n  useId,\n} from 'react';\n\nimport type { SlotComponentPropsWithoutOverride } from '../components.ts';\nimport { assocDefaultStyle } from '../utils/assign-default-style.ts';\n\nexport const FieldContext = createContext<{ id: string; name: string }>({\n  id: '',\n  name: '',\n});\n\ninterface SlotProps {\n  root?: SlotComponentPropsWithoutOverride<'fieldset'>;\n}\n\nexport const Field = forwardRef(function Field(\n  {\n    children,\n    disableDefaultClasses,\n    name,\n    slotProps: givenSlotProps,\n    ...rest\n  }: PropsWithChildren<\n    FormControlProps & {\n      disableDefaultClasses?: boolean;\n      name: string;\n      slotProps?: SlotProps;\n    }\n  >,\n  ref: Ref<HTMLInputElement>,\n) {\n  const id = useId();\n  const { value: fieldValue, ...formControlProps } = rest;\n  const formControlDefaultValue = fieldValue ?? null;\n  const slotProps = disableDefaultClasses\n    ? givenSlotProps\n    : (assocDefaultStyle<SlotProps>({\n        slotWithDefaultClasses: {\n          root: clsx('tw-group'),\n        },\n      })(givenSlotProps) as any);\n  return (\n    <FieldContext.Provider value={{ id: id, name }}>\n      <FormControl\n        {...formControlProps}\n        ref={ref}\n        slotProps={slotProps}\n        slots={{ root: 'fieldset' }}\n        value={formControlDefaultValue}\n      >\n        {children}\n      </FormControl>\n    </FieldContext.Provider>\n  );\n});\n"],"names":["FormControlContext","React","COMPONENT_NAME","getFormControlUtilityClass","slot","generateUtilityClass","generateUtilityClasses","_excluded","hasValue","value","useUtilityClasses","ownerState","disabled","error","filled","focused","required","slots","composeClasses","useClassNamesOverride","FormControl","props","forwardedRef","_slots$root","defaultValue","children","onChange","slotProps","incomingValue","other","_objectWithoutPropertiesLoose","setValue","useControlled","focusedState","setFocused","isFocused","_extends","childContext","event","classes","renderChildren","Root","rootProps","useSlotProps","_jsx","PropTypes","FieldContext","createContext","Field","forwardRef","disableDefaultClasses","name","givenSlotProps","rest","ref","id","useId","fieldValue","formControlProps","formControlDefaultValue","assocDefaultStyle","clsx","jsx"],"mappings":"mlBAIMA,EAAkCC,EAAM,cAAc,MAAS,EACjE,QAAQ,IAAI,WAAa,eAC3BD,EAAmB,YAAc,sBCJnC,MAAME,EAAiB,cAChB,SAASC,EAA2BC,EAAM,CAC/C,OAAOC,EAAoB,qBAACH,EAAgBE,CAAI,CAClD,CACkCE,EAAAA,uBAAuBJ,EAAgB,CAAC,OAAQ,WAAY,QAAS,SAAU,UAAW,UAAU,CAAC,ECFvI,MAAMK,EAAY,CAAC,eAAgB,WAAY,WAAY,QAAS,WAAY,WAAY,YAAa,QAAS,OAAO,EAUzH,SAASC,EAASC,EAAO,CACvB,OAAOA,GAAS,MAAQ,EAAE,MAAM,QAAQA,CAAK,GAAKA,EAAM,SAAW,IAAMA,IAAU,EACrF,CACA,SAASC,EAAkBC,EAAY,CACrC,KAAM,CACJ,SAAAC,EACA,MAAAC,EACA,OAAAC,EACA,QAAAC,EACA,SAAAC,CACD,EAAGL,EACEM,EAAQ,CACZ,KAAM,CAAC,OAAQL,GAAY,WAAYG,GAAW,UAAWF,GAAS,QAASC,GAAU,SAAUE,GAAY,UAAU,CAC7H,EACE,OAAOE,EAAc,eAACD,EAAOE,wBAAsBhB,CAA0B,CAAC,CAChF,CAuCA,MAAMiB,EAA2BnB,EAAM,WAAW,SAAqBoB,EAAOC,EAAc,CAC1F,IAAIC,EACJ,KAAM,CACF,aAAAC,EACA,SAAAC,EACA,SAAAb,EAAW,GACX,MAAAC,EAAQ,GACR,SAAAa,EACA,SAAAV,EAAW,GACX,UAAAW,EAAY,CAAE,EACd,MAAAV,EAAQ,CAAE,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