@xwadex/fesd-next 0.3.4-7.5 → 0.3.4-7.6

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,7 @@
1
1
  import { Easing } from "motion/react";
2
2
  export interface PropsTypes {
3
3
  }
4
- export interface AnimationOptions {
4
+ export interface AnimateOptions {
5
5
  duration?: number;
6
6
  delay?: number;
7
7
  ease?: Easing | Easing[] | undefined;
@@ -9,7 +9,7 @@ export interface AnimationOptions {
9
9
  onScrolling?: (value: number) => void;
10
10
  onScrolled?: () => void;
11
11
  }
12
- export interface AnchorActionsOptions extends AnimationOptions {
12
+ export interface AnchorOptions extends AnimateOptions {
13
13
  anchor: string;
14
14
  container?: string;
15
15
  offseters?: string | string[];
@@ -17,7 +17,7 @@ export interface AnchorActionsOptions extends AnimationOptions {
17
17
  align?: "start" | "center" | "end";
18
18
  offset?: number;
19
19
  }
20
- export interface ScrollAnimationsOptions extends AnimationOptions {
20
+ export interface ScrollOptions extends AnimateOptions {
21
21
  containerDom: HTMLElement | Window;
22
22
  scrollValue: {
23
23
  x: number;
@@ -27,22 +27,22 @@ export interface ScrollAnimationsOptions extends AnimationOptions {
27
27
  left: number;
28
28
  top: number;
29
29
  };
30
- direction?: AnchorActionsOptions["direction"];
30
+ direction?: AnchorOptions["direction"];
31
31
  }
32
32
  export declare function useAnchors(): {
33
33
  registerAnchors: typeof registerAnchors;
34
34
  registerContainers: typeof registerContainers;
35
35
  registerOffseters: typeof registerOffseters;
36
- setStores: (options: SetAnchorStoreOptions) => void;
36
+ setStores: (states: AnchorStoreStates) => void;
37
37
  getStores: () => AnchorsStores;
38
- scrollToAnchor: (anchorOptions: AnchorActionsOptions) => void;
38
+ scrollToAnchor: (anchorOptions: AnchorOptions) => void;
39
39
  };
40
- export interface RegistrationProps {
41
- name: string;
40
+ export interface RegistrationDatas {
42
41
  key: keyof AnchorsStores;
42
+ name: string;
43
43
  node: HTMLDivElement | null;
44
44
  }
45
- export declare function registration({ name, key, node }: RegistrationProps): void;
45
+ export declare function registration({ name, key, node }: RegistrationDatas): void;
46
46
  export declare function registerAnchors(name: string): {
47
47
  ref: (node: HTMLDivElement | null) => void;
48
48
  "data-anchor": string;
@@ -55,17 +55,14 @@ export declare function registerOffseters(name: string): {
55
55
  ref: (node: HTMLDivElement | null) => void;
56
56
  "data-anchor-offseter": string;
57
57
  };
58
- export type AnchorsStores = {
58
+ export interface AnchorsStores {
59
59
  anchors: Map<string, HTMLElement | null>;
60
60
  containers: Map<string, HTMLElement | null>;
61
61
  offseters: Map<string, HTMLElement | null>;
62
- };
62
+ }
63
63
  export declare const useAnchorsStores: import("zustand").UseBoundStore<import("zustand").StoreApi<AnchorsStores>>;
64
64
  export declare const getAnchorsStores: () => AnchorsStores;
65
- export interface SetAnchorStoreOptions {
66
- key: keyof AnchorsStores;
65
+ export interface AnchorStoreStates extends RegistrationDatas {
67
66
  action: "add" | "remove";
68
- name: string;
69
- node?: HTMLElement | null;
70
67
  }
71
- export declare const setAnchorStore: (options: SetAnchorStoreOptions) => void;
68
+ export declare const setAnchorStore: (states: AnchorStoreStates) => void;
@@ -138,28 +138,30 @@ export const useAnchorsStores = create()(() => ({
138
138
  offseters: new Map(),
139
139
  }));
140
140
  export const getAnchorsStores = () => useAnchorsStores.getState();
141
- export const setAnchorStore = (options) => useAnchorsStores.setState(stores => {
142
- const { key, action, name, node } = options;
143
- switch (key) {
144
- case "anchors":
145
- if (action == "add" && node instanceof HTMLElement)
146
- stores.anchors?.set(name, node);
147
- if (action == "remove")
148
- stores.anchors?.delete(name);
149
- return { anchors: stores.anchors };
150
- case "containers":
151
- if (action == "add" && node instanceof HTMLElement)
152
- stores.containers?.set(name, node);
153
- if (action == "remove")
154
- stores.containers?.delete(name);
155
- return { containers: stores.containers };
156
- case "offseters":
157
- if (action == "add" && node instanceof HTMLElement)
158
- stores.offseters?.set(name, node);
159
- if (action == "remove")
160
- stores.offseters?.delete(name);
161
- return { offseters: stores.offseters };
162
- default:
163
- return stores;
164
- }
165
- });
141
+ export const setAnchorStore = (states) => {
142
+ const { key, action, name, node } = states;
143
+ useAnchorsStores.setState(stores => {
144
+ switch (key) {
145
+ case "anchors":
146
+ if (action == "add" && node instanceof HTMLElement)
147
+ stores.anchors?.set(name, node);
148
+ if (action == "remove")
149
+ stores.anchors?.delete(name);
150
+ return { anchors: stores.anchors };
151
+ case "containers":
152
+ if (action == "add" && node instanceof HTMLElement)
153
+ stores.containers?.set(name, node);
154
+ if (action == "remove")
155
+ stores.containers?.delete(name);
156
+ return { containers: stores.containers };
157
+ case "offseters":
158
+ if (action == "add" && node instanceof HTMLElement)
159
+ stores.offseters?.set(name, node);
160
+ if (action == "remove")
161
+ stores.offseters?.delete(name);
162
+ return { offseters: stores.offseters };
163
+ default:
164
+ return stores;
165
+ }
166
+ });
167
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xwadex/fesd-next",
3
- "version": "0.3.4-7.5",
3
+ "version": "0.3.4-7.6",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",