@nexub/react 4.6.0 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accessibility.json +1 -1
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/hooks/useScopedSeed.d.ts +11 -0
- package/dist/hooks/useScopedSeed.js +24 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/package.json +6 -6
package/accessibility.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.
|
|
2
|
+
"version": "4.7.0",
|
|
3
3
|
"standard": "WCAG 2.2 Level AA",
|
|
4
4
|
"method": {
|
|
5
5
|
"automated": "axe-core rules tagged wcag2a, wcag2aa, wcag21a, wcag21aa and wcag22aa, run on every Storybook story in light and dark on every pull request; a new violation fails the build.",
|
|
@@ -4,7 +4,7 @@ import type { ToneValue } from '@nexub/core';
|
|
|
4
4
|
export type { ToneValue };
|
|
5
5
|
export { toneTextClasses } from '../../utils/control.js';
|
|
6
6
|
export declare const buttonVariants: (props?: ({
|
|
7
|
-
variant?: "accent" | "text" | "link" | "outline" | "glass" | "ghost" | "subtle" | "filled" | "tonal" | "outlined" | "hero" | "
|
|
7
|
+
variant?: "accent" | "text" | "link" | "outline" | "primary" | "glass" | "ghost" | "subtle" | "filled" | "tonal" | "outlined" | "hero" | "secondary" | "destructive" | null | undefined;
|
|
8
8
|
size?: "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
9
9
|
fullWidth?: boolean | null | undefined;
|
|
10
10
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const useIsomorphicLayoutEffect: typeof
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
export declare const useIsomorphicLayoutEffect: typeof useEffect;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 4.7: recolours one element (and everything inside it) from a brand seed, like
|
|
4
|
+
* <ThemeProvider seed> but scoped, e.g. to preview a customer's brand on one
|
|
5
|
+
* card or section. Writes the seeded role variables through the CSSOM (strict-
|
|
6
|
+
* CSP safe) and removes them when the seed is cleared or the component unmounts.
|
|
7
|
+
* Lazy-loads @nexub/tokens/seed, so the colour library stays out of the main bundle.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useScopedSeed<T extends HTMLElement>(ref: React.RefObject<T | null>, seed: string | null | undefined, options?: {
|
|
10
|
+
target?: 'primary' | 'tertiary';
|
|
11
|
+
}): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
function useScopedSeed(ref, seed, options = {}) {
|
|
4
|
+
const { target = "primary" } = options;
|
|
5
|
+
React.useEffect(() => {
|
|
6
|
+
const el = ref.current;
|
|
7
|
+
if (!el || !seed) return;
|
|
8
|
+
let applied = [];
|
|
9
|
+
let cancelled = false;
|
|
10
|
+
import("@nexub/tokens/seed").then(({ createSeedTheme }) => {
|
|
11
|
+
if (cancelled) return;
|
|
12
|
+
const vars = createSeedTheme(seed, { target });
|
|
13
|
+
for (const [k, v] of Object.entries(vars)) el.style.setProperty(k, v);
|
|
14
|
+
applied = Object.keys(vars);
|
|
15
|
+
});
|
|
16
|
+
return () => {
|
|
17
|
+
cancelled = true;
|
|
18
|
+
for (const k of applied) el.style.removeProperty(k);
|
|
19
|
+
};
|
|
20
|
+
}, [ref, seed, target]);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
useScopedSeed
|
|
24
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { cn } from './utils/cn.js';
|
|
2
2
|
export type { Size } from './utils/control.js';
|
|
3
3
|
export { startViewTransition } from './utils/viewTransition.js';
|
|
4
|
+
export { useScopedSeed } from './hooks/useScopedSeed.js';
|
|
4
5
|
export { useControllableState } from './hooks/useControllableState.js';
|
|
5
6
|
export { useDisclosure } from './hooks/useDisclosure.js';
|
|
6
7
|
export { useIsomorphicLayoutEffect } from './hooks/useIsomorphicLayoutEffect.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cn } from "./utils/cn.js";
|
|
2
2
|
import { startViewTransition } from "./utils/viewTransition.js";
|
|
3
|
+
import { useScopedSeed } from "./hooks/useScopedSeed.js";
|
|
3
4
|
import { useControllableState } from "./hooks/useControllableState.js";
|
|
4
5
|
import { useDisclosure } from "./hooks/useDisclosure.js";
|
|
5
6
|
import { useIsomorphicLayoutEffect } from "./hooks/useIsomorphicLayoutEffect.js";
|
|
@@ -297,6 +298,7 @@ export {
|
|
|
297
298
|
useNexubMessages,
|
|
298
299
|
usePointerSheen,
|
|
299
300
|
usePrefersReducedMotion,
|
|
301
|
+
useScopedSeed,
|
|
300
302
|
useTheme,
|
|
301
303
|
useToastStore
|
|
302
304
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexub/react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "React component library for Nexub Design System — 90+ accessible, themeable UI components built on Radix UI primitives.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -81,13 +81,13 @@
|
|
|
81
81
|
"date-fns": "^4.4.0",
|
|
82
82
|
"react-day-picker": "^10.0.2",
|
|
83
83
|
"tailwind-merge": "^3.7.0",
|
|
84
|
-
"@nexub/
|
|
85
|
-
"@nexub/
|
|
84
|
+
"@nexub/icons": "4.7.0",
|
|
85
|
+
"@nexub/core": "4.7.0"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"react": ">=18 <20",
|
|
89
89
|
"react-dom": ">=18 <20",
|
|
90
|
-
"@nexub/tokens": "^4.
|
|
90
|
+
"@nexub/tokens": "^4.7.0"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@playwright/test": "1.64.0",
|
|
@@ -113,8 +113,8 @@
|
|
|
113
113
|
"vaul": "1.1.2",
|
|
114
114
|
"vite": "^8.3.5",
|
|
115
115
|
"vitest": "^5.0.5",
|
|
116
|
-
"@nexub/themes": "4.
|
|
117
|
-
"@nexub/tokens": "4.
|
|
116
|
+
"@nexub/themes": "4.7.0",
|
|
117
|
+
"@nexub/tokens": "4.7.0"
|
|
118
118
|
},
|
|
119
119
|
"scripts": {
|
|
120
120
|
"build": "rm -rf dist && tsup && tsc -p tsconfig.build.json && rm -f dist/vendor/*.d.ts && node scripts/check-dts.mjs && tailwindcss -i src/styles.css -o dist/styles.css --minify && cp -R ../themes/src/fonts dist/fonts",
|