@rokku-x/react-hook-loading-spinner 0.2.1 → 0.2.5
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 -21
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.esm.js +93 -121
- package/package.json +1 -1
- package/dist/hooks/ssrLoading.d.ts +0 -9
package/README.md
CHANGED
|
@@ -20,7 +20,6 @@ npm install @rokku-x/react-hook-loading-spinner
|
|
|
20
20
|
- 📡 **Event System** - Subscribe to loading state changes
|
|
21
21
|
- ♿ **Accessibility** - Built-in inert attribute and scroll prevention
|
|
22
22
|
- 📱 **Zero Dependencies** - Only requires React and Zustand
|
|
23
|
-
- 🌐 **SSR-Compatible** - Hooks work in SSR; use `ssrLoading` helper in Server Components
|
|
24
23
|
|
|
25
24
|
## Bundle Size
|
|
26
25
|
|
|
@@ -397,28 +396,9 @@ function App() {
|
|
|
397
396
|
loadingComponentScale={1.5}
|
|
398
397
|
/>
|
|
399
398
|
</>
|
|
400
|
-
|
|
401
|
-
### SSR Usage
|
|
402
|
-
|
|
403
|
-
For Server Components, use the SSR-safe helper instead of the client hook:
|
|
404
|
-
|
|
405
|
-
```tsx
|
|
406
|
-
import { ssrLoading } from '@rokku-x/react-hook-loading-spinner';
|
|
407
|
-
|
|
408
|
-
export default function ServerComponent() {
|
|
409
|
-
const { startLoading, stopLoading, isLoading } = ssrLoading();
|
|
410
|
-
|
|
411
|
-
startLoading();
|
|
412
|
-
// ...run your server-side work
|
|
413
|
-
stopLoading();
|
|
414
|
-
|
|
415
|
-
return <div>{isLoading ? 'Loading…' : 'Done'}</div>;
|
|
416
|
-
}
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
For Client Components, continue using `useLoading` as shown above.
|
|
420
399
|
);
|
|
421
400
|
}
|
|
401
|
+
}
|
|
422
402
|
```
|
|
423
403
|
|
|
424
404
|
### Example 7: Fade Animation
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),L=require("react/jsx-runtime"),O=require("react-dom"),v=e=>{let t;const n=new Set,o=(a,l)=>{const d=typeof a=="function"?a(t):a;if(!Object.is(d,t)){const m=t;t=l??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(p=>p(t,m))}},i=()=>t,f={setState:o,getState:i,getInitialState:()=>b,subscribe:a=>(n.add(a),()=>n.delete(a))},b=t=e(o,i,f);return f},A=(e=>e?v(e):v),R=e=>e;function $(e,t=R){const n=s.useSyncExternalStore(e.subscribe,s.useCallback(()=>t(e.getState()),[e,t]),s.useCallback(()=>t(e.getInitialState()),[e,t]));return s.useDebugValue(n),n}const x=e=>{const t=A(e),n=o=>$(t,o);return Object.assign(n,t),n},F=(e=>e?x(e):x);class y extends EventTarget{constructor(){super(...arguments),this.controller=new AbortController}on(t,n){return this.addEventListener(t,o=>n(o.detail),{signal:this.controller.signal}),this}once(t,n){return this.addEventListener(t,o=>n(o.detail),{signal:this.controller.signal,once:!0}),this}emit(t,n){return this.dispatchEvent(new CustomEvent(t,{detail:n}))}removeAllListeners(){this.controller.abort(),this.controller=new AbortController}}const g=new y,C=F()((e,t)=>({loadingCount:0,overrideState:null,localCounters:{},isLoading(){return t().overrideState??t().loadingCount>0},actions:{isGlobalLoading(){return t().isLoading()},startLoading:n=>{const o=t().isLoading();e(r=>({loadingCount:r.loadingCount+1})),n&&e(r=>({localCounters:{...r.localCounters,[n]:(r.localCounters[n]??0)+1}}));const i=t().isLoading();i&&!o&&g.emit("start",null),g.emit("change",{isLoading:i,isOverrideState:t().overrideState!==null})},stopLoading:n=>{const o=t().isLoading(),i=n?t().localCounters[n]??0:0;n&&i>0&&e(u=>({loadingCount:Math.max(0,u.loadingCount-1),localCounters:{...u.localCounters,[n]:Math.max(0,u.localCounters[n]-1)}}));const r=t().isLoading();!r&&o&&g.emit("stop",null),g.emit("change",{isLoading:r,isOverrideState:t().overrideState!==null})},overrideLoading:n=>{const o=t().isLoading();e({overrideState:n});const i=t().isLoading();i&&!o?g.emit("start",null):!i&&o&&g.emit("stop",null),g.emit("change",{isLoading:i,isOverrideState:n!==null})},getLocalCounter:n=>t().localCounters[n]??0,isLocalLoading:n=>(t().localCounters[n]??0)>0}}));function w(){const e=s.useId(),{actions:t}=C(r=>r),n=()=>{t.startLoading(e)},o=()=>{t.isLocalLoading(e)&&t.stopLoading(e)},i=async r=>{n();try{return await r}finally{o()}};return{overrideLoading:t.overrideLoading,startLoading:n,stopLoading:o,get isLocalLoading(){return t.isLocalLoading(e)},asyncUseLoading:i,get isLoading(){return t.isGlobalLoading()}}}const c={Spin:"spin",FadeInOut:"fadeInOut",None:"none"},k=({scale:e=1,animationType:t=c.Spin,animationDuration:n,children:o,style:i,className:r,id:u,prefix:f})=>{const b=t,a=t===c.Spin?1:t===c.FadeInOut?2:0,l=n||a,d=t===c.Spin?"linear":t===c.FadeInOut?"ease-in-out":"linear",m=t===c.None?"none":`${f}-${b} ${l}s ${d} infinite`;return L.jsx("div",{style:{animation:m,...e!==1?{zoom:e}:{},...i},className:r,id:u,children:o})},E=e=>L.jsx("div",{id:"loading-circle",style:{width:"90px",height:"90px",border:"15px solid #f3f3f3",borderTop:"15px solid #009b4bff",borderRadius:"50%",boxSizing:"border-box"},...e}),j=e=>L.jsx("div",{style:{padding:"20px",fontSize:"25px",color:"#333",fontFamily:"system-ui, sans-serif"},...e,children:"Please wait..."});function M({loadingComponent:e,loadingComponentScale:t=1,animationType:n=c.Spin,animationDuration:o,wrapperStyle:i,wrapperClassName:r,wrapperId:u,animationWrapperStyle:f,animationWrapperClassName:b,animationWrapperId:a}){e=e||(n===c.Spin?E:j);const l=s.useRef(Math.random().toString(36).substring(2,6).replace(/[0-9]/g,"")),{loadingCount:d,overrideState:m}=C(I=>I),p=m??d>0,S=s.useRef(null);s.useEffect(()=>{p?(S.current?.showModal(),document.body.setAttribute("inert","")):(S.current?.close(),document.body.removeAttribute("inert"))},[p]);const h=u||"loading-wrapper-"+l.current;return p?O.createPortal(L.jsxs(L.Fragment,{children:[L.jsx("style",{children:`
|
|
2
2
|
dialog#${h}[open] {
|
|
3
3
|
display: flex !important;
|
|
4
4
|
justify-content: center;
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
body {
|
|
23
23
|
scrollbar-gutter: stable;
|
|
24
24
|
}
|
|
25
|
-
`}),L.jsx("dialog",{ref:S,style:{border:"none",padding:0,backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(2px)",...
|
|
25
|
+
`}),L.jsx("dialog",{ref:S,style:{border:"none",padding:0,backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(2px)",...i},className:r,id:h,children:L.jsx(k,{scale:t,animationType:n,animationDuration:o,style:f,className:b,id:a,prefix:l.current,children:s.isValidElement(e)?e:s.createElement(e)})})]}),document.body):null}function N({isLoading:e=!1}){const{startLoading:t,stopLoading:n}=w();return s.useEffect(()=>(e?t():n(),()=>{e&&n()}),[e]),null}exports.AnimationType=c;exports.EventEmitter=y;exports.Loading=N;exports.LoadingCircle=E;exports.LoadingPleaseWait=j;exports.LoadingRenderer=M;exports.loadingEventTarget=g;exports.useLoading=w;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { default as useLoading } from './hooks/useLoading';
|
|
2
|
-
export { default as ssrLoading } from './hooks/ssrLoading';
|
|
3
2
|
export { LoadingCircle, LoadingPleaseWait, AnimationType } from './components/LoadingRenderer';
|
|
4
3
|
export type { AnimationType as AnimationTypeType } from './components/LoadingRenderer';
|
|
5
4
|
export { default as Loading } from './components/Loading';
|
package/dist/index.esm.js
CHANGED
|
@@ -1,60 +1,59 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import L, { useId as E, useRef as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const x = (n) => {
|
|
2
|
+
import L, { useId as E, useRef as v, useEffect as C } from "react";
|
|
3
|
+
import { jsx as f, jsxs as O, Fragment as $ } from "react/jsx-runtime";
|
|
4
|
+
import { createPortal as j } from "react-dom";
|
|
5
|
+
const y = (n) => {
|
|
7
6
|
let t;
|
|
8
|
-
const
|
|
9
|
-
const l = typeof
|
|
7
|
+
const e = /* @__PURE__ */ new Set(), o = (s, a) => {
|
|
8
|
+
const l = typeof s == "function" ? s(t) : s;
|
|
10
9
|
if (!Object.is(l, t)) {
|
|
11
|
-
const
|
|
12
|
-
t =
|
|
10
|
+
const m = t;
|
|
11
|
+
t = a ?? (typeof l != "object" || l === null) ? l : Object.assign({}, t, l), e.forEach((p) => p(t, m));
|
|
13
12
|
}
|
|
14
|
-
},
|
|
13
|
+
}, i = () => t, g = { setState: o, getState: i, getInitialState: () => b, subscribe: (s) => (e.add(s), () => e.delete(s)) }, b = t = n(o, i, g);
|
|
15
14
|
return g;
|
|
16
|
-
},
|
|
17
|
-
function
|
|
18
|
-
const
|
|
15
|
+
}, A = ((n) => n ? y(n) : y), F = (n) => n;
|
|
16
|
+
function k(n, t = F) {
|
|
17
|
+
const e = L.useSyncExternalStore(
|
|
19
18
|
n.subscribe,
|
|
20
19
|
L.useCallback(() => t(n.getState()), [n, t]),
|
|
21
20
|
L.useCallback(() => t(n.getInitialState()), [n, t])
|
|
22
21
|
);
|
|
23
|
-
return L.useDebugValue(
|
|
22
|
+
return L.useDebugValue(e), e;
|
|
24
23
|
}
|
|
25
|
-
const
|
|
26
|
-
const t =
|
|
27
|
-
return Object.assign(
|
|
28
|
-
},
|
|
29
|
-
class
|
|
24
|
+
const x = (n) => {
|
|
25
|
+
const t = A(n), e = (o) => k(t, o);
|
|
26
|
+
return Object.assign(e, t), e;
|
|
27
|
+
}, N = ((n) => n ? x(n) : x);
|
|
28
|
+
class R extends EventTarget {
|
|
30
29
|
constructor() {
|
|
31
30
|
super(...arguments), this.controller = new AbortController();
|
|
32
31
|
}
|
|
33
|
-
on(t,
|
|
32
|
+
on(t, e) {
|
|
34
33
|
return this.addEventListener(
|
|
35
34
|
t,
|
|
36
|
-
(
|
|
35
|
+
(o) => e(o.detail),
|
|
37
36
|
{ signal: this.controller.signal }
|
|
38
37
|
), this;
|
|
39
38
|
}
|
|
40
|
-
once(t,
|
|
39
|
+
once(t, e) {
|
|
41
40
|
return this.addEventListener(
|
|
42
41
|
t,
|
|
43
|
-
(
|
|
42
|
+
(o) => e(o.detail),
|
|
44
43
|
{
|
|
45
44
|
signal: this.controller.signal,
|
|
46
45
|
once: !0
|
|
47
46
|
}
|
|
48
47
|
), this;
|
|
49
48
|
}
|
|
50
|
-
emit(t,
|
|
51
|
-
return this.dispatchEvent(new CustomEvent(t, { detail:
|
|
49
|
+
emit(t, e) {
|
|
50
|
+
return this.dispatchEvent(new CustomEvent(t, { detail: e }));
|
|
52
51
|
}
|
|
53
52
|
removeAllListeners() {
|
|
54
53
|
this.controller.abort(), this.controller = new AbortController();
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
|
-
const u = new
|
|
56
|
+
const u = new R(), w = N()((n, t) => ({
|
|
58
57
|
loadingCount: 0,
|
|
59
58
|
overrideState: null,
|
|
60
59
|
localCounters: {},
|
|
@@ -65,86 +64,60 @@ const u = new M(), v = R()((n, t) => ({
|
|
|
65
64
|
isGlobalLoading() {
|
|
66
65
|
return t().isLoading();
|
|
67
66
|
},
|
|
68
|
-
startLoading: (
|
|
69
|
-
const
|
|
70
|
-
n((
|
|
67
|
+
startLoading: (e) => {
|
|
68
|
+
const o = t().isLoading();
|
|
69
|
+
n((r) => ({ loadingCount: r.loadingCount + 1 })), e && n((r) => ({
|
|
71
70
|
localCounters: {
|
|
72
|
-
...
|
|
73
|
-
[
|
|
71
|
+
...r.localCounters,
|
|
72
|
+
[e]: (r.localCounters[e] ?? 0) + 1
|
|
74
73
|
}
|
|
75
74
|
}));
|
|
76
|
-
const
|
|
77
|
-
|
|
75
|
+
const i = t().isLoading();
|
|
76
|
+
i && !o && u.emit("start", null), u.emit("change", { isLoading: i, isOverrideState: t().overrideState !== null });
|
|
78
77
|
},
|
|
79
|
-
stopLoading: (
|
|
80
|
-
const
|
|
81
|
-
|
|
78
|
+
stopLoading: (e) => {
|
|
79
|
+
const o = t().isLoading(), i = e ? t().localCounters[e] ?? 0 : 0;
|
|
80
|
+
e && i > 0 && n((d) => ({
|
|
82
81
|
loadingCount: Math.max(0, d.loadingCount - 1),
|
|
83
82
|
localCounters: {
|
|
84
83
|
...d.localCounters,
|
|
85
|
-
[
|
|
84
|
+
[e]: Math.max(0, d.localCounters[e] - 1)
|
|
86
85
|
}
|
|
87
86
|
}));
|
|
88
|
-
const i = t().isLoading();
|
|
89
|
-
!i && e && u.emit("stop", null), u.emit("change", { isLoading: i, isOverrideState: t().overrideState !== null });
|
|
90
|
-
},
|
|
91
|
-
overrideLoading: (o) => {
|
|
92
|
-
const e = t().isLoading();
|
|
93
|
-
n({ overrideState: o });
|
|
94
87
|
const r = t().isLoading();
|
|
95
|
-
|
|
88
|
+
!r && o && u.emit("stop", null), u.emit("change", { isLoading: r, isOverrideState: t().overrideState !== null });
|
|
96
89
|
},
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
overrideLoading: (e) => {
|
|
91
|
+
const o = t().isLoading();
|
|
92
|
+
n({ overrideState: e });
|
|
93
|
+
const i = t().isLoading();
|
|
94
|
+
i && !o ? u.emit("start", null) : !i && o && u.emit("stop", null), u.emit("change", { isLoading: i, isOverrideState: e !== null });
|
|
95
|
+
},
|
|
96
|
+
getLocalCounter: (e) => t().localCounters[e] ?? 0,
|
|
97
|
+
isLocalLoading: (e) => (t().localCounters[e] ?? 0) > 0
|
|
99
98
|
}
|
|
100
99
|
}));
|
|
101
|
-
function
|
|
102
|
-
const n = E(), { actions: t } =
|
|
103
|
-
t.startLoading(n);
|
|
104
|
-
}, e = () => {
|
|
105
|
-
t.isLocalLoading(n) && t.stopLoading(n);
|
|
106
|
-
}, r = async (i) => {
|
|
107
|
-
o();
|
|
108
|
-
try {
|
|
109
|
-
return await i;
|
|
110
|
-
} finally {
|
|
111
|
-
e();
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
return {
|
|
115
|
-
overrideLoading: t.overrideLoading,
|
|
116
|
-
startLoading: o,
|
|
117
|
-
stopLoading: e,
|
|
118
|
-
get isLocalLoading() {
|
|
119
|
-
return t.isLocalLoading(n);
|
|
120
|
-
},
|
|
121
|
-
asyncUseLoading: r,
|
|
122
|
-
get isLoading() {
|
|
123
|
-
return t.isGlobalLoading();
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function q() {
|
|
128
|
-
const n = O(), { actions: t } = v((i) => i), o = () => {
|
|
100
|
+
function M() {
|
|
101
|
+
const n = E(), { actions: t } = w((r) => r), e = () => {
|
|
129
102
|
t.startLoading(n);
|
|
130
|
-
},
|
|
103
|
+
}, o = () => {
|
|
131
104
|
t.isLocalLoading(n) && t.stopLoading(n);
|
|
132
|
-
},
|
|
133
|
-
|
|
105
|
+
}, i = async (r) => {
|
|
106
|
+
e();
|
|
134
107
|
try {
|
|
135
|
-
return await
|
|
108
|
+
return await r;
|
|
136
109
|
} finally {
|
|
137
|
-
|
|
110
|
+
o();
|
|
138
111
|
}
|
|
139
112
|
};
|
|
140
113
|
return {
|
|
141
114
|
overrideLoading: t.overrideLoading,
|
|
142
|
-
startLoading:
|
|
143
|
-
stopLoading:
|
|
115
|
+
startLoading: e,
|
|
116
|
+
stopLoading: o,
|
|
144
117
|
get isLocalLoading() {
|
|
145
118
|
return t.isLocalLoading(n);
|
|
146
119
|
},
|
|
147
|
-
asyncUseLoading:
|
|
120
|
+
asyncUseLoading: i,
|
|
148
121
|
get isLoading() {
|
|
149
122
|
return t.isGlobalLoading();
|
|
150
123
|
}
|
|
@@ -154,32 +127,32 @@ const c = {
|
|
|
154
127
|
Spin: "spin",
|
|
155
128
|
FadeInOut: "fadeInOut",
|
|
156
129
|
None: "none"
|
|
157
|
-
}, z = ({ scale: n = 1, animationType: t = c.Spin, animationDuration:
|
|
158
|
-
const
|
|
159
|
-
return /* @__PURE__ */ f("div", { style: { animation:
|
|
160
|
-
},
|
|
161
|
-
function
|
|
130
|
+
}, z = ({ scale: n = 1, animationType: t = c.Spin, animationDuration: e, children: o, style: i, className: r, id: d, prefix: g }) => {
|
|
131
|
+
const b = t, s = t === c.Spin ? 1 : t === c.FadeInOut ? 2 : 0, a = e || s, l = t === c.Spin ? "linear" : t === c.FadeInOut ? "ease-in-out" : "linear", m = t === c.None ? "none" : `${g}-${b} ${a}s ${l} infinite`;
|
|
132
|
+
return /* @__PURE__ */ f("div", { style: { animation: m, ...n !== 1 ? { zoom: n } : {}, ...i }, className: r, id: d, children: o });
|
|
133
|
+
}, P = (n) => /* @__PURE__ */ f("div", { id: "loading-circle", style: { width: "90px", height: "90px", border: "15px solid #f3f3f3", borderTop: "15px solid #009b4bff", borderRadius: "50%", boxSizing: "border-box" }, ...n }), D = (n) => /* @__PURE__ */ f("div", { style: { padding: "20px", fontSize: "25px", color: "#333", fontFamily: "system-ui, sans-serif" }, ...n, children: "Please wait..." });
|
|
134
|
+
function B({
|
|
162
135
|
loadingComponent: n,
|
|
163
136
|
loadingComponentScale: t = 1,
|
|
164
|
-
animationType:
|
|
165
|
-
animationDuration:
|
|
166
|
-
wrapperStyle:
|
|
167
|
-
wrapperClassName:
|
|
137
|
+
animationType: e = c.Spin,
|
|
138
|
+
animationDuration: o,
|
|
139
|
+
wrapperStyle: i,
|
|
140
|
+
wrapperClassName: r,
|
|
168
141
|
wrapperId: d,
|
|
169
142
|
animationWrapperStyle: g,
|
|
170
|
-
animationWrapperClassName:
|
|
171
|
-
animationWrapperId:
|
|
143
|
+
animationWrapperClassName: b,
|
|
144
|
+
animationWrapperId: s
|
|
172
145
|
}) {
|
|
173
|
-
n = n || (
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}, [
|
|
178
|
-
const
|
|
179
|
-
return
|
|
180
|
-
/* @__PURE__ */
|
|
146
|
+
n = n || (e === c.Spin ? P : D);
|
|
147
|
+
const a = v(Math.random().toString(36).substring(2, 6).replace(/[0-9]/g, "")), { loadingCount: l, overrideState: m } = w((I) => I), p = m ?? l > 0, h = v(null);
|
|
148
|
+
C(() => {
|
|
149
|
+
p ? (h.current?.showModal(), document.body.setAttribute("inert", "")) : (h.current?.close(), document.body.removeAttribute("inert"));
|
|
150
|
+
}, [p]);
|
|
151
|
+
const S = d || "loading-wrapper-" + a.current;
|
|
152
|
+
return p ? j(
|
|
153
|
+
/* @__PURE__ */ O($, { children: [
|
|
181
154
|
/* @__PURE__ */ f("style", { children: `
|
|
182
|
-
dialog#${
|
|
155
|
+
dialog#${S}[open] {
|
|
183
156
|
display: flex !important;
|
|
184
157
|
justify-content: center;
|
|
185
158
|
align-items: center;
|
|
@@ -188,15 +161,15 @@ function H({
|
|
|
188
161
|
max-width: 100%;
|
|
189
162
|
max-height: 100%;
|
|
190
163
|
}
|
|
191
|
-
@keyframes ${
|
|
164
|
+
@keyframes ${a.current}-spin {
|
|
192
165
|
0% { transform: rotate(0deg); }
|
|
193
166
|
100% { transform: rotate(360deg); }
|
|
194
167
|
}
|
|
195
|
-
@keyframes ${
|
|
168
|
+
@keyframes ${a.current}-fadeInOut {
|
|
196
169
|
0%, 100% { opacity: 0.2; }
|
|
197
170
|
50% { opacity: 1; }
|
|
198
171
|
}
|
|
199
|
-
body:has(dialog#${
|
|
172
|
+
body:has(dialog#${S}[open]) {
|
|
200
173
|
overflow: hidden;
|
|
201
174
|
}
|
|
202
175
|
body {
|
|
@@ -206,37 +179,36 @@ function H({
|
|
|
206
179
|
/* @__PURE__ */ f(
|
|
207
180
|
"dialog",
|
|
208
181
|
{
|
|
209
|
-
ref:
|
|
182
|
+
ref: h,
|
|
210
183
|
style: {
|
|
211
184
|
border: "none",
|
|
212
185
|
padding: 0,
|
|
213
186
|
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
214
187
|
backdropFilter: "blur(2px)",
|
|
215
|
-
...
|
|
188
|
+
...i
|
|
216
189
|
},
|
|
217
|
-
className:
|
|
218
|
-
id:
|
|
219
|
-
children: /* @__PURE__ */ f(z, { scale: t, animationType:
|
|
190
|
+
className: r,
|
|
191
|
+
id: S,
|
|
192
|
+
children: /* @__PURE__ */ f(z, { scale: t, animationType: e, animationDuration: o, style: g, className: b, id: s, prefix: a.current, children: L.isValidElement(n) ? n : L.createElement(n) })
|
|
220
193
|
}
|
|
221
194
|
)
|
|
222
195
|
] }),
|
|
223
196
|
document.body
|
|
224
197
|
) : null;
|
|
225
198
|
}
|
|
226
|
-
function
|
|
227
|
-
const { startLoading: t, stopLoading:
|
|
228
|
-
return
|
|
229
|
-
n &&
|
|
199
|
+
function U({ isLoading: n = !1 }) {
|
|
200
|
+
const { startLoading: t, stopLoading: e } = M();
|
|
201
|
+
return C(() => (n ? t() : e(), () => {
|
|
202
|
+
n && e();
|
|
230
203
|
}), [n]), null;
|
|
231
204
|
}
|
|
232
205
|
export {
|
|
233
206
|
c as AnimationType,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
207
|
+
R as EventEmitter,
|
|
208
|
+
U as Loading,
|
|
209
|
+
P as LoadingCircle,
|
|
210
|
+
D as LoadingPleaseWait,
|
|
211
|
+
B as LoadingRenderer,
|
|
239
212
|
u as loadingEventTarget,
|
|
240
|
-
|
|
241
|
-
U as useLoading
|
|
213
|
+
M as useLoading
|
|
242
214
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokku-x/react-hook-loading-spinner",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "A lightweight and flexible React loading state hook library with built-in spinner components, global state management, and zero dependencies (except React and Zustand).",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export default function ssrLoading(): {
|
|
2
|
-
overrideLoading: (state: boolean | null) => void;
|
|
3
|
-
startLoading: () => void;
|
|
4
|
-
stopLoading: () => void;
|
|
5
|
-
readonly isLocalLoading: boolean;
|
|
6
|
-
asyncUseLoading: <R, _ extends any[]>(asyncFunction: Promise<R>) => Promise<R>;
|
|
7
|
-
readonly isLoading: boolean;
|
|
8
|
-
};
|
|
9
|
-
export * from '../store/loadingStore';
|