@gohanfromgoku/ui-kit 0.1.0 → 0.1.2

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,6 +1,6 @@
1
1
  import { jsx as _jsx } from "preact/jsx-runtime";
2
2
  import { memo, forwardRef } from "preact/compat";
3
- import checkProps from "../../helpers/checkProps";
3
+ import { checkProps } from "../../helpers/index";
4
4
  const defaultProps = {
5
5
  onClick: () => { },
6
6
  disabled: false,
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "preact/jsx-runtime";
2
2
  import { forwardRef, memo } from "preact/compat";
3
- import checkProps from "../../helpers/checkProps";
3
+ import { checkProps } from "../../helpers/index";
4
4
  const defaultProps = {
5
5
  altImage: null,
6
6
  className: "",
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "preact/jsx-runtime";
2
2
  import { memo } from "preact/compat";
3
- import checkProps from "../../helpers/checkProps";
3
+ import { checkProps } from "../../helpers/index";
4
4
  import { translate } from "../../translations/index";
5
5
  const defaultProps = {
6
6
  onChange: () => { },
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "preact/jsx-runtime";
2
- import checkProps from "../../helpers/checkProps";
2
+ import { checkProps } from "../../helpers/index";
3
3
  import { translate } from "../../translations/index";
4
4
  import { forwardRef, memo, useMemo } from "preact/compat";
5
5
  const defaultProps = {
@@ -1,8 +1,7 @@
1
1
  import { jsx as _jsx } from "preact/jsx-runtime";
2
2
  import { useEffect, useRef } from "preact/hooks";
3
3
  import { memo } from "preact/compat";
4
- import checkProps from "../../helpers/checkProps";
5
- import toast from "../../helpers/toast";
4
+ import { checkProps, toast } from "../../helpers/index";
6
5
  import { translate } from "../../translations/index";
7
6
  const isTouchDevice = () => typeof window !== "undefined" && "ontouchstart" in window;
8
7
  const styles = {
@@ -15,7 +15,7 @@ const Outlet = ({ routes, page404: Page404Page = Page404 }) => {
15
15
  const params = extractParamsFromURL(currentpath, active.pathname);
16
16
  const queryParams = extractQueryParamsFromURL(href);
17
17
  activeRoute.setState({ value: active });
18
- location.setState({ value: { params, queryParams } });
18
+ location.setState({ value: { params, queryParams, ...window.location } });
19
19
  };
20
20
  updateLocation();
21
21
  window.addEventListener("popstate", updateLocation);
@@ -1,6 +1,16 @@
1
- import { globalRoutes } from "./navigation.store";
1
+ import { activeRoute, globalRoutes, location } from "./navigation.store";
2
+ import { extractParamsFromURL } from "./extractParamsFromURL";
3
+ import { extractQueryParamsFromURL } from "./extractQueryParamsFromURL";
4
+ import isRouteMatching from "./isRouteMatching";
5
+ import { Page404 } from "./Page404";
2
6
  const createRoutes = (routes) => {
3
7
  globalRoutes.setState({ value: routes });
8
+ const active = routes.find(r => isRouteMatching(r.pathname)) || { pathname: window.location.href, component: Page404 };
9
+ const { pathname: currentpath, href } = window.location;
10
+ const params = extractParamsFromURL(currentpath, active.pathname);
11
+ const queryParams = extractQueryParamsFromURL(href);
12
+ activeRoute.setState({ value: active });
13
+ location.setState({ value: { params, queryParams, ...window.location } });
4
14
  return routes;
5
15
  };
6
16
  export default createRoutes;
@@ -3,8 +3,8 @@
3
3
  */
4
4
  const isRouteMatching = (routePath) => {
5
5
  const current = window.location.pathname;
6
- if (routePath === "/") {
7
- return current === "/";
6
+ if (routePath === "/" || routePath === "") {
7
+ return current === "/" || current === "/index.html" || current === "";
8
8
  }
9
9
  const routeParts = routePath.split("/").filter(Boolean);
10
10
  const currentParts = current.split("/").filter(Boolean);
@@ -1,5 +1,5 @@
1
1
  import { signal, computed } from "@preact/signals";
2
- import objectPath from "../helpers/objectPath";
2
+ import { objectPath } from "../helpers/index";
3
3
  export const languages = signal({});
4
4
  export const language = signal(window.localStorage.getItem("language") || "en");
5
5
  const translations = computed(() => objectPath(languages.value[language.value]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gohanfromgoku/ui-kit",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "ui-kit is a TypeScript based UI component library designed for building modern web applications with ease and efficiency.",
5
5
  "sideEffects": false,
6
6
  "scripts": {
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@preact/signals": "^2.5.1",
34
- "preact": "^10.28.0",
34
+ "preact": "^10.28.1",
35
35
  "tsc-alias": "^1.8.16",
36
36
  "typescript": "^5.9.3"
37
37
  },
@@ -2,7 +2,6 @@ import type { ComponentType } from "preact/compat";
2
2
  export interface Route {
3
3
  pathname: string;
4
4
  component: ComponentType;
5
- index?: true | undefined | null;
6
5
  }
7
6
  declare const createRoutes: (routes: Route[]) => Route[];
8
7
  export default createRoutes;