LittleDemon WebShell


Linux premium331.web-hosting.com 4.18.0-553.80.1.lve.el8.x86_64 #1 SMP Wed Oct 22 19:29:36 UTC 2025 x86_64
Path : /proc/self/root/home/livedhms/lmgt/node_modules/next/dist/esm/client/app-dir/
File Upload :
Command :
Current File : //proc/self/root/home/livedhms/lmgt/node_modules/next/dist/esm/client/app-dir/form.js.map

{"version":3,"sources":["../../../../src/client/app-dir/form.tsx"],"sourcesContent":["'use client'\n\nimport { useCallback, type FormEvent, useContext } from 'react'\nimport { addBasePath } from '../add-base-path'\nimport { useMergedRef } from '../use-merged-ref'\nimport {\n  AppRouterContext,\n  type AppRouterInstance,\n} from '../../shared/lib/app-router-context.shared-runtime'\nimport {\n  checkFormActionUrl,\n  createFormSubmitDestinationUrl,\n  DISALLOWED_FORM_PROPS,\n  hasReactClientActionAttributes,\n  hasUnsupportedSubmitterAttributes,\n  type FormProps,\n} from '../form-shared'\nimport {\n  mountFormInstance,\n  unmountPrefetchableInstance,\n} from '../components/links'\nimport { FetchStrategy } from '../components/segment-cache/types'\n\nexport type { FormProps }\n\nexport default function Form({\n  replace,\n  scroll,\n  prefetch: prefetchProp,\n  ref: externalRef,\n  ...props\n}: FormProps) {\n  const router = useContext(AppRouterContext)\n\n  const actionProp = props.action\n  const isNavigatingForm = typeof actionProp === 'string'\n\n  // Validate `action`\n  if (process.env.NODE_ENV === 'development') {\n    if (isNavigatingForm) {\n      checkFormActionUrl(actionProp, 'action')\n    }\n  }\n\n  // Validate `prefetch`\n  if (process.env.NODE_ENV === 'development') {\n    if (\n      !(\n        prefetchProp === undefined ||\n        prefetchProp === false ||\n        prefetchProp === null\n      )\n    ) {\n      console.error('The `prefetch` prop of <Form> must be `false` or `null`')\n    }\n\n    if (prefetchProp !== undefined && !isNavigatingForm) {\n      console.error(\n        'Passing `prefetch` to a <Form> whose `action` is a function has no effect.'\n      )\n    }\n  }\n\n  // TODO(runtime-ppr): allow runtime prefetches in Form\n  const prefetch =\n    prefetchProp === false || prefetchProp === null ? prefetchProp : null\n\n  // Validate `scroll` and `replace`\n  if (process.env.NODE_ENV === 'development') {\n    if (!isNavigatingForm && (replace !== undefined || scroll !== undefined)) {\n      console.error(\n        'Passing `replace` or `scroll` to a <Form> whose `action` is a function has no effect.\\n' +\n          'See the relevant docs to learn how to control this behavior for navigations triggered from actions:\\n' +\n          '  `redirect()`       - https://nextjs.org/docs/app/api-reference/functions/redirect#parameters\\n' +\n          '  `router.replace()` - https://nextjs.org/docs/app/api-reference/functions/use-router#userouter\\n'\n      )\n    }\n  }\n\n  // Clean up any unsupported form props (and warn if present)\n  for (const key of DISALLOWED_FORM_PROPS) {\n    if (key in props) {\n      if (process.env.NODE_ENV === 'development') {\n        console.error(\n          `<Form> does not support changing \\`${key}\\`. ` +\n            (isNavigatingForm\n              ? `If you'd like to use it to perform a mutation, consider making \\`action\\` a function instead.\\n` +\n                `Learn more: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations`\n              : '')\n        )\n      }\n      delete (props as Record<string, unknown>)[key]\n    }\n  }\n\n  const isPrefetchEnabled =\n    // if we don't have an action path, we can't prefetch anything.\n    !!router && isNavigatingForm && prefetch === null\n\n  const observeFormVisibilityOnMount = useCallback(\n    (element: HTMLFormElement) => {\n      if (isPrefetchEnabled && router !== null) {\n        mountFormInstance(\n          element,\n          actionProp,\n          router,\n          // We default to PPR. We'll discover whether or not the route supports it with the initial prefetch.\n          FetchStrategy.PPR\n        )\n      }\n      return () => {\n        unmountPrefetchableInstance(element)\n      }\n    },\n    [isPrefetchEnabled, actionProp, router]\n  )\n\n  const mergedRef = useMergedRef(\n    observeFormVisibilityOnMount,\n    externalRef ?? null\n  )\n\n  if (!isNavigatingForm) {\n    return <form {...props} ref={mergedRef} />\n  }\n\n  const actionHref = addBasePath(actionProp)\n\n  return (\n    <form\n      {...props}\n      ref={mergedRef}\n      action={actionHref}\n      onSubmit={(event) =>\n        onFormSubmit(event, {\n          router,\n          actionHref,\n          replace,\n          scroll,\n          onSubmit: props.onSubmit,\n        })\n      }\n    />\n  )\n}\n\nfunction onFormSubmit(\n  event: FormEvent<HTMLFormElement>,\n  {\n    actionHref,\n    onSubmit,\n    replace,\n    scroll,\n    router,\n  }: {\n    actionHref: string\n    onSubmit: FormProps['onSubmit']\n    replace: FormProps['replace']\n    scroll: FormProps['scroll']\n    router: AppRouterInstance | null\n  }\n) {\n  if (typeof onSubmit === 'function') {\n    onSubmit(event)\n\n    // if the user called event.preventDefault(), do nothing.\n    // (this matches what Link does for `onClick`)\n    if (event.defaultPrevented) {\n      return\n    }\n  }\n\n  if (!router) {\n    // Form was somehow used outside of the router (but not in pages, the implementation is forked!).\n    // We can't perform a soft navigation, so let the native submit handling do its thing.\n    return\n  }\n\n  const formElement = event.currentTarget\n  const submitter = (event.nativeEvent as SubmitEvent).submitter\n\n  let action = actionHref\n\n  if (submitter) {\n    if (process.env.NODE_ENV === 'development') {\n      // the way server actions are encoded (e.g. `formMethod=\"post\")\n      // causes some unnecessary dev-mode warnings from `hasUnsupportedSubmitterAttributes`.\n      // we'd bail out anyway, but we just do it silently.\n      if (hasReactServerActionAttributes(submitter)) {\n        return\n      }\n    }\n\n    if (hasUnsupportedSubmitterAttributes(submitter)) {\n      return\n    }\n\n    // client actions have `formAction=\"javascript:...\"`. We obviously can't prefetch/navigate to that.\n    if (hasReactClientActionAttributes(submitter)) {\n      return\n    }\n\n    // If the submitter specified an alternate formAction,\n    // use that URL instead -- this is what a native form would do.\n    // NOTE: `submitter.formAction` is unreliable, because it will give us `location.href` if it *wasn't* set\n    // NOTE: this should not have `basePath` added, because we can't add it before hydration\n    const submitterFormAction = submitter.getAttribute('formAction')\n    if (submitterFormAction !== null) {\n      if (process.env.NODE_ENV === 'development') {\n        checkFormActionUrl(submitterFormAction, 'formAction')\n      }\n      action = submitterFormAction\n    }\n  }\n\n  const targetUrl = createFormSubmitDestinationUrl(action, formElement)\n\n  // Finally, no more reasons for bailing out.\n  event.preventDefault()\n\n  const method = replace ? 'replace' : 'push'\n  const targetHref = targetUrl.href\n  router[method](targetHref, { scroll })\n}\n\nfunction hasReactServerActionAttributes(submitter: HTMLElement) {\n  // https://github.com/facebook/react/blob/942eb80381b96f8410eab1bef1c539bed1ab0eb1/packages/react-client/src/ReactFlightReplyClient.js#L931-L934\n  const name = submitter.getAttribute('name')\n  return (\n    name && (name.startsWith('$ACTION_ID_') || name.startsWith('$ACTION_REF_'))\n  )\n}\n"],"names":["useCallback","useContext","addBasePath","useMergedRef","AppRouterContext","checkFormActionUrl","createFormSubmitDestinationUrl","DISALLOWED_FORM_PROPS","hasReactClientActionAttributes","hasUnsupportedSubmitterAttributes","mountFormInstance","unmountPrefetchableInstance","FetchStrategy","Form","replace","scroll","prefetch","prefetchProp","ref","externalRef","props","router","actionProp","action","isNavigatingForm","process","env","NODE_ENV","undefined","console","error","key","isPrefetchEnabled","observeFormVisibilityOnMount","element","PPR","mergedRef","form","actionHref","onSubmit","event","onFormSubmit","defaultPrevented","formElement","currentTarget","submitter","nativeEvent","hasReactServerActionAttributes","submitterFormAction","getAttribute","targetUrl","preventDefault","method","targetHref","href","name","startsWith"],"mappings":"AAAA;;AAEA,SAASA,WAAW,EAAkBC,UAAU,QAAQ,QAAO;AAC/D,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SACEC,gBAAgB,QAEX,qDAAoD;AAC3D,SACEC,kBAAkB,EAClBC,8BAA8B,EAC9BC,qBAAqB,EACrBC,8BAA8B,EAC9BC,iCAAiC,QAE5B,iBAAgB;AACvB,SACEC,iBAAiB,EACjBC,2BAA2B,QACtB,sBAAqB;AAC5B,SAASC,aAAa,QAAQ,oCAAmC;AAIjE,eAAe,SAASC,KAAK,EAC3BC,OAAO,EACPC,MAAM,EACNC,UAAUC,YAAY,EACtBC,KAAKC,WAAW,EAChB,GAAGC,OACO;IACV,MAAMC,SAASpB,WAAWG;IAE1B,MAAMkB,aAAaF,MAAMG,MAAM;IAC/B,MAAMC,mBAAmB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