feat(core-consent): add ConsentProvider + useConsent() React subpath

Adds the ./react subpath to @repo/core-consent following the same
pattern as @repo/core-analytics/react:

- ConsentProvider wraps IConsent in React context
- useConsent() returns the injected IConsent or throws ConsentContextError
- RTL tests cover context propagation, grant/withdraw delegation,
  isGranted state reflection, getCategories, and missing-provider error
- package.json: ./react export + React optional peerDep + RTL devDeps
- tsconfig: extend react-library.json, include .tsx
- vitest.config: jsdom environment for .test.tsx + jsdom setup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-19 19:19:47 +00:00
parent 33e3c093ad
commit 9b6deac954
8 changed files with 188 additions and 32 deletions

View File

@@ -1,9 +1,17 @@
import path from "node:path";
import { mergeConfig } from "vitest/config";
import { defineConfig, mergeConfig } from "vitest/config";
import { nodeVitestConfig } from "@repo/core-typescript/vitest.base.node";
export default mergeConfig(nodeVitestConfig, {
resolve: {
alias: { "@": path.resolve(__dirname, "./src") },
},
});
export default mergeConfig(
nodeVitestConfig,
defineConfig({
test: {
include: ["src/**/*.test.{ts,tsx}", "tests/**/*.test.{ts,tsx}"],
environmentMatchGlobs: [["**/*.test.tsx", "jsdom"]],
setupFiles: ["@repo/core-testing/setup/jsdom"],
},
resolve: {
alias: { "@": path.resolve(__dirname, "./src") },
},
}),
);