wex-ui-lib 1.0.3 → 1.0.5
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/dist/index.cjs.js +2295 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.esm.js +2272 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/types/components/Button/index.d.ts +3 -0
- package/dist/types/components/Hero/index.d.ts +3 -0
- package/dist/types/components/Navbar/index.d.ts +3 -0
- package/dist/types/components/Showcase/index.d.ts +3 -0
- package/dist/types/samples/Holik/Homepage.d.ts +2 -0
- package/dist/{src → types}/shared/components/Fade.d.ts +1 -1
- package/dist/{shared → types/shared}/components/Icon.d.ts +2 -1
- package/package.json +28 -19
- package/.storybook/main.ts +0 -19
- package/.storybook/manager-head.html +0 -1
- package/.storybook/preview.ts +0 -15
- package/dist/components/Button/index.d.ts +0 -2
- package/dist/components/Hero/index.d.ts +0 -2
- package/dist/components/Navbar/index.d.ts +0 -2
- package/dist/components/Showcase/index.d.ts +0 -2
- package/dist/index.js +0 -345
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -345
- package/dist/index.mjs.map +0 -1
- package/dist/samples/Holik/Homepage.d.ts +0 -1
- package/dist/shared/components/Fade.d.ts +0 -7
- package/dist/src/components/Button/index.d.ts +0 -2
- package/dist/src/components/Button/index.stories.d.ts +0 -12
- package/dist/src/components/Button/index.types.d.ts +0 -10
- package/dist/src/components/Hero/index.d.ts +0 -2
- package/dist/src/components/Hero/index.stories.d.ts +0 -12
- package/dist/src/components/Hero/index.types.d.ts +0 -12
- package/dist/src/components/Navbar/index.d.ts +0 -2
- package/dist/src/components/Navbar/index.stories.d.ts +0 -7
- package/dist/src/components/Navbar/index.types.d.ts +0 -25
- package/dist/src/components/Showcase/index.d.ts +0 -2
- package/dist/src/components/Showcase/index.stories.d.ts +0 -7
- package/dist/src/components/Showcase/index.types.d.ts +0 -9
- package/dist/src/samples/Holik/Homepage.d.ts +0 -1
- package/dist/src/samples/Holik/index.stories.d.ts +0 -10
- package/dist/src/shared/components/Icon.d.ts +0 -11
- package/dist/src/shared/styles/animations.d.ts +0 -6
- package/dist/src/shared/styles/theme.d.ts +0 -7
- package/dist/src/shared/types.d.ts +0 -15
- package/dist/src/shared/utils/formatters.d.ts +0 -2
- package/dist/src/shared/utils/useIntObs.d.ts +0 -19
- package/public/logo.png +0 -0
- package/rollup.config.mjs +0 -42
- package/src/components/Button/index.stories.tsx +0 -54
- package/src/components/Button/index.tsx +0 -157
- package/src/components/Button/index.types.ts +0 -11
- package/src/components/Hero/index.stories.tsx +0 -40
- package/src/components/Hero/index.tsx +0 -76
- package/src/components/Hero/index.types.ts +0 -13
- package/src/components/Navbar/index.stories.tsx +0 -59
- package/src/components/Navbar/index.tsx +0 -196
- package/src/components/Navbar/index.types.ts +0 -27
- package/src/components/Showcase/index.stories.tsx +0 -54
- package/src/components/Showcase/index.tsx +0 -66
- package/src/components/Showcase/index.types.ts +0 -9
- package/src/index.ts +0 -6
- package/src/samples/Holik/Homepage.tsx +0 -141
- package/src/samples/Holik/index.stories.tsx +0 -17
- package/src/shared/components/Fade.tsx +0 -48
- package/src/shared/components/Icon.tsx +0 -81
- package/src/shared/styles/animations.ts +0 -80
- package/src/shared/styles/global.css +0 -6
- package/src/shared/styles/theme.ts +0 -7
- package/src/shared/types.ts +0 -18
- package/src/shared/utils/formatters.ts +0 -12
- package/src/shared/utils/useIntObs.ts +0 -112
- package/tsconfig.json +0 -30
- /package/dist/{components → types/components}/Button/index.stories.d.ts +0 -0
- /package/dist/{components → types/components}/Button/index.types.d.ts +0 -0
- /package/dist/{components → types/components}/Hero/index.stories.d.ts +0 -0
- /package/dist/{components → types/components}/Hero/index.types.d.ts +0 -0
- /package/dist/{components → types/components}/Navbar/index.stories.d.ts +0 -0
- /package/dist/{components → types/components}/Navbar/index.types.d.ts +0 -0
- /package/dist/{components → types/components}/Showcase/index.stories.d.ts +0 -0
- /package/dist/{components → types/components}/Showcase/index.types.d.ts +0 -0
- /package/dist/{src → types}/index.d.ts +0 -0
- /package/dist/{samples → types/samples}/Holik/index.stories.d.ts +0 -0
- /package/dist/{shared → types/shared}/styles/animations.d.ts +0 -0
- /package/dist/{shared → types/shared}/styles/theme.d.ts +0 -0
- /package/dist/{shared → types/shared}/types.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/formatters.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils/useIntObs.d.ts +0 -0
@@ -1,112 +0,0 @@
|
|
1
|
-
import { useEffect, useRef, useState, MutableRefObject } from 'react';
|
2
|
-
|
3
|
-
interface UseIntObsOptions {
|
4
|
-
threshold?: number | number[];
|
5
|
-
root?: any;
|
6
|
-
rootMargin?: string;
|
7
|
-
freezeOnceVisible?: boolean;
|
8
|
-
initialIsIntersecting?: boolean;
|
9
|
-
onChange?: (isIntersecting: boolean, entry: IntersectionObserverEntry) => void;
|
10
|
-
}
|
11
|
-
|
12
|
-
interface IntObsState {
|
13
|
-
isIntersecting: boolean;
|
14
|
-
entry?: IntersectionObserverEntry;
|
15
|
-
}
|
16
|
-
|
17
|
-
type UseIntObsResult = [
|
18
|
-
(node: Element | null) => void,
|
19
|
-
boolean,
|
20
|
-
IntersectionObserverEntry | undefined
|
21
|
-
] & {
|
22
|
-
ref: (node: Element | null) => void;
|
23
|
-
isIntersecting: boolean;
|
24
|
-
entry: IntersectionObserverEntry | undefined;
|
25
|
-
};
|
26
|
-
|
27
|
-
export function useIntObs({
|
28
|
-
threshold = 0,
|
29
|
-
root = null,
|
30
|
-
rootMargin = '0%',
|
31
|
-
freezeOnceVisible = false,
|
32
|
-
initialIsIntersecting = false,
|
33
|
-
onChange,
|
34
|
-
}: UseIntObsOptions = {}): UseIntObsResult {
|
35
|
-
const [ref, setRef] = useState<Element | null>(null);
|
36
|
-
const [state, setState] = useState<IntObsState>(() => ({
|
37
|
-
isIntersecting: initialIsIntersecting,
|
38
|
-
entry: undefined,
|
39
|
-
}));
|
40
|
-
|
41
|
-
const callbackRef = useRef<(isIntersecting: boolean, entry: IntersectionObserverEntry) => void>(undefined);
|
42
|
-
callbackRef.current = onChange;
|
43
|
-
|
44
|
-
const frozen = state.entry?.isIntersecting && freezeOnceVisible;
|
45
|
-
|
46
|
-
useEffect(() => {
|
47
|
-
if (!ref || frozen || !('IntersectionObserver' in window)) return;
|
48
|
-
|
49
|
-
let unobserve: (() => void) | undefined;
|
50
|
-
|
51
|
-
const observer = new IntersectionObserver(
|
52
|
-
(entries) => {
|
53
|
-
const thresholds = Array.isArray(observer.thresholds)
|
54
|
-
? observer.thresholds
|
55
|
-
: [observer.thresholds];
|
56
|
-
|
57
|
-
entries.forEach((entry) => {
|
58
|
-
const isIntersecting =
|
59
|
-
entry.isIntersecting &&
|
60
|
-
thresholds.some((threshold) => entry.intersectionRatio >= threshold);
|
61
|
-
|
62
|
-
setState({ isIntersecting, entry });
|
63
|
-
|
64
|
-
if (callbackRef.current) {
|
65
|
-
callbackRef.current(isIntersecting, entry);
|
66
|
-
}
|
67
|
-
|
68
|
-
if (isIntersecting && freezeOnceVisible && unobserve) {
|
69
|
-
unobserve();
|
70
|
-
unobserve = undefined;
|
71
|
-
}
|
72
|
-
});
|
73
|
-
},
|
74
|
-
{ threshold, root, rootMargin }
|
75
|
-
);
|
76
|
-
|
77
|
-
observer.observe(ref);
|
78
|
-
|
79
|
-
unobserve = () => observer.unobserve(ref);
|
80
|
-
|
81
|
-
return () => {
|
82
|
-
observer.disconnect();
|
83
|
-
};
|
84
|
-
}, [ref, JSON.stringify(threshold), root, rootMargin, frozen, freezeOnceVisible]);
|
85
|
-
|
86
|
-
const prevRef = useRef<Element | null>(null);
|
87
|
-
|
88
|
-
useEffect(() => {
|
89
|
-
if (
|
90
|
-
!ref &&
|
91
|
-
state.entry?.target &&
|
92
|
-
!freezeOnceVisible &&
|
93
|
-
!frozen &&
|
94
|
-
prevRef.current !== state.entry.target
|
95
|
-
) {
|
96
|
-
prevRef.current = state.entry.target as Element;
|
97
|
-
setState({ isIntersecting: initialIsIntersecting, entry: undefined });
|
98
|
-
}
|
99
|
-
}, [ref, state.entry, freezeOnceVisible, frozen, initialIsIntersecting]);
|
100
|
-
|
101
|
-
const result: UseIntObsResult = [
|
102
|
-
setRef,
|
103
|
-
!!state.isIntersecting,
|
104
|
-
state.entry,
|
105
|
-
] as UseIntObsResult;
|
106
|
-
|
107
|
-
result.ref = result[0];
|
108
|
-
result.isIntersecting = result[1];
|
109
|
-
result.entry = result[2];
|
110
|
-
|
111
|
-
return result;
|
112
|
-
}
|
package/tsconfig.json
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "esnext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
4
|
-
"lib": [
|
5
|
-
"dom",
|
6
|
-
"dom.iterable",
|
7
|
-
"esnext"
|
8
|
-
], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
9
|
-
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
10
|
-
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
|
11
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
12
|
-
"allowSyntheticDefaultImports": true,
|
13
|
-
"strict": true, /* Enable all strict type-checking options. */
|
14
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
15
|
-
"noFallthroughCasesInSwitch": true,
|
16
|
-
"module": "esnext", /* Specify what module code is generated. */
|
17
|
-
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
18
|
-
"resolveJsonModule": true, /* Enable importing .json files. */
|
19
|
-
"noEmit": true, /* Disable emitting files from a compilation. */
|
20
|
-
"jsx": "react-jsx",
|
21
|
-
"rootDir": ".",
|
22
|
-
"declaration": true,
|
23
|
-
"sourceMap": true,
|
24
|
-
"outDir": "dist",
|
25
|
-
"emitDeclarationOnly": true
|
26
|
-
},
|
27
|
-
"include": [
|
28
|
-
"src"
|
29
|
-
]
|
30
|
-
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|