reykit 1.0.172 → 1.0.174

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/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Link as W5, useLocation as ej, useNavigate as tj } from "react-router-dom";
2
2
  import * as S from "react";
3
- import lm, { useState as Yl, useEffect as nj, createElement as mM, useLayoutEffect as aj, useMemo as oj, Fragment as lj, createContext as ij, useContext as rj, isValidElement as sj } from "react";
3
+ import lm, { useState as Yl, useEffect as nj, createElement as mM, useLayoutEffect as aj, useMemo as oj, createContext as lj, useContext as ij, Fragment as rj, isValidElement as sj } from "react";
4
4
  import * as Zo from "react-dom";
5
5
  import YA from "react-dom";
6
6
  import { cva as Pl } from "class-variance-authority";
@@ -49026,10 +49026,40 @@ const C4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49026
49026
  usePopupBox: T4,
49027
49027
  useSidebar: ax
49028
49028
  }, Symbol.toStringTag, { value: "Module" }));
49029
+ function O4(a) {
49030
+ const i = lj(null);
49031
+ return [({ children: m }) => {
49032
+ const [g, y] = Yl(!1), b = {
49033
+ isCovering: g,
49034
+ setIsCovering: y
49035
+ };
49036
+ return /* @__PURE__ */ E.jsxs(i, { value: b, children: [
49037
+ m,
49038
+ /* @__PURE__ */ E.jsx("div", { className: oe(
49039
+ "fixed inset-0 z-50 flex justify-center items-center transition bg-black/5",
49040
+ g ? "opacity-100" : "opacity-0 pointer-events-none"
49041
+ ), children: g && a })
49042
+ ] });
49043
+ }, () => {
49044
+ const m = ij(i);
49045
+ if (!m) throw new Error("must be used within cover component");
49046
+ return {
49047
+ ...m,
49048
+ withCover: async (g, ...y) => {
49049
+ m.setIsCovering(!0);
49050
+ try {
49051
+ return await g(...y);
49052
+ } finally {
49053
+ m.setIsCovering(!1);
49054
+ }
49055
+ }
49056
+ };
49057
+ }];
49058
+ }
49029
49059
  function JI({ dict: a }) {
49030
49060
  const { pathname: i } = ej(), u = a[i] || [];
49031
49061
  return /* @__PURE__ */ E.jsx(o4, { children: /* @__PURE__ */ E.jsx(l4, { children: u.map(
49032
- (d, m) => /* @__PURE__ */ E.jsxs(lj, { children: [
49062
+ (d, m) => /* @__PURE__ */ E.jsxs(rj, { children: [
49033
49063
  /* @__PURE__ */ E.jsx(i4, { children: d.href ? /* @__PURE__ */ E.jsx(r4, { href: d.href, children: d.label }) : /* @__PURE__ */ E.jsx(s4, { children: d.label }) }),
49034
49064
  m < u.length - 1 && /* @__PURE__ */ E.jsx(u4, { className: "-mx-1 md:mx-0" })
49035
49065
  ] }, m)
@@ -49062,32 +49092,9 @@ function ek({
49062
49092
  };
49063
49093
  return /* @__PURE__ */ E.jsx("form", { onSubmit: g, ...d });
49064
49094
  }
49065
- const O4 = ij(null);
49066
- function tk({ children: a }) {
49067
- const [i, u] = Yl(!1), d = {
49068
- isLoading: i,
49069
- setIsLoading: u
49070
- };
49071
- return /* @__PURE__ */ E.jsxs(O4, { value: d, children: [
49072
- a,
49073
- i && /* @__PURE__ */ E.jsx("div", { className: "fixed inset-0 z-50 flex justify-center items-center bg-black/5", children: /* @__PURE__ */ E.jsx("div", { className: "flex justify-center items-center size-10 rounded-full bg-white shadow-md", children: /* @__PURE__ */ E.jsx(UC, { role: "status", "aria-label": "Loading", className: "size-full animate-spin" }) }) })
49074
- ] });
49075
- }
49076
- function nk() {
49077
- const a = rj(O4);
49078
- if (!a) throw new Error("must be used within Loading component");
49079
- return {
49080
- ...a,
49081
- withLoading: async (i, ...u) => {
49082
- a.setIsLoading(!0);
49083
- try {
49084
- return await i(...u);
49085
- } finally {
49086
- a.setIsLoading(!1);
49087
- }
49088
- }
49089
- };
49090
- }
49095
+ const [tk, nk] = O4(
49096
+ /* @__PURE__ */ E.jsx("div", { className: "flex justify-center items-center size-10 rounded-full bg-white shadow-md", children: /* @__PURE__ */ E.jsx(UC, { role: "status", "aria-label": "Loading", className: "size-full animate-spin" }) })
49097
+ );
49091
49098
  function ak({
49092
49099
  children: a,
49093
49100
  position: i = "top-center",
@@ -49925,6 +49932,7 @@ const fk = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49925
49932
  Loading: tk,
49926
49933
  Notice: ak,
49927
49934
  Table: ik,
49935
+ createCover: O4,
49928
49936
  notice: jj,
49929
49937
  ui: C4,
49930
49938
  useLoading: nk
@@ -0,0 +1,24 @@
1
+ import { ReactNode } from 'react';
2
+ export type CoverContextParams = {
3
+ isCovering: boolean;
4
+ setIsCovering: (value: boolean) => void;
5
+ };
6
+ /**
7
+ * Create cover component and hook.
8
+ *
9
+ * @param display - Cover display content.
10
+ * @returns Cover component and hook.
11
+ * @example
12
+ * const [Cover, useCover] = createCover('content')
13
+ * const { withCover } = useCover()
14
+ * <Cover>
15
+ * <button onClick={() => withCover(console, 'test')}>Button</button>
16
+ * </Cover>
17
+ */
18
+ export declare function createCover(display: ReactNode): [({ children }: {
19
+ children: ReactNode;
20
+ }) => import("react/jsx-runtime").JSX.Element, () => {
21
+ withCover: <T, Args extends any[]>(fn: (...args: Args) => T | Promise<T>, ...args: Args) => Promise<T>;
22
+ isCovering: boolean;
23
+ setIsCovering: (value: boolean) => void;
24
+ }];
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @Time : 2026-06-11
3
+ * @Author : Rey
4
+ * @Contact : reyxbo@163.com
5
+ * @Explain : Loading components.
6
+ */
7
+ export declare const Loading: ({ children }: {
8
+ children: import('react').ReactNode;
9
+ }) => import("react/jsx-runtime").JSX.Element, useLoading: () => {
10
+ withCover: <T, Args extends any[]>(fn: (...args: Args) => T | Promise<T>, ...args: Args) => Promise<T>;
11
+ isCovering: boolean;
12
+ setIsCovering: (value: boolean) => void;
13
+ };
@@ -6,11 +6,11 @@
6
6
  */
7
7
  import * as ui from './ui';
8
8
  export { ui };
9
+ export { type CoverContextParams, createCover } from './Base';
9
10
  export { type BreadcrumbDict, Breadcrumb } from './Breadcrumb';
10
11
  export { CycleButton } from './Button';
11
12
  export { Form } from './Form';
12
- export { Loading } from './Loading/Loading';
13
- export { useLoading } from './Loading/uesLoading';
13
+ export { Loading, useLoading } from './Loading';
14
14
  export { Notice, notice } from './Notice';
15
15
  export { type HeaderOption, type SearchOption, type ButtonOption, type OptionName, type RowOption, type SelectRowsOption, Table } from './Table';
16
16
  export { IconToggle } from './Toggle';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reykit",
3
- "version": "1.0.172",
3
+ "version": "1.0.174",
4
4
  "description": "Kit method set.",
5
5
  "author": "reyxbo",
6
6
  "keywords": [
@@ -1,15 +0,0 @@
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 {};
@@ -1,19 +0,0 @@
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
- };