@12-apps/ui 6.38.0 → 6.39.0
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/_internal/components/data-display/DataGrid/DataGrid.body.js +3 -2
- package/dist/_internal/components/data-display/DataGrid/DataGrid.cells.js +2 -1
- package/dist/_internal/components/data-display/DataGrid/DataGrid.js +4 -4
- package/dist/_internal/components/data-display/DataGrid/DataGrid.model.js +2 -1
- package/dist/_internal/components/data-display/DataViews/DataViewsGrid.js +19 -19
- package/dist/_internal/components/data-display/DataViews/DataViewsTableBase.js +26 -26
- package/dist/_internal/components/data-display/DataViews/SaveViewModal.js +5 -5
- package/dist/_internal/components/data-display/DataViews/base-list-card-geometry.js +4 -4
- package/dist/_internal/components/data-display/DataViews/base-list-card-slots.js +3 -3
- package/dist/_internal/components/data-display/DataViews/base-list-card.js +5 -5
- package/dist/_internal/components/data-display/DataViews/data-views-columns.js +2 -2
- package/dist/_internal/components/data-display/DataViews/data-views-display-panel.js +3 -3
- package/dist/_internal/components/data-display/DataViews/data-views-display-tabs.js +2 -2
- package/dist/_internal/components/data-display/DataViews/data-views-grid-bodies.js +8 -8
- package/dist/_internal/components/data-display/DataViews/data-views-grid-helpers.js +1 -1
- package/dist/_internal/components/data-display/DataViews/data-views-grid-parts.js +16 -16
- package/dist/_internal/components/data-display/DataViews/data-views-layout-context.js +1 -1
- package/dist/_internal/components/data-display/DataViews/data-views-overflow-costs.js +4 -3
- package/dist/_internal/components/data-display/DataViews/data-views-overflow.js +3 -2
- package/dist/_internal/components/data-display/DataViews/data-views-scope-tabs.js +2 -2
- package/dist/_internal/components/data-display/DataViews/data-views-shell-toolbar.js +6 -6
- package/dist/_internal/components/data-display/DataViews/data-views-table-parts.js +6 -6
- package/dist/_internal/components/data-display/DataViews/data-views-toolbar.js +5 -5
- package/dist/_internal/components/data-display/DataViews/list-card-rails.js +2 -2
- package/dist/_internal/components/data-display/DataViews/use-data-views-state.js +3 -3
- package/dist/_internal/components/data-display/FleetMap/FleetBody.js +9 -9
- package/dist/_internal/components/data-display/FleetMap/FleetCanvas.js +8 -8
- package/dist/_internal/components/data-display/FleetMap/FleetMap.js +10 -10
- package/dist/_internal/components/data-display/MapPreview/MapDecorations.js +2 -2
- package/dist/_internal/components/data-display/MapPreview/MapPreview.hooks.js +2 -2
- package/dist/_internal/components/data-display/MapPreview/MapPreview.js +7 -7
- package/dist/_internal/components/data-display/MapPreview/MapTiles.js +2 -2
- package/dist/_internal/components/data-display/MapPreview/StaticMapView.js +4 -4
- package/dist/_internal/components/data-display/MapPreview/mapProjection.js +3 -3
- package/dist/_internal/components/data-display/MapPreview/useMapPreview.js +3 -3
- package/dist/_internal/components/data-display/Table/Table.helpers.js +5 -3
- package/dist/_internal/components/data-display/Table/Table.hooks.js +2 -1
- package/dist/_internal/components/data-display/Table/Table.js +4 -4
- package/dist/_internal/components/data-display/Table/TableParts.hooks.js +4 -2
- package/dist/_internal/components/data-display/Table/TableParts.js +4 -2
- package/dist/_internal/components/data-display/index.js +18 -18
- package/dist/_internal/components/form/Calendar/Calendar.js +5 -4
- package/dist/_internal/components/form/Calendar/CalendarDay.js +2 -1
- package/dist/_internal/components/form/Calendar/CalendarDayCell.js +3 -2
- package/dist/_internal/components/form/Calendar/CalendarMonth.js +4 -3
- package/dist/_internal/components/form/DateRangePicker/DateRangePicker.js +5 -5
- package/dist/_internal/components/form/Switch/Switch.js +4 -4
- package/dist/_internal/components/form/Switch/Switch.metrics.js +5 -1
- package/dist/_internal/components/form/Switch/Switch.parts.js +3 -3
- package/dist/_internal/components/form/Switch/Switch.styles.js +2 -2
- package/dist/_internal/components/form/index.js +9 -9
- package/dist/_internal/components/index.js +37 -37
- package/dist/_internal/components/layout/CardGrid/CardGrid.js +2 -1
- package/dist/_internal/components/layout/Resizable/Resizable.helpers.js +8 -3
- package/dist/_internal/components/layout/Resizable/Resizable.hooks.js +3 -2
- package/dist/_internal/components/layout/Resizable/Resizable.js +4 -3
- package/dist/_internal/components/layout/ScrollArea/ScrollArea.helpers.js +1 -1
- package/dist/_internal/components/layout/ScrollArea/ScrollArea.js +2 -2
- package/dist/_internal/components/layout/index.js +5 -5
- package/dist/_internal/components/utility/InfiniteScroll/InfiniteScroll.hooks.js +1 -1
- package/dist/_internal/components/utility/InfiniteScroll/InfiniteScroll.js +4 -3
- package/dist/_internal/components/utility/InfiniteScroll/InfiniteScroll.parts.js +2 -1
- package/dist/_internal/components/utility/VirtualList/VirtualList.hooks.js +6 -3
- package/dist/_internal/components/utility/VirtualList/VirtualList.js +3 -2
- package/dist/_internal/components/utility/index.js +5 -5
- package/dist/{chunk-J2DAQQQH.js → chunk-222HN7GK.js} +33 -64
- package/dist/chunk-222HN7GK.js.map +1 -0
- package/dist/{chunk-MR2HKBHS.js → chunk-27LOJVR3.js} +2 -2
- package/dist/{chunk-S3D5VBHW.js → chunk-3YOXVNO4.js} +7 -7
- package/dist/{chunk-CZIX4BW2.js → chunk-4ALF5PB5.js} +3 -3
- package/dist/{chunk-XJPJ6ESI.js → chunk-4OAKGKK5.js} +3 -3
- package/dist/{chunk-4CHROSWR.js → chunk-5ETBB2DG.js} +2 -2
- package/dist/{chunk-ATSHKSSD.js → chunk-5KNDAC24.js} +20 -7
- package/dist/chunk-5KNDAC24.js.map +1 -0
- package/dist/{chunk-ULTOQ6ZV.js → chunk-5LWB4BYX.js} +80 -89
- package/dist/chunk-5LWB4BYX.js.map +1 -0
- package/dist/{chunk-46UPILLK.js → chunk-5NT2M2JI.js} +2 -2
- package/dist/{chunk-H5BEWPEY.js → chunk-6N2EDWMG.js} +2 -2
- package/dist/{chunk-GJQYM3PM.js → chunk-6PU3JYVY.js} +2 -2
- package/dist/{chunk-PUBPZOQJ.js → chunk-AG3DY5TH.js} +8 -5
- package/dist/chunk-AG3DY5TH.js.map +1 -0
- package/dist/{chunk-PPRV4LTM.js → chunk-BWHOCNGW.js} +4 -4
- package/dist/chunk-BWHOCNGW.js.map +1 -0
- package/dist/{chunk-TUBCN4DJ.js → chunk-CB6DTWD5.js} +7 -7
- package/dist/chunk-CB6DTWD5.js.map +1 -0
- package/dist/{chunk-ZAY6OA6F.js → chunk-D4FZ3ANG.js} +15 -5
- package/dist/chunk-D4FZ3ANG.js.map +1 -0
- package/dist/{chunk-Y7F5JBAT.js → chunk-DDRKYNPB.js} +2 -2
- package/dist/{chunk-DLJGBJZW.js → chunk-DGMDQHMI.js} +16 -9
- package/dist/chunk-DGMDQHMI.js.map +1 -0
- package/dist/{chunk-IAGOUTI6.js → chunk-DNT5PZLF.js} +21 -12
- package/dist/chunk-DNT5PZLF.js.map +1 -0
- package/dist/{chunk-DZA7RSLX.js → chunk-DVSO3EG6.js} +19 -11
- package/dist/chunk-DVSO3EG6.js.map +1 -0
- package/dist/{chunk-OS6KPL4D.js → chunk-EHYI2WCJ.js} +4 -4
- package/dist/{chunk-NB3FGWU4.js → chunk-EQXIW5MQ.js} +2 -2
- package/dist/{chunk-C66RGVAS.js → chunk-ERY6D2OV.js} +6 -4
- package/dist/chunk-ERY6D2OV.js.map +1 -0
- package/dist/{chunk-M2JTIH5M.js → chunk-F44R7US6.js} +2 -2
- package/dist/{chunk-AROBXRC5.js → chunk-F7JTIHV5.js} +18 -7
- package/dist/chunk-F7JTIHV5.js.map +1 -0
- package/dist/{chunk-XJJXBUPN.js → chunk-FX26DAFF.js} +2 -2
- package/dist/{chunk-R6SN73RX.js → chunk-GLHNMTP6.js} +7 -7
- package/dist/{chunk-YU26GBNX.js → chunk-H3AQQOTI.js} +9 -4
- package/dist/chunk-H3AQQOTI.js.map +1 -0
- package/dist/{chunk-HTZNB6IV.js → chunk-H5ZTIELC.js} +23 -8
- package/dist/chunk-H5ZTIELC.js.map +1 -0
- package/dist/{chunk-GSFNH4C5.js → chunk-HBP2OU4Q.js} +15 -8
- package/dist/chunk-HBP2OU4Q.js.map +1 -0
- package/dist/{chunk-I4QA2F4L.js → chunk-HBRQPG7H.js} +5 -5
- package/dist/{chunk-HGMBY5LP.js → chunk-HQWJUHR4.js} +18 -11
- package/dist/chunk-HQWJUHR4.js.map +1 -0
- package/dist/{chunk-CNQUCNEA.js → chunk-I3F4C5SS.js} +3 -3
- package/dist/{chunk-UFJYJHQI.js → chunk-J5VWGQSR.js} +2 -2
- package/dist/{chunk-MTFCPPZ5.js → chunk-JWZJSXI5.js} +3 -2
- package/dist/chunk-JWZJSXI5.js.map +1 -0
- package/dist/{chunk-4JFL62K3.js → chunk-K7FSTB2K.js} +3 -3
- package/dist/{chunk-FFCJ7NR2.js → chunk-KRQUPE4K.js} +4 -4
- package/dist/{chunk-2OYFTSG4.js → chunk-KXLUMEDX.js} +2 -2
- package/dist/{chunk-DVAAUWTC.js → chunk-LCHCE2G5.js} +2 -2
- package/dist/{chunk-G4HBNILE.js → chunk-LEHMWJNZ.js} +3 -3
- package/dist/{chunk-P6TNXBDA.js → chunk-MYKWJCR7.js} +9 -9
- package/dist/chunk-MYKWJCR7.js.map +1 -0
- package/dist/{chunk-TQ6FPOPD.js → chunk-ODW2D5PN.js} +39 -30
- package/dist/chunk-ODW2D5PN.js.map +1 -0
- package/dist/{chunk-RZYSKQTS.js → chunk-PCBZYORN.js} +3 -3
- package/dist/{chunk-5OBXEMQO.js → chunk-PRIBOWX4.js} +3 -3
- package/dist/{chunk-F42MJOHM.js → chunk-PVM7XTLZ.js} +64 -62
- package/dist/chunk-PVM7XTLZ.js.map +1 -0
- package/dist/{chunk-3TDVGZZN.js → chunk-QBTBRJ2Q.js} +37 -13
- package/dist/chunk-QBTBRJ2Q.js.map +1 -0
- package/dist/{chunk-2WFDHFK4.js → chunk-QNCWSDXE.js} +26 -11
- package/dist/chunk-QNCWSDXE.js.map +1 -0
- package/dist/{chunk-PQECNGDE.js → chunk-QSRZOXQI.js} +2 -2
- package/dist/{chunk-RHIDWUK7.js → chunk-QUWK7SYN.js} +1 -2
- package/dist/chunk-QUWK7SYN.js.map +1 -0
- package/dist/{chunk-UN5INW6K.js → chunk-R53ZOW4B.js} +8 -4
- package/dist/chunk-R53ZOW4B.js.map +1 -0
- package/dist/{chunk-DCJSHYE5.js → chunk-RSDYS5B3.js} +4 -4
- package/dist/{chunk-N5GVW6RO.js → chunk-S6IWKDWT.js} +2 -2
- package/dist/{chunk-TKC6WHGB.js → chunk-SBIZXZPP.js} +2 -2
- package/dist/{chunk-D5SZXH7Q.js → chunk-TNBJ4DK4.js} +7 -3
- package/dist/chunk-TNBJ4DK4.js.map +1 -0
- package/dist/{chunk-PMOEG36E.js → chunk-XZJM6EPC.js} +8 -6
- package/dist/chunk-XZJM6EPC.js.map +1 -0
- package/dist/{chunk-QF6LTUCE.js → chunk-Y2X7LYIN.js} +4 -4
- package/dist/chunk-Y2X7LYIN.js.map +1 -0
- package/dist/{chunk-UEVHI62V.js → chunk-YCCY77W5.js} +2 -2
- package/dist/{chunk-DF4K5XVW.js → chunk-YZVR5ROE.js} +14 -6
- package/dist/chunk-YZVR5ROE.js.map +1 -0
- package/dist/{chunk-AUSUCZYR.js → chunk-ZBVU2YWV.js} +5 -5
- package/dist/chunk-ZBVU2YWV.js.map +1 -0
- package/dist/{chunk-VZIB5W5L.js → chunk-ZGCPDA3F.js} +2 -2
- package/dist/data-display/DataGrid.js +4 -4
- package/dist/data-display/DataViews.js +29 -29
- package/dist/data-display/FleetMap.js +10 -10
- package/dist/data-display/MapPreview.js +7 -7
- package/dist/data-display/Table.js +4 -4
- package/dist/form/Calendar.js +5 -4
- package/dist/form/DateRangePicker.js +5 -5
- package/dist/form/Switch.js +4 -4
- package/dist/layout/CardGrid.js +2 -1
- package/dist/layout/Resizable.js +4 -3
- package/dist/layout/ScrollArea.js +2 -2
- package/dist/native/form/Switch.js +3 -1
- package/dist/native/form/Switch.js.map +1 -1
- package/dist/types/components/data-display/DataGrid/DataGrid.body.d.ts.map +1 -1
- package/dist/types/components/data-display/DataGrid/DataGrid.cells.d.ts +4 -2
- package/dist/types/components/data-display/DataGrid/DataGrid.cells.d.ts.map +1 -1
- package/dist/types/components/data-display/DataGrid/DataGrid.model.d.ts +7 -1
- package/dist/types/components/data-display/DataGrid/DataGrid.model.d.ts.map +1 -1
- package/dist/types/components/data-display/DataGrid/DataGrid.types.d.ts +10 -4
- package/dist/types/components/data-display/DataGrid/DataGrid.types.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/data-views-columns.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/data-views-grid-helpers.d.ts +2 -0
- package/dist/types/components/data-display/DataViews/data-views-grid-helpers.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/data-views-layout-context.d.ts +7 -3
- package/dist/types/components/data-display/DataViews/data-views-layout-context.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/data-views-overflow-costs.d.ts +19 -9
- package/dist/types/components/data-display/DataViews/data-views-overflow-costs.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/data-views-overflow.d.ts.map +1 -1
- package/dist/types/components/data-display/MapPreview/MapTiles.d.ts.map +1 -1
- package/dist/types/components/data-display/MapPreview/mapProjection.d.ts +6 -1
- package/dist/types/components/data-display/MapPreview/mapProjection.d.ts.map +1 -1
- package/dist/types/components/data-display/Table/Table.helpers.d.ts +6 -0
- package/dist/types/components/data-display/Table/Table.helpers.d.ts.map +1 -1
- package/dist/types/components/data-display/Table/Table.hooks.d.ts +9 -1
- package/dist/types/components/data-display/Table/Table.hooks.d.ts.map +1 -1
- package/dist/types/components/data-display/Table/Table.types.d.ts +6 -2
- package/dist/types/components/data-display/Table/Table.types.d.ts.map +1 -1
- package/dist/types/components/data-display/Table/TableParts.d.ts +2 -0
- package/dist/types/components/data-display/Table/TableParts.d.ts.map +1 -1
- package/dist/types/components/form/Calendar/Calendar.d.ts.map +1 -1
- package/dist/types/components/form/Calendar/CalendarDay.d.ts.map +1 -1
- package/dist/types/components/form/Calendar/CalendarMonth.d.ts.map +1 -1
- package/dist/types/components/form/Switch/Switch.metrics.d.ts +13 -3
- package/dist/types/components/form/Switch/Switch.metrics.d.ts.map +1 -1
- package/dist/types/components/form/Switch/Switch.styles.d.ts.map +1 -1
- package/dist/types/components/layout/CardGrid/CardGrid.d.ts +9 -7
- package/dist/types/components/layout/CardGrid/CardGrid.d.ts.map +1 -1
- package/dist/types/components/layout/Resizable/Resizable.d.ts.map +1 -1
- package/dist/types/components/layout/Resizable/Resizable.helpers.d.ts +21 -9
- package/dist/types/components/layout/Resizable/Resizable.helpers.d.ts.map +1 -1
- package/dist/types/components/layout/Resizable/Resizable.hooks.d.ts +13 -3
- package/dist/types/components/layout/Resizable/Resizable.hooks.d.ts.map +1 -1
- package/dist/types/components/layout/Resizable/Resizable.types.d.ts +10 -0
- package/dist/types/components/layout/Resizable/Resizable.types.d.ts.map +1 -1
- package/dist/types/components/layout/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/components/layout/ScrollArea/ScrollArea.helpers.d.ts +1 -1
- package/dist/types/components/layout/ScrollArea/ScrollArea.helpers.d.ts.map +1 -1
- package/dist/types/components/layout/ScrollArea/ScrollArea.types.d.ts +4 -1
- package/dist/types/components/layout/ScrollArea/ScrollArea.types.d.ts.map +1 -1
- package/dist/types/components/utility/InfiniteScroll/InfiniteScroll.d.ts.map +1 -1
- package/dist/types/components/utility/InfiniteScroll/InfiniteScroll.hooks.d.ts +3 -2
- package/dist/types/components/utility/InfiniteScroll/InfiniteScroll.hooks.d.ts.map +1 -1
- package/dist/types/components/utility/InfiniteScroll/InfiniteScroll.parts.d.ts +3 -2
- package/dist/types/components/utility/InfiniteScroll/InfiniteScroll.parts.d.ts.map +1 -1
- package/dist/types/components/utility/InfiniteScroll/InfiniteScroll.types.d.ts +9 -0
- package/dist/types/components/utility/InfiniteScroll/InfiniteScroll.types.d.ts.map +1 -1
- package/dist/types/components/utility/VirtualList/VirtualList.d.ts.map +1 -1
- package/dist/types/components/utility/VirtualList/VirtualList.hooks.d.ts +24 -28
- package/dist/types/components/utility/VirtualList/VirtualList.hooks.d.ts.map +1 -1
- package/dist/types/components/utility/VirtualList/VirtualList.types.d.ts +17 -0
- package/dist/types/components/utility/VirtualList/VirtualList.types.d.ts.map +1 -1
- package/dist/types-native/components/form/Switch/Switch.metrics.d.ts +13 -3
- package/dist/types-native/components/form/Switch/Switch.metrics.d.ts.map +1 -1
- package/dist/utility/InfiniteScroll.js +4 -3
- package/dist/utility/VirtualList.js +3 -2
- package/package.json +1 -1
- package/src/components/data-display/DataGrid/DataGrid.body.tsx +27 -7
- package/src/components/data-display/DataGrid/DataGrid.cells.tsx +33 -9
- package/src/components/data-display/DataGrid/DataGrid.model.ts +24 -11
- package/src/components/data-display/DataGrid/DataGrid.types.ts +12 -6
- package/src/components/data-display/DataViews/data-views-columns.ts +14 -3
- package/src/components/data-display/DataViews/data-views-grid-helpers.tsx +5 -3
- package/src/components/data-display/DataViews/data-views-layout-context.tsx +12 -9
- package/src/components/data-display/DataViews/data-views-overflow-costs.ts +32 -14
- package/src/components/data-display/DataViews/data-views-overflow.ts +40 -26
- package/src/components/data-display/MapPreview/MapTiles.tsx +16 -9
- package/src/components/data-display/MapPreview/mapProjection.ts +10 -5
- package/src/components/data-display/Table/Table.helpers.ts +7 -1
- package/src/components/data-display/Table/Table.hooks.ts +16 -5
- package/src/components/data-display/Table/Table.types.ts +6 -2
- package/src/components/data-display/Table/TableParts.tsx +38 -42
- package/src/components/form/Calendar/Calendar.tsx +4 -2
- package/src/components/form/Calendar/CalendarDay.tsx +6 -3
- package/src/components/form/Calendar/CalendarMonth.tsx +6 -3
- package/src/components/form/Switch/Switch.metrics.ts +19 -5
- package/src/components/form/Switch/Switch.styles.ts +5 -3
- package/src/components/layout/CardGrid/CardGrid.tsx +37 -24
- package/src/components/layout/Resizable/Resizable.helpers.ts +43 -21
- package/src/components/layout/Resizable/Resizable.hooks.ts +17 -9
- package/src/components/layout/Resizable/Resizable.md +9 -5
- package/src/components/layout/Resizable/Resizable.tsx +20 -8
- package/src/components/layout/Resizable/Resizable.types.ts +10 -0
- package/src/components/layout/ScrollArea/ScrollArea.helpers.ts +0 -2
- package/src/components/layout/ScrollArea/ScrollArea.tsx +5 -3
- package/src/components/layout/ScrollArea/ScrollArea.types.ts +4 -1
- package/src/components/utility/InfiniteScroll/InfiniteScroll.hooks.ts +5 -4
- package/src/components/utility/InfiniteScroll/InfiniteScroll.parts.tsx +29 -12
- package/src/components/utility/InfiniteScroll/InfiniteScroll.tsx +11 -5
- package/src/components/utility/InfiniteScroll/InfiniteScroll.types.ts +10 -2
- package/src/components/utility/VirtualList/VirtualList.hooks.ts +101 -112
- package/src/components/utility/VirtualList/VirtualList.tsx +36 -65
- package/src/components/utility/VirtualList/VirtualList.types.ts +20 -3
- package/dist/chunk-2WFDHFK4.js.map +0 -1
- package/dist/chunk-3TDVGZZN.js.map +0 -1
- package/dist/chunk-AROBXRC5.js.map +0 -1
- package/dist/chunk-ATSHKSSD.js.map +0 -1
- package/dist/chunk-AUSUCZYR.js.map +0 -1
- package/dist/chunk-C66RGVAS.js.map +0 -1
- package/dist/chunk-D5SZXH7Q.js.map +0 -1
- package/dist/chunk-DF4K5XVW.js.map +0 -1
- package/dist/chunk-DLJGBJZW.js.map +0 -1
- package/dist/chunk-DZA7RSLX.js.map +0 -1
- package/dist/chunk-F42MJOHM.js.map +0 -1
- package/dist/chunk-GSFNH4C5.js.map +0 -1
- package/dist/chunk-HGMBY5LP.js.map +0 -1
- package/dist/chunk-HTZNB6IV.js.map +0 -1
- package/dist/chunk-IAGOUTI6.js.map +0 -1
- package/dist/chunk-J2DAQQQH.js.map +0 -1
- package/dist/chunk-MTFCPPZ5.js.map +0 -1
- package/dist/chunk-P6TNXBDA.js.map +0 -1
- package/dist/chunk-PMOEG36E.js.map +0 -1
- package/dist/chunk-PPRV4LTM.js.map +0 -1
- package/dist/chunk-PUBPZOQJ.js.map +0 -1
- package/dist/chunk-QF6LTUCE.js.map +0 -1
- package/dist/chunk-RHIDWUK7.js.map +0 -1
- package/dist/chunk-TQ6FPOPD.js.map +0 -1
- package/dist/chunk-TUBCN4DJ.js.map +0 -1
- package/dist/chunk-ULTOQ6ZV.js.map +0 -1
- package/dist/chunk-UN5INW6K.js.map +0 -1
- package/dist/chunk-YU26GBNX.js.map +0 -1
- package/dist/chunk-ZAY6OA6F.js.map +0 -1
- /package/dist/{chunk-MR2HKBHS.js.map → chunk-27LOJVR3.js.map} +0 -0
- /package/dist/{chunk-S3D5VBHW.js.map → chunk-3YOXVNO4.js.map} +0 -0
- /package/dist/{chunk-CZIX4BW2.js.map → chunk-4ALF5PB5.js.map} +0 -0
- /package/dist/{chunk-XJPJ6ESI.js.map → chunk-4OAKGKK5.js.map} +0 -0
- /package/dist/{chunk-4CHROSWR.js.map → chunk-5ETBB2DG.js.map} +0 -0
- /package/dist/{chunk-46UPILLK.js.map → chunk-5NT2M2JI.js.map} +0 -0
- /package/dist/{chunk-H5BEWPEY.js.map → chunk-6N2EDWMG.js.map} +0 -0
- /package/dist/{chunk-GJQYM3PM.js.map → chunk-6PU3JYVY.js.map} +0 -0
- /package/dist/{chunk-Y7F5JBAT.js.map → chunk-DDRKYNPB.js.map} +0 -0
- /package/dist/{chunk-OS6KPL4D.js.map → chunk-EHYI2WCJ.js.map} +0 -0
- /package/dist/{chunk-NB3FGWU4.js.map → chunk-EQXIW5MQ.js.map} +0 -0
- /package/dist/{chunk-M2JTIH5M.js.map → chunk-F44R7US6.js.map} +0 -0
- /package/dist/{chunk-XJJXBUPN.js.map → chunk-FX26DAFF.js.map} +0 -0
- /package/dist/{chunk-R6SN73RX.js.map → chunk-GLHNMTP6.js.map} +0 -0
- /package/dist/{chunk-I4QA2F4L.js.map → chunk-HBRQPG7H.js.map} +0 -0
- /package/dist/{chunk-CNQUCNEA.js.map → chunk-I3F4C5SS.js.map} +0 -0
- /package/dist/{chunk-UFJYJHQI.js.map → chunk-J5VWGQSR.js.map} +0 -0
- /package/dist/{chunk-4JFL62K3.js.map → chunk-K7FSTB2K.js.map} +0 -0
- /package/dist/{chunk-FFCJ7NR2.js.map → chunk-KRQUPE4K.js.map} +0 -0
- /package/dist/{chunk-2OYFTSG4.js.map → chunk-KXLUMEDX.js.map} +0 -0
- /package/dist/{chunk-DVAAUWTC.js.map → chunk-LCHCE2G5.js.map} +0 -0
- /package/dist/{chunk-G4HBNILE.js.map → chunk-LEHMWJNZ.js.map} +0 -0
- /package/dist/{chunk-RZYSKQTS.js.map → chunk-PCBZYORN.js.map} +0 -0
- /package/dist/{chunk-5OBXEMQO.js.map → chunk-PRIBOWX4.js.map} +0 -0
- /package/dist/{chunk-PQECNGDE.js.map → chunk-QSRZOXQI.js.map} +0 -0
- /package/dist/{chunk-DCJSHYE5.js.map → chunk-RSDYS5B3.js.map} +0 -0
- /package/dist/{chunk-N5GVW6RO.js.map → chunk-S6IWKDWT.js.map} +0 -0
- /package/dist/{chunk-TKC6WHGB.js.map → chunk-SBIZXZPP.js.map} +0 -0
- /package/dist/{chunk-UEVHI62V.js.map → chunk-YCCY77W5.js.map} +0 -0
- /package/dist/{chunk-VZIB5W5L.js.map → chunk-ZGCPDA3F.js.map} +0 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { Theme } from '@mui/material/styles/index.js';
|
|
2
2
|
|
|
3
|
+
import { rem, remPx } from '../../../tokens/relative';
|
|
4
|
+
|
|
3
5
|
import type { ResizableProps, ResizableVariant, ResizeHandle } from './Resizable.types';
|
|
4
6
|
|
|
7
|
+
/** One axis's clamp, in the px a drag runs in. */
|
|
5
8
|
export interface Axis {
|
|
6
9
|
min: number;
|
|
7
10
|
max: number;
|
|
@@ -80,16 +83,30 @@ export const handleStyle = (theme: Theme, handle: ResizeHandle, active: boolean)
|
|
|
80
83
|
|
|
81
84
|
switch (handle) {
|
|
82
85
|
case 'right':
|
|
83
|
-
return {
|
|
86
|
+
return {
|
|
87
|
+
...baseStyle,
|
|
88
|
+
top: 0,
|
|
89
|
+
right: rem(theme, -2),
|
|
90
|
+
width: rem(theme, 4),
|
|
91
|
+
height: '100%',
|
|
92
|
+
cursor: 'ew-resize',
|
|
93
|
+
};
|
|
84
94
|
case 'bottom':
|
|
85
|
-
return {
|
|
95
|
+
return {
|
|
96
|
+
...baseStyle,
|
|
97
|
+
bottom: rem(theme, -2),
|
|
98
|
+
left: 0,
|
|
99
|
+
width: '100%',
|
|
100
|
+
height: rem(theme, 4),
|
|
101
|
+
cursor: 'ns-resize',
|
|
102
|
+
};
|
|
86
103
|
case 'bottomRight':
|
|
87
104
|
return {
|
|
88
105
|
...baseStyle,
|
|
89
|
-
bottom: -2,
|
|
90
|
-
right: -2,
|
|
91
|
-
width: 8,
|
|
92
|
-
height: 8,
|
|
106
|
+
bottom: rem(theme, -2),
|
|
107
|
+
right: rem(theme, -2),
|
|
108
|
+
width: rem(theme, 8),
|
|
109
|
+
height: rem(theme, 8),
|
|
93
110
|
cursor: 'nw-resize',
|
|
94
111
|
borderRadius: '50%',
|
|
95
112
|
};
|
|
@@ -98,30 +115,35 @@ export const handleStyle = (theme: Theme, handle: ResizeHandle, active: boolean)
|
|
|
98
115
|
}
|
|
99
116
|
};
|
|
100
117
|
|
|
101
|
-
type ResizableDefaultedKeys =
|
|
102
|
-
| 'variant'
|
|
103
|
-
| 'width'
|
|
104
|
-
| 'height'
|
|
105
|
-
| 'minWidth'
|
|
106
|
-
| 'maxWidth'
|
|
107
|
-
| 'minHeight'
|
|
108
|
-
| 'maxHeight'
|
|
109
|
-
| 'disabled';
|
|
118
|
+
type ResizableDefaultedKeys = 'variant' | 'disabled';
|
|
110
119
|
|
|
111
120
|
type ResolvedResizableProps = ResizableProps &
|
|
112
121
|
Required<Pick<ResizableProps, ResizableDefaultedKeys>>;
|
|
113
122
|
|
|
114
123
|
const RESIZABLE_DEFAULTS: Pick<ResizableProps, ResizableDefaultedKeys> = {
|
|
115
124
|
variant: 'both',
|
|
116
|
-
width: 200,
|
|
117
|
-
height: 200,
|
|
118
|
-
minWidth: 50,
|
|
119
|
-
maxWidth: 1000,
|
|
120
|
-
minHeight: 50,
|
|
121
|
-
maxHeight: 1000,
|
|
122
125
|
disabled: false,
|
|
123
126
|
};
|
|
124
127
|
|
|
128
|
+
/** The box's own defaults, in design px: where it starts, and its clamp. */
|
|
129
|
+
const DEFAULT_BOX_PX = { start: 200, min: 50, max: 1000 } as const;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Where the box starts, in the px a drag runs in. The consumer's sizes are
|
|
133
|
+
* design px, like every other size in the package; a drag is pointer pixels,
|
|
134
|
+
* so the live size is px from here on.
|
|
135
|
+
*/
|
|
136
|
+
export const startSizePx = (theme: Theme, width?: number, height?: number) => ({
|
|
137
|
+
width: remPx(theme, width ?? DEFAULT_BOX_PX.start),
|
|
138
|
+
height: remPx(theme, height ?? DEFAULT_BOX_PX.start),
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
/** One axis's clamp, from the consumer's design px to the px a drag runs in. */
|
|
142
|
+
export const axisPx = (theme: Theme, min?: number, max?: number): Axis => ({
|
|
143
|
+
min: remPx(theme, min ?? DEFAULT_BOX_PX.min),
|
|
144
|
+
max: remPx(theme, max ?? DEFAULT_BOX_PX.max),
|
|
145
|
+
});
|
|
146
|
+
|
|
125
147
|
// Strips explicitly-undefined props before the merge, so `minWidth={undefined}`
|
|
126
148
|
// still falls back to the default exactly as a destructuring default would.
|
|
127
149
|
const definedProps = (props: ResizableProps): Partial<ResizableProps> =>
|
|
@@ -5,9 +5,12 @@ import { resizedTo } from './Resizable.helpers';
|
|
|
5
5
|
import type { ResizeHandle } from './Resizable.types';
|
|
6
6
|
|
|
7
7
|
interface ResizeArgs {
|
|
8
|
-
|
|
9
|
-
height: number;
|
|
8
|
+
/** Where the box starts, in px (`startSizePx`); a new object re-seats the box. */
|
|
9
|
+
start: { width: number; height: number };
|
|
10
|
+
/** The clamp, in px (`axisPx` per axis). */
|
|
10
11
|
bounds: Bounds;
|
|
12
|
+
/** Rendered px per design px (`remPx(theme, 1)`) — `onResize` reports design px. */
|
|
13
|
+
pxPerDesignPx: number;
|
|
11
14
|
disabled: boolean;
|
|
12
15
|
onResize?: (width: number, height: number) => void;
|
|
13
16
|
}
|
|
@@ -16,17 +19,21 @@ interface ResizeArgs {
|
|
|
16
19
|
* Tracks the box's size across a drag. The listeners live on the document rather
|
|
17
20
|
* than the handle, so the pointer can leave the handle — or the component — mid
|
|
18
21
|
* drag without the resize sticking.
|
|
22
|
+
*
|
|
23
|
+
* The live size is px, because a drag is pointer pixels. What `onResize`
|
|
24
|
+
* reports is design px — the unit the consumer's `width`/`height` are in — so a
|
|
25
|
+
* controlled box (`onResize` feeding `width`) stays put at any type scale.
|
|
19
26
|
*/
|
|
20
|
-
export const useResize = ({
|
|
21
|
-
const [size, setSize] = useState(
|
|
27
|
+
export const useResize = ({ start, bounds, pxPerDesignPx, disabled, onResize }: ResizeArgs) => {
|
|
28
|
+
const [size, setSize] = useState(start);
|
|
22
29
|
const [isResizing, setIsResizing] = useState(false);
|
|
23
30
|
const startPos = useRef({ x: 0, y: 0 });
|
|
24
31
|
const startSize = useRef({ width: 0, height: 0 });
|
|
25
32
|
const activeHandle = useRef<ResizeHandle | null>(null);
|
|
26
33
|
|
|
27
34
|
React.useEffect(() => {
|
|
28
|
-
setSize(
|
|
29
|
-
}, [
|
|
35
|
+
setSize(start);
|
|
36
|
+
}, [start]);
|
|
30
37
|
|
|
31
38
|
const handleMouseDown = useCallback(
|
|
32
39
|
(e: React.MouseEvent, handle: ResizeHandle) => {
|
|
@@ -38,7 +45,8 @@ export const useResize = ({ width, height, bounds, disabled, onResize }: ResizeA
|
|
|
38
45
|
setIsResizing(true);
|
|
39
46
|
activeHandle.current = handle;
|
|
40
47
|
startPos.current = { x: e.clientX, y: e.clientY };
|
|
41
|
-
|
|
48
|
+
// State is replaced on every change, never mutated, so holding it is a snapshot.
|
|
49
|
+
startSize.current = size;
|
|
42
50
|
|
|
43
51
|
const handleMouseMove = (move: globalThis.MouseEvent) => {
|
|
44
52
|
const delta = {
|
|
@@ -48,7 +56,7 @@ export const useResize = ({ width, height, bounds, disabled, onResize }: ResizeA
|
|
|
48
56
|
const next = resizedTo(handle, delta, startSize.current, bounds);
|
|
49
57
|
|
|
50
58
|
setSize(next);
|
|
51
|
-
onResize?.(next.width, next.height);
|
|
59
|
+
onResize?.(next.width / pxPerDesignPx, next.height / pxPerDesignPx);
|
|
52
60
|
};
|
|
53
61
|
|
|
54
62
|
const handleMouseUp = () => {
|
|
@@ -61,7 +69,7 @@ export const useResize = ({ width, height, bounds, disabled, onResize }: ResizeA
|
|
|
61
69
|
document.addEventListener('mousemove', handleMouseMove);
|
|
62
70
|
document.addEventListener('mouseup', handleMouseUp);
|
|
63
71
|
},
|
|
64
|
-
[disabled, size, bounds, onResize],
|
|
72
|
+
[disabled, size, bounds, pxPerDesignPx, onResize],
|
|
65
73
|
);
|
|
66
74
|
|
|
67
75
|
return { size, isResizing, activeHandle, handleMouseDown };
|
|
@@ -51,18 +51,22 @@ import { Resizable } from '@procurement/ui';
|
|
|
51
51
|
| -------------- | ---------------------------------------- | ------------------------------------ | ------------------------------------------------ |
|
|
52
52
|
| `children` | `ReactNode` | - | Content to render inside the resizable container |
|
|
53
53
|
| `variant` | `'horizontal' \| 'vertical' \| 'both'` | `'both'` | Resize direction constraint |
|
|
54
|
-
| `width` | `number` | `
|
|
55
|
-
| `height` | `number` | `200` | Initial height
|
|
54
|
+
| `width` | `number` | `200` | Initial width, design px (scales with the theme's type scale) |
|
|
55
|
+
| `height` | `number` | `200` | Initial height, design px (scales with the theme's type scale) |
|
|
56
56
|
| `minWidth` | `number` | `50` | Minimum width constraint |
|
|
57
|
-
| `maxWidth` | `number` |
|
|
57
|
+
| `maxWidth` | `number` | `1000` | Maximum width constraint |
|
|
58
58
|
| `minHeight` | `number` | `50` | Minimum height constraint |
|
|
59
|
-
| `maxHeight` | `number` |
|
|
60
|
-
| `onResize` | `(
|
|
59
|
+
| `maxHeight` | `number` | `1000` | Maximum height constraint |
|
|
60
|
+
| `onResize` | `(width: number, height: number) => void` | - | Fired during resize with the new size, in design px |
|
|
61
61
|
| `disabled` | `boolean` | `false` | Disables resize functionality |
|
|
62
62
|
| `handles` | `HandlePosition[]` | `['right', 'bottom', 'bottomRight']` | Array of handle positions |
|
|
63
63
|
| `className` | `string` | - | Additional CSS class name |
|
|
64
64
|
| `data-testid` | `string` | - | Test ID for automated testing |
|
|
65
65
|
|
|
66
|
+
Every size prop — and what `onResize` reports — is in design px, the unit the
|
|
67
|
+
whole package draws in, scaled with the theme's type scale (`remPx`). A drag
|
|
68
|
+
follows the pointer in real pixels.
|
|
69
|
+
|
|
66
70
|
## Handle Positions
|
|
67
71
|
|
|
68
72
|
The `handles` prop accepts an array of the following positions:
|
|
@@ -2,7 +2,15 @@ import Box from '@mui/material/Box/index.js';
|
|
|
2
2
|
import { useTheme } from '@mui/material/styles/index.js';
|
|
3
3
|
import React, { useMemo } from 'react';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { remPx } from '../../../tokens/relative';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
axisPx,
|
|
9
|
+
defaultHandles,
|
|
10
|
+
handleStyle,
|
|
11
|
+
resolveResizableProps,
|
|
12
|
+
startSizePx,
|
|
13
|
+
} from './Resizable.helpers';
|
|
6
14
|
import { useResize } from './Resizable.hooks';
|
|
7
15
|
import type { ResizableProps } from './Resizable.types';
|
|
8
16
|
|
|
@@ -10,8 +18,8 @@ export const Resizable: React.FC<ResizableProps> = (rawProps) => {
|
|
|
10
18
|
const {
|
|
11
19
|
children,
|
|
12
20
|
variant,
|
|
13
|
-
width
|
|
14
|
-
height
|
|
21
|
+
width,
|
|
22
|
+
height,
|
|
15
23
|
minWidth,
|
|
16
24
|
maxWidth,
|
|
17
25
|
minHeight,
|
|
@@ -24,18 +32,20 @@ export const Resizable: React.FC<ResizableProps> = (rawProps) => {
|
|
|
24
32
|
...rest
|
|
25
33
|
} = resolveResizableProps(rawProps);
|
|
26
34
|
const theme = useTheme();
|
|
35
|
+
// Keyed apart: a new `start` re-seats the box, which a changed clamp must not do.
|
|
36
|
+
const start = useMemo(() => startSizePx(theme, width, height), [theme, width, height]);
|
|
27
37
|
const bounds = useMemo(
|
|
28
38
|
() => ({
|
|
29
|
-
width:
|
|
30
|
-
height:
|
|
39
|
+
width: axisPx(theme, minWidth, maxWidth),
|
|
40
|
+
height: axisPx(theme, minHeight, maxHeight),
|
|
31
41
|
}),
|
|
32
|
-
[minWidth, maxWidth, minHeight, maxHeight],
|
|
42
|
+
[theme, minWidth, maxWidth, minHeight, maxHeight],
|
|
33
43
|
);
|
|
34
44
|
|
|
35
45
|
const { size, isResizing, activeHandle, handleMouseDown } = useResize({
|
|
36
|
-
|
|
37
|
-
height: initialHeight,
|
|
46
|
+
start,
|
|
38
47
|
bounds,
|
|
48
|
+
pxPerDesignPx: remPx(theme, 1),
|
|
39
49
|
disabled,
|
|
40
50
|
onResize,
|
|
41
51
|
});
|
|
@@ -49,6 +59,8 @@ export const Resizable: React.FC<ResizableProps> = (rawProps) => {
|
|
|
49
59
|
data-testid={dataTestId}
|
|
50
60
|
sx={{
|
|
51
61
|
position: 'relative',
|
|
62
|
+
// The live size: the start and the clamp came through `remPx`, the rest
|
|
63
|
+
// is pointer pixels dragged, so it is px as it stands.
|
|
52
64
|
width: size.width,
|
|
53
65
|
height: size.height,
|
|
54
66
|
border: `1px solid ${theme.palette.divider}`,
|
|
@@ -14,12 +14,22 @@ export type ResizeHandle =
|
|
|
14
14
|
export interface ResizableProps {
|
|
15
15
|
children: ReactNode;
|
|
16
16
|
variant?: ResizableVariant;
|
|
17
|
+
/** Starting width (default 200). Design px, scaled with the theme's type scale. */
|
|
17
18
|
width?: number;
|
|
19
|
+
/** Starting height (default 200). Design px, scaled with the theme's type scale. */
|
|
18
20
|
height?: number;
|
|
21
|
+
/** Narrowest a drag can make it (default 50). Design px, scaled with the theme's type scale. */
|
|
19
22
|
minWidth?: number;
|
|
23
|
+
/** Widest a drag can make it (default 1000). Design px, scaled with the theme's type scale. */
|
|
20
24
|
maxWidth?: number;
|
|
25
|
+
/** Shortest a drag can make it (default 50). Design px, scaled with the theme's type scale. */
|
|
21
26
|
minHeight?: number;
|
|
27
|
+
/** Tallest a drag can make it (default 1000). Design px, scaled with the theme's type scale. */
|
|
22
28
|
maxHeight?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Fired on every drag step with the new size, in design px — the unit `width`
|
|
31
|
+
* and `height` take, so feeding it back keeps a controlled box where it is.
|
|
32
|
+
*/
|
|
23
33
|
onResize?: (width: number, height: number) => void;
|
|
24
34
|
disabled?: boolean;
|
|
25
35
|
handles?: ResizeHandle[];
|
|
@@ -10,7 +10,6 @@ type ScrollAreaDefaultedKeys =
|
|
|
10
10
|
| 'smoothScroll'
|
|
11
11
|
| 'variant'
|
|
12
12
|
| 'scrollToTopButton'
|
|
13
|
-
| 'scrollToTopThreshold'
|
|
14
13
|
| 'contentPadding'
|
|
15
14
|
| 'alwaysShowScrollbar'
|
|
16
15
|
| 'disabled'
|
|
@@ -30,7 +29,6 @@ const SCROLL_AREA_DEFAULTS: Pick<ScrollAreaProps, ScrollAreaDefaultedKeys> = {
|
|
|
30
29
|
smoothScroll: true,
|
|
31
30
|
variant: 'default',
|
|
32
31
|
scrollToTopButton: false,
|
|
33
|
-
scrollToTopThreshold: 100,
|
|
34
32
|
contentPadding: 0,
|
|
35
33
|
alwaysShowScrollbar: false,
|
|
36
34
|
disabled: false,
|
|
@@ -8,7 +8,7 @@ import type { SxProps, Theme } from '@mui/material/styles/index.js';
|
|
|
8
8
|
import type { FC } from 'react';
|
|
9
9
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
10
10
|
|
|
11
|
-
import { rem, sxRem } from '../../../tokens/relative';
|
|
11
|
+
import { rem, remPx, sxRem } from '../../../tokens/relative';
|
|
12
12
|
|
|
13
13
|
import type { ResolvedScrollAreaProps } from './ScrollArea.helpers';
|
|
14
14
|
import { resolveScrollAreaProps } from './ScrollArea.helpers';
|
|
@@ -105,6 +105,7 @@ const useScrollArea = (
|
|
|
105
105
|
scrollToTopThreshold,
|
|
106
106
|
smoothScroll } = props;
|
|
107
107
|
|
|
108
|
+
const theme = useTheme();
|
|
108
109
|
const { scrollRef, setScrollRef, containerDimensions } = useObservedScrollRef({
|
|
109
110
|
externalScrollRef,
|
|
110
111
|
onResize });
|
|
@@ -121,12 +122,13 @@ const useScrollArea = (
|
|
|
121
122
|
noteScroll();
|
|
122
123
|
|
|
123
124
|
if (scrollToTopButton && scrollRef.current) {
|
|
124
|
-
|
|
125
|
+
// 100 design px unless the caller says, in the px `scrollTop` is measured in.
|
|
126
|
+
setShowScrollToTop(scrollRef.current.scrollTop > remPx(theme, scrollToTopThreshold ?? 100));
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
onScroll?.(event);
|
|
128
130
|
},
|
|
129
|
-
[disabled, noteScroll, scrollToTopButton, scrollToTopThreshold, onScroll, scrollRef],
|
|
131
|
+
[disabled, noteScroll, scrollToTopButton, scrollToTopThreshold, onScroll, scrollRef, theme],
|
|
130
132
|
);
|
|
131
133
|
|
|
132
134
|
const scrollToTop = useCallback(() => {
|
|
@@ -63,7 +63,10 @@ export interface ScrollAreaBase extends Omit<BoxProps, 'ref'> {
|
|
|
63
63
|
/** Scroll event handler */
|
|
64
64
|
onScroll?: (event: React.UIEvent<HTMLDivElement>) => void;
|
|
65
65
|
|
|
66
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* How far down the scroll-to-top button appears (default 100) — design px,
|
|
68
|
+
* scaled with the theme's type scale.
|
|
69
|
+
*/
|
|
67
70
|
scrollToTopThreshold?: number;
|
|
68
71
|
|
|
69
72
|
/** Custom scrollbar color */
|
|
@@ -19,7 +19,8 @@ const resolveScrollable = (scrollableTarget: ScrollableTarget): Element | null =
|
|
|
19
19
|
|
|
20
20
|
interface ObserverArgs {
|
|
21
21
|
testMode: boolean;
|
|
22
|
-
|
|
22
|
+
/** The observer's `rootMargin` — px, which is all `IntersectionObserver` takes. */
|
|
23
|
+
rootMargin: string;
|
|
23
24
|
scrollableTarget: ScrollableTarget;
|
|
24
25
|
}
|
|
25
26
|
|
|
@@ -28,7 +29,7 @@ interface ObserverArgs {
|
|
|
28
29
|
* it fire before the sentinel is actually on screen, so the next page is already
|
|
29
30
|
* loading by the time the user reaches the bottom.
|
|
30
31
|
*/
|
|
31
|
-
export const useSentinel = ({ testMode,
|
|
32
|
+
export const useSentinel = ({ testMode, rootMargin, scrollableTarget }: ObserverArgs) => {
|
|
32
33
|
const sentinelRef = useRef<HTMLDivElement>(null);
|
|
33
34
|
const [isIntersecting, setIsIntersecting] = useState(false);
|
|
34
35
|
|
|
@@ -43,7 +44,7 @@ export const useSentinel = ({ testMode, threshold, scrollableTarget }: ObserverA
|
|
|
43
44
|
},
|
|
44
45
|
{
|
|
45
46
|
root: resolveScrollable(scrollableTarget) || undefined,
|
|
46
|
-
rootMargin
|
|
47
|
+
rootMargin,
|
|
47
48
|
threshold: 0,
|
|
48
49
|
},
|
|
49
50
|
);
|
|
@@ -51,7 +52,7 @@ export const useSentinel = ({ testMode, threshold, scrollableTarget }: ObserverA
|
|
|
51
52
|
observer.observe(sentinelRef.current);
|
|
52
53
|
|
|
53
54
|
return () => observer.disconnect();
|
|
54
|
-
}, [testMode,
|
|
55
|
+
}, [testMode, rootMargin, scrollableTarget]);
|
|
55
56
|
|
|
56
57
|
return { sentinelRef, isIntersecting };
|
|
57
58
|
};
|
|
@@ -2,27 +2,33 @@ import Alert from '@mui/material/Alert/index.js';
|
|
|
2
2
|
import Box from '@mui/material/Box/index.js';
|
|
3
3
|
import CircularProgress from '@mui/material/CircularProgress/index.js';
|
|
4
4
|
import Typography from '@mui/material/Typography/index.js';
|
|
5
|
+
import { useTheme, type SxProps, type Theme } from '@mui/material/styles/index.js';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
|
|
8
|
+
import { rem } from '../../../tokens/relative';
|
|
9
|
+
|
|
7
10
|
import type { InfiniteScrollProps } from './InfiniteScroll.types';
|
|
8
11
|
|
|
9
12
|
type Variant = NonNullable<InfiniteScrollProps['variant']>;
|
|
10
13
|
|
|
11
|
-
const CENTERED = {
|
|
14
|
+
const CENTERED: SxProps<Theme> = {
|
|
12
15
|
display: 'flex',
|
|
13
16
|
justifyContent: 'center',
|
|
14
17
|
alignItems: 'center',
|
|
15
18
|
p: 2,
|
|
16
|
-
}
|
|
19
|
+
};
|
|
17
20
|
|
|
18
|
-
export const DefaultLoader: React.FC<{ loadingText: string }> = ({ loadingText }) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
export const DefaultLoader: React.FC<{ loadingText: string }> = ({ loadingText }) => {
|
|
22
|
+
const theme = useTheme();
|
|
23
|
+
return (
|
|
24
|
+
<Box sx={CENTERED}>
|
|
25
|
+
<CircularProgress size={rem(theme, 24)} />
|
|
26
|
+
<Typography variant="body2" sx={{ ml: 1 }}>
|
|
27
|
+
{loadingText}
|
|
28
|
+
</Typography>
|
|
29
|
+
</Box>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
26
32
|
|
|
27
33
|
export const DefaultEndMessage: React.FC<{ endText: string }> = ({ endText }) => (
|
|
28
34
|
<Box sx={CENTERED}>
|
|
@@ -38,14 +44,25 @@ export const DefaultError: React.FC<{ error: Error }> = ({ error }) => (
|
|
|
38
44
|
</Alert>
|
|
39
45
|
);
|
|
40
46
|
|
|
47
|
+
/**
|
|
48
|
+
* The horizontal variant's `width` as CSS: a number of 1 or less stays the
|
|
49
|
+
* fraction `sx` reads it as, a larger one is design px, a string is as given;
|
|
50
|
+
* unset (or 0) fills the parent.
|
|
51
|
+
*/
|
|
52
|
+
const horizontalWidth = (theme: Theme, width: number | string | undefined): string => {
|
|
53
|
+
if (!width) return '100%';
|
|
54
|
+
if (typeof width !== 'number') return width;
|
|
55
|
+
return width <= 1 ? `${width * 100}%` : rem(theme, width);
|
|
56
|
+
};
|
|
57
|
+
|
|
41
58
|
/**
|
|
42
59
|
* `horizontal` scrolls along a row; `reverse` stacks bottom-up, for a chat log
|
|
43
60
|
* that loads older messages as you scroll away from the newest.
|
|
44
61
|
*/
|
|
45
|
-
export const containerStyles = (variant: Variant, width?: number | string) => {
|
|
62
|
+
export const containerStyles = (theme: Theme, variant: Variant, width?: number | string) => {
|
|
46
63
|
const horizontal = variant === 'horizontal';
|
|
47
64
|
const base = {
|
|
48
|
-
width: horizontal ? width
|
|
65
|
+
width: horizontal ? horizontalWidth(theme, width) : '100%',
|
|
49
66
|
height: horizontal ? '100%' : 'auto',
|
|
50
67
|
overflowX: horizontal ? 'auto' : 'hidden',
|
|
51
68
|
overflowY: horizontal ? 'hidden' : 'visible',
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import Box from '@mui/material/Box/index.js';
|
|
2
|
+
import { useTheme } from '@mui/material/styles/index.js';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
|
|
5
|
+
import { rem, remPx } from '../../../tokens/relative';
|
|
6
|
+
|
|
4
7
|
import { useLoadMore, useSentinel } from './InfiniteScroll.hooks';
|
|
5
8
|
import {
|
|
6
9
|
containerStyles,
|
|
@@ -15,7 +18,7 @@ export const InfiniteScroll: React.FC<InfiniteScrollProps> = ({
|
|
|
15
18
|
variant = 'default',
|
|
16
19
|
hasMore,
|
|
17
20
|
loading,
|
|
18
|
-
threshold
|
|
21
|
+
threshold,
|
|
19
22
|
loadMore,
|
|
20
23
|
loader,
|
|
21
24
|
loadingText,
|
|
@@ -31,7 +34,10 @@ export const InfiniteScroll: React.FC<InfiniteScrollProps> = ({
|
|
|
31
34
|
testMode = false,
|
|
32
35
|
testTriggerRef,
|
|
33
36
|
}) => {
|
|
34
|
-
const
|
|
37
|
+
const theme = useTheme();
|
|
38
|
+
// 150 design px unless the caller says; `rootMargin` only takes px.
|
|
39
|
+
const rootMargin = `${remPx(theme, threshold ?? 150)}px`;
|
|
40
|
+
const { sentinelRef, isIntersecting } = useSentinel({ testMode, rootMargin, scrollableTarget });
|
|
35
41
|
|
|
36
42
|
useLoadMore({
|
|
37
43
|
hasMore,
|
|
@@ -56,8 +62,8 @@ export const InfiniteScroll: React.FC<InfiniteScrollProps> = ({
|
|
|
56
62
|
ref={sentinelRef}
|
|
57
63
|
data-testid="infinite-scroll-sentinel"
|
|
58
64
|
style={{
|
|
59
|
-
height: variant === 'horizontal' ? '100%' :
|
|
60
|
-
width: variant === 'horizontal' ?
|
|
65
|
+
height: variant === 'horizontal' ? '100%' : rem(theme, 1),
|
|
66
|
+
width: variant === 'horizontal' ? rem(theme, 1) : '100%',
|
|
61
67
|
}}
|
|
62
68
|
/>
|
|
63
69
|
);
|
|
@@ -67,7 +73,7 @@ export const InfiniteScroll: React.FC<InfiniteScrollProps> = ({
|
|
|
67
73
|
<Box
|
|
68
74
|
className={className}
|
|
69
75
|
sx={{
|
|
70
|
-
...containerStyles(variant, width),
|
|
76
|
+
...containerStyles(theme, variant, width),
|
|
71
77
|
...style,
|
|
72
78
|
}}
|
|
73
79
|
>
|
|
@@ -13,7 +13,11 @@ export interface InfiniteScrollProps {
|
|
|
13
13
|
variant?: InfiniteScrollVariant;
|
|
14
14
|
hasMore: boolean;
|
|
15
15
|
loading: boolean;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* How far before the end the next page is requested (default 150) — design
|
|
18
|
+
* px, scaled with the theme's type scale.
|
|
19
|
+
*/
|
|
20
|
+
threshold?: number;
|
|
17
21
|
loadMore: () => void | Promise<void>;
|
|
18
22
|
loader?: ReactNode;
|
|
19
23
|
endMessage?: ReactNode;
|
|
@@ -22,7 +26,11 @@ export interface InfiniteScrollProps {
|
|
|
22
26
|
onError?: (error: Error) => void;
|
|
23
27
|
className?: string;
|
|
24
28
|
style?: React.CSSProperties;
|
|
25
|
-
|
|
29
|
+
/**
|
|
30
|
+
* The `horizontal` variant's width. A number of 1 or less is a fraction of
|
|
31
|
+
* the parent (as in `sx`); a larger number is design px, scaled with the
|
|
32
|
+
* theme's type scale; a string is used as given.
|
|
33
|
+
*/
|
|
26
34
|
width?: number | string;
|
|
27
35
|
scrollableTarget?: string | HTMLElement; // For custom scroll containers
|
|
28
36
|
/**
|