@iress-oss/ids-components 0.0.1-dev.2 → 0.0.1-dev.3

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,51 +1,53 @@
1
- import { jsxs as R, Fragment as v, jsx as r } from "react/jsx-runtime";
2
- import { useMemo as a, useRef as C, useState as b, Suspense as k, useEffect as F } from "react";
3
- import { Q as f } from "../../Loading-rKDsRTjZ.js";
1
+ import { jsxs as d, Fragment as a, jsx as n } from "react/jsx-runtime";
2
+ import { useMemo as S, useRef as F, useState as g, useEffect as b, Suspense as R } from "react";
3
+ import { Q as i } from "../../Loading-rKDsRTjZ.js";
4
4
  import { useSuspenseResource as I, uncacheSuspenseResource as E } from "./hooks/useSuspenseResource.js";
5
- const x = ({
5
+ const k = ({
6
6
  children: s,
7
- delay: l,
8
- onLoaded: u,
7
+ delay: r,
8
+ onLoaded: l,
9
9
  pattern: e,
10
10
  startFrom: c,
11
11
  ...t
12
12
  }) => {
13
- const o = a(() => l || (e === "component" || e === "default" || e === "validate" ? 0 : e === "long" ? 1300 : 250), [l, e]), d = a(() => c || (e === "component" || e === "default" || e === "long" ? 0 : 250), [c, e]), m = C(!1), [n, j] = b(!1), h = f.shouldRender(n, o, d, 0), [i, S] = b(!1), g = () => {
14
- m.current || (m.current = !0, j(() => !0), h ? setTimeout(() => {
15
- S(!0), u == null || u();
16
- }, o) : (S(!0), u == null || u()));
13
+ const w = S(() => r || (e === "component" || e === "default" || e === "validate" ? 0 : e === "long" ? 1300 : 500), [r, e]), x = S(() => c || (e === "component" || e === "default" || e === "long" ? 0 : 250), [c, e]), m = F(!1), [u, j] = g(!1), o = i.shouldRender(u, w, x), [f, C] = g(!1);
14
+ b(() => {
15
+ u && !o && (C(!0), l == null || l());
16
+ }, [u, l, o]);
17
+ const h = () => {
18
+ m.current || (m.current = !0, j(() => !0));
17
19
  };
18
- return e === "component" || e === "validate" ? /* @__PURE__ */ R(v, { children: [
19
- /* @__PURE__ */ r(
20
- f,
20
+ return e === "component" || e === "validate" ? /* @__PURE__ */ d(a, { children: [
21
+ /* @__PURE__ */ n(
22
+ i,
21
23
  {
22
24
  pattern: e,
23
- loaded: n,
25
+ loaded: u,
24
26
  ...t,
25
- children: i && s
27
+ children: f && s
26
28
  }
27
29
  ),
28
- /* @__PURE__ */ r(k, { fallback: null, children: !i && /* @__PURE__ */ r(w, { onResolved: g, children: !n && s }) })
29
- ] }) : /* @__PURE__ */ R(v, { children: [
30
- h && /* @__PURE__ */ r(
31
- f,
30
+ /* @__PURE__ */ n(R, { fallback: null, children: !f && /* @__PURE__ */ n(v, { onResolved: h, children: !u && s }) })
31
+ ] }) : /* @__PURE__ */ d(a, { children: [
32
+ o && /* @__PURE__ */ n(
33
+ i,
32
34
  {
33
35
  pattern: e,
34
- loaded: n,
36
+ loaded: u,
35
37
  ...t
36
38
  }
37
39
  ),
38
- /* @__PURE__ */ r(k, { fallback: null, children: i ? s : /* @__PURE__ */ r(w, { onResolved: g, children: !n && s }) })
40
+ /* @__PURE__ */ n(R, { fallback: null, children: f ? s : /* @__PURE__ */ n(v, { onResolved: h, children: !u && s }) })
39
41
  ] });
40
42
  };
41
- x.use = I;
42
- x.uncache = E;
43
- const w = ({
43
+ k.use = I;
44
+ k.uncache = E;
45
+ const v = ({
44
46
  onResolved: s,
45
- children: l
46
- }) => (F(() => {
47
+ children: r
48
+ }) => (b(() => {
47
49
  s();
48
- }, [s]), l);
50
+ }, [s]), r);
49
51
  export {
50
- x as IressLoadingSuspense
52
+ k as IressLoadingSuspense
51
53
  };
@@ -5,7 +5,7 @@ import { PageLoadingProps } from './components/PageLoading';
5
5
  import { ComponentLoadingProps } from './components/ComponentLoading';
6
6
  import { LongLoadingProps } from './components/LongLoading';
7
7
  import { DefaultLoadingProps } from './components/DefaultLoading';
8
- type IressLoadingSuspenseProps = (Omit<StartUpLoadingProps, 'loaded'> | ValidateLoadingProps | Omit<PageLoadingProps, 'loaded'> | Omit<ComponentLoadingProps, 'loaded'> | Omit<LongLoadingProps, 'loaded'> | DefaultLoadingProps) & {
8
+ export type IressLoadingSuspenseProps = (Omit<StartUpLoadingProps, 'loaded'> | ValidateLoadingProps | Omit<PageLoadingProps, 'loaded'> | Omit<ComponentLoadingProps, 'loaded'> | Omit<LongLoadingProps, 'loaded'> | DefaultLoadingProps) & {
9
9
  /**
10
10
  * The content that will be rendered inside the Suspense boundary.
11
11
  * Typically includes lazy-loaded components and components that use the `use` or `IressLoadingSuspense.use` hook.
@@ -71,4 +71,3 @@ export declare const IressLoadingSuspense: {
71
71
  */
72
72
  uncache: (fetcher: () => Promise<unknown>, timeout?: number) => void;
73
73
  };
74
- export {};
@@ -4,6 +4,7 @@
4
4
  * @param isLoaded - A boolean value that determines if the component waiting to be loaded has finished loading.
5
5
  * @param delay - Once a component has loaded, how long should the loading indicator be displayed for. This is useful to allow the loading indicator to animate out.
6
6
  * @param startFrom - If a component is still loading after this time in milliseconds, you should show the loading message. Default is 500ms, meaning a user will not even see the loading indicator if the page loads before this time.
7
+ * @param avoidDelayTimeout - If the component has a start up animation, this is the time in milliseconds that we will avoid the delay timeout for. This is useful to speed up the loading indicator removal if the component loaded before the first half of an animation finishes.
7
8
  * @returns A boolean value that determines whether the `IressLoading` component should be rendered.
8
9
  */
9
10
  export declare const useShouldRenderLoading: (isLoaded: boolean, delay?: number, startFrom?: number, avoidDelayTimeout?: number) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iress-oss/ids-components",
3
- "version": "0.0.1-dev.2",
3
+ "version": "0.0.1-dev.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/"
6
6
  },