@ndlib/component-library 0.0.52 → 0.0.53

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.
@@ -25,8 +25,8 @@ const StateManager = ({ children }) => {
25
25
  return _jsx(_Fragment, { children: children({ items, setItems }) });
26
26
  };
27
27
  export const Default = {
28
- render: () => (_jsx(StateManager, { children: ({ items, setItems }) => (_jsx(DragDropList, Object.assign({ items: items, onReorder: ({ reorderedList }) => setItems(reorderedList) }, { children: (item) => (_jsxs(_Fragment, { children: [_jsx(DragHandle, {}), _jsx(Paragraph, Object.assign({ sx: { ml: 2 } }, { children: item.label }))] })) }))) })),
28
+ render: () => (_jsx(StateManager, { children: ({ items, setItems }) => (_jsx(DragDropList, Object.assign({ items: items, onReorder: ({ reorderedList }) => setItems(reorderedList) }, { children: ({ item }) => (_jsxs(_Fragment, { children: [_jsx(DragHandle, {}), _jsx(Paragraph, Object.assign({ sx: { ml: 2 } }, { children: item.label }))] })) }))) })),
29
29
  };
30
30
  export const Disabled = {
31
- render: () => (_jsx(DragDropList, Object.assign({ disabled: true, items: _items, onReorder: () => { } }, { children: (item) => (_jsxs(_Fragment, { children: [_jsx(DragHandle, {}), _jsx(Paragraph, Object.assign({ sx: { ml: 2 } }, { children: item.label }))] })) }))),
31
+ render: () => (_jsx(DragDropList, Object.assign({ disabled: true, items: _items, onReorder: () => { } }, { children: ({ item }) => (_jsxs(_Fragment, { children: [_jsx(DragHandle, {}), _jsx(Paragraph, Object.assign({ sx: { ml: 2 } }, { children: item.label }))] })) }))),
32
32
  };
@@ -16,7 +16,10 @@ type DragDropListProps<Item extends DraggableItem> = {
16
16
  itemStyles?: StylesProp;
17
17
  dragItemsDirectly?: boolean;
18
18
  disabled?: boolean;
19
- children: (item: Item) => React.ReactNode;
19
+ children: (params: {
20
+ item: Item;
21
+ index: number;
22
+ }) => React.ReactNode;
20
23
  };
21
24
  export declare const DragHandle: React.FC<ButtonProps>;
22
25
  export declare function DragDropList<Item extends DraggableItem>({ items, itemIdKey, wrapperStyles, itemStyles, children: renderChild, onReorder, disabled, dragItemsDirectly, }: DragDropListProps<Item>): import("react/jsx-runtime").JSX.Element;
@@ -11,11 +11,13 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
13
13
  import { DragDropContext, Droppable, Draggable, } from 'react-beautiful-dnd';
14
- import DragIndicator from '@mui/icons-material/DragIndicator';
14
+ import _DragIndicator from '@mui/icons-material/DragIndicator';
15
15
  import { BUTTON_TYPE, Button } from '../../elements/Button';
16
16
  import { Column } from '../../elements/layout/Column';
17
17
  import { Row } from '../../elements/layout/Row';
18
18
  import { useUniqueId } from '../../providers/uniqueIds';
19
+ import { importedDefaultComponentShim } from '../../../utils/misc';
20
+ const DragIndicator = importedDefaultComponentShim(_DragIndicator);
19
21
  export const DragHandle = (_a) => {
20
22
  var { sx } = _a, props = __rest(_a, ["sx"]);
21
23
  return (_jsx(Button, Object.assign({ type: BUTTON_TYPE.TEXT, primaryIcon: DragIndicator, disableFocusStyles: true, sx: Object.assign({ cursor: 'inherit' }, sx) }, props)));
@@ -41,6 +43,6 @@ export function DragDropList({ items, itemIdKey = 'id', wrapperStyles, itemStyle
41
43
  return (_jsx(Row, Object.assign({ sx: {
42
44
  alignItems: 'center',
43
45
  itemStyles,
44
- }, ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps, { "aria-describedby": `item-${index}` }, (dragItemsDirectly ? provided.dragHandleProps : {}), { children: _jsx(Row, Object.assign({ sx: { mt: 1 }, id: `item-${index}` }, { children: renderChild(item) })) })));
46
+ }, ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps, { "aria-describedby": `item-${index}` }, (dragItemsDirectly ? provided.dragHandleProps : {}), { children: _jsx(Row, Object.assign({ sx: { mt: 1 }, id: `item-${index}` }, { children: renderChild({ item, index }) })) })));
45
47
  } }), String(item[itemIdKey])))) }) }))) })) })));
46
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/component-library",
3
- "version": "0.0.52",
3
+ "version": "0.0.53",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [