{"version":3,"file":"form-hooks.mjs","names":[],"sources":["../../../../../../../react-form/src/hooks/form-hooks.ts"],"sourcesContent":["\"use client\";\n\nimport { useMemo } from \"react\";\n\n/**\n * Derive a stable DOM id for a form control from its `id` prop or `name`.\n *\n * Renamed from `useId` in v4 so the package root no longer shadows React 18's\n * `useId` for `import { useId } from \"@mongez/react-form\"`.\n */\nexport function useControlId(data: { id?: string; name: string }) {\n  return useMemo(() => {\n    if (data.id) return data.id;\n\n    const name = data.name\n      // replace all . to -\n      .replace(/\\./g, \"-\")\n      // remove any non-alphanumeric characters\n      .replace(/[^a-zA-Z0-9-]/g, \"\")\n      // reduce any dashes to a single dash\n      .replace(/-+/g, \"-\")\n      // remove any leading or trailing dashes\n      .replace(/^-+|-+$/g, \"\");\n\n    if (data.name) return `input-${name}`;\n\n    return \"input-\" + Math.random().toString(36).substring(2, 9);\n  }, [data.id, data.name]);\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,aAAa,MAAqC;CAChE,OAAO,cAAc;EACnB,IAAI,KAAK,IAAI,OAAO,KAAK;EAEzB,MAAM,OAAO,KAAK,KAEf,QAAQ,OAAO,GAAG,CAAC,CAEnB,QAAQ,kBAAkB,EAAE,CAAC,CAE7B,QAAQ,OAAO,GAAG,CAAC,CAEnB,QAAQ,YAAY,EAAE;EAEzB,IAAI,KAAK,MAAM,OAAO,SAAS;EAE/B,OAAO,WAAW,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,UAAU,GAAG,CAAC;CAC7D,GAAG,CAAC,KAAK,IAAI,KAAK,IAAI,CAAC;AACzB"}