@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
1 lines • 1.8 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","names":["useEnvironment"],"sources":["../../../../src/hooks/use-os/index.ts"],"sourcesContent":["import { useEnvironment } from \"../../core\"\nimport { isUndefined } from \"../../utils\"\n\nexport type OS =\n | \"android\"\n | \"chromeos\"\n | \"ios\"\n | \"linux\"\n | \"macos\"\n | \"undetermined\"\n | \"windows\"\n\nconst getOS = ({ navigator: { userAgent } }: Window): OS => {\n const macos = /(Macintosh)|(MacIntel)|(MacPPC)|(Mac68K)/i\n const windows = /(Win32)|(Win64)|(Windows)|(WinCE)/i\n const ios = /(iPhone)|(iPad)|(iPod)/i\n const android = /Android/i\n const linux = /Linux/i\n const chromeos = /CrOS/i\n\n if (macos.test(userAgent)) return \"macos\"\n if (ios.test(userAgent)) return \"ios\"\n if (windows.test(userAgent)) return \"windows\"\n if (android.test(userAgent)) return \"android\"\n if (linux.test(userAgent)) return \"linux\"\n if (chromeos.test(userAgent)) return \"chromeos\"\n\n return \"undetermined\"\n}\n\n/**\n * `useOS` is a custom hook that returns the user's OS.\n *\n * @see https://yamada-ui.com/docs/hooks/use-os\n */\nexport const useOS = (): OS => {\n const { getWindow } = useEnvironment()\n const win = getWindow()\n\n if (!isUndefined(win)) return getOS(win)\n\n return \"undetermined\"\n}\n"],"mappings":";;;;AAYA,MAAM,SAAS,EAAE,WAAW,EAAE,kBAA8B;CAC1D,MAAM,QAAQ;CACd,MAAM,UAAU;CAChB,MAAM,MAAM;CACZ,MAAM,UAAU;CAChB,MAAM,QAAQ;CACd,MAAM,WAAW;AAEjB,KAAI,MAAM,KAAK,UAAU,CAAE,QAAO;AAClC,KAAI,IAAI,KAAK,UAAU,CAAE,QAAO;AAChC,KAAI,QAAQ,KAAK,UAAU,CAAE,QAAO;AACpC,KAAI,QAAQ,KAAK,UAAU,CAAE,QAAO;AACpC,KAAI,MAAM,KAAK,UAAU,CAAE,QAAO;AAClC,KAAI,SAAS,KAAK,UAAU,CAAE,QAAO;AAErC,QAAO;;;;;;;AAQT,MAAa,cAAkB;CAC7B,MAAM,EAAE,cAAcA,6CAAgB;CACtC,MAAM,MAAM,WAAW;AAEvB,KAAI,oDAAa,IAAI,CAAE,QAAO,MAAM,IAAI;AAExC,QAAO"}