{"version":3,"file":"migration-helpers.cjs","sources":["../../src/util/migration-helpers.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { usePrevious } from \"./state-hooks\";\n\nexport function useComponentDidUpdate<\n  Props extends object,\n  State extends object,\n>(\n  componentUpdater: (prevProps: Props, prevState: State) => void,\n  props = {} as Props,\n  state = {} as State,\n) {\n  /** Run a function every time props and state changes.\n   * Analogous to componentDidUpdate in a class component. This is useful for incrementally\n   * transitioning from class to functional React components. */\n  const prevProps = usePrevious<Props>(props);\n  const prevState = usePrevious<State>(state);\n  useEffect(\n    () =>\n      console.warn(\n        \"The useComponentDidUpdate hook performs poorly and is only meant \" +\n          \"to ease the transition to functional components. \" +\n          \"Please transition to direct use of useEffect to remove this warning.\",\n      ),\n    [],\n  );\n  useEffect(() => {\n    if (prevProps == null) return;\n    componentUpdater(prevProps, prevState ?? ({} as State));\n  }, [...Object.values(props ?? {}), ...Object.values(state ?? {})]);\n}\n\nexport function useWarning(message: string, isEnabled: boolean = true) {\n  /** This hook is used to warn developers for migration purposes */\n  useEffect(() => {\n    if (isEnabled) console.warn(message);\n  }, [message, isEnabled]);\n}\n\nexport function useDeprecationWarning(\n  name: string = \"This component\",\n  replacedBy?: string,\n) {\n  /** This hook is used to warn developers for migration purposes */\n  let msg = `${name} is deprecated and will be removed in a future release`;\n  if (replacedBy) {\n    msg += `. Please use ${replacedBy} instead`;\n  }\n  useWarning(msg);\n}\n"],"names":["usePrevious","useEffect"],"mappings":";;;;AAGO,SAAS,sBAId,kBACA,QAAQ,CAAA,GACR,QAAQ,CAAA,GACR;AAIA,QAAM,YAAYA,WAAAA,YAAmB,KAAK;AAC1C,QAAM,YAAYA,WAAAA,YAAmB,KAAK;AAC1CC,QAAAA;AAAAA,IACE,MACE,QAAQ;AAAA,MACN;AAAA,IAAA;AAAA,IAIJ,CAAA;AAAA,EAAC;AAEHA,QAAAA,UAAU,MAAM;AACd,QAAI,aAAa,KAAM;AACvB,qBAAiB,WAAW,aAAc,EAAY;AAAA,EACxD,GAAG,CAAC,GAAG,OAAO,OAAO,SAAS,CAAA,CAAE,GAAG,GAAG,OAAO,OAAO,SAAS,CAAA,CAAE,CAAC,CAAC;AACnE;AAEO,SAAS,WAAW,SAAiB,YAAqB,MAAM;AAErEA,QAAAA,UAAU,MAAM;AACd,QAAI,UAAW,SAAQ,KAAK,OAAO;AAAA,EACrC,GAAG,CAAC,SAAS,SAAS,CAAC;AACzB;AAEO,SAAS,sBACd,OAAe,kBACf,YACA;AAEA,MAAI,MAAM,GAAG,IAAI;AACjB,MAAI,YAAY;AACd,WAAO,gBAAgB,UAAU;AAAA,EACnC;AACA,aAAW,GAAG;AAChB;;;;"}