@ledgerhq/react-ui 0.24.0-next.0 → 0.24.0-nightly.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.
Files changed (31) hide show
  1. package/lib/cjs/pre-ldls/components/NetworkItem/NetworkItem.js +90 -0
  2. package/lib/cjs/pre-ldls/components/NetworkItem/NetworkItem.js.map +7 -0
  3. package/lib/cjs/pre-ldls/components/NetworkItem/NetworkItem.stories.js +43 -0
  4. package/lib/cjs/pre-ldls/components/NetworkItem/NetworkItem.stories.js.map +7 -0
  5. package/lib/cjs/pre-ldls/components/NetworkList/NetworkList.js +50 -0
  6. package/lib/cjs/pre-ldls/components/NetworkList/NetworkList.js.map +7 -0
  7. package/lib/cjs/pre-ldls/components/NetworkList/NetworkList.stories.js +62 -0
  8. package/lib/cjs/pre-ldls/components/NetworkList/NetworkList.stories.js.map +7 -0
  9. package/lib/cjs/pre-ldls/components/VirtualList/VirtualList.js +51 -11
  10. package/lib/cjs/pre-ldls/components/VirtualList/VirtualList.js.map +3 -3
  11. package/lib/cjs/pre-ldls/components/VirtualList/VirtualList.stories.js +107 -10
  12. package/lib/cjs/pre-ldls/components/VirtualList/VirtualList.stories.js.map +2 -2
  13. package/lib/cjs/pre-ldls/components/index.js +2 -0
  14. package/lib/cjs/pre-ldls/components/index.js.map +2 -2
  15. package/lib/pre-ldls/components/NetworkItem/NetworkItem.d.ts +8 -0
  16. package/lib/pre-ldls/components/NetworkItem/NetworkItem.d.ts.map +1 -0
  17. package/lib/pre-ldls/components/NetworkItem/NetworkItem.js +41 -0
  18. package/lib/pre-ldls/components/NetworkItem/NetworkItem.js.map +1 -0
  19. package/lib/pre-ldls/components/NetworkList/NetworkList.d.ts +9 -0
  20. package/lib/pre-ldls/components/NetworkList/NetworkList.d.ts.map +1 -0
  21. package/lib/pre-ldls/components/NetworkList/NetworkList.js +7 -0
  22. package/lib/pre-ldls/components/NetworkList/NetworkList.js.map +1 -0
  23. package/lib/pre-ldls/components/VirtualList/VirtualList.d.ts +50 -4
  24. package/lib/pre-ldls/components/VirtualList/VirtualList.d.ts.map +1 -1
  25. package/lib/pre-ldls/components/VirtualList/VirtualList.js +40 -5
  26. package/lib/pre-ldls/components/VirtualList/VirtualList.js.map +1 -1
  27. package/lib/pre-ldls/components/index.d.ts +2 -0
  28. package/lib/pre-ldls/components/index.d.ts.map +1 -1
  29. package/lib/pre-ldls/components/index.js +2 -0
  30. package/lib/pre-ldls/components/index.js.map +1 -1
  31. package/package.json +4 -4
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var NetworkItem_exports = {};
30
+ __export(NetworkItem_exports, {
31
+ NetworkItem: () => NetworkItem
32
+ });
33
+ module.exports = __toCommonJS(NetworkItem_exports);
34
+ var import_react = __toESM(require("react"));
35
+ var import_styled_components = __toESM(require("styled-components"));
36
+ var import_libs = require("../../libs");
37
+ var import_components = require("../../../components");
38
+ const TempAssetBadge = () => (
39
+ // TODO: To be replaced with LIVE-18221
40
+ /* @__PURE__ */ import_react.default.createElement("div", { style: { display: "flex", alignItems: "center" } }, /* @__PURE__ */ import_react.default.createElement(
41
+ "span",
42
+ {
43
+ style: {
44
+ height: 48,
45
+ width: 48,
46
+ borderRadius: 48,
47
+ backgroundColor: "grey",
48
+ display: "inline-block"
49
+ }
50
+ }
51
+ ))
52
+ );
53
+ const Wrapper = import_styled_components.default.div`
54
+ ${(0, import_libs.withTokens)(
55
+ "spacing-xs",
56
+ "marging-s",
57
+ "colors-content-default-default",
58
+ "colors-surface-transparent-hover",
59
+ "colors-surface-transparent-pressed"
60
+ )}
61
+ display: flex;
62
+ padding: var(--spacing-xs);
63
+ cursor: pointer;
64
+
65
+ :hover {
66
+ background-color: var(--colors-surface-transparent-hover);
67
+ }
68
+
69
+ :active {
70
+ background-color: var(--colors-surface-transparent-pressed);
71
+ }
72
+ `;
73
+ const InfoWrapper = import_styled_components.default.div`
74
+ display: flex;
75
+ flex-direction: column;
76
+ justify-content: center;
77
+ margin-left: var(--marging-s);
78
+ `;
79
+ const NetworkItem = ({ name, onClick }) => {
80
+ return /* @__PURE__ */ import_react.default.createElement(Wrapper, { onClick }, /* @__PURE__ */ import_react.default.createElement(TempAssetBadge, null), /* @__PURE__ */ import_react.default.createElement(InfoWrapper, null, /* @__PURE__ */ import_react.default.createElement(
81
+ import_components.Text,
82
+ {
83
+ variant: "largeLineHeight",
84
+ fontWeight: "semiBold",
85
+ color: "var(--colors-content-default-default)"
86
+ },
87
+ name
88
+ )));
89
+ };
90
+ //# sourceMappingURL=NetworkItem.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pre-ldls/components/NetworkItem/NetworkItem.tsx"],
4
+ "sourcesContent": ["import React from \"react\";\nimport styled from \"styled-components\";\nimport { withTokens } from \"../../libs\";\nimport { Text } from \"../../../components\";\n\ntype NetworkItemProps = {\n name: string;\n onClick: () => void;\n};\n\nconst TempAssetBadge = () => (\n // TODO: To be replaced with LIVE-18221\n <div style={{ display: \"flex\", alignItems: \"center\" }}>\n <span\n style={{\n height: 48,\n width: 48,\n borderRadius: 48,\n backgroundColor: \"grey\",\n display: \"inline-block\",\n }}\n />\n </div>\n);\n\nconst Wrapper = styled.div`\n ${withTokens(\n \"spacing-xs\",\n \"marging-s\",\n \"colors-content-default-default\",\n \"colors-surface-transparent-hover\",\n \"colors-surface-transparent-pressed\",\n )}\n display: flex;\n padding: var(--spacing-xs);\n cursor: pointer;\n\n :hover {\n background-color: var(--colors-surface-transparent-hover);\n }\n\n :active {\n background-color: var(--colors-surface-transparent-pressed);\n }\n`;\n\nconst InfoWrapper = styled.div`\n display: flex;\n flex-direction: column;\n justify-content: center;\n margin-left: var(--marging-s);\n`;\n\nexport const NetworkItem = ({ name, onClick }: NetworkItemProps) => {\n return (\n <Wrapper onClick={onClick}>\n <TempAssetBadge />\n <InfoWrapper>\n <Text\n variant=\"largeLineHeight\"\n fontWeight=\"semiBold\"\n color=\"var(--colors-content-default-default)\"\n >\n {name}\n </Text>\n </InfoWrapper>\n </Wrapper>\n );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,+BAAmB;AACnB,kBAA2B;AAC3B,wBAAqB;AAOrB,MAAM,iBAAiB;AAAA;AAAA,EAErB,6BAAAA,QAAA,cAAC,SAAI,OAAO,EAAE,SAAS,QAAQ,YAAY,SAAS,KAClD,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,SAAS;AAAA,MACX;AAAA;AAAA,EACF,CACF;AAAA;AAGF,MAAM,UAAU,yBAAAC,QAAO;AAAA,QACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcH,MAAM,cAAc,yBAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAOpB,MAAM,cAAc,CAAC,EAAE,MAAM,QAAQ,MAAwB;AAClE,SACE,6BAAAD,QAAA,cAAC,WAAQ,WACP,6BAAAA,QAAA,cAAC,oBAAe,GAChB,6BAAAA,QAAA,cAAC,mBACC,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,YAAW;AAAA,MACX,OAAM;AAAA;AAAA,IAEL;AAAA,EACH,CACF,CACF;AAEJ;",
6
+ "names": ["React", "styled"]
7
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var NetworkItem_stories_exports = {};
20
+ __export(NetworkItem_stories_exports, {
21
+ Default: () => Default,
22
+ TestNetworkItem: () => TestNetworkItem,
23
+ default: () => NetworkItem_stories_default
24
+ });
25
+ module.exports = __toCommonJS(NetworkItem_stories_exports);
26
+ var import_NetworkItem = require("./NetworkItem");
27
+ var import_test = require("@storybook/test");
28
+ const meta = {
29
+ component: import_NetworkItem.NetworkItem,
30
+ title: "PreLdls/Components/NetworkItem",
31
+ tags: ["autodocs"],
32
+ args: { name: "Bitcoin" }
33
+ };
34
+ var NetworkItem_stories_default = meta;
35
+ const Default = {};
36
+ const TestNetworkItem = {
37
+ play: async ({ canvasElement }) => {
38
+ const canvas = (0, import_test.within)(canvasElement);
39
+ const name = canvas.getByText("Bitcoin");
40
+ await (0, import_test.expect)(name).toBeInTheDocument();
41
+ }
42
+ };
43
+ //# sourceMappingURL=NetworkItem.stories.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pre-ldls/components/NetworkItem/NetworkItem.stories.tsx"],
4
+ "sourcesContent": ["import type { Meta, StoryObj } from \"@storybook/react\";\nimport { NetworkItem } from \"./NetworkItem\";\nimport { expect, within } from \"@storybook/test\";\n\nconst meta: Meta<typeof NetworkItem> = {\n component: NetworkItem,\n title: \"PreLdls/Components/NetworkItem\",\n tags: [\"autodocs\"],\n args: { name: \"Bitcoin\" },\n};\nexport default meta;\n\ntype Story = StoryObj<typeof NetworkItem>;\n\nexport const Default: Story = {};\n\nexport const TestNetworkItem: Story = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n\n const name = canvas.getByText(\"Bitcoin\");\n\n await expect(name).toBeInTheDocument();\n },\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA4B;AAC5B,kBAA+B;AAE/B,MAAM,OAAiC;AAAA,EACrC,WAAW;AAAA,EACX,OAAO;AAAA,EACP,MAAM,CAAC,UAAU;AAAA,EACjB,MAAM,EAAE,MAAM,UAAU;AAC1B;AACA,IAAO,8BAAQ;AAIR,MAAM,UAAiB,CAAC;AAExB,MAAM,kBAAyB;AAAA,EACpC,MAAM,OAAO,EAAE,cAAc,MAAM;AACjC,UAAM,aAAS,oBAAO,aAAa;AAEnC,UAAM,OAAO,OAAO,UAAU,SAAS;AAEvC,cAAM,oBAAO,IAAI,EAAE,kBAAkB;AAAA,EACvC;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var NetworkList_exports = {};
30
+ __export(NetworkList_exports, {
31
+ NetworkList: () => NetworkList
32
+ });
33
+ module.exports = __toCommonJS(NetworkList_exports);
34
+ var import_react = __toESM(require("react"));
35
+ var import_NetworkItem = require("../NetworkItem/NetworkItem");
36
+ var import_VirtualList = require("../VirtualList/VirtualList");
37
+ const NetworkList = ({
38
+ networks,
39
+ onClick
40
+ }) => {
41
+ return /* @__PURE__ */ import_react.default.createElement(
42
+ import_VirtualList.VirtualList,
43
+ {
44
+ itemHeight: 64,
45
+ count: networks.length,
46
+ renderItem: (i) => /* @__PURE__ */ import_react.default.createElement(import_NetworkItem.NetworkItem, { name: networks[i].name, onClick: () => onClick(networks[i].id) })
47
+ }
48
+ );
49
+ };
50
+ //# sourceMappingURL=NetworkList.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pre-ldls/components/NetworkList/NetworkList.tsx"],
4
+ "sourcesContent": ["import React from \"react\";\nimport { NetworkItem } from \"../NetworkItem/NetworkItem\";\nimport { VirtualList } from \"../VirtualList/VirtualList\";\n\nexport const NetworkList = ({\n networks,\n onClick,\n}: {\n networks: { name: string; id: string }[];\n onClick: (networkId: string) => void;\n}) => {\n return (\n <VirtualList\n itemHeight={64}\n count={networks.length}\n renderItem={(i: number) => (\n <NetworkItem name={networks[i].name} onClick={() => onClick(networks[i].id)} />\n )}\n />\n );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,yBAA4B;AAC5B,yBAA4B;AAErB,MAAM,cAAc,CAAC;AAAA,EAC1B;AAAA,EACA;AACF,MAGM;AACJ,SACE,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACC,YAAY;AAAA,MACZ,OAAO,SAAS;AAAA,MAChB,YAAY,CAAC,MACX,6BAAAA,QAAA,cAAC,kCAAY,MAAM,SAAS,CAAC,EAAE,MAAM,SAAS,MAAM,QAAQ,SAAS,CAAC,EAAE,EAAE,GAAG;AAAA;AAAA,EAEjF;AAEJ;",
6
+ "names": ["React"]
7
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var NetworkList_stories_exports = {};
30
+ __export(NetworkList_stories_exports, {
31
+ Default: () => Default,
32
+ TestNetworkClick: () => TestNetworkClick,
33
+ default: () => NetworkList_stories_default
34
+ });
35
+ module.exports = __toCommonJS(NetworkList_stories_exports);
36
+ var import_react = __toESM(require("react"));
37
+ var import_NetworkList = require("./NetworkList");
38
+ var import_test = require("@storybook/test");
39
+ const testFn = (0, import_test.fn)();
40
+ const meta = {
41
+ component: import_NetworkList.NetworkList,
42
+ decorators: [
43
+ (Story) => /* @__PURE__ */ import_react.default.createElement("div", { style: { height: "400px" } }, /* @__PURE__ */ import_react.default.createElement(Story, null))
44
+ ],
45
+ title: "PreLdls/Components/NetworkList",
46
+ tags: ["autodocs"],
47
+ args: {
48
+ networks: Array.from({ length: 50 }, (_, i) => ({ name: `Bitcoin ${i}`, id: `btc${i}` })),
49
+ onClick: testFn
50
+ }
51
+ };
52
+ var NetworkList_stories_default = meta;
53
+ const Default = {};
54
+ const TestNetworkClick = {
55
+ play: async ({ canvasElement }) => {
56
+ const canvas = (0, import_test.within)(canvasElement);
57
+ const input = canvas.getByText("Bitcoin 1");
58
+ await import_test.userEvent.click(input);
59
+ await (0, import_test.expect)(testFn).toHaveBeenCalledWith("btc1");
60
+ }
61
+ };
62
+ //# sourceMappingURL=NetworkList.stories.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/pre-ldls/components/NetworkList/NetworkList.stories.tsx"],
4
+ "sourcesContent": ["import React from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { NetworkList } from \"./NetworkList\";\nimport { expect, fn, userEvent, within } from \"@storybook/test\";\n\nconst testFn = fn();\n\nconst meta: Meta<typeof NetworkList> = {\n component: NetworkList,\n decorators: [\n Story => (\n <div style={{ height: \"400px\" }}>\n <Story />\n </div>\n ),\n ],\n title: \"PreLdls/Components/NetworkList\",\n tags: [\"autodocs\"],\n args: {\n networks: Array.from({ length: 50 }, (_, i) => ({ name: `Bitcoin ${i}`, id: `btc${i}` })),\n onClick: testFn,\n },\n};\nexport default meta;\n\ntype Story = StoryObj<typeof NetworkList>;\n\nexport const Default: Story = {};\n\nexport const TestNetworkClick: Story = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n const input = canvas.getByText(\"Bitcoin 1\");\n await userEvent.click(input);\n await expect(testFn).toHaveBeenCalledWith(\"btc1\");\n },\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,yBAA4B;AAC5B,kBAA8C;AAE9C,MAAM,aAAS,gBAAG;AAElB,MAAM,OAAiC;AAAA,EACrC,WAAW;AAAA,EACX,YAAY;AAAA,IACV,WACE,6BAAAA,QAAA,cAAC,SAAI,OAAO,EAAE,QAAQ,QAAQ,KAC5B,6BAAAA,QAAA,cAAC,WAAM,CACT;AAAA,EAEJ;AAAA,EACA,OAAO;AAAA,EACP,MAAM,CAAC,UAAU;AAAA,EACjB,MAAM;AAAA,IACJ,UAAU,MAAM,KAAK,EAAE,QAAQ,GAAG,GAAG,CAAC,GAAG,OAAO,EAAE,MAAM,WAAW,CAAC,IAAI,IAAI,MAAM,CAAC,GAAG,EAAE;AAAA,IACxF,SAAS;AAAA,EACX;AACF;AACA,IAAO,8BAAQ;AAIR,MAAM,UAAiB,CAAC;AAExB,MAAM,mBAA0B;AAAA,EACrC,MAAM,OAAO,EAAE,cAAc,MAAM;AACjC,UAAM,aAAS,oBAAO,aAAa;AACnC,UAAM,QAAQ,OAAO,UAAU,WAAW;AAC1C,UAAM,sBAAU,MAAM,KAAK;AAC3B,cAAM,oBAAO,MAAM,EAAE,qBAAqB,MAAM;AAAA,EAClD;AACF;",
6
+ "names": ["React"]
7
+ }
@@ -32,23 +32,63 @@ __export(VirtualList_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(VirtualList_exports);
34
34
  var import_react = __toESM(require("react"));
35
- var import_react_window = require("react-window");
36
- var import_react_virtualized_auto_sizer = __toESM(require("react-virtualized-auto-sizer"));
35
+ var import_react_virtual = require("@tanstack/react-virtual");
36
+ var import_components = require("../../../components");
37
+ const DefaultLoadingComponent = () => /* @__PURE__ */ import_react.default.createElement(import_components.Flex, { justifyContent: "center", alignItems: "center", height: "76px" }, /* @__PURE__ */ import_react.default.createElement(import_components.InfiniteLoader, null));
37
38
  const VirtualList = ({
38
39
  count,
39
40
  itemHeight,
41
+ overscan = 5,
42
+ LoadingComponent,
43
+ isLoading,
44
+ hasNextPage = false,
45
+ threshold = 5,
46
+ onVisibleItemsScrollEnd,
40
47
  renderItem
41
48
  }) => {
42
- return /* @__PURE__ */ import_react.default.createElement(import_react_virtualized_auto_sizer.default, { style: { height: "100%", width: "100%" } }, ({ height }) => /* @__PURE__ */ import_react.default.createElement(
43
- import_react_window.FixedSizeList,
49
+ const parentRef = (0, import_react.useRef)(null);
50
+ const rowVirtualizer = (0, import_react_virtual.useVirtualizer)({
51
+ count: hasNextPage ? count + 1 : count,
52
+ getScrollElement: () => parentRef.current,
53
+ estimateSize: () => itemHeight,
54
+ overscan
55
+ });
56
+ (0, import_react.useEffect)(() => {
57
+ const items = rowVirtualizer.getVirtualItems();
58
+ if (!items.length)
59
+ return;
60
+ const lastItem = items[items.length - 1];
61
+ if (lastItem.index >= count - 1 - threshold && hasNextPage && !isLoading && onVisibleItemsScrollEnd) {
62
+ onVisibleItemsScrollEnd();
63
+ }
64
+ }, [hasNextPage, onVisibleItemsScrollEnd, count, isLoading, rowVirtualizer.getVirtualItems()]);
65
+ const showCustomLoadingComponent = !!LoadingComponent;
66
+ return /* @__PURE__ */ import_react.default.createElement("div", { ref: parentRef, style: { width: "100%", height: "100%", overflow: "auto" } }, /* @__PURE__ */ import_react.default.createElement(
67
+ "div",
44
68
  {
45
- height,
46
- itemCount: count,
47
- itemSize: itemHeight,
48
- layout: "vertical",
49
- width: "100%"
69
+ style: {
70
+ height: `${rowVirtualizer.getTotalSize()}px`,
71
+ width: "100%",
72
+ position: "relative"
73
+ }
50
74
  },
51
- ({ index, style }) => /* @__PURE__ */ import_react.default.createElement("div", { style }, renderItem(index))
52
- ));
75
+ rowVirtualizer.getVirtualItems().map((virtualRow) => /* @__PURE__ */ import_react.default.createElement(
76
+ "div",
77
+ {
78
+ key: virtualRow.index,
79
+ "data-index": virtualRow.index,
80
+ ref: rowVirtualizer.measureElement,
81
+ style: {
82
+ position: "absolute",
83
+ top: 0,
84
+ left: 0,
85
+ transform: `translateY(${virtualRow.start}px)`,
86
+ height: `${itemHeight}px`,
87
+ width: "100%"
88
+ }
89
+ },
90
+ renderItem(virtualRow.index)
91
+ ))
92
+ ), isLoading && (showCustomLoadingComponent ? LoadingComponent : /* @__PURE__ */ import_react.default.createElement(DefaultLoadingComponent, null)));
53
93
  };
54
94
  //# sourceMappingURL=VirtualList.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/pre-ldls/components/VirtualList/VirtualList.tsx"],
4
- "sourcesContent": ["import React, { ReactNode } from \"react\";\nimport { FixedSizeList as List } from \"react-window\";\nimport AutoSizer from \"react-virtualized-auto-sizer\";\n\nexport const VirtualList = ({\n count,\n itemHeight,\n renderItem,\n}: {\n count: number;\n itemHeight: number;\n renderItem: (index: number) => ReactNode;\n}) => {\n return (\n <AutoSizer style={{ height: \"100%\", width: \"100%\" }}>\n {({ height }: { height: number }) => (\n <List\n height={height}\n itemCount={count}\n itemSize={itemHeight}\n layout=\"vertical\"\n width=\"100%\"\n >\n {({ index, style }) => <div style={style}>{renderItem(index)}</div>}\n </List>\n )}\n </AutoSizer>\n );\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;AACjC,0BAAsC;AACtC,0CAAsB;AAEf,MAAM,cAAc,CAAC;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AACF,MAIM;AACJ,SACE,6BAAAA,QAAA,cAAC,oCAAAC,SAAA,EAAU,OAAO,EAAE,QAAQ,QAAQ,OAAO,OAAO,KAC/C,CAAC,EAAE,OAAO,MACT,6BAAAD,QAAA;AAAA,IAAC,oBAAAE;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,MACX,UAAU;AAAA,MACV,QAAO;AAAA,MACP,OAAM;AAAA;AAAA,IAEL,CAAC,EAAE,OAAO,MAAM,MAAM,6BAAAF,QAAA,cAAC,SAAI,SAAe,WAAW,KAAK,CAAE;AAAA,EAC/D,CAEJ;AAEJ;",
6
- "names": ["React", "AutoSizer", "List"]
4
+ "sourcesContent": ["import React, { useEffect, useRef } from \"react\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport { Flex, InfiniteLoader } from \"../../../components\";\n\ninterface VirtualItem {\n key: string | number | bigint;\n index: number;\n start: number;\n end: number;\n size: number;\n}\n\n/**\n * Props for the VirtualList component, which efficiently renders large lists\n * by virtualizing DOM nodes to improve performance.\n */\ntype VirtualListProps = {\n /**\n * Total number of items in the list.\n * This is used to calculate the total height of the list.\n */\n count: number;\n /**\n * Height of each item in the list.\n * This is used to calculate the total height of the list and the position of each item.\n */\n itemHeight: number;\n /**\n * Number of extra items to render outside the visible viewport for smoother scrolling.\n * Defaults to 5.\n */\n overscan?: number;\n /**\n * React component or node to display when the list is loading additional items.\n * If not provided, a default loading spinner will be used.\n */\n LoadingComponent?: React.ReactNode;\n /**\n * Indicates whether new items are currently being loaded.\n */\n isLoading?: boolean;\n /**\n * Indicates if there are more items to load.\n */\n hasNextPage?: boolean;\n /**\n * Number of items to check before the end of the list to trigger loading more items.\n * Defaults to 5.\n */\n threshold?: number;\n /**\n * Callback function to be called when the user scrolls to the end of the visible items.\n * This can be used to load more items when the user reaches the end of the list.\n */\n onVisibleItemsScrollEnd?: () => void;\n /**\n * Function to render each item in the list.\n * Receives the index of the item as an argument and should return a React node.\n */\n renderItem: (index: number) => React.ReactNode;\n};\n\nconst DefaultLoadingComponent = () => (\n <Flex justifyContent=\"center\" alignItems=\"center\" height=\"76px\">\n <InfiniteLoader />\n </Flex>\n);\n\nexport const VirtualList = ({\n count,\n itemHeight,\n overscan = 5,\n LoadingComponent,\n isLoading,\n hasNextPage = false,\n threshold = 5,\n onVisibleItemsScrollEnd,\n renderItem,\n}: VirtualListProps) => {\n const parentRef = useRef<HTMLDivElement>(null);\n\n const rowVirtualizer = useVirtualizer({\n count: hasNextPage ? count + 1 : count,\n getScrollElement: () => parentRef.current,\n estimateSize: () => itemHeight,\n overscan,\n });\n\n useEffect(() => {\n const items = rowVirtualizer.getVirtualItems();\n if (!items.length) return;\n const lastItem = items[items.length - 1];\n\n if (\n lastItem.index >= count - 1 - threshold &&\n hasNextPage &&\n !isLoading &&\n onVisibleItemsScrollEnd\n ) {\n onVisibleItemsScrollEnd();\n }\n }, [hasNextPage, onVisibleItemsScrollEnd, count, isLoading, rowVirtualizer.getVirtualItems()]);\n\n const showCustomLoadingComponent = !!LoadingComponent;\n\n return (\n <div ref={parentRef} style={{ width: \"100%\", height: \"100%\", overflow: \"auto\" }}>\n <div\n style={{\n height: `${rowVirtualizer.getTotalSize()}px`,\n width: \"100%\",\n position: \"relative\",\n }}\n >\n {rowVirtualizer.getVirtualItems().map((virtualRow: VirtualItem) => (\n <div\n key={virtualRow.index}\n data-index={virtualRow.index}\n ref={rowVirtualizer.measureElement}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n transform: `translateY(${virtualRow.start}px)`,\n height: `${itemHeight}px`,\n width: \"100%\",\n }}\n >\n {renderItem(virtualRow.index)}\n </div>\n ))}\n </div>\n {isLoading && (showCustomLoadingComponent ? LoadingComponent : <DefaultLoadingComponent />)}\n </div>\n );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyC;AACzC,2BAA+B;AAC/B,wBAAqC;AA4DrC,MAAM,0BAA0B,MAC9B,6BAAAA,QAAA,cAAC,0BAAK,gBAAe,UAAS,YAAW,UAAS,QAAO,UACvD,6BAAAA,QAAA,cAAC,sCAAe,CAClB;AAGK,MAAM,cAAc,CAAC;AAAA,EAC1B;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,YAAY;AAAA,EACZ;AAAA,EACA;AACF,MAAwB;AACtB,QAAM,gBAAY,qBAAuB,IAAI;AAE7C,QAAM,qBAAiB,qCAAe;AAAA,IACpC,OAAO,cAAc,QAAQ,IAAI;AAAA,IACjC,kBAAkB,MAAM,UAAU;AAAA,IAClC,cAAc,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AAED,8BAAU,MAAM;AACd,UAAM,QAAQ,eAAe,gBAAgB;AAC7C,QAAI,CAAC,MAAM;AAAQ;AACnB,UAAM,WAAW,MAAM,MAAM,SAAS,CAAC;AAEvC,QACE,SAAS,SAAS,QAAQ,IAAI,aAC9B,eACA,CAAC,aACD,yBACA;AACA,8BAAwB;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,aAAa,yBAAyB,OAAO,WAAW,eAAe,gBAAgB,CAAC,CAAC;AAE7F,QAAM,6BAA6B,CAAC,CAAC;AAErC,SACE,6BAAAA,QAAA,cAAC,SAAI,KAAK,WAAW,OAAO,EAAE,OAAO,QAAQ,QAAQ,QAAQ,UAAU,OAAO,KAC5E,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,QAAQ,GAAG,eAAe,aAAa,CAAC;AAAA,QACxC,OAAO;AAAA,QACP,UAAU;AAAA,MACZ;AAAA;AAAA,IAEC,eAAe,gBAAgB,EAAE,IAAI,CAAC,eACrC,6BAAAA,QAAA;AAAA,MAAC;AAAA;AAAA,QACC,KAAK,WAAW;AAAA,QAChB,cAAY,WAAW;AAAA,QACvB,KAAK,eAAe;AAAA,QACpB,OAAO;AAAA,UACL,UAAU;AAAA,UACV,KAAK;AAAA,UACL,MAAM;AAAA,UACN,WAAW,cAAc,WAAW,KAAK;AAAA,UACzC,QAAQ,GAAG,UAAU;AAAA,UACrB,OAAO;AAAA,QACT;AAAA;AAAA,MAEC,WAAW,WAAW,KAAK;AAAA,IAC9B,CACD;AAAA,EACH,GACC,cAAc,6BAA6B,mBAAmB,6BAAAA,QAAA,cAAC,6BAAwB,EAC1F;AAEJ;",
6
+ "names": ["React"]
7
7
  }
@@ -30,11 +30,13 @@ var VirtualList_stories_exports = {};
30
30
  __export(VirtualList_stories_exports, {
31
31
  Default: () => Default,
32
32
  TestVirtualList: () => TestVirtualList,
33
+ WithPagination: () => WithPagination,
33
34
  default: () => VirtualList_stories_default
34
35
  });
35
36
  module.exports = __toCommonJS(VirtualList_stories_exports);
36
37
  var import_react = __toESM(require("react"));
37
38
  var import_VirtualList = require("./VirtualList");
39
+ var import_addon_actions = require("@storybook/addon-actions");
38
40
  var import_test = require("@storybook/test");
39
41
  const meta = {
40
42
  component: import_VirtualList.VirtualList,
@@ -43,28 +45,123 @@ const meta = {
43
45
  ],
44
46
  title: "PreLdls/Components/VirtualList",
45
47
  tags: ["autodocs"],
48
+ parameters: {
49
+ layout: "fullscreen",
50
+ docs: {
51
+ description: {
52
+ component: "A virtualized list component that renders only the visible items in a scrollable container using the `useVirtualizer` hook from `@tanstack/react-virtual`. It supports pagination and custom item rendering."
53
+ }
54
+ }
55
+ },
56
+ argTypes: {
57
+ count: {
58
+ description: "Total number of items in the list."
59
+ },
60
+ itemHeight: {
61
+ description: "Height of each item in the list."
62
+ },
63
+ overscan: {
64
+ description: "Number of extra items to render outside the visible viewport for smoother scrolling.",
65
+ table: {
66
+ defaultValue: {
67
+ summary: "5"
68
+ }
69
+ }
70
+ },
71
+ LoadingComponent: {
72
+ description: "React component or node to display when the list is loading additional items. If not provided, a default loading spinner will be used."
73
+ },
74
+ isLoading: {
75
+ description: "Indicates whether new items are currently being loaded."
76
+ },
77
+ hasNextPage: {
78
+ description: "Indicates if there are more items to load. If true, the list will trigger loading more items when scrolled to the end.",
79
+ defaultValue: {
80
+ summary: "false"
81
+ }
82
+ },
83
+ threshold: {
84
+ description: "Number of items to check before the end of the list to trigger loading more items.",
85
+ defaultValue: {
86
+ summary: "5"
87
+ }
88
+ },
89
+ onVisibleItemsScrollEnd: {
90
+ description: "Callback function to be called when the user scrolls to the end of the visible items. This can be used to load more items when the user reaches the end of the list."
91
+ },
92
+ renderItem: {
93
+ description: "Function to render each item in the list. Receives the index of the item as an argument and should return a React node."
94
+ }
95
+ },
46
96
  args: {
47
97
  itemHeight: 64,
48
98
  count: 50,
49
- renderItem: (i) => /* @__PURE__ */ import_react.default.createElement("h1", { tabIndex: i }, "Item #", i)
99
+ LoadingComponent: void 0,
100
+ isLoading: false,
101
+ overscan: 5,
102
+ hasNextPage: false,
103
+ threshold: 5,
104
+ onVisibleItemsScrollEnd: () => {
105
+ },
106
+ renderItem: (index) => /* @__PURE__ */ import_react.default.createElement("h1", { tabIndex: index }, "Item #", index)
50
107
  }
51
108
  };
52
109
  var VirtualList_stories_default = meta;
53
- const Default = {};
110
+ const Default = {
111
+ args: {
112
+ count: 20,
113
+ itemHeight: 50,
114
+ overscan: 5,
115
+ renderItem: (index) => /* @__PURE__ */ import_react.default.createElement("div", { style: { height: 50, backgroundColor: "lightblue", border: "1px solid black" } }, "Item ", index)
116
+ }
117
+ };
118
+ const WithPagination = {
119
+ render: (args) => {
120
+ const [items, setItems] = (0, import_react.useState)(Array.from({ length: args.count }, (_, i) => i));
121
+ const [isFetching, setIsFetching] = (0, import_react.useState)(false);
122
+ const handleFetchNextPage = async () => {
123
+ (0, import_addon_actions.action)("fetchNextPage")();
124
+ if (isFetching)
125
+ return;
126
+ setIsFetching(true);
127
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
128
+ setItems((prev) => [...prev, ...Array.from({ length: 50 }, (_, i) => prev.length + i)]);
129
+ setIsFetching(false);
130
+ };
131
+ return /* @__PURE__ */ import_react.default.createElement(
132
+ import_VirtualList.VirtualList,
133
+ {
134
+ ...args,
135
+ count: items.length,
136
+ isLoading: isFetching,
137
+ onVisibleItemsScrollEnd: handleFetchNextPage,
138
+ hasNextPage: true,
139
+ renderItem: (index) => /* @__PURE__ */ import_react.default.createElement("div", { style: { height: 50, backgroundColor: "lightgreen", border: "1px solid black" } }, "Item ", items[index])
140
+ }
141
+ );
142
+ },
143
+ args: {
144
+ count: 50,
145
+ itemHeight: 50,
146
+ overscan: 5,
147
+ hasNextPage: true,
148
+ isLoading: false
149
+ }
150
+ };
54
151
  const TestVirtualList = {
55
152
  play: async ({ canvasElement }) => {
56
153
  const canvas = (0, import_test.within)(canvasElement);
57
- const visible = canvas.getAllByText(/Item #/i);
58
- const firstVisible = visible[0];
59
- const lastVisible = visible[visible.length - 1];
60
- await (0, import_test.expect)(visible.length).toBeLessThanOrEqual(10);
61
- await (0, import_test.expect)(firstVisible).toBeInTheDocument();
154
+ const visibleItems = canvas.getAllByText(/Item #/i);
155
+ const firstVisibleItem = visibleItems[0];
156
+ const lastVisibleItem = visibleItems[visibleItems.length - 1];
157
+ await (0, import_test.expect)(visibleItems.length).toBeLessThanOrEqual(12);
158
+ await (0, import_test.expect)(firstVisibleItem).toBeInTheDocument();
62
159
  await import_test.userEvent.pointer([
63
- { keys: "[TouchA>]", target: lastVisible },
64
- { target: firstVisible },
160
+ { keys: "[TouchA>]", target: lastVisibleItem },
161
+ { target: firstVisibleItem },
65
162
  { keys: "[/TouchA]" }
66
163
  ]);
67
- await (0, import_test.waitFor)(() => (0, import_test.expect)(firstVisible).not.toBeInTheDocument());
164
+ await (0, import_test.waitFor)(() => (0, import_test.expect)(firstVisibleItem).not.toBeInTheDocument());
68
165
  }
69
166
  };
70
167
  //# sourceMappingURL=VirtualList.stories.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/pre-ldls/components/VirtualList/VirtualList.stories.tsx"],
4
- "sourcesContent": ["import React from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { VirtualList } from \"./VirtualList\";\nimport { expect, userEvent, waitFor, within } from \"@storybook/test\";\n\nconst meta: Meta<typeof VirtualList> = {\n component: VirtualList,\n decorators: [\n Story => (\n <div style={{ height: \"400px\" }}>\n <Story />\n </div>\n ),\n ],\n title: \"PreLdls/Components/VirtualList\",\n tags: [\"autodocs\"],\n args: {\n itemHeight: 64,\n count: 50,\n renderItem: (i: number) => <h1 tabIndex={i}>Item #{i}</h1>,\n },\n};\nexport default meta;\n\ntype Story = StoryObj<typeof VirtualList>;\n\nexport const Default: Story = {};\n\nexport const TestVirtualList: Story = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n\n const visible = canvas.getAllByText(/Item #/i);\n const firstVisible = visible[0];\n const lastVisible = visible[visible.length - 1];\n\n await expect(visible.length).toBeLessThanOrEqual(10);\n\n await expect(firstVisible).toBeInTheDocument();\n await userEvent.pointer([\n { keys: \"[TouchA>]\", target: lastVisible },\n { target: firstVisible },\n { keys: \"[/TouchA]\" },\n ]);\n await waitFor(() => expect(firstVisible).not.toBeInTheDocument());\n },\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,yBAA4B;AAC5B,kBAAmD;AAEnD,MAAM,OAAiC;AAAA,EACrC,WAAW;AAAA,EACX,YAAY;AAAA,IACV,WACE,6BAAAA,QAAA,cAAC,SAAI,OAAO,EAAE,QAAQ,QAAQ,KAC5B,6BAAAA,QAAA,cAAC,WAAM,CACT;AAAA,EAEJ;AAAA,EACA,OAAO;AAAA,EACP,MAAM,CAAC,UAAU;AAAA,EACjB,MAAM;AAAA,IACJ,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,YAAY,CAAC,MAAc,6BAAAA,QAAA,cAAC,QAAG,UAAU,KAAG,UAAO,CAAE;AAAA,EACvD;AACF;AACA,IAAO,8BAAQ;AAIR,MAAM,UAAiB,CAAC;AAExB,MAAM,kBAAyB;AAAA,EACpC,MAAM,OAAO,EAAE,cAAc,MAAM;AACjC,UAAM,aAAS,oBAAO,aAAa;AAEnC,UAAM,UAAU,OAAO,aAAa,SAAS;AAC7C,UAAM,eAAe,QAAQ,CAAC;AAC9B,UAAM,cAAc,QAAQ,QAAQ,SAAS,CAAC;AAE9C,cAAM,oBAAO,QAAQ,MAAM,EAAE,oBAAoB,EAAE;AAEnD,cAAM,oBAAO,YAAY,EAAE,kBAAkB;AAC7C,UAAM,sBAAU,QAAQ;AAAA,MACtB,EAAE,MAAM,aAAa,QAAQ,YAAY;AAAA,MACzC,EAAE,QAAQ,aAAa;AAAA,MACvB,EAAE,MAAM,YAAY;AAAA,IACtB,CAAC;AACD,cAAM,qBAAQ,UAAM,oBAAO,YAAY,EAAE,IAAI,kBAAkB,CAAC;AAAA,EAClE;AACF;",
4
+ "sourcesContent": ["import React, { useState } from \"react\";\nimport type { Meta, StoryObj } from \"@storybook/react\";\nimport { VirtualList } from \"./VirtualList\";\nimport { action } from \"@storybook/addon-actions\";\nimport { expect, userEvent, waitFor, within } from \"@storybook/test\";\n\nconst meta: Meta<typeof VirtualList> = {\n component: VirtualList,\n decorators: [\n Story => (\n <div style={{ height: \"400px\" }}>\n <Story />\n </div>\n ),\n ],\n title: \"PreLdls/Components/VirtualList\",\n tags: [\"autodocs\"],\n parameters: {\n layout: \"fullscreen\",\n docs: {\n description: {\n component:\n \"A virtualized list component that renders only the visible items in a scrollable container using the `useVirtualizer` hook from `@tanstack/react-virtual`. It supports pagination and custom item rendering.\",\n },\n },\n },\n argTypes: {\n count: {\n description: \"Total number of items in the list.\",\n },\n itemHeight: {\n description: \"Height of each item in the list.\",\n },\n overscan: {\n description:\n \"Number of extra items to render outside the visible viewport for smoother scrolling.\",\n table: {\n defaultValue: {\n summary: \"5\",\n },\n },\n },\n LoadingComponent: {\n description:\n \"React component or node to display when the list is loading additional items. If not provided, a default loading spinner will be used.\",\n },\n isLoading: {\n description: \"Indicates whether new items are currently being loaded.\",\n },\n hasNextPage: {\n description:\n \"Indicates if there are more items to load. If true, the list will trigger loading more items when scrolled to the end.\",\n defaultValue: {\n summary: \"false\",\n },\n },\n threshold: {\n description:\n \"Number of items to check before the end of the list to trigger loading more items.\",\n defaultValue: {\n summary: \"5\",\n },\n },\n onVisibleItemsScrollEnd: {\n description:\n \"Callback function to be called when the user scrolls to the end of the visible items. This can be used to load more items when the user reaches the end of the list.\",\n },\n renderItem: {\n description:\n \"Function to render each item in the list. Receives the index of the item as an argument and should return a React node.\",\n },\n },\n args: {\n itemHeight: 64,\n count: 50,\n LoadingComponent: undefined,\n isLoading: false,\n overscan: 5,\n hasNextPage: false,\n threshold: 5,\n onVisibleItemsScrollEnd: () => {},\n renderItem: (index: number) => <h1 tabIndex={index}>Item #{index}</h1>,\n },\n};\nexport default meta;\n\ntype Story = StoryObj<typeof VirtualList>;\n\nexport const Default: Story = {\n args: {\n count: 20,\n itemHeight: 50,\n overscan: 5,\n renderItem: (index: number) => (\n <div style={{ height: 50, backgroundColor: \"lightblue\", border: \"1px solid black\" }}>\n Item {index}\n </div>\n ),\n },\n};\n\nexport const WithPagination: Story = {\n render: args => {\n const [items, setItems] = useState(Array.from({ length: args.count }, (_, i) => i));\n const [isFetching, setIsFetching] = useState(false);\n\n const handleFetchNextPage = async () => {\n action(\"fetchNextPage\")();\n if (isFetching) return;\n setIsFetching(true);\n await new Promise(resolve => setTimeout(resolve, 1000));\n setItems(prev => [...prev, ...Array.from({ length: 50 }, (_, i) => prev.length + i)]);\n setIsFetching(false);\n };\n\n return (\n <VirtualList\n {...args}\n count={items.length}\n isLoading={isFetching}\n onVisibleItemsScrollEnd={handleFetchNextPage}\n hasNextPage={true}\n renderItem={index => (\n <div style={{ height: 50, backgroundColor: \"lightgreen\", border: \"1px solid black\" }}>\n Item {items[index]}\n </div>\n )}\n />\n );\n },\n args: {\n count: 50,\n itemHeight: 50,\n overscan: 5,\n hasNextPage: true,\n isLoading: false,\n },\n};\n\nexport const TestVirtualList: Story = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n\n const visibleItems = canvas.getAllByText(/Item #/i);\n const firstVisibleItem = visibleItems[0];\n const lastVisibleItem = visibleItems[visibleItems.length - 1];\n\n // need to add 5 due to the overscan set to 5 (it renders 5 items before and after the visible items)\n await expect(visibleItems.length).toBeLessThanOrEqual(12);\n\n await expect(firstVisibleItem).toBeInTheDocument();\n\n await userEvent.pointer([\n { keys: \"[TouchA>]\", target: lastVisibleItem },\n { target: firstVisibleItem },\n { keys: \"[/TouchA]\" },\n ]);\n\n await waitFor(() => expect(firstVisibleItem).not.toBeInTheDocument());\n },\n};\n"],
5
+ "mapp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ACJ,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,aAAa;AAAA,IACb,WAAW;AAAA,EACb;AACF;AAEO,MAAM,kBAAyB;AAAA,EACpC,MAAM,OAAO,EAAE,cAAc,MAAM;AACjC,UAAM,aAAS,oBAAO,aAAa;AAEnC,UAAM,eAAe,OAAO,aAAa,SAAS;AAClD,UAAM,mBAAmB,aAAa,CAAC;AACvC,UAAM,kBAAkB,aAAa,aAAa,SAAS,CAAC;AAG5D,cAAM,oBAAO,aAAa,MAAM,EAAE,oBAAoB,EAAE;AAExD,cAAM,oBAAO,gBAAgB,EAAE,kBAAkB;AAEjD,UAAM,sBAAU,QAAQ;AAAA,MACtB,EAAE,MAAM,aAAa,QAAQ,gBAAgB;AAAA,MAC7C,EAAE,QAAQ,iBAAiB;AAAA,MAC3B,EAAE,MAAM,YAAY;AAAA,IACtB,CAAC;AAED,cAAM,qBAAQ,UAAM,oBAAO,gBAAgB,EAAE,IAAI,kBAAkB,CAAC;AAAA,EACtE;AACF;",
6
6
  "names": ["React"]
7
7
  }
@@ -18,6 +18,8 @@ module.exports = __toCommonJS(components_exports);
18
18
  __reExport(components_exports, require("./AssetItem/AssetItem"), module.exports);
19
19
  __reExport(components_exports, require("./AssetList/AssetList"), module.exports);
20
20
  __reExport(components_exports, require("./Input/Input"), module.exports);
21
+ __reExport(components_exports, require("./NetworkItem/NetworkItem"), module.exports);
22
+ __reExport(components_exports, require("./NetworkList/NetworkList"), module.exports);
21
23
  __reExport(components_exports, require("./Search/Search"), module.exports);
22
24
  __reExport(components_exports, require("./VirtualList/VirtualList"), module.exports);
23
25
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/pre-ldls/components/index.ts"],
4
- "sourcesContent": ["export * from \"./AssetItem/AssetItem\";\nexport * from \"./AssetList/AssetList\";\nexport * from \"./Input/Input\";\nexport * from \"./Search/Search\";\nexport * from \"./VirtualList/VirtualList\";\n"],
5
- "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,kCAAd;AACA,+BAAc,kCADd;AAEA,+BAAc,0BAFd;AAGA,+BAAc,4BAHd;AAIA,+BAAc,sCAJd;",
4
+ "sourcesContent": ["export * from \"./AssetItem/AssetItem\";\nexport * from \"./AssetList/AssetList\";\nexport * from \"./Input/Input\";\nexport * from \"./NetworkItem/NetworkItem\";\nexport * from \"./NetworkList/NetworkList\";\nexport * from \"./Search/Search\";\nexport * from \"./VirtualList/VirtualList\";\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,kCAAd;AACA,+BAAc,kCADd;AAEA,+BAAc,0BAFd;AAGA,+BAAc,sCAHd;AAIA,+BAAc,sCAJd;AAKA,+BAAc,4BALd;AAMA,+BAAc,sCANd;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ type NetworkItemProps = {
3
+ name: string;
4
+ onClick: () => void;
5
+ };
6
+ export declare const NetworkItem: ({ name, onClick }: NetworkItemProps) => React.JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=NetworkItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkItem.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/NetworkItem/NetworkItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AA6CF,eAAO,MAAM,WAAW,sBAAuB,gBAAgB,sBAe9D,CAAC"}
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+ import styled from "styled-components";
3
+ import { withTokens } from "../../libs";
4
+ import { Text } from "../../../components";
5
+ const TempAssetBadge = () => (
6
+ // TODO: To be replaced with LIVE-18221
7
+ React.createElement("div", { style: { display: "flex", alignItems: "center" } },
8
+ React.createElement("span", { style: {
9
+ height: 48,
10
+ width: 48,
11
+ borderRadius: 48,
12
+ backgroundColor: "grey",
13
+ display: "inline-block",
14
+ } })));
15
+ const Wrapper = styled.div `
16
+ ${withTokens("spacing-xs", "marging-s", "colors-content-default-default", "colors-surface-transparent-hover", "colors-surface-transparent-pressed")}
17
+ display: flex;
18
+ padding: var(--spacing-xs);
19
+ cursor: pointer;
20
+
21
+ :hover {
22
+ background-color: var(--colors-surface-transparent-hover);
23
+ }
24
+
25
+ :active {
26
+ background-color: var(--colors-surface-transparent-pressed);
27
+ }
28
+ `;
29
+ const InfoWrapper = styled.div `
30
+ display: flex;
31
+ flex-direction: column;
32
+ justify-content: center;
33
+ margin-left: var(--marging-s);
34
+ `;
35
+ export const NetworkItem = ({ name, onClick }) => {
36
+ return (React.createElement(Wrapper, { onClick: onClick },
37
+ React.createElement(TempAssetBadge, null),
38
+ React.createElement(InfoWrapper, null,
39
+ React.createElement(Text, { variant: "largeLineHeight", fontWeight: "semiBold", color: "var(--colors-content-default-default)" }, name))));
40
+ };
41
+ //# sourceMappingURL=NetworkItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkItem.js","sourceRoot":"","sources":["../../../../src/pre-ldls/components/NetworkItem/NetworkItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAO3C,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC;AAC3B,uCAAuC;AACvC,6BAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE;IACnD,8BACE,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE;YACT,YAAY,EAAE,EAAE;YAChB,eAAe,EAAE,MAAM;YACvB,OAAO,EAAE,cAAc;SACxB,GACD,CACE,CACP,CAAC;AAEF,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAA;IACtB,UAAU,CACV,YAAY,EACZ,WAAW,EACX,gCAAgC,EAChC,kCAAkC,EAClC,oCAAoC,CACrC;;;;;;;;;;;;CAYF,CAAC;AAEF,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAK7B,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAoB,EAAE,EAAE;IACjE,OAAO,CACL,oBAAC,OAAO,IAAC,OAAO,EAAE,OAAO;QACvB,oBAAC,cAAc,OAAG;QAClB,oBAAC,WAAW;YACV,oBAAC,IAAI,IACH,OAAO,EAAC,iBAAiB,EACzB,UAAU,EAAC,UAAU,EACrB,KAAK,EAAC,uCAAuC,IAE5C,IAAI,CACA,CACK,CACN,CACX,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ export declare const NetworkList: ({ networks, onClick, }: {
3
+ networks: {
4
+ name: string;
5
+ id: string;
6
+ }[];
7
+ onClick: (networkId: string) => void;
8
+ }) => React.JSX.Element;
9
+ //# sourceMappingURL=NetworkList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkList.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/NetworkList/NetworkList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,WAAW;cAIZ;QAAE,MAAM,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE;yBACnB,MAAM,KAAK,IAAI;uBAWrC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { NetworkItem } from "../NetworkItem/NetworkItem";
3
+ import { VirtualList } from "../VirtualList/VirtualList";
4
+ export const NetworkList = ({ networks, onClick, }) => {
5
+ return (React.createElement(VirtualList, { itemHeight: 64, count: networks.length, renderItem: (i) => (React.createElement(NetworkItem, { name: networks[i].name, onClick: () => onClick(networks[i].id) })) }));
6
+ };
7
+ //# sourceMappingURL=NetworkList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkList.js","sourceRoot":"","sources":["../../../../src/pre-ldls/components/NetworkList/NetworkList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,QAAQ,EACR,OAAO,GAIR,EAAE,EAAE;IACH,OAAO,CACL,oBAAC,WAAW,IACV,UAAU,EAAE,EAAE,EACd,KAAK,EAAE,QAAQ,CAAC,MAAM,EACtB,UAAU,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CACzB,oBAAC,WAAW,IAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAI,CAChF,GACD,CACH,CAAC;AACJ,CAAC,CAAC"}
@@ -1,7 +1,53 @@
1
- import React, { ReactNode } from "react";
2
- export declare const VirtualList: ({ count, itemHeight, renderItem, }: {
1
+ import React from "react";
2
+ /**
3
+ * Props for the VirtualList component, which efficiently renders large lists
4
+ * by virtualizing DOM nodes to improve performance.
5
+ */
6
+ type VirtualListProps = {
7
+ /**
8
+ * Total number of items in the list.
9
+ * This is used to calculate the total height of the list.
10
+ */
3
11
  count: number;
12
+ /**
13
+ * Height of each item in the list.
14
+ * This is used to calculate the total height of the list and the position of each item.
15
+ */
4
16
  itemHeight: number;
5
- renderItem: (index: number) => ReactNode;
6
- }) => React.JSX.Element;
17
+ /**
18
+ * Number of extra items to render outside the visible viewport for smoother scrolling.
19
+ * Defaults to 5.
20
+ */
21
+ overscan?: number;
22
+ /**
23
+ * React component or node to display when the list is loading additional items.
24
+ * If not provided, a default loading spinner will be used.
25
+ */
26
+ LoadingComponent?: React.ReactNode;
27
+ /**
28
+ * Indicates whether new items are currently being loaded.
29
+ */
30
+ isLoading?: boolean;
31
+ /**
32
+ * Indicates if there are more items to load.
33
+ */
34
+ hasNextPage?: boolean;
35
+ /**
36
+ * Number of items to check before the end of the list to trigger loading more items.
37
+ * Defaults to 5.
38
+ */
39
+ threshold?: number;
40
+ /**
41
+ * Callback function to be called when the user scrolls to the end of the visible items.
42
+ * This can be used to load more items when the user reaches the end of the list.
43
+ */
44
+ onVisibleItemsScrollEnd?: () => void;
45
+ /**
46
+ * Function to render each item in the list.
47
+ * Receives the index of the item as an argument and should return a React node.
48
+ */
49
+ renderItem: (index: number) => React.ReactNode;
50
+ };
51
+ export declare const VirtualList: ({ count, itemHeight, overscan, LoadingComponent, isLoading, hasNextPage, threshold, onVisibleItemsScrollEnd, renderItem, }: VirtualListProps) => React.JSX.Element;
52
+ export {};
7
53
  //# sourceMappingURL=VirtualList.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualList.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/VirtualList/VirtualList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIzC,eAAO,MAAM,WAAW;WAKf,MAAM;gBACD,MAAM;wBACE,MAAM,KAAK,SAAS;uBAiBzC,CAAC"}
1
+ {"version":3,"file":"VirtualList.d.ts","sourceRoot":"","sources":["../../../../src/pre-ldls/components/VirtualList/VirtualList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAYjD;;;GAGG;AACH,KAAK,gBAAgB,GAAG;IACtB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,IAAI,CAAC;IACrC;;;OAGG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CAChD,CAAC;AAQF,eAAO,MAAM,WAAW,+HAUrB,gBAAgB,sBAyDlB,CAAC"}
@@ -1,7 +1,42 @@
1
- import React from "react";
2
- import { FixedSizeList as List } from "react-window";
3
- import AutoSizer from "react-virtualized-auto-sizer";
4
- export const VirtualList = ({ count, itemHeight, renderItem, }) => {
5
- return (React.createElement(AutoSizer, { style: { height: "100%", width: "100%" } }, ({ height }) => (React.createElement(List, { height: height, itemCount: count, itemSize: itemHeight, layout: "vertical", width: "100%" }, ({ index, style }) => React.createElement("div", { style: style }, renderItem(index))))));
1
+ import React, { useEffect, useRef } from "react";
2
+ import { useVirtualizer } from "@tanstack/react-virtual";
3
+ import { Flex, InfiniteLoader } from "../../../components";
4
+ const DefaultLoadingComponent = () => (React.createElement(Flex, { justifyContent: "center", alignItems: "center", height: "76px" },
5
+ React.createElement(InfiniteLoader, null)));
6
+ export const VirtualList = ({ count, itemHeight, overscan = 5, LoadingComponent, isLoading, hasNextPage = false, threshold = 5, onVisibleItemsScrollEnd, renderItem, }) => {
7
+ const parentRef = useRef(null);
8
+ const rowVirtualizer = useVirtualizer({
9
+ count: hasNextPage ? count + 1 : count,
10
+ getScrollElement: () => parentRef.current,
11
+ estimateSize: () => itemHeight,
12
+ overscan,
13
+ });
14
+ useEffect(() => {
15
+ const items = rowVirtualizer.getVirtualItems();
16
+ if (!items.length)
17
+ return;
18
+ const lastItem = items[items.length - 1];
19
+ if (lastItem.index >= count - 1 - threshold &&
20
+ hasNextPage &&
21
+ !isLoading &&
22
+ onVisibleItemsScrollEnd) {
23
+ onVisibleItemsScrollEnd();
24
+ }
25
+ }, [hasNextPage, onVisibleItemsScrollEnd, count, isLoading, rowVirtualizer.getVirtualItems()]);
26
+ const showCustomLoadingComponent = !!LoadingComponent;
27
+ return (React.createElement("div", { ref: parentRef, style: { width: "100%", height: "100%", overflow: "auto" } },
28
+ React.createElement("div", { style: {
29
+ height: `${rowVirtualizer.getTotalSize()}px`,
30
+ width: "100%",
31
+ position: "relative",
32
+ } }, rowVirtualizer.getVirtualItems().map((virtualRow) => (React.createElement("div", { key: virtualRow.index, "data-index": virtualRow.index, ref: rowVirtualizer.measureElement, style: {
33
+ position: "absolute",
34
+ top: 0,
35
+ left: 0,
36
+ transform: `translateY(${virtualRow.start}px)`,
37
+ height: `${itemHeight}px`,
38
+ width: "100%",
39
+ } }, renderItem(virtualRow.index))))),
40
+ isLoading && (showCustomLoadingComponent ? LoadingComponent : React.createElement(DefaultLoadingComponent, null))));
6
41
  };
7
42
  //# sourceMappingURL=VirtualList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualList.js","sourceRoot":"","sources":["../../../../src/pre-ldls/components/VirtualList/VirtualList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,SAAS,MAAM,8BAA8B,CAAC;AAErD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,KAAK,EACL,UAAU,EACV,UAAU,GAKX,EAAE,EAAE;IACH,OAAO,CACL,oBAAC,SAAS,IAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAChD,CAAC,EAAE,MAAM,EA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EAAE,GAAG,UAAU,IAAI;gBACzB,KAAK,EAAE,MAAM;aACd,IAEA,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CACzB,CACP,CAAC,CACE;QACL,SAAS,IAAI,CAAC,0BAA0B,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,oBAAC,uBAAuB,OAAG,CAAC,CACvF,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -1,6 +1,8 @@
1
1
  export * from "./AssetItem/AssetItem";
2
2
  export * from "./AssetList/AssetList";
3
3
  export * from "./Input/Input";
4
+ export * from "./NetworkItem/NetworkItem";
5
+ export * from "./NetworkList/NetworkList";
4
6
  export * from "./Search/Search";
5
7
  export * from "./VirtualList/VirtualList";
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pre-ldls/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pre-ldls/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC"}
@@ -1,6 +1,8 @@
1
1
  export * from "./AssetItem/AssetItem";
2
2
  export * from "./AssetList/AssetList";
3
3
  export * from "./Input/Input";
4
+ export * from "./NetworkItem/NetworkItem";
5
+ export * from "./NetworkList/NetworkList";
4
6
  export * from "./Search/Search";
5
7
  export * from "./VirtualList/VirtualList";
6
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pre-ldls/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pre-ldls/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/react-ui",
3
- "version": "0.24.0-next.0",
3
+ "version": "0.24.0-nightly.3",
4
4
  "description": "Ledger Live - Desktop UI",
5
5
  "author": "Ledger Live Team <team-live@ledger.fr>",
6
6
  "repository": {
@@ -61,6 +61,7 @@
61
61
  ],
62
62
  "dependencies": {
63
63
  "@floating-ui/react-dom": "^0.4.0",
64
+ "@tanstack/react-virtual": "3.13.6",
64
65
  "@tippyjs/react": "^4.2.6",
65
66
  "color": "^4.0.0",
66
67
  "embla-carousel-autoplay": "8.4.0",
@@ -71,11 +72,10 @@
71
72
  "react-select": "^5.2.1",
72
73
  "react-spring": "8.0.27",
73
74
  "react-transition-group": "^4.4.2",
74
- "react-virtualized-auto-sizer": "1.0.24",
75
75
  "react-window": "^1.8.6",
76
76
  "styled-system": "^5.1.5",
77
- "@ledgerhq/crypto-icons-ui": "^1.13.0-next.0",
78
- "@ledgerhq/icons-ui": "^0.10.0-next.0",
77
+ "@ledgerhq/crypto-icons-ui": "^1.13.0-nightly.0",
78
+ "@ledgerhq/icons-ui": "^0.10.0-nightly.0",
79
79
  "@ledgerhq/ui-shared": "^0.3.0"
80
80
  },
81
81
  "peerDependencies": {