@gohanfromgoku/ui-kit 0.1.3 → 1.0.0

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,13 +1,13 @@
1
- import { jsx as _jsx } from "preact/jsx-runtime";
2
- import { memo, forwardRef } from "preact/compat";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
3
2
  import { checkProps } from "../../helpers/index";
3
+ import { forwardRef, memo } from "react";
4
4
  const defaultProps = {
5
5
  onClick: () => { },
6
6
  disabled: false,
7
7
  className: "",
8
8
  type: "button",
9
9
  };
10
- const Button = forwardRef((props, ref) => {
10
+ const Button = memo(forwardRef((props, ref) => {
11
11
  const { children, className, onClick, disabled, type, ...rest } = { ...defaultProps, ...props };
12
12
  return (_jsx("button", { ref: ref, className: className, disabled: disabled, type: type, onClick: (event) => {
13
13
  if (type === "button" || !type) {
@@ -17,5 +17,6 @@ const Button = forwardRef((props, ref) => {
17
17
  onClick(event);
18
18
  }
19
19
  }, ...rest, children: children }));
20
- });
21
- export default memo(Button, checkProps);
20
+ }), checkProps);
21
+ Button.displayName = "Button";
22
+ export default Button;
@@ -1,5 +1,5 @@
1
- import { jsx as _jsx } from "preact/jsx-runtime";
2
- import { forwardRef, memo } from "preact/compat";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, memo } from "react";
3
3
  import { checkProps } from "../../helpers/index";
4
4
  const defaultProps = {
5
5
  altImage: null,
@@ -8,12 +8,13 @@ const defaultProps = {
8
8
  priority: true,
9
9
  onClick: () => { }
10
10
  };
11
- const Image = forwardRef((props, ref) => {
11
+ const Image = memo(forwardRef((props, ref) => {
12
12
  const { altImage, className, src, priority, onClick, alt, ...rest } = { ...defaultProps, ...props };
13
13
  return (_jsx("img", { src: src, ref: ref, width: "100%", height: "100%", onClick: (event) => { event.preventDefault(); onClick(event); }, draggable: false, onError: async () => {
14
14
  if (ref && 'current' in ref && ref.current) {
15
15
  ref.current.src = altImage || "";
16
16
  }
17
17
  }, alt: alt, className: className, fetchPriority: priority ? "high" : "auto", loading: priority ? "eager" : "lazy", ...rest }));
18
- });
19
- export default memo(Image, checkProps);
18
+ }), checkProps);
19
+ Image.displayName = "Image";
20
+ export default Image;
@@ -1,7 +1,7 @@
1
- import { jsx as _jsx } from "preact/jsx-runtime";
2
- import { memo } from "preact/compat";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, memo } from "react";
3
3
  import { checkProps } from "../../helpers/index";
4
- import { translate } from "../../translations/index";
4
+ import { useTranslations } from "../../translations/index";
5
5
  const defaultProps = {
6
6
  onChange: () => { },
7
7
  className: "",
@@ -9,8 +9,10 @@ const defaultProps = {
9
9
  type: "text",
10
10
  name: ""
11
11
  };
12
- const Input = (props) => {
12
+ const Input = memo(forwardRef((props, ref) => {
13
+ const { translate } = useTranslations();
13
14
  const { onChange, className, placeholder, type, name, ...rest } = { ...defaultProps, ...props };
14
- return _jsx("input", { className: className, placeholder: translate(placeholder), type: type, name: name, onChange: event => onChange(event.currentTarget.value, event), ...rest });
15
- };
16
- export default memo(Input, checkProps);
15
+ return _jsx("input", { className: className, placeholder: translate(placeholder), type: type, ref: ref, name: name, onChange: event => onChange(event.currentTarget.value, event), ...rest });
16
+ }), checkProps);
17
+ Input.displayName = "Input";
18
+ export default Input;
@@ -1,7 +1,7 @@
1
- import { jsx as _jsx } from "preact/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { checkProps } from "../../helpers/index";
3
- import { translate } from "../../translations/index";
4
- import { forwardRef, memo, useMemo } from "preact/compat";
3
+ import { useTranslations } from "../../translations/index";
4
+ import { forwardRef, memo } from "react";
5
5
  const defaultProps = {
6
6
  text: "",
7
7
  data: {},
@@ -10,12 +10,14 @@ const defaultProps = {
10
10
  tag: "span",
11
11
  onClick: () => { },
12
12
  };
13
- const Text = forwardRef((props, ref) => {
13
+ const Text = memo(forwardRef((props, ref) => {
14
+ const { translate } = useTranslations();
14
15
  const { text, data, html, className, tag: Tag, onClick, ...rest } = { ...defaultProps, ...props };
15
- const translated = useMemo(() => translate(text, data), [text, JSON.stringify(data)]);
16
+ const translated = translate(text, data);
16
17
  if (html) {
17
18
  return (_jsx(Tag, { ...rest, ref: ref, dangerouslySetInnerHTML: { __html: translated }, className: className, onClick: (event) => { event.preventDefault(); onClick(event); } }));
18
19
  }
19
20
  return (_jsx(Tag, { ...rest, ref: ref, className: className, onClick: (event) => { event.preventDefault(); onClick(event); }, children: translated }));
20
- });
21
- export default memo(Text, checkProps);
21
+ }), checkProps);
22
+ Text.displayName = "Text";
23
+ export default Text;
@@ -1,14 +1,15 @@
1
- import { jsx as _jsx } from "preact/jsx-runtime";
2
- import { useEffect, useRef } from "preact/hooks";
3
- import { memo } from "preact/compat";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from "react";
3
+ import { memo } from "react";
4
4
  import { checkProps, toast } from "../../helpers/index";
5
- import { translate } from "../../translations/index";
5
+ import { useTranslations } from "../../translations/index";
6
6
  const isTouchDevice = () => typeof window !== "undefined" && "ontouchstart" in window;
7
7
  const styles = {
8
8
  width: "fit-content",
9
9
  height: "fit-content"
10
10
  };
11
- const Tooltip = ({ message, children, className }) => {
11
+ const Tooltip = memo(({ message, children, className }) => {
12
+ const { translate } = useTranslations();
12
13
  const ref = useRef(null);
13
14
  const toastRef = useRef(null);
14
15
  useEffect(() => {
@@ -48,5 +49,6 @@ const Tooltip = ({ message, children, className }) => {
48
49
  else
49
50
  toastRef.current = toast(translate(message), ref.current, 2000);
50
51
  }, children: children }));
51
- };
52
- export default memo(Tooltip, checkProps);
52
+ }, checkProps);
53
+ Tooltip.displayName = "Tooltip";
54
+ export default Tooltip;
@@ -1,4 +1,4 @@
1
- import { useEffect } from "preact/compat";
1
+ import { useEffect } from "react";
2
2
  const useHandleClickOutside = (ref, cb) => {
3
3
  useEffect(() => {
4
4
  const handlePointerDown = (event) => {
@@ -1,5 +1,5 @@
1
- import { signal } from "@preact/signals";
2
- const queryParamsSignal = signal({});
1
+ import createStore from "../storage/index";
2
+ const { queryParamsSignal } = createStore("queryParamsSignal", { value: {} });
3
3
  const getParams = () => {
4
4
  const search = window.location.search.slice(1);
5
5
  const params = new URLSearchParams(search);
@@ -8,10 +8,8 @@ const getParams = () => {
8
8
  obj[key] = value;
9
9
  return obj;
10
10
  };
11
- queryParamsSignal.value = getParams();
12
- window.addEventListener("popstate", () => {
13
- queryParamsSignal.value = getParams();
14
- });
11
+ queryParamsSignal.setState({ value: getParams() });
12
+ window.addEventListener("popstate", () => { queryParamsSignal.setState({ value: getParams() }); });
15
13
  export const setQueryParams = (updates, { replace = false, pathname } = {}) => {
16
14
  const params = new URLSearchParams();
17
15
  Object.entries(updates).forEach(([key, value]) => {
@@ -26,6 +24,6 @@ export const setQueryParams = (updates, { replace = false, pathname } = {}) => {
26
24
  window.history.replaceState({}, "", newUrl);
27
25
  else
28
26
  window.history.pushState({}, "", newUrl);
29
- queryParamsSignal.value = getParams();
27
+ queryParamsSignal.setState({ value: getParams() });
30
28
  };
31
29
  export { queryParamsSignal as queryParams };
@@ -1,4 +1,4 @@
1
- import { useLayoutEffect, useMemo, useState } from "preact/hooks";
1
+ import { useLayoutEffect, useMemo, useState } from "react";
2
2
  const useWindowSize = () => {
3
3
  const [size, setSize] = useState({ height: window.innerHeight, width: window.innerWidth });
4
4
  useLayoutEffect(() => {
@@ -1,52 +1,71 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "preact/jsx-runtime";
2
- import { useEffect } from "preact/compat";
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
3
  import createStore from "../storage/index";
4
4
  import { generateURLToNavigate, isRouteMatching } from "./support/url.support";
5
5
  import { extractParamsFromURL } from "./support/params.support";
6
6
  import { extractQueryParamsFromURL } from "./support/query-params.support";
7
- import { computed } from "@preact/signals";
8
- const locationDetails = createStore("location-details", { value: { params: {}, queryParams: {}, ...window.location } });
9
- const activeRoute = createStore("active-route", { value: {} });
7
+ // Initialize stores
8
+ const { locationDetails } = createStore("locationDetails", {
9
+ value: { params: {}, queryParams: {}, ...window.location }
10
+ });
11
+ const { activeRoute } = createStore("activeRoute", {
12
+ value: {}
13
+ });
10
14
  const createBrowserRouter = (routes, { page404 } = { page404: () => _jsx(_Fragment, { children: "Page Not Found" }) }) => {
15
+ // Navigate function
11
16
  const navigate = (to, { queryParams, replace } = {}) => {
12
17
  if (typeof to === "number") {
13
18
  window.history.go(to);
14
19
  return;
15
20
  }
16
21
  const url = generateURLToNavigate(to, queryParams || {});
17
- if (window.location.href === url) {
22
+ if (window.location.href === url)
18
23
  return;
19
- }
20
24
  if (replace) {
21
25
  window.history.replaceState({}, "", url);
22
26
  }
23
27
  else {
24
28
  window.history.pushState({}, "", url);
25
29
  }
30
+ // Trigger update
26
31
  window.dispatchEvent(new Event("popstate"));
27
32
  };
33
+ // Hook to get current location details
28
34
  const useLocationDetails = () => {
29
35
  if (routes.length === 0) {
30
- throw "useLocationDetails cannot be used without initializing routes, use createRoutes initialize routes";
36
+ throw new Error("useLocationDetails cannot be used without initializing routes. Use createBrowserRouter with routes.");
31
37
  }
32
- ;
33
- const values = computed(() => locationDetails.value);
34
- return values.value;
38
+ const [state, setState] = useState(locationDetails.value);
39
+ useEffect(() => {
40
+ const update = () => setState(locationDetails.value);
41
+ window.addEventListener("popstate", update);
42
+ return () => window.removeEventListener("popstate", update);
43
+ }, []);
44
+ return state;
35
45
  };
46
+ // Outlet component
36
47
  const Outlet = () => {
37
- const component = computed(() => activeRoute.value?.component ?? page404);
48
+ const [, setRender] = useState(0);
38
49
  useEffect(() => {
39
50
  const updateLocation = () => {
40
- const active = routes.find(r => isRouteMatching(r.pathname)) || { pathname: window.location.href, component: page404 };
51
+ // Find active route
52
+ const active = routes.find(r => isRouteMatching(r.pathname)) ||
53
+ { pathname: window.location.pathname, component: page404 };
41
54
  activeRoute.setState({ value: active });
55
+ // Update location details
42
56
  const params = extractParamsFromURL(window.location.pathname, active.pathname);
43
57
  const queryParams = extractQueryParamsFromURL(window.location.href);
44
58
  locationDetails.setState({ value: { params, queryParams, ...window.location } });
59
+ // Force re-render
60
+ setRender(r => r + 1);
45
61
  };
62
+ // Initial update
63
+ updateLocation();
46
64
  window.addEventListener("popstate", updateLocation);
47
65
  return () => window.removeEventListener("popstate", updateLocation);
48
66
  }, []);
49
- return _jsx(component.value, {});
67
+ const Component = activeRoute.value?.component ?? page404;
68
+ return _jsx(Component, {});
50
69
  };
51
70
  return {
52
71
  navigate,
@@ -1,5 +1,5 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "preact/jsx-runtime";
2
- import {} from "preact/compat";
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import {} from "react";
3
3
  import createStore from "../storage/index";
4
4
  import { generateURLToNavigate, isRouteMatching } from "./support/url.support";
5
5
  import { extractParamsFromURL } from "./support/params.support";
@@ -9,10 +9,10 @@ const createMemoryRouter = (routes, { page404 } = { page404: () => _jsx(_Fragmen
9
9
  throw "Atleast one route should present";
10
10
  }
11
11
  ;
12
- const activeRoute = createStore("active-route", { value: routes.find(() => isRouteMatching("/")) || { pathname: "/", component: page404 } });
13
- const locationDetails = createStore("location-details", { value: { params: {}, queryParams: {}, ...window.location, pathname: activeRoute.value.pathname } });
14
- const entries = createStore("entries", { value: ["/"] });
15
- const currentIndex = createStore("current-index", { value: 0 });
12
+ const { activeRoute } = createStore("activeRoute", routes.find(() => isRouteMatching("/")) || { pathname: "/", component: page404 });
13
+ const { locationDetails } = createStore("locationDetails", { params: {}, queryParams: {}, ...window.location, pathname: activeRoute.pathname });
14
+ const { entries } = createStore("entries", { value: ["/"] });
15
+ const { currentIndex } = createStore("currentIndex", { value: 0 });
16
16
  const navigate = (to, { queryParams } = {}) => {
17
17
  if (typeof to === "number") {
18
18
  const targetIndex = currentIndex.value + to;
@@ -22,28 +22,28 @@ const createMemoryRouter = (routes, { page404 } = { page404: () => _jsx(_Fragmen
22
22
  const url = raw.startsWith("http") ? new URL(raw).pathname + new URL(raw).search : raw;
23
23
  currentIndex.setState({ value: targetIndex });
24
24
  const active = routes.find(r => isRouteMatching(r.pathname, url)) || { pathname: url, component: page404 };
25
- activeRoute.setState({ value: active });
25
+ activeRoute.setState(active);
26
26
  const params = extractParamsFromURL(url, active.pathname);
27
27
  const allQueryParams = extractQueryParamsFromURL(url);
28
- locationDetails.setState({ value: { params, queryParams: allQueryParams, ...window.location, pathname: active.pathname } });
28
+ locationDetails.setState({ params, queryParams: allQueryParams, ...window.location, pathname: active.pathname });
29
29
  return;
30
30
  }
31
31
  const url = generateURLToNavigate(to, queryParams || {});
32
- if (activeRoute.value.pathname === url)
32
+ if (activeRoute.pathname === url)
33
33
  return;
34
34
  entries.setState({ value: [...entries.value, url] });
35
35
  const active = routes.find(r => isRouteMatching(r.pathname, to)) || { pathname: to, component: page404 };
36
- activeRoute.setState({ value: active });
37
- const params = extractParamsFromURL(to, activeRoute.value.pathname);
36
+ activeRoute.setState(active);
37
+ const params = extractParamsFromURL(to, activeRoute.pathname);
38
38
  const allQueryParams = extractQueryParamsFromURL(url);
39
- locationDetails.setState({ value: { params, queryParams: allQueryParams, ...window.location, pathname: active.pathname } });
39
+ locationDetails.setState({ params, queryParams: allQueryParams, ...window.location, pathname: active.pathname });
40
40
  currentIndex.setState({ value: currentIndex.value + 1 });
41
41
  };
42
42
  const useLocationDetails = () => {
43
- return locationDetails.value;
43
+ return locationDetails;
44
44
  };
45
45
  const Outlet = () => {
46
- const Component = activeRoute.value.component;
46
+ const Component = activeRoute.component;
47
47
  return _jsx(Component, {});
48
48
  };
49
49
  return {
@@ -1,5 +1,6 @@
1
1
  import toast from "../helpers/toast";
2
- const copyToClipboard = async (text = "", message = "Copied") => {
2
+ const copyToClipboard = async function (message = "Copied") {
3
+ const text = this;
3
4
  try {
4
5
  if (navigator.clipboard && window.isSecureContext) {
5
6
  await navigator.clipboard.writeText(text);
@@ -1,6 +1,8 @@
1
1
  import copyToClipboard from "./copyToClipboard";
2
2
  import maskString from "./maskString";
3
+ import capitalize from "./stringCapitalize";
3
4
  if (!String.prototype.copy) {
4
5
  String.prototype.copy = copyToClipboard;
5
6
  String.prototype.mask = maskString;
7
+ String.prototype.capitalize = capitalize;
6
8
  }
@@ -0,0 +1,4 @@
1
+ const capitalize = function () {
2
+ return (this.charAt(0).toUpperCase() + this.slice(1));
3
+ };
4
+ export default capitalize;
@@ -1,51 +1,36 @@
1
- import { signal } from "@preact/signals";
2
- const createStore = (name, initialState, persist = []) => {
3
- const state = signal({ ...initialState });
4
- try {
5
- const stored = localStorage.getItem(name);
6
- if (stored) {
7
- state.value = { ...state.value, ...JSON.parse(stored) };
8
- }
9
- }
10
- catch {
11
- // Catch any Errors
12
- }
13
- const setState = (values) => {
14
- state.value = { ...state.value, ...values };
15
- if (persist.length) {
16
- const toStore = persist.reduce((acc, key) => {
17
- acc[key] = state.value[key];
18
- return acc;
19
- }, {});
20
- localStorage.setItem(name, JSON.stringify(toStore));
21
- }
1
+ import "../prototypes";
2
+ import { useSyncExternalStore } from "react";
3
+ export default function createStore(name, initialState) {
4
+ let state = initialState;
5
+ const listeners = new Set();
6
+ const subscribe = (listener) => {
7
+ listeners.add(listener);
8
+ return () => listeners.delete(listener);
9
+ };
10
+ const getSnapshot = () => state;
11
+ const setState = (partial) => {
12
+ state = { ...state, ...partial };
13
+ listeners.forEach(l => l());
22
14
  };
23
15
  const resetState = () => {
24
- state.value = initialState;
25
- localStorage.removeItem(name);
16
+ state = initialState;
17
+ listeners.forEach(l => l());
26
18
  };
27
- return Object.assign(new Proxy(initialState, {
28
- get(_, prop) {
29
- switch (prop) {
30
- case "setState":
31
- return setState;
32
- case "resetState":
33
- return resetState;
34
- default:
35
- return state.value[prop];
36
- }
37
- },
38
- set(_, prop, value) {
39
- state.value = { ...state.value, [prop]: value };
40
- if (persist.includes(prop)) {
41
- const toStore = persist.reduce((acc, key) => {
42
- acc[key] = state.value[key];
43
- return acc;
44
- }, {});
45
- localStorage.setItem(name, JSON.stringify(toStore));
46
- }
47
- return true;
19
+ const useStore = () => useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
20
+ const capName = name.capitalize();
21
+ const exposedState = {};
22
+ Object.keys(initialState).forEach(key => {
23
+ Object.defineProperty(exposedState, key, {
24
+ enumerable: true,
25
+ get: () => state[key],
26
+ });
27
+ });
28
+ return {
29
+ [name]: {
30
+ ...exposedState,
31
+ setState,
32
+ resetState
48
33
  },
49
- }), { __signal: state });
50
- };
51
- export default createStore;
34
+ [`use${capName}State`]: useStore
35
+ };
36
+ }
@@ -1,34 +1,39 @@
1
- import { signal, computed } from "@preact/signals";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { objectPath } from "../helpers/index";
3
- export const languages = signal({});
4
- export const language = signal(window.localStorage.getItem("language") || "en");
5
- const translations = computed(() => objectPath(languages.value[language.value]));
6
- const interpolate = (str, data) => {
7
- if (typeof str === "string") {
8
- return str.replace(/{{\s*(\w+)\s*}}/g, (_, key) => key in data ? String(data[key]) : `{{${key}}}`);
9
- }
10
- ;
11
- return JSON.stringify(str);
3
+ import { createContext, useContext, useState, useEffect, } from "react";
4
+ const TranslationsContext = createContext(null);
5
+ const isBrowser = typeof window !== "undefined";
6
+ const interpolate = (str, data) => str.replace(/{{\s*(\w+)\s*}}/g, (_, key) => key in data ? String(data[key]) : `{{${key}}}`);
7
+ export const TranslationsProvider = ({ children, languages, }) => {
8
+ const [language, setLanguage] = useState(() => {
9
+ if (!isBrowser)
10
+ return "en";
11
+ return localStorage.getItem("language") ?? "en";
12
+ });
13
+ useEffect(() => { if (isBrowser) {
14
+ localStorage.setItem("language", language);
15
+ return () => { localStorage.removeItem("language"); };
16
+ } }, [language]);
17
+ return (_jsx(TranslationsContext.Provider, { value: { languages, changeLanguage: setLanguage, language }, children: children }));
12
18
  };
13
- export const initTranslations = async (langs) => {
14
- try {
15
- languages.value = langs;
16
- return true;
17
- }
18
- catch (e) {
19
- console.error(e);
20
- return false;
19
+ export const useTranslations = () => {
20
+ const context = useContext(TranslationsContext);
21
+ if (!context) {
22
+ throw new Error("useTranslations must be used inside TranslationsProvider");
21
23
  }
22
- };
23
- export const translate = (key, data = {}) => {
24
- const dictionary = translations.value;
25
- if (!dictionary.has(key))
26
- return key;
27
- const value = dictionary.get(key);
28
- return Object.keys(data).length ? interpolate(value, data) : value;
29
- };
30
- export const changeLanguage = (lang) => {
31
- language.value = lang;
32
- window.localStorage.setItem("language", lang);
33
- return true;
24
+ const { languages, language, changeLanguage } = context;
25
+ const translations = objectPath(languages[language]);
26
+ const translate = (key, data = {}) => {
27
+ if (!translations?.has?.(key))
28
+ return key;
29
+ const value = translations.get(key);
30
+ if (typeof value !== "string")
31
+ return String(value);
32
+ return Object.keys(data).length ? interpolate(value, data) : value;
33
+ };
34
+ return {
35
+ translate,
36
+ changeLanguage,
37
+ language,
38
+ };
34
39
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gohanfromgoku/ui-kit",
3
- "version": "0.1.3",
3
+ "version": "1.0.0",
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": {
@@ -26,12 +26,11 @@
26
26
  "author": "GohanfromGoku",
27
27
  "license": "MIT",
28
28
  "peerDependencies": {
29
- "@preact/signals": "^2.5.1",
30
- "preact": "^10.28.0"
29
+ "react": "^19.2.3"
31
30
  },
32
31
  "devDependencies": {
33
- "@preact/signals": "^2.5.1",
34
- "preact": "^10.28.1",
32
+ "@types/react": "^19.2.8",
33
+ "react": "^19.2.3",
35
34
  "tsc-alias": "^1.8.16",
36
35
  "typescript": "^5.9.3"
37
36
  },
@@ -1,6 +1,6 @@
1
- import type { ButtonHTMLAttributes } from "preact";
2
- import { type ReactNode, type Ref } from "preact/compat";
3
- type ClickEvent = MouseEvent | TouchEvent;
1
+ import type { ButtonHTMLAttributes, MouseEvent, TouchEvent } from "react";
2
+ import { type ReactNode } from "react";
3
+ type ClickEvent = MouseEvent<HTMLButtonElement> | TouchEvent<HTMLButtonElement>;
4
4
  export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
5
5
  children: ReactNode;
6
6
  className?: string;
@@ -8,7 +8,5 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
8
8
  onClick?: (event: ClickEvent) => void;
9
9
  type?: "button" | "submit" | "reset";
10
10
  }
11
- declare const _default: import("preact").FunctionComponent<import("preact/compat").PropsWithoutRef<ButtonProps> & {
12
- ref?: Ref<HTMLButtonElement> | undefined;
13
- }>;
14
- export default _default;
11
+ declare const Button: import("react").NamedExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
12
+ export default Button;
@@ -1,5 +1,5 @@
1
- import type { ImgHTMLAttributes } from "preact";
2
- type ClickEvent = MouseEvent | TouchEvent;
1
+ import type { ImgHTMLAttributes, MouseEvent, TouchEvent } from "react";
2
+ type ClickEvent = MouseEvent<HTMLImageElement> | TouchEvent<HTMLImageElement>;
3
3
  export interface ImageProps extends ImgHTMLAttributes<HTMLImageElement> {
4
4
  src: string;
5
5
  className?: string;
@@ -8,7 +8,5 @@ export interface ImageProps extends ImgHTMLAttributes<HTMLImageElement> {
8
8
  priority?: true | false;
9
9
  onClick?: (event: ClickEvent) => void;
10
10
  }
11
- declare const _default: import("preact").FunctionComponent<import("preact/compat").PropsWithoutRef<ImageProps> & {
12
- ref?: import("preact").Ref<HTMLImageElement> | undefined;
13
- }>;
14
- export default _default;
11
+ declare const Image: import("react").NamedExoticComponent<ImageProps & import("react").RefAttributes<HTMLImageElement>>;
12
+ export default Image;
@@ -1,10 +1,10 @@
1
- import type { InputHTMLAttributes, TargetedEvent } from "preact";
1
+ import type { ChangeEvent, InputHTMLAttributes } from "react";
2
2
  interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> {
3
3
  placeholder?: string;
4
4
  className?: string;
5
5
  type?: string;
6
- onChange?: (value: string, event: TargetedEvent<HTMLInputElement, Event>) => void;
6
+ onChange?: (value: string, event: ChangeEvent<HTMLInputElement>) => void;
7
7
  name?: string;
8
8
  }
9
- declare const _default: (props: InputProps) => import("preact").JSX.Element;
10
- export default _default;
9
+ declare const Input: import("react").NamedExoticComponent<InputProps & import("react").RefAttributes<HTMLInputElement>>;
10
+ export default Input;
@@ -6,7 +6,5 @@ interface TextProps {
6
6
  tag?: any;
7
7
  onClick?: (event: any) => void;
8
8
  }
9
- declare const _default: import("preact").FunctionComponent<import("preact/compat").PropsWithoutRef<TextProps> & {
10
- ref?: import("preact").Ref<HTMLSpanElement> | undefined;
11
- }>;
12
- export default _default;
9
+ declare const Text: import("react").NamedExoticComponent<TextProps & import("react").RefAttributes<HTMLElement>>;
10
+ export default Text;
@@ -1,7 +1,7 @@
1
- import { type ReactNode } from "preact/compat";
2
- declare const _default: ({ message, children, className }: {
1
+ import { type ReactNode } from "react";
2
+ declare const Tooltip: import("react").MemoExoticComponent<({ message, children, className }: {
3
3
  message: string;
4
4
  children: ReactNode;
5
5
  className?: string;
6
- }) => import("preact").JSX.Element;
7
- export default _default;
6
+ }) => import("react/jsx-runtime").JSX.Element>;
7
+ export default Tooltip;
@@ -1,3 +1,3 @@
1
- import { type MutableRefObject } from "preact/compat";
2
- declare const useHandleClickOutside: (ref: MutableRefObject<HTMLElement | null>, cb: () => void) => void;
1
+ import { type RefObject } from "react";
2
+ declare const useHandleClickOutside: (ref: RefObject<HTMLElement>, cb: () => void) => void;
3
3
  export default useHandleClickOutside;
@@ -3,6 +3,13 @@ type SetQueryParams = (updates: Record<string, any>, options?: {
3
3
  replace?: boolean;
4
4
  pathname?: string;
5
5
  }) => void;
6
- declare const queryParamsSignal: import("@preact/signals").Signal<QueryParams>;
6
+ declare const queryParamsSignal: {
7
+ value: QueryParams;
8
+ } & {
9
+ setState: (partial: Partial<{
10
+ value: QueryParams;
11
+ }>) => void;
12
+ resetState: () => void;
13
+ };
7
14
  export declare const setQueryParams: SetQueryParams;
8
15
  export { queryParamsSignal as queryParams };
@@ -1,4 +1,4 @@
1
- import { type ComponentType } from "preact/compat";
1
+ import { type ComponentType } from "react";
2
2
  interface Route {
3
3
  pathname: string;
4
4
  component: ComponentType;
@@ -28,6 +28,6 @@ declare const createBrowserRouter: (routes: Route[], { page404 }?: {
28
28
  params: {};
29
29
  queryParams: {};
30
30
  };
31
- Outlet: () => import("preact").JSX.Element;
31
+ Outlet: () => import("react/jsx-runtime").JSX.Element;
32
32
  };
33
33
  export default createBrowserRouter;
@@ -1,4 +1,4 @@
1
- import { type ComponentType } from "preact/compat";
1
+ import { type ComponentType } from "react";
2
2
  interface Route {
3
3
  pathname: string;
4
4
  component: ComponentType;
@@ -26,7 +26,27 @@ declare const createMemoryRouter: (routes: Route[], { page404 }?: {
26
26
  replace(url: string | URL): void;
27
27
  params: {};
28
28
  queryParams: {};
29
+ } & {
30
+ setState: (partial: Partial<{
31
+ pathname: string;
32
+ ancestorOrigins: DOMStringList;
33
+ hash: string;
34
+ host: string;
35
+ hostname: string;
36
+ href: string;
37
+ toString(): string;
38
+ origin: string;
39
+ port: string;
40
+ protocol: string;
41
+ search: string;
42
+ assign(url: string | URL): void;
43
+ reload(): void;
44
+ replace(url: string | URL): void;
45
+ params: {};
46
+ queryParams: {};
47
+ }>) => void;
48
+ resetState: () => void;
29
49
  };
30
- Outlet: () => import("preact").JSX.Element;
50
+ Outlet: () => import("react/jsx-runtime").JSX.Element;
31
51
  };
32
52
  export default createMemoryRouter;
@@ -1,2 +1,2 @@
1
- declare const copyToClipboard: (text?: string, message?: string) => Promise<true | undefined>;
1
+ declare const copyToClipboard: (this: string, message?: string) => Promise<true | undefined>;
2
2
  export default copyToClipboard;
@@ -1,7 +1,8 @@
1
1
  declare global {
2
2
  interface String {
3
- copy(text: string, message?: string): void;
3
+ copy(message?: string): void;
4
4
  mask(visibleCharacters?: number, maskWith?: string): string;
5
+ capitalize(): Capitalize<string>;
5
6
  }
6
7
  }
7
8
  export {};
@@ -0,0 +1,2 @@
1
+ declare const capitalize: <T extends string>(this: T) => Capitalize<T>;
2
+ export default capitalize;
@@ -1,8 +1,5 @@
1
- type PersistKeys<T> = (keyof T)[];
2
- declare const createStore: <T extends Record<string, any>>(name: string, initialState: T, persist?: PersistKeys<T>) => T & {
3
- setState: (values: Partial<T>) => void;
1
+ import "../prototypes";
2
+ export default function createStore<Name extends string, T extends Record<string, any>>(name: Name, initialState: T): { [K in Name]: T & {
3
+ setState: (partial: Partial<T>) => void;
4
4
  resetState: () => void;
5
- } & {
6
- __signal: import("@preact/signals").Signal<T>;
7
- };
8
- export default createStore;
5
+ }; } & { [K in `use${Capitalize<Name>}State`]: () => T; };
@@ -1,5 +1,12 @@
1
- export declare const languages: import("@preact/signals").Signal<Record<string, Record<string, any>>>;
2
- export declare const language: import("@preact/signals").Signal<string>;
3
- export declare const initTranslations: (langs: Record<string, Record<string, any>>) => Promise<boolean>;
4
- export declare const translate: (key: string, data?: Record<string, string | number>) => string;
5
- export declare const changeLanguage: (lang: string) => boolean;
1
+ import { type ReactNode } from "react";
2
+ type Languages = Record<string, Record<string, any>>;
3
+ export declare const TranslationsProvider: ({ children, languages, }: {
4
+ children: ReactNode;
5
+ languages: Languages;
6
+ }) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const useTranslations: () => {
8
+ translate: (key: string, data?: Record<string, string | number>) => string;
9
+ changeLanguage: (lang: any) => void;
10
+ language: any;
11
+ };
12
+ export {};