# entropy-ui

Shared React Native UI primitives, hooks, services, and auth screens for Entropy Softworks Expo
apps. Targets React 19 / React Native 0.83 / Expo SDK 55 with NativeWind v4.

Ships **both** forms via conditional exports: React Native / Metro consumers resolve the original
TypeScript source (`source` / `react-native` conditions) so NativeWind's `className` transform runs
at the consumer; other bundlers (web, Node) resolve the compiled `lib/` output (`default` condition)
with type declarations. JSX is preserved in the compiled output (`jsx: preserve`) so the `className`
transform still applies there too.

### Runtime requirements

- **Node 20.3+** (web tooling). `utils/fetch` uses `AbortSignal.any`, which requires Node 20.3,
  Safari 17.4, Chrome 116, Firefox 124, or newer. Older runtimes throw on import.
- **iOS 16+ / Android 9+ / Chromium 116+ / Safari 17.4+ / Firefox 124+** at runtime.

The package is **UI + auth screens + cross-cutting hooks/services** that are reusable across Entropy
Softworks consumer apps (vault, bootstrap, paperhands, pirates, …). App-specific branding (logo,
copy, route map) is parameterised through props and a config provider.

## Installation

```bash
npm install @entropy-softworks/ui
```

Peer deps the consumer must provide (see `peerDependencies` in `package.json`): `react`,
`react-native`, `expo`, `expo-router`, `nativewind`, `react-hook-form`, `zod`,
`lucide-react-native`, the `@rn-primitives/*` family, `@tanstack/react-query`,
`class-variance-authority`, `clsx`, `tailwind-merge`, `react-native-toast-message`, plus the various
Expo modules referenced (`expo-image`, `expo-blur`, `expo-clipboard`, …).

## Quick Start

### Tailwind preset

```js
// tailwind.config.js
module.exports = {
  presets: [require("@entropy-softworks/ui/tailwind-preset")],
  content: [
    "./app/**/*.{js,jsx,ts,tsx}",
    "./components/**/*.{js,jsx,ts,tsx}",
    "./node_modules/@entropy-softworks/ui/**/*.{js,jsx,ts,tsx}",
  ],
};
```

### Global CSS

```css
/* styles/globals.css */
@import "@entropy-softworks/ui/styles/globals.css";
```

### Primitives

```tsx
import { Button, Card, Input, Heading, MutedText } from "@entropy-softworks/ui";
```

### Auth screens

```tsx
// app/(auth)/login.tsx
import { LoginScreen } from "@entropy-softworks/ui/screens/auth";
import { BootstrapLogo } from "@/components/BootstrapLogo";

export default function Login() {
  return <LoginScreen Logo={BootstrapLogo} appName="Bootstrap" />;
}
```

## Exports

| Subpath                                    | Contents                                                                                                                        |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
| `@entropy-softworks/ui`                    | UI primitives (Button, Card, Input, Text, Heading, MutedText, Checkbox, Dialog, …)                                              |
| `@entropy-softworks/ui/screens/auth`       | Welcome, Login, Register, MFA challenge/enroll, Verify-email, Forgot/Reset-password, Server-config, Terms, Privacy, Import-data |
| `@entropy-softworks/ui/hooks`              | useAuth, useShakeAnimation, useAutoLock                                                                                         |
| `@entropy-softworks/ui/services`           | auth.service, api-config, hibp                                                                                                  |
| `@entropy-softworks/ui/context`            | ThemeContext, NotificationContext, AppConfigContext                                                                             |
| `@entropy-softworks/ui/forms`              | form-error, shake-field                                                                                                         |
| `@entropy-softworks/ui/utils`              | cn, …                                                                                                                           |
| `@entropy-softworks/ui/tailwind-preset`    | Tailwind preset (colors, typography, animations)                                                                                |
| `@entropy-softworks/ui/styles/globals.css` | Global stylesheet (Tailwind directives + CSS vars + animations)                                                                 |

## Development

```bash
git clone git@gitlab.com:entropysoftworks/packages/entropy-ui.git
cd entropy-ui
npm install
npm run type-check
npm run lint
npm test
npm run build   # compile src -> lib (also runs automatically on publish)
```

## Publishing

Published to the public npm registry on a `vX.Y.Z` git tag (CI runs `npm publish`; `prepublishOnly`
builds `lib/` first). The tag must match `version` in `package.json`. Bump the version, tag, push.

See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full workflow.

## Versioning

Semantic Versioning. Breaking API changes bump the major; new components or screens bump the minor;
bug fixes bump the patch. See [CHANGELOG.md](./CHANGELOG.md).

## License

MIT — see [LICENSE](./LICENSE).
