@northlight/ui 1.5.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/northlight.d.mts +7 -2
- package/dist/es/northlight.mjs +7 -15
- package/dist/es/northlight.mjs.map +1 -1
- package/dist/ts/types.d.ts +7 -2
- package/dist/umd/northlight.js +7 -15
- package/dist/umd/northlight.js.map +1 -1
- package/dist/umd/northlight.min.js +1 -1
- package/dist/umd/northlight.min.js.map +1 -1
- package/package.json +2 -2
package/dist/ts/types.d.ts
CHANGED
|
@@ -1337,12 +1337,16 @@ declare function MultiSort<itemKeys extends string | number | symbol>({ items: s
|
|
|
1337
1337
|
* @example (Example)
|
|
1338
1338
|
* ### With custom component
|
|
1339
1339
|
* (?
|
|
1340
|
+
* () => {
|
|
1341
|
+
* const [items, setItems] = useState([ { name: 'item1' }, { name: 'item2' }, { name: 'item3' } ])
|
|
1342
|
+
* return (
|
|
1340
1343
|
* <Stack>
|
|
1341
1344
|
*
|
|
1342
1345
|
* <SortableList
|
|
1343
|
-
items={
|
|
1346
|
+
items={ items }
|
|
1344
1347
|
createKey={ (item) => item.name }
|
|
1345
1348
|
disableDrag={ true }
|
|
1349
|
+
onChange={setItems}
|
|
1346
1350
|
>
|
|
1347
1351
|
{ ({ name }, listeners, { isOver }) => (
|
|
1348
1352
|
<HStack>
|
|
@@ -1352,6 +1356,7 @@ declare function MultiSort<itemKeys extends string | number | symbol>({ items: s
|
|
|
1352
1356
|
) }
|
|
1353
1357
|
</SortableList>
|
|
1354
1358
|
</Stack>
|
|
1359
|
+
)}
|
|
1355
1360
|
* ?)
|
|
1356
1361
|
<br />
|
|
1357
1362
|
If disableDrag=false, then when the user double clicks it will trigger
|
|
@@ -1360,7 +1365,7 @@ the default behaviour of the rendered component instead of the dragging,
|
|
|
1360
1365
|
*
|
|
1361
1366
|
*
|
|
1362
1367
|
*/
|
|
1363
|
-
declare function SortableList<T>({ children, items
|
|
1368
|
+
declare function SortableList<T>({ children, items, collisionDetection, createKey, strategy, onChange, onMovedItem, displayOverlay, sensors, dblClickThreshold, disableDrag, }: SortableListProps<T>): JSX.Element;
|
|
1364
1369
|
|
|
1365
1370
|
/**
|
|
1366
1371
|
* Used with multi sort to render a sortable list inside a droppable
|
package/dist/umd/northlight.js
CHANGED
|
@@ -5943,7 +5943,7 @@
|
|
|
5943
5943
|
|
|
5944
5944
|
function SortableList({
|
|
5945
5945
|
children,
|
|
5946
|
-
items
|
|
5946
|
+
items,
|
|
5947
5947
|
collisionDetection,
|
|
5948
5948
|
createKey = ramda.identity,
|
|
5949
5949
|
strategy,
|
|
@@ -5955,15 +5955,8 @@
|
|
|
5955
5955
|
dblClickThreshold = 300,
|
|
5956
5956
|
disableDrag = false
|
|
5957
5957
|
}) {
|
|
5958
|
-
const [items, setItems] = React.useState(sortableItems);
|
|
5959
5958
|
const [activeItem, setActiveItem] = React.useState(null);
|
|
5960
5959
|
const identifierItems = React.useMemo(() => ramda.map(createKey, items), [items]);
|
|
5961
|
-
React.useEffect(() => {
|
|
5962
|
-
onChange(items);
|
|
5963
|
-
}, [items]);
|
|
5964
|
-
React.useEffect(() => {
|
|
5965
|
-
setItems(sortableItems);
|
|
5966
|
-
}, [sortableItems]);
|
|
5967
5960
|
const customSensors = core.useSensors(
|
|
5968
5961
|
core.useSensor(core.PointerSensor),
|
|
5969
5962
|
core.useSensor(core.KeyboardSensor, {
|
|
@@ -5979,13 +5972,12 @@
|
|
|
5979
5972
|
const handleDragEnd = (event) => {
|
|
5980
5973
|
const { active, over } = event;
|
|
5981
5974
|
if (active && over && active.id !== over.id) {
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
});
|
|
5975
|
+
const prevIds = ramda.map(createKey, items);
|
|
5976
|
+
const oldIndex = ramda.indexOf(active.id, prevIds);
|
|
5977
|
+
const newIndex = ramda.indexOf(over.id, prevIds);
|
|
5978
|
+
onMovedItem({ item: items[oldIndex], oldIndex, newIndex });
|
|
5979
|
+
const newItems = sortable.arrayMove(items, oldIndex, newIndex);
|
|
5980
|
+
onChange(newItems);
|
|
5989
5981
|
}
|
|
5990
5982
|
};
|
|
5991
5983
|
return /* @__PURE__ */ React.createElement(
|