@unsetsoft/ryunixjs 0.2.9-nightly.4 → 0.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unsetsoft/ryunixjs",
3
- "version": "0.2.9-nightly.4",
3
+ "version": "0.2.9",
4
4
  "license": "MIT",
5
5
  "main": "./dist/Ryunix.js",
6
6
  "private": false,
package/webpack.config.js CHANGED
@@ -22,7 +22,7 @@ module.exports = {
22
22
  rules: [
23
23
  {
24
24
  test: /\.(js|jsx|ts|tsx|ryx)$/,
25
-
25
+ exclude: /node_modules/,
26
26
  use: {
27
27
  loader: "babel-loader",
28
28
  options: {
package/navigate/Link.jsx DELETED
@@ -1,25 +0,0 @@
1
- /**
2
- * The Link function is a Ryunix component that prevents page reload when a link is clicked and updates
3
- * the browser's history and local storage.
4
- * @param props - The `props` parameter is an object that contains the properties passed to the `Link`
5
- * component. These properties can include the following:
6
- * @returns The Link component is being returned.
7
- */
8
- const Link = (props) => {
9
- const preventReload = (event) => {
10
- event.preventDefault();
11
- if (window.location.pathname !== props.to) {
12
- window.history.pushState({}, "", props.to);
13
- const navigationEvent = new Event("pushsatate");
14
- window.dispatchEvent(navigationEvent);
15
- localStorage.setItem("pathname", props.to);
16
- }
17
- };
18
- return (
19
- <a href={props.to} onClick={preventReload} {...props}>
20
- {props.children}
21
- </a>
22
- );
23
- };
24
-
25
- export default Link;
@@ -1,30 +0,0 @@
1
- import { useEffect, useStore } from "../lib/dom";
2
- /**
3
- * The Router component is responsible for rendering a specific component based on the current path in
4
- * the browser's URL.
5
- * @returns The `Router` component returns the `component` if the `currentPath` matches the specified
6
- * `path`, otherwise it returns `null`.
7
- */
8
- const Router = ({ path, component }) => {
9
- const [currentPath, setCurrentPath] = useStore(window.location.pathname);
10
-
11
- useEffect(() => {
12
- const onLocationChange = () => {
13
- setCurrentPath(() => window.location.pathname);
14
- };
15
-
16
- window.addEventListener("navigate", onLocationChange);
17
- window.addEventListener("pushsatate", onLocationChange);
18
- window.addEventListener("popstate", onLocationChange);
19
-
20
- return () => {
21
- window.removeEventListener("navigate", onLocationChange);
22
- window.removeEventListener("pushsatate", onLocationChange);
23
- window.removeEventListener("popstate", onLocationChange);
24
- };
25
- }, [currentPath]);
26
-
27
- return currentPath === path ? component() : null;
28
- };
29
-
30
- export default Router;
package/navigate/index.js DELETED
@@ -1,4 +0,0 @@
1
- import Router from "./Router";
2
- import Link from "./Link";
3
-
4
- export { Router, Link };