@northlight/ui 1.5.9 → 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 -11
- package/dist/es/northlight.mjs.map +1 -1
- package/dist/ts/types.d.ts +7 -2
- package/dist/umd/northlight.js +7 -11
- 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/es/northlight.d.mts
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/es/northlight.mjs
CHANGED
|
@@ -5977,7 +5977,7 @@ function MultiSort({
|
|
|
5977
5977
|
|
|
5978
5978
|
function SortableList({
|
|
5979
5979
|
children,
|
|
5980
|
-
items
|
|
5980
|
+
items,
|
|
5981
5981
|
collisionDetection,
|
|
5982
5982
|
createKey = identity,
|
|
5983
5983
|
strategy,
|
|
@@ -5989,7 +5989,6 @@ function SortableList({
|
|
|
5989
5989
|
dblClickThreshold = 300,
|
|
5990
5990
|
disableDrag = false
|
|
5991
5991
|
}) {
|
|
5992
|
-
const [items, setItems] = useState(sortableItems);
|
|
5993
5992
|
const [activeItem, setActiveItem] = useState(null);
|
|
5994
5993
|
const identifierItems = useMemo(() => map(createKey, items), [items]);
|
|
5995
5994
|
const customSensors = useSensors(
|
|
@@ -6007,15 +6006,12 @@ function SortableList({
|
|
|
6007
6006
|
const handleDragEnd = (event) => {
|
|
6008
6007
|
const { active, over } = event;
|
|
6009
6008
|
if (active && over && active.id !== over.id) {
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
onChange(newItems);
|
|
6017
|
-
return newItems;
|
|
6018
|
-
});
|
|
6009
|
+
const prevIds = map(createKey, items);
|
|
6010
|
+
const oldIndex = indexOf(active.id, prevIds);
|
|
6011
|
+
const newIndex = indexOf(over.id, prevIds);
|
|
6012
|
+
onMovedItem({ item: items[oldIndex], oldIndex, newIndex });
|
|
6013
|
+
const newItems = arrayMove(items, oldIndex, newIndex);
|
|
6014
|
+
onChange(newItems);
|
|
6019
6015
|
}
|
|
6020
6016
|
};
|
|
6021
6017
|
return /* @__PURE__ */ React.createElement(
|