UNPKG

@coveord/plasma-mantine

Version:

A Plasma flavoured Mantine theme

136 lines (135 loc) 5.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "CollectionItem", { enumerable: true, get: function() { return CollectionItem; } }); var _object_spread = require("@swc/helpers/_/_object_spread"); var _object_spread_props = require("@swc/helpers/_/_object_spread_props"); var _object_without_properties = require("@swc/helpers/_/_object_without_properties"); var _jsxruntime = require("react/jsx-runtime"); var _sortable = require("@dnd-kit/sortable"); var _utilities = require("@dnd-kit/utilities"); var _core = require("@mantine/core"); var _CollectionContext = require("./CollectionContext.js"); var _DragHandle = require("./layouts/shared/DragHandle.js"); var _RemoveButton = require("./layouts/shared/RemoveButton.js"); var defaultProps = { removable: true, gap: 'sm' }; var StaticCollectionItem = function StaticCollectionItem(props) { var _useProps = (0, _core.useProps)('CollectionItem', defaultProps, props), children = _useProps.children, removable = _useProps.removable, onRemove = _useProps.onRemove, id = _useProps.id, // Style props style = _useProps.style, className = _useProps.className, classNames = _useProps.classNames, styles = _useProps.styles, others = _object_without_properties._(_useProps, [ "children", "removable", "onRemove", "id", "style", "className", "classNames", "styles" ]); var ctx = (0, _CollectionContext.useCollectionContext)(); return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_core.Group, _object_spread_props._(_object_spread._({ "data-testid": "item-".concat(id) }, ctx.getStyles('item', { style: style, className: className, classNames: classNames, styles: styles }), others), { children: [ children, /*#__PURE__*/ (0, _jsxruntime.jsx)(_RemoveButton.RemoveButton, { removable: removable, onRemove: onRemove }) ] })); }; var DisabledCollectionItem = function DisabledCollectionItem(props) { var ctx = (0, _CollectionContext.useCollectionContext)(); var _useProps = (0, _core.useProps)('CollectionItem', defaultProps, props), children = _useProps.children, id = _useProps.id, _removable = _useProps.removable, _onRemove = _useProps.onRemove, // Style props style = _useProps.style, className = _useProps.className, classNames = _useProps.classNames, styles = _useProps.styles, others = _object_without_properties._(_useProps, [ "children", "id", "removable", "onRemove", "style", "className", "classNames", "styles" ]); return /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.Group, _object_spread_props._(_object_spread._({ "data-testid": "item-".concat(id) }, ctx.getStyles('item', { style: style, className: className, classNames: classNames, styles: styles }), others), { children: children })); }; var DraggableCollectionItem = function DraggableCollectionItem(props) { var ctx = (0, _CollectionContext.useCollectionContext)(); var _useProps = (0, _core.useProps)('CollectionItem', defaultProps, props), children = _useProps.children, removable = _useProps.removable, onRemove = _useProps.onRemove, id = _useProps.id, // Style props className = _useProps.className, classNames = _useProps.classNames, styles = _useProps.styles, others = _object_without_properties._(_useProps, [ "children", "removable", "onRemove", "id", "className", "classNames", "styles" ]); var _useSortable = (0, _sortable.useSortable)({ id: id }), attributes = _useSortable.attributes, listeners = _useSortable.listeners, setNodeRef = _useSortable.setNodeRef, transform = _useSortable.transform, transition = _useSortable.transition, isDragging = _useSortable.isDragging, setActivatorNodeRef = _useSortable.setActivatorNodeRef; return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_core.Group, _object_spread_props._(_object_spread._(_object_spread_props._(_object_spread._({ "data-testid": "item-".concat(id), ref: setNodeRef }, ctx.getStyles('item', { style: transform ? { transform: _utilities.CSS.Transform.toString(transform), transition: transition } : undefined, className: className, classNames: classNames, styles: styles })), { "data-isdragging": isDragging }), others), { children: [ /*#__PURE__*/ (0, _jsxruntime.jsx)(_DragHandle.DragHandle, { setActivatorNodeRef: setActivatorNodeRef, listeners: listeners, attributes: attributes }), children, /*#__PURE__*/ (0, _jsxruntime.jsx)(_RemoveButton.RemoveButton, { removable: removable, onRemove: onRemove }) ] })); }; var CollectionItem = function CollectionItem(_0) { var draggable = _0.draggable, disabled = _0.disabled, otherProps = _object_without_properties._(_0, [ "draggable", "disabled" ]); if (disabled) { return /*#__PURE__*/ (0, _jsxruntime.jsx)(DisabledCollectionItem, _object_spread._({}, otherProps)); } if (draggable) { return /*#__PURE__*/ (0, _jsxruntime.jsx)(DraggableCollectionItem, _object_spread._({}, otherProps)); } return /*#__PURE__*/ (0, _jsxruntime.jsx)(StaticCollectionItem, _object_spread._({}, otherProps)); }; //# sourceMappingURL=CollectionItem.js.map