@elliemae/ds-fast-list 3.80.0-next.4 → 3.80.0-next.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/FastList.js +2 -2
- package/dist/cjs/FastList.js.map +2 -2
- package/dist/cjs/{DSFastListDefinitions.js → constants/index.js} +8 -7
- package/dist/cjs/constants/index.js.map +7 -0
- package/dist/cjs/hooks/useFastList.js +35 -6
- package/dist/cjs/hooks/useFastList.js.map +2 -2
- package/dist/cjs/hooks/useValidateProps.js +2 -2
- package/dist/cjs/hooks/useValidateProps.js.map +2 -2
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/parts/List.js +36 -28
- package/dist/cjs/parts/List.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js +40 -4
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/{FastListDataTestID.js → typescript-testing/slot-props.js} +13 -13
- package/dist/cjs/typescript-testing/slot-props.js.map +7 -0
- package/dist/cjs/typescript-testing/typescript-fast-list-valid.js +87 -4
- package/dist/cjs/typescript-testing/typescript-fast-list-valid.js.map +2 -2
- package/dist/esm/FastList.js +1 -1
- package/dist/esm/FastList.js.map +1 -1
- package/dist/esm/{DSFastListDefinitions.js → constants/index.js} +5 -4
- package/dist/esm/constants/index.js.map +7 -0
- package/dist/esm/hooks/useFastList.js +35 -6
- package/dist/esm/hooks/useFastList.js.map +2 -2
- package/dist/esm/hooks/useValidateProps.js +1 -1
- package/dist/esm/hooks/useValidateProps.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/parts/List.js +31 -23
- package/dist/esm/parts/List.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js +41 -5
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/typescript-testing/slot-props.js +15 -0
- package/dist/esm/typescript-testing/slot-props.js.map +7 -0
- package/dist/esm/typescript-testing/typescript-fast-list-valid.js +87 -4
- package/dist/esm/typescript-testing/typescript-fast-list-valid.js.map +2 -2
- package/dist/types/constants/index.d.ts +13 -0
- package/dist/types/hooks/useFastList.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/react-desc-prop-types.d.ts +34 -4
- package/package.json +10 -9
- package/dist/cjs/DSFastListDefinitions.js.map +0 -7
- package/dist/cjs/FastListDataTestID.js.map +0 -7
- package/dist/esm/DSFastListDefinitions.js.map +0 -7
- package/dist/esm/FastListDataTestID.js +0 -8
- package/dist/esm/FastListDataTestID.js.map +0 -7
- package/dist/types/DSFastListDefinitions.d.ts +0 -11
- package/dist/types/FastListDataTestID.d.ts +0 -3
|
@@ -29,6 +29,9 @@ const data = [1, 2, 3];
|
|
|
29
29
|
const extraProps = { data };
|
|
30
30
|
const MockItemRenderer = ({ index }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {});
|
|
31
31
|
const actionRef = (0, import_react.createRef)();
|
|
32
|
+
const innerRefObject = (0, import_react.createRef)();
|
|
33
|
+
const innerRefCallback = (node) => {
|
|
34
|
+
};
|
|
32
35
|
const testRequiredProps = {
|
|
33
36
|
ItemRenderer: MockItemRenderer,
|
|
34
37
|
count: 0,
|
|
@@ -36,7 +39,9 @@ const testRequiredProps = {
|
|
|
36
39
|
};
|
|
37
40
|
const testOptionalProps = {
|
|
38
41
|
actionRef,
|
|
39
|
-
extraItemProps: { data }
|
|
42
|
+
extraItemProps: { data },
|
|
43
|
+
innerRef: innerRefObject,
|
|
44
|
+
extraContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", children: "Load more" })
|
|
40
45
|
};
|
|
41
46
|
const testPartialDefaults = {};
|
|
42
47
|
const testProps = {
|
|
@@ -50,7 +55,10 @@ const testPropsAsSyntax = {
|
|
|
50
55
|
...testPartialDefaults
|
|
51
56
|
};
|
|
52
57
|
const testCompleteDefaults = {
|
|
53
|
-
estimateSize: () => 36
|
|
58
|
+
estimateSize: () => 36,
|
|
59
|
+
paddingStart: 0,
|
|
60
|
+
paddingEnd: 0,
|
|
61
|
+
remountOnCountChange: true
|
|
54
62
|
};
|
|
55
63
|
const testInternalProps = {
|
|
56
64
|
...testRequiredProps,
|
|
@@ -69,7 +77,7 @@ const testExplicitDefinition = {
|
|
|
69
77
|
actionRef,
|
|
70
78
|
extraItemProps: { data }
|
|
71
79
|
};
|
|
72
|
-
const
|
|
80
|
+
const testInferredTypeCompatibility = {
|
|
73
81
|
ItemRenderer: MockItemRenderer,
|
|
74
82
|
count: 0,
|
|
75
83
|
getId: (index) => "",
|
|
@@ -83,10 +91,59 @@ const testDefinitionAsConst = {
|
|
|
83
91
|
actionRef,
|
|
84
92
|
extraItemProps: { foo: "bar" }
|
|
85
93
|
};
|
|
94
|
+
const testGlobalAttributes = {
|
|
95
|
+
ItemRenderer: MockItemRenderer,
|
|
96
|
+
count: 0,
|
|
97
|
+
getId: (index) => "",
|
|
98
|
+
className: "custom-class",
|
|
99
|
+
id: "custom-id",
|
|
100
|
+
"aria-label": "custom list"
|
|
101
|
+
};
|
|
102
|
+
const testContainerIntegration = {
|
|
103
|
+
...testRequiredProps,
|
|
104
|
+
innerRef: innerRefCallback,
|
|
105
|
+
paddingStart: 24,
|
|
106
|
+
paddingEnd: -5,
|
|
107
|
+
remountOnCountChange: false,
|
|
108
|
+
extraContent: null
|
|
109
|
+
};
|
|
110
|
+
const testContainerIntegrationAsSyntax = {
|
|
111
|
+
...testRequiredProps,
|
|
112
|
+
innerRef: innerRefObject,
|
|
113
|
+
paddingStart: 24,
|
|
114
|
+
paddingEnd: 40,
|
|
115
|
+
remountOnCountChange: true,
|
|
116
|
+
extraContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "extra" })
|
|
117
|
+
};
|
|
118
|
+
const testContainerIntegrationAsConst = {
|
|
119
|
+
...testRequiredProps,
|
|
120
|
+
paddingStart: 0,
|
|
121
|
+
paddingEnd: 0,
|
|
122
|
+
remountOnCountChange: false
|
|
123
|
+
};
|
|
124
|
+
const publishedScrollToOptions = { align: "start" };
|
|
125
|
+
const publishedAlign = publishedScrollToOptions.align;
|
|
126
|
+
const scrollActionOptions = { behavior: "smooth" };
|
|
127
|
+
const handleScrollToWithActionOptions = () => actionRef.current.scrollTo?.(1, scrollActionOptions);
|
|
128
|
+
const handleScrollToWithPublishedOptions = () => actionRef.current.scrollTo?.(1, publishedScrollToOptions);
|
|
129
|
+
const handleScrollToAlign = () => actionRef.current.scrollTo?.(1, { align: "center" });
|
|
130
|
+
const handleScrollToBehavior = () => actionRef.current.scrollTo?.(1, { behavior: "smooth" });
|
|
131
|
+
const handleScrollToBoth = () => actionRef.current.scrollTo?.(1, { align: "end", behavior: "auto" });
|
|
132
|
+
const handleMeasure = () => actionRef.current.measure?.();
|
|
133
|
+
const handleGetVisibleItems = () => actionRef.current.getVisibleItems?.() ?? [];
|
|
134
|
+
const handleGetMountedItems = () => actionRef.current.getMountedItems?.() ?? [];
|
|
135
|
+
const handleGetOffsetForIndex = () => actionRef.current.getOffsetForIndex?.(1);
|
|
136
|
+
const handleGetOffsetForIndexAligned = () => actionRef.current.getOffsetForIndex?.(1, "center");
|
|
137
|
+
const handleScrollToOffset = () => actionRef.current.scrollToOffset?.(100);
|
|
138
|
+
const handleScrollToOffsetWithOptions = () => actionRef.current.scrollToOffset?.(100, { behavior: "auto" });
|
|
86
139
|
const ExampleUsageComponent = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
87
140
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSFastList, { ...testExplicitDefinition }),
|
|
88
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSFastList, { ...
|
|
141
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSFastList, { ...testInferredTypeCompatibility }),
|
|
89
142
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSFastList, { ...testDefinitionAsConst }),
|
|
143
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSFastList, { ...testGlobalAttributes }),
|
|
144
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSFastList, { ...testContainerIntegration }),
|
|
145
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSFastList, { ...testContainerIntegrationAsSyntax }),
|
|
146
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSFastList, { ...testContainerIntegrationAsConst }),
|
|
90
147
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
91
148
|
import__.DSFastList,
|
|
92
149
|
{
|
|
@@ -96,6 +153,32 @@ const ExampleUsageComponent = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)
|
|
|
96
153
|
actionRef,
|
|
97
154
|
extraItemProps: { foo: "bar" }
|
|
98
155
|
}
|
|
156
|
+
),
|
|
157
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
158
|
+
import__.DSFastList,
|
|
159
|
+
{
|
|
160
|
+
ItemRenderer: MockItemRenderer,
|
|
161
|
+
count: 0,
|
|
162
|
+
getId: (index) => "",
|
|
163
|
+
innerRef: innerRefObject,
|
|
164
|
+
paddingStart: 24,
|
|
165
|
+
paddingEnd: -5,
|
|
166
|
+
remountOnCountChange: false,
|
|
167
|
+
extraContent: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", children: "Load more" }),
|
|
168
|
+
dsFastlistExtraContent: { role: "listitem" }
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
172
|
+
import__.DSFastList,
|
|
173
|
+
{
|
|
174
|
+
className: "custom-class",
|
|
175
|
+
id: "custom-id",
|
|
176
|
+
"aria-label": "custom list",
|
|
177
|
+
"data-testid": "custom-testid",
|
|
178
|
+
ItemRenderer: MockItemRenderer,
|
|
179
|
+
count: 0,
|
|
180
|
+
getId: (index) => ""
|
|
181
|
+
}
|
|
99
182
|
)
|
|
100
183
|
] });
|
|
101
184
|
//# sourceMappingURL=typescript-fast-list-valid.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/typescript-fast-list-valid.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { type MutableRefObject, createRef } from 'react';\nimport { DSFastList } from '../index.js';\nimport type { DSFastListT } from '../index.js';\n\nconst data = [1, 2, 3];\nconst extraProps = { data };\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSFastListT.Props<typeof extraProps>;\ntype ComponentPropsInternals = DSFastListT.InternalProps<typeof extraProps>;\ntype ComponentPropsDefaultProps = DSFastListT.DefaultProps;\ntype ComponentPropsOptionalProps = DSFastListT.OptionalProps<typeof extraProps>;\ntype ComponentPropsRequiredProps = DSFastListT.RequiredProps<typeof extraProps>;\n\nconst MockItemRenderer = ({ index }: { index: number }) => <div></div>;\n\nconst actionRef = createRef() as MutableRefObject<
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACcoC;AAb3D,mBAAiD;AACjD,eAA2B;AAG3B,MAAM,OAAO,CAAC,GAAG,GAAG,CAAC;AACrB,MAAM,aAAa,EAAE,KAAK;AAQ1B,MAAM,mBAAmB,CAAC,EAAE,MAAM,MAAyB,4CAAC,SAAI;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { type MutableRefObject, createRef } from 'react';\nimport { DSFastList } from '../index.js';\nimport type { DSFastListT } from '../index.js';\n\nconst data = [1, 2, 3];\nconst extraProps = { data };\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSFastListT.Props<typeof extraProps>;\ntype ComponentPropsInternals = DSFastListT.InternalProps<typeof extraProps>;\ntype ComponentPropsDefaultProps = DSFastListT.DefaultProps;\ntype ComponentPropsOptionalProps = DSFastListT.OptionalProps<typeof extraProps>;\ntype ComponentPropsRequiredProps = DSFastListT.RequiredProps<typeof extraProps>;\n\nconst MockItemRenderer = ({ index }: { index: number }) => <div></div>;\n\n// Referencing DSFastListT.ActionRef directly (not a hand-written shape) so this file breaks if\n// the real ActionRef contract changes \u2014 a hand-written shape here would silently drift.\nconst actionRef = createRef() as MutableRefObject<DSFastListT.ActionRef>;\nconst innerRefObject = createRef() as MutableRefObject<HTMLDivElement | null>;\nconst innerRefCallback = (node: HTMLDivElement | null) => {};\n\nconst testRequiredProps: ComponentPropsRequiredProps = {\n ItemRenderer: MockItemRenderer,\n count: 0,\n getId: (index: number) => '',\n};\n\nconst testOptionalProps: ComponentPropsOptionalProps = {\n actionRef,\n extraItemProps: { data },\n innerRef: innerRefObject,\n extraContent: <button type=\"button\">Load more</button>,\n};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {};\n\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n};\n\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n estimateSize: () => 36,\n paddingStart: 0,\n paddingEnd: 0,\n remountOnCountChange: true,\n};\n\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n};\n\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n ItemRenderer: MockItemRenderer,\n count: 0,\n getId: (index: number) => '',\n actionRef,\n extraItemProps: { data },\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferredTypeCompatibility = {\n ItemRenderer: MockItemRenderer,\n count: 0,\n getId: (index: number) => '',\n actionRef,\n extraItemProps: { data },\n} as ComponentPropsForApp;\n\nconst testDefinitionAsConst = {\n ItemRenderer: MockItemRenderer,\n count: 0,\n getId: (index: number) => '',\n actionRef,\n extraItemProps: { foo: 'bar' },\n} as const;\n\n// Global HTML/ARIA attributes (className, id, aria-*, data-*) work at runtime via\n// useGetGlobalAttributes in List.tsx \u2014 PropsT/InternalPropsT intersect with\n// Omit<GlobalAttributesT<HTMLElement>, ...> specifically so this compiles. Regression here means\n// the type/runtime contract has drifted apart again.\nconst testGlobalAttributes: ComponentPropsForApp = {\n ItemRenderer: MockItemRenderer,\n count: 0,\n getId: (index: number) => '',\n className: 'custom-class',\n id: 'custom-id',\n 'aria-label': 'custom list',\n};\n// container-integration props, all assignment styles\nconst testContainerIntegration: ComponentPropsForApp = {\n ...testRequiredProps,\n innerRef: innerRefCallback,\n paddingStart: 24,\n paddingEnd: -5,\n remountOnCountChange: false,\n extraContent: null,\n};\n\nconst testContainerIntegrationAsSyntax = {\n ...testRequiredProps,\n innerRef: innerRefObject,\n paddingStart: 24,\n paddingEnd: 40,\n remountOnCountChange: true,\n extraContent: <span>extra</span>,\n} as ComponentPropsForApp;\n\nconst testContainerIntegrationAsConst = {\n ...testRequiredProps,\n paddingStart: 0,\n paddingEnd: 0,\n remountOnCountChange: false,\n} as const;\n\n// scrollTo accepts the virtualizer's full scroll options\n// ScrollToOptions keeps its published shape: `align` is required, so reading it needs no undefined check\nconst publishedScrollToOptions: DSFastListT.ScrollToOptions = { align: 'start' };\nconst publishedAlign: 'start' | 'center' | 'end' | 'auto' = publishedScrollToOptions.align;\nconst scrollActionOptions: DSFastListT.ScrollActionOptions = { behavior: 'smooth' };\nconst handleScrollToWithActionOptions = () => actionRef.current.scrollTo?.(1, scrollActionOptions);\nconst handleScrollToWithPublishedOptions = () => actionRef.current.scrollTo?.(1, publishedScrollToOptions);\nconst handleScrollToAlign = () => actionRef.current.scrollTo?.(1, { align: 'center' });\nconst handleScrollToBehavior = () => actionRef.current.scrollTo?.(1, { behavior: 'smooth' });\nconst handleScrollToBoth = () => actionRef.current.scrollTo?.(1, { align: 'end', behavior: 'auto' });\n\n// actionRef method usages \u2014 measure() and getVisibleItems() (PUI-17898)\nconst handleMeasure = () => actionRef.current.measure?.();\nconst handleGetVisibleItems: () => number[] = () => actionRef.current.getVisibleItems?.() ?? [];\nconst handleGetMountedItems: () => number[] = () => actionRef.current.getMountedItems?.() ?? [];\n\n// single-shot scrolling primitives \u2014 getOffsetForIndex() + scrollToOffset()\nconst handleGetOffsetForIndex: () => number | undefined = () => actionRef.current.getOffsetForIndex?.(1);\nconst handleGetOffsetForIndexAligned: () => number | undefined = () =>\n actionRef.current.getOffsetForIndex?.(1, 'center');\nconst handleScrollToOffset = () => actionRef.current.scrollToOffset?.(100);\nconst handleScrollToOffsetWithOptions = () => actionRef.current.scrollToOffset?.(100, { behavior: 'auto' });\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <DSFastList {...testExplicitDefinition} />\n <DSFastList {...testInferredTypeCompatibility} />\n <DSFastList {...testDefinitionAsConst} />\n <DSFastList {...testGlobalAttributes} />\n <DSFastList {...testContainerIntegration} />\n <DSFastList {...testContainerIntegrationAsSyntax} />\n <DSFastList {...testContainerIntegrationAsConst} />\n {/* works with inline values */}\n <DSFastList\n ItemRenderer={MockItemRenderer}\n count={0}\n getId={(index: number) => ''}\n actionRef={actionRef}\n extraItemProps={{ foo: 'bar' }}\n />\n {/* Inline props test \u2014 container-integration props */}\n <DSFastList\n ItemRenderer={MockItemRenderer}\n count={0}\n getId={(index: number) => ''}\n innerRef={innerRefObject}\n paddingStart={24}\n paddingEnd={-5}\n remountOnCountChange={false}\n extraContent={<button type=\"button\">Load more</button>}\n dsFastlistExtraContent={{ role: 'listitem' }}\n />\n {/* Inline props test \u2014 global HTML/ARIA attributes */}\n <DSFastList\n className=\"custom-class\"\n id=\"custom-id\"\n aria-label=\"custom list\"\n data-testid=\"custom-testid\"\n ItemRenderer={MockItemRenderer}\n count={0}\n getId={(index: number) => ''}\n />\n </>\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACcoC;AAb3D,mBAAiD;AACjD,eAA2B;AAG3B,MAAM,OAAO,CAAC,GAAG,GAAG,CAAC;AACrB,MAAM,aAAa,EAAE,KAAK;AAQ1B,MAAM,mBAAmB,CAAC,EAAE,MAAM,MAAyB,4CAAC,SAAI;AAIhE,MAAM,gBAAY,wBAAU;AAC5B,MAAM,qBAAiB,wBAAU;AACjC,MAAM,mBAAmB,CAAC,SAAgC;AAAC;AAE3D,MAAM,oBAAiD;AAAA,EACrD,cAAc;AAAA,EACd,OAAO;AAAA,EACP,OAAO,CAAC,UAAkB;AAC5B;AAEA,MAAM,oBAAiD;AAAA,EACrD;AAAA,EACA,gBAAgB,EAAE,KAAK;AAAA,EACvB,UAAU;AAAA,EACV,cAAc,4CAAC,YAAO,MAAK,UAAS,uBAAS;AAC/C;AAIA,MAAM,sBAA2D,CAAC;AAElE,MAAM,YAAkC;AAAA,EACtC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,oBAAoB;AAAA,EACxB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAGA,MAAM,uBAA6D;AAAA,EACjE,cAAc,MAAM;AAAA,EACpB,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,sBAAsB;AACxB;AAEA,MAAM,oBAA6C;AAAA,EACjD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,4B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CAAC,UAAkB;AAAA,MAC1B,UAAU;AAAA,MACV,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,sBAAsB;AAAA,MACtB,cAAc,4CAAC,YAAO,MAAK,UAAS,uBAAS;AAAA,MAC7C,wBAAwB,EAAE,MAAM,WAAW;AAAA;AAAA,EAC7C;AAAA,EAEA;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,IAAG;AAAA,MACH,cAAW;AAAA,MACX,eAAY;AAAA,MACZ,cAAc;AAAA,MACd,OAAO;AAAA,MACP,OAAO,CAAC,UAAkB;AAAA;AAAA,EAC5B;AAAA,GACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/FastList.js
CHANGED
|
@@ -3,7 +3,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { describe } from "@elliemae/ds-props-helpers";
|
|
4
4
|
import { List } from "./parts/List.js";
|
|
5
5
|
import { DSFastListPropTypes } from "./react-desc-prop-types.js";
|
|
6
|
-
import { DSFastListName } from "./
|
|
6
|
+
import { DSFastListName } from "./constants/index.js";
|
|
7
7
|
const DSFastList = (props) => /* @__PURE__ */ jsx(List, { ...props });
|
|
8
8
|
DSFastList.displayName = DSFastListName;
|
|
9
9
|
const DSFastListWithSchema = describe(DSFastList).description("DSFastList");
|
package/dist/esm/FastList.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/FastList.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { List } from './parts/List.js';\nimport { DSFastListPropTypes, type DSFastListT } from './react-desc-prop-types.js';\nimport { DSFastListName } from './
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { List } from './parts/List.js';\nimport { DSFastListPropTypes, type DSFastListT } from './react-desc-prop-types.js';\nimport { DSFastListName } from './constants/index.js';\n\n// we create ds-fast-list to solve the issue with the children prop in ds-virtual-list\n// this packages use render props instead of children prop.\n// we are not using a context nor zustand so all the logic is handled in List...\nconst DSFastList = <T extends object>(props: DSFastListT.Props<T>) => <List {...props} />;\n\nDSFastList.displayName = DSFastListName;\nconst DSFastListWithSchema = describe(DSFastList).description('DSFastList');\nDSFastListWithSchema.propTypes = DSFastListPropTypes;\n\nexport { DSFastList, DSFastListWithSchema };\n"],
|
|
5
5
|
"mappings": "AAAA,YAAY,WAAW;ACS+C;AARtE,SAAS,gBAAgB;AACzB,SAAS,YAAY;AACrB,SAAS,2BAA6C;AACtD,SAAS,sBAAsB;AAK/B,MAAM,aAAa,CAAmB,UAAgC,oBAAC,QAAM,GAAG,OAAO;AAEvF,WAAW,cAAc;AACzB,MAAM,uBAAuB,SAAS,UAAU,EAAE,YAAY,YAAY;AAC1E,qBAAqB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,12 +4,13 @@ const DSFastListName = "DSFastlist";
|
|
|
4
4
|
const DSFastListSlots = {
|
|
5
5
|
CONTAINER: "container",
|
|
6
6
|
WRAPPER_LIST: "wrapper-list",
|
|
7
|
-
ITEM: "item"
|
|
7
|
+
ITEM: "item",
|
|
8
|
+
EXTRA_CONTENT: "extra-content"
|
|
8
9
|
};
|
|
9
|
-
const
|
|
10
|
+
const DSFastListDataTestIds = slotObjectToDataTestIds(DSFastListName, DSFastListSlots);
|
|
10
11
|
export {
|
|
11
|
-
|
|
12
|
+
DSFastListDataTestIds,
|
|
12
13
|
DSFastListName,
|
|
13
14
|
DSFastListSlots
|
|
14
15
|
};
|
|
15
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/constants/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { slotObjectToDataTestIds } from '@elliemae/ds-system';\n\nexport const DSFastListName = 'DSFastlist';\n\nexport const DSFastListSlots = {\n CONTAINER: 'container',\n WRAPPER_LIST: 'wrapper-list',\n ITEM: 'item',\n EXTRA_CONTENT: 'extra-content',\n} as const;\n\nexport const DSFastListDataTestIds = slotObjectToDataTestIds(DSFastListName, DSFastListSlots);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,+BAA+B;AAEjC,MAAM,iBAAiB;AAEvB,MAAM,kBAAkB;AAAA,EAC7B,WAAW;AAAA,EACX,cAAc;AAAA,EACd,MAAM;AAAA,EACN,eAAe;AACjB;AAEO,MAAM,wBAAwB,wBAAwB,gBAAgB,eAAe;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -3,6 +3,7 @@ import React2 from "react";
|
|
|
3
3
|
import { uid } from "uid";
|
|
4
4
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
5
5
|
import { useMemoMergePropsWithDefault } from "@elliemae/ds-props-helpers";
|
|
6
|
+
import { setMultipleRefs } from "@elliemae/ds-system";
|
|
6
7
|
import { DSFastListPropTypes, defaultProps } from "../react-desc-prop-types.js";
|
|
7
8
|
import { useValidateProps } from "./useValidateProps.js";
|
|
8
9
|
const useFastList = (propsFromUser) => {
|
|
@@ -11,26 +12,54 @@ const useFastList = (propsFromUser) => {
|
|
|
11
12
|
defaultProps
|
|
12
13
|
);
|
|
13
14
|
useValidateProps(propsWithDefault, DSFastListPropTypes);
|
|
14
|
-
const { actionRef, count, estimateSize } = propsWithDefault;
|
|
15
|
+
const { actionRef, count, estimateSize, paddingStart, paddingEnd, innerRef, remountOnCountChange } = propsWithDefault;
|
|
15
16
|
const parentRef = React2.useRef(null);
|
|
17
|
+
const containerRef = React2.useMemo(
|
|
18
|
+
() => innerRef ? setMultipleRefs([parentRef, innerRef]) : parentRef,
|
|
19
|
+
[innerRef]
|
|
20
|
+
);
|
|
16
21
|
const useVirtualHelpers = useVirtualizer({
|
|
17
22
|
count,
|
|
18
23
|
getScrollElement: () => parentRef.current,
|
|
19
24
|
overscan: 15,
|
|
20
|
-
estimateSize
|
|
25
|
+
estimateSize,
|
|
26
|
+
paddingStart,
|
|
27
|
+
paddingEnd
|
|
21
28
|
});
|
|
22
29
|
const totalSize = useVirtualHelpers.getTotalSize();
|
|
23
|
-
if (actionRef && actionRef.current)
|
|
24
|
-
|
|
30
|
+
if (actionRef && actionRef.current) {
|
|
31
|
+
actionRef.current.scrollTo = useVirtualHelpers.scrollToIndex;
|
|
32
|
+
actionRef.current.measure = useVirtualHelpers.measure;
|
|
33
|
+
actionRef.current.getVisibleItems = () => {
|
|
34
|
+
const range = useVirtualHelpers.calculateRange();
|
|
35
|
+
if (!range) return [];
|
|
36
|
+
const viewportStart = useVirtualHelpers.scrollOffset ?? 0;
|
|
37
|
+
const viewportEnd = viewportStart + (useVirtualHelpers.scrollRect?.height ?? 0);
|
|
38
|
+
const indices = [];
|
|
39
|
+
for (let index = range.startIndex; index <= range.endIndex; index += 1) {
|
|
40
|
+
const item = useVirtualHelpers.measurementsCache[index];
|
|
41
|
+
if (item && item.end > viewportStart && item.start < viewportEnd) indices.push(index);
|
|
42
|
+
}
|
|
43
|
+
return indices;
|
|
44
|
+
};
|
|
45
|
+
actionRef.current.getMountedItems = () => useVirtualHelpers.getVirtualItems().map((item) => item.index);
|
|
46
|
+
actionRef.current.getOffsetForIndex = (index, align) => useVirtualHelpers.getOffsetForIndex(index, align)?.[0];
|
|
47
|
+
actionRef.current.scrollToOffset = useVirtualHelpers.scrollToOffset;
|
|
48
|
+
}
|
|
49
|
+
const stableUid = React2.useMemo(() => uid(6), []);
|
|
50
|
+
const instanceUid = React2.useMemo(
|
|
51
|
+
() => remountOnCountChange === false ? `ds-fast-list-${stableUid}` : `ds-fast-list-${uid(6)}${count}`,
|
|
52
|
+
[count, remountOnCountChange, stableUid]
|
|
53
|
+
);
|
|
25
54
|
return React2.useMemo(
|
|
26
55
|
() => ({
|
|
27
56
|
instanceUid,
|
|
28
|
-
|
|
57
|
+
containerRef,
|
|
29
58
|
getVirtualItems: useVirtualHelpers.getVirtualItems,
|
|
30
59
|
totalSize,
|
|
31
60
|
measureElement: useVirtualHelpers.measureElement
|
|
32
61
|
}),
|
|
33
|
-
[useVirtualHelpers.getVirtualItems, useVirtualHelpers.measureElement, totalSize, instanceUid]
|
|
62
|
+
[useVirtualHelpers.getVirtualItems, useVirtualHelpers.measureElement, totalSize, instanceUid, containerRef]
|
|
34
63
|
);
|
|
35
64
|
};
|
|
36
65
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useFastList.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { uid } from 'uid';\nimport { useVirtualizer, type Virtualizer } from '@tanstack/react-virtual';\nimport { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport { type DSFastListT, DSFastListPropTypes, defaultProps } from '../react-desc-prop-types.js';\nimport { useValidateProps } from './useValidateProps.js';\n\nexport type FastListCTX = {\n instanceUid: string;\n
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,YAAW;AAClB,SAAS,WAAW;AACpB,SAAS,sBAAwC;AACjD,SAAS,oCAAoC;AAC7C,SAA2B,qBAAqB,oBAAoB;AACpE,SAAS,wBAAwB;AAS1B,MAAM,cAAc,CAAK,kBAAqD;AAInF,QAAM,mBAAmB;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACA,mBAAiB,kBAAkB,mBAAmB;AAItD,QAAM,EAAE,WAAW,OAAO,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { uid } from 'uid';\nimport { useVirtualizer, type Virtualizer } from '@tanstack/react-virtual';\nimport { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport { setMultipleRefs } from '@elliemae/ds-system';\nimport { type DSFastListT, DSFastListPropTypes, defaultProps } from '../react-desc-prop-types.js';\nimport { useValidateProps } from './useValidateProps.js';\n\nexport type FastListCTX = {\n instanceUid: string;\n containerRef: React.MutableRefObject<HTMLDivElement | null> | React.RefCallback<HTMLDivElement>;\n getVirtualItems: Virtualizer<HTMLDivElement, HTMLElement>['getVirtualItems'];\n totalSize: ReturnType<Virtualizer<HTMLDivElement, HTMLElement>['getTotalSize']>;\n measureElement: Virtualizer<HTMLDivElement, HTMLElement>['measureElement'];\n};\nexport const useFastList = <T,>(propsFromUser: DSFastListT.Props<T>): FastListCTX => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSFastListT.InternalProps<T>>(\n propsFromUser,\n defaultProps as Partial<DSFastListT.InternalProps<T>>,\n );\n useValidateProps(propsWithDefault, DSFastListPropTypes);\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n const { actionRef, count, estimateSize, paddingStart, paddingEnd, innerRef, remountOnCountChange } = propsWithDefault;\n const parentRef = React.useRef<HTMLDivElement>(null);\n const containerRef = React.useMemo(\n () => (innerRef ? setMultipleRefs<HTMLDivElement>([parentRef, innerRef]) : parentRef),\n [innerRef],\n );\n const useVirtualHelpers = useVirtualizer({\n count,\n getScrollElement: () => parentRef.current,\n overscan: 15,\n estimateSize,\n paddingStart,\n paddingEnd,\n });\n const totalSize = useVirtualHelpers.getTotalSize();\n\n if (actionRef && actionRef.current) {\n actionRef.current.scrollTo = useVirtualHelpers.scrollToIndex;\n actionRef.current.measure = useVirtualHelpers.measure;\n // `getVirtualItems()` includes the overscan buffer on each side \u2014 not what \"visible\" means.\n // `calculateRange()` is the virtualizer's own pre-overscan viewport calculation (pure scroll\n // geometry, no DOM scraping) and is what \"currently visible\" should actually be backed by.\n actionRef.current.getVisibleItems = () => {\n const range = useVirtualHelpers.calculateRange();\n if (!range) return [];\n /**\n * `calculateRange()` always seeds the item nearest to the scroll offset, even when only padding is in view\n * (a `paddingStart` or `paddingEnd` larger than the viewport), so each index is kept only if its item\n * actually intersects the viewport.\n */\n const viewportStart = useVirtualHelpers.scrollOffset ?? 0;\n const viewportEnd = viewportStart + (useVirtualHelpers.scrollRect?.height ?? 0);\n const indices: number[] = [];\n for (let index = range.startIndex; index <= range.endIndex; index += 1) {\n const item = useVirtualHelpers.measurementsCache[index];\n if (item && item.end > viewportStart && item.start < viewportEnd) indices.push(index);\n }\n return indices;\n };\n // The overscanned set (viewport + the 15-item buffer on each side) \u2014 everything currently\n // mounted in the DOM, as opposed to `getVisibleItems()`'s true-viewport-only set above.\n actionRef.current.getMountedItems = () => useVirtualHelpers.getVirtualItems().map((item) => item.index);\n actionRef.current.getOffsetForIndex = (index, align) => useVirtualHelpers.getOffsetForIndex(index, align)?.[0];\n actionRef.current.scrollToOffset = useVirtualHelpers.scrollToOffset;\n }\n\n const stableUid = React.useMemo(() => uid(6), []);\n const instanceUid = React.useMemo(\n () => (remountOnCountChange === false ? `ds-fast-list-${stableUid}` : `ds-fast-list-${uid(6)}${count}`),\n [count, remountOnCountChange, stableUid],\n );\n return React.useMemo(\n () => ({\n instanceUid,\n containerRef,\n getVirtualItems: useVirtualHelpers.getVirtualItems,\n totalSize,\n measureElement: useVirtualHelpers.measureElement,\n }),\n [useVirtualHelpers.getVirtualItems, useVirtualHelpers.measureElement, totalSize, instanceUid, containerRef],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,YAAW;AAClB,SAAS,WAAW;AACpB,SAAS,sBAAwC;AACjD,SAAS,oCAAoC;AAC7C,SAAS,uBAAuB;AAChC,SAA2B,qBAAqB,oBAAoB;AACpE,SAAS,wBAAwB;AAS1B,MAAM,cA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AAiB,kBAAkB;AAAA,EACvD;AAEA,QAAM,YAAYA,OAAM,QAAQ,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,QAAM,cAAcA,OAAM;AAAA,IACxB,MAAO,yBAAyB,QAAQ,gBAAgB,SAAS,KAAK,gBAAgB,IAAI,CAAC,CAAC,GAAG,KAAK;AAAA,IACpG,CAAC,OAAO,sBAAsB,SAAS;AAAA,EACzC;AACA,SAAOA,OAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,iBAAiB,kBAAkB;AAAA,MACnC;AAAA,MACA,gBAAgB,kBAAkB;AAAA,IACpC;AAAA,IACA,CAAC,kBAAkB,iBAAiB,kBAAkB,gBAAgB,WAAW,aAAa,YAAY;AAAA,EAC5G;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useValidateTypescriptPropTypes } from "@elliemae/ds-props-helpers";
|
|
3
|
-
import { DSFastListName } from "../
|
|
3
|
+
import { DSFastListName } from "../constants/index.js";
|
|
4
4
|
const useValidateProps = (props, propTypes) => {
|
|
5
5
|
useValidateTypescriptPropTypes(props, propTypes, DSFastListName);
|
|
6
6
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useValidateProps.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport type { WeakValidationMap } from 'react';\nimport { type DSFastListT } from '../react-desc-prop-types.js';\nimport { DSFastListName } from '../
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport type { WeakValidationMap } from 'react';\nimport { type DSFastListT } from '../react-desc-prop-types.js';\nimport { DSFastListName } from '../constants/index.js';\n\nexport const useValidateProps = <T>(\n props: DSFastListT.InternalProps<T>,\n propTypes: WeakValidationMap<unknown>,\n): void => {\n // we validate the \"required if\" via 'isRequiredIf from our custom PropTypes\n useValidateTypescriptPropTypes(props, propTypes, DSFastListName);\n};\n"],
|
|
5
5
|
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,sCAAsC;AAG/C,SAAS,sBAAsB;AAExB,MAAM,mBAAmB,CAC9B,OACA,cACS;AAET,iCAA+B,OAAO,WAAW,cAAc;AACjE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { DSFastList, DSFastListWithSchema } from "./FastList.js";
|
|
3
|
+
import { DSFastListName, DSFastListSlots, DSFastListDataTestIds } from "./constants/index.js";
|
|
3
4
|
export {
|
|
4
5
|
DSFastList,
|
|
6
|
+
DSFastListDataTestIds,
|
|
7
|
+
DSFastListName,
|
|
8
|
+
DSFastListSlots,
|
|
5
9
|
DSFastListWithSchema
|
|
6
10
|
};
|
|
7
11
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { type DSFastListT } from './react-desc-prop-types.js';\nexport { DSFastList, DSFastListWithSchema } from './FastList.js';\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,YAAY,4BAA4B;",
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { type DSFastListT } from './react-desc-prop-types.js';\nexport { DSFastList, DSFastListWithSchema } from './FastList.js';\nexport { DSFastListName, DSFastListSlots, DSFastListDataTestIds } from './constants/index.js';\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,YAAY,4BAA4B;AACjD,SAAS,gBAAgB,iBAAiB,6BAA6B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/parts/List.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import React2, { useCallback } from "react";
|
|
4
4
|
import { styled } from "@elliemae/ds-system";
|
|
5
5
|
import { useGetGlobalAttributes } from "@elliemae/ds-props-helpers";
|
|
6
6
|
import { useFastList } from "../hooks/useFastList.js";
|
|
7
|
-
import { DSFastListName, DSFastListSlots } from "../
|
|
7
|
+
import { DSFastListName, DSFastListSlots } from "../constants/index.js";
|
|
8
8
|
const StyledList = styled("div", {
|
|
9
9
|
name: DSFastListName,
|
|
10
10
|
slot: DSFastListSlots.WRAPPER_LIST
|
|
@@ -21,6 +21,10 @@ const StyledListItem = styled("div", {
|
|
|
21
21
|
left: 0;
|
|
22
22
|
width: 100%;
|
|
23
23
|
`;
|
|
24
|
+
const StyledExtraContent = styled("div", {
|
|
25
|
+
name: DSFastListName,
|
|
26
|
+
slot: DSFastListSlots.EXTRA_CONTENT
|
|
27
|
+
})``;
|
|
24
28
|
const StyledListContainer = styled("div", {
|
|
25
29
|
name: DSFastListName,
|
|
26
30
|
slot: DSFastListSlots.CONTAINER
|
|
@@ -31,8 +35,9 @@ const StyledListContainer = styled("div", {
|
|
|
31
35
|
padding-bottom: 0;
|
|
32
36
|
`;
|
|
33
37
|
const List = (props) => {
|
|
34
|
-
const {
|
|
35
|
-
const { ItemRenderer, extraItemProps, getId } = props;
|
|
38
|
+
const { containerRef, getVirtualItems, totalSize, instanceUid, measureElement } = useFastList(props);
|
|
39
|
+
const { ItemRenderer, extraItemProps, getId, extraContent } = props;
|
|
40
|
+
const hasExtraContent = extraContent !== null && extraContent !== void 0 && typeof extraContent !== "boolean";
|
|
36
41
|
const virtualItems = getVirtualItems();
|
|
37
42
|
const measureRef = React2.useCallback(
|
|
38
43
|
(node) => measureElement(node),
|
|
@@ -43,11 +48,11 @@ const List = (props) => {
|
|
|
43
48
|
return /* @__PURE__ */ jsx(
|
|
44
49
|
StyledListContainer,
|
|
45
50
|
{
|
|
46
|
-
innerRef:
|
|
51
|
+
innerRef: containerRef,
|
|
47
52
|
tabIndex: -1,
|
|
48
53
|
getOwnerProps,
|
|
49
54
|
...globalAttributes,
|
|
50
|
-
children: /* @__PURE__ */
|
|
55
|
+
children: /* @__PURE__ */ jsxs(
|
|
51
56
|
StyledList,
|
|
52
57
|
{
|
|
53
58
|
style: {
|
|
@@ -56,24 +61,27 @@ const List = (props) => {
|
|
|
56
61
|
},
|
|
57
62
|
role: "list",
|
|
58
63
|
getOwnerProps,
|
|
59
|
-
children:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
children: [
|
|
65
|
+
hasExtraContent ? /* @__PURE__ */ jsx(StyledExtraContent, { getOwnerProps, children: extraContent }) : null,
|
|
66
|
+
virtualItems.map((virtualItem) => {
|
|
67
|
+
const { index, start } = virtualItem;
|
|
68
|
+
return /* @__PURE__ */ jsx(
|
|
69
|
+
StyledListItem,
|
|
70
|
+
{
|
|
71
|
+
innerRef: measureRef,
|
|
72
|
+
"data-index": index,
|
|
73
|
+
style: {
|
|
74
|
+
transform: `translateY(${start}px)`
|
|
75
|
+
},
|
|
76
|
+
role: "listitem",
|
|
77
|
+
getOwnerProps,
|
|
78
|
+
getOwnerPropsArguments: () => ({ index: getId(index) }),
|
|
79
|
+
children: /* @__PURE__ */ jsx(ItemRenderer, { extraItemProps, index })
|
|
68
80
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
getId(index)
|
|
75
|
-
);
|
|
76
|
-
})
|
|
81
|
+
getId(index)
|
|
82
|
+
);
|
|
83
|
+
})
|
|
84
|
+
]
|
|
77
85
|
}
|
|
78
86
|
)
|
|
79
87
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/List.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback } from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { useGetGlobalAttributes } from '@elliemae/ds-props-helpers';\nimport { useFastList } from '../hooks/useFastList.js';\nimport type { DSFastListT } from '../react-desc-prop-types.js';\nimport { DSFastListName, DSFastListSlots } from '../
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;AC+
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback } from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { useGetGlobalAttributes } from '@elliemae/ds-props-helpers';\nimport { useFastList } from '../hooks/useFastList.js';\nimport type { DSFastListT } from '../react-desc-prop-types.js';\nimport { DSFastListName, DSFastListSlots } from '../constants/index.js';\n\nconst StyledList = styled('div', {\n name: DSFastListName,\n slot: DSFastListSlots.WRAPPER_LIST,\n})`\n width: 100%;\n position: relative;\n`;\n\nconst StyledListItem = styled('div', {\n name: DSFastListName,\n slot: DSFastListSlots.ITEM,\n})`\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n`;\n\nconst StyledExtraContent = styled('div', {\n name: DSFastListName,\n slot: DSFastListSlots.EXTRA_CONTENT,\n})``;\n\nconst StyledListContainer = styled('div', {\n name: DSFastListName,\n slot: DSFastListSlots.CONTAINER,\n})`\n overflow: auto;\n width: 100%;\n height: 100%;\n padding-bottom: 0;\n`;\n\nexport const List = <T extends object>(props: DSFastListT.Props<T>) => {\n const { containerRef, getVirtualItems, totalSize, instanceUid, measureElement } = useFastList(props);\n const { ItemRenderer, extraItemProps, getId, extraContent } = props;\n const hasExtraContent = extraContent !== null && extraContent !== undefined && typeof extraContent !== 'boolean';\n\n const virtualItems = getVirtualItems();\n const measureRef: React.LegacyRef<HTMLDivElement> = React.useCallback(\n (node: HTMLDivElement) => measureElement(node),\n [measureElement],\n );\n\n const getOwnerProps = useCallback(() => props, [props]);\n const globalAttributes = useGetGlobalAttributes(props);\n\n return (\n <StyledListContainer\n innerRef={containerRef}\n // firefox needs this tabIndex to prevent scrolling\n tabIndex={-1}\n key={instanceUid}\n getOwnerProps={getOwnerProps}\n {...globalAttributes}\n >\n <StyledList\n style={{\n // we add up 0.5 to prevent the scrollbar from appearing in some cases\n height: `${totalSize + 0.5}px`,\n }}\n role=\"list\"\n getOwnerProps={getOwnerProps}\n >\n {hasExtraContent ? <StyledExtraContent getOwnerProps={getOwnerProps}>{extraContent}</StyledExtraContent> : null}\n {virtualItems.map((virtualItem) => {\n const { index, start } = virtualItem;\n return (\n <StyledListItem\n innerRef={measureRef}\n data-index={index}\n style={{\n transform: `translateY(${start}px)`,\n }}\n role=\"listitem\"\n key={getId(index)}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={() => ({ index: getId(index) })}\n >\n <ItemRenderer extraItemProps={extraItemProps} index={index} />\n </StyledListItem>\n );\n })}\n </StyledList>\n </StyledListContainer>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC+DjB,SAQqB,KARrB;AA/DN,OAAOA,UAAS,mBAAmB;AACnC,SAAS,cAAc;AACvB,SAAS,8BAA8B;AACvC,SAAS,mBAAmB;AAE5B,SAAS,gBAAgB,uBAAuB;AAEhD,MAAM,aAAa,OAAO,OAAO;AAAA,EAC/B,MAAM;AAAA,EACN,MAAM,gBAAgB;AACxB,CAAC;AAAA;AAAA;AAAA;AAKD,MAAM,iBAAiB,OAAO,OAAO;AAAA,EACnC,MAAM;AAAA,EACN,MAAM,gBAAgB;AACxB,C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AAE,OAAO,MAAM,KAAK,EAAE;AAAA,kBAErD,8BAAC,gBAAa,gBAAgC,OAAc;AAAA;AAAA,gBAJvD,MAAM,KAAK;AAAA,cAKlB;AAAA,YAEJ,CAAC;AAAA;AAAA;AAAA,MACH;AAAA;AAAA,IA/BK;AAAA,EAgCP;AAEJ;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -1,24 +1,60 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { PropTypes } from "@elliemae/ds-props-helpers";
|
|
2
|
+
import { PropTypes, getPropsPerSlotPropTypes, globalAttributesPropTypes } from "@elliemae/ds-props-helpers";
|
|
3
|
+
import { DSFastListName, DSFastListSlots } from "./constants/index.js";
|
|
3
4
|
const defaultProps = {
|
|
4
|
-
estimateSize: () => 36
|
|
5
|
+
estimateSize: () => 36,
|
|
6
|
+
paddingStart: 0,
|
|
7
|
+
paddingEnd: 0,
|
|
8
|
+
remountOnCountChange: true
|
|
5
9
|
};
|
|
6
10
|
const DSFastListPropTypes = {
|
|
11
|
+
...getPropsPerSlotPropTypes(DSFastListName, DSFastListSlots),
|
|
12
|
+
...globalAttributesPropTypes,
|
|
7
13
|
actionRef: PropTypes.shape({
|
|
8
14
|
current: PropTypes.oneOfType([
|
|
9
15
|
PropTypes.oneOf([null]),
|
|
10
16
|
PropTypes.shape({
|
|
11
|
-
scrollTo: PropTypes.func.description("Scroll to a index inside the list").signature(
|
|
17
|
+
scrollTo: PropTypes.func.description("Scroll to a index inside the list").signature(
|
|
18
|
+
`((index: number, options?: { align?: 'start' | 'center' | 'end' | 'auto'; behavior?: 'auto' | 'smooth' }) => void)`
|
|
19
|
+
),
|
|
20
|
+
measure: PropTypes.func.description(
|
|
21
|
+
"Clears the cached size of every item, falling back to the estimated size until each item is measured again (on its next real layout change or remount) \u2014 does not force an immediate DOM remeasurement"
|
|
22
|
+
).signature(`(() => void)`),
|
|
23
|
+
getVisibleItems: PropTypes.func.description("Returns the indices of the items currently visible in the viewport (no overscan buffer)").signature(`(() => number[])`),
|
|
24
|
+
getMountedItems: PropTypes.func.description("Returns the indices of all items currently mounted in the DOM, including the overscan buffer").signature(`(() => number[])`),
|
|
25
|
+
getOffsetForIndex: PropTypes.func.description(
|
|
26
|
+
"Returns the scroll offset that brings the item at the given index into view with the given alignment, or undefined when there is no measurement for it yet (for example, an empty list). It reads the current measurements, where items not rendered yet still have the estimated size, and it does not scroll"
|
|
27
|
+
).signature(`((index: number, align?: 'start' | 'center' | 'end' | 'auto') => number | undefined)`),
|
|
28
|
+
scrollToOffset: PropTypes.func.description(
|
|
29
|
+
"Scrolls the list to the given offset once. Unlike scrollTo, it does not verify and retry the position on the following frames, so it never competes with the user scrolling at the same time"
|
|
30
|
+
).signature(
|
|
31
|
+
`((offset: number, options?: { align?: 'start' | 'center' | 'end' | 'auto'; behavior?: 'auto' | 'smooth' }) => void)`
|
|
32
|
+
)
|
|
12
33
|
})
|
|
13
34
|
])
|
|
14
|
-
}).description(
|
|
35
|
+
}).description(
|
|
36
|
+
"Mutable reference where the methods are stored. They are assigned during render only when `actionRef.current` is already an object, so pass a ref initialized with one (for example `useRef({})`), not `useRef(null)`"
|
|
37
|
+
),
|
|
15
38
|
ItemRenderer: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).isRequired.description(
|
|
16
39
|
"Render function for each item"
|
|
17
40
|
),
|
|
18
41
|
count: PropTypes.number.isRequired.description("Number of items to render"),
|
|
19
42
|
extraItemProps: PropTypes.object.description("Extra props to pass to each item"),
|
|
20
43
|
getId: PropTypes.func.isRequired.description("Function to get the key for each item"),
|
|
21
|
-
estimateSize: PropTypes.func.description("Function to estimate the size of each item")
|
|
44
|
+
estimateSize: PropTypes.func.description("Function to estimate the size of each item"),
|
|
45
|
+
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description(
|
|
46
|
+
"Ref (object or callback) that receives the scroll container element of the list"
|
|
47
|
+
),
|
|
48
|
+
paddingStart: PropTypes.number.description("Space in pixels reserved before the first item inside the scrolling area").defaultValue(0),
|
|
49
|
+
paddingEnd: PropTypes.number.description(
|
|
50
|
+
"Space in pixels reserved after the last item inside the scrolling area; negative values are passed through"
|
|
51
|
+
).defaultValue(0),
|
|
52
|
+
remountOnCountChange: PropTypes.bool.description(
|
|
53
|
+
"When true the scroll container element is recreated every time count changes; set it to false to keep the same element and scroll position while the number of items changes"
|
|
54
|
+
).defaultValue(true),
|
|
55
|
+
extraContent: PropTypes.node.description(
|
|
56
|
+
'Content rendered inside the list wrapper before the items, within the extra content slot; it should be positioned out of the normal flow because the wrapper height is fixed. The wrapper has role="list" by default, so the content must carry role="listitem" itself (for example a container around a button), unless the wrapper role is overridden through the wrapper-list slot, in which case it must fit that role instead'
|
|
57
|
+
)
|
|
22
58
|
};
|
|
23
59
|
export {
|
|
24
60
|
DSFastListPropTypes,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from '@elliemae/ds-props-helpers';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport type React from 'react';\nimport
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { GlobalAttributesT } from '@elliemae/ds-props-helpers';\nimport { PropTypes, getPropsPerSlotPropTypes, globalAttributesPropTypes } from '@elliemae/ds-props-helpers';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport type React from 'react';\nimport { DSFastListName, DSFastListSlots } from './constants/index.js';\n\nexport declare namespace DSFastListT {\n type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';\n /** Kept with its published shape (`align` required) so code that reads it keeps compiling. */\n export type ScrollToOptions = {\n align: ScrollAlignment;\n };\n\n /** What the scroll actions accept: `align` is optional and `behavior` can request a smooth scroll. */\n export type ScrollActionOptions = {\n align?: ScrollAlignment;\n behavior?: 'auto' | 'smooth';\n };\n\n /**\n * `scrollTo` and `scrollToOffset` use method syntax on purpose: their parameters are compared bivariantly, so an\n * `actionRef` typed with the published `(index, options?: ScrollToOptions) => void` stays assignable.\n */\n export type ActionRef = {\n scrollTo?(index: number, options?: ScrollActionOptions): void;\n measure?: () => void;\n getVisibleItems?: () => number[];\n getMountedItems?: () => number[];\n getOffsetForIndex?: (index: number, align?: ScrollAlignment) => number | undefined;\n scrollToOffset?(offset: number, options?: ScrollActionOptions): void;\n };\n\n export type SlotFunctionArguments = {\n dsFastlistContainer: () => object;\n dsFastlistWrapperList: () => object;\n dsFastlistItem: () => object;\n dsFastlistExtraContent: () => object;\n };\n\n export interface OptionalProps<ExtraItemPropsT> extends TypescriptHelpersT.PropsForGlobalOnSlots<\n typeof DSFastListName,\n typeof DSFastListSlots\n > {\n actionRef?: React.MutableRefObject<ActionRef>;\n extraItemProps?: ExtraItemPropsT;\n innerRef?: React.MutableRefObject<HTMLDivElement | null> | React.RefCallback<HTMLDivElement>;\n extraContent?: React.ReactNode;\n }\n\n export interface RequiredProps<ExtraItemPropsT> {\n ItemRenderer: React.ComponentType<{ index: number; extraItemProps?: ExtraItemPropsT }>;\n count: number;\n getId: (index: number) => string | number;\n }\n\n export interface DefaultProps {\n estimateSize: () => number;\n paddingStart: number;\n paddingEnd: number;\n remountOnCountChange: boolean;\n }\n\n // 'children' is excluded on top of `keyof D | keyof R`: DSFastList is the render-prop variant\n // (see FastList.tsx's own comment) and never reads props.children \u2014 without this exclusion,\n // GlobalAttributesT<HTMLElement> (which includes children via React's DOMAttributes) would let\n // the public type silently accept children that are dropped at runtime.\n type PropsT<D, R, O> = Partial<D> & R & O & Omit<GlobalAttributesT<HTMLElement>, keyof D | keyof R | 'children'>;\n type InternalPropsT<D, R, O> = D & R & O & Omit<GlobalAttributesT<HTMLElement>, keyof D | keyof R | 'children'>;\n\n export type Props<ExtraItemPropsT> = PropsT<\n DefaultProps,\n RequiredProps<ExtraItemPropsT>,\n OptionalProps<ExtraItemPropsT>\n >;\n export type InternalProps<ExtraItemPropsT> = InternalPropsT<\n DefaultProps,\n RequiredProps<ExtraItemPropsT>,\n OptionalProps<ExtraItemPropsT>\n >;\n}\n\nexport const defaultProps = {\n estimateSize: () => 36,\n paddingStart: 0,\n paddingEnd: 0,\n remountOnCountChange: true,\n};\n\nexport const DSFastListPropTypes = {\n ...getPropsPerSlotPropTypes(DSFastListName, DSFastListSlots),\n ...globalAttributesPropTypes,\n actionRef: PropTypes.shape({\n current: PropTypes.oneOfType([\n PropTypes.oneOf([null]),\n PropTypes.shape({\n scrollTo: PropTypes.func\n .description('Scroll to a index inside the list')\n .signature(\n `((index: number, options?: { align?: 'start' | 'center' | 'end' | 'auto'; behavior?: 'auto' | 'smooth' }) => void)`,\n ),\n measure: PropTypes.func\n .description(\n 'Clears the cached size of every item, falling back to the estimated size until each item is measured again (on its next real layout change or remount) \u2014 does not force an immediate DOM remeasurement',\n )\n .signature(`(() => void)`),\n getVisibleItems: PropTypes.func\n .description('Returns the indices of the items currently visible in the viewport (no overscan buffer)')\n .signature(`(() => number[])`),\n getMountedItems: PropTypes.func\n .description('Returns the indices of all items currently mounted in the DOM, including the overscan buffer')\n .signature(`(() => number[])`),\n getOffsetForIndex: PropTypes.func\n .description(\n 'Returns the scroll offset that brings the item at the given index into view with the given alignment, or undefined when there is no measurement for it yet (for example, an empty list). It reads the current measurements, where items not rendered yet still have the estimated size, and it does not scroll',\n )\n .signature(`((index: number, align?: 'start' | 'center' | 'end' | 'auto') => number | undefined)`),\n scrollToOffset: PropTypes.func\n .description(\n 'Scrolls the list to the given offset once. Unlike scrollTo, it does not verify and retry the position on the following frames, so it never competes with the user scrolling at the same time',\n )\n .signature(\n `((offset: number, options?: { align?: 'start' | 'center' | 'end' | 'auto'; behavior?: 'auto' | 'smooth' }) => void)`,\n ),\n }),\n ]),\n }).description(\n 'Mutable reference where the methods are stored. They are assigned during render only when `actionRef.current` is already an object, so pass a ref initialized with one (for example `useRef({})`), not `useRef(null)`',\n ),\n ItemRenderer: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).isRequired.description(\n 'Render function for each item',\n ),\n count: PropTypes.number.isRequired.description('Number of items to render'),\n extraItemProps: PropTypes.object.description('Extra props to pass to each item'),\n getId: PropTypes.func.isRequired.description('Function to get the key for each item'),\n estimateSize: PropTypes.func.description('Function to estimate the size of each item'),\n innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description(\n 'Ref (object or callback) that receives the scroll container element of the list',\n ),\n paddingStart: PropTypes.number\n .description('Space in pixels reserved before the first item inside the scrolling area')\n .defaultValue(0),\n paddingEnd: PropTypes.number\n .description(\n 'Space in pixels reserved after the last item inside the scrolling area; negative values are passed through',\n )\n .defaultValue(0),\n remountOnCountChange: PropTypes.bool\n .description(\n 'When true the scroll container element is recreated every time count changes; set it to false to keep the same element and scroll position while the number of items changes',\n )\n .defaultValue(true),\n extraContent: PropTypes.node.description(\n 'Content rendered inside the list wrapper before the items, within the extra content slot; it should be positioned out of the normal flow because the wrapper height is fixed. The wrapper has role=\"list\" by default, so the content must carry role=\"listitem\" itself (for example a container around a button), unless the wrapper role is overridden through the wrapper-list slot, in which case it must fit that role instead',\n ),\n} as React.WeakValidationMap<unknown>;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,WAAW,0BAA0B,iCAAiC;AAG/E,SAAS,gBAAgB,uBAAuB;AA6EzC,MAAM,eAAe;AAAA,EAC1B,cAAc,MAAM;AAAA,EACpB,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,sBAAsB;AACxB;AAEO,MAAM,sBAAsB;AAAA,EACjC,GAAG,yBAAyB,gBAAgB,eAAe;AAAA,EAC3D,GAAG;AAAA,EACH,WAAW,UAAU,MAAM;AAAA,IACzB,SAAS,UAAU,UAAU;AAAA,MAC3B,UAAU,MAAM,CAAC,IAAI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