@elliemae/ds-fast-list 3.31.4 → 3.32.0-rc.2
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/DSFastListDefinitions.js +10 -1
- package/dist/cjs/DSFastListDefinitions.js.map +2 -2
- package/dist/cjs/FastList.js.map +2 -2
- package/dist/cjs/hooks/useFastList.js.map +2 -2
- package/dist/cjs/hooks/useValidateProps.js.map +2 -2
- package/dist/cjs/parts/List.js +39 -23
- package/dist/cjs/parts/List.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js +2 -1
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/typescript-testing/typescript-fast-list-valid.js +5 -3
- package/dist/cjs/typescript-testing/typescript-fast-list-valid.js.map +2 -2
- package/dist/esm/DSFastListDefinitions.js +10 -1
- package/dist/esm/DSFastListDefinitions.js.map +2 -2
- package/dist/esm/FastList.js.map +2 -2
- package/dist/esm/hooks/useFastList.js.map +2 -2
- package/dist/esm/hooks/useValidateProps.js.map +2 -2
- package/dist/esm/parts/List.js +40 -24
- package/dist/esm/parts/List.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js +2 -1
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/typescript-testing/typescript-fast-list-valid.js +5 -3
- package/dist/esm/typescript-testing/typescript-fast-list-valid.js.map +2 -2
- package/dist/types/DSFastListDefinitions.d.ts +6 -0
- package/dist/types/FastList.d.ts +2 -2
- package/dist/types/hooks/useFastList.d.ts +1 -1
- package/dist/types/hooks/useValidateProps.d.ts +1 -1
- package/dist/types/parts/List.d.ts +1 -2
- package/dist/types/react-desc-prop-types.d.ts +12 -9
- package/package.json +6 -6
|
@@ -28,9 +28,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var DSFastListDefinitions_exports = {};
|
|
30
30
|
__export(DSFastListDefinitions_exports, {
|
|
31
|
-
|
|
31
|
+
DSCardV3DataTestIds: () => DSCardV3DataTestIds,
|
|
32
|
+
DSFastListName: () => DSFastListName,
|
|
33
|
+
DSFastListSlots: () => DSFastListSlots
|
|
32
34
|
});
|
|
33
35
|
module.exports = __toCommonJS(DSFastListDefinitions_exports);
|
|
34
36
|
var React = __toESM(require("react"));
|
|
37
|
+
var import_ds_system = require("@elliemae/ds-system");
|
|
35
38
|
const DSFastListName = "DSFastList";
|
|
39
|
+
const DSFastListSlots = {
|
|
40
|
+
CONTAINER: "container",
|
|
41
|
+
WRAPPER_LIST: "wrapper-list",
|
|
42
|
+
ITEM: "item"
|
|
43
|
+
};
|
|
44
|
+
const DSCardV3DataTestIds = (0, import_ds_system.slotObjectToDataTestIds)(DSFastListName, DSFastListSlots);
|
|
36
45
|
//# sourceMappingURL=DSFastListDefinitions.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSFastListDefinitions.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import { slotObjectToDataTestIds } from '@elliemae/ds-system';\n\nexport const DSFastListName = 'DSFastList';\nexport const DSFastListSlots = {\n CONTAINER: 'container',\n WRAPPER_LIST: 'wrapper-list',\n ITEM: 'item',\n};\n\nexport const DSCardV3DataTestIds = slotObjectToDataTestIds(DSFastListName, DSFastListSlots);\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAwC;AAEjC,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAAA,EAC7B,WAAW;AAAA,EACX,cAAc;AAAA,EACd,MAAM;AACR;AAEO,MAAM,0BAAsB,0CAAwB,gBAAgB,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/FastList.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/FastList.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["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 './DSFastListDefinitions.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 = (props: DSFastListT.Props) => <List {...props} />;\n\nDSFastList.propTypes = DSFastListPropTypes;\nDSFastList.displayName = DSFastListName;\nconst DSFastListWithSchema = describe(DSFastList).description('DSFastList');\nDSFastListWithSchema.propTypes = DSFastListPropTypes;\n\nexport { DSFastList, DSFastListWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["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 './DSFastListDefinitions.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.propTypes = DSFastListPropTypes;\nDSFastList.displayName = DSFastListName;\nconst DSFastListWithSchema = describe(DSFastList).description('DSFastList');\nDSFastListWithSchema.propTypes = DSFastListPropTypes;\n\nexport { DSFastList, DSFastListWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADS+C;AARtE,8BAAyB;AACzB,kBAAqB;AACrB,mCAAsD;AACtD,mCAA+B;AAK/B,MAAM,aAAa,CAAmB,UAAgC,4CAAC,oBAAM,GAAG,OAAO;AAEvF,WAAW,YAAY;AACvB,WAAW,cAAc;AACzB,MAAM,2BAAuB,kCAAS,UAAU,EAAE,YAAY,YAAY;AAC1E,qBAAqB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useFastList.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { uid } from 'uid';\nimport { useVirtualizer } 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\nconst estimateSize = () => 50;\n// we \"own\" the interfaces/type instead of importing from react-virtual\n// to abstract our implementation from their\ninterface VirtualItem {\n key: string | number;\n index: number;\n start: number;\n end: number;\n size: number;\n}\ntype MeasureElement = ((element: HTMLElement) => number) | ((node: Element | null) => void);\n\nexport type FastListCTX = {\n parentRef: React.MutableRefObject<HTMLDivElement | null>;\n getVirtualItems: () => VirtualItem[];\n totalSize: number;\n instanceUid: string;\n measureElement: MeasureElement;\n};\nexport const useFastList = (propsFromUser: DSFastListT.Props): FastListCTX => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSFastListT.InternalProps
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,iBAAoB;AACpB,2BAA+B;AAC/B,8BAA6C;AAC7C,mCAAoE;AACpE,8BAAiC;AAEjC,MAAM,eAAe,MAAM;AAmBpB,MAAM,cAAc,
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { uid } from 'uid';\nimport { useVirtualizer } 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\nconst estimateSize = () => 50;\n// we \"own\" the interfaces/type instead of importing from react-virtual\n// to abstract our implementation from their\ninterface VirtualItem {\n key: string | number;\n index: number;\n start: number;\n end: number;\n size: number;\n}\ntype MeasureElement = ((element: HTMLElement) => number) | ((node: Element | null) => void);\n\nexport type FastListCTX = {\n parentRef: React.MutableRefObject<HTMLDivElement | null>;\n getVirtualItems: () => VirtualItem[];\n totalSize: number;\n instanceUid: string;\n measureElement: 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>>(propsFromUser, defaultProps);\n useValidateProps(propsWithDefault, DSFastListPropTypes);\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n const { actionRef, count } = propsWithDefault;\n const parentRef = React.useRef<HTMLDivElement>(null);\n const useVirtualHelpers = useVirtualizer({\n count,\n getScrollElement: () => parentRef.current,\n overscan: 15,\n estimateSize,\n });\n const totalSize = useVirtualHelpers.getTotalSize();\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.scrollTo = useVirtualHelpers.scrollToIndex;\n }\n }, [actionRef, useVirtualHelpers]);\n\n const instanceUid = React.useMemo(() => `ds-fast-list-${uid(6)}`, []);\n return React.useMemo(\n () => ({\n parentRef,\n getVirtualItems: useVirtualHelpers.getVirtualItems,\n totalSize,\n instanceUid,\n measureElement: useVirtualHelpers.measureElement,\n }),\n [useVirtualHelpers.getVirtualItems, useVirtualHelpers.measureElement, totalSize, instanceUid],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,iBAAoB;AACpB,2BAA+B;AAC/B,8BAA6C;AAC7C,mCAAoE;AACpE,8BAAiC;AAEjC,MAAM,eAAe,MAAM;AAmBpB,MAAM,cAAc,CAAK,kBAAqD;AAInF,QAAM,uBAAmB,sDAA2D,eAAe,yCAAY;AAC/G,gDAAiB,kBAAkB,gDAAmB;AAItD,QAAM,EAAE,WAAW,MAAM,IAAI;AAC7B,QAAM,YAAY,aAAAA,QAAM,OAAuB,IAAI;AACnD,QAAM,wBAAoB,qCAAe;AAAA,IACvC;AAAA,IACA,kBAAkB,MAAM,UAAU;AAAA,IAClC,UAAU;AAAA,IACV;AAAA,EACF,CAAC;AACD,QAAM,YAAY,kBAAkB,aAAa;AACjD,eAAAA,QAAM,UAAU,MAAM;AACpB,QAAI,aAAa,UAAU,SAAS;AAClC,gBAAU,QAAQ,WAAW,kBAAkB;AAAA,IACjD;AAAA,EACF,GAAG,CAAC,WAAW,iBAAiB,CAAC;AAEjC,QAAM,cAAc,aAAAA,QAAM,QAAQ,MAAM,oBAAgB,gBAAI,CAAC,KAAK,CAAC,CAAC;AACpE,SAAO,aAAAA,QAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA,iBAAiB,kBAAkB;AAAA,MACnC;AAAA,MACA;AAAA,MACA,gBAAgB,kBAAkB;AAAA,IACpC;AAAA,IACA,CAAC,kBAAkB,iBAAiB,kBAAkB,gBAAgB,WAAW,WAAW;AAAA,EAC9F;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useValidateProps.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport type { WeakValidationMap } from 'react';\nimport { type DSFastListT } from '../react-desc-prop-types.js';\nimport { DSFastListName } from '../DSFastListDefinitions.js';\n\nexport const useValidateProps = (props: DSFastListT.InternalProps
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,8BAA+C;AAG/C,mCAA+B;AAExB,MAAM,mBAAmB,
|
|
4
|
+
"sourcesContent": ["import { useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport type { WeakValidationMap } from 'react';\nimport { type DSFastListT } from '../react-desc-prop-types.js';\nimport { DSFastListName } from '../DSFastListDefinitions.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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,8BAA+C;AAG/C,mCAA+B;AAExB,MAAM,mBAAmB,CAC9B,OACA,cACS;AAET,8DAA+B,OAAO,WAAW,2CAAc;AACjE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/parts/List.js
CHANGED
|
@@ -34,9 +34,35 @@ module.exports = __toCommonJS(List_exports);
|
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
35
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
36
|
var import_react = __toESM(require("react"));
|
|
37
|
-
var
|
|
37
|
+
var import_ds_system = require("@elliemae/ds-system");
|
|
38
38
|
var import_useFastList = require("../hooks/useFastList.js");
|
|
39
|
-
|
|
39
|
+
var import_DSFastListDefinitions = require("../DSFastListDefinitions.js");
|
|
40
|
+
const StyledList = (0, import_ds_system.styled)("div", {
|
|
41
|
+
name: import_DSFastListDefinitions.DSFastListName,
|
|
42
|
+
slot: import_DSFastListDefinitions.DSFastListSlots.WRAPPER_LIST
|
|
43
|
+
})`
|
|
44
|
+
width: 100%;
|
|
45
|
+
position: relative;
|
|
46
|
+
`;
|
|
47
|
+
const StyledListItem = (0, import_ds_system.styled)("div", {
|
|
48
|
+
name: import_DSFastListDefinitions.DSFastListName,
|
|
49
|
+
slot: import_DSFastListDefinitions.DSFastListSlots.ITEM
|
|
50
|
+
})`
|
|
51
|
+
position: absolute;
|
|
52
|
+
top: 0;
|
|
53
|
+
left: 0;
|
|
54
|
+
width: 100%;
|
|
55
|
+
`;
|
|
56
|
+
const StyledListContainer = (0, import_ds_system.styled)("div", {
|
|
57
|
+
name: import_DSFastListDefinitions.DSFastListName,
|
|
58
|
+
slot: import_DSFastListDefinitions.DSFastListSlots.CONTAINER
|
|
59
|
+
})`
|
|
60
|
+
overflow: auto;
|
|
61
|
+
width: 100%;
|
|
62
|
+
height: 100%;
|
|
63
|
+
padding-bottom: 0;
|
|
64
|
+
`;
|
|
65
|
+
const List = (props) => {
|
|
40
66
|
const { parentRef, getVirtualItems, totalSize, instanceUid, measureElement } = (0, import_useFastList.useFastList)(props);
|
|
41
67
|
const { ItemRenderer, extraItemProps, getId } = props;
|
|
42
68
|
const virtualItems = getVirtualItems();
|
|
@@ -44,43 +70,33 @@ const List = import_react.default.memo((props) => {
|
|
|
44
70
|
(node) => measureElement(node),
|
|
45
71
|
[measureElement]
|
|
46
72
|
);
|
|
73
|
+
const getOwnerProps = (0, import_react.useCallback)(() => props, [props]);
|
|
47
74
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
48
|
-
|
|
75
|
+
StyledListContainer,
|
|
49
76
|
{
|
|
50
|
-
|
|
51
|
-
"data-testid": import_FastListDataTestID.LIST_DATA_TESTID.CONTAINER,
|
|
52
|
-
style: {
|
|
53
|
-
width: "100%",
|
|
54
|
-
height: "100%",
|
|
55
|
-
paddingBottom: 0,
|
|
56
|
-
overflow: "auto"
|
|
57
|
-
},
|
|
77
|
+
innerRef: parentRef,
|
|
58
78
|
tabIndex: -1,
|
|
59
79
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
|
-
|
|
80
|
+
StyledList,
|
|
61
81
|
{
|
|
62
82
|
style: {
|
|
63
|
-
|
|
64
|
-
height: `${totalSize}px`,
|
|
65
|
-
position: "relative"
|
|
83
|
+
height: `${totalSize}px`
|
|
66
84
|
},
|
|
67
85
|
role: "list",
|
|
86
|
+
getOwnerProps,
|
|
68
87
|
children: virtualItems.map((virtualItem) => {
|
|
69
88
|
const { index, start } = virtualItem;
|
|
70
89
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
71
|
-
|
|
90
|
+
StyledListItem,
|
|
72
91
|
{
|
|
73
|
-
|
|
92
|
+
innerRef: measureRef,
|
|
74
93
|
"data-index": index,
|
|
75
94
|
style: {
|
|
76
|
-
position: "absolute",
|
|
77
|
-
top: 0,
|
|
78
|
-
left: 0,
|
|
79
|
-
width: "100%",
|
|
80
95
|
transform: `translateY(${start}px)`
|
|
81
96
|
},
|
|
82
97
|
role: "listitem",
|
|
83
|
-
|
|
98
|
+
getOwnerProps,
|
|
99
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemRenderer, { extraItemProps, index })
|
|
84
100
|
},
|
|
85
101
|
getId(index)
|
|
86
102
|
);
|
|
@@ -90,5 +106,5 @@ const List = import_react.default.memo((props) => {
|
|
|
90
106
|
},
|
|
91
107
|
instanceUid
|
|
92
108
|
);
|
|
93
|
-
}
|
|
109
|
+
};
|
|
94
110
|
//# sourceMappingURL=List.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/parts/List.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React, { useCallback } from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { useFastList } from '../hooks/useFastList.js';\nimport type { DSFastListT } from '../react-desc-prop-types.js';\nimport { DSFastListName, DSFastListSlots } from '../DSFastListDefinitions.js';\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 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 { parentRef, getVirtualItems, totalSize, instanceUid, measureElement } = useFastList(props);\n const { ItemRenderer, extraItemProps, getId } = props;\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\n return (\n <StyledListContainer\n key={instanceUid}\n innerRef={parentRef}\n // firefox needs this tabIndex to prevent scrolling\n tabIndex={-1}\n >\n <StyledList\n style={{\n height: `${totalSize}px`,\n }}\n role=\"list\"\n getOwnerProps={getOwnerProps}\n >\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 >\n <ItemRenderer extraItemProps={extraItemProps} index={index} />\n </StyledListItem>\n );\n })}\n </StyledList>\n </StyledListContainer>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADwET;AAxEd,mBAAmC;AACnC,uBAAuB;AACvB,yBAA4B;AAE5B,mCAAgD;AAChD,MAAM,iBAAa,yBAAO,OAAO;AAAA,EAC/B,MAAM;AAAA,EACN,MAAM,6CAAgB;AACxB,CAAC;AAAA;AAAA;AAAA;AAKD,MAAM,qBAAiB,yBAAO,OAAO;AAAA,EACnC,MAAM;AAAA,EACN,MAAM,6CAAgB;AACxB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAOD,MAAM,0BAAsB,yBAAO,OAAO;AAAA,EACxC,MAAM;AAAA,EACN,MAAM,6CAAgB;AACxB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAOM,MAAM,OAAO,CAAmB,UAAgC;AACrE,QAAM,EAAE,WAAW,iBAAiB,WAAW,aAAa,eAAe,QAAI,gCAAY,KAAK;AAChG,QAAM,EAAE,cAAc,gBAAgB,MAAM,IAAI;AAEhD,QAAM,eAAe,gBAAgB;AACrC,QAAM,aAA8C,aAAAA,QAAM;AAAA,IACxD,CAAC,SAAyB,eAAe,IAAI;AAAA,IAC7C,CAAC,cAAc;AAAA,EACjB;AAEA,QAAM,oBAAgB,0BAAY,MAAM,OAAO,CAAC,KAAK,CAAC;AAEtD,SACE;AAAA,IAAC;AAAA;AAAA,MAEC,UAAU;AAAA,MAEV,UAAU;AAAA,MAEV;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,QAAQ,GAAG;AAAA,UACb;AAAA,UACA,MAAK;AAAA,UACL;AAAA,UAEC,uBAAa,IAAI,CAAC,gBAAgB;AACjC,kBAAM,EAAE,OAAO,MAAM,IAAI;AACzB,mBACE;AAAA,cAAC;AAAA;AAAA,gBACC,UAAU;AAAA,gBACV,cAAY;AAAA,gBACZ,OAAO;AAAA,kBACL,WAAW,cAAc;AAAA,gBAC3B;AAAA,gBACA,MAAK;AAAA,gBAEL;AAAA,gBAEA,sDAAC,gBAAa,gBAAgC,OAAc;AAAA;AAAA,cAHvD,MAAM,KAAK;AAAA,YAIlB;AAAA,UAEJ,CAAC;AAAA;AAAA,MACH;AAAA;AAAA,IA7BK;AAAA,EA8BP;AAEJ;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -48,6 +48,7 @@ const DSFastListPropTypes = {
|
|
|
48
48
|
"Render function for each item"
|
|
49
49
|
),
|
|
50
50
|
count: import_ds_props_helpers.PropTypes.number.isRequired.description("Number of items to render"),
|
|
51
|
-
extraItemProps: import_ds_props_helpers.PropTypes.object.description("Extra props to pass to each item")
|
|
51
|
+
extraItemProps: import_ds_props_helpers.PropTypes.object.description("Extra props to pass to each item"),
|
|
52
|
+
getId: import_ds_props_helpers.PropTypes.func.isRequired.description("Function to get the key for each item")
|
|
52
53
|
};
|
|
53
54
|
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react-desc-prop-types.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\nimport type { DSFastListSlots, DSFastListName } from './DSFastListDefinitions.js';\nexport declare namespace DSFastListT {\n type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';\n type ScrollToOptions = {\n align: ScrollAlignment;\n };\n\n export type ActionRef = {\n scrollTo?: (index: number, options?: ScrollToOptions | undefined) => void;\n };\n\n export interface OptionalProps<T>\n extends TypescriptHelpersT.PropsForGlobalOnSlots<typeof DSFastListName, typeof DSFastListSlots> {\n actionRef?: React.MutableRefObject<ActionRef>;\n extraItemProps?: T;\n }\n\n export interface RequiredProps<T> {\n ItemRenderer: React.ComponentType<{ index: number; extraItemProps?: T }>;\n count: number;\n getId: (index: number) => string | number;\n }\n\n export interface DefaultProps {}\n\n type PropsT<D, R, O> = Partial<D> & R & O;\n type InternalPropsT<D, R, O> = D & R & O;\n\n export type Props<T> = PropsT<DefaultProps, RequiredProps<T>, OptionalProps<T>>;\n export type InternalProps<T> = InternalPropsT<DefaultProps, RequiredProps<T>, OptionalProps<T>>;\n}\n\nexport const defaultProps: DSFastListT.DefaultProps = {};\n\nexport const DSFastListPropTypes = {\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(`((index: number, { align: 'start' | 'center' | 'end' | 'auto' }) => void)`),\n }),\n ]),\n }).description(`mutable reference where methods will be stored`),\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} as React.WeakValidationMap<unknown>;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,8BAA0B;AAiCnB,MAAM,eAAyC,CAAC;AAEhD,MAAM,sBAAsB;AAAA,EACjC,WAAW,kCAAU,MAAM;AAAA,IACzB,SAAS,kCAAU,UAAU;AAAA,MAC3B,kCAAU,MAAM,CAAC,IAAI,CAAC;AAAA,MACtB,kCAAU,MAAM;AAAA,QACd,UAAU,kCAAU,KACjB,YAAY,mCAAmC,EAC/C,UAAU,2EAA2E;AAAA,MAC1F,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC,EAAE,YAAY,gDAAgD;AAAA,EAC/D,cAAc,kCAAU,UAAU,CAAC,kCAAU,QAAQ,kCAAU,IAAI,CAAC,EAAE,WAAW;AAAA,IAC/E;AAAA,EACF;AAAA,EACA,OAAO,kCAAU,OAAO,WAAW,YAAY,2BAA2B;AAAA,EAC1E,gBAAgB,kCAAU,OAAO,YAAY,kCAAkC;AAAA,EAC/E,OAAO,kCAAU,KAAK,WAAW,YAAY,uCAAuC;AACtF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -25,6 +25,8 @@ var React = __toESM(require("react"));
|
|
|
25
25
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
26
|
var import_react = require("react");
|
|
27
27
|
var import__ = require("../index.js");
|
|
28
|
+
const data = [1, 2, 3];
|
|
29
|
+
const extraProps = { data };
|
|
28
30
|
const MockItemRenderer = ({ index }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {});
|
|
29
31
|
const actionRef = (0, import_react.createRef)();
|
|
30
32
|
const testRequiredProps = {
|
|
@@ -34,7 +36,7 @@ const testRequiredProps = {
|
|
|
34
36
|
};
|
|
35
37
|
const testOptionalProps = {
|
|
36
38
|
actionRef,
|
|
37
|
-
extraItemProps: {
|
|
39
|
+
extraItemProps: { data }
|
|
38
40
|
};
|
|
39
41
|
const testPartialDefaults = {};
|
|
40
42
|
const testProps = {
|
|
@@ -63,14 +65,14 @@ const testExplicitDefinition = {
|
|
|
63
65
|
count: 0,
|
|
64
66
|
getId: (index) => "",
|
|
65
67
|
actionRef,
|
|
66
|
-
extraItemProps: {
|
|
68
|
+
extraItemProps: { data }
|
|
67
69
|
};
|
|
68
70
|
const testInferedTypeCompatibility = {
|
|
69
71
|
ItemRenderer: MockItemRenderer,
|
|
70
72
|
count: 0,
|
|
71
73
|
getId: (index) => "",
|
|
72
74
|
actionRef,
|
|
73
|
-
extraItemProps: {
|
|
75
|
+
extraItemProps: { data }
|
|
74
76
|
};
|
|
75
77
|
const testDefinitionAsConst = {
|
|
76
78
|
ItemRenderer: MockItemRenderer,
|
|
@@ -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\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSFastListT.Props
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;
|
|
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<{ scrollTo: (index: number) => void }>;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {\n ItemRenderer: MockItemRenderer,\n count: 0,\n getId: (index: number) => '',\n};\n\nconst testOptionalProps: ComponentPropsOptionalProps = {\n actionRef: actionRef,\n extraItemProps: { data },\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\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: 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 testInferedTypeCompatibility = {\n ItemRenderer: MockItemRenderer,\n count: 0,\n getId: (index: number) => '',\n actionRef: actionRef,\n extraItemProps: { data },\n} as ComponentPropsForApp;\n\nconst testDefinitionAsConst = {\n ItemRenderer: MockItemRenderer,\n count: 0,\n getId: (index: number) => '',\n actionRef: actionRef,\n extraItemProps: { foo: 'bar' },\n} as const;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <DSFastList {...testExplicitDefinition} />\n <DSFastList {...testInferedTypeCompatibility} />\n <DSFastList {...testDefinitionAsConst} />\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 </>\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;AAEhE,MAAM,gBAAY,wBAAU;AAE5B,MAAM,oBAAiD;AAAA,EACrD,cAAc;AAAA,EACd,OAAO;AAAA,EACP,OAAO,CAAC,UAAkB;AAC5B;AAEA,MAAM,oBAAiD;AAAA,EACrD;AAAA,EACA,gBAAgB,EAAE,KAAK;AACzB;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,CAAC;AAEpE,MAAM,oBAA6C;AAAA,EACjD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,4BAA4B;AAAA,EAChC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAGA,MAAM,yBAA+C;AAAA,EACnD,cAAc;AAAA,EACd,OAAO;AAAA,EACP,OAAO,CAAC,UAAkB;AAAA,EAC1B;AAAA,EACA,gBAAgB,EAAE,KAAK;AACzB;AAGA,MAAM,+BAA+B;AAAA,EACnC,cAAc;AAAA,EACd,OAAO;AAAA,EACP,OAAO,CAAC,UAAkB;AAAA,EAC1B;AAAA,EACA,gBAAgB,EAAE,KAAK;AACzB;AAEA,MAAM,wBAAwB;AAAA,EAC5B,cAAc;AAAA,EACd,OAAO;AAAA,EACP,OAAO,CAAC,UAAkB;AAAA,EAC1B;AAAA,EACA,gBAAgB,EAAE,KAAK,MAAM;AAC/B;AAEA,MAAM,wBAAwB,MAC5B,4EAEE;AAAA,8CAAC,uBAAY,GAAG,wBAAwB;AAAA,EACxC,4CAAC,uBAAY,GAAG,8BAA8B;AAAA,EAC9C,4CAAC,uBAAY,GAAG,uBAAuB;AAAA,EAEvC;AAAA,IAAC;AAAA;AAAA,MACC,cAAc;AAAA,MACd,OAAO;AAAA,MACP,OAAO,CAAC,UAAkB;AAAA,MAC1B;AAAA,MACA,gBAAgB,EAAE,KAAK,MAAM;AAAA;AAAA,EAC/B;AAAA,GACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { slotObjectToDataTestIds } from "@elliemae/ds-system";
|
|
2
3
|
const DSFastListName = "DSFastList";
|
|
4
|
+
const DSFastListSlots = {
|
|
5
|
+
CONTAINER: "container",
|
|
6
|
+
WRAPPER_LIST: "wrapper-list",
|
|
7
|
+
ITEM: "item"
|
|
8
|
+
};
|
|
9
|
+
const DSCardV3DataTestIds = slotObjectToDataTestIds(DSFastListName, DSFastListSlots);
|
|
3
10
|
export {
|
|
4
|
-
|
|
11
|
+
DSCardV3DataTestIds,
|
|
12
|
+
DSFastListName,
|
|
13
|
+
DSFastListSlots
|
|
5
14
|
};
|
|
6
15
|
//# sourceMappingURL=DSFastListDefinitions.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSFastListDefinitions.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { slotObjectToDataTestIds } from '@elliemae/ds-system';\n\nexport const DSFastListName = 'DSFastList';\nexport const DSFastListSlots = {\n CONTAINER: 'container',\n WRAPPER_LIST: 'wrapper-list',\n ITEM: 'item',\n};\n\nexport const DSCardV3DataTestIds = slotObjectToDataTestIds(DSFastListName, DSFastListSlots);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,+BAA+B;AAEjC,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAAA,EAC7B,WAAW;AAAA,EACX,cAAc;AAAA,EACd,MAAM;AACR;AAEO,MAAM,sBAAsB,wBAAwB,gBAAgB,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
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 './DSFastListDefinitions.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 = (props: DSFastListT.Props) => <List {...props} />;\n\nDSFastList.propTypes = DSFastListPropTypes;\nDSFastList.displayName = DSFastListName;\nconst DSFastListWithSchema = describe(DSFastList).description('DSFastList');\nDSFastListWithSchema.propTypes = DSFastListPropTypes;\n\nexport { DSFastList, DSFastListWithSchema };\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
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 './DSFastListDefinitions.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.propTypes = DSFastListPropTypes;\nDSFastList.displayName = DSFastListName;\nconst DSFastListWithSchema = describe(DSFastList).description('DSFastList');\nDSFastListWithSchema.propTypes = DSFastListPropTypes;\n\nexport { DSFastList, DSFastListWithSchema };\n"],
|
|
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,YAAY;AACvB,WAAW,cAAc;AACzB,MAAM,uBAAuB,SAAS,UAAU,EAAE,YAAY,YAAY;AAC1E,qBAAqB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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 } 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\nconst estimateSize = () => 50;\n// we \"own\" the interfaces/type instead of importing from react-virtual\n// to abstract our implementation from their\ninterface VirtualItem {\n key: string | number;\n index: number;\n start: number;\n end: number;\n size: number;\n}\ntype MeasureElement = ((element: HTMLElement) => number) | ((node: Element | null) => void);\n\nexport type FastListCTX = {\n parentRef: React.MutableRefObject<HTMLDivElement | null>;\n getVirtualItems: () => VirtualItem[];\n totalSize: number;\n instanceUid: string;\n measureElement: MeasureElement;\n};\nexport const useFastList = (propsFromUser: DSFastListT.Props): FastListCTX => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSFastListT.InternalProps
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,YAAW;AAClB,SAAS,WAAW;AACpB,SAAS,sBAAsB;AAC/B,SAAS,oCAAoC;AAC7C,SAA2B,qBAAqB,oBAAoB;AACpE,SAAS,wBAAwB;AAEjC,MAAM,eAAe,MAAM;AAmBpB,MAAM,cAAc,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { uid } from 'uid';\nimport { useVirtualizer } 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\nconst estimateSize = () => 50;\n// we \"own\" the interfaces/type instead of importing from react-virtual\n// to abstract our implementation from their\ninterface VirtualItem {\n key: string | number;\n index: number;\n start: number;\n end: number;\n size: number;\n}\ntype MeasureElement = ((element: HTMLElement) => number) | ((node: Element | null) => void);\n\nexport type FastListCTX = {\n parentRef: React.MutableRefObject<HTMLDivElement | null>;\n getVirtualItems: () => VirtualItem[];\n totalSize: number;\n instanceUid: string;\n measureElement: 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>>(propsFromUser, defaultProps);\n useValidateProps(propsWithDefault, DSFastListPropTypes);\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n const { actionRef, count } = propsWithDefault;\n const parentRef = React.useRef<HTMLDivElement>(null);\n const useVirtualHelpers = useVirtualizer({\n count,\n getScrollElement: () => parentRef.current,\n overscan: 15,\n estimateSize,\n });\n const totalSize = useVirtualHelpers.getTotalSize();\n React.useEffect(() => {\n if (actionRef && actionRef.current) {\n actionRef.current.scrollTo = useVirtualHelpers.scrollToIndex;\n }\n }, [actionRef, useVirtualHelpers]);\n\n const instanceUid = React.useMemo(() => `ds-fast-list-${uid(6)}`, []);\n return React.useMemo(\n () => ({\n parentRef,\n getVirtualItems: useVirtualHelpers.getVirtualItems,\n totalSize,\n instanceUid,\n measureElement: useVirtualHelpers.measureElement,\n }),\n [useVirtualHelpers.getVirtualItems, useVirtualHelpers.measureElement, totalSize, instanceUid],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,YAAW;AAClB,SAAS,WAAW;AACpB,SAAS,sBAAsB;AAC/B,SAAS,oCAAoC;AAC7C,SAA2B,qBAAqB,oBAAoB;AACpE,SAAS,wBAAwB;AAEjC,MAAM,eAAe,MAAM;AAmBpB,MAAM,cAAc,CAAK,kBAAqD;AAInF,QAAM,mBAAmB,6BAA2D,eAAe,YAAY;AAC/G,mBAAiB,kBAAkB,mBAAmB;AAItD,QAAM,EAAE,WAAW,MAAM,IAAI;AAC7B,QAAM,YAAYA,OAAM,OAAuB,IAAI;AACnD,QAAM,oBAAoB,eAAe;AAAA,IACvC;AAAA,IACA,kBAAkB,MAAM,UAAU;AAAA,IAClC,UAAU;AAAA,IACV;AAAA,EACF,CAAC;AACD,QAAM,YAAY,kBAAkB,aAAa;AACjD,EAAAA,OAAM,UAAU,MAAM;AACpB,QAAI,aAAa,UAAU,SAAS;AAClC,gBAAU,QAAQ,WAAW,kBAAkB;AAAA,IACjD;AAAA,EACF,GAAG,CAAC,WAAW,iBAAiB,CAAC;AAEjC,QAAM,cAAcA,OAAM,QAAQ,MAAM,gBAAgB,IAAI,CAAC,KAAK,CAAC,CAAC;AACpE,SAAOA,OAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA,iBAAiB,kBAAkB;AAAA,MACnC;AAAA,MACA;AAAA,MACA,gBAAgB,kBAAkB;AAAA,IACpC;AAAA,IACA,CAAC,kBAAkB,iBAAiB,kBAAkB,gBAAgB,WAAW,WAAW;AAAA,EAC9F;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -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 '../DSFastListDefinitions.js';\n\nexport const useValidateProps = (props: DSFastListT.InternalProps
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,sCAAsC;AAG/C,SAAS,sBAAsB;AAExB,MAAM,mBAAmB,
|
|
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 '../DSFastListDefinitions.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
|
+
"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/parts/List.js
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import React2 from "react";
|
|
4
|
-
import {
|
|
3
|
+
import React2, { useCallback } from "react";
|
|
4
|
+
import { styled } from "@elliemae/ds-system";
|
|
5
5
|
import { useFastList } from "../hooks/useFastList.js";
|
|
6
|
-
|
|
6
|
+
import { DSFastListName, DSFastListSlots } from "../DSFastListDefinitions.js";
|
|
7
|
+
const StyledList = styled("div", {
|
|
8
|
+
name: DSFastListName,
|
|
9
|
+
slot: DSFastListSlots.WRAPPER_LIST
|
|
10
|
+
})`
|
|
11
|
+
width: 100%;
|
|
12
|
+
position: relative;
|
|
13
|
+
`;
|
|
14
|
+
const StyledListItem = styled("div", {
|
|
15
|
+
name: DSFastListName,
|
|
16
|
+
slot: DSFastListSlots.ITEM
|
|
17
|
+
})`
|
|
18
|
+
position: absolute;
|
|
19
|
+
top: 0;
|
|
20
|
+
left: 0;
|
|
21
|
+
width: 100%;
|
|
22
|
+
`;
|
|
23
|
+
const StyledListContainer = styled("div", {
|
|
24
|
+
name: DSFastListName,
|
|
25
|
+
slot: DSFastListSlots.CONTAINER
|
|
26
|
+
})`
|
|
27
|
+
overflow: auto;
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
padding-bottom: 0;
|
|
31
|
+
`;
|
|
32
|
+
const List = (props) => {
|
|
7
33
|
const { parentRef, getVirtualItems, totalSize, instanceUid, measureElement } = useFastList(props);
|
|
8
34
|
const { ItemRenderer, extraItemProps, getId } = props;
|
|
9
35
|
const virtualItems = getVirtualItems();
|
|
@@ -11,43 +37,33 @@ const List = React2.memo((props) => {
|
|
|
11
37
|
(node) => measureElement(node),
|
|
12
38
|
[measureElement]
|
|
13
39
|
);
|
|
40
|
+
const getOwnerProps = useCallback(() => props, [props]);
|
|
14
41
|
return /* @__PURE__ */ jsx(
|
|
15
|
-
|
|
42
|
+
StyledListContainer,
|
|
16
43
|
{
|
|
17
|
-
|
|
18
|
-
"data-testid": LIST_DATA_TESTID.CONTAINER,
|
|
19
|
-
style: {
|
|
20
|
-
width: "100%",
|
|
21
|
-
height: "100%",
|
|
22
|
-
paddingBottom: 0,
|
|
23
|
-
overflow: "auto"
|
|
24
|
-
},
|
|
44
|
+
innerRef: parentRef,
|
|
25
45
|
tabIndex: -1,
|
|
26
46
|
children: /* @__PURE__ */ jsx(
|
|
27
|
-
|
|
47
|
+
StyledList,
|
|
28
48
|
{
|
|
29
49
|
style: {
|
|
30
|
-
|
|
31
|
-
height: `${totalSize}px`,
|
|
32
|
-
position: "relative"
|
|
50
|
+
height: `${totalSize}px`
|
|
33
51
|
},
|
|
34
52
|
role: "list",
|
|
53
|
+
getOwnerProps,
|
|
35
54
|
children: virtualItems.map((virtualItem) => {
|
|
36
55
|
const { index, start } = virtualItem;
|
|
37
56
|
return /* @__PURE__ */ jsx(
|
|
38
|
-
|
|
57
|
+
StyledListItem,
|
|
39
58
|
{
|
|
40
|
-
|
|
59
|
+
innerRef: measureRef,
|
|
41
60
|
"data-index": index,
|
|
42
61
|
style: {
|
|
43
|
-
position: "absolute",
|
|
44
|
-
top: 0,
|
|
45
|
-
left: 0,
|
|
46
|
-
width: "100%",
|
|
47
62
|
transform: `translateY(${start}px)`
|
|
48
63
|
},
|
|
49
64
|
role: "listitem",
|
|
50
|
-
|
|
65
|
+
getOwnerProps,
|
|
66
|
+
children: /* @__PURE__ */ jsx(ItemRenderer, { extraItemProps, index })
|
|
51
67
|
},
|
|
52
68
|
getId(index)
|
|
53
69
|
);
|
|
@@ -57,7 +73,7 @@ const List = React2.memo((props) => {
|
|
|
57
73
|
},
|
|
58
74
|
instanceUid
|
|
59
75
|
);
|
|
60
|
-
}
|
|
76
|
+
};
|
|
61
77
|
export {
|
|
62
78
|
List
|
|
63
79
|
};
|
|
@@ -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 from 'react';\nimport {
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback } from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { useFastList } from '../hooks/useFastList.js';\nimport type { DSFastListT } from '../react-desc-prop-types.js';\nimport { DSFastListName, DSFastListSlots } from '../DSFastListDefinitions.js';\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 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 { parentRef, getVirtualItems, totalSize, instanceUid, measureElement } = useFastList(props);\n const { ItemRenderer, extraItemProps, getId } = props;\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\n return (\n <StyledListContainer\n key={instanceUid}\n innerRef={parentRef}\n // firefox needs this tabIndex to prevent scrolling\n tabIndex={-1}\n >\n <StyledList\n style={{\n height: `${totalSize}px`,\n }}\n role=\"list\"\n getOwnerProps={getOwnerProps}\n >\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 >\n <ItemRenderer extraItemProps={extraItemProps} index={index} />\n </StyledListItem>\n );\n })}\n </StyledList>\n </StyledListContainer>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACwET;AAxEd,OAAOA,UAAS,mBAAmB;AACnC,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAE5B,SAAS,gBAAgB,uBAAuB;AAChD,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,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAOD,MAAM,sBAAsB,OAAO,OAAO;AAAA,EACxC,MAAM;AAAA,EACN,MAAM,gBAAgB;AACxB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAOM,MAAM,OAAO,CAAmB,UAAgC;AACrE,QAAM,EAAE,WAAW,iBAAiB,WAAW,aAAa,eAAe,IAAI,YAAY,KAAK;AAChG,QAAM,EAAE,cAAc,gBAAgB,MAAM,IAAI;AAEhD,QAAM,eAAe,gBAAgB;AACrC,QAAM,aAA8CA,OAAM;AAAA,IACxD,CAAC,SAAyB,eAAe,IAAI;AAAA,IAC7C,CAAC,cAAc;AAAA,EACjB;AAEA,QAAM,gBAAgB,YAAY,MAAM,OAAO,CAAC,KAAK,CAAC;AAEtD,SACE;AAAA,IAAC;AAAA;AAAA,MAEC,UAAU;AAAA,MAEV,UAAU;AAAA,MAEV;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,QAAQ,GAAG;AAAA,UACb;AAAA,UACA,MAAK;AAAA,UACL;AAAA,UAEC,uBAAa,IAAI,CAAC,gBAAgB;AACjC,kBAAM,EAAE,OAAO,MAAM,IAAI;AACzB,mBACE;AAAA,cAAC;AAAA;AAAA,gBACC,UAAU;AAAA,gBACV,cAAY;AAAA,gBACZ,OAAO;AAAA,kBACL,WAAW,cAAc;AAAA,gBAC3B;AAAA,gBACA,MAAK;AAAA,gBAEL;AAAA,gBAEA,8BAAC,gBAAa,gBAAgC,OAAc;AAAA;AAAA,cAHvD,MAAM,KAAK;AAAA,YAIlB;AAAA,UAEJ,CAAC;AAAA;AAAA,MACH;AAAA;AAAA,IA7BK;AAAA,EA8BP;AAEJ;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -14,7 +14,8 @@ const DSFastListPropTypes = {
|
|
|
14
14
|
"Render function for each item"
|
|
15
15
|
),
|
|
16
16
|
count: PropTypes.number.isRequired.description("Number of items to render"),
|
|
17
|
-
extraItemProps: PropTypes.object.description("Extra props to pass to each item")
|
|
17
|
+
extraItemProps: PropTypes.object.description("Extra props to pass to each item"),
|
|
18
|
+
getId: PropTypes.func.isRequired.description("Function to get the key for each item")
|
|
18
19
|
};
|
|
19
20
|
export {
|
|
20
21
|
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", "/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\nimport { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\nimport type { DSFastListSlots, DSFastListName } from './DSFastListDefinitions.js';\nexport declare namespace DSFastListT {\n type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';\n type ScrollToOptions = {\n align: ScrollAlignment;\n };\n\n export type ActionRef = {\n scrollTo?: (index: number, options?: ScrollToOptions | undefined) => void;\n };\n\n export interface OptionalProps<T>\n extends TypescriptHelpersT.PropsForGlobalOnSlots<typeof DSFastListName, typeof DSFastListSlots> {\n actionRef?: React.MutableRefObject<ActionRef>;\n extraItemProps?: T;\n }\n\n export interface RequiredProps<T> {\n ItemRenderer: React.ComponentType<{ index: number; extraItemProps?: T }>;\n count: number;\n getId: (index: number) => string | number;\n }\n\n export interface DefaultProps {}\n\n type PropsT<D, R, O> = Partial<D> & R & O;\n type InternalPropsT<D, R, O> = D & R & O;\n\n export type Props<T> = PropsT<DefaultProps, RequiredProps<T>, OptionalProps<T>>;\n export type InternalProps<T> = InternalPropsT<DefaultProps, RequiredProps<T>, OptionalProps<T>>;\n}\n\nexport const defaultProps: DSFastListT.DefaultProps = {};\n\nexport const DSFastListPropTypes = {\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(`((index: number, { align: 'start' | 'center' | 'end' | 'auto' }) => void)`),\n }),\n ]),\n }).description(`mutable reference where methods will be stored`),\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} as React.WeakValidationMap<unknown>;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,iBAAiB;AAiCnB,MAAM,eAAyC,CAAC;AAEhD,MAAM,sBAAsB;AAAA,EACjC,WAAW,UAAU,MAAM;AAAA,IACzB,SAAS,UAAU,UAAU;AAAA,MAC3B,UAAU,MAAM,CAAC,IAAI,CAAC;AAAA,MACtB,UAAU,MAAM;AAAA,QACd,UAAU,UAAU,KACjB,YAAY,mCAAmC,EAC/C,UAAU,2EAA2E;AAAA,MAC1F,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC,EAAE,YAAY,gDAAgD;AAAA,EAC/D,cAAc,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,IAAI,CAAC,EAAE,WAAW;AAAA,IAC/E;AAAA,EACF;AAAA,EACA,OAAO,UAAU,OAAO,WAAW,YAAY,2BAA2B;AAAA,EAC1E,gBAAgB,UAAU,OAAO,YAAY,kCAAkC;AAAA,EAC/E,OAAO,UAAU,KAAK,WAAW,YAAY,uCAAuC;AACtF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,8 @@ import * as React from "react";
|
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { createRef } from "react";
|
|
4
4
|
import { DSFastList } from "../index.js";
|
|
5
|
+
const data = [1, 2, 3];
|
|
6
|
+
const extraProps = { data };
|
|
5
7
|
const MockItemRenderer = ({ index }) => /* @__PURE__ */ jsx("div", {});
|
|
6
8
|
const actionRef = createRef();
|
|
7
9
|
const testRequiredProps = {
|
|
@@ -11,7 +13,7 @@ const testRequiredProps = {
|
|
|
11
13
|
};
|
|
12
14
|
const testOptionalProps = {
|
|
13
15
|
actionRef,
|
|
14
|
-
extraItemProps: {
|
|
16
|
+
extraItemProps: { data }
|
|
15
17
|
};
|
|
16
18
|
const testPartialDefaults = {};
|
|
17
19
|
const testProps = {
|
|
@@ -40,14 +42,14 @@ const testExplicitDefinition = {
|
|
|
40
42
|
count: 0,
|
|
41
43
|
getId: (index) => "",
|
|
42
44
|
actionRef,
|
|
43
|
-
extraItemProps: {
|
|
45
|
+
extraItemProps: { data }
|
|
44
46
|
};
|
|
45
47
|
const testInferedTypeCompatibility = {
|
|
46
48
|
ItemRenderer: MockItemRenderer,
|
|
47
49
|
count: 0,
|
|
48
50
|
getId: (index) => "",
|
|
49
51
|
actionRef,
|
|
50
|
-
extraItemProps: {
|
|
52
|
+
extraItemProps: { data }
|
|
51
53
|
};
|
|
52
54
|
const testDefinitionAsConst = {
|
|
53
55
|
ItemRenderer: MockItemRenderer,
|
|
@@ -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\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSFastListT.Props
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
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<{ scrollTo: (index: number) => void }>;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {\n ItemRenderer: MockItemRenderer,\n count: 0,\n getId: (index: number) => '',\n};\n\nconst testOptionalProps: ComponentPropsOptionalProps = {\n actionRef: actionRef,\n extraItemProps: { data },\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\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: 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 testInferedTypeCompatibility = {\n ItemRenderer: MockItemRenderer,\n count: 0,\n getId: (index: number) => '',\n actionRef: actionRef,\n extraItemProps: { data },\n} as ComponentPropsForApp;\n\nconst testDefinitionAsConst = {\n ItemRenderer: MockItemRenderer,\n count: 0,\n getId: (index: number) => '',\n actionRef: actionRef,\n extraItemProps: { foo: 'bar' },\n} as const;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <DSFastList {...testExplicitDefinition} />\n <DSFastList {...testInferedTypeCompatibility} />\n <DSFastList {...testDefinitionAsConst} />\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 </>\n);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACcoC,SAyEzD,UAzEyD,KAyEzD,YAzEyD;AAb3D,SAAgC,iBAAiB;AACjD,SAAS,kBAAkB;AAG3B,MAAM,OAAO,CAAC,GAAG,GAAG,CAAC;AACrB,MAAM,aAAa,EAAE,KAAK;AAQ1B,MAAM,mBAAmB,CAAC,EAAE,MAAM,MAAyB,oBAAC,SAAI;AAEhE,MAAM,YAAY,UAAU;AAE5B,MAAM,oBAAiD;AAAA,EACrD,cAAc;AAAA,EACd,OAAO;AAAA,EACP,OAAO,CAAC,UAAkB;AAC5B;AAEA,MAAM,oBAAiD;AAAA,EACrD;AAAA,EACA,gBAAgB,EAAE,KAAK;AACzB;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,CAAC;AAEpE,MAAM,oBAA6C;AAAA,EACjD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,4BAA4B;AAAA,EAChC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAGA,MAAM,yBAA+C;AAAA,EACnD,cAAc;AAAA,EACd,OAAO;AAAA,EACP,OAAO,CAAC,UAAkB;AAAA,EAC1B;AAAA,EACA,gBAAgB,EAAE,KAAK;AACzB;AAGA,MAAM,+BAA+B;AAAA,EACnC,cAAc;AAAA,EACd,OAAO;AAAA,EACP,OAAO,CAAC,UAAkB;AAAA,EAC1B;AAAA,EACA,gBAAgB,EAAE,KAAK;AACzB;AAEA,MAAM,wBAAwB;AAAA,EAC5B,cAAc;AAAA,EACd,OAAO;AAAA,EACP,OAAO,CAAC,UAAkB;AAAA,EAC1B;AAAA,EACA,gBAAgB,EAAE,KAAK,MAAM;AAC/B;AAEA,MAAM,wBAAwB,MAC5B,iCAEE;AAAA,sBAAC,cAAY,GAAG,wBAAwB;AAAA,EACxC,oBAAC,cAAY,GAAG,8BAA8B;AAAA,EAC9C,oBAAC,cAAY,GAAG,uBAAuB;AAAA,EAEvC;AAAA,IAAC;AAAA;AAAA,MACC,cAAc;AAAA,MACd,OAAO;AAAA,MACP,OAAO,CAAC,UAAkB;AAAA,MAC1B;AAAA,MACA,gBAAgB,EAAE,KAAK,MAAM;AAAA;AAAA,EAC/B;AAAA,GACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/types/FastList.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type DSFastListT } from './react-desc-prop-types.js';
|
|
3
3
|
declare const DSFastList: {
|
|
4
|
-
(props: DSFastListT.Props): import("react/jsx-runtime.js").JSX.Element;
|
|
4
|
+
<T extends object>(props: DSFastListT.Props<T>): import("react/jsx-runtime.js").JSX.Element;
|
|
5
5
|
propTypes: React.WeakValidationMap<unknown>;
|
|
6
6
|
displayName: string;
|
|
7
7
|
};
|
|
8
|
-
declare const DSFastListWithSchema: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").DocumentedReactComponent<DSFastListT.Props
|
|
8
|
+
declare const DSFastListWithSchema: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").DocumentedReactComponent<DSFastListT.Props<object>>;
|
|
9
9
|
export { DSFastList, DSFastListWithSchema };
|
|
@@ -15,5 +15,5 @@ export type FastListCTX = {
|
|
|
15
15
|
instanceUid: string;
|
|
16
16
|
measureElement: MeasureElement;
|
|
17
17
|
};
|
|
18
|
-
export declare const useFastList: (propsFromUser: DSFastListT.Props) => FastListCTX;
|
|
18
|
+
export declare const useFastList: <T>(propsFromUser: DSFastListT.Props<T>) => FastListCTX;
|
|
19
19
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { WeakValidationMap } from 'react';
|
|
2
2
|
import { type DSFastListT } from '../react-desc-prop-types.js';
|
|
3
|
-
export declare const useValidateProps: (props: DSFastListT.InternalProps
|
|
3
|
+
export declare const useValidateProps: <T>(props: DSFastListT.InternalProps<T>, propTypes: WeakValidationMap<unknown>) => void;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { DSFastListT } from '../react-desc-prop-types.js';
|
|
3
|
-
export declare const List:
|
|
2
|
+
export declare const List: <T extends object>(props: DSFastListT.Props<T>) => import("react/jsx-runtime.js").JSX.Element;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
+
import { type TypescriptHelpersT } from '@elliemae/ds-typescript-helpers';
|
|
3
|
+
import type { DSFastListSlots, DSFastListName } from './DSFastListDefinitions.js';
|
|
2
4
|
export declare namespace DSFastListT {
|
|
3
5
|
type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';
|
|
4
6
|
type ScrollToOptions = {
|
|
@@ -7,23 +9,24 @@ export declare namespace DSFastListT {
|
|
|
7
9
|
type ActionRef = {
|
|
8
10
|
scrollTo?: (index: number, options?: ScrollToOptions | undefined) => void;
|
|
9
11
|
};
|
|
10
|
-
interface
|
|
12
|
+
interface OptionalProps<T> extends TypescriptHelpersT.PropsForGlobalOnSlots<typeof DSFastListName, typeof DSFastListSlots> {
|
|
13
|
+
actionRef?: React.MutableRefObject<ActionRef>;
|
|
14
|
+
extraItemProps?: T;
|
|
15
|
+
}
|
|
16
|
+
interface RequiredProps<T> {
|
|
11
17
|
ItemRenderer: React.ComponentType<{
|
|
12
18
|
index: number;
|
|
19
|
+
extraItemProps?: T;
|
|
13
20
|
}>;
|
|
14
21
|
count: number;
|
|
15
22
|
getId: (index: number) => string | number;
|
|
16
23
|
}
|
|
17
24
|
interface DefaultProps {
|
|
18
25
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
interface Props extends Partial<DefaultProps>, OptionalProps, RequiredProps {
|
|
24
|
-
}
|
|
25
|
-
interface InternalProps extends DefaultProps, OptionalProps, RequiredProps {
|
|
26
|
-
}
|
|
26
|
+
type PropsT<D, R, O> = Partial<D> & R & O;
|
|
27
|
+
type InternalPropsT<D, R, O> = D & R & O;
|
|
28
|
+
type Props<T> = PropsT<DefaultProps, RequiredProps<T>, OptionalProps<T>>;
|
|
29
|
+
type InternalProps<T> = InternalPropsT<DefaultProps, RequiredProps<T>, OptionalProps<T>>;
|
|
27
30
|
}
|
|
28
31
|
export declare const defaultProps: DSFastListT.DefaultProps;
|
|
29
32
|
export declare const DSFastListPropTypes: React.WeakValidationMap<unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-fast-list",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.32.0-rc.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Virtual List",
|
|
6
6
|
"files": [
|
|
@@ -61,16 +61,16 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@tanstack/react-virtual": "3.0.0-beta.54",
|
|
63
63
|
"@xstyled/system": "3.7.0",
|
|
64
|
-
"axe-core": "^4.6.3",
|
|
65
64
|
"uid": "^2.0.1",
|
|
66
|
-
"@elliemae/ds-props-helpers": "3.
|
|
67
|
-
"@elliemae/ds-system": "3.
|
|
65
|
+
"@elliemae/ds-props-helpers": "3.32.0-rc.2",
|
|
66
|
+
"@elliemae/ds-system": "3.32.0-rc.2",
|
|
67
|
+
"@elliemae/ds-typescript-helpers": "3.32.0-rc.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@elliemae/pui-cli": "~9.0.0-next.31",
|
|
71
71
|
"styled-components": "~5.3.9",
|
|
72
|
-
"@elliemae/ds-monorepo-devops": "3.
|
|
73
|
-
"@elliemae/ds-test-utils": "3.
|
|
72
|
+
"@elliemae/ds-monorepo-devops": "3.32.0-rc.2",
|
|
73
|
+
"@elliemae/ds-test-utils": "3.32.0-rc.2"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"lodash": "^4.17.21",
|