@elliemae/ds-mobile 3.1.4-rc.0 → 3.1.4-rc.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.
@@ -29,40 +29,51 @@ var import_react = __toESM(require("react"));
29
29
  var import_ds_utilities = require("@elliemae/ds-utilities");
30
30
  var import_ds_grid = require("@elliemae/ds-grid");
31
31
  var import_Loader = require("./Loader");
32
- const InfiniteLoader = ({ isFetching, fetchData, children, height = window.innerHeight }) => {
33
- const callback = (entries) => {
32
+ const InfiniteLoader = ({ isFetching, fetchData, children, height }) => {
33
+ const [viewportHeight, setViewportHeight] = (0, import_react.useState)(height);
34
+ const baselineRef = (0, import_react.useRef)(null);
35
+ const observerRef = (0, import_react.useRef)(null);
36
+ const callback = (0, import_react.useCallback)((entries) => {
34
37
  const { isIntersecting } = entries[0];
35
38
  if (isIntersecting && !isFetching) {
36
39
  fetchData();
37
- observer.current.disconnect();
38
- observer.current = void 0;
40
+ observerRef.current?.disconnect();
39
41
  }
40
- };
41
- const target = (0, import_react.useRef)(null);
42
- const observer = (0, import_react.useRef)(null);
42
+ }, [fetchData, isFetching]);
43
43
  (0, import_react.useEffect)(() => {
44
- if (observer.current) {
45
- observer.current.disconnect();
44
+ if (!isFetching) {
45
+ observerRef.current?.disconnect();
46
+ observerRef.current = new IntersectionObserver(callback, {
47
+ root: null,
48
+ rootMargin: "0px",
49
+ threshold: 0.1
50
+ });
51
+ if (baselineRef.current)
52
+ observerRef.current.observe(baselineRef.current);
46
53
  }
47
- observer.current = new IntersectionObserver(callback, {
48
- root: null,
49
- rootMargin: "0px",
50
- threshold: 0.25
51
- });
52
- if (target.current) {
53
- observer.current.observe(target.current);
54
+ return () => {
55
+ observerRef.current?.disconnect();
56
+ };
57
+ }, [baselineRef, observerRef, fetchData, callback, isFetching]);
58
+ const handleResize = (0, import_react.useCallback)(() => {
59
+ setViewportHeight(window.innerHeight);
60
+ }, []);
61
+ (0, import_react.useEffect)(() => {
62
+ if (!height) {
63
+ window.addEventListener("resize", handleResize);
64
+ handleResize();
54
65
  }
55
66
  return () => {
56
- observer.current?.unobserve(target.current);
57
- observer.current?.disconnect();
67
+ if (!height)
68
+ window.removeEventListener("resize", handleResize);
58
69
  };
59
- }, [target, observer, fetchData]);
70
+ }, [handleResize, height]);
60
71
  return /* @__PURE__ */ import_react.default.createElement(import_ds_grid.Grid, {
61
- style: { position: "relative", height, overflow: "hidden" }
72
+ style: { position: "relative", overflow: "hidden", height: viewportHeight }
62
73
  }, /* @__PURE__ */ import_react.default.createElement(import_ds_grid.Grid, {
63
- style: { overflow: isFetching ? "hidden" : "auto", height }
74
+ style: { overflow: isFetching ? "hidden" : "auto", height: viewportHeight }
64
75
  }, children, /* @__PURE__ */ import_react.default.createElement("div", {
65
- ref: target,
76
+ ref: baselineRef,
66
77
  style: { height: 1 }
67
78
  })), /* @__PURE__ */ import_react.default.createElement(import_Loader.Loader, {
68
79
  isOpen: isFetching
@@ -72,10 +83,8 @@ const listProps = {
72
83
  isFetching: import_ds_utilities.PropTypes.bool.description("toggle loading state"),
73
84
  fetchData: import_ds_utilities.PropTypes.func.description("callback to fetch new items"),
74
85
  children: import_ds_utilities.PropTypes.element.description("row items for infinite loader"),
75
- height: import_ds_utilities.PropTypes.number.isRequired.description("infinite loader list height")
86
+ height: import_ds_utilities.PropTypes.number.description("infinite loader list height")
76
87
  };
77
- InfiniteLoader.propTypes = listProps;
78
- InfiniteLoader.displayName = "InfiniteLoader";
79
88
  const InfiniteLoaderWithSchema = (0, import_ds_utilities.describe)(InfiniteLoader);
80
89
  InfiniteLoaderWithSchema.propTypes = listProps;
81
90
  //# sourceMappingURL=Infiniteloader.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/InfiniteLoader/Infiniteloader.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import React, { useEffect, useRef } from 'react';\nimport { PropTypes, describe } from '@elliemae/ds-utilities';\nimport { Grid } from '@elliemae/ds-grid';\nimport { Loader } from './Loader';\n\nconst InfiniteLoader = ({ isFetching, fetchData, children, height = window.innerHeight }) => {\n const callback = (entries) => {\n const { isIntersecting } = entries[0];\n if (isIntersecting && !isFetching) {\n fetchData();\n // observer.current.unobserve(target.current);\n observer.current.disconnect();\n observer.current = undefined;\n }\n };\n // const [target, setTarget] = useState(null);\n const target = useRef(null);\n const observer = useRef(null);\n\n useEffect(() => {\n if (observer.current) {\n observer.current.disconnect();\n }\n observer.current = new IntersectionObserver(callback, {\n root: null,\n rootMargin: '0px',\n threshold: 0.25,\n });\n if (target.current) {\n observer.current.observe(target.current);\n }\n return () => {\n observer.current?.unobserve(target.current);\n observer.current?.disconnect();\n };\n }, [target, observer, fetchData]);\n\n return (\n <Grid style={{ position: 'relative', height, overflow: 'hidden' }}>\n <Grid style={{ overflow: isFetching ? 'hidden' : 'auto', height }}>\n {children}\n <div ref={target} style={{ height: 1 }} />\n </Grid>\n <Loader isOpen={isFetching} />\n </Grid>\n );\n};\n\nconst listProps = {\n /** toggle loading state */\n isFetching: PropTypes.bool.description('toggle loading state'),\n /** callback to fetch new items */\n fetchData: PropTypes.func.description('callback to fetch new items'),\n /** row items for infinite loader */\n children: PropTypes.element.description('row items for infinite loader'),\n /** infinite loader list height */\n height: PropTypes.number.isRequired.description('infinite loader list height'),\n};\n\nInfiniteLoader.propTypes = listProps;\nInfiniteLoader.displayName = 'InfiniteLoader';\nconst InfiniteLoaderWithSchema = describe(InfiniteLoader);\n\nInfiniteLoaderWithSchema.propTypes = listProps;\n\nexport { InfiniteLoader, InfiniteLoaderWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyC;AACzC,0BAAoC;AACpC,qBAAqB;AACrB,oBAAuB;AAEvB,MAAM,iBAAiB,CAAC,EAAE,YAAY,WAAW,UAA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c;AAC7B,MAAM,2BAA2B,kCAAS,cAAc;AAExD,yBAAyB,YAAY;",
4
+ "sourcesContent": ["import React, { useEffect, useRef, useCallback, useState } from 'react';\nimport { PropTypes, describe } from '@elliemae/ds-utilities';\nimport { Grid } from '@elliemae/ds-grid';\nimport { Loader } from './Loader';\n\ninterface Props {\n isFetching: boolean;\n fetchData: () => void;\n children: React.ReactNode;\n height?: number | string;\n}\n\nconst InfiniteLoader = ({ isFetching, fetchData, children, height }: Props) => {\n const [viewportHeight, setViewportHeight] = useState<number | undefined | string>(height);\n const baselineRef = useRef<HTMLDivElement | null>(null);\n const observerRef = useRef<IntersectionObserver | null>(null);\n\n const callback = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n const { isIntersecting } = entries[0];\n if (isIntersecting && !isFetching) {\n fetchData();\n observerRef.current?.disconnect();\n }\n },\n [fetchData, isFetching],\n );\n\n useEffect(() => {\n if (!isFetching) {\n observerRef.current?.disconnect();\n observerRef.current = new IntersectionObserver(callback, {\n root: null,\n rootMargin: '0px',\n threshold: 0.1,\n });\n if (baselineRef.current) observerRef.current.observe(baselineRef.current);\n }\n return () => {\n observerRef.current?.disconnect();\n };\n }, [baselineRef, observerRef, fetchData, callback, isFetching]);\n\n const handleResize = useCallback(() => {\n setViewportHeight(window.innerHeight);\n }, []);\n\n useEffect(() => {\n if (!height) {\n window.addEventListener('resize', handleResize);\n handleResize();\n }\n return () => {\n if (!height) window.removeEventListener('resize', handleResize);\n };\n }, [handleResize, height]);\n\n return (\n <Grid style={{ position: 'relative', overflow: 'hidden', height: viewportHeight }}>\n <Grid style={{ overflow: isFetching ? 'hidden' : 'auto', height: viewportHeight }}>\n {children}\n <div ref={baselineRef} style={{ height: 1 }} />\n </Grid>\n <Loader isOpen={isFetching} />\n </Grid>\n );\n};\n\nconst listProps = {\n isFetching: PropTypes.bool.description('toggle loading state'),\n fetchData: PropTypes.func.description('callback to fetch new items'),\n children: PropTypes.element.description('row items for infinite loader'),\n height: PropTypes.number.description('infinite loader list height'),\n};\n\nconst InfiniteLoaderWithSchema = describe(InfiniteLoader);\nInfiniteLoaderWithSchema.propTypes = listProps;\nexport { InfiniteLoader, InfiniteLoaderWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAgE;AAChE,0BAAoC;AACpC,qBAAqB;AACrB,oBAAuB;AASvB,MAAM,iBAAiB,CAAC,EAAE,YAAY,WAAW,UAAU,aAAoB;AAC7E,QAAM,CAAC,gBAAgB,qBAAqB,2BAAsC,MAAM;AACxF,QAAM,cAAc,yBAA8B,IAAI;AACtD,QAAM,cAAc,yBAAoC,IAAI;AAE5D,QAAM,WAAW,8BACf,CAAC,YAAyC;AACxC,UAAM,EAAE,mBAAmB,QAAQ;AACnC,QAAI,kBAAkB,CAAC,YAAY;AACjC,gBAAU;AACV,kBAAY,SAAS,WAAW;AAAA,IAClC;AAAA,EACF,GACA,CAAC,WAAW,UAAU,CACxB;AAEA,8BAAU,MAAM;AACd,QAAI,CAAC,YAAY;AACf,kBAAY,SAAS,WAAW;AAChC,kBAAY,UAAU,IAAI,qBAAqB,UAAU;AAAA,QACvD,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,WAAW;AAAA,MACb,CAAC;AACD,UAAI,YAAY;AAAS,oBAAY,QAAQ,QAAQ,YAAY,OAAO;AAAA,IAC1E;AACA,WAAO,MAAM;AACX,kBAAY,SAAS,WAAW;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,aAAa,aAAa,WAAW,UAAU,UAAU,CAAC;AAE9D,QAAM,eAAe,8BAAY,MAAM;AACrC,sBAAkB,OAAO,WAAW;AAAA,EACtC,GAAG,CAAC,CAAC;AAEL,8BAAU,MAAM;AACd,QAAI,CAAC,QAAQ;AACX,aAAO,iBAAiB,UAAU,YAAY;AAC9C,mBAAa;AAAA,IACf;AACA,WAAO,MAAM;AACX,UAAI,CAAC;AAAQ,eAAO,oBAAoB,UAAU,YAAY;AAAA,IAChE;AAAA,EACF,GAAG,CAAC,cAAc,MAAM,CAAC;AAEzB,SACE,mDAAC;AAAA,IAAK,OAAO,EAAE,UAAU,YAAY,UAAU,UAAU,QAAQ,eAAe;AAAA,KAC9E,mDAAC;AAAA,IAAK,OAAO,EAAE,UAAU,aAAa,WAAW,QAAQ,QAAQ,eAAe;AAAA,KAC7E,UACD,mDAAC;AAAA,IAAI,KAAK;AAAA,IAAa,OAAO,EAAE,QAAQ,EAAE;AAAA,GAAG,CAC/C,GACA,mDAAC;AAAA,IAAO,QAAQ;AAAA,GAAY,CAC9B;AAEJ;AAEA,MAAM,YAAY;AAAA,EAChB,YAAY,8BAAU,KAAK,YAAY,sBAAsB;AAAA,EAC7D,WAAW,8BAAU,KAAK,YAAY,6BAA6B;AAAA,EACnE,UAAU,8BAAU,QAAQ,YAAY,+BAA+B;AAAA,EACvE,QAAQ,8BAAU,OAAO,YAAY,6BAA6B;AACpE;AAEA,MAAM,2BAA2B,kCAAS,cAAc;AACxD,yBAAyB,YAAY;",
6
6
  "names": []
7
7
  }
@@ -29,7 +29,7 @@ var import_prop_types = __toESM(require("prop-types"));
29
29
  var import_ds_indeterminate_progress_indicator = __toESM(require("@elliemae/ds-indeterminate-progress-indicator"));
30
30
  var import_styled = require("./styled");
31
31
  const Loader = ({ isOpen }) => /* @__PURE__ */ import_react.default.createElement(import_styled.LoaderBox, {
32
- className: isOpen && "opened"
32
+ className: isOpen ? "opened" : ""
33
33
  }, /* @__PURE__ */ import_react.default.createElement(import_ds_indeterminate_progress_indicator.default, {
34
34
  processing: true,
35
35
  title: "Loading"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/InfiniteLoader/Loader.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable react/no-unused-state */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport DSIndeterminateProgressIndicator from '@elliemae/ds-indeterminate-progress-indicator';\nimport { LoaderBox } from './styled';\n\nexport const Loader = ({ isOpen }) => (\n <LoaderBox className={isOpen && 'opened'}>\n <DSIndeterminateProgressIndicator processing title=\"Loading\" />\n </LoaderBox>\n);\n\nLoader.propTypes = {\n isOpen: PropTypes.bool,\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkB;AAClB,wBAAsB;AACtB,iDAA6C;AAC7C,oBAA0B;AAEnB,MAAM,SAAS,CAAC,EAAE,aACvB,mDAAC;AAAA,EAAU,WAAW,UAAU;AAAA,GAC9B,mDAAC;AAAA,EAAiC,YAAU;AAAA,EAAC,OAAM;AAAA,CAAU,CAC/D;AAGF,OAAO,YAAY;AAAA,EACjB,QAAQ,0BAAU;AACpB;",
4
+ "sourcesContent": ["/* eslint-disable react/no-unused-state */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport DSIndeterminateProgressIndicator from '@elliemae/ds-indeterminate-progress-indicator';\nimport { LoaderBox } from './styled';\n\ninterface Props {\n isOpen: boolean;\n}\n\nexport const Loader = ({ isOpen }: Props) => (\n <LoaderBox className={isOpen ? 'opened' : ''}>\n <DSIndeterminateProgressIndicator processing title=\"Loading\" />\n </LoaderBox>\n);\n\nLoader.propTypes = {\n isOpen: PropTypes.bool,\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkB;AAClB,wBAAsB;AACtB,iDAA6C;AAC7C,oBAA0B;AAMnB,MAAM,SAAS,CAAC,EAAE,aACvB,mDAAC;AAAA,EAAU,WAAW,SAAS,WAAW;AAAA,GACxC,mDAAC;AAAA,EAAiC,YAAU;AAAA,EAAC,OAAM;AAAA,CAAU,CAC/D;AAGF,OAAO,YAAY;AAAA,EACjB,QAAQ,0BAAU;AACpB;",
6
6
  "names": []
7
7
  }
@@ -1,42 +1,53 @@
1
1
  import * as React from "react";
2
- import React2, { useEffect, useRef } from "react";
2
+ import React2, { useEffect, useRef, useCallback, useState } from "react";
3
3
  import { PropTypes, describe } from "@elliemae/ds-utilities";
4
4
  import { Grid } from "@elliemae/ds-grid";
5
5
  import { Loader } from "./Loader";
6
- const InfiniteLoader = ({ isFetching, fetchData, children, height = window.innerHeight }) => {
7
- const callback = (entries) => {
6
+ const InfiniteLoader = ({ isFetching, fetchData, children, height }) => {
7
+ const [viewportHeight, setViewportHeight] = useState(height);
8
+ const baselineRef = useRef(null);
9
+ const observerRef = useRef(null);
10
+ const callback = useCallback((entries) => {
8
11
  const { isIntersecting } = entries[0];
9
12
  if (isIntersecting && !isFetching) {
10
13
  fetchData();
11
- observer.current.disconnect();
12
- observer.current = void 0;
14
+ observerRef.current?.disconnect();
13
15
  }
14
- };
15
- const target = useRef(null);
16
- const observer = useRef(null);
16
+ }, [fetchData, isFetching]);
17
17
  useEffect(() => {
18
- if (observer.current) {
19
- observer.current.disconnect();
18
+ if (!isFetching) {
19
+ observerRef.current?.disconnect();
20
+ observerRef.current = new IntersectionObserver(callback, {
21
+ root: null,
22
+ rootMargin: "0px",
23
+ threshold: 0.1
24
+ });
25
+ if (baselineRef.current)
26
+ observerRef.current.observe(baselineRef.current);
20
27
  }
21
- observer.current = new IntersectionObserver(callback, {
22
- root: null,
23
- rootMargin: "0px",
24
- threshold: 0.25
25
- });
26
- if (target.current) {
27
- observer.current.observe(target.current);
28
+ return () => {
29
+ observerRef.current?.disconnect();
30
+ };
31
+ }, [baselineRef, observerRef, fetchData, callback, isFetching]);
32
+ const handleResize = useCallback(() => {
33
+ setViewportHeight(window.innerHeight);
34
+ }, []);
35
+ useEffect(() => {
36
+ if (!height) {
37
+ window.addEventListener("resize", handleResize);
38
+ handleResize();
28
39
  }
29
40
  return () => {
30
- observer.current?.unobserve(target.current);
31
- observer.current?.disconnect();
41
+ if (!height)
42
+ window.removeEventListener("resize", handleResize);
32
43
  };
33
- }, [target, observer, fetchData]);
44
+ }, [handleResize, height]);
34
45
  return /* @__PURE__ */ React2.createElement(Grid, {
35
- style: { position: "relative", height, overflow: "hidden" }
46
+ style: { position: "relative", overflow: "hidden", height: viewportHeight }
36
47
  }, /* @__PURE__ */ React2.createElement(Grid, {
37
- style: { overflow: isFetching ? "hidden" : "auto", height }
48
+ style: { overflow: isFetching ? "hidden" : "auto", height: viewportHeight }
38
49
  }, children, /* @__PURE__ */ React2.createElement("div", {
39
- ref: target,
50
+ ref: baselineRef,
40
51
  style: { height: 1 }
41
52
  })), /* @__PURE__ */ React2.createElement(Loader, {
42
53
  isOpen: isFetching
@@ -46,10 +57,8 @@ const listProps = {
46
57
  isFetching: PropTypes.bool.description("toggle loading state"),
47
58
  fetchData: PropTypes.func.description("callback to fetch new items"),
48
59
  children: PropTypes.element.description("row items for infinite loader"),
49
- height: PropTypes.number.isRequired.description("infinite loader list height")
60
+ height: PropTypes.number.description("infinite loader list height")
50
61
  };
51
- InfiniteLoader.propTypes = listProps;
52
- InfiniteLoader.displayName = "InfiniteLoader";
53
62
  const InfiniteLoaderWithSchema = describe(InfiniteLoader);
54
63
  InfiniteLoaderWithSchema.propTypes = listProps;
55
64
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/InfiniteLoader/Infiniteloader.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useEffect, useRef } from 'react';\nimport { PropTypes, describe } from '@elliemae/ds-utilities';\nimport { Grid } from '@elliemae/ds-grid';\nimport { Loader } from './Loader';\n\nconst InfiniteLoader = ({ isFetching, fetchData, children, height = window.innerHeight }) => {\n const callback = (entries) => {\n const { isIntersecting } = entries[0];\n if (isIntersecting && !isFetching) {\n fetchData();\n // observer.current.unobserve(target.current);\n observer.current.disconnect();\n observer.current = undefined;\n }\n };\n // const [target, setTarget] = useState(null);\n const target = useRef(null);\n const observer = useRef(null);\n\n useEffect(() => {\n if (observer.current) {\n observer.current.disconnect();\n }\n observer.current = new IntersectionObserver(callback, {\n root: null,\n rootMargin: '0px',\n threshold: 0.25,\n });\n if (target.current) {\n observer.current.observe(target.current);\n }\n return () => {\n observer.current?.unobserve(target.current);\n observer.current?.disconnect();\n };\n }, [target, observer, fetchData]);\n\n return (\n <Grid style={{ position: 'relative', height, overflow: 'hidden' }}>\n <Grid style={{ overflow: isFetching ? 'hidden' : 'auto', height }}>\n {children}\n <div ref={target} style={{ height: 1 }} />\n </Grid>\n <Loader isOpen={isFetching} />\n </Grid>\n );\n};\n\nconst listProps = {\n /** toggle loading state */\n isFetching: PropTypes.bool.description('toggle loading state'),\n /** callback to fetch new items */\n fetchData: PropTypes.func.description('callback to fetch new items'),\n /** row items for infinite loader */\n children: PropTypes.element.description('row items for infinite loader'),\n /** infinite loader list height */\n height: PropTypes.number.isRequired.description('infinite loader list height'),\n};\n\nInfiniteLoader.propTypes = listProps;\nInfiniteLoader.displayName = 'InfiniteLoader';\nconst InfiniteLoaderWithSchema = describe(InfiniteLoader);\n\nInfiniteLoaderWithSchema.propTypes = listProps;\n\nexport { InfiniteLoader, InfiniteLoaderWithSchema };\n"],
5
- "mappings": "AAAA;ACAA;AACA;AACA;AACA;AAEA,MAAM,iBAAiB,CAAC,EAAE,YAAY,WAAW,UAAU,SAAS,OAAO,kBAAkB;AAC3F,QAAM,WAAW,CAAC,YAAY;AAC5B,UAAM,EAAE,mBAAmB,QAAQ;AACnC,QAAI,kBAAkB,CAAC,YAAY;AACjC,gBAAU;AAEV,eAAS,QAAQ,WAAW;AAC5B,eAAS,UAAU;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,SAAS,OAAO,IAAI;AAC1B,QAAM,WAAW,OAAO,IAAI;AAE5B,YAAU,MAAM;AACd,QAAI,SAAS,SAAS;AACpB,eAAS,QAAQ,WAAW;AAAA,IAC9B;AACA,aAAS,UAAU,IAAI,qBAAqB,UAAU;AAAA,MACpD,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,WAAW;AAAA,IACb,CAAC;AACD,QAAI,OAAO,SAAS;AAClB,eAAS,QAAQ,QAAQ,OAAO,OAAO;AAAA,IACzC;AACA,WAAO,MAAM;AACX,eAAS,SAAS,UAAU,OAAO,OAAO;AAC1C,eAAS,SAAS,WAAW;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,QAAQ,UAAU,SAAS,CAAC;AAEhC,SACE,qCAAC;AAAA,IAAK,OAAO,EAAE,UAAU,YAAY,QAAQ,UAAU,SAAS;AAAA,KAC9D,qCAAC;AAAA,IAAK,OAAO,EAAE,UAAU,aAAa,WAAW,QAAQ,OAAO;AAAA,KAC7D,UACD,qCAAC;AAAA,IAAI,KAAK;AAAA,IAAQ,OAAO,EAAE,QAAQ,EAAE;AAAA,GAAG,CAC1C,GACA,qCAAC;AAAA,IAAO,QAAQ;AAAA,GAAY,CAC9B;AAEJ;AAEA,MAAM,YAAY;AAAA,EAEhB,YAAY,UAAU,KAAK,YAAY,sBAAsB;AAAA,EAE7D,WAAW,UAAU,KAAK,YAAY,6BAA6B;AAAA,EAEnE,UAAU,UAAU,QAAQ,YAAY,+BAA+B;AAAA,EAEvE,QAAQ,UAAU,OAAO,WAAW,YAAY,6BAA6B;AAC/E;AAEA,eAAe,YAAY;AAC3B,eAAe,cAAc;AAC7B,MAAM,2BAA2B,SAAS,cAAc;AAExD,yBAAyB,YAAY;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useEffect, useRef, useCallback, useState } from 'react';\nimport { PropTypes, describe } from '@elliemae/ds-utilities';\nimport { Grid } from '@elliemae/ds-grid';\nimport { Loader } from './Loader';\n\ninterface Props {\n isFetching: boolean;\n fetchData: () => void;\n children: React.ReactNode;\n height?: number | string;\n}\n\nconst InfiniteLoader = ({ isFetching, fetchData, children, height }: Props) => {\n const [viewportHeight, setViewportHeight] = useState<number | undefined | string>(height);\n const baselineRef = useRef<HTMLDivElement | null>(null);\n const observerRef = useRef<IntersectionObserver | null>(null);\n\n const callback = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n const { isIntersecting } = entries[0];\n if (isIntersecting && !isFetching) {\n fetchData();\n observerRef.current?.disconnect();\n }\n },\n [fetchData, isFetching],\n );\n\n useEffect(() => {\n if (!isFetching) {\n observerRef.current?.disconnect();\n observerRef.current = new IntersectionObserver(callback, {\n root: null,\n rootMargin: '0px',\n threshold: 0.1,\n });\n if (baselineRef.current) observerRef.current.observe(baselineRef.current);\n }\n return () => {\n observerRef.current?.disconnect();\n };\n }, [baselineRef, observerRef, fetchData, callback, isFetching]);\n\n const handleResize = useCallback(() => {\n setViewportHeight(window.innerHeight);\n }, []);\n\n useEffect(() => {\n if (!height) {\n window.addEventListener('resize', handleResize);\n handleResize();\n }\n return () => {\n if (!height) window.removeEventListener('resize', handleResize);\n };\n }, [handleResize, height]);\n\n return (\n <Grid style={{ position: 'relative', overflow: 'hidden', height: viewportHeight }}>\n <Grid style={{ overflow: isFetching ? 'hidden' : 'auto', height: viewportHeight }}>\n {children}\n <div ref={baselineRef} style={{ height: 1 }} />\n </Grid>\n <Loader isOpen={isFetching} />\n </Grid>\n );\n};\n\nconst listProps = {\n isFetching: PropTypes.bool.description('toggle loading state'),\n fetchData: PropTypes.func.description('callback to fetch new items'),\n children: PropTypes.element.description('row items for infinite loader'),\n height: PropTypes.number.description('infinite loader list height'),\n};\n\nconst InfiniteLoaderWithSchema = describe(InfiniteLoader);\nInfiniteLoaderWithSchema.propTypes = listProps;\nexport { InfiniteLoader, InfiniteLoaderWithSchema };\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;AACA;AASA,MAAM,iBAAiB,CAAC,EAAE,YAAY,WAAW,UAAU,aAAoB;AAC7E,QAAM,CAAC,gBAAgB,qBAAqB,SAAsC,MAAM;AACxF,QAAM,cAAc,OAA8B,IAAI;AACtD,QAAM,cAAc,OAAoC,I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AY,sBAAsB;AAAA,EAC7D,WAAW,UAAU,KAAK,YAAY,6BAA6B;AAAA,EACnE,UAAU,UAAU,QAAQ,YAAY,+BAA+B;AAAA,EACvE,QAAQ,UAAU,OAAO,YAAY,6BAA6B;AACpE;AAEA,MAAM,2BAA2B,SAAS,cAAc;AACxD,yBAAyB,YAAY;",
6
6
  "names": []
7
7
  }
@@ -4,7 +4,7 @@ import PropTypes from "prop-types";
4
4
  import DSIndeterminateProgressIndicator from "@elliemae/ds-indeterminate-progress-indicator";
5
5
  import { LoaderBox } from "./styled";
6
6
  const Loader = ({ isOpen }) => /* @__PURE__ */ React2.createElement(LoaderBox, {
7
- className: isOpen && "opened"
7
+ className: isOpen ? "opened" : ""
8
8
  }, /* @__PURE__ */ React2.createElement(DSIndeterminateProgressIndicator, {
9
9
  processing: true,
10
10
  title: "Loading"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/InfiniteLoader/Loader.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/no-unused-state */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport DSIndeterminateProgressIndicator from '@elliemae/ds-indeterminate-progress-indicator';\nimport { LoaderBox } from './styled';\n\nexport const Loader = ({ isOpen }) => (\n <LoaderBox className={isOpen && 'opened'}>\n <DSIndeterminateProgressIndicator processing title=\"Loading\" />\n </LoaderBox>\n);\n\nLoader.propTypes = {\n isOpen: PropTypes.bool,\n};\n"],
5
- "mappings": "AAAA;ACCA;AACA;AACA;AACA;AAEO,MAAM,SAAS,CAAC,EAAE,aACvB,qCAAC;AAAA,EAAU,WAAW,UAAU;AAAA,GAC9B,qCAAC;AAAA,EAAiC,YAAU;AAAA,EAAC,OAAM;AAAA,CAAU,CAC/D;AAGF,OAAO,YAAY;AAAA,EACjB,QAAQ,UAAU;AACpB;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/no-unused-state */\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport DSIndeterminateProgressIndicator from '@elliemae/ds-indeterminate-progress-indicator';\nimport { LoaderBox } from './styled';\n\ninterface Props {\n isOpen: boolean;\n}\n\nexport const Loader = ({ isOpen }: Props) => (\n <LoaderBox className={isOpen ? 'opened' : ''}>\n <DSIndeterminateProgressIndicator processing title=\"Loading\" />\n </LoaderBox>\n);\n\nLoader.propTypes = {\n isOpen: PropTypes.bool,\n};\n"],
5
+ "mappings": "AAAA;ACCA;AACA;AACA;AACA;AAMO,MAAM,SAAS,CAAC,EAAE,aACvB,qCAAC;AAAA,EAAU,WAAW,SAAS,WAAW;AAAA,GACxC,qCAAC;AAAA,EAAiC,YAAU;AAAA,EAAC,OAAM;AAAA,CAAU,CAC/D;AAGF,OAAO,YAAY;AAAA,EACjB,QAAQ,UAAU;AACpB;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-mobile",
3
- "version": "3.1.4-rc.0",
3
+ "version": "3.1.4-rc.1",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - System",
6
6
  "files": [
@@ -435,20 +435,20 @@
435
435
  "typeSafety": false
436
436
  },
437
437
  "dependencies": {
438
- "@elliemae/ds-accordion": "3.1.4-rc.0",
439
- "@elliemae/ds-backdrop": "3.1.4-rc.0",
440
- "@elliemae/ds-button": "3.1.4-rc.0",
441
- "@elliemae/ds-circular-progress-indicator": "3.1.4-rc.0",
442
- "@elliemae/ds-form": "3.1.4-rc.0",
443
- "@elliemae/ds-grid": "3.1.4-rc.0",
444
- "@elliemae/ds-icon": "3.1.4-rc.0",
445
- "@elliemae/ds-icons": "3.1.4-rc.0",
446
- "@elliemae/ds-indeterminate-progress-indicator": "3.1.4-rc.0",
447
- "@elliemae/ds-shared": "3.1.4-rc.0",
448
- "@elliemae/ds-system": "3.1.4-rc.0",
449
- "@elliemae/ds-tabs": "3.1.4-rc.0",
450
- "@elliemae/ds-truncated-expandable-text": "3.1.4-rc.0",
451
- "@elliemae/ds-utilities": "3.1.4-rc.0",
438
+ "@elliemae/ds-accordion": "3.1.4-rc.1",
439
+ "@elliemae/ds-backdrop": "3.1.4-rc.1",
440
+ "@elliemae/ds-button": "3.1.4-rc.1",
441
+ "@elliemae/ds-circular-progress-indicator": "3.1.4-rc.1",
442
+ "@elliemae/ds-form": "3.1.4-rc.1",
443
+ "@elliemae/ds-grid": "3.1.4-rc.1",
444
+ "@elliemae/ds-icon": "3.1.4-rc.1",
445
+ "@elliemae/ds-icons": "3.1.4-rc.1",
446
+ "@elliemae/ds-indeterminate-progress-indicator": "3.1.4-rc.1",
447
+ "@elliemae/ds-shared": "3.1.4-rc.1",
448
+ "@elliemae/ds-system": "3.1.4-rc.1",
449
+ "@elliemae/ds-tabs": "3.1.4-rc.1",
450
+ "@elliemae/ds-truncated-expandable-text": "3.1.4-rc.1",
451
+ "@elliemae/ds-utilities": "3.1.4-rc.1",
452
452
  "polished": "~3.6.7",
453
453
  "prop-types": "~15.8.1",
454
454
  "react-window": "~1.8.6",