@gohanfromgoku/ui-kit 0.0.1
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/README.md +1 -0
- package/dist/api/index.js +1 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/Image/index.js +1 -0
- package/dist/components/Input/index.js +1 -0
- package/dist/components/Text/index.js +1 -0
- package/dist/components/Tooltip/index.js +1 -0
- package/dist/helpers/checkProps.js +1 -0
- package/dist/helpers/objectPath.js +1 -0
- package/dist/helpers/toast.js +1 -0
- package/dist/hooks/useHandleClickOutside.js +1 -0
- package/dist/hooks/useQueryParams.js +1 -0
- package/dist/hooks/useWindowSize.js +1 -0
- package/dist/prototypes/copyToClipboard.js +1 -0
- package/dist/prototypes/index.js +1 -0
- package/dist/prototypes/maskString.js +1 -0
- package/dist/storage/index.js +1 -0
- package/dist/translations/index.js +1 -0
- package/package.json +90 -0
- package/types/api/index.d.ts +23 -0
- package/types/components/Button/index.d.ts +14 -0
- package/types/components/Image/index.d.ts +14 -0
- package/types/components/Input/index.d.ts +10 -0
- package/types/components/Text/index.d.ts +12 -0
- package/types/components/Tooltip/index.d.ts +7 -0
- package/types/helpers/checkProps.d.ts +2 -0
- package/types/helpers/objectPath.d.ts +6 -0
- package/types/helpers/toast.d.ts +2 -0
- package/types/hooks/useHandleClickOutside.d.ts +3 -0
- package/types/hooks/useQueryParams.d.ts +8 -0
- package/types/hooks/useWindowSize.d.ts +5 -0
- package/types/prototypes/copyToClipboard.d.ts +2 -0
- package/types/prototypes/index.d.ts +7 -0
- package/types/prototypes/maskString.d.ts +2 -0
- package/types/storage/index.d.ts +8 -0
- package/types/translations/index.d.ts +5 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @gohanfromgoku/ui-kit
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const METHODS={GET:"GET",POST:"POST",PUT:"PUT",DELETE:"DELETE"};const appendParams=(t,e)=>{if(!e)return t;const s=new URLSearchParams({...e}).toString();return s?`${t}?${s}`:t},parseResponse=async t=>{const e=t.headers.get("content-type")||"";return e.includes("application/json")?await t.json().catch(()=>null):e.includes("text/")?await t.text():await t.blob().catch(()=>null)},baseHeaders={"Content-Type":"application/json"};export class API{baseURL;constructor(t){this.baseURL=t.replace(/\/+$/,"")}createURL(t){return t.startsWith("http")?t:"/"===t||""===t?this.baseURL:t.startsWith("/")?`${this.baseURL}${t}`:`${this.baseURL}/${t}`}async request(t,e,s={}){const{params:a,headers:r,body:n,signal:i}=s,o=appendParams(this.createURL(e),a),c=n instanceof FormData||t===METHODS.GET?{...r}:{...baseHeaders,...r},T=await fetch(o,{method:t,body:n?n instanceof FormData||"string"==typeof n?n:JSON.stringify(n):void 0,headers:c,signal:i}),E=await parseResponse(T);if(!T.ok)throw E;return E}GET=(t,e)=>this.request(METHODS.GET,t,e);POST=(t,e)=>this.request(METHODS.POST,t,e);PUT=(t,e)=>this.request(METHODS.PUT,t,e);DELETE=(t,e)=>this.request(METHODS.DELETE,t,e)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"preact/jsx-runtime";import{memo,forwardRef}from"preact/compat";import checkProps from"../../helpers/checkProps";const defaultProps={onClick:()=>{},disabled:!1,className:"",type:"button"},Button=forwardRef((e,t)=>{const{children:o,className:r,onClick:s,disabled:c,type:a,...p}={...defaultProps,...e};return _jsx("button",{ref:t,className:r,onClick:e=>{"button"!==a&&a||e.preventDefault(),!c&&s&&s(e)},...p,children:o})});export default memo(Button,checkProps);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"preact/jsx-runtime";import{forwardRef,memo}from"preact/compat";import checkProps from"../../helpers/checkProps";const defaultProps={altImage:null,className:"",alt:"",priority:!0,onClick:()=>{}},Image=forwardRef((r,e)=>{const{altImage:a,className:t,src:o,priority:c,onClick:s,alt:l,...m}={...defaultProps,...r};return _jsx("img",{src:o,ref:e,width:"100%",height:"100%",onClick:r=>{r.preventDefault(),s(r)},draggable:!1,onError:async()=>{e&&"current"in e&&e.current&&(e.current.src=a||"")},alt:l,className:t,fetchPriority:c?"high":"auto",loading:c?"eager":"lazy",...m})});export default memo(Image,checkProps);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"preact/jsx-runtime";import{memo}from"preact/compat";import checkProps from"../../helpers/checkProps";import{translate}from"../../translations/index";const defaultProps={onChange:()=>{},className:"",placeholder:"",type:"text",name:""},Input=e=>{const{onChange:t,className:a,placeholder:r,type:o,name:p,...s}={...defaultProps,...e};return _jsx("input",{className:a,placeholder:translate(r),type:o,name:p,onChange:e=>t(e.currentTarget.value,e),...s})};export default memo(Input,checkProps);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"preact/jsx-runtime";import checkProps from"../../helpers/checkProps";import{translate}from"../../translations/index";import{forwardRef,memo,useMemo}from"preact/compat";const defaultProps={text:"",data:{},html:!1,className:"",tag:"span",onClick:()=>{}},Text=forwardRef((e,t)=>{const{text:r,data:a,html:s,className:o,tag:m,onClick:l,...n}={...defaultProps,...e},c=useMemo(()=>translate(r,a),[r,JSON.stringify(a)]);return _jsx(m,s?{...n,ref:t,dangerouslySetInnerHTML:{__html:c},className:o,onClick:e=>{e.preventDefault(),l(e)}}:{...n,ref:t,className:o,onClick:e=>{e.preventDefault(),l(e)},children:c})});export default memo(Text,checkProps);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"preact/jsx-runtime";import{useEffect,useRef}from"preact/hooks";import{memo}from"preact/compat";import checkProps from"../../helpers/checkProps";import toast from"../../helpers/toast";import{translate}from"../../translations/index";const isTouchDevice=()=>"undefined"!=typeof window&&"ontouchstart"in window,styles={width:"fit-content",height:"fit-content"},Tooltip=({message:e,children:t,className:o})=>{const r=useRef(null),s=useRef(null);useEffect(()=>()=>{s.current?.(),s.current=null},[]);const n=()=>{s.current?.(),s.current=null};return _jsx("section",{className:`${styles} ${o||""}`,ref:r,onMouseEnter:t=>{isTouchDevice()||(t.stopPropagation(),t.preventDefault(),r.current&&(s.current=toast(translate(e),r.current,0)))},onMouseLeave:e=>{isTouchDevice()||(e.stopPropagation(),e.preventDefault(),n())},onClick:t=>{t.stopPropagation(),t.preventDefault(),isTouchDevice()&&(s.current?n():s.current=toast(translate(e),r.current,2e3))},children:t})};export default memo(Tooltip,checkProps);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const checkProps=(e,c)=>Array.from(new Set([...Object.keys(e),...Object.keys(c)])).every(r=>e[r]===c[r]);export default checkProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const getPath=(t,e)=>{if(t)return e.split(".").reduce((t,e)=>{if(null!=t&&e in t)return t[e]},t)},hasPath=(t,e)=>void 0!==getPath(t,e),objectPath=t=>({get:e=>getPath(t,e),has:e=>hasPath(t,e),print:()=>t});export default objectPath;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const toast=(t,e,n=1500)=>{if(!e)return;const s=e.getBoundingClientRect(),o=document.createElement("div");o.textContent=t,o.className="cursor-toast",o.style.opacity="0",o.style.position="fixed",o.style.top="0",o.style.left="0",o.style.transform="translateY(0)",o.style.transition="opacity 0.3s ease, transform 0.3s ease",document.body.appendChild(o),requestAnimationFrame(()=>{const t=o.getBoundingClientRect();let e=s.top-t.height-8,n=s.left+s.width/2-t.width/2;e=Math.max(8,Math.min(e,window.innerHeight-t.height-8)),n=Math.max(8,Math.min(n,window.innerWidth-t.width-8)),Object.assign(o.style,{top:`${e}px`,left:`${n}px`,opacity:"1",transform:"translateY(-4px)"})});let i=null;const a=()=>{o.isConnected&&(o.style.opacity="0",o.style.transform="translateY(0)",setTimeout(()=>o.remove(),300))};return n>0&&(i=setTimeout(a,n)),()=>{i&&clearTimeout(i),a()}};export default toast;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEffect}from"preact/compat";const useHandleClickOutside=(e,t)=>{useEffect(()=>{const n=n=>{e.current&&(e.current.contains(n.target)||t())};return document.addEventListener("pointerdown",n,{passive:!0}),()=>{document.removeEventListener("pointerdown",n)}},[e,t])};export default useHandleClickOutside;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{signal}from"@preact/signals";const queryParamsSignal=signal({}),getParams=()=>{const a=window.location.search.slice(1),e=new URLSearchParams(a),r={};for(const[a,t]of e.entries())r[a]=t;return r};queryParamsSignal.value=getParams(),window.addEventListener("popstate",()=>{queryParamsSignal.value=getParams()});export const setQueryParams=(a,{replace:e=!1,pathname:r}={})=>{const t=new URLSearchParams;Object.entries(a).forEach(([a,e])=>{null!=e&&t.set(a,e)});const s=t.toString(),n=window.location.pathname,o=r??n,i=s?`${o}?${s}`:o;e?window.history.replaceState({},"",i):window.history.pushState({},"",i),queryParamsSignal.value=getParams()};export{queryParamsSignal as queryParams};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useLayoutEffect,useMemo,useState}from"preact/hooks";const useWindowSize=()=>{const[e,t]=useState({height:window.innerHeight,width:window.innerWidth});return useLayoutEffect(()=>{const e=()=>{t({height:window.innerHeight,width:window.innerWidth})};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),useMemo(()=>({height:e.height,width:e.width}),[e.height,e.width])};export default useWindowSize;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import toast from"../helpers/toast";const copyToClipboard=async(o="",t="Copied")=>{try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(o),!0;const e=document.createElement("textarea");e.value=o,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e),toast(t,document.body,1e3)}catch{toast("Failed to copy",document.body,1e3)}};export default copyToClipboard;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import copyToClipboard from"./copyToClipboard";import maskString from"./maskString";String.prototype.copy||(String.prototype.copy=copyToClipboard,String.prototype.mask=maskString);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const maskString=function(t=6,n="..."){if(null==this)return"";const r=String(this);if(!r)return"";if(r.length<=2*t)return r;return`${r.slice(0,t)}${n}${r.slice(-t)}`};export default maskString;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{signal}from"@preact/signals";const createStore=(e,t,a=[])=>{const r=signal({...t});try{const t=localStorage.getItem(e);t&&(r.value={...r.value,...JSON.parse(t)})}catch{}const l=t=>{if(r.value={...r.value,...t},a.length){const t=a.reduce((e,t)=>(e[t]=r.value[t],e),{});localStorage.setItem(e,JSON.stringify(t))}},s=()=>{r.value=t,localStorage.removeItem(e)};return Object.assign(new Proxy(t,{get(e,t){switch(t){case"setState":return l;case"resetState":return s;default:return r.value[t]}},set(t,l,s){if(r.value={...r.value,[l]:s},a.includes(l)){const t=a.reduce((e,t)=>(e[t]=r.value[t],e),{});localStorage.setItem(e,JSON.stringify(t))}return!0}}),{__signal:r})};export default createStore;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{signal,computed}from"@preact/signals";import objectPath from"../helpers/objectPath";export const languages=signal({});export const language=signal(window.localStorage.getItem("language")||"en");const translations=computed(()=>objectPath(languages.value[language.value])),interpolate=(t,e)=>"string"==typeof t?t.replace(/{{\s*(\w+)\s*}}/g,(t,a)=>a in e?String(e[a]):`{{${a}}}`):JSON.stringify(t);export const initTranslations=async t=>{try{return languages.value=t,!0}catch(t){return console.error(t),!1}};export const translate=(t,e={})=>{const a=translations.value;if(!a.has(t))return t;const n=a.get(t);return Object.keys(e).length?interpolate(n,e):n};export const changeLanguage=t=>(language.value=t,window.localStorage.setItem("language",t),!0);
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gohanfromgoku/ui-kit",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsc && tsc-alias && pnpm run minify",
|
|
7
|
+
"minify": "find dist -name '*.js' -exec terser {} --compress --mangle --output {} \\;",
|
|
8
|
+
"watch": "tsc --watch"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [],
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@preact/signals": "^2.5.1",
|
|
15
|
+
"preact": "^10.28.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"terser": "^5.44.1",
|
|
19
|
+
"tsc-alias": "^1.8.16",
|
|
20
|
+
"typescript": "^5.9.3"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/**/*",
|
|
24
|
+
"types/**/*",
|
|
25
|
+
"README.md",
|
|
26
|
+
"package.json"
|
|
27
|
+
],
|
|
28
|
+
"exports": {
|
|
29
|
+
"./prototypes": {
|
|
30
|
+
"import": "./dist/prototypes/index.js",
|
|
31
|
+
"types": "./types/prototypes/index.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./api": {
|
|
34
|
+
"import": "./dist/api/index.js",
|
|
35
|
+
"types": "./types/api/index.d.ts"
|
|
36
|
+
},
|
|
37
|
+
"./Button": {
|
|
38
|
+
"import": "./dist/components/Button/index.js",
|
|
39
|
+
"types": "./types/components/Button/index.d.ts"
|
|
40
|
+
},
|
|
41
|
+
"./Image": {
|
|
42
|
+
"import": "./dist/components/Image/index.js",
|
|
43
|
+
"types": "./types/components/Image/index.d.ts"
|
|
44
|
+
},
|
|
45
|
+
"./Input": {
|
|
46
|
+
"import": "./dist/components/Input/index.js",
|
|
47
|
+
"types": "./types/components/Input/index.d.ts"
|
|
48
|
+
},
|
|
49
|
+
"./Text": {
|
|
50
|
+
"import": "./dist/components/Text/index.js",
|
|
51
|
+
"types": "./types/components/Text/index.d.ts"
|
|
52
|
+
},
|
|
53
|
+
"./Tooltip": {
|
|
54
|
+
"import": "./dist/components/Tooltip/index.js",
|
|
55
|
+
"types": "./types/components/Tooltip/index.d.ts"
|
|
56
|
+
},
|
|
57
|
+
"./checkProps": {
|
|
58
|
+
"import": "./dist/helpers/checkProps.js",
|
|
59
|
+
"types": "./types/helpers/checkProps.d.ts"
|
|
60
|
+
},
|
|
61
|
+
"./objectPath": {
|
|
62
|
+
"import": "./dist/helpers/objectPath.js",
|
|
63
|
+
"types": "./types/helpers/objectPath.d.ts"
|
|
64
|
+
},
|
|
65
|
+
"./toast": {
|
|
66
|
+
"import": "./dist/helpers/toast.js",
|
|
67
|
+
"types": "./types/helpers/toast.d.ts"
|
|
68
|
+
},
|
|
69
|
+
"./useHandleClickOutside": {
|
|
70
|
+
"import": "./dist/hooks/useHandleClickOutside.js",
|
|
71
|
+
"types": "./types/hooks/useHandleClickOutside.d.ts"
|
|
72
|
+
},
|
|
73
|
+
"./useQueryParams": {
|
|
74
|
+
"import": "./dist/hooks/useQueryParams.js",
|
|
75
|
+
"types": "./types/hooks/useQueryParams.d.ts"
|
|
76
|
+
},
|
|
77
|
+
"./useWindowSize": {
|
|
78
|
+
"import": "./dist/hooks/useWindowSize.js",
|
|
79
|
+
"types": "./types/hooks/useWindowSize.d.ts"
|
|
80
|
+
},
|
|
81
|
+
"./storage": {
|
|
82
|
+
"import": "./dist/storage/index.js",
|
|
83
|
+
"types": "./types/storage/index.d.ts"
|
|
84
|
+
},
|
|
85
|
+
"./translations": {
|
|
86
|
+
"import": "./dist/translations/index.js",
|
|
87
|
+
"types": "./types/translations/index.d.ts"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const METHODS: {
|
|
2
|
+
readonly GET: "GET";
|
|
3
|
+
readonly POST: "POST";
|
|
4
|
+
readonly PUT: "PUT";
|
|
5
|
+
readonly DELETE: "DELETE";
|
|
6
|
+
};
|
|
7
|
+
export type RequestBody = Record<string, any> | string | FormData | Blob | ArrayBuffer | Uint8Array | null | undefined;
|
|
8
|
+
export interface RequestOptions {
|
|
9
|
+
params?: Record<string, any>;
|
|
10
|
+
headers?: Record<string, any>;
|
|
11
|
+
body?: RequestBody;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}
|
|
14
|
+
export declare class API {
|
|
15
|
+
private baseURL;
|
|
16
|
+
constructor(baseURL: string);
|
|
17
|
+
private createURL;
|
|
18
|
+
private request;
|
|
19
|
+
GET: <T = any>(endpoint: string, opts?: RequestOptions) => Promise<T>;
|
|
20
|
+
POST: <T = any>(endpoint: string, opts?: RequestOptions) => Promise<T>;
|
|
21
|
+
PUT: <T = any>(endpoint: string, opts?: RequestOptions) => Promise<T>;
|
|
22
|
+
DELETE: <T = any>(endpoint: string, opts?: RequestOptions) => Promise<T>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes } from "preact";
|
|
2
|
+
import { type ReactNode, type Ref } from "preact/compat";
|
|
3
|
+
type ClickEvent = MouseEvent | TouchEvent;
|
|
4
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
onClick?: (event: ClickEvent) => void;
|
|
9
|
+
type?: "button" | "submit" | "reset";
|
|
10
|
+
}
|
|
11
|
+
declare const _default: import("preact").FunctionComponent<import("preact/compat").PropsWithoutRef<ButtonProps> & {
|
|
12
|
+
ref?: Ref<HTMLButtonElement> | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ImgHTMLAttributes } from "preact";
|
|
2
|
+
type ClickEvent = MouseEvent | TouchEvent;
|
|
3
|
+
export interface ImageProps extends ImgHTMLAttributes<HTMLImageElement> {
|
|
4
|
+
src: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
alt?: string;
|
|
7
|
+
altImage?: null | string;
|
|
8
|
+
priority?: true | false;
|
|
9
|
+
onClick?: (event: ClickEvent) => void;
|
|
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;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, TargetedEvent } from "preact";
|
|
2
|
+
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> {
|
|
3
|
+
placeholder?: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
onChange?: (value: string, event: TargetedEvent<HTMLInputElement, Event>) => void;
|
|
7
|
+
name?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: (props: InputProps) => import("preact").JSX.Element;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface TextProps {
|
|
2
|
+
text: string;
|
|
3
|
+
data?: Record<string, string | number>;
|
|
4
|
+
html?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
tag?: any;
|
|
7
|
+
onClick?: (event: any) => void;
|
|
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;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type QueryParams = Record<string, string>;
|
|
2
|
+
type SetQueryParams = (updates: Record<string, any>, options?: {
|
|
3
|
+
replace?: boolean;
|
|
4
|
+
pathname?: string;
|
|
5
|
+
}) => void;
|
|
6
|
+
declare const queryParamsSignal: import("@preact/signals").Signal<QueryParams>;
|
|
7
|
+
export declare const setQueryParams: SetQueryParams;
|
|
8
|
+
export { queryParamsSignal as queryParams };
|
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
4
|
+
resetState: () => void;
|
|
5
|
+
} & {
|
|
6
|
+
__signal: import("@preact/signals").Signal<T>;
|
|
7
|
+
};
|
|
8
|
+
export default createStore;
|
|
@@ -0,0 +1,5 @@
|
|
|
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;
|