@unsetsoft/ryunixjs 0.2.30-nightly.1 → 0.2.30-nightly.3

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.30-nightly.1",
3
+ "version": "0.2.30-nightly.3",
4
4
  "license": "MIT",
5
5
  "main": "./dist/Ryunix.js",
6
6
  "private": false,
package/src/lib/index.js CHANGED
@@ -2,7 +2,7 @@ import { createElement, Fragments } from "./createElement";
2
2
  import { render, init } from "./render";
3
3
  import { useContext, useStore, useEffect } from "./hooks";
4
4
  import { createContext } from "./createContext";
5
- import { Router, Link } from "./navigation";
5
+ import { Router, Navigate } from "./navigation";
6
6
  import * as Dom from "./dom";
7
7
  import * as Workers from "./workers";
8
8
  import * as Reconciler from "./reconciler";
@@ -16,7 +16,7 @@ export {
16
16
  useContext,
17
17
  Fragments,
18
18
  Router,
19
- Link,
19
+ Navigate,
20
20
  };
21
21
 
22
22
  export default {
@@ -22,7 +22,18 @@ const Router = ({ path, component }) => {
22
22
  return currentPath === path ? component() : null;
23
23
  };
24
24
 
25
- const Link = (props) => {
25
+ const Navigate = (props) => {
26
+ if (props.style) {
27
+ throw new Error(
28
+ "The style attribute is not supported on internal components."
29
+ );
30
+ }
31
+ if (props.to === "") {
32
+ throw new Error("'to=' cannot be empty.");
33
+ }
34
+ if (props.className === "") {
35
+ throw new Error("className cannot be empty.");
36
+ }
26
37
  const preventReload = (event) => {
27
38
  event.preventDefault();
28
39
  if (window.location.pathname !== props.to) {
@@ -32,11 +43,9 @@ const Link = (props) => {
32
43
  localStorage.setItem("pathname", props.to);
33
44
  }
34
45
  };
35
- return createElement(
36
- "a",
37
- { href: "google.com", onclick: preventReload },
38
- props.children
39
- );
46
+
47
+ const anchor = { href: props.to, onClick: preventReload, ...props };
48
+ return createElement("a", anchor, props.label);
40
49
  };
41
50
 
42
- export { Router, Link };
51
+ export { Router, Navigate };
package/src/main.js CHANGED
@@ -6,6 +6,8 @@ export {
6
6
  createContext,
7
7
  useContext,
8
8
  Fragments,
9
+ Navigate,
10
+ Router,
9
11
  } from "./lib/index";
10
12
 
11
13
  window.Ryunix = Ryunix;