From b2c4999c517573643c2febd230510845f1a715fc Mon Sep 17 00:00:00 2001 From: Maksym Portianoi Date: Wed, 28 Aug 2024 14:14:23 -0400 Subject: [PATCH] fix(ktreelist): add group prop [KHCP-13028] (#2361) * fix(ktreelist): add group prop [KHCP-13028] * test(ktreelist): add group prop tests [KHCP-13028] * docs(tree-list): update component docs [KHCP-13028] * fix: address pr feedback --- docs/components/tree-list.md | 38 ++++++++++++++++++ sandbox/pages/SandboxTreeList.vue | 44 ++++++++++++++++++--- src/components/KTreeList/KTreeDraggable.vue | 7 +++- src/components/KTreeList/KTreeList.cy.ts | 40 +++++++++++++++++++ src/components/KTreeList/KTreeList.vue | 6 +++ 5 files changed, 128 insertions(+), 7 deletions(-) diff --git a/docs/components/tree-list.md b/docs/components/tree-list.md index 0e343e2710..2afbde765c 100644 --- a/docs/components/tree-list.md +++ b/docs/components/tree-list.md @@ -147,6 +147,30 @@ const items = ref([ ``` +### group + +To drag elements from one list into another, both lists must have the same `group` value. Defaults to `k-tree-list` (meaning that elements from one list on a page can be dragged into another, unless a different `group` value is provided for one of them). + +In the example below, try toggling the grouping on and off and dragging items from one list into another. + + + +
+ + +
+
+ +```html + +``` + ### disableDrag Boolean to turn off drag-n-drop reordering of the list. Defaults to `false`. @@ -349,6 +373,10 @@ const defaultItems = ref(JSON.parse(JSON.stringify(items))) const defaultItems2 = ref(JSON.parse(JSON.stringify(items))) +const groupedItems = ref(JSON.parse(JSON.stringify(items))) + +const groupedItems2 = ref(JSON.parse(JSON.stringify(items))) + const disableItems = ref(JSON.parse(JSON.stringify(items))) const maxLevelsItems = ref(JSON.parse(JSON.stringify(items))) @@ -370,4 +398,14 @@ const reset = (): void => { flex-direction: column; gap: $kui-space-50; } + +.group-container { + display: flex; + flex-direction: column; + gap: $kui-space-40; + + @media (min-width: $kui-breakpoint-mobile) { + flex-direction: row; + } +} diff --git a/sandbox/pages/SandboxTreeList.vue b/sandbox/pages/SandboxTreeList.vue index e34f9fc627..5924116d57 100644 --- a/sandbox/pages/SandboxTreeList.vue +++ b/sandbox/pages/SandboxTreeList.vue @@ -12,28 +12,46 @@ + + + +
+ + +
+
+
@@ -43,7 +61,7 @@ title="Slots" /> - +