@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Collection/Collection.tsx"],"sourcesContent":["import {IconPlus} from '@coveord/plasma-react-icons';\nimport {DndContext, DragEndEvent, KeyboardSensor, PointerSensor, useSensor, useSensors} from '@dnd-kit/core';\nimport {restrictToParentElement, restrictToVerticalAxis} from '@dnd-kit/modifiers';\nimport {SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy} from '@dnd-kit/sortable';\nimport {\n __InputWrapperProps,\n Box,\n BoxProps,\n Factory,\n Input,\n MantineSpacing,\n Stack,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport {useDidUpdate} from '@mantine/hooks';\nimport {ForwardedRef, ReactNode} from 'react';\n\nimport {CustomComponentThemeExtend, identity} from '../../utils/createFactoryComponent.js';\nimport {Button} from '../Button/Button.js';\nimport classes from './Collection.module.css';\nimport {CollectionProvider} from './CollectionContext.js';\nimport {CollectionItem} from './CollectionItem.js';\n\nexport interface CollectionProps<T> extends __InputWrapperProps, BoxProps, StylesApiProps<CollectionFactory> {\n /**\n * The default value each new item should have\n */\n newItem: T | (() => T);\n /**\n * A render function called for each item passed in the `value` prop.\n *\n * @param item The current item's value\n * @param index The current item's index\n */\n children: (item: T, index: number) => ReactNode;\n /**\n * The list of items to display inside the collection\n *\n * @default []\n */\n value?: T[];\n /**\n * Defines how each item is uniquely identified. It is highly recommended that you specify this prop to an ID that makes sense.\n *\n * This method is required when using this component with ReactHookForm.\n *\n * @see {@link https://react-hook-form.com/api/usefieldarray/} for using a collection with ReactHookForm.\n *\n * @param originalItem The original item\n * @param itemIndex The index of the original item\n */\n getItemId?: (originalItem: T, itemIndex: number) => string;\n /**\n * Unused, has no effect\n */\n onFocus?: () => void;\n /**\n * Function called whenever the value needs to be updated\n *\n * @param value The whole list of items after the change\n */\n onChange?: (value: T[]) => void;\n /**\n * Function called after an item is removed from the collection using the remove button\n *\n * @param itemIndex The index of the item that was removed\n */\n onRemoveItem?: (itemIndex: number) => void;\n /**\n * Function that gets called whenever a collection item needs to be reordered\n *\n * @param payload The origin and destination index of the item to reorder\n */\n onReorderItem?: (payload: {from: number; to: number}) => void;\n /**\n * Function that gets called when a new item needs to be added to the collection\n *\n * @param value The value of the item to insert\n * @param index The index of the new item to insert\n */\n onInsertItem?: (value: T, index: number) => void;\n /**\n * Whether the collection should have drag and drop behavior enabled\n *\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether the collection is disabled, or in other words in read only mode\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Whether the collection is readOnly. If true, the collection will not allow adding or removing items\n *\n * @default false\n */\n readOnly?: boolean;\n /**\n * Function that determines if the add item button should be enabled given the current items of the collection.\n * The button is always enabled if this props remains undefined\n *\n * @param values The current items of the collection\n */\n allowAdd?: boolean | ((values: T[]) => boolean);\n /**\n * The label of the add item button\n *\n * @default \"Add item\"\n */\n addLabel?: string;\n /**\n * The tooltip text displayed when hovering over the disabled add item button\n *\n * @default 'There is already an empty item'\n */\n addDisabledTooltip?: string;\n /**\n * The gap between the colleciton items\n *\n * @default 'xs'\n */\n gap?: MantineSpacing;\n /**\n * Whether the collection is required. When required is true, the collection will hide the remove button if there is only one item\n *\n * @default false\n */\n required?: boolean;\n}\n\nexport type CollectionStylesNames = 'root' | 'item' | 'items' | 'itemDragging' | 'dragHandle';\n\nexport type CollectionFactory = Factory<{\n props: CollectionProps<unknown>;\n ref: HTMLDivElement;\n stylesNames: CollectionStylesNames;\n}>;\n\nconst defaultProps: Partial<CollectionProps<unknown>> = {\n draggable: false,\n addLabel: 'Add item',\n addDisabledTooltip: 'There is already an empty item',\n disabled: false,\n readOnly: false,\n gap: 'md',\n required: false,\n getItemId: ({id}: any) => id,\n};\n\nexport const Collection = <T,>(props: CollectionProps<T> & {ref?: ForwardedRef<HTMLDivElement>}) => {\n const {\n value,\n onChange,\n onRemoveItem,\n onReorderItem,\n onInsertItem,\n disabled,\n readOnly,\n draggable,\n children,\n gap,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\n allowAdd,\n label,\n labelProps,\n withAsterisk,\n description,\n descriptionProps,\n error,\n errorProps,\n getItemId,\n ref,\n\n // Style props\n style,\n className,\n classNames,\n styles,\n unstyled,\n ...others\n } = useProps('Collection', defaultProps as CollectionProps<T>, props);\n\n const getStyles = useStyles<CollectionFactory>({\n name: 'Collection',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n });\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n }),\n );\n\n const canEdit = !disabled && !readOnly;\n const hasOnlyOneItem = value.length === 1;\n\n /**\n * Enforcing onChange when the value is modified will make sure the errors are carried through.\n */\n useDidUpdate(() => {\n onChange?.(value);\n }, [JSON.stringify(value)]);\n\n const isRequired = typeof withAsterisk === 'boolean' ? withAsterisk : required;\n const _label = label ? (\n <Input.Label required={isRequired} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n const _error = error ? (\n <Input.Error {...errorProps} pt=\"xs\">\n {error}\n </Input.Error>\n ) : null;\n const _header =\n _label || _description ? (\n <Stack gap=\"xxs\" pb=\"xs\">\n {_label}\n {_description}\n </Stack>\n ) : null;\n\n const standardizedItems = value.map((item, index) => ({id: getItemId?.(item, index) ?? String(index), data: item}));\n\n const items = standardizedItems.map((item, index) => (\n <CollectionItem\n key={item.id}\n id={item.id}\n disabled={!canEdit}\n draggable={draggable}\n onRemove={() => onRemoveItem?.(index)}\n removable={!(isRequired && hasOnlyOneItem)}\n >\n {children(item.data, index)}\n </CollectionItem>\n ));\n\n const addAllowed = typeof allowAdd === 'boolean' ? allowAdd : (allowAdd?.(value) ?? true);\n\n const _addButton = canEdit ? (\n <Box className={classes.addButtonContainer}>\n <Button.Quaternary\n leftSection={<IconPlus size={16} />}\n onClick={() => {\n const newItemValue = typeof newItem === 'function' ? (newItem as () => T)() : newItem;\n onInsertItem(newItemValue, value?.length ?? 0);\n }}\n disabled={!addAllowed}\n disabledTooltip={addDisabledTooltip}\n >\n {addLabel}\n </Button.Quaternary>\n </Box>\n ) : null;\n\n const getIndex = (id: string) => standardizedItems.findIndex((item) => item.id === id);\n\n const handleDragEnd = ({over, active}: DragEndEvent): void => {\n if (over) {\n const activeIndex = getIndex(String(active.id));\n const overIndex = getIndex(String(over.id));\n if (activeIndex !== overIndex) {\n onReorderItem?.({from: activeIndex, to: overIndex});\n }\n }\n };\n\n return (\n <CollectionProvider value={{getStyles}}>\n <DndContext\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToVerticalAxis, restrictToParentElement]}\n >\n <SortableContext items={standardizedItems} strategy={verticalListSortingStrategy}>\n <Box ref={ref} {...others} {...getStyles('root')}>\n {_header}\n <Stack gap={gap} {...getStyles('items')}>\n {items}\n {_addButton}\n </Stack>\n {_error}\n </Box>\n </SortableContext>\n </DndContext>\n </CollectionProvider>\n );\n};\n\nCollection.displayName = 'Collection';\n\nCollection.extend = identity as CustomComponentThemeExtend<CollectionFactory>;\n"],"names":["IconPlus","DndContext","KeyboardSensor","PointerSensor","useSensor","useSensors","restrictToParentElement","restrictToVerticalAxis","SortableContext","sortableKeyboardCoordinates","verticalListSortingStrategy","Box","Input","Stack","useProps","useStyles","useDidUpdate","identity","Button","classes","CollectionProvider","CollectionItem","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","readOnly","gap","required","getItemId","id","Collection","props","value","onChange","onRemoveItem","onReorderItem","onInsertItem","children","newItem","allowAdd","label","labelProps","withAsterisk","description","descriptionProps","error","errorProps","ref","style","className","classNames","styles","unstyled","others","getStyles","name","sensors","coordinateGetter","canEdit","hasOnlyOneItem","length","JSON","stringify","isRequired","_label","Label","_description","Description","_error","Error","pt","_header","pb","standardizedItems","map","item","index","String","data","items","onRemove","removable","addAllowed","_addButton","addButtonContainer","Quaternary","leftSection","size","onClick","newItemValue","disabledTooltip","getIndex","findIndex","handleDragEnd","over","active","activeIndex","overIndex","from","to","onDragEnd","modifiers","strategy","displayName","extend"],"mappings":";AAAA,SAAQA,QAAQ,QAAO,8BAA8B;AACrD,SAAQC,UAAU,EAAgBC,cAAc,EAAEC,aAAa,EAAEC,SAAS,EAAEC,UAAU,QAAO,gBAAgB;AAC7G,SAAQC,uBAAuB,EAAEC,sBAAsB,QAAO,qBAAqB;AACnF,SAAQC,eAAe,EAAEC,2BAA2B,EAAEC,2BAA2B,QAAO,oBAAoB;AAC5G,SAEIC,GAAG,EAGHC,KAAK,EAELC,KAAK,EAELC,QAAQ,EACRC,SAAS,QACN,gBAAgB;AACvB,SAAQC,YAAY,QAAO,iBAAiB;AAG5C,SAAoCC,QAAQ,QAAO,wCAAwC;AAC3F,SAAQC,MAAM,QAAO,sBAAsB;AAC3C,OAAOC,aAAa,0BAA0B;AAC9C,SAAQC,kBAAkB,QAAO,yBAAyB;AAC1D,SAAQC,cAAc,QAAO,sBAAsB;AAuHnD,MAAMC,eAAkD;IACpDC,WAAW;IACXC,UAAU;IACVC,oBAAoB;IACpBC,UAAU;IACVC,UAAU;IACVC,KAAK;IACLC,UAAU;IACVC,WAAW,CAAC,EAACC,EAAE,EAAM,GAAKA;AAC9B;AAEA,OAAO,MAAMC,aAAa,CAAKC;IAC3B,MAAM,EACFC,KAAK,EACLC,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,YAAY,EACZZ,QAAQ,EACRC,QAAQ,EACRJ,SAAS,EACTgB,QAAQ,EACRX,GAAG,EACHC,QAAQ,EACRW,OAAO,EACPhB,QAAQ,EACRC,kBAAkB,EAClBgB,QAAQ,EACRC,KAAK,EACLC,UAAU,EACVC,YAAY,EACZC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BAAM,GAAG4B,UAAU,QAAQ;;gCAClCyB;gCACAI;;;wBAEJf;;;;;;AAMzB,EAAE;AAEFtC,WAAWyE,WAAW,GAAG;AAEzBzE,WAAW0E,MAAM,GAAGzF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Collection/Collection.tsx"],"sourcesContent":["import {DndContext, DragEndEvent, KeyboardSensor, PointerSensor, useSensor, useSensors} from '@dnd-kit/core';\nimport {restrictToParentElement, restrictToVerticalAxis} from '@dnd-kit/modifiers';\nimport {SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy} from '@dnd-kit/sortable';\nimport {\n __InputWrapperProps,\n Box,\n BoxProps,\n Factory,\n Input,\n MantineSpacing,\n Stack,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport {useDidUpdate} from '@mantine/hooks';\nimport {ForwardedRef, ReactNode} from 'react';\n\nimport {CustomComponentThemeExtend, identity} from '../../utils/createFactoryComponent.js';\nimport classes from './Collection.module.css';\nimport {CollectionAddButton} from './CollectionAddButton.js';\nimport {CollectionColumnDef} from './CollectionColumn.types.js';\nimport {CollectionProvider} from './CollectionContext.js';\nimport {CollectionItem} from './CollectionItem.js';\nimport {CollectionLayout} from './layouts/CollectionLayout.types.js';\nimport {CollectionLayouts} from './layouts/CollectionLayouts.js';\n\n/**\n * Base props shared by both column-based and children-based patterns\n */\ninterface BaseCollectionProps<T> extends __InputWrapperProps, BoxProps, StylesApiProps<CollectionFactory> {\n /**\n * The default value each new item should have\n */\n newItem: T | (() => T);\n /**\n * The list of items to display inside the collection\n *\n * @default []\n */\n value?: T[];\n /**\n * Defines how each item is uniquely identified. It is highly recommended that you specify this prop to an ID that makes sense.\n *\n * This method is required when using this component with ReactHookForm.\n *\n * @see {@link https://react-hook-form.com/api/usefieldarray/} for using a collection with ReactHookForm.\n *\n * @param originalItem The original item\n * @param itemIndex The index of the original item\n */\n getItemId?: (originalItem: T, itemIndex: number) => string;\n /**\n * Unused, has no effect\n */\n onFocus?: () => void;\n /**\n * Function called whenever the value needs to be updated\n *\n * @param value The whole list of items after the change\n */\n onChange?: (value: T[]) => void;\n /**\n * Function called after an item is removed from the collection using the remove button\n *\n * @param itemIndex The index of the item that was removed\n */\n onRemoveItem?: (itemIndex: number) => void;\n /**\n * Function that gets called whenever a collection item needs to be reordered\n *\n * @param payload The origin and destination index of the item to reorder\n */\n onReorderItem?: (payload: {from: number; to: number}) => void;\n /**\n * Function that gets called when a new item needs to be added to the collection\n *\n * @param value The value of the item to insert\n * @param index The index of the new item to insert\n */\n onInsertItem?: (value: T, index: number) => void;\n /**\n * Whether the collection should have drag and drop behavior enabled\n *\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether the collection is disabled, or in other words in read only mode\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Whether the collection is readOnly. If true, the collection will not allow adding or removing items\n *\n * @default false\n */\n readOnly?: boolean;\n /**\n * Function that determines if the add item button should be enabled given the current items of the collection.\n * The button is always enabled if this props remains undefined\n *\n * @param values The current items of the collection\n */\n allowAdd?: boolean | ((values: T[]) => boolean);\n /**\n * The label of the add item button\n *\n * @default \"Add item\"\n */\n addLabel?: ReactNode;\n /**\n * The tooltip text displayed when hovering over the disabled add item button\n *\n * @default 'There is already an empty item'\n */\n addDisabledTooltip?: string;\n /**\n * The gap between the collection items\n *\n * @default 'md'\n */\n gap?: MantineSpacing;\n /**\n * Whether the collection is required. When required is true, the collection will hide the remove button if there is only one item\n *\n * @default false\n */\n required?: boolean;\n}\n\n/**\n * Collection with column-based layout\n */\ninterface CollectionWithColumns<T> extends BaseCollectionProps<T> {\n /**\n * Column definitions for the collection\n */\n columns: Array<CollectionColumnDef<T>>;\n\n /**\n * Layout component to use for rendering\n * @default CollectionLayouts.Horizontal\n */\n layout?: CollectionLayout;\n\n /**\n * Must not have children when using columns\n */\n children?: never;\n}\n\n/**\n * Collection with legacy children render prop\n */\ninterface CollectionWithChildren<T> extends BaseCollectionProps<T> {\n /**\n * A render function called for each item passed in the `value` prop.\n *\n * @param item The current item's value\n * @param index The current item's index\n */\n children: (item: T, index: number) => ReactNode;\n\n /**\n * Must not have columns when using children\n */\n columns?: never;\n\n /**\n * Must not have layout when using children\n */\n layout?: never;\n}\n\n/**\n * Collection props - either columns OR children, never both\n */\nexport type CollectionProps<T> = CollectionWithColumns<T> | CollectionWithChildren<T>;\n\nexport type CollectionStylesNames = 'root' | 'item' | 'items' | 'itemDragging' | 'dragHandle' | 'removeButton';\n\nexport type CollectionFactory = Factory<{\n props: CollectionProps<unknown>;\n ref: HTMLDivElement;\n stylesNames: CollectionStylesNames;\n}>;\n\nconst defaultProps: Partial<CollectionProps<unknown>> = {\n draggable: false,\n addLabel: 'Add item',\n addDisabledTooltip: 'There is already an empty item',\n disabled: false,\n readOnly: false,\n gap: 'md',\n required: false,\n getItemId: ({id}: any) => id,\n};\n\nexport const Collection = <T,>(props: CollectionProps<T> & {ref?: ForwardedRef<HTMLDivElement>}) => {\n const {\n value,\n onChange,\n onRemoveItem,\n onReorderItem,\n onInsertItem,\n disabled,\n readOnly,\n draggable,\n children,\n columns,\n layout,\n gap,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\n allowAdd,\n label,\n labelProps,\n withAsterisk,\n description,\n descriptionProps,\n error,\n errorProps,\n getItemId,\n ref,\n\n // Style props\n style,\n className,\n classNames,\n styles,\n unstyled,\n ...others\n } = useProps('Collection', defaultProps as CollectionProps<T>, props);\n\n // Runtime validation: ensure columns and children are mutually exclusive\n if (columns && children) {\n throw new Error('Collection: Cannot use both \"columns\" and \"children\" props.');\n }\n\n if (layout && !columns) {\n throw new Error('Collection: \"layout\" prop can only be used with \"columns\" prop.');\n }\n\n const getStyles = useStyles<CollectionFactory>({\n name: 'Collection',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n });\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n }),\n );\n\n const canEdit = !disabled && !readOnly;\n const items = value ?? [];\n const hasOnlyOneItem = items.length === 1;\n\n /**\n * Enforcing onChange when the value is modified will make sure the errors are carried through.\n */\n useDidUpdate(() => {\n onChange?.(items);\n }, [JSON.stringify(items)]);\n\n const isRequired = typeof withAsterisk === 'boolean' ? withAsterisk : required;\n const _label = label ? (\n <Input.Label required={isRequired} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n const _error = error ? (\n <Input.Error {...errorProps} pt=\"xs\">\n {error}\n </Input.Error>\n ) : null;\n const _header =\n _label || _description ? (\n <Stack gap=\"xxs\" pb=\"xs\">\n {_label}\n {_description}\n </Stack>\n ) : null;\n\n const standardizedItems = items.map((item, index) => ({id: getItemId?.(item, index) ?? String(index), data: item}));\n\n const getIndex = (id: string) => standardizedItems.findIndex((item) => item.id === id);\n\n const handleDragEnd = ({over, active}: DragEndEvent): void => {\n if (over) {\n const activeIndex = getIndex(String(active.id));\n const overIndex = getIndex(String(over.id));\n if (activeIndex !== overIndex) {\n onReorderItem?.({from: activeIndex, to: overIndex});\n }\n }\n };\n\n const addAllowed = typeof allowAdd === 'boolean' ? allowAdd : (allowAdd?.(items) ?? true);\n\n const handleAdd = () => {\n const newItemValue = typeof newItem === 'function' ? (newItem as () => T)() : newItem;\n onInsertItem?.(newItemValue, items?.length ?? 0);\n };\n\n const _addButton = canEdit ? (\n <CollectionAddButton\n addLabel={addLabel}\n addDisabledTooltip={addDisabledTooltip}\n addAllowed={addAllowed}\n onAdd={handleAdd}\n />\n ) : null;\n\n // Column-based layout pattern\n if (columns) {\n const Layout = layout || CollectionLayouts.Horizontal;\n\n return (\n <CollectionProvider value={{getStyles, columns: columns as Array<CollectionColumnDef<unknown>>}}>\n <DndContext\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToVerticalAxis, restrictToParentElement]}\n >\n <SortableContext items={standardizedItems} strategy={verticalListSortingStrategy}>\n <Box ref={ref} {...others} {...getStyles('root')}>\n {_header}\n <Layout>\n <Layout.Header\n draggable={draggable && canEdit}\n removable={canEdit && !(isRequired && hasOnlyOneItem)}\n />\n <Layout.Body\n items={items}\n onRemove={canEdit ? onRemoveItem : undefined}\n removable={canEdit && !(isRequired && hasOnlyOneItem)}\n draggable={draggable && canEdit}\n disabled={disabled}\n readOnly={readOnly}\n getItemId={getItemId}\n gap={gap}\n />\n </Layout>\n {_addButton}\n {_error}\n </Box>\n </SortableContext>\n </DndContext>\n </CollectionProvider>\n );\n }\n\n // Legacy children render prop pattern\n const renderedItems = standardizedItems.map((item, index) => (\n <CollectionItem\n key={item.id}\n id={item.id}\n disabled={!canEdit}\n draggable={draggable}\n onRemove={() => onRemoveItem?.(index)}\n removable={!(isRequired && hasOnlyOneItem)}\n >\n {children(item.data, index)}\n </CollectionItem>\n ));\n\n return (\n <CollectionProvider value={{getStyles}}>\n <DndContext\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToVerticalAxis, restrictToParentElement]}\n >\n <SortableContext items={standardizedItems} strategy={verticalListSortingStrategy}>\n <Box ref={ref} {...others} {...getStyles('root')}>\n {_header}\n <Stack gap={gap} {...getStyles('items')}>\n {renderedItems}\n {_addButton}\n </Stack>\n {_error}\n </Box>\n </SortableContext>\n </DndContext>\n </CollectionProvider>\n );\n};\n\nCollection.displayName = 'Collection';\n\nCollection.extend = identity as CustomComponentThemeExtend<CollectionFactory>;\n\nCollection.Layouts = CollectionLayouts;\n"],"names":["DndContext","KeyboardSensor","PointerSensor","useSensor","useSensors","restrictToParentElement","restrictToVerticalAxis","SortableContext","sortableKeyboardCoordinates","verticalListSortingStrategy","Box","Input","Stack","useProps","useStyles","useDidUpdate","identity","classes","CollectionAddButton","CollectionProvider","CollectionItem","CollectionLayouts","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","readOnly","gap","required","getItemId","id","Collection","props","value","onChange","onRemoveItem","onReorderItem","onInsertItem","children","columns","layout","newItem","allowAdd","label","labelProps","withAsterisk","description","descriptionProps","error","errorProps","ref","style","className","classNames","styles","unstyled","others","Error","getStyles","name","sensors","coordinateGetter","canEdit","items","hasOnlyOneItem","length","JSON","stringify","isRequired","_label","Label","_description","Description","_error","pt","_header","pb","standardizedItems","map","item","index","String","data","getIndex","findIndex","handleDragEnd","over","active","activeIndex","overIndex","from","to","addAllowed","handleAdd","newItemValue","_addButton","onAdd","Layout","Horizontal","onDragEnd","modifiers","strategy","Header","removable","Body","onRemove","undefined","renderedItems","displayName","extend","Layouts"],"mappings":";AAAA,SAAQA,UAAU,EAAgBC,cAAc,EAAEC,aAAa,EAAEC,SAAS,EAAEC,UAAU,QAAO,gBAAgB;AAC7G,SAAQC,uBAAuB,EAAEC,sBAAsB,QAAO,qBAAqB;AACnF,SAAQC,eAAe,EAAEC,2BAA2B,EAAEC,2BAA2B,QAAO,oBAAoB;AAC5G,SAEIC,GAAG,EAGHC,KAAK,EAELC,KAAK,EAELC,QAAQ,EACRC,SAAS,QACN,gBAAgB;AACvB,SAAQC,YAAY,QAAO,iBAAiB;AAG5C,SAAoCC,QAAQ,QAAO,wCAAwC;AAC3F,OAAOC,aAAa,0BAA0B;AAC9C,SAAQC,mBAAmB,QAAO,2BAA2B;AAE7D,SAAQC,kBAAkB,QAAO,yBAAyB;AAC1D,SAAQC,cAAc,QAAO,sBAAsB;AAEnD,SAAQC,iBAAiB,QAAO,iCAAiC;AAoKjE,MAAMC,eAAkD;IACpDC,WAAW;IACXC,UAAU;IACVC,oBAAoB;IACpBC,UAAU;IACVC,UAAU;IACVC,KAAK;IACLC,UAAU;IACVC,WAAW,CAAC,EAACC,EAAE,EAAM,GAAKA;AAC9B;AAEA,OAAO,MAAMC,aAAa,CAAKC;IAC3B,MAAM,EACFC,KAAK,EACLC,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,YAAY,EACZZ,QAAQ,EACRC,QAAQ,EACRJ,SAAS,EACTgB,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNb,GAAG,EACH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
+
cursor: grab;
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
|
|
27
|
+
&:active {
|
|
28
|
+
cursor: grabbing;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.removeButton {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
24
35
|
}
|
|
25
36
|
|
|
26
37
|
.addButtonContainer {
|
|
27
38
|
align-self: flex-start;
|
|
39
|
+
width: min-content;
|
|
28
40
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface CollectionAddButtonProps {
|
|
3
|
+
/**
|
|
4
|
+
* The label of the add item button
|
|
5
|
+
*
|
|
6
|
+
* @default "Add item"
|
|
7
|
+
*/
|
|
8
|
+
addLabel?: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* The tooltip text displayed when hovering over the disabled add item button
|
|
11
|
+
*
|
|
12
|
+
* @default 'There is already an empty item'
|
|
13
|
+
*/
|
|
14
|
+
addDisabledTooltip?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the add button is allowed/enabled
|
|
17
|
+
*/
|
|
18
|
+
addAllowed: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Callback when the add button is clicked
|
|
21
|
+
*/
|
|
22
|
+
onAdd: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare const CollectionAddButton: ({ addLabel, addDisabledTooltip, addAllowed, onAdd }: CollectionAddButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=CollectionAddButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollectionAddButton.d.ts","sourceRoot":"","sources":["../../../../src/components/Collection/CollectionAddButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAKhC,MAAM,WAAW,wBAAwB;IACrC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,mBAAmB,GAAI,qDAAmD,wBAAwB,4CAW9G,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { IconPlus } from '@coveord/plasma-react-icons';
|
|
3
|
+
import { Box } from '@mantine/core';
|
|
4
|
+
import { Button } from '../Button/Button.js';
|
|
5
|
+
import classes from './Collection.module.css';
|
|
6
|
+
export const CollectionAddButton = ({ addLabel, addDisabledTooltip, addAllowed, onAdd })=>/*#__PURE__*/ _jsx(Box, {
|
|
7
|
+
className: classes.addButtonContainer,
|
|
8
|
+
children: /*#__PURE__*/ _jsx(Button.Quaternary, {
|
|
9
|
+
leftSection: /*#__PURE__*/ _jsx(IconPlus, {
|
|
10
|
+
size: 16
|
|
11
|
+
}),
|
|
12
|
+
onClick: onAdd,
|
|
13
|
+
disabled: !addAllowed,
|
|
14
|
+
disabledTooltip: addDisabledTooltip,
|
|
15
|
+
children: addLabel
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=CollectionAddButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Collection/CollectionAddButton.tsx"],"sourcesContent":["import {IconPlus} from '@coveord/plasma-react-icons';\nimport {Box} from '@mantine/core';\nimport {ReactNode} from 'react';\n\nimport {Button} from '../Button/Button.js';\nimport classes from './Collection.module.css';\n\nexport interface CollectionAddButtonProps {\n /**\n * The label of the add item button\n *\n * @default \"Add item\"\n */\n addLabel?: ReactNode;\n /**\n * The tooltip text displayed when hovering over the disabled add item button\n *\n * @default 'There is already an empty item'\n */\n addDisabledTooltip?: string;\n /**\n * Whether the add button is allowed/enabled\n */\n addAllowed: boolean;\n /**\n * Callback when the add button is clicked\n */\n onAdd: () => void;\n}\n\nexport const CollectionAddButton = ({addLabel, addDisabledTooltip, addAllowed, onAdd}: CollectionAddButtonProps) => (\n <Box className={classes.addButtonContainer}>\n <Button.Quaternary\n leftSection={<IconPlus size={16} />}\n onClick={onAdd}\n disabled={!addAllowed}\n disabledTooltip={addDisabledTooltip}\n >\n {addLabel}\n </Button.Quaternary>\n </Box>\n);\n"],"names":["IconPlus","Box","Button","classes","CollectionAddButton","addLabel","addDisabledTooltip","addAllowed","onAdd","className","addButtonContainer","Quaternary","leftSection","size","onClick","disabled","disabledTooltip"],"mappings":";AAAA,SAAQA,QAAQ,QAAO,8BAA8B;AACrD,SAAQC,GAAG,QAAO,gBAAgB;AAGlC,SAAQC,MAAM,QAAO,sBAAsB;AAC3C,OAAOC,aAAa,0BAA0B;AAyB9C,OAAO,MAAMC,sBAAsB,CAAC,EAACC,QAAQ,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,KAAK,EAA2B,iBAC3G,KAACP;QAAIQ,WAAWN,QAAQO,kBAAkB;kBACtC,cAAA,KAACR,OAAOS,UAAU;YACdC,2BAAa,KAACZ;gBAASa,MAAM;;YAC7BC,SAASN;YACTO,UAAU,CAACR;YACXS,iBAAiBV;sBAEhBD;;OAGX"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Context provided to header render functions
|
|
4
|
+
*/
|
|
5
|
+
export interface CollectionHeaderContext {
|
|
6
|
+
/** Column index */
|
|
7
|
+
index: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Context provided to cell render functions.
|
|
11
|
+
*
|
|
12
|
+
* Use `context.disabled` and `context.readOnly` to pass the collection's state to your form inputs:
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* cell: (item, index, context) => (
|
|
16
|
+
* <TextInput
|
|
17
|
+
* {...form.getInputProps(`items.${index}.name`)}
|
|
18
|
+
* disabled={context.disabled}
|
|
19
|
+
* readOnly={context.readOnly}
|
|
20
|
+
* />
|
|
21
|
+
* )
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export interface CollectionCellContext<T = unknown> {
|
|
25
|
+
/** Whether the item can be removed */
|
|
26
|
+
removable?: boolean;
|
|
27
|
+
/** Whether the collection is draggable */
|
|
28
|
+
draggable?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the collection is disabled.
|
|
31
|
+
* Pass this to your form inputs: `disabled={context.disabled}`
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the collection is read-only.
|
|
36
|
+
* Pass this to your form inputs: `readOnly={context.readOnly}`
|
|
37
|
+
*/
|
|
38
|
+
readOnly?: boolean;
|
|
39
|
+
/** Callback to remove the item */
|
|
40
|
+
onRemove?: () => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Column definition for Collection component
|
|
44
|
+
*/
|
|
45
|
+
export interface CollectionColumnDef<T = unknown> {
|
|
46
|
+
/**
|
|
47
|
+
* Column header content
|
|
48
|
+
* Can be a ReactNode or a function that receives header context
|
|
49
|
+
*/
|
|
50
|
+
header?: ReactNode | ((context: CollectionHeaderContext) => ReactNode);
|
|
51
|
+
/**
|
|
52
|
+
* Cell render function
|
|
53
|
+
* @param item The current item's data
|
|
54
|
+
* @param index The current item's index
|
|
55
|
+
* @param context Additional context for rendering
|
|
56
|
+
*/
|
|
57
|
+
cell: (item: T, index: number, context: CollectionCellContext<T>) => ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* Minimum column size
|
|
60
|
+
*/
|
|
61
|
+
minSize?: string | number;
|
|
62
|
+
/**
|
|
63
|
+
* Maximum column size
|
|
64
|
+
*/
|
|
65
|
+
maxSize?: string | number;
|
|
66
|
+
/**
|
|
67
|
+
* Unique identifier for the column
|
|
68
|
+
* Auto-generated if not provided
|
|
69
|
+
*/
|
|
70
|
+
id?: string;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=CollectionColumn.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollectionColumn.types.d.ts","sourceRoot":"","sources":["../../../../src/components/Collection/CollectionColumn.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,mBAAmB;IACnB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,OAAO;IAC9C,sCAAsC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,GAAG,OAAO;IAC5C;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,OAAO,EAAE,uBAAuB,KAAK,SAAS,CAAC,CAAC;IAEvE;;;;;OAKG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IAE/E;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1B;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Collection/CollectionColumn.types.ts"],"sourcesContent":["import {ReactNode} from 'react';\n\n/**\n * Context provided to header render functions\n */\nexport interface CollectionHeaderContext {\n /** Column index */\n index: number;\n}\n\n/**\n * Context provided to cell render functions.\n *\n * Use `context.disabled` and `context.readOnly` to pass the collection's state to your form inputs:\n * @example\n * ```tsx\n * cell: (item, index, context) => (\n * <TextInput\n * {...form.getInputProps(`items.${index}.name`)}\n * disabled={context.disabled}\n * readOnly={context.readOnly}\n * />\n * )\n * ```\n */\n// eslint-disable-next-line unused-imports/no-unused-vars\nexport interface CollectionCellContext<T = unknown> {\n /** Whether the item can be removed */\n removable?: boolean;\n /** Whether the collection is draggable */\n draggable?: boolean;\n /**\n * Whether the collection is disabled.\n * Pass this to your form inputs: `disabled={context.disabled}`\n */\n disabled?: boolean;\n /**\n * Whether the collection is read-only.\n * Pass this to your form inputs: `readOnly={context.readOnly}`\n */\n readOnly?: boolean;\n /** Callback to remove the item */\n onRemove?: () => void;\n}\n\n/**\n * Column definition for Collection component\n */\nexport interface CollectionColumnDef<T = unknown> {\n /**\n * Column header content\n * Can be a ReactNode or a function that receives header context\n */\n header?: ReactNode | ((context: CollectionHeaderContext) => ReactNode);\n\n /**\n * Cell render function\n * @param item The current item's data\n * @param index The current item's index\n * @param context Additional context for rendering\n */\n cell: (item: T, index: number, context: CollectionCellContext<T>) => ReactNode;\n\n /**\n * Minimum column size\n */\n minSize?: string | number;\n\n /**\n * Maximum column size\n */\n maxSize?: string | number;\n\n /**\n * Unique identifier for the column\n * Auto-generated if not provided\n */\n id?: string;\n}\n"],"names":[],"mappings":"AA6CA;;CAEC,GACD,WA8BC"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { type GetStylesApi } from '@mantine/core';
|
|
2
2
|
import type { CollectionFactory } from './Collection.js';
|
|
3
|
+
import type { CollectionColumnDef } from './CollectionColumn.types.js';
|
|
3
4
|
interface CollectionContextType {
|
|
4
5
|
getStyles: GetStylesApi<CollectionFactory>;
|
|
6
|
+
/**
|
|
7
|
+
* Column definitions for the collection (only present when using column-based layout)
|
|
8
|
+
*/
|
|
9
|
+
columns?: Array<CollectionColumnDef<unknown>>;
|
|
5
10
|
}
|
|
6
11
|
export declare const CollectionProvider: ({ children, value }: {
|
|
7
12
|
value: CollectionContextType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionContext.d.ts","sourceRoot":"","sources":["../../../../src/components/Collection/CollectionContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,YAAY,EAAC,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"CollectionContext.d.ts","sourceRoot":"","sources":["../../../../src/components/Collection/CollectionContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,YAAY,EAAC,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAErE,UAAU,qBAAqB;IAC3B,SAAS,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAC;IAC3C;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;CACjD;AAED,eAAO,MAAO,kBAAkB;;;+CAAE,oBAAoB,6BAErD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Collection/CollectionContext.ts"],"sourcesContent":["import {createSafeContext, type GetStylesApi} from '@mantine/core';\nimport type {CollectionFactory} from './Collection.js';\n\ninterface CollectionContextType {\n getStyles: GetStylesApi<CollectionFactory>;\n}\n\nexport const [CollectionProvider, useCollectionContext] = createSafeContext<CollectionContextType>(\n 'Collection component was not found in tree',\n);\n"],"names":["createSafeContext","CollectionProvider","useCollectionContext"],"mappings":"AAAA,SAAQA,iBAAiB,QAA0B,gBAAgB;
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Collection/CollectionContext.ts"],"sourcesContent":["import {createSafeContext, type GetStylesApi} from '@mantine/core';\nimport type {CollectionFactory} from './Collection.js';\nimport type {CollectionColumnDef} from './CollectionColumn.types.js';\n\ninterface CollectionContextType {\n getStyles: GetStylesApi<CollectionFactory>;\n /**\n * Column definitions for the collection (only present when using column-based layout)\n */\n columns?: Array<CollectionColumnDef<unknown>>;\n}\n\nexport const [CollectionProvider, useCollectionContext] = createSafeContext<CollectionContextType>(\n 'Collection component was not found in tree',\n);\n"],"names":["createSafeContext","CollectionProvider","useCollectionContext"],"mappings":"AAAA,SAAQA,iBAAiB,QAA0B,gBAAgB;AAYnE,OAAO,MAAM,CAACC,oBAAoBC,qBAAqB,GAAGF,kBACtD,8CACF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { GroupProps } from '@mantine/core';
|
|
2
|
-
import { FunctionComponent, PropsWithChildren } from 'react';
|
|
2
|
+
import { FunctionComponent, type MouseEventHandler, PropsWithChildren } from 'react';
|
|
3
3
|
interface CollectionItemProps extends CollectionItemSharedProps {
|
|
4
4
|
draggable?: boolean;
|
|
5
5
|
disabled: boolean;
|
|
6
6
|
}
|
|
7
7
|
interface CollectionItemSharedProps extends GroupProps {
|
|
8
8
|
id: string;
|
|
9
|
-
onRemove?:
|
|
9
|
+
onRemove?: MouseEventHandler<HTMLButtonElement>;
|
|
10
10
|
removable?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export declare const CollectionItem: FunctionComponent<PropsWithChildren<CollectionItemProps>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionItem.d.ts","sourceRoot":"","sources":["../../../../src/components/Collection/CollectionItem.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CollectionItem.d.ts","sourceRoot":"","sources":["../../../../src/components/Collection/CollectionItem.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAQ,UAAU,EAAW,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAMnF,UAAU,mBAAoB,SAAQ,yBAAyB;IAC3D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,yBAA0B,SAAQ,UAAU;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAyGD,eAAO,MAAM,cAAc,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAYpF,CAAC"}
|
|
@@ -1,36 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DragAndDropSize24Px, IconTrash } from '@coveord/plasma-react-icons';
|
|
3
2
|
import { useSortable } from '@dnd-kit/sortable';
|
|
4
3
|
import { CSS } from '@dnd-kit/utilities';
|
|
5
4
|
import { Group, useProps } from '@mantine/core';
|
|
6
|
-
import { ActionIcon } from '../ActionIcon/ActionIcon.js';
|
|
7
5
|
import { useCollectionContext } from './CollectionContext.js';
|
|
6
|
+
import { DragHandle } from './layouts/shared/DragHandle.js';
|
|
7
|
+
import { RemoveButton } from './layouts/shared/RemoveButton.js';
|
|
8
8
|
const defaultProps = {
|
|
9
9
|
removable: true,
|
|
10
10
|
gap: 'sm'
|
|
11
11
|
};
|
|
12
|
-
const RemoveButton = ({ onClick })=>/*#__PURE__*/ _jsx(ActionIcon.Quaternary, {
|
|
13
|
-
style: {
|
|
14
|
-
alignSelf: 'center'
|
|
15
|
-
},
|
|
16
|
-
onClick: onClick,
|
|
17
|
-
children: /*#__PURE__*/ _jsx(IconTrash, {
|
|
18
|
-
"aria-label": "Remove",
|
|
19
|
-
size: 16
|
|
20
|
-
})
|
|
21
|
-
});
|
|
22
|
-
const RemoveButtonPlaceholder = ()=>/*#__PURE__*/ _jsx("div", {
|
|
23
|
-
style: {
|
|
24
|
-
width: 28
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
12
|
const StaticCollectionItem = (props)=>{
|
|
28
13
|
const { children, removable, onRemove, id, // Style props
|
|
29
14
|
style, className, classNames, styles, ...others } = useProps('CollectionItem', defaultProps, props);
|
|
30
15
|
const ctx = useCollectionContext();
|
|
31
|
-
const removeButton = removable && onRemove ? /*#__PURE__*/ _jsx(RemoveButton, {
|
|
32
|
-
onClick: onRemove
|
|
33
|
-
}) : /*#__PURE__*/ _jsx(RemoveButtonPlaceholder, {});
|
|
34
16
|
return /*#__PURE__*/ _jsxs(Group, {
|
|
35
17
|
"data-testid": `item-${id}`,
|
|
36
18
|
...ctx.getStyles('item', {
|
|
@@ -42,13 +24,16 @@ const StaticCollectionItem = (props)=>{
|
|
|
42
24
|
...others,
|
|
43
25
|
children: [
|
|
44
26
|
children,
|
|
45
|
-
|
|
27
|
+
/*#__PURE__*/ _jsx(RemoveButton, {
|
|
28
|
+
removable: removable,
|
|
29
|
+
onRemove: onRemove
|
|
30
|
+
})
|
|
46
31
|
]
|
|
47
32
|
});
|
|
48
33
|
};
|
|
49
34
|
const DisabledCollectionItem = (props)=>{
|
|
50
35
|
const ctx = useCollectionContext();
|
|
51
|
-
const { children, id, // Style props
|
|
36
|
+
const { children, id, removable: _removable, onRemove: _onRemove, // Style props
|
|
52
37
|
style, className, classNames, styles, ...others } = useProps('CollectionItem', defaultProps, props);
|
|
53
38
|
return /*#__PURE__*/ _jsx(Group, {
|
|
54
39
|
"data-testid": `item-${id}`,
|
|
@@ -66,9 +51,6 @@ const DraggableCollectionItem = (props)=>{
|
|
|
66
51
|
const ctx = useCollectionContext();
|
|
67
52
|
const { children, removable, onRemove, id, // Style props
|
|
68
53
|
className, classNames, styles, ...others } = useProps('CollectionItem', defaultProps, props);
|
|
69
|
-
const removeButton = removable && onRemove ? /*#__PURE__*/ _jsx(RemoveButton, {
|
|
70
|
-
onClick: onRemove
|
|
71
|
-
}) : null;
|
|
72
54
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging, setActivatorNodeRef } = useSortable({
|
|
73
55
|
id
|
|
74
56
|
});
|
|
@@ -87,17 +69,16 @@ const DraggableCollectionItem = (props)=>{
|
|
|
87
69
|
"data-isdragging": isDragging,
|
|
88
70
|
...others,
|
|
89
71
|
children: [
|
|
90
|
-
/*#__PURE__*/ _jsx(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
...ctx.getStyles('dragHandle'),
|
|
95
|
-
children: /*#__PURE__*/ _jsx(DragAndDropSize24Px, {
|
|
96
|
-
height: 16
|
|
97
|
-
})
|
|
72
|
+
/*#__PURE__*/ _jsx(DragHandle, {
|
|
73
|
+
setActivatorNodeRef: setActivatorNodeRef,
|
|
74
|
+
listeners: listeners,
|
|
75
|
+
attributes: attributes
|
|
98
76
|
}),
|
|
99
77
|
children,
|
|
100
|
-
|
|
78
|
+
/*#__PURE__*/ _jsx(RemoveButton, {
|
|
79
|
+
removable: removable,
|
|
80
|
+
onRemove: onRemove
|
|
81
|
+
})
|
|
101
82
|
]
|
|
102
83
|
});
|
|
103
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Collection/CollectionItem.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Collection/CollectionItem.tsx"],"sourcesContent":["import {useSortable} from '@dnd-kit/sortable';\nimport {CSS} from '@dnd-kit/utilities';\nimport {Group, GroupProps, useProps} from '@mantine/core';\nimport {FunctionComponent, type MouseEventHandler, PropsWithChildren} from 'react';\n\nimport {useCollectionContext} from './CollectionContext.js';\nimport {DragHandle} from './layouts/shared/DragHandle.js';\nimport {RemoveButton} from './layouts/shared/RemoveButton.js';\n\ninterface CollectionItemProps extends CollectionItemSharedProps {\n draggable?: boolean;\n disabled: boolean;\n}\n\ninterface CollectionItemSharedProps extends GroupProps {\n id: string;\n onRemove?: MouseEventHandler<HTMLButtonElement>;\n removable?: boolean;\n}\n\nconst defaultProps: Partial<CollectionItemSharedProps> = {\n removable: true,\n gap: 'sm',\n};\n\nconst StaticCollectionItem: FunctionComponent<PropsWithChildren<CollectionItemSharedProps>> = (props) => {\n const {\n children,\n removable,\n onRemove,\n id,\n\n // Style props\n style,\n className,\n classNames,\n styles,\n ...others\n } = useProps('CollectionItem', defaultProps, props);\n const ctx = useCollectionContext();\n\n return (\n <Group\n data-testid={`item-${id}`}\n {...ctx.getStyles('item', {style, className, classNames, styles})}\n {...others}\n >\n {children}\n <RemoveButton removable={removable} onRemove={onRemove} />\n </Group>\n );\n};\n\nconst DisabledCollectionItem: FunctionComponent<PropsWithChildren<CollectionItemSharedProps>> = (props) => {\n const ctx = useCollectionContext();\n const {\n children,\n id,\n removable: _removable,\n onRemove: _onRemove,\n\n // Style props\n style,\n className,\n classNames,\n styles,\n ...others\n } = useProps('CollectionItem', defaultProps, props);\n return (\n <Group\n data-testid={`item-${id}`}\n {...ctx.getStyles('item', {style, className, classNames, styles})}\n {...others}\n >\n {children}\n </Group>\n );\n};\n\nconst DraggableCollectionItem: FunctionComponent<PropsWithChildren<CollectionItemSharedProps>> = (props) => {\n const ctx = useCollectionContext();\n const {\n children,\n removable,\n onRemove,\n id,\n\n // Style props\n className,\n classNames,\n styles,\n ...others\n } = useProps('CollectionItem', defaultProps, props);\n\n const {attributes, listeners, setNodeRef, transform, transition, isDragging, setActivatorNodeRef} = useSortable({\n id,\n });\n\n return (\n <Group\n data-testid={`item-${id}`}\n ref={setNodeRef}\n {...ctx.getStyles('item', {\n style: transform\n ? {\n transform: CSS.Transform.toString(transform),\n transition,\n }\n : undefined,\n className,\n classNames,\n styles,\n })}\n data-isdragging={isDragging}\n {...others}\n >\n <DragHandle setActivatorNodeRef={setActivatorNodeRef} listeners={listeners} attributes={attributes} />\n {children}\n <RemoveButton removable={removable} onRemove={onRemove} />\n </Group>\n );\n};\n\nexport const CollectionItem: FunctionComponent<PropsWithChildren<CollectionItemProps>> = ({\n draggable,\n disabled,\n ...otherProps\n}) => {\n if (disabled) {\n return <DisabledCollectionItem {...otherProps} />;\n }\n if (draggable) {\n return <DraggableCollectionItem {...otherProps} />;\n }\n return <StaticCollectionItem {...otherProps} />;\n};\n"],"names":["useSortable","CSS","Group","useProps","useCollectionContext","DragHandle","RemoveButton","defaultProps","removable","gap","StaticCollectionItem","props","children","onRemove","id","style","className","classNames","styles","others","ctx","data-testid","getStyles","DisabledCollectionItem","_removable","_onRemove","DraggableCollectionItem","attributes","listeners","setNodeRef","transform","transition","isDragging","setActivatorNodeRef","ref","Transform","toString","undefined","data-isdragging","CollectionItem","draggable","disabled","otherProps"],"mappings":";AAAA,SAAQA,WAAW,QAAO,oBAAoB;AAC9C,SAAQC,GAAG,QAAO,qBAAqB;AACvC,SAAQC,KAAK,EAAcC,QAAQ,QAAO,gBAAgB;AAG1D,SAAQC,oBAAoB,QAAO,yBAAyB;AAC5D,SAAQC,UAAU,QAAO,iCAAiC;AAC1D,SAAQC,YAAY,QAAO,mCAAmC;AAa9D,MAAMC,eAAmD;IACrDC,WAAW;IACXC,KAAK;AACT;AAEA,MAAMC,uBAAwF,CAACC;IAC3F,MAAM,EACFC,QAAQ,EACRJ,SAAS,EACTK,QAAQ,EACRC,EAAE,EAEF,cAAc;IACdC,KAAK,EACLC,SAAS,EACTC,UAAU,EACVC,MAAM,EACN,GAAGC,QACN,GAAGhB,SAAS,kBAAkBI,cAAcI;IAC7C,MAAMS,MAAMhB;IAEZ,qBACI,MAACF;QACGmB,eAAa,CAAC,KAAK,EAAEP,IAAI;QACxB,GAAGM,IAAIE,SAAS,CAAC,QAAQ;YAACP;YAAOC;YAAWC;YAAYC;QAAM,EAAE;QAChE,GAAGC,MAAM;;YAETP;0BACD,KAACN;gBAAaE,WAAWA;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C,SAAS,EACTC,QAAQ,EACR,GAAGC,YACN;IACG,IAAID,UAAU;QACV,qBAAO,KAAClB;YAAwB,GAAGmB,UAAU;;IACjD;IACA,IAAIF,WAAW;QACX,qBAAO,KAACd;YAAyB,GAAGgB,UAAU;;IAClD;IACA,qBAAO,KAAChC;QAAsB,GAAGgC,UAAU;;AAC/C,EAAE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { MantineSpacing } from '@mantine/core';
|
|
2
|
+
import { ReactElement, ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Props passed to layout Header component
|
|
5
|
+
*/
|
|
6
|
+
export interface CollectionLayoutHeaderProps {
|
|
7
|
+
/** Whether drag and drop is enabled */
|
|
8
|
+
draggable?: boolean;
|
|
9
|
+
/** Whether items are removable */
|
|
10
|
+
removable?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Props passed to layout Body component
|
|
14
|
+
*/
|
|
15
|
+
export interface CollectionLayoutBodyProps<T = unknown> {
|
|
16
|
+
/** Items to render */
|
|
17
|
+
items: T[];
|
|
18
|
+
/** Callback to remove an item */
|
|
19
|
+
onRemove?: (index: number) => void;
|
|
20
|
+
/** Whether items are removable */
|
|
21
|
+
removable?: boolean;
|
|
22
|
+
/** Whether drag and drop is enabled */
|
|
23
|
+
draggable?: boolean;
|
|
24
|
+
/** Whether the collection is disabled */
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/** Function to get unique ID for each item */
|
|
27
|
+
getItemId?: (item: T, index: number) => string;
|
|
28
|
+
/** Gap between items */
|
|
29
|
+
gap?: MantineSpacing;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Collection Layout interface
|
|
33
|
+
* Follows the same pattern as Table's RowLayout
|
|
34
|
+
*/
|
|
35
|
+
export interface CollectionLayout {
|
|
36
|
+
(props: {
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
}): ReactElement;
|
|
39
|
+
/** Layout display name */
|
|
40
|
+
displayName: string;
|
|
41
|
+
/** Header component - renders column headers */
|
|
42
|
+
Header: (props: CollectionLayoutHeaderProps) => ReactElement | null;
|
|
43
|
+
/** Body component - renders rows/items */
|
|
44
|
+
Body: <TData>(props: CollectionLayoutBodyProps<TData>) => ReactElement;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=CollectionLayout.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollectionLayout.types.d.ts","sourceRoot":"","sources":["../../../../../src/components/Collection/layouts/CollectionLayout.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,2BAA2B;IACxC,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,kCAAkC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB,CAAC,CAAC,GAAG,OAAO;IAClD,sBAAsB;IACtB,KAAK,EAAE,CAAC,EAAE,CAAC;IAEX,iCAAiC;IACjC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEnC,kCAAkC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAE/C,wBAAwB;IACxB,GAAG,CAAC,EAAE,cAAc,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B,CAAC,KAAK,EAAE;QAAC,QAAQ,EAAE,SAAS,CAAA;KAAC,GAAG,YAAY,CAAC;IAE7C,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IAEpB,gDAAgD;IAChD,MAAM,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,YAAY,GAAG,IAAI,CAAC;IAEpE,0CAA0C;IAC1C,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,yBAAyB,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC;CAC1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/Collection/layouts/CollectionLayout.types.ts"],"sourcesContent":["import type {MantineSpacing} from '@mantine/core';\nimport {ReactElement, ReactNode} from 'react';\n\n/**\n * Props passed to layout Header component\n */\nexport interface CollectionLayoutHeaderProps {\n /** Whether drag and drop is enabled */\n draggable?: boolean;\n\n /** Whether items are removable */\n removable?: boolean;\n}\n\n/**\n * Props passed to layout Body component\n */\nexport interface CollectionLayoutBodyProps<T = unknown> {\n /** Items to render */\n items: T[];\n\n /** Callback to remove an item */\n onRemove?: (index: number) => void;\n\n /** Whether items are removable */\n removable?: boolean;\n\n /** Whether drag and drop is enabled */\n draggable?: boolean;\n\n /** Whether the collection is disabled */\n disabled?: boolean;\n\n /** Function to get unique ID for each item */\n getItemId?: (item: T, index: number) => string;\n\n /** Gap between items */\n gap?: MantineSpacing;\n}\n\n/**\n * Collection Layout interface\n * Follows the same pattern as Table's RowLayout\n */\nexport interface CollectionLayout {\n (props: {children: ReactNode}): ReactElement;\n\n /** Layout display name */\n displayName: string;\n\n /** Header component - renders column headers */\n Header: (props: CollectionLayoutHeaderProps) => ReactElement | null;\n\n /** Body component - renders rows/items */\n Body: <TData>(props: CollectionLayoutBodyProps<TData>) => ReactElement;\n}\n"],"names":[],"mappings":"AAwCA;;;CAGC,GACD,WAWC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const CollectionLayouts: {
|
|
2
|
+
readonly Horizontal: {
|
|
3
|
+
({ children }: import("./shared/layoutConstants.js").LayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
Body: <T>(props: import("./shared/layoutConstants.js").LayoutBodyProps<T> & {
|
|
5
|
+
ref?: import("react").ForwardedRef<HTMLDivElement>;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
Header: (props: import("./shared/layoutConstants.js").LayoutHeaderProps & {
|
|
8
|
+
ref?: import("react").ForwardedRef<HTMLDivElement>;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
displayName: string;
|
|
11
|
+
};
|
|
12
|
+
readonly Vertical: {
|
|
13
|
+
({ children }: import("./shared/layoutConstants.js").LayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
Body: <T>(props: import("./shared/layoutConstants.js").LayoutBodyProps<T> & {
|
|
15
|
+
ref?: import("react").ForwardedRef<HTMLDivElement>;
|
|
16
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
Header: (_props: import("./shared/layoutConstants.js").LayoutHeaderProps & {
|
|
18
|
+
ref?: import("react").ForwardedRef<HTMLDivElement>;
|
|
19
|
+
}) => null;
|
|
20
|
+
displayName: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export { HorizontalLayout } from './horizontal-layout/HorizontalLayout.js';
|
|
24
|
+
export { VerticalLayout } from './vertical-layout/VerticalLayout.js';
|
|
25
|
+
export type { CollectionLayout, CollectionLayoutBodyProps, CollectionLayoutHeaderProps, } from './CollectionLayout.types.js';
|
|
26
|
+
//# sourceMappingURL=CollectionLayouts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollectionLayouts.d.ts","sourceRoot":"","sources":["../../../../../src/components/Collection/layouts/CollectionLayouts.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB;;;;eAY2xB,CAAC;;;eAA5xB,CAAC;;;;;;;eAAgyF,CAAC;;;eANh0F,CAAC;;;;CAHS,CAAC;AAEX,OAAO,EAAC,gBAAgB,EAAC,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAC,cAAc,EAAC,MAAM,qCAAqC,CAAC;AACnE,YAAY,EACR,gBAAgB,EAChB,yBAAyB,EACzB,2BAA2B,GAC9B,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HorizontalLayout } from './horizontal-layout/HorizontalLayout.js';
|
|
2
|
+
import { VerticalLayout } from './vertical-layout/VerticalLayout.js';
|
|
3
|
+
export const CollectionLayouts = {
|
|
4
|
+
Horizontal: HorizontalLayout,
|
|
5
|
+
Vertical: VerticalLayout
|
|
6
|
+
};
|
|
7
|
+
export { HorizontalLayout } from './horizontal-layout/HorizontalLayout.js';
|
|
8
|
+
export { VerticalLayout } from './vertical-layout/VerticalLayout.js';
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=CollectionLayouts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/Collection/layouts/CollectionLayouts.tsx"],"sourcesContent":["import {HorizontalLayout} from './horizontal-layout/HorizontalLayout.js';\nimport {VerticalLayout} from './vertical-layout/VerticalLayout.js';\n\nexport const CollectionLayouts = {\n Horizontal: HorizontalLayout,\n Vertical: VerticalLayout,\n} as const;\n\nexport {HorizontalLayout} from './horizontal-layout/HorizontalLayout.js';\nexport {VerticalLayout} from './vertical-layout/VerticalLayout.js';\nexport type {\n CollectionLayout,\n CollectionLayoutBodyProps,\n CollectionLayoutHeaderProps,\n} from './CollectionLayout.types.js';\n"],"names":["HorizontalLayout","VerticalLayout","CollectionLayouts","Horizontal","Vertical"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,0CAA0C;AACzE,SAAQC,cAAc,QAAO,sCAAsC;AAEnE,OAAO,MAAMC,oBAAoB;IAC7BC,YAAYH;IACZI,UAAUH;AACd,EAAW;AAEX,SAAQD,gBAAgB,QAAO,0CAA0C;AACzE,SAAQC,cAAc,QAAO,sCAAsC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LayoutProps } from '../shared/layoutConstants.js';
|
|
2
|
+
export declare const HorizontalLayout: {
|
|
3
|
+
({ children }: LayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
Body: <T>(props: import("../shared/layoutConstants.js").LayoutBodyProps<T> & {
|
|
5
|
+
ref?: import("react").ForwardedRef<HTMLDivElement>;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
Header: (props: import("../shared/layoutConstants.js").LayoutHeaderProps & {
|
|
8
|
+
ref?: import("react").ForwardedRef<HTMLDivElement>;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
displayName: string;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=HorizontalLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HorizontalLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Collection/layouts/horizontal-layout/HorizontalLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,eAAO,MAAM,gBAAgB;mBAAgB,WAAW;;WAK63B,CAAC;;;WAA5xB,CAAC;;;CAL/E,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { HorizontalLayoutBody } from './HorizontalLayoutBody.js';
|
|
3
|
+
import { HorizontalLayoutHeader } from './HorizontalLayoutHeader.js';
|
|
4
|
+
export const HorizontalLayout = ({ children })=>/*#__PURE__*/ _jsx(_Fragment, {
|
|
5
|
+
children: children
|
|
6
|
+
});
|
|
7
|
+
HorizontalLayout.Body = HorizontalLayoutBody;
|
|
8
|
+
HorizontalLayout.Header = HorizontalLayoutHeader;
|
|
9
|
+
HorizontalLayout.displayName = 'Horizontal';
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=HorizontalLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Collection/layouts/horizontal-layout/HorizontalLayout.tsx"],"sourcesContent":["import {LayoutProps} from '../shared/layoutConstants.js';\nimport {HorizontalLayoutBody} from './HorizontalLayoutBody.js';\nimport {HorizontalLayoutHeader} from './HorizontalLayoutHeader.js';\n\nexport const HorizontalLayout = ({children}: LayoutProps) => <>{children}</>;\n\nHorizontalLayout.Body = HorizontalLayoutBody;\nHorizontalLayout.Header = HorizontalLayoutHeader;\nHorizontalLayout.displayName = 'Horizontal';\n"],"names":["HorizontalLayoutBody","HorizontalLayoutHeader","HorizontalLayout","children","Body","Header","displayName"],"mappings":";AACA,SAAQA,oBAAoB,QAAO,4BAA4B;AAC/D,SAAQC,sBAAsB,QAAO,8BAA8B;AAEnE,OAAO,MAAMC,mBAAmB,CAAC,EAACC,QAAQ,EAAc,iBAAK;kBAAGA;OAAa;AAE7ED,iBAAiBE,IAAI,GAAGJ;AACxBE,iBAAiBG,MAAM,GAAGJ;AAC1BC,iBAAiBI,WAAW,GAAG"}
|