From e46520b04503f880636e782cc0f1f063d73493a4 Mon Sep 17 00:00:00 2001 From: Caleb Porzio Date: Sun, 21 Apr 2024 09:09:29 -0400 Subject: [PATCH] Change to `x-sort:item`, add sorting class to body, and use `x-sort:group` (#4161) * Add .sorting class to body while dragging * wip * fix tests --- index.html | 7 + packages/docs/src/en/plugins/sort.md | 198 ++++++++++++------ packages/sort/src/index.js | 36 +++- .../cypress/integration/plugins/sort.spec.js | 84 +++++++- 4 files changed, 260 insertions(+), 65 deletions(-) diff --git a/index.html b/index.html index 7d9567cf1..376da39f0 100644 --- a/index.html +++ b/index.html @@ -6,10 +6,17 @@ --> + +
+
foo
+
foo
+
foo
+
+
diff --git a/packages/docs/src/en/plugins/sort.md b/packages/docs/src/en/plugins/sort.md index b45f84a25..b67ff495c 100644 --- a/packages/docs/src/en/plugins/sort.md +++ b/packages/docs/src/en/plugins/sort.md @@ -52,22 +52,22 @@ Alpine.plugin(sort) ## Basic usage -The primary API for using this plugin is the `x-sort` directive. By adding `x-sort` to an element, its children become sortable—meaning you can drag them around with your mouse, and they will change positions. +The primary API for using this plugin is the `x-sort` directive. By adding `x-sort` to an element, its children containing `x-sort:item` become sortable—meaning you can drag them around with your mouse, and they will change positions. ```alpine ```
    -
  • foo
  • -
  • bar
  • -
  • baz
  • +
  • foo
  • +
  • bar
  • +
  • baz
@@ -75,36 +75,36 @@ The primary API for using this plugin is the `x-sort` directive. By adding `x-so ## Sort handlers -You can react to sorting changes by passing a handler function to `x-sort` and adding keys to each item using `x-sort:key`. Here is an example of a simple handler function that shows an alert dialog with the changed item's key and its new position: +You can react to sorting changes by passing a handler function to `x-sort` and adding keys to each item using `x-sort:item`. Here is an example of a simple handler function that shows an alert dialog with the changed item's key and its new position: ```alpine -