@ansh-ui/react 0.2.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/LICENSE +21 -0
- package/dist/chunk-5CFQFMP5.js +178 -0
- package/dist/chunk-5CFQFMP5.js.map +1 -0
- package/dist/chunk-6VRF7X5C.cjs +164 -0
- package/dist/chunk-6VRF7X5C.cjs.map +1 -0
- package/dist/chunk-AVPEA5PB.cjs +718 -0
- package/dist/chunk-AVPEA5PB.cjs.map +1 -0
- package/dist/chunk-C32LKF23.cjs +198 -0
- package/dist/chunk-C32LKF23.cjs.map +1 -0
- package/dist/chunk-C5JG6TMM.cjs +1200 -0
- package/dist/chunk-C5JG6TMM.cjs.map +1 -0
- package/dist/chunk-DATBU46V.cjs +614 -0
- package/dist/chunk-DATBU46V.cjs.map +1 -0
- package/dist/chunk-EGG4CP7C.js +320 -0
- package/dist/chunk-EGG4CP7C.js.map +1 -0
- package/dist/chunk-H34OXXJU.js +55 -0
- package/dist/chunk-H34OXXJU.js.map +1 -0
- package/dist/chunk-HO2YSF5O.js +187 -0
- package/dist/chunk-HO2YSF5O.js.map +1 -0
- package/dist/chunk-HPGCILO4.js +760 -0
- package/dist/chunk-HPGCILO4.js.map +1 -0
- package/dist/chunk-IBXLC5IE.js +154 -0
- package/dist/chunk-IBXLC5IE.js.map +1 -0
- package/dist/chunk-LDCZQP3R.js +1185 -0
- package/dist/chunk-LDCZQP3R.js.map +1 -0
- package/dist/chunk-LXCIXR5T.js +27 -0
- package/dist/chunk-LXCIXR5T.js.map +1 -0
- package/dist/chunk-O2PX54KX.js +94 -0
- package/dist/chunk-O2PX54KX.js.map +1 -0
- package/dist/chunk-OHBWBXLO.cjs +101 -0
- package/dist/chunk-OHBWBXLO.cjs.map +1 -0
- package/dist/chunk-OJN5JBNP.cjs +776 -0
- package/dist/chunk-OJN5JBNP.cjs.map +1 -0
- package/dist/chunk-OLTS6G5M.js +606 -0
- package/dist/chunk-OLTS6G5M.js.map +1 -0
- package/dist/chunk-PO5DU3FU.cjs +29 -0
- package/dist/chunk-PO5DU3FU.cjs.map +1 -0
- package/dist/chunk-QO3E7TJS.js +2940 -0
- package/dist/chunk-QO3E7TJS.js.map +1 -0
- package/dist/chunk-RHTLNSVW.cjs +2976 -0
- package/dist/chunk-RHTLNSVW.cjs.map +1 -0
- package/dist/chunk-SFU5EPSN.cjs +61 -0
- package/dist/chunk-SFU5EPSN.cjs.map +1 -0
- package/dist/chunk-T4AK2KLM.js +699 -0
- package/dist/chunk-T4AK2KLM.js.map +1 -0
- package/dist/chunk-WGYNCSTP.cjs +333 -0
- package/dist/chunk-WGYNCSTP.cjs.map +1 -0
- package/dist/chunk-XEP6P7E6.js +279 -0
- package/dist/chunk-XEP6P7E6.js.map +1 -0
- package/dist/chunk-XMXECSQO.cjs +286 -0
- package/dist/chunk-XMXECSQO.cjs.map +1 -0
- package/dist/chunk-ZWAFLHC2.cjs +181 -0
- package/dist/chunk-ZWAFLHC2.cjs.map +1 -0
- package/dist/data.cjs +71 -0
- package/dist/data.cjs.map +1 -0
- package/dist/data.d.cts +316 -0
- package/dist/data.d.ts +316 -0
- package/dist/data.js +6 -0
- package/dist/data.js.map +1 -0
- package/dist/form.cjs +153 -0
- package/dist/form.cjs.map +1 -0
- package/dist/form.d.cts +660 -0
- package/dist/form.d.ts +660 -0
- package/dist/form.js +8 -0
- package/dist/form.js.map +1 -0
- package/dist/index.cjs +1641 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +552 -0
- package/dist/index.d.ts +552 -0
- package/dist/index.js +956 -0
- package/dist/index.js.map +1 -0
- package/dist/layout.cjs +68 -0
- package/dist/layout.cjs.map +1 -0
- package/dist/layout.d.cts +169 -0
- package/dist/layout.d.ts +169 -0
- package/dist/layout.js +7 -0
- package/dist/layout.js.map +1 -0
- package/dist/motion-CQmCq6_k.d.ts +395 -0
- package/dist/motion-CSX4g2N8.d.cts +395 -0
- package/dist/motion.cjs +79 -0
- package/dist/motion.cjs.map +1 -0
- package/dist/motion.d.cts +4 -0
- package/dist/motion.d.ts +4 -0
- package/dist/motion.js +6 -0
- package/dist/motion.js.map +1 -0
- package/dist/navigation.cjs +48 -0
- package/dist/navigation.cjs.map +1 -0
- package/dist/navigation.d.cts +210 -0
- package/dist/navigation.d.ts +210 -0
- package/dist/navigation.js +7 -0
- package/dist/navigation.js.map +1 -0
- package/dist/overlay.cjs +69 -0
- package/dist/overlay.cjs.map +1 -0
- package/dist/overlay.d.cts +330 -0
- package/dist/overlay.d.ts +330 -0
- package/dist/overlay.js +8 -0
- package/dist/overlay.js.map +1 -0
- package/dist/position-DVScKcaa.d.cts +66 -0
- package/dist/position-DVScKcaa.d.ts +66 -0
- package/dist/primitives.cjs +162 -0
- package/dist/primitives.cjs.map +1 -0
- package/dist/primitives.d.cts +294 -0
- package/dist/primitives.d.ts +294 -0
- package/dist/primitives.js +9 -0
- package/dist/primitives.js.map +1 -0
- package/dist/sidebar-D-PafAXw.d.cts +71 -0
- package/dist/sidebar-D-PafAXw.d.ts +71 -0
- package/dist/styles.css +5575 -0
- package/dist/use-observers-B9qtimrk.d.cts +99 -0
- package/dist/use-observers-B9qtimrk.d.ts +99 -0
- package/package.json +92 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { BudgetReport, PointerState, ScrollTrackOptions, ScrollProgress, FrameState } from '@ansh-ui/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Subscribe to the shared ticker.
|
|
6
|
+
*
|
|
7
|
+
* The callback is held in a ref and never re-subscribes, so a component that closes over changing
|
|
8
|
+
* props doesn't tear down and rebuild its subscription on every render. That matters: resubscribing
|
|
9
|
+
* changes execution order within the phase, which can visibly reorder dependent animations.
|
|
10
|
+
*/
|
|
11
|
+
declare function useTicker(callback: (state: FrameState) => void, options?: {
|
|
12
|
+
phase?: 'read' | 'compute' | 'write' | 'post';
|
|
13
|
+
priority?: number;
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
}): void;
|
|
16
|
+
interface InViewOptions {
|
|
17
|
+
/** Fraction visible before triggering, in `[0, 1]`. Default `0`. */
|
|
18
|
+
threshold?: number;
|
|
19
|
+
/** Extra margin around the root. Default `'0px'`. */
|
|
20
|
+
rootMargin?: string;
|
|
21
|
+
/** Stop observing after the first intersection. Default `false`. */
|
|
22
|
+
once?: boolean;
|
|
23
|
+
root?: Element | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Is the element in the viewport?
|
|
27
|
+
*
|
|
28
|
+
* Uses the pooled observer, so a page with 200 scroll-revealed elements creates one
|
|
29
|
+
* `IntersectionObserver` rather than 200.
|
|
30
|
+
*/
|
|
31
|
+
declare function useInView<El extends Element = HTMLDivElement>(options?: InViewOptions): [RefObject<El | null>, boolean];
|
|
32
|
+
/**
|
|
33
|
+
* Track an element's size.
|
|
34
|
+
*
|
|
35
|
+
* Returns state rather than a MotionValue because size changes at interaction rate, not frame
|
|
36
|
+
* rate, so a re-render per change is appropriate and far more ergonomic.
|
|
37
|
+
*/
|
|
38
|
+
declare function useElementSize<El extends Element = HTMLDivElement>(): [
|
|
39
|
+
RefObject<El | null>,
|
|
40
|
+
{
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
/**
|
|
46
|
+
* Track an element's scroll progress through the viewport.
|
|
47
|
+
*
|
|
48
|
+
* The returned progress is a **ref**, not state, deliberately — scroll progress changes every
|
|
49
|
+
* frame, and rendering on each change would make scrolling janky. Read `progress.current` inside a
|
|
50
|
+
* `useTicker` callback, or pass the `onChange` callback and write to the DOM directly.
|
|
51
|
+
*/
|
|
52
|
+
declare function useScrollProgress<El extends HTMLElement = HTMLDivElement>(options?: ScrollTrackOptions & {
|
|
53
|
+
onChange?: (progress: ScrollProgress) => void;
|
|
54
|
+
}): [RefObject<El | null>, RefObject<ScrollProgress>];
|
|
55
|
+
/** Track the window's (or a container's) overall scroll progress. */
|
|
56
|
+
declare function useWindowScroll(onChange?: (info: {
|
|
57
|
+
progress: number;
|
|
58
|
+
scroll: number;
|
|
59
|
+
velocity: number;
|
|
60
|
+
max: number;
|
|
61
|
+
}) => void, options?: {
|
|
62
|
+
axis?: 'y' | 'x';
|
|
63
|
+
container?: HTMLElement | null;
|
|
64
|
+
}): RefObject<{
|
|
65
|
+
progress: number;
|
|
66
|
+
scroll: number;
|
|
67
|
+
velocity: number;
|
|
68
|
+
max: number;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Track pointer position over an element.
|
|
72
|
+
*
|
|
73
|
+
* Returns a ref to the live state object, which is mutated in place by the tracker. Reading it
|
|
74
|
+
* inside a `useTicker` callback is the intended use; it deliberately does not trigger renders.
|
|
75
|
+
*/
|
|
76
|
+
declare function usePointer<El extends HTMLElement = HTMLDivElement>(options?: {
|
|
77
|
+
smoothing?: number;
|
|
78
|
+
trackOutside?: boolean;
|
|
79
|
+
enabled?: boolean;
|
|
80
|
+
}): [RefObject<El | null>, RefObject<Readonly<PointerState> | null>];
|
|
81
|
+
/**
|
|
82
|
+
* Does the user prefer reduced motion?
|
|
83
|
+
*
|
|
84
|
+
* Returns `false` during SSR and on the first client render, then updates. That ordering is
|
|
85
|
+
* deliberate: returning the real value during SSR is impossible (the server cannot know), and
|
|
86
|
+
* returning it on the first client render would be a hydration mismatch.
|
|
87
|
+
*/
|
|
88
|
+
declare function useReducedMotion(): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Live frame-budget telemetry — FPS, frame cost percentiles, and the adaptive quality scalar.
|
|
91
|
+
*
|
|
92
|
+
* Intended for a development overlay. Subscribing causes a re-render every frame, so this must not
|
|
93
|
+
* ship in production render paths; the `enabled` flag exists so it can be gated on `NODE_ENV`.
|
|
94
|
+
*/
|
|
95
|
+
declare function useFrameBudget(enabled?: boolean): BudgetReport | null;
|
|
96
|
+
/** Merge several refs into one callback ref, for components that both forward and use a ref. */
|
|
97
|
+
declare function useMergedRef<T>(...refs: Array<React.Ref<T> | undefined | null>): (node: T | null) => void;
|
|
98
|
+
|
|
99
|
+
export { type InViewOptions as I, useFrameBudget as a, useInView as b, useMergedRef as c, usePointer as d, useReducedMotion as e, useScrollProgress as f, useTicker as g, useWindowScroll as h, useElementSize as u };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { BudgetReport, PointerState, ScrollTrackOptions, ScrollProgress, FrameState } from '@ansh-ui/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Subscribe to the shared ticker.
|
|
6
|
+
*
|
|
7
|
+
* The callback is held in a ref and never re-subscribes, so a component that closes over changing
|
|
8
|
+
* props doesn't tear down and rebuild its subscription on every render. That matters: resubscribing
|
|
9
|
+
* changes execution order within the phase, which can visibly reorder dependent animations.
|
|
10
|
+
*/
|
|
11
|
+
declare function useTicker(callback: (state: FrameState) => void, options?: {
|
|
12
|
+
phase?: 'read' | 'compute' | 'write' | 'post';
|
|
13
|
+
priority?: number;
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
}): void;
|
|
16
|
+
interface InViewOptions {
|
|
17
|
+
/** Fraction visible before triggering, in `[0, 1]`. Default `0`. */
|
|
18
|
+
threshold?: number;
|
|
19
|
+
/** Extra margin around the root. Default `'0px'`. */
|
|
20
|
+
rootMargin?: string;
|
|
21
|
+
/** Stop observing after the first intersection. Default `false`. */
|
|
22
|
+
once?: boolean;
|
|
23
|
+
root?: Element | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Is the element in the viewport?
|
|
27
|
+
*
|
|
28
|
+
* Uses the pooled observer, so a page with 200 scroll-revealed elements creates one
|
|
29
|
+
* `IntersectionObserver` rather than 200.
|
|
30
|
+
*/
|
|
31
|
+
declare function useInView<El extends Element = HTMLDivElement>(options?: InViewOptions): [RefObject<El | null>, boolean];
|
|
32
|
+
/**
|
|
33
|
+
* Track an element's size.
|
|
34
|
+
*
|
|
35
|
+
* Returns state rather than a MotionValue because size changes at interaction rate, not frame
|
|
36
|
+
* rate, so a re-render per change is appropriate and far more ergonomic.
|
|
37
|
+
*/
|
|
38
|
+
declare function useElementSize<El extends Element = HTMLDivElement>(): [
|
|
39
|
+
RefObject<El | null>,
|
|
40
|
+
{
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
/**
|
|
46
|
+
* Track an element's scroll progress through the viewport.
|
|
47
|
+
*
|
|
48
|
+
* The returned progress is a **ref**, not state, deliberately — scroll progress changes every
|
|
49
|
+
* frame, and rendering on each change would make scrolling janky. Read `progress.current` inside a
|
|
50
|
+
* `useTicker` callback, or pass the `onChange` callback and write to the DOM directly.
|
|
51
|
+
*/
|
|
52
|
+
declare function useScrollProgress<El extends HTMLElement = HTMLDivElement>(options?: ScrollTrackOptions & {
|
|
53
|
+
onChange?: (progress: ScrollProgress) => void;
|
|
54
|
+
}): [RefObject<El | null>, RefObject<ScrollProgress>];
|
|
55
|
+
/** Track the window's (or a container's) overall scroll progress. */
|
|
56
|
+
declare function useWindowScroll(onChange?: (info: {
|
|
57
|
+
progress: number;
|
|
58
|
+
scroll: number;
|
|
59
|
+
velocity: number;
|
|
60
|
+
max: number;
|
|
61
|
+
}) => void, options?: {
|
|
62
|
+
axis?: 'y' | 'x';
|
|
63
|
+
container?: HTMLElement | null;
|
|
64
|
+
}): RefObject<{
|
|
65
|
+
progress: number;
|
|
66
|
+
scroll: number;
|
|
67
|
+
velocity: number;
|
|
68
|
+
max: number;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Track pointer position over an element.
|
|
72
|
+
*
|
|
73
|
+
* Returns a ref to the live state object, which is mutated in place by the tracker. Reading it
|
|
74
|
+
* inside a `useTicker` callback is the intended use; it deliberately does not trigger renders.
|
|
75
|
+
*/
|
|
76
|
+
declare function usePointer<El extends HTMLElement = HTMLDivElement>(options?: {
|
|
77
|
+
smoothing?: number;
|
|
78
|
+
trackOutside?: boolean;
|
|
79
|
+
enabled?: boolean;
|
|
80
|
+
}): [RefObject<El | null>, RefObject<Readonly<PointerState> | null>];
|
|
81
|
+
/**
|
|
82
|
+
* Does the user prefer reduced motion?
|
|
83
|
+
*
|
|
84
|
+
* Returns `false` during SSR and on the first client render, then updates. That ordering is
|
|
85
|
+
* deliberate: returning the real value during SSR is impossible (the server cannot know), and
|
|
86
|
+
* returning it on the first client render would be a hydration mismatch.
|
|
87
|
+
*/
|
|
88
|
+
declare function useReducedMotion(): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Live frame-budget telemetry — FPS, frame cost percentiles, and the adaptive quality scalar.
|
|
91
|
+
*
|
|
92
|
+
* Intended for a development overlay. Subscribing causes a re-render every frame, so this must not
|
|
93
|
+
* ship in production render paths; the `enabled` flag exists so it can be gated on `NODE_ENV`.
|
|
94
|
+
*/
|
|
95
|
+
declare function useFrameBudget(enabled?: boolean): BudgetReport | null;
|
|
96
|
+
/** Merge several refs into one callback ref, for components that both forward and use a ref. */
|
|
97
|
+
declare function useMergedRef<T>(...refs: Array<React.Ref<T> | undefined | null>): (node: T | null) => void;
|
|
98
|
+
|
|
99
|
+
export { type InViewOptions as I, useFrameBudget as a, useInView as b, useMergedRef as c, usePointer as d, useReducedMotion as e, useScrollProgress as f, useTicker as g, useWindowScroll as h, useElementSize as u };
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ansh-ui/react",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Ansh for React and Next.js — premium animated components and motion hooks.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"**/*.css"
|
|
9
|
+
],
|
|
10
|
+
"keywords": [
|
|
11
|
+
"react",
|
|
12
|
+
"nextjs",
|
|
13
|
+
"animation",
|
|
14
|
+
"motion",
|
|
15
|
+
"components",
|
|
16
|
+
"ui",
|
|
17
|
+
"canvas",
|
|
18
|
+
"particles"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/jithin003/ui-library.git",
|
|
23
|
+
"directory": "packages/react"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/jithin003/ui-library",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"main": "./dist/index.cjs",
|
|
30
|
+
"module": "./dist/index.js",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"import": "./dist/index.js",
|
|
36
|
+
"require": "./dist/index.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./primitives": {
|
|
39
|
+
"types": "./dist/primitives.d.ts",
|
|
40
|
+
"import": "./dist/primitives.js",
|
|
41
|
+
"require": "./dist/primitives.cjs"
|
|
42
|
+
},
|
|
43
|
+
"./layout": {
|
|
44
|
+
"types": "./dist/layout.d.ts",
|
|
45
|
+
"import": "./dist/layout.js",
|
|
46
|
+
"require": "./dist/layout.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./form": {
|
|
49
|
+
"types": "./dist/form.d.ts",
|
|
50
|
+
"import": "./dist/form.js",
|
|
51
|
+
"require": "./dist/form.cjs"
|
|
52
|
+
},
|
|
53
|
+
"./overlay": {
|
|
54
|
+
"types": "./dist/overlay.d.ts",
|
|
55
|
+
"import": "./dist/overlay.js",
|
|
56
|
+
"require": "./dist/overlay.cjs"
|
|
57
|
+
},
|
|
58
|
+
"./data": {
|
|
59
|
+
"types": "./dist/data.d.ts",
|
|
60
|
+
"import": "./dist/data.js",
|
|
61
|
+
"require": "./dist/data.cjs"
|
|
62
|
+
},
|
|
63
|
+
"./navigation": {
|
|
64
|
+
"types": "./dist/navigation.d.ts",
|
|
65
|
+
"import": "./dist/navigation.js",
|
|
66
|
+
"require": "./dist/navigation.cjs"
|
|
67
|
+
},
|
|
68
|
+
"./motion": {
|
|
69
|
+
"types": "./dist/motion.d.ts",
|
|
70
|
+
"import": "./dist/motion.js",
|
|
71
|
+
"require": "./dist/motion.cjs"
|
|
72
|
+
},
|
|
73
|
+
"./styles.css": "./dist/styles.css",
|
|
74
|
+
"./package.json": "./package.json"
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"@ansh-ui/tokens": "0.2.0",
|
|
78
|
+
"@ansh-ui/core": "0.2.0"
|
|
79
|
+
},
|
|
80
|
+
"peerDependencies": {
|
|
81
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
82
|
+
"react-dom": "^18.2.0 || ^19.0.0"
|
|
83
|
+
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public"
|
|
86
|
+
},
|
|
87
|
+
"scripts": {
|
|
88
|
+
"build": "tsup && node ./scripts/add-use-client.mjs && node ./scripts/build-css.mjs",
|
|
89
|
+
"dev": "tsup --watch",
|
|
90
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
91
|
+
}
|
|
92
|
+
}
|