@coveord/plasma-mantine 56.18.0 → 56.20.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/.turbo/turbo-build.log +4 -4
- package/.turbo/turbo-test.log +118 -115
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/components/Collection/Collection.d.ts +75 -12
- package/dist/cjs/components/Collection/Collection.d.ts.map +1 -1
- package/dist/cjs/components/Collection/Collection.js +94 -38
- package/dist/cjs/components/Collection/Collection.js.map +1 -1
- package/dist/cjs/components/Collection/Collection.module.css +13 -1
- package/dist/cjs/components/Collection/CollectionAddButton.d.ts +25 -0
- package/dist/cjs/components/Collection/CollectionAddButton.d.ts.map +1 -0
- package/dist/cjs/components/Collection/CollectionAddButton.js +33 -0
- package/dist/cjs/components/Collection/CollectionAddButton.js.map +1 -0
- package/dist/cjs/components/Collection/CollectionColumn.types.d.ts +72 -0
- package/dist/cjs/components/Collection/CollectionColumn.types.d.ts.map +1 -0
- package/dist/cjs/components/Collection/CollectionColumn.types.js +6 -0
- package/dist/cjs/components/Collection/CollectionColumn.types.js.map +1 -0
- package/dist/cjs/components/Collection/CollectionContext.d.ts +5 -0
- package/dist/cjs/components/Collection/CollectionContext.d.ts.map +1 -1
- package/dist/cjs/components/Collection/CollectionContext.js.map +1 -1
- package/dist/cjs/components/Collection/CollectionItem.d.ts +2 -2
- package/dist/cjs/components/Collection/CollectionItem.d.ts.map +1 -1
- package/dist/cjs/components/Collection/CollectionItem.js +18 -38
- package/dist/cjs/components/Collection/CollectionItem.js.map +1 -1
- package/dist/cjs/components/Collection/layouts/CollectionLayout.types.d.ts +46 -0
- package/dist/cjs/components/Collection/layouts/CollectionLayout.types.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/CollectionLayout.types.js +6 -0
- package/dist/cjs/components/Collection/layouts/CollectionLayout.types.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/CollectionLayouts.d.ts +26 -0
- package/dist/cjs/components/Collection/layouts/CollectionLayouts.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/CollectionLayouts.js +29 -0
- package/dist/cjs/components/Collection/layouts/CollectionLayouts.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayout.d.ts +12 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayout.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayout.js +24 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayout.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayout.module.css +37 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.d.ts +6 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.js +78 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.d.ts +6 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.js +56 -0
- package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/shared/DragHandle.d.ts +12 -0
- package/dist/cjs/components/Collection/layouts/shared/DragHandle.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/shared/DragHandle.js +28 -0
- package/dist/cjs/components/Collection/layouts/shared/DragHandle.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/shared/RemoveButton.d.ts +11 -0
- package/dist/cjs/components/Collection/layouts/shared/RemoveButton.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/shared/RemoveButton.js +39 -0
- package/dist/cjs/components/Collection/layouts/shared/RemoveButton.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/shared/columnUtils.d.ts +8 -0
- package/dist/cjs/components/Collection/layouts/shared/columnUtils.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/shared/columnUtils.js +24 -0
- package/dist/cjs/components/Collection/layouts/shared/columnUtils.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/shared/headerUtils.d.ts +8 -0
- package/dist/cjs/components/Collection/layouts/shared/headerUtils.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/shared/headerUtils.js +21 -0
- package/dist/cjs/components/Collection/layouts/shared/headerUtils.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/shared/itemRenderer.d.ts +78 -0
- package/dist/cjs/components/Collection/layouts/shared/itemRenderer.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/shared/itemRenderer.js +160 -0
- package/dist/cjs/components/Collection/layouts/shared/itemRenderer.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/shared/layoutConstants.d.ts +38 -0
- package/dist/cjs/components/Collection/layouts/shared/layoutConstants.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/shared/layoutConstants.js +31 -0
- package/dist/cjs/components/Collection/layouts/shared/layoutConstants.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayout.d.ts +12 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayout.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayout.js +24 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayout.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayout.module.css +35 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutBody.d.ts +6 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutBody.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutBody.js +134 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutBody.js.map +1 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.d.ts +10 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.d.ts.map +1 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.js +15 -0
- package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/Collection/Collection.d.ts +75 -12
- package/dist/esm/components/Collection/Collection.d.ts.map +1 -1
- package/dist/esm/components/Collection/Collection.js +87 -32
- package/dist/esm/components/Collection/Collection.js.map +1 -1
- package/dist/esm/components/Collection/Collection.module.css +13 -1
- package/dist/esm/components/Collection/CollectionAddButton.d.ts +25 -0
- package/dist/esm/components/Collection/CollectionAddButton.d.ts.map +1 -0
- package/dist/esm/components/Collection/CollectionAddButton.js +19 -0
- package/dist/esm/components/Collection/CollectionAddButton.js.map +1 -0
- package/dist/esm/components/Collection/CollectionColumn.types.d.ts +72 -0
- package/dist/esm/components/Collection/CollectionColumn.types.d.ts.map +1 -0
- package/dist/esm/components/Collection/CollectionColumn.types.js +5 -0
- package/dist/esm/components/Collection/CollectionColumn.types.js.map +1 -0
- package/dist/esm/components/Collection/CollectionContext.d.ts +5 -0
- package/dist/esm/components/Collection/CollectionContext.d.ts.map +1 -1
- package/dist/esm/components/Collection/CollectionContext.js.map +1 -1
- package/dist/esm/components/Collection/CollectionItem.d.ts +2 -2
- package/dist/esm/components/Collection/CollectionItem.d.ts.map +1 -1
- package/dist/esm/components/Collection/CollectionItem.js +15 -34
- package/dist/esm/components/Collection/CollectionItem.js.map +1 -1
- package/dist/esm/components/Collection/layouts/CollectionLayout.types.d.ts +46 -0
- package/dist/esm/components/Collection/layouts/CollectionLayout.types.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/CollectionLayout.types.js +6 -0
- package/dist/esm/components/Collection/layouts/CollectionLayout.types.js.map +1 -0
- package/dist/esm/components/Collection/layouts/CollectionLayouts.d.ts +26 -0
- package/dist/esm/components/Collection/layouts/CollectionLayouts.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/CollectionLayouts.js +10 -0
- package/dist/esm/components/Collection/layouts/CollectionLayouts.js.map +1 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayout.d.ts +12 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayout.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayout.js +11 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayout.js.map +1 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayout.module.css +37 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.d.ts +6 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.js +49 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.js.map +1 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.d.ts +6 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.js +36 -0
- package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.js.map +1 -0
- package/dist/esm/components/Collection/layouts/shared/DragHandle.d.ts +12 -0
- package/dist/esm/components/Collection/layouts/shared/DragHandle.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/shared/DragHandle.js +20 -0
- package/dist/esm/components/Collection/layouts/shared/DragHandle.js.map +1 -0
- package/dist/esm/components/Collection/layouts/shared/RemoveButton.d.ts +11 -0
- package/dist/esm/components/Collection/layouts/shared/RemoveButton.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/shared/RemoveButton.js +30 -0
- package/dist/esm/components/Collection/layouts/shared/RemoveButton.js.map +1 -0
- package/dist/esm/components/Collection/layouts/shared/columnUtils.d.ts +8 -0
- package/dist/esm/components/Collection/layouts/shared/columnUtils.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/shared/columnUtils.js +17 -0
- package/dist/esm/components/Collection/layouts/shared/columnUtils.js.map +1 -0
- package/dist/esm/components/Collection/layouts/shared/headerUtils.d.ts +8 -0
- package/dist/esm/components/Collection/layouts/shared/headerUtils.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/shared/headerUtils.js +14 -0
- package/dist/esm/components/Collection/layouts/shared/headerUtils.js.map +1 -0
- package/dist/esm/components/Collection/layouts/shared/itemRenderer.d.ts +78 -0
- package/dist/esm/components/Collection/layouts/shared/itemRenderer.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/shared/itemRenderer.js +150 -0
- package/dist/esm/components/Collection/layouts/shared/itemRenderer.js.map +1 -0
- package/dist/esm/components/Collection/layouts/shared/layoutConstants.d.ts +38 -0
- package/dist/esm/components/Collection/layouts/shared/layoutConstants.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/shared/layoutConstants.js +18 -0
- package/dist/esm/components/Collection/layouts/shared/layoutConstants.js.map +1 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayout.d.ts +12 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayout.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayout.js +11 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayout.js.map +1 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayout.module.css +35 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutBody.d.ts +6 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutBody.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutBody.js +103 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutBody.js.map +1 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.d.ts +10 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.d.ts.map +1 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.js +6 -0
- package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/Collection/Collection.module.css +13 -1
- package/src/components/Collection/Collection.tsx +149 -50
- package/src/components/Collection/CollectionAddButton.tsx +42 -0
- package/src/components/Collection/CollectionColumn.types.ts +79 -0
- package/src/components/Collection/CollectionContext.ts +5 -0
- package/src/components/Collection/CollectionItem.tsx +10 -21
- package/src/components/Collection/__tests__/CollectionWithColumns.spec.tsx +560 -0
- package/src/components/Collection/layouts/CollectionLayout.types.ts +56 -0
- package/src/components/Collection/layouts/CollectionLayouts.tsx +15 -0
- package/src/components/Collection/layouts/horizontal-layout/HorizontalLayout.module.css +37 -0
- package/src/components/Collection/layouts/horizontal-layout/HorizontalLayout.tsx +9 -0
- package/src/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.tsx +68 -0
- package/src/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.tsx +33 -0
- package/src/components/Collection/layouts/shared/DragHandle.tsx +22 -0
- package/src/components/Collection/layouts/shared/RemoveButton.tsx +30 -0
- package/src/components/Collection/layouts/shared/columnUtils.ts +20 -0
- package/src/components/Collection/layouts/shared/headerUtils.ts +14 -0
- package/src/components/Collection/layouts/shared/itemRenderer.tsx +242 -0
- package/src/components/Collection/layouts/shared/layoutConstants.ts +51 -0
- package/src/components/Collection/layouts/vertical-layout/VerticalLayout.module.css +35 -0
- package/src/components/Collection/layouts/vertical-layout/VerticalLayout.tsx +9 -0
- package/src/components/Collection/layouts/vertical-layout/VerticalLayoutBody.tsx +120 -0
- package/src/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.tsx +8 -0
- package/src/index.ts +11 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.headerRow {
|
|
2
|
+
display: flex;
|
|
3
|
+
gap: var(--mantine-spacing-sm);
|
|
4
|
+
padding-bottom: var(--mantine-spacing-xs);
|
|
5
|
+
align-items: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.headerCell {
|
|
9
|
+
flex: 1;
|
|
10
|
+
font-weight: var(--coveo-fw-bold);
|
|
11
|
+
text-align: left;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.dragHandleHeader {
|
|
15
|
+
width: var(--mantine-spacing-sm);
|
|
16
|
+
flex-shrink: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.removeButtonHeader {
|
|
20
|
+
width: calc(var(--mantine-spacing-md) + var(--mantine-spacing-sm));
|
|
21
|
+
flex-shrink: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.row {
|
|
25
|
+
display: flex;
|
|
26
|
+
gap: var(--mantine-spacing-sm);
|
|
27
|
+
align-items: center;
|
|
28
|
+
background: var(--mantine-color-body);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.row[data-isdragging='true'] {
|
|
32
|
+
z-index: 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.cell {
|
|
36
|
+
flex: 1;
|
|
37
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ForwardedRef } from 'react';
|
|
2
|
+
import { LayoutBodyProps } from '../shared/layoutConstants.js';
|
|
3
|
+
export declare const HorizontalLayoutBody: <T>(props: LayoutBodyProps<T> & {
|
|
4
|
+
ref?: ForwardedRef<HTMLDivElement>;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=HorizontalLayoutBody.d.ts.map
|
package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HorizontalLayoutBody.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAU,MAAM,OAAO,CAAC;AAI5C,OAAO,EAA4B,eAAe,EAAC,MAAM,8BAA8B,CAAC;AA8BxF,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAG,OAAO,eAAe,CAAC,CAAC,CAAC,GAAG;IAAC,GAAG,CAAC,EAAE,YAAY,CAAC,cAAc,CAAC,CAAA;CAAC,4CAgCxG,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Stack, useProps } from '@mantine/core';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { useCollectionContext } from '../../CollectionContext.js';
|
|
5
|
+
import { getColumnSizeStyles } from '../shared/columnUtils.js';
|
|
6
|
+
import { createItemRenderers, mapItemsToComponents } from '../shared/itemRenderer.js';
|
|
7
|
+
import { LAYOUT_BODY_DEFAULT_PROPS } from '../shared/layoutConstants.js';
|
|
8
|
+
import classes from './HorizontalLayout.module.css';
|
|
9
|
+
const defaultProps = LAYOUT_BODY_DEFAULT_PROPS;
|
|
10
|
+
/**
|
|
11
|
+
* Horizontal layout specific content renderer - renders cells in a row
|
|
12
|
+
*/ const renderHorizontalContent = (item, index, columns, cellContext, layoutClasses)=>/*#__PURE__*/ _jsx(_Fragment, {
|
|
13
|
+
children: columns.map((column, colIndex)=>{
|
|
14
|
+
const columnId = column.id ?? `column-${colIndex}`;
|
|
15
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
16
|
+
className: layoutClasses.cell,
|
|
17
|
+
style: getColumnSizeStyles(column),
|
|
18
|
+
children: column.cell(item, index, cellContext)
|
|
19
|
+
}, columnId);
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
// Create renderers once - they are stable component references
|
|
23
|
+
const horizontalRenderers = createItemRenderers();
|
|
24
|
+
export const HorizontalLayoutBody = (props)=>{
|
|
25
|
+
const collectionCtx = useCollectionContext();
|
|
26
|
+
const { items, onRemove, removable, draggable, disabled, readOnly, getItemId, gap, ref, ...others } = useProps('HorizontalLayoutBody', defaultProps, props);
|
|
27
|
+
const config = useMemo(()=>({
|
|
28
|
+
renderContent: renderHorizontalContent,
|
|
29
|
+
containerSelector: 'row',
|
|
30
|
+
inlineControls: true
|
|
31
|
+
}), []);
|
|
32
|
+
const rows = mapItemsToComponents(items, horizontalRenderers, config, classes, {
|
|
33
|
+
getItemId,
|
|
34
|
+
onRemove,
|
|
35
|
+
removable,
|
|
36
|
+
draggable,
|
|
37
|
+
disabled,
|
|
38
|
+
readOnly,
|
|
39
|
+
columns: collectionCtx.columns
|
|
40
|
+
});
|
|
41
|
+
return /*#__PURE__*/ _jsx(Stack, {
|
|
42
|
+
ref: ref,
|
|
43
|
+
gap: gap,
|
|
44
|
+
...others,
|
|
45
|
+
children: rows
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=HorizontalLayoutBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.tsx"],"sourcesContent":["import {Box, Stack, useProps} from '@mantine/core';\nimport {ForwardedRef, useMemo} from 'react';\nimport {useCollectionContext} from '../../CollectionContext.js';\nimport {getColumnSizeStyles} from '../shared/columnUtils.js';\nimport {createItemRenderers, ItemContentRenderer, LayoutClasses, mapItemsToComponents} from '../shared/itemRenderer.js';\nimport {LAYOUT_BODY_DEFAULT_PROPS, LayoutBodyProps} from '../shared/layoutConstants.js';\nimport classes from './HorizontalLayout.module.css';\n\nconst defaultProps: Partial<LayoutBodyProps> = LAYOUT_BODY_DEFAULT_PROPS;\n\n/**\n * Horizontal layout specific content renderer - renders cells in a row\n */\nconst renderHorizontalContent: ItemContentRenderer<unknown> = (\n item,\n index,\n columns,\n cellContext,\n layoutClasses: LayoutClasses,\n) => (\n <>\n {columns.map((column, colIndex) => {\n const columnId = column.id ?? `column-${colIndex}`;\n return (\n <Box key={columnId} className={layoutClasses.cell} style={getColumnSizeStyles(column)}>\n {column.cell(item, index, cellContext)}\n </Box>\n );\n })}\n </>\n);\n\n// Create renderers once - they are stable component references\nconst horizontalRenderers = createItemRenderers<unknown>();\n\nexport const HorizontalLayoutBody = <T,>(props: LayoutBodyProps<T> & {ref?: ForwardedRef<HTMLDivElement>}) => {\n const collectionCtx = useCollectionContext();\n const {items, onRemove, removable, draggable, disabled, readOnly, getItemId, gap, ref, ...others} = useProps(\n 'HorizontalLayoutBody',\n defaultProps as LayoutBodyProps<T>,\n props,\n );\n\n const config = useMemo(\n () => ({\n renderContent: renderHorizontalContent,\n containerSelector: 'row',\n inlineControls: true,\n }),\n [],\n );\n\n const rows = mapItemsToComponents(items, horizontalRenderers, config, classes as LayoutClasses, {\n getItemId,\n onRemove,\n removable,\n draggable,\n disabled,\n readOnly,\n columns: collectionCtx.columns,\n });\n\n return (\n <Stack ref={ref} gap={gap} {...others}>\n {rows}\n </Stack>\n );\n};\n"],"names":["Box","Stack","useProps","useMemo","useCollectionContext","getColumnSizeStyles","createItemRenderers","mapItemsToComponents","LAYOUT_BODY_DEFAULT_PROPS","classes","defaultProps","renderHorizontalContent","item","index","columns","cellContext","layoutClasses","map","column","colIndex","columnId","id","className","cell","style","horizontalRenderers","HorizontalLayoutBody","props","collectionCtx","items","onRemove","removable","draggable","disabled","readOnly","getItemId","gap","ref","others","config","renderContent","containerSelector","inlineControls","rows"],"mappings":";AAAA,SAAQA,GAAG,EAAEC,KAAK,EAAEC,QAAQ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
1
|
+
import { ForwardedRef } from 'react';
|
|
2
|
+
import { LayoutHeaderProps } from '../shared/layoutConstants.js';
|
|
3
|
+
export declare const HorizontalLayoutHeader: (props: LayoutHeaderProps & {
|
|
4
|
+
ref?: ForwardedRef<HTMLDivElement>;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=HorizontalLayoutHeader.d.ts.map
|
package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HorizontalLayoutHeader.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,OAAO,CAAC;AAInC,OAAO,EAA8B,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAK5F,eAAO,MAAM,sBAAsB,GAAI,OAAO,iBAAiB,GAAG;IAAC,GAAG,CAAC,EAAE,YAAY,CAAC,cAAc,CAAC,CAAA;CAAC,4CAsBrG,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, useProps } from '@mantine/core';
|
|
3
|
+
import { useCollectionContext } from '../../CollectionContext.js';
|
|
4
|
+
import { getColumnSizeStyles } from '../shared/columnUtils.js';
|
|
5
|
+
import { renderColumnHeader } from '../shared/headerUtils.js';
|
|
6
|
+
import { LAYOUT_HEADER_DEFAULT_PROPS } from '../shared/layoutConstants.js';
|
|
7
|
+
import classes from './HorizontalLayout.module.css';
|
|
8
|
+
const defaultProps = LAYOUT_HEADER_DEFAULT_PROPS;
|
|
9
|
+
export const HorizontalLayoutHeader = (props)=>{
|
|
10
|
+
const collectionCtx = useCollectionContext();
|
|
11
|
+
const { draggable, removable, style, ref, ...others } = useProps('HorizontalLayoutHeader', defaultProps, props);
|
|
12
|
+
return /*#__PURE__*/ _jsxs(Box, {
|
|
13
|
+
ref: ref,
|
|
14
|
+
className: classes.headerRow,
|
|
15
|
+
style: style,
|
|
16
|
+
...others,
|
|
17
|
+
children: [
|
|
18
|
+
draggable && /*#__PURE__*/ _jsx("div", {
|
|
19
|
+
className: classes.dragHandleHeader
|
|
20
|
+
}),
|
|
21
|
+
collectionCtx.columns.map((column, index)=>{
|
|
22
|
+
const columnId = column.id ?? `column-${index}`;
|
|
23
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
24
|
+
className: classes.headerCell,
|
|
25
|
+
style: getColumnSizeStyles(column),
|
|
26
|
+
children: renderColumnHeader(column.header, index)
|
|
27
|
+
}, columnId);
|
|
28
|
+
}),
|
|
29
|
+
removable && /*#__PURE__*/ _jsx("div", {
|
|
30
|
+
className: classes.removeButtonHeader
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=HorizontalLayoutHeader.js.map
|
package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.tsx"],"sourcesContent":["import {Box, useProps} from '@mantine/core';\nimport {ForwardedRef} from 'react';\nimport {useCollectionContext} from '../../CollectionContext.js';\nimport {getColumnSizeStyles} from '../shared/columnUtils.js';\nimport {renderColumnHeader} from '../shared/headerUtils.js';\nimport {LAYOUT_HEADER_DEFAULT_PROPS, LayoutHeaderProps} from '../shared/layoutConstants.js';\nimport classes from './HorizontalLayout.module.css';\n\nconst defaultProps: Partial<LayoutHeaderProps> = LAYOUT_HEADER_DEFAULT_PROPS;\n\nexport const HorizontalLayoutHeader = (props: LayoutHeaderProps & {ref?: ForwardedRef<HTMLDivElement>}) => {\n const collectionCtx = useCollectionContext();\n const {draggable, removable, style, ref, ...others} = useProps(\n 'HorizontalLayoutHeader',\n defaultProps as LayoutHeaderProps,\n props,\n );\n\n return (\n <Box ref={ref} className={classes.headerRow} style={style} {...others}>\n {draggable && <div className={classes.dragHandleHeader} />}\n {collectionCtx.columns.map((column, index) => {\n const columnId = column.id ?? `column-${index}`;\n return (\n <Box key={columnId} className={classes.headerCell} style={getColumnSizeStyles(column)}>\n {renderColumnHeader(column.header, index)}\n </Box>\n );\n })}\n {removable && <div className={classes.removeButtonHeader} />}\n </Box>\n );\n};\n"],"names":["Box","useProps","useCollectionContext","getColumnSizeStyles","renderColumnHeader","LAYOUT_HEADER_DEFAULT_PROPS","classes","defaultProps","HorizontalLayoutHeader","props","collectionCtx","draggable","removable","style","ref","others","className","headerRow","div","dragHandleHeader","columns","map","column","index","columnId","id","headerCell","header","removeButtonHeader"],"mappings":";AAAA,SAAQA,GAAG,EAAEC,QAAQ,QAAO,gBAAgB;AAE5C,SAAQC,oBAAoB,QAAO,6BAA6B;AAChE,SAAQC,mBAAmB,QAAO,2BAA2B;AAC7D,SAAQC,kBAAkB,QAAO,2BAA2B;AAC5D,SAAQC,2BAA2B,QAA0B,+BAA+B;AAC5F,OAAOC,aAAa,gCAAgC;AAEpD,MAAMC,eAA2CF;AAEjD,OAAO,MAAMG,yBAAyB,CAACC;IACnC,MAAMC,gBAAgBR;IACtB,MAAM,EAACS,SAAS,EAAEC,SAAS,EAAEC,KAAK,EAAEC,GAAG,EAAE,GAAGC,QAAO,GAAGd,SAClD,0BACAM,cACAE;IAGJ,qBACI,MAACT;QAAIc,KAAKA;QAAKE,WAAWV,QAAQW,SAAS;QAAEJ,OAAOA;QAAQ,GAAGE,MAAM;;YAChEJ,2BAAa,KAACO;gBAAIF,WAAWV,QAAQa,gBAAgB;;YACrDT,cAAcU,OAAO,CAACC,GAAG,CAAC,CAACC,QAAQC;gBAChC,MAAMC,WAAWF,OAAOG,EAAE,IAAI,CAAC,OAAO,EAAEF,OAAO;gBAC/C,qBACI,KAACvB;oBAAmBgB,WAAWV,QAAQoB,UAAU;oBAAEb,OAAOV,oBAAoBmB;8BACzElB,mBAAmBkB,OAAOK,MAAM,EAAEJ;mBAD7BC;YAIlB;YACCZ,2BAAa,KAACM;gBAAIF,WAAWV,QAAQsB,kBAAkB;;;;AAGpE,EAAE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
export interface DragHandleProps {
|
|
3
|
+
setActivatorNodeRef: (element: HTMLElement | null) => void;
|
|
4
|
+
listeners: any;
|
|
5
|
+
attributes: any;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Shared drag handle component used by both horizontal and vertical layouts.
|
|
9
|
+
* Renders the drag icon with proper event handlers for drag and drop functionality.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DragHandle: FunctionComponent<DragHandleProps>;
|
|
12
|
+
//# sourceMappingURL=DragHandle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragHandle.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Collection/layouts/shared/DragHandle.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAG7C,MAAM,WAAW,eAAe;IAC5B,mBAAmB,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3D,SAAS,EAAE,GAAG,CAAC;IACf,UAAU,EAAE,GAAG,CAAC;CACnB;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAOzD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DragAndDropSize16Px } from '@coveord/plasma-react-icons';
|
|
3
|
+
import { useCollectionContext } from '../../CollectionContext.js';
|
|
4
|
+
/**
|
|
5
|
+
* Shared drag handle component used by both horizontal and vertical layouts.
|
|
6
|
+
* Renders the drag icon with proper event handlers for drag and drop functionality.
|
|
7
|
+
*/ export const DragHandle = ({ setActivatorNodeRef, listeners, attributes })=>{
|
|
8
|
+
const { getStyles } = useCollectionContext();
|
|
9
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
10
|
+
ref: setActivatorNodeRef,
|
|
11
|
+
...listeners,
|
|
12
|
+
...attributes,
|
|
13
|
+
...getStyles('dragHandle'),
|
|
14
|
+
children: /*#__PURE__*/ _jsx(DragAndDropSize16Px, {
|
|
15
|
+
height: 16
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=DragHandle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Collection/layouts/shared/DragHandle.tsx"],"sourcesContent":["import {DragAndDropSize16Px} from '@coveord/plasma-react-icons';\nimport type {FunctionComponent} from 'react';\nimport {useCollectionContext} from '../../CollectionContext.js';\n\nexport interface DragHandleProps {\n setActivatorNodeRef: (element: HTMLElement | null) => void;\n listeners: any;\n attributes: any;\n}\n\n/**\n * Shared drag handle component used by both horizontal and vertical layouts.\n * Renders the drag icon with proper event handlers for drag and drop functionality.\n */\nexport const DragHandle: FunctionComponent<DragHandleProps> = ({setActivatorNodeRef, listeners, attributes}) => {\n const {getStyles} = useCollectionContext();\n return (\n <div ref={setActivatorNodeRef} {...listeners} {...attributes} {...getStyles('dragHandle')}>\n <DragAndDropSize16Px height={16} />\n </div>\n );\n};\n"],"names":["DragAndDropSize16Px","useCollectionContext","DragHandle","setActivatorNodeRef","listeners","attributes","getStyles","div","ref","height"],"mappings":";AAAA,SAAQA,mBAAmB,QAAO,8BAA8B;AAEhE,SAAQC,oBAAoB,QAAO,6BAA6B;AAQhE;;;CAGC,GACD,OAAO,MAAMC,aAAiD,CAAC,EAACC,mBAAmB,EAAEC,SAAS,EAAEC,UAAU,EAAC;IACvG,MAAM,EAACC,SAAS,EAAC,GAAGL;IACpB,qBACI,KAACM;QAAIC,KAAKL;QAAsB,GAAGC,SAAS;QAAG,GAAGC,UAAU;QAAG,GAAGC,UAAU,aAAa;kBACrF,cAAA,KAACN;YAAoBS,QAAQ;;;AAGzC,EAAE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FunctionComponent, type MouseEventHandler } from 'react';
|
|
2
|
+
export interface RemoveButtonProps {
|
|
3
|
+
removable?: boolean;
|
|
4
|
+
onRemove?: MouseEventHandler<HTMLButtonElement>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Shared remove button component used by both horizontal and vertical layouts.
|
|
8
|
+
* Renders a trash icon button when removable, or a spacer div otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare const RemoveButton: FunctionComponent<RemoveButtonProps>;
|
|
11
|
+
//# sourceMappingURL=RemoveButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemoveButton.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Collection/layouts/shared/RemoveButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,iBAAiB,EAAE,KAAK,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAIhE,MAAM,WAAW,iBAAiB;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;CACnD;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CAc7D,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { IconTrash } from '@coveord/plasma-react-icons';
|
|
3
|
+
import { Box } from '@mantine/core';
|
|
4
|
+
import { ActionIcon } from '../../../ActionIcon/ActionIcon.js';
|
|
5
|
+
import { useCollectionContext } from '../../CollectionContext.js';
|
|
6
|
+
/**
|
|
7
|
+
* Shared remove button component used by both horizontal and vertical layouts.
|
|
8
|
+
* Renders a trash icon button when removable, or a spacer div otherwise.
|
|
9
|
+
*/ export const RemoveButton = ({ removable, onRemove })=>{
|
|
10
|
+
const { getStyles } = useCollectionContext();
|
|
11
|
+
if (!removable || !onRemove) {
|
|
12
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
13
|
+
style: {
|
|
14
|
+
width: 28
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
19
|
+
...getStyles('removeButton'),
|
|
20
|
+
children: /*#__PURE__*/ _jsx(ActionIcon.Quaternary, {
|
|
21
|
+
onClick: onRemove,
|
|
22
|
+
children: /*#__PURE__*/ _jsx(IconTrash, {
|
|
23
|
+
"aria-label": "Remove",
|
|
24
|
+
size: 16
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=RemoveButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Collection/layouts/shared/RemoveButton.tsx"],"sourcesContent":["import {IconTrash} from '@coveord/plasma-react-icons';\nimport {Box} from '@mantine/core';\nimport {FunctionComponent, type MouseEventHandler} from 'react';\nimport {ActionIcon} from '../../../ActionIcon/ActionIcon.js';\nimport {useCollectionContext} from '../../CollectionContext.js';\n\nexport interface RemoveButtonProps {\n removable?: boolean;\n onRemove?: MouseEventHandler<HTMLButtonElement>;\n}\n\n/**\n * Shared remove button component used by both horizontal and vertical layouts.\n * Renders a trash icon button when removable, or a spacer div otherwise.\n */\nexport const RemoveButton: FunctionComponent<RemoveButtonProps> = ({removable, onRemove}) => {\n const {getStyles} = useCollectionContext();\n\n if (!removable || !onRemove) {\n return <div style={{width: 28}} />;\n }\n\n return (\n <Box {...getStyles('removeButton')}>\n <ActionIcon.Quaternary onClick={onRemove}>\n <IconTrash aria-label=\"Remove\" size={16} />\n </ActionIcon.Quaternary>\n </Box>\n );\n};\n"],"names":["IconTrash","Box","ActionIcon","useCollectionContext","RemoveButton","removable","onRemove","getStyles","div","style","width","Quaternary","onClick","aria-label","size"],"mappings":";AAAA,SAAQA,SAAS,QAAO,8BAA8B;AACtD,SAAQC,GAAG,QAAO,gBAAgB;AAElC,SAAQC,UAAU,QAAO,oCAAoC;AAC7D,SAAQC,oBAAoB,QAAO,6BAA6B;AAOhE;;;CAGC,GACD,OAAO,MAAMC,eAAqD,CAAC,EAACC,SAAS,EAAEC,QAAQ,EAAC;IACpF,MAAM,EAACC,SAAS,EAAC,GAAGJ;IAEpB,IAAI,CAACE,aAAa,CAACC,UAAU;QACzB,qBAAO,KAACE;YAAIC,OAAO;gBAACC,OAAO;YAAE;;IACjC;IAEA,qBACI,KAACT;QAAK,GAAGM,UAAU,eAAe;kBAC9B,cAAA,KAACL,WAAWS,UAAU;YAACC,SAASN;sBAC5B,cAAA,KAACN;gBAAUa,cAAW;gBAASC,MAAM;;;;AAIrD,EAAE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { CollectionColumnDef } from '../../CollectionColumn.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Converts column size configuration to CSS styles.
|
|
5
|
+
* Handles both numeric (px) and string (%, fr, etc.) size values.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getColumnSizeStyles: (column: CollectionColumnDef<any>) => CSSProperties;
|
|
8
|
+
//# sourceMappingURL=columnUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columnUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Collection/layouts/shared/columnUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AACpC,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,mBAAmB,CAAC,GAAG,CAAC,KAAG,aAYtE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts column size configuration to CSS styles.
|
|
3
|
+
* Handles both numeric (px) and string (%, fr, etc.) size values.
|
|
4
|
+
*/ export const getColumnSizeStyles = (column)=>{
|
|
5
|
+
const sizeToStyle = (size)=>{
|
|
6
|
+
if (size === undefined) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return typeof size === 'number' ? `${size}px` : size;
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
minWidth: sizeToStyle(column.minSize),
|
|
13
|
+
maxWidth: sizeToStyle(column.maxSize)
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=columnUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Collection/layouts/shared/columnUtils.ts"],"sourcesContent":["import {CSSProperties} from 'react';\nimport {CollectionColumnDef} from '../../CollectionColumn.types.js';\n\n/**\n * Converts column size configuration to CSS styles.\n * Handles both numeric (px) and string (%, fr, etc.) size values.\n */\nexport const getColumnSizeStyles = (column: CollectionColumnDef<any>): CSSProperties => {\n const sizeToStyle = (size: number | string | undefined): string | undefined => {\n if (size === undefined) {\n return undefined;\n }\n return typeof size === 'number' ? `${size}px` : size;\n };\n\n return {\n minWidth: sizeToStyle(column.minSize),\n maxWidth: sizeToStyle(column.maxSize),\n };\n};\n"],"names":["getColumnSizeStyles","column","sizeToStyle","size","undefined","minWidth","minSize","maxWidth","maxSize"],"mappings":"AAGA;;;CAGC,GACD,OAAO,MAAMA,sBAAsB,CAACC;IAChC,MAAMC,cAAc,CAACC;QACjB,IAAIA,SAASC,WAAW;YACpB,OAAOA;QACX;QACA,OAAO,OAAOD,SAAS,WAAW,GAAGA,KAAK,EAAE,CAAC,GAAGA;IACpD;IAEA,OAAO;QACHE,UAAUH,YAAYD,OAAOK,OAAO;QACpCC,UAAUL,YAAYD,OAAOO,OAAO;IACxC;AACJ,EAAE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { CollectionColumnDef } from '../../CollectionColumn.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Renders a column header by invoking the header function with context if needed.
|
|
5
|
+
* Handles both static headers (strings/nodes) and dynamic header functions.
|
|
6
|
+
*/
|
|
7
|
+
export declare const renderColumnHeader: (header: CollectionColumnDef<unknown>["header"], index: number) => ReactNode;
|
|
8
|
+
//# sourceMappingURL=headerUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headerUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Collection/layouts/shared/headerUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAChC,OAAO,EAAC,mBAAmB,EAA0B,MAAM,iCAAiC,CAAC;AAE7F;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,mBAAmB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,MAAM,KAAG,SAMlG,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a column header by invoking the header function with context if needed.
|
|
3
|
+
* Handles both static headers (strings/nodes) and dynamic header functions.
|
|
4
|
+
*/ export const renderColumnHeader = (header, index)=>{
|
|
5
|
+
if (typeof header === 'function') {
|
|
6
|
+
const context = {
|
|
7
|
+
index
|
|
8
|
+
};
|
|
9
|
+
return header(context);
|
|
10
|
+
}
|
|
11
|
+
return header;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=headerUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Collection/layouts/shared/headerUtils.ts"],"sourcesContent":["import {ReactNode} from 'react';\nimport {CollectionColumnDef, CollectionHeaderContext} from '../../CollectionColumn.types.js';\n\n/**\n * Renders a column header by invoking the header function with context if needed.\n * Handles both static headers (strings/nodes) and dynamic header functions.\n */\nexport const renderColumnHeader = (header: CollectionColumnDef<unknown>['header'], index: number): ReactNode => {\n if (typeof header === 'function') {\n const context: CollectionHeaderContext = {index};\n return header(context);\n }\n return header;\n};\n"],"names":["renderColumnHeader","header","index","context"],"mappings":"AAGA;;;CAGC,GACD,OAAO,MAAMA,qBAAqB,CAACC,QAAgDC;IAC/E,IAAI,OAAOD,WAAW,YAAY;QAC9B,MAAME,UAAmC;YAACD;QAAK;QAC/C,OAAOD,OAAOE;IAClB;IACA,OAAOF;AACX,EAAE"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { CollectionCellContext, CollectionColumnDef } from '../../CollectionColumn.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* CSS classes object for layout styling.
|
|
5
|
+
*/
|
|
6
|
+
export interface LayoutClasses {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Common props for rendering an item/row in either layout.
|
|
11
|
+
*/
|
|
12
|
+
export interface ItemProps<T> {
|
|
13
|
+
item: T;
|
|
14
|
+
index: number;
|
|
15
|
+
id: string;
|
|
16
|
+
columns: Array<CollectionColumnDef<T>>;
|
|
17
|
+
onRemove?: () => void;
|
|
18
|
+
removable?: boolean;
|
|
19
|
+
draggable?: boolean;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
classes: LayoutClasses;
|
|
23
|
+
config: ItemRendererConfig<T>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Function type that renders the content specific to each layout.
|
|
27
|
+
* Horizontal layout renders cells in a row, vertical layout renders stacked fields.
|
|
28
|
+
*/
|
|
29
|
+
export type ItemContentRenderer<T> = (item: T, index: number, columns: Array<CollectionColumnDef<T>>, cellContext: CollectionCellContext<T>, classes: LayoutClasses) => ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Function type that renders content with inline drag handle for draggable items.
|
|
32
|
+
* Used by layouts that want the drag handle integrated into the content (e.g., vertical layout).
|
|
33
|
+
*/
|
|
34
|
+
export type DraggableContentRenderer<T> = (item: T, index: number, columns: Array<CollectionColumnDef<T>>, cellContext: CollectionCellContext<T>, classes: LayoutClasses, dragHandleProps: {
|
|
35
|
+
setActivatorNodeRef: (element: HTMLElement | null) => void;
|
|
36
|
+
listeners: any;
|
|
37
|
+
attributes: any;
|
|
38
|
+
}) => ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* Configuration for creating layout-specific item renderers.
|
|
41
|
+
*/
|
|
42
|
+
export interface ItemRendererConfig<T> {
|
|
43
|
+
/** The content rendering function specific to the layout */
|
|
44
|
+
renderContent: ItemContentRenderer<T>;
|
|
45
|
+
/** The container style selector ('row' for horizontal, 'item' for vertical) */
|
|
46
|
+
containerSelector: string;
|
|
47
|
+
/** Optional: whether to render drag handle and remove button inline with content (used by horizontal layout) */
|
|
48
|
+
inlineControls?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Optional: custom content renderer for draggable items that integrates the drag handle.
|
|
51
|
+
* If provided, this is used instead of the default drag handle + renderContent pattern.
|
|
52
|
+
* Used by vertical layout to place drag handle alongside the field stack.
|
|
53
|
+
*/
|
|
54
|
+
renderDraggableContent?: DraggableContentRenderer<T>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a set of item renderers (draggable, static, disabled) for a layout.
|
|
58
|
+
* This eliminates the duplication of three nearly identical component variants.
|
|
59
|
+
* The renderers are stable function references that don't capture variables in closures.
|
|
60
|
+
*/
|
|
61
|
+
export declare const createItemRenderers: <T>() => {
|
|
62
|
+
DraggableItem: (props: ItemProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
63
|
+
StaticItem: (props: ItemProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
64
|
+
DisabledItem: (props: ItemProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Maps items to their appropriate renderer components based on state.
|
|
68
|
+
*/
|
|
69
|
+
export declare const mapItemsToComponents: <T>(items: T[], renderers: ReturnType<typeof createItemRenderers<T>>, config: ItemRendererConfig<T>, classes: LayoutClasses, options: {
|
|
70
|
+
getItemId?: (item: T, index: number) => string;
|
|
71
|
+
onRemove?: (index: number) => void;
|
|
72
|
+
removable?: boolean;
|
|
73
|
+
draggable?: boolean;
|
|
74
|
+
disabled?: boolean;
|
|
75
|
+
readOnly?: boolean;
|
|
76
|
+
columns: Array<CollectionColumnDef<T>>;
|
|
77
|
+
}) => ReactNode[];
|
|
78
|
+
//# sourceMappingURL=itemRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itemRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Collection/layouts/shared/itemRenderer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAChC,OAAO,EAAC,qBAAqB,EAAE,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAI3F;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAA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I,CAAC,EAClC,OAAO,CAAC,EAAE,EACV,WAAW,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,EACpD,QAAQ,kBAAkB,CAAC,CAAC,CAAC,EAC7B,SAAS,aAAa,EACtB,SAAS;IACL,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;CAC1C,KACF,SAAS,EA8BX,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useSortable } from '@dnd-kit/sortable';
|
|
3
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
4
|
+
import { Box } from '@mantine/core';
|
|
5
|
+
import { DragHandle } from './DragHandle.js';
|
|
6
|
+
import { RemoveButton } from './RemoveButton.js';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a set of item renderers (draggable, static, disabled) for a layout.
|
|
9
|
+
* This eliminates the duplication of three nearly identical component variants.
|
|
10
|
+
* The renderers are stable function references that don't capture variables in closures.
|
|
11
|
+
*/ export const createItemRenderers = ()=>{
|
|
12
|
+
/**
|
|
13
|
+
* Draggable item/row renderer with drag and drop functionality
|
|
14
|
+
*/ const DraggableItem = (props)=>{
|
|
15
|
+
const { item, index, id, columns, onRemove, removable, disabled, readOnly, classes, config } = props;
|
|
16
|
+
const { attributes, listeners, setNodeRef, transform, transition, isDragging, setActivatorNodeRef } = useSortable({
|
|
17
|
+
id
|
|
18
|
+
});
|
|
19
|
+
const cellContext = {
|
|
20
|
+
removable,
|
|
21
|
+
draggable: true,
|
|
22
|
+
disabled,
|
|
23
|
+
readOnly,
|
|
24
|
+
onRemove
|
|
25
|
+
};
|
|
26
|
+
const dragHandleProps = {
|
|
27
|
+
setActivatorNodeRef,
|
|
28
|
+
listeners,
|
|
29
|
+
attributes
|
|
30
|
+
};
|
|
31
|
+
// Use renderDraggableContent if provided (integrates drag handle into content)
|
|
32
|
+
if (config.renderDraggableContent) {
|
|
33
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
34
|
+
ref: setNodeRef,
|
|
35
|
+
"data-testid": `item-${id}`,
|
|
36
|
+
className: classes[config.containerSelector],
|
|
37
|
+
style: transform ? {
|
|
38
|
+
transform: CSS.Transform.toString(transform),
|
|
39
|
+
transition
|
|
40
|
+
} : undefined,
|
|
41
|
+
"data-isdragging": isDragging,
|
|
42
|
+
children: config.renderDraggableContent(item, index, columns, cellContext, classes, dragHandleProps)
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// Default behavior: inline drag handle + content + remove button (used by horizontal layout)
|
|
46
|
+
return /*#__PURE__*/ _jsxs(Box, {
|
|
47
|
+
ref: setNodeRef,
|
|
48
|
+
"data-testid": `item-${id}`,
|
|
49
|
+
className: classes[config.containerSelector],
|
|
50
|
+
style: transform ? {
|
|
51
|
+
transform: CSS.Transform.toString(transform),
|
|
52
|
+
transition
|
|
53
|
+
} : undefined,
|
|
54
|
+
"data-isdragging": isDragging,
|
|
55
|
+
children: [
|
|
56
|
+
/*#__PURE__*/ _jsx(DragHandle, {
|
|
57
|
+
setActivatorNodeRef: setActivatorNodeRef,
|
|
58
|
+
listeners: listeners,
|
|
59
|
+
attributes: attributes
|
|
60
|
+
}),
|
|
61
|
+
config.renderContent(item, index, columns, cellContext, classes),
|
|
62
|
+
config.inlineControls && /*#__PURE__*/ _jsx(RemoveButton, {
|
|
63
|
+
removable: removable,
|
|
64
|
+
onRemove: onRemove
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Static (non-draggable) item/row renderer
|
|
71
|
+
*/ const StaticItem = (props)=>{
|
|
72
|
+
const { item, index, id, columns, onRemove, removable, disabled, readOnly, classes, config } = props;
|
|
73
|
+
const cellContext = {
|
|
74
|
+
removable,
|
|
75
|
+
draggable: false,
|
|
76
|
+
disabled,
|
|
77
|
+
readOnly,
|
|
78
|
+
onRemove
|
|
79
|
+
};
|
|
80
|
+
return /*#__PURE__*/ _jsxs(Box, {
|
|
81
|
+
"data-testid": `item-${id}`,
|
|
82
|
+
className: classes[config.containerSelector],
|
|
83
|
+
children: [
|
|
84
|
+
config.renderContent(item, index, columns, cellContext, classes),
|
|
85
|
+
config.inlineControls && /*#__PURE__*/ _jsx(RemoveButton, {
|
|
86
|
+
removable: removable,
|
|
87
|
+
onRemove: onRemove
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Disabled item/row renderer (no drag, no remove)
|
|
94
|
+
*/ const DisabledItem = (props)=>{
|
|
95
|
+
const { item, index, id, columns, disabled, readOnly, classes, config } = props;
|
|
96
|
+
const cellContext = {
|
|
97
|
+
removable: false,
|
|
98
|
+
draggable: false,
|
|
99
|
+
disabled,
|
|
100
|
+
readOnly
|
|
101
|
+
};
|
|
102
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
103
|
+
"data-testid": `item-${id}`,
|
|
104
|
+
className: classes[config.containerSelector],
|
|
105
|
+
children: config.renderContent(item, index, columns, cellContext, classes)
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
DraggableItem,
|
|
110
|
+
StaticItem,
|
|
111
|
+
DisabledItem
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Maps items to their appropriate renderer components based on state.
|
|
116
|
+
*/ export const mapItemsToComponents = (items, renderers, config, classes, options)=>{
|
|
117
|
+
const { getItemId, onRemove, removable, draggable, disabled, readOnly, columns } = options;
|
|
118
|
+
const { DraggableItem, StaticItem, DisabledItem } = renderers;
|
|
119
|
+
return items.map((item, index)=>{
|
|
120
|
+
const id = getItemId?.(item, index) ?? String(index);
|
|
121
|
+
const itemProps = {
|
|
122
|
+
item,
|
|
123
|
+
index,
|
|
124
|
+
id,
|
|
125
|
+
columns,
|
|
126
|
+
onRemove: onRemove ? ()=>onRemove(index) : undefined,
|
|
127
|
+
removable,
|
|
128
|
+
draggable,
|
|
129
|
+
disabled,
|
|
130
|
+
readOnly,
|
|
131
|
+
classes,
|
|
132
|
+
config
|
|
133
|
+
};
|
|
134
|
+
if (disabled) {
|
|
135
|
+
return /*#__PURE__*/ _jsx(DisabledItem, {
|
|
136
|
+
...itemProps
|
|
137
|
+
}, id);
|
|
138
|
+
}
|
|
139
|
+
if (draggable) {
|
|
140
|
+
return /*#__PURE__*/ _jsx(DraggableItem, {
|
|
141
|
+
...itemProps
|
|
142
|
+
}, id);
|
|
143
|
+
}
|
|
144
|
+
return /*#__PURE__*/ _jsx(StaticItem, {
|
|
145
|
+
...itemProps
|
|
146
|
+
}, id);
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
//# sourceMappingURL=itemRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Collection/layouts/shared/itemRenderer.tsx"],"sourcesContent":["import {useSortable} from '@dnd-kit/sortable';\nimport {CSS} from '@dnd-kit/utilities';\nimport {Box} from '@mantine/core';\nimport {ReactNode} from 'react';\nimport {CollectionCellContext, CollectionColumnDef} from '../../CollectionColumn.types.js';\nimport {DragHandle} from './DragHandle.js';\nimport {RemoveButton} from './RemoveButton.js';\n\n/**\n * CSS classes object for layout styling.\n */\nexport interface LayoutClasses {\n [key: string]: string;\n}\n\n/**\n * Common props for rendering an item/row in either layout.\n */\nexport interface ItemProps<T> {\n item: T;\n index: number;\n id: string;\n columns: Array<CollectionColumnDef<T>>;\n onRemove?: () => void;\n removable?: boolean;\n draggable?: boolean;\n disabled?: boolean;\n readOnly?: boolean;\n classes: LayoutClasses;\n config: ItemRendererConfig<T>;\n}\n\n/**\n * Function type that renders the content specific to each layout.\n * Horizontal layout renders cells in a row, vertical layout renders stacked fields.\n */\nexport type ItemContentRenderer<T> = (\n item: T,\n index: number,\n columns: Array<CollectionColumnDef<T>>,\n cellContext: CollectionCellContext<T>,\n classes: LayoutClasses,\n) => ReactNode;\n\n/**\n * Function type that renders content with inline drag handle for draggable items.\n * Used by layouts that want the drag handle integrated into the content (e.g., vertical layout).\n */\nexport type DraggableContentRenderer<T> = (\n item: T,\n index: number,\n columns: Array<CollectionColumnDef<T>>,\n cellContext: CollectionCellContext<T>,\n classes: LayoutClasses,\n dragHandleProps: {\n setActivatorNodeRef: (element: HTMLElement | null) => void;\n listeners: any;\n attributes: any;\n },\n) => ReactNode;\n\n/**\n * Configuration for creating layout-specific item renderers.\n */\nexport interface ItemRendererConfig<T> {\n /** The content rendering function specific to the layout */\n renderContent: ItemContentRenderer<T>;\n /** The container style selector ('row' for horizontal, 'item' for vertical) */\n containerSelector: string;\n /** Optional: whether to render drag handle and remove button inline with content (used by horizontal layout) */\n inlineControls?: boolean;\n /**\n * Optional: custom content renderer for draggable items that integrates the drag handle.\n * If provided, this is used instead of the default drag handle + renderContent pattern.\n * Used by vertical layout to place drag handle alongside the field stack.\n */\n renderDraggableContent?: DraggableContentRenderer<T>;\n}\n\n/**\n * Creates a set of item renderers (draggable, static, disabled) for a layout.\n * This eliminates the duplication of three nearly identical component variants.\n * The renderers are stable function references that don't capture variables in closures.\n */\nexport const createItemRenderers = <T,>() => {\n /**\n * Draggable item/row renderer with drag and drop functionality\n */\n const DraggableItem = (props: ItemProps<T>) => {\n const {item, index, id, columns, onRemove, removable, disabled, readOnly, classes, config} = props;\n const {attributes, listeners, setNodeRef, transform, transition, isDragging, setActivatorNodeRef} = useSortable(\n {id},\n );\n\n const cellContext: CollectionCellContext<T> = {\n removable,\n draggable: true,\n disabled,\n readOnly,\n onRemove,\n };\n\n const dragHandleProps = {setActivatorNodeRef, listeners, attributes};\n\n // Use renderDraggableContent if provided (integrates drag handle into content)\n if (config.renderDraggableContent) {\n return (\n <Box\n ref={setNodeRef}\n data-testid={`item-${id}`}\n className={classes[config.containerSelector]}\n style={\n transform\n ? {\n transform: CSS.Transform.toString(transform),\n transition,\n }\n : undefined\n }\n data-isdragging={isDragging}\n >\n {config.renderDraggableContent(item, index, columns, cellContext, classes, dragHandleProps)}\n </Box>\n );\n }\n\n // Default behavior: inline drag handle + content + remove button (used by horizontal layout)\n return (\n <Box\n ref={setNodeRef}\n data-testid={`item-${id}`}\n className={classes[config.containerSelector]}\n style={\n transform\n ? {\n transform: CSS.Transform.toString(transform),\n transition,\n }\n : undefined\n }\n data-isdragging={isDragging}\n >\n <DragHandle setActivatorNodeRef={setActivatorNodeRef} listeners={listeners} attributes={attributes} />\n {config.renderContent(item, index, columns, cellContext, classes)}\n {config.inlineControls && <RemoveButton removable={removable} onRemove={onRemove} />}\n </Box>\n );\n };\n\n /**\n * Static (non-draggable) item/row renderer\n */\n const StaticItem = (props: ItemProps<T>) => {\n const {item, index, id, columns, onRemove, removable, disabled, readOnly, classes, config} = props;\n\n const cellContext: CollectionCellContext<T> = {\n removable,\n draggable: false,\n disabled,\n readOnly,\n onRemove,\n };\n\n return (\n <Box data-testid={`item-${id}`} className={classes[config.containerSelector]}>\n {config.renderContent(item, index, columns, cellContext, classes)}\n {config.inlineControls && <RemoveButton removable={removable} onRemove={onRemove} />}\n </Box>\n );\n };\n\n /**\n * Disabled item/row renderer (no drag, no remove)\n */\n const DisabledItem = (props: ItemProps<T>) => {\n const {item, index, id, columns, disabled, readOnly, classes, config} = props;\n\n const cellContext: CollectionCellContext<T> = {\n removable: false,\n draggable: false,\n disabled,\n readOnly,\n };\n\n return (\n <Box data-testid={`item-${id}`} className={classes[config.containerSelector]}>\n {config.renderContent(item, index, columns, cellContext, classes)}\n </Box>\n );\n };\n\n return {DraggableItem, StaticItem, DisabledItem};\n};\n\n/**\n * Maps items to their appropriate renderer components based on state.\n */\nexport const mapItemsToComponents = <T,>(\n items: T[],\n renderers: ReturnType<typeof createItemRenderers<T>>,\n config: ItemRendererConfig<T>,\n classes: LayoutClasses,\n options: {\n getItemId?: (item: T, index: number) => string;\n onRemove?: (index: number) => void;\n removable?: boolean;\n draggable?: boolean;\n disabled?: boolean;\n readOnly?: boolean;\n columns: Array<CollectionColumnDef<T>>;\n },\n): ReactNode[] => {\n const {getItemId, onRemove, removable, draggable, disabled, readOnly, columns} = options;\n const {DraggableItem, StaticItem, DisabledItem} = renderers;\n\n return items.map((item, index) => {\n const id = getItemId?.(item, index) ?? String(index);\n const itemProps: ItemProps<T> = {\n item,\n index,\n id,\n columns,\n onRemove: onRemove ? () => onRemove(index) : undefined,\n removable,\n draggable,\n disabled,\n readOnly,\n classes,\n config,\n };\n\n if (disabled) {\n return <DisabledItem key={id} {...itemProps} />;\n }\n\n if (draggable) {\n return <DraggableItem key={id} {...itemProps} />;\n }\n\n return <StaticItem key={id} {...itemProps} />;\n });\n};\n"],"names":["useSortable","CSS","Box","DragHandle","RemoveButton","createItemRenderers","DraggableItem","props","item","index","id","columns","onRemove","removable","disabled","readOnly","classes","config","attributes","listeners","setNodeRef","transform","transition","isDragging","setActivatorNodeRef","cellContext","draggable","dragHandleProps","renderDraggableContent","ref","data-testid","className","containerSelector","style","Transform","toString","undefined","data-isdragging","renderContent","inlineControls","StaticItem","DisabledItem","mapItemsToComponents","items","renderers","options","getItemId","map","String","itemProps"],"mappings":";AAAA,SAAQA,WAAW,QAAO,oBAAoB;AAC9C,SAAQC,GAAG,QAAO,qBAAqB;AACvC,SAAQC,GAAG,QAAO,gBAAgB;AAGlC,SAAQC,UAAU,QAAO,kBAAkB;AAC3C,SAAQC,YAAY,QAAO,oBAAoB;AAyE/C;;;;CAIC,GACD,O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