@xwadex/fesd-next 0.3.4-7.8 → 0.3.4-7.9

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.
@@ -1,7 +1,6 @@
1
1
  import { animate } from "motion/react";
2
2
  import type { Easing } from "motion/react";
3
- export interface PropsTypes {
4
- }
3
+ import { registerContainers } from "./useScrollContainers";
5
4
  export interface AnimateOptions {
6
5
  duration?: number;
7
6
  delay?: number;
@@ -34,9 +33,9 @@ export interface ScrollOptions extends AnimateOptions {
34
33
  export type AnimateController = ReturnType<typeof animate>;
35
34
  export declare function useAnchors(): {
36
35
  registerAnchors: typeof registerAnchors;
37
- registerContainers: typeof registerContainers;
38
36
  registerOffseters: typeof registerOffseters;
39
- setStores: (states: AnchorStoreStates) => void;
37
+ registerContainers: typeof registerContainers;
38
+ setStores: (options: AnchorStoreOptions) => void;
40
39
  getStores: () => AnchorsStores;
41
40
  scrollToAnchor: (anchorOptions: AnchorOptions) => void;
42
41
  };
@@ -50,22 +49,17 @@ export declare function registerAnchors(name: string): {
50
49
  ref: (node: HTMLDivElement | null) => void;
51
50
  "data-anchor": string;
52
51
  };
53
- export declare function registerContainers(name: string): {
54
- ref: (node: HTMLDivElement | null) => void;
55
- "data-anchor-container": string;
56
- };
57
52
  export declare function registerOffseters(name: string): {
58
53
  ref: (node: HTMLDivElement | null) => void;
59
54
  "data-anchor-offseter": string;
60
55
  };
61
56
  export interface AnchorsStores {
62
57
  anchors: Map<string, HTMLElement | null>;
63
- containers: Map<string, HTMLElement | null>;
64
58
  offseters: Map<string, HTMLElement | null>;
65
59
  }
66
60
  export declare const useAnchorsStores: import("zustand").UseBoundStore<import("zustand").StoreApi<AnchorsStores>>;
67
61
  export declare const getAnchorsStores: () => AnchorsStores;
68
- export interface AnchorStoreStates extends RegistrationDatas {
62
+ export interface AnchorStoreOptions extends RegistrationDatas {
69
63
  action: "add" | "remove";
70
64
  }
71
- export declare const setAnchorStore: (states: AnchorStoreStates) => void;
65
+ export declare const setAnchorsStore: (options: AnchorStoreOptions) => void;
@@ -1,10 +1,13 @@
1
1
  "use client";
2
- // update: 2025.10.30
3
- // version: 0.0.1.bate
2
+ // update: 2025.11.07
3
+ // version: 0.0.2.bate
4
4
  // dev: wade
5
5
  import { useCallback, useMemo, useRef } from "react";
6
6
  import { animate, motionValue } from "motion/react";
7
7
  import { create } from "zustand";
8
+ import { getScrollContainersStores, registerContainers } from "./useScrollContainers";
9
+ const ANCHOR_ATTRIBUTE = "data-anchor";
10
+ const OFFSETER_ATTRIBUTE = "data-anchor-offseter";
8
11
  export function useAnchors() {
9
12
  const controllerRef = useRef(new Map());
10
13
  const scrollAnimations = useCallback(({ controllerKey, containerDom, anchorScrollValue, containerScrollValue, direction = "y", duration = 0.5, delay = 0, ease = [0.215, 0.61, 0.355, 1.0], onScroll: onPlay, onScrolled, onScrolling }) => {
@@ -38,7 +41,8 @@ export function useAnchors() {
38
41
  }, []);
39
42
  const scrollToAnchor = useCallback((anchorOptions) => {
40
43
  const { anchor: anchorName, container: containerName, offseters, align, offset = 0, ...options } = anchorOptions;
41
- const stores = getAnchorsStores();
44
+ const anchorsStores = getAnchorsStores();
45
+ const scrollContainersStores = getScrollContainersStores();
42
46
  const isScrolltoAnchor = anchorName !== "#";
43
47
  const isScrollContainer = containerName && containerName !== "window";
44
48
  const controllerKey = containerName ?? "window";
@@ -47,12 +51,12 @@ export function useAnchors() {
47
51
  controllerRef.current.delete(controllerKey);
48
52
  }
49
53
  const anchorDom = isScrolltoAnchor
50
- ? stores.anchors.get(anchorName)
54
+ ? anchorsStores.anchors.get(anchorName)
51
55
  : undefined;
52
56
  if (isScrolltoAnchor && !(anchorDom instanceof HTMLElement))
53
57
  return;
54
58
  const containerDom = isScrollContainer
55
- ? stores.containers.get(containerName)
59
+ ? scrollContainersStores.containers.get(containerName)
56
60
  : window;
57
61
  if (!containerDom)
58
62
  return;
@@ -73,7 +77,7 @@ export function useAnchors() {
73
77
  };
74
78
  const offsetsValue = Array.isArray(offseters)
75
79
  ? offseters.reduce((init, offseter) => {
76
- const offseterDom = stores.offseters.get(offseter);
80
+ const offseterDom = anchorsStores.offseters.get(offseter);
77
81
  const width = (init.width ?? 0) + (offseterDom ? offseterDom.clientWidth : 0);
78
82
  const height = (init.height ?? 0) + (offseterDom ? offseterDom.clientHeight : 0);
79
83
  return { width, height };
@@ -102,9 +106,9 @@ export function useAnchors() {
102
106
  }, []);
103
107
  const returnsMemo = useMemo(() => ({
104
108
  registerAnchors,
105
- registerContainers,
106
109
  registerOffseters,
107
- setStores: setAnchorStore,
110
+ registerContainers: registerContainers,
111
+ setStores: setAnchorsStore,
108
112
  getStores: getAnchorsStores,
109
113
  scrollToAnchor
110
114
  }), [scrollToAnchor]);
@@ -117,54 +121,47 @@ export function registration({ name, key, node }) {
117
121
  console.error(`Cannot register ${key} name '#'`);
118
122
  return;
119
123
  }
120
- if (node instanceof Window || node.tagName === "BODY" || node.tagName === "HTML") {
121
- console.error(`Cannot register ${key} 'body' or 'html' `);
122
- return;
123
- }
124
- setAnchorStore({ key, name, node, action: node ? "add" : "remove" });
124
+ setAnchorsStore({ key, name, node, action: node ? "add" : "remove" });
125
125
  }
126
- const ANCHOR_ATTRIBUTE = "data-anchor";
127
- const CONTAINER_ATTRIBUTE = "data-anchor-container";
128
- const OFFSETER_ATTRIBUTE = "data-anchor-offseter";
129
126
  export function registerAnchors(name) {
130
127
  const register = useCallback((node) => registration({ key: "anchors", name, node }), [name]);
131
128
  return { ref: register, [ANCHOR_ATTRIBUTE]: name };
132
129
  }
133
- export function registerContainers(name) {
134
- const register = useCallback((node) => registration({ key: "containers", name, node }), [name]);
135
- return { ref: register, [CONTAINER_ATTRIBUTE]: name };
136
- }
137
130
  export function registerOffseters(name) {
138
131
  const register = useCallback((node) => registration({ key: "offseters", name, node }), [name]);
139
132
  return { ref: register, [OFFSETER_ATTRIBUTE]: name };
140
133
  }
141
134
  export const useAnchorsStores = create()(() => ({
142
135
  anchors: new Map(),
143
- containers: new Map(),
136
+ // containers: new Map(),
144
137
  offseters: new Map(),
145
138
  }));
146
139
  export const getAnchorsStores = () => useAnchorsStores.getState();
147
- export const setAnchorStore = (states) => {
148
- const { key, action, name, node } = states;
140
+ export const setAnchorsStore = (options) => {
141
+ const { key, action, name, node } = options;
149
142
  useAnchorsStores.setState(stores => {
150
143
  switch (key) {
151
144
  case "anchors":
152
- if (action == "add" && node instanceof HTMLElement)
145
+ const anchorDom = stores.anchors?.get(name);
146
+ if (action == "add" && node instanceof HTMLElement) {
147
+ if (anchorDom == node)
148
+ return stores;
153
149
  stores.anchors?.set(name, node);
154
- if (action == "remove")
150
+ }
151
+ else if (action == "remove" && anchorDom) {
155
152
  stores.anchors?.delete(name);
153
+ }
156
154
  return { anchors: stores.anchors };
157
- case "containers":
158
- if (action == "add" && node instanceof HTMLElement)
159
- stores.containers?.set(name, node);
160
- if (action == "remove")
161
- stores.containers?.delete(name);
162
- return { containers: stores.containers };
163
155
  case "offseters":
164
- if (action == "add" && node instanceof HTMLElement)
156
+ const offseterDom = stores.offseters?.get(name);
157
+ if (action == "add" && node instanceof HTMLElement) {
158
+ if (offseterDom == node)
159
+ return stores;
165
160
  stores.offseters?.set(name, node);
166
- if (action == "remove")
161
+ }
162
+ else if (action == "remove" && offseterDom) {
167
163
  stores.offseters?.delete(name);
164
+ }
168
165
  return { offseters: stores.offseters };
169
166
  default:
170
167
  return stores;
@@ -0,0 +1,27 @@
1
+ export interface UseScrollContainers {
2
+ container?: string;
3
+ }
4
+ export declare function useScrollContainers(options?: UseScrollContainers): {
5
+ container: HTMLElement | (Window & typeof globalThis);
6
+ setStores: (options: AnchorStoreOptions) => void;
7
+ getStores: () => ScrollContainersStores;
8
+ registerContainers: typeof registerContainers;
9
+ };
10
+ export declare function registration({ name, node }: RegistrationDatas): void;
11
+ export declare function registerContainers(name: string): {
12
+ ref: (node: HTMLDivElement | null) => void;
13
+ "data-scroll-container": string;
14
+ };
15
+ export interface ScrollContainersStores {
16
+ containers: Map<string, HTMLElement | null>;
17
+ }
18
+ export declare const useScrollContainersStores: import("zustand").UseBoundStore<import("zustand").StoreApi<ScrollContainersStores>>;
19
+ export declare const getScrollContainersStores: () => ScrollContainersStores;
20
+ export interface RegistrationDatas {
21
+ name: string;
22
+ node: HTMLDivElement | null;
23
+ }
24
+ export interface AnchorStoreOptions extends RegistrationDatas {
25
+ action: "add" | "remove";
26
+ }
27
+ export declare const setScrollContainerStore: (options: AnchorStoreOptions) => void;
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ // update: 2025.11.07
3
+ // version: 0.0.1.bate
4
+ // dev: wade
5
+ import { useCallback } from "react";
6
+ import { create } from "zustand";
7
+ const CONTAINER_ATTRIBUTE = "data-scroll-container";
8
+ export function useScrollContainers(options) {
9
+ const { container: containerName } = options || {};
10
+ const stores = getScrollContainersStores();
11
+ const isScrollContainer = containerName && containerName !== "window";
12
+ const containerDom = isScrollContainer
13
+ ? stores.containers.get(containerName)
14
+ : window;
15
+ return {
16
+ container: containerDom,
17
+ setStores: setScrollContainerStore,
18
+ getStores: getScrollContainersStores,
19
+ registerContainers
20
+ };
21
+ }
22
+ export function registration({ name, node }) {
23
+ if (!node)
24
+ return;
25
+ if (node instanceof Window || node.tagName === "BODY" || node.tagName === "HTML") {
26
+ console.error(`Cannot register scroll container 'body' or 'html' `);
27
+ return;
28
+ }
29
+ setScrollContainerStore({ name, node, action: node ? "add" : "remove" });
30
+ }
31
+ export function registerContainers(name) {
32
+ const register = useCallback((node) => registration({ name, node }), [name]);
33
+ return { ref: register, [CONTAINER_ATTRIBUTE]: name };
34
+ }
35
+ export const useScrollContainersStores = create()(() => ({
36
+ containers: new Map(),
37
+ }));
38
+ export const getScrollContainersStores = () => useScrollContainersStores.getState();
39
+ export const setScrollContainerStore = (options) => {
40
+ const { action, name, node } = options;
41
+ useScrollContainersStores.setState(stores => {
42
+ const containerDom = stores.containers?.get(name);
43
+ if (action == "add" && node instanceof HTMLElement) {
44
+ if (containerDom == node)
45
+ return stores;
46
+ stores.containers?.set(name, node);
47
+ }
48
+ else if (action == "remove" && containerDom) {
49
+ stores.containers?.delete(name);
50
+ }
51
+ return { containers: stores.containers };
52
+ });
53
+ };
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { type VariantProps } from 'class-variance-authority';
3
3
  declare const alertVariants: (props?: ({
4
4
  variant?: "default" | "destructive" | null | undefined;
5
- } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
6
  declare function Alert({ className, variant, ...props }: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>): import("react/jsx-runtime").JSX.Element;
7
7
  declare function AlertTitle({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
8
8
  declare function AlertDescription({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { type VariantProps } from 'class-variance-authority';
3
3
  declare const badgeVariants: (props?: ({
4
4
  variant?: "default" | "outline" | "destructive" | "secondary" | null | undefined;
5
- } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
6
  declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<'span'> & VariantProps<typeof badgeVariants> & {
7
7
  asChild?: boolean;
8
8
  }): import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ import { type VariantProps } from 'class-variance-authority';
3
3
  declare const buttonVariants: (props?: ({
4
4
  variant?: "default" | "outline" | "link" | "destructive" | "secondary" | "ghost" | null | undefined;
5
5
  size?: "default" | "sm" | "lg" | "icon" | null | undefined;
6
- } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
7
  declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
8
8
  asChild?: boolean;
9
9
  }): import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,7 @@ declare function NavigationMenu({ className, children, viewport, ...props }: Rea
5
5
  }): import("react/jsx-runtime").JSX.Element;
6
6
  declare function NavigationMenuList({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.List>): import("react/jsx-runtime").JSX.Element;
7
7
  declare function NavigationMenuItem({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Item>): import("react/jsx-runtime").JSX.Element;
8
- declare const navigationMenuTriggerStyle: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
8
+ declare const navigationMenuTriggerStyle: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
9
9
  declare function NavigationMenuTrigger({ className, children, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
10
10
  declare function NavigationMenuContent({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
11
11
  declare function NavigationMenuViewport({ className, ...props }: React.ComponentProps<typeof NavigationMenuPrimitive.Viewport>): import("react/jsx-runtime").JSX.Element;
@@ -42,7 +42,7 @@ declare function SidebarMenuItem({ className, ...props }: React.ComponentProps<'
42
42
  declare const sidebarMenuButtonVariants: (props?: ({
43
43
  variant?: "default" | "outline" | null | undefined;
44
44
  size?: "default" | "sm" | "lg" | null | undefined;
45
- } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
45
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
46
46
  declare function SidebarMenuButton({ asChild, isActive, variant, size, tooltip, className, ...props }: React.ComponentProps<'button'> & {
47
47
  asChild?: boolean;
48
48
  isActive?: boolean;
@@ -4,6 +4,6 @@ import { type VariantProps } from 'class-variance-authority';
4
4
  declare const toggleVariants: (props?: ({
5
5
  variant?: "default" | "outline" | null | undefined;
6
6
  size?: "default" | "sm" | "lg" | null | undefined;
7
- } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
8
  declare function Toggle({ className, variant, size, ...props }: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>): import("react/jsx-runtime").JSX.Element;
9
9
  export { Toggle, toggleVariants };
@@ -39,6 +39,7 @@ export * from "./components/ui/slider";
39
39
  export * from "./components/ui/sonner";
40
40
  export * from "./components/ui/switch";
41
41
  export * from "./components/ui/tabs";
42
+ export * from "./components/ui/table";
42
43
  export * from "./components/ui/textarea";
43
44
  export * from "./components/ui/toggle-group";
44
45
  export * from "./components/ui/toggle";
@@ -39,6 +39,7 @@ export * from "./components/ui/slider";
39
39
  export * from "./components/ui/sonner";
40
40
  export * from "./components/ui/switch";
41
41
  export * from "./components/ui/tabs";
42
+ export * from "./components/ui/table";
42
43
  export * from "./components/ui/textarea";
43
44
  export * from "./components/ui/toggle-group";
44
45
  export * from "./components/ui/toggle";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xwadex/fesd-next",
3
- "version": "0.3.4-7.8",
3
+ "version": "0.3.4-7.9",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",