diff --git a/apps/next/app/page.tsx b/apps/next/app/page.tsx index 8d0a036..6714861 100644 --- a/apps/next/app/page.tsx +++ b/apps/next/app/page.tsx @@ -1,4 +1,4 @@ -import { Iconify } from "@oktaytest/ui"; +import { Iconify } from "@oktaytest/react"; import styles from "../styles/index.module.css"; diff --git a/apps/next/package.json b/apps/next/package.json index 43df77a..87fc836 100644 --- a/apps/next/package.json +++ b/apps/next/package.json @@ -9,7 +9,7 @@ "lint": "next lint" }, "dependencies": { - "@oktaytest/ui": "*", + "@oktaytest/react": "*", "next": "^14.0.4", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/apps/rollup-react/package.json b/apps/rollup-react/package.json index 4c86835..8d27947 100644 --- a/apps/rollup-react/package.json +++ b/apps/rollup-react/package.json @@ -9,7 +9,7 @@ "dev": "rollup -c --watch" }, "dependencies": { - "@oktaytest/ui": "*", + "@oktaytest/react": "*", "react": "^18.3.1", "react-dom": "^18.3.1" }, diff --git a/apps/rollup-react/src/App.jsx b/apps/rollup-react/src/App.jsx index 775696a..8a849f2 100644 --- a/apps/rollup-react/src/App.jsx +++ b/apps/rollup-react/src/App.jsx @@ -1,5 +1,5 @@ import React from "react"; -import { Iconify } from "@oktaytest/ui"; +import { Iconify } from "@oktaytest/react"; const App = () => { return ( diff --git a/apps/rspack-react/package.json b/apps/rspack-react/package.json index 1152671..0aacec3 100644 --- a/apps/rspack-react/package.json +++ b/apps/rspack-react/package.json @@ -9,7 +9,7 @@ "dependencies": { "react": "^18.2.0", "react-dom": "^18.2.0", - "@oktaytest/ui": "*" + "@oktaytest/react": "*" }, "devDependencies": { "@rspack/plugin-react-refresh": "1.0.0", diff --git a/apps/rspack-react/src/App.jsx b/apps/rspack-react/src/App.jsx index 67d8a56..87e59cb 100644 --- a/apps/rspack-react/src/App.jsx +++ b/apps/rspack-react/src/App.jsx @@ -1,5 +1,6 @@ import React from "react"; -import { Iconify } from "@oktaytest/ui"; +import { Iconify } from "@oktaytest/react"; + import "./App.css"; function App() { diff --git a/apps/vite-react/package.json b/apps/vite-react/package.json index 2fa865a..cd32484 100644 --- a/apps/vite-react/package.json +++ b/apps/vite-react/package.json @@ -10,7 +10,7 @@ "preview": "vite preview" }, "dependencies": { - "@oktaytest/ui": "*", + "@oktaytest/react": "*", "react": "^18.3.1", "react-dom": "^18.3.1" }, diff --git a/apps/vite-react/src/App.tsx b/apps/vite-react/src/App.tsx index 3c94cd5..a2e1ddd 100644 --- a/apps/vite-react/src/App.tsx +++ b/apps/vite-react/src/App.tsx @@ -1,6 +1,6 @@ import "./App.css"; -import { Iconify } from "@oktaytest/ui"; +import { Iconify } from "@oktaytest/react"; function App() { return ( diff --git a/packages/native/src/iconify.tsx b/packages/native/src/iconify.tsx index 89be245..eca1f01 100644 --- a/packages/native/src/iconify.tsx +++ b/packages/native/src/iconify.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect, ReactNode } from "react"; +import React from "react"; import { IconifyProps, RuntimeIcon, RuntimeIconifyProps } from "./types"; import { setAttributes } from "./utils"; @@ -72,7 +72,9 @@ const getComponent = async (props: RuntimeIconifyProps) => { }; export const Iconify = (props: IconifyProps) => { - const [Component, setComponent] = useState(null); + const [Component, setComponent] = React.useState( + null + ); const renderIcon = async () => { const icon = await getIcon(props.name); @@ -85,7 +87,7 @@ export const Iconify = (props: IconifyProps) => { setComponent(component); }; - useEffect(() => { + React.useEffect(() => { renderIcon(); }, [props]); diff --git a/packages/ui/.gitignore b/packages/react/.gitignore similarity index 100% rename from packages/ui/.gitignore rename to packages/react/.gitignore diff --git a/packages/ui/CHANGELOG.md b/packages/react/CHANGELOG.md similarity index 100% rename from packages/ui/CHANGELOG.md rename to packages/react/CHANGELOG.md diff --git a/packages/ui/package.json b/packages/react/package.json similarity index 83% rename from packages/ui/package.json rename to packages/react/package.json index 2495537..46d043e 100644 --- a/packages/ui/package.json +++ b/packages/react/package.json @@ -1,5 +1,5 @@ { - "name": "@oktaytest/ui", + "name": "@oktaytest/react", "version": "0.0.119", "main": "./dist/index.js", "module": "./dist/index.mjs", @@ -29,7 +29,6 @@ "devDependencies": { "@oktaytest/typescript-config": "*", "@types/react": "^18.2.46", - "@types/react-native": "^0.73.0", "tsup": "^8.0.1", "typescript": "^5.3.3" }, @@ -38,8 +37,6 @@ "@oktaytest/core": "*" }, "peerDependencies": { - "react": ">=18.2.0", - "react-native": ">=0.63.0", - "react-native-svg": ">=13.2.0" + "react": ">=18.2.0" } } diff --git a/packages/ui/src/iconify.tsx b/packages/react/src/iconify.tsx similarity index 70% rename from packages/ui/src/iconify.tsx rename to packages/react/src/iconify.tsx index 5205773..1fda595 100644 --- a/packages/ui/src/iconify.tsx +++ b/packages/react/src/iconify.tsx @@ -1,19 +1,8 @@ -import React, { useState, useEffect, ReactNode } from "react"; +import React from "react"; + import { IconifyProps, RuntimeIcon, RuntimeIconifyProps } from "./types"; import { setAttributes } from "./utils"; -const isReactNative = async () => { - try { - if (typeof navigator === "undefined") return true; - - require("react-native"); - - return true; - } catch (error) { - return false; - } -}; - const getIcon = (iconName: string) => new Promise(async (resolve, reject) => { try { @@ -46,19 +35,6 @@ const getIcon = (iconName: string) => } }); -const nativeIcon = async (props: RuntimeIconifyProps) => { - const { SvgXml } = require("react-native-svg"); - - return ( - - ); -}; - const webIcon = async (props: RuntimeIconifyProps) => { // @ts-ignore const parse = await import("html-react-parser"); @@ -69,15 +45,13 @@ const webIcon = async (props: RuntimeIconifyProps) => { const getComponent = async (props: RuntimeIconifyProps) => { const formatted = setAttributes(props); - const isNative = await isReactNative(); - - if (isNative) return nativeIcon(formatted); - return webIcon(formatted); }; export const Iconify = (props: IconifyProps) => { - const [Component, setComponent] = useState(null); + const [Component, setComponent] = React.useState( + null + ); const renderIcon = async () => { const icon = await getIcon(props.name); @@ -90,7 +64,7 @@ export const Iconify = (props: IconifyProps) => { setComponent(component); }; - useEffect(() => { + React.useEffect(() => { renderIcon(); }, [props]); diff --git a/packages/ui/src/index.tsx b/packages/react/src/index.tsx similarity index 100% rename from packages/ui/src/index.tsx rename to packages/react/src/index.tsx diff --git a/packages/ui/src/types.ts b/packages/react/src/types.ts similarity index 100% rename from packages/ui/src/types.ts rename to packages/react/src/types.ts diff --git a/packages/ui/src/utils.ts b/packages/react/src/utils.ts similarity index 100% rename from packages/ui/src/utils.ts rename to packages/react/src/utils.ts diff --git a/packages/ui/tsconfig.json b/packages/react/tsconfig.json similarity index 100% rename from packages/ui/tsconfig.json rename to packages/react/tsconfig.json diff --git a/packages/ui/tsup.config.ts b/packages/react/tsup.config.ts similarity index 100% rename from packages/ui/tsup.config.ts rename to packages/react/tsup.config.ts diff --git a/turbo.json b/turbo.json index b2b75d2..9a298bc 100644 --- a/turbo.json +++ b/turbo.json @@ -8,7 +8,7 @@ "dependsOn": ["^build"] }, - "ui#build": { + "react#build": { "dependsOn": ["core#build"] }, "native#build": { @@ -55,16 +55,16 @@ ] }, "next#build": { - "dependsOn": ["webpack#build", "ui#build"] + "dependsOn": ["webpack#build", "react#build"] }, "vite-react#build": { - "dependsOn": ["vite#build", "ui#build"] + "dependsOn": ["vite#build", "react#build"] }, "rspack-react#build": { - "dependsOn": ["rspack#build", "ui#build"] + "dependsOn": ["rspack#build", "react#build"] }, "rollup-react#build": { - "dependsOn": ["rollup#build", "ui#build"] + "dependsOn": ["rollup#build", "react#build"] }, "vite-vue#build": { "dependsOn": ["vite#build", "vue#build"]