reykit 1.0.105 → 1.0.106

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.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @Time : 2026-03-11
3
+ * @Author : Rey
4
+ * @Contact : reyxbo@163.com
5
+ * @Explain : Base methods.
6
+ */
7
+ export type Key<T> = keyof T;
8
+ export type Value<T> = T[keyof T];
9
+ export type KeyByValue<T, V> = {
10
+ [K in keyof T]: T[K] extends V ? K : never;
11
+ }[keyof T];
12
+ /**
13
+ * Start debug CSS style, need to import 'reykit/debug' CSS style first.
14
+ */
15
+ export declare function debugCss(): void;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @Time : 2026-03-27
3
+ * @Author : Rey
4
+ * @Contact : reyxbo@163.com
5
+ * @Explain : Breadcrumb components.
6
+ */
7
+ export type BreadcrumbDict = Record<string, {
8
+ label: string;
9
+ href?: string;
10
+ }[]>;
11
+ /**
12
+ * Breadcrumb components.
13
+ *
14
+ * @param props.dict - Breadcrumb data dictionary.
15
+ */
16
+ export declare function Breadcrumb({ dict }: {
17
+ dict: BreadcrumbDict;
18
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { ReactNode, ComponentProps, MouseEvent } from 'react';
2
+ /**
3
+ * Button component of cycle display children.
4
+ *
5
+ * @param props.childrens - Children array.
6
+ * @param props.handleCycle - Handle cycle.
7
+ */
8
+ export declare function CycleButton({ childrens, handleCycle, onClick, ...props }: {
9
+ childrens: ReactNode[];
10
+ handleCycle: (index: number) => any | Promise<any>;
11
+ data: {
12
+ children: ReactNode;
13
+ handleClick: (event: MouseEvent<HTMLButtonElement>) => void;
14
+ }[];
15
+ } & ComponentProps<'button'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { ComponentProps } from 'react';
2
+ /**
3
+ * Form component of prevent access link.
4
+ *
5
+ * @param props.handleFormData - Handle submited form data.
6
+ * @param props.link - Access router link.
7
+ */
8
+ export declare function Form({ handleFormData, link, onSubmit, ...props }: {
9
+ handleFormData?: (formData: FormData) => any | Promise<any>;
10
+ link?: string;
11
+ } & ComponentProps<'form'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ type LoadingContextParams = {
3
+ isLoading: boolean;
4
+ setIsLoading: (value: boolean) => void;
5
+ };
6
+ export declare const LoadingContext: import('react').Context<LoadingContextParams | null>;
7
+ /**
8
+ * Loading component of display rotate icon.
9
+ *
10
+ * @param props.children - The node tree of the mounting context.
11
+ */
12
+ export declare function Loading({ children }: {
13
+ children: ReactNode;
14
+ }): import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @Time : 2026-03-25
3
+ * @Author : Rey
4
+ * @Contact : reyxbo@163.com
5
+ * @Explain : Hook of loading components.
6
+ */
7
+ /**
8
+ * Hook of get loading component status parameters.
9
+ *
10
+ * @returns Status parameters.
11
+ * - `isLoading` : Loading status.
12
+ * - `setIsLoading` : Set loading status.
13
+ * - `withLoading` : Execute a function in the context.
14
+ */
15
+ export declare function useLoading(): {
16
+ withLoading: <T, Args extends any[]>(fn: (...args: Args) => T | Promise<T>, ...args: Args) => Promise<T>;
17
+ isLoading: boolean;
18
+ setIsLoading: (value: boolean) => void;
19
+ };
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ import { ToasterProps } from 'sonner';
3
+ export { toast as notice } from 'sonner';
4
+ /**
5
+ * Top banner notice component.
6
+ *
7
+ * @param props.children - The node tree of the mounting context.
8
+ */
9
+ export declare function Notice({ children, position, richColors, toastOptions, ...props }: {
10
+ children: ReactNode;
11
+ } & ToasterProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { ReactNode, ComponentProps } from 'react';
2
+ /**
3
+ * Toggle component of with icon.
4
+ *
5
+ * @param props.openIcon - Open icon.
6
+ * @param props.closeIcon - Close icon.
7
+ * @param props.tooltip - Tooltip text.
8
+ * @param props.tooltipSide - Tooltip text popup side.
9
+ * @param props.rotate - Whether to use rotating icon animation.
10
+ * @param props.open - Open state value.
11
+ * @param props.onChangeOpen - Open callback function.
12
+ * @param props.defaultOpen - Default open state.
13
+ */
14
+ export declare function IconToggle({ openIcon, closeIcon, tooltip, tooltipSide, rotate, open, onChangeOpen, defaultOpen, onClick, className, ...props }: {
15
+ openIcon: ReactNode;
16
+ closeIcon: ReactNode;
17
+ tooltip?: string;
18
+ tooltipSide?: 'top' | 'bottom' | 'left' | 'right';
19
+ rotate?: boolean;
20
+ open?: boolean;
21
+ onChangeOpen?: (nextOpen: boolean) => any | Promise<any>;
22
+ defaultOpen?: boolean;
23
+ } & ComponentProps<'button'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @Time : 2026-03-11
3
+ * @Author : Rey
4
+ * @Contact : reyxbo@163.com
5
+ * @Explain : Component index file.
6
+ */
7
+ export { Breadcrumb } from './Breadcrumb';
8
+ export { CycleButton } from './Button';
9
+ export { Form } from './Form';
10
+ export { Loading } from './Loading/Loading';
11
+ export { useLoading } from './Loading/uesLoading';
12
+ export { Notice, notice } from './Notice';
13
+ export { IconToggle } from './Toggle';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @Time : 2026-03-17
3
+ * @Author : Rey
4
+ * @Contact : reyxbo@163.com
5
+ * @Explain : Data methods.
6
+ */
7
+ export declare function range(stop: number): Generator<number>;
8
+ export declare function range(start: number, stop: number, step?: number): Generator<number>;
9
+ export declare function rangeArr(stop: number): number[];
10
+ export declare function rangeArr(start: number, stop: number, step?: number): number[];
@@ -0,0 +1,19 @@
1
+ import * as component from './components';
2
+ import * as base from './base';
3
+ import * as data from './data';
4
+ import * as net from './net';
5
+ import * as re from './re';
6
+ import * as react from './react';
7
+ import * as twc from './twc';
8
+ import * as window from './window';
9
+ declare const _default: {
10
+ component: typeof component;
11
+ base: typeof base;
12
+ data: typeof data;
13
+ net: typeof net;
14
+ re: typeof re;
15
+ react: typeof react;
16
+ twc: typeof twc;
17
+ window: typeof window;
18
+ };
19
+ export default _default;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @Time : 2026-03-11
3
+ * @Author : Rey
4
+ * @Contact : reyxbo@163.com
5
+ * @Explain : Network methods.
6
+ */
7
+ /**
8
+ * Send request.
9
+ *
10
+ * @param url - Request URL.
11
+ * @param option - Request option.
12
+ * @param option.params - Request URL add parameters.
13
+ * @param option.body - Request body data.
14
+ * - `URLSearchParams` : Form data. Automatic set `Content-Type` to `application/x-www-form-urlencoded`.
15
+ * - `FormData` : Multi form data. Automatic set `Content-Type` to `multipart/form-data`.
16
+ * - `File` : `file` item of multi form data. Automatic set `Content-Type` to attribute `type` value.
17
+ * - `Blob` : Bytes data. Automatic set `Content-Type` to attribute `type` value.
18
+ * - `Record<string, any> | string` : JSON data. Automatic set `Content-Type` to `application/json`.
19
+ * @param option.headers - Request header data.
20
+ * @param option.method - Request method.
21
+ * - `undefined` : Automatic judge. When parameter `data` not has value, then is `get`, otherwise is `post`.
22
+ * @param option.check - Whether to throw an error if the response is not in the 200–299 range.
23
+ * Note: `Error.message` is response body string, `Error.cause` is `Response` instance.
24
+ * - `undefined` : False.
25
+ */
26
+ export declare function request(url: string, option?: {
27
+ params?: Record<string, string | number | boolean>;
28
+ body?: URLSearchParams | File | FormData | Blob | Record<string, any> | string;
29
+ headers?: Record<string, string | number | boolean>;
30
+ method?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'head';
31
+ check?: boolean;
32
+ }): Promise<Response>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @Time : 2026-03-11
3
+ * @Author : Rey
4
+ * @Contact : reyxbo@163.com
5
+ * @Explain : Regular expression methods.
6
+ */
7
+ export declare const PATTERN_IP: RegExp;
8
+ export declare const PATTERN_URL: RegExp;
9
+ export declare const PATTERN_EMAIL: RegExp;
10
+ export declare const PATTERN_PHONE: RegExp;
11
+ export declare const PATTERN_CN: RegExp;
@@ -0,0 +1,46 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * Render react note.
4
+ * Note: `react` and `react-dom` packages version must be `19.2.4`.
5
+ *
6
+ * @param app - React note.
7
+ * @param elementId - Render HTML element ID.
8
+ */
9
+ export declare function renderReact(app: ReactNode, elementId?: string): void;
10
+ /**
11
+ * Hook of toggle.
12
+ *
13
+ * @param array - Array.
14
+ * @param loop - Whether to loop count.
15
+ * @returns Returns a stateful open value, and a function to automatic count it.
16
+ */
17
+ export declare function useOpen(defaultOpen?: boolean): [boolean, (open?: boolean) => void];
18
+ /**
19
+ * Hook of count number.
20
+ *
21
+ * @param start - Start number.
22
+ * @param step - Count step.
23
+ * @param stop - Stop number.
24
+ * @param loop - Whether to loop count.
25
+ * @returns Returns a stateful count value, and a function to automatic count it.
26
+ */
27
+ export declare function useCount(start?: number, step?: number, stop?: number, loop?: boolean): [number, () => void];
28
+ /**
29
+ * Hook of count array index.
30
+ *
31
+ * @param array - Array.
32
+ * @param loop - Whether to loop count.
33
+ * @returns Returns a stateful index value, and a function to automatic count it.
34
+ */
35
+ export declare function useIndex(array: any[], loop?: boolean): [number, () => void];
36
+ /**
37
+ * Force update render.
38
+ */
39
+ export declare function useRender(): () => void;
40
+ /**
41
+ * Whether is mobile.
42
+ *
43
+ * @returns Judgement.
44
+ */
45
+ export declare function useIsMobile(): boolean;
46
+ export declare function useValueByMobile<Value, MobileValue>(value: Value, mobileValue: MobileValue): Value | MobileValue;
@@ -0,0 +1,8 @@
1
+ import { ClassValue } from 'clsx';
2
+ /**
3
+ * Merge TailwindCSS class style string array.
4
+ *
5
+ * @param inputs - TailwindCSS class style string array.
6
+ * @returns Merged string.
7
+ */
8
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -0,0 +1,67 @@
1
+ import { Key, Value, KeyByValue } from './base';
2
+ /**
3
+ * Manage local storage data.
4
+ */
5
+ export declare class Storager<Data extends Record<string, any>> {
6
+ name: string;
7
+ /**
8
+ * Build instance.
9
+ *
10
+ * @param name - Local storage key.
11
+ */
12
+ constructor(name: string);
13
+ /**
14
+ * Get all data.
15
+ *
16
+ * @returns All data.
17
+ */
18
+ get data(): Data;
19
+ /**
20
+ * Get all keys.
21
+ *
22
+ * @returns All keys.
23
+ */
24
+ get keys(): Key<Data>[];
25
+ /**
26
+ * Get all values.
27
+ *
28
+ * @returns All values.
29
+ */
30
+ get values(): Value<Data>[];
31
+ /**
32
+ * Update data.
33
+ *
34
+ * @param data - New data.
35
+ */
36
+ update(data: Partial<Data>): void;
37
+ /**
38
+ * Clear data.
39
+ */
40
+ clear(): void;
41
+ /**
42
+ * Get a item value.
43
+ *
44
+ * @param key - Item key.
45
+ * @returns Item value.
46
+ */
47
+ get<K extends keyof Data>(key: K): Data[K];
48
+ /**
49
+ * Set a item.
50
+ *
51
+ * @param key - Item key.
52
+ * @param value - Item value.
53
+ */
54
+ set<K extends keyof Data>(key: K, value: Data[K]): void;
55
+ /**
56
+ * Delete a item.
57
+ *
58
+ * @param key - Item key.
59
+ */
60
+ del<K extends keyof Data>(key: K): void;
61
+ /**
62
+ * Toggle boolean value.
63
+ *
64
+ * @param key - Item key.
65
+ */
66
+ toggle<K extends KeyByValue<Data, boolean>>(key: K): void;
67
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reykit",
3
- "version": "1.0.105",
3
+ "version": "1.0.106",
4
4
  "description": "Kit method set.",
5
5
  "author": "reyxbo",
6
6
  "keywords": [
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "type": "module",
24
24
  "main": "./dist/index.js",
25
- "types": "./dist/index.d.ts",
25
+ "types": "./dist/src/index.d.ts",
26
26
  "exports": {
27
27
  ".": {
28
28
  "default": "./dist/index.js"
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { }