@redvars/peacock 4.3.2 → 4.3.3

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.
Files changed (174) hide show
  1. package/dist/{BaseField-Cpcwp4yU.js → BaseField-DPyW5Zm5.js} +3 -3
  2. package/dist/{BaseField-Cpcwp4yU.js.map → BaseField-DPyW5Zm5.js.map} +1 -1
  3. package/dist/{BaseInput-E7kPUiiZ.js → BaseInput-FhjvfMjF.js} +2 -2
  4. package/dist/{BaseInput-E7kPUiiZ.js.map → BaseInput-FhjvfMjF.js.map} +1 -1
  5. package/dist/ai-badge.js +2 -2
  6. package/dist/ai-summary.js +2 -2
  7. package/dist/alert.js +2 -2
  8. package/dist/anchor-nav.js +2 -2
  9. package/dist/app-shell.js +2 -2
  10. package/dist/assistant-panel.js +2 -2
  11. package/dist/assistant-step.js +2 -2
  12. package/dist/assistant-steps.js +2 -2
  13. package/dist/avatar-group.js +2 -2
  14. package/dist/banner.js +2 -2
  15. package/dist/{base-progress-DDWoywDO.js → base-progress-D8-x6XS4.js} +2 -2
  16. package/dist/{base-progress-DDWoywDO.js.map → base-progress-D8-x6XS4.js.map} +1 -1
  17. package/dist/bottom-sheet.js +2 -2
  18. package/dist/breadcrumb.js +2 -2
  19. package/dist/calendar.js +2 -2
  20. package/dist/{canvas-base-Cyo5f6KN.js → canvas-base-CjxNdEsR.js} +2 -2
  21. package/dist/{canvas-base-Cyo5f6KN.js.map → canvas-base-CjxNdEsR.js.map} +1 -1
  22. package/dist/carousel.js +2 -2
  23. package/dist/{cartesian-chart-CO5Vrevp.js → cartesian-chart-D30aTNVm.js} +2 -2
  24. package/dist/{cartesian-chart-CO5Vrevp.js.map → cartesian-chart-D30aTNVm.js.map} +1 -1
  25. package/dist/{cb-group-base-C2N3ohXb.js → cb-group-base-Crt0BSzR.js} +2 -2
  26. package/dist/{cb-group-base-C2N3ohXb.js.map → cb-group-base-Crt0BSzR.js.map} +1 -1
  27. package/dist/cb-group.js +3 -3
  28. package/dist/cb-rule.js +3 -3
  29. package/dist/chart-area.js +4 -4
  30. package/dist/chart-bar.js +4 -4
  31. package/dist/{chart-base-C8oWNR3Q.js → chart-base-D2kPte5J.js} +2 -2
  32. package/dist/{chart-base-C8oWNR3Q.js.map → chart-base-D2kPte5J.js.map} +1 -1
  33. package/dist/chart-doughnut.js +3 -3
  34. package/dist/chart-line.js +4 -4
  35. package/dist/chart-pie.js +3 -3
  36. package/dist/chat-event.js +2 -2
  37. package/dist/chat-message.js +2 -2
  38. package/dist/chat-thread.js +2 -2
  39. package/dist/checkbox-group.js +3 -3
  40. package/dist/checkbox.js +3 -3
  41. package/dist/chip-set.js +2 -2
  42. package/dist/chip.js +2 -2
  43. package/dist/circular-progress.js +3 -3
  44. package/dist/citation.js +2 -2
  45. package/dist/code-editor.js +3 -3
  46. package/dist/code-highlighter.js +2 -2
  47. package/dist/color-field.js +4 -4
  48. package/dist/color-picker.js +2 -2
  49. package/dist/command-palette.js +2 -2
  50. package/dist/comment-composer.js +4 -4
  51. package/dist/condition-builder.js +3 -3
  52. package/dist/confirm-dialog.js +2 -2
  53. package/dist/copy-button.js +2 -2
  54. package/dist/currency-field.js +4 -4
  55. package/dist/custom-elements-jsdocs.json +1 -1
  56. package/dist/custom-elements.json +302 -1
  57. package/dist/date-field.js +5 -5
  58. package/dist/date-picker.js +2 -2
  59. package/dist/date-range-field.js +5 -5
  60. package/dist/datetime-field.js +5 -5
  61. package/dist/dependency-map.js +3 -3
  62. package/dist/description-item.js +2 -2
  63. package/dist/description-list.js +2 -2
  64. package/dist/{diagram-BT-BZLZf.js → diagram-BFGq2POp.js} +2 -2
  65. package/dist/{diagram-BT-BZLZf.js.map → diagram-BFGq2POp.js.map} +1 -1
  66. package/dist/diagram-controls.js +2 -2
  67. package/dist/diagram-minimap.js +2 -2
  68. package/dist/diagram.js +4 -4
  69. package/dist/diff-viewer.js +2 -2
  70. package/dist/discussion-activity.js +2 -2
  71. package/dist/discussion-comment.js +2 -2
  72. package/dist/discussion.js +4 -4
  73. package/dist/{document-editor-B4ePud1R.js → document-editor-CC7MTHMO.js} +2 -2
  74. package/dist/{document-editor-B4ePud1R.js.map → document-editor-CC7MTHMO.js.map} +1 -1
  75. package/dist/document-editor.js +3 -3
  76. package/dist/draft-card.js +2 -2
  77. package/dist/erd.js +3 -3
  78. package/dist/file-upload.js +3 -3
  79. package/dist/filter-bar.js +2 -2
  80. package/dist/flow.js +4 -4
  81. package/dist/form.js +2 -2
  82. package/dist/{generative-view-xGY15iNe.js → generative-view-DoT9YwHL.js} +2 -2
  83. package/dist/{generative-view-xGY15iNe.js.map → generative-view-DoT9YwHL.js.map} +1 -1
  84. package/dist/generative-view.js +3 -3
  85. package/dist/html-editor.js +4 -4
  86. package/dist/{i18n-controller-D6HbL-Ru.js → i18n-controller-Co6pasNo.js} +2 -2
  87. package/dist/{i18n-controller-D6HbL-Ru.js.map → i18n-controller-Co6pasNo.js.map} +1 -1
  88. package/dist/image.js +2 -2
  89. package/dist/index.js +17 -17
  90. package/dist/inline-edit.js +2 -2
  91. package/dist/input.js +3 -3
  92. package/dist/json-viewer.js +2 -2
  93. package/dist/kanban.js +2 -2
  94. package/dist/kbd.js +2 -2
  95. package/dist/linear-progress.js +3 -3
  96. package/dist/listbox.js +2 -2
  97. package/dist/loader-full.js +10 -10
  98. package/dist/loader.js +10 -10
  99. package/dist/markdown-editor.js +4 -4
  100. package/dist/mention-input.js +4 -4
  101. package/dist/modal.js +2 -2
  102. package/dist/navigation-bar.js +2 -2
  103. package/dist/navigation-drawer.js +2 -2
  104. package/dist/navigation-rail.js +2 -2
  105. package/dist/notification-center.js +2 -2
  106. package/dist/number-field.js +4 -4
  107. package/dist/page-header.js +2 -2
  108. package/dist/pagination.js +2 -2
  109. package/dist/password-field.js +4 -4
  110. package/dist/password-rules.js +2 -2
  111. package/dist/phone-field.js +4 -4
  112. package/dist/{picker-field-DJkGHGLP.js → picker-field-BliKNENo.js} +3 -3
  113. package/dist/{picker-field-DJkGHGLP.js.map → picker-field-BliKNENo.js.map} +1 -1
  114. package/dist/pin-input.js +4 -4
  115. package/dist/presence-indicator.js +2 -2
  116. package/dist/prompt-input.js +4 -4
  117. package/dist/radio.js +3 -3
  118. package/dist/rating.js +3 -3
  119. package/dist/redvars-loader.js +2 -2
  120. package/dist/relative-time.js +2 -2
  121. package/dist/resizable-panels.js +2 -2
  122. package/dist/{rich-text-input-BFZN9JqO.js → rich-text-input-YeqK1or-.js} +3 -3
  123. package/dist/{rich-text-input-BFZN9JqO.js.map → rich-text-input-YeqK1or-.js.map} +1 -1
  124. package/dist/{schema-D-luMxHL.js → schema-CuHBNpzo.js} +2 -2
  125. package/dist/{schema-D-luMxHL.js.map → schema-CuHBNpzo.js.map} +1 -1
  126. package/dist/search.js +3 -3
  127. package/dist/select.js +4 -4
  128. package/dist/side-sheet.js +2 -2
  129. package/dist/signature-pad.js +3 -3
  130. package/dist/site-header.js +2 -2
  131. package/dist/slider.js +3 -3
  132. package/dist/snackbar.js +2 -2
  133. package/dist/sparkline.js +2 -2
  134. package/dist/split-button.js +2 -2
  135. package/dist/src/__internal/i18n/strings.d.ts +2 -0
  136. package/dist/src/transfer-list/transfer-list.d.ts +49 -1
  137. package/dist/stat.js +2 -2
  138. package/dist/status-indicator.js +2 -2
  139. package/dist/step.js +2 -2
  140. package/dist/stepper.js +2 -2
  141. package/dist/{strings-CXI3T-AI.js → strings-DYwXSSu_.js} +3 -1
  142. package/dist/strings-DYwXSSu_.js.map +1 -0
  143. package/dist/svg.js +2 -2
  144. package/dist/switch.js +3 -3
  145. package/dist/table.js +2 -2
  146. package/dist/textarea.js +4 -4
  147. package/dist/time-field.js +5 -5
  148. package/dist/time-picker.js +2 -2
  149. package/dist/timeline-item.js +2 -2
  150. package/dist/timeline.js +2 -2
  151. package/dist/{toggle-base-B05ckmj_.js → toggle-base-B-HOnUIy.js} +2 -2
  152. package/dist/{toggle-base-B05ckmj_.js.map → toggle-base-B-HOnUIy.js.map} +1 -1
  153. package/dist/tour.js +2 -2
  154. package/dist/transfer-list.js +427 -6
  155. package/dist/transfer-list.js.map +1 -1
  156. package/dist/tree-chart.js +3 -3
  157. package/dist/tree-item.js +2 -2
  158. package/dist/tree.js +2 -2
  159. package/dist/tsconfig.tsbuildinfo +1 -1
  160. package/dist/typing-indicator.js +2 -2
  161. package/dist/url-field.js +4 -4
  162. package/dist/user-menu.js +2 -2
  163. package/dist/{video-CZJ4TypQ.js → video-u-Vs7M9g.js} +2 -2
  164. package/dist/{video-CZJ4TypQ.js.map → video-u-Vs7M9g.js.map} +1 -1
  165. package/dist/video.js +3 -3
  166. package/dist/virtual-list.js +2 -2
  167. package/dist/workflow-timeline.js +2 -2
  168. package/dist/workflow.js +3 -3
  169. package/dist/workspace-switcher.js +2 -2
  170. package/package.json +1 -1
  171. package/src/__internal/i18n/strings.ts +3 -0
  172. package/src/transfer-list/transfer-list.scss +95 -1
  173. package/src/transfer-list/transfer-list.ts +359 -2
  174. package/dist/strings-CXI3T-AI.js.map +0 -1
@@ -37,6 +37,29 @@ export interface TransferListChangeDetail {
37
37
  /** The two lists: the source ("Available") and the value ("Selected"). */
38
38
  type Side = 'available' | 'selected';
39
39
 
40
+ /** A press on a drag handle of the selected list, which becomes a drag past `DRAG_THRESHOLD`. */
41
+ interface DragSession {
42
+ pointerId: number;
43
+ handle: Element;
44
+ startX: number;
45
+ startY: number;
46
+ /** The values that move, in their current order. */
47
+ values: string[];
48
+ active: boolean;
49
+ /** Last pointer position, for auto-scroll. */
50
+ clientX: number;
51
+ clientY: number;
52
+ }
53
+
54
+ /** Pointer travel in pixels before a handle press becomes a drag. */
55
+ const DRAG_THRESHOLD = 4;
56
+
57
+ /** Distance in pixels from a list edge at which a drag scrolls the list. */
58
+ const AUTO_SCROLL_EDGE = 24;
59
+
60
+ /** Pixels a drag scrolls the list per frame at the very edge. */
61
+ const AUTO_SCROLL_SPEED = 12;
62
+
40
63
  function isListboxOption(node: EventTarget): node is ListboxOption {
41
64
  return node instanceof Element && node.localName === 'wc-listbox-option';
42
65
  }
@@ -65,7 +88,9 @@ let transferListCount = 0;
65
88
  * <p>Without <code>ordered</code> the value keeps the order of <code>options</code>. With
66
89
  * <code>ordered</code> the selected list keeps the person's order: moved items join at the end,
67
90
  * the Move up and Move down buttons move the checked items, and Alt+Up and Alt+Down move the
68
- * focused one.</p>
91
+ * focused one. Each selected item also gets a drag handle: dragging it moves the item, or all
92
+ * checked items when it is checked, to where the drop line shows. Escape or a release outside
93
+ * the list cancels the drag.</p>
69
94
  * <p>The value follows <code>wc-listbox multiple</code>: <code>value</code> is a comma-separated
70
95
  * list (so option values must not contain commas) and <code>values</code> the same as an array.
71
96
  * Inside a <code>&lt;form&gt;</code> each value is submitted under <code>name</code>;
@@ -168,12 +193,23 @@ export class TransferList extends BaseInput {
168
193
  /** Text of the polite live region. */
169
194
  @state() private announcement = '';
170
195
 
196
+ /** The values being dragged in the selected list; empty while no drag is active. */
197
+ @state() private dragValues: string[] = [];
198
+
199
+ /** Where a drag would drop, as an index among the shown selected items; `null` for nowhere. */
200
+ @state() private dropIndex: number | null = null;
201
+
202
+ /** Pointer position inside the selected list wrapper, for the dragged copy. */
203
+ @state() private dragPoint: { x: number; y: number } = { x: 0, y: 0 };
204
+
171
205
  // ── Queries ──────────────────────────────────────────────────────────────
172
206
 
173
207
  @query('.list-available') private availableList?: Listbox;
174
208
 
175
209
  @query('.list-selected') private selectedList?: Listbox;
176
210
 
211
+ @query('.pane-selected .list-wrapper') private selectedWrapper?: HTMLElement;
212
+
177
213
  // ── Private fields ───────────────────────────────────────────────────────
178
214
 
179
215
  private readonly idPrefix = `wc-transfer-list-${(transferListCount += 1)}`;
@@ -181,8 +217,22 @@ export class TransferList extends BaseInput {
181
217
  /** Peacock's strings for the headlines, buttons and announcements. */
182
218
  private readonly i18n = new I18nController(this);
183
219
 
220
+ /** The handle press that may become a drag. */
221
+ private dragSession?: DragSession;
222
+
223
+ /** Frame of the auto-scroll loop while a drag is near a list edge. */
224
+ private autoScrollFrame = 0;
225
+
226
+ /** Swallows the click that ends a drag, so it does not also check the item. */
227
+ private suppressClick = false;
228
+
184
229
  // ── Lifecycle ────────────────────────────────────────────────────────────
185
230
 
231
+ override disconnectedCallback() {
232
+ super.disconnectedCallback();
233
+ this.endDrag(false);
234
+ }
235
+
186
236
  protected override willUpdate(changed: PropertyValues<this>) {
187
237
  super.willUpdate(changed);
188
238
  if (changed.has('options') && !Array.isArray(this.options)) {
@@ -560,14 +610,314 @@ export class TransferList extends BaseInput {
560
610
  }
561
611
  }
562
612
 
613
+ /** Whether selected items show a drag handle. */
614
+ private get canDrag(): boolean {
615
+ return this.ordered && this.isInteractive;
616
+ }
617
+
618
+ /** The selected values a drag from `value` moves: all checked ones if it is checked. */
619
+ private dragGroup(value: string): string[] {
620
+ const checked = this.movableChecked('selected');
621
+ return checked.includes(value) ? checked : [value];
622
+ }
623
+
624
+ /** The order after moving `moving` to the drop index among the shown selected items. */
625
+ private orderAfterDrop(moving: string[], index: number): string[] {
626
+ const shown = this.sideOptions('selected')
627
+ .filter(option => this.matchesSearch(option, 'selected'))
628
+ .map(option => option.value);
629
+ const rest = this.values.filter(value => !moving.includes(value));
630
+ const ordered = this.values.filter(value => moving.includes(value));
631
+ // Before the first shown item at or below the line that stays where it is.
632
+ const before = shown.slice(index).find(value => !moving.includes(value));
633
+ let at: number;
634
+ if (before !== undefined) {
635
+ at = rest.indexOf(before);
636
+ } else {
637
+ // Below the last shown item, so hidden items after it keep their places.
638
+ const after = shown
639
+ .slice(0, index)
640
+ .reverse()
641
+ .find(value => !moving.includes(value));
642
+ at = after === undefined ? rest.length : rest.indexOf(after) + 1;
643
+ }
644
+ return [...rest.slice(0, at), ...ordered, ...rest.slice(at)];
645
+ }
646
+
647
+ /** The shown options of the selected list, in display order. */
648
+ private shownSelectedOptions(): ListboxOption[] {
649
+ return (this.selectedList?.options ?? []).filter(option => !option.hidden);
650
+ }
651
+
652
+ /** The drop index for a pointer at `clientY`, or `null` outside the list or for no change. */
653
+ private dropIndexAt(clientX: number, clientY: number): number | null {
654
+ const wrapper = this.selectedWrapper;
655
+ const session = this.dragSession;
656
+ if (!wrapper || !session) return null;
657
+ const box = wrapper.getBoundingClientRect();
658
+ if (
659
+ clientX < box.left ||
660
+ clientX > box.right ||
661
+ clientY < box.top ||
662
+ clientY > box.bottom
663
+ ) {
664
+ return null;
665
+ }
666
+ const shown = this.shownSelectedOptions();
667
+ let index = shown.length;
668
+ for (let i = 0; i < shown.length; i += 1) {
669
+ const rect = shown[i].getBoundingClientRect();
670
+ if (clientY < rect.top + rect.height / 2) {
671
+ index = i;
672
+ break;
673
+ }
674
+ }
675
+ const next = this.orderAfterDrop(session.values, index);
676
+ return next.join(',') === this.value ? null : index;
677
+ }
678
+
679
+ /** Top of the drop line, in the selected list wrapper's scrolled coordinates. */
680
+ private dropLineTop(index: number): number {
681
+ const wrapper = this.selectedWrapper;
682
+ const shown = this.shownSelectedOptions();
683
+ if (!wrapper || !shown.length) return 0;
684
+ const origin = wrapper.getBoundingClientRect().top - wrapper.scrollTop;
685
+ if (index < shown.length) {
686
+ return shown[index].getBoundingClientRect().top - origin;
687
+ }
688
+ return shown[shown.length - 1].getBoundingClientRect().bottom - origin;
689
+ }
690
+
691
+ private handleDragPointerDown(value: string, event: PointerEvent) {
692
+ if (!this.canDrag || event.button !== 0 || this.dragSession) return;
693
+ // Keep the press from reaching the listbox, which would focus or check the item.
694
+ event.preventDefault();
695
+ event.stopPropagation();
696
+ const handle = event.currentTarget as Element;
697
+ this.dragSession = {
698
+ pointerId: event.pointerId,
699
+ handle,
700
+ startX: event.clientX,
701
+ startY: event.clientY,
702
+ values: this.dragGroup(value),
703
+ active: false,
704
+ clientX: event.clientX,
705
+ clientY: event.clientY,
706
+ };
707
+ try {
708
+ handle.setPointerCapture(event.pointerId);
709
+ } catch {
710
+ // The pointer is gone already; the window listeners still end the drag.
711
+ }
712
+ window.addEventListener('pointermove', this.handleDragPointerMove);
713
+ window.addEventListener('pointerup', this.handleDragPointerUp);
714
+ window.addEventListener('pointercancel', this.handleDragPointerCancel);
715
+ window.addEventListener('keydown', this.handleDragKeyDown, true);
716
+ }
717
+
718
+ private readonly handleDragPointerMove = (event: PointerEvent) => {
719
+ const session = this.dragSession;
720
+ if (!session || event.pointerId !== session.pointerId) return;
721
+ session.clientX = event.clientX;
722
+ session.clientY = event.clientY;
723
+ if (!session.active) {
724
+ const travel = Math.hypot(
725
+ event.clientX - session.startX,
726
+ event.clientY - session.startY,
727
+ );
728
+ if (travel < DRAG_THRESHOLD) return;
729
+ session.active = true;
730
+ this.dragValues = [...session.values];
731
+ }
732
+ event.preventDefault();
733
+ this.updateDragPosition();
734
+ this.startAutoScroll();
735
+ };
736
+
737
+ private readonly handleDragPointerUp = (event: PointerEvent) => {
738
+ const session = this.dragSession;
739
+ if (!session || event.pointerId !== session.pointerId) return;
740
+ session.clientX = event.clientX;
741
+ session.clientY = event.clientY;
742
+ if (session.active) this.updateDragPosition();
743
+ this.endDrag(session.active);
744
+ };
745
+
746
+ private readonly handleDragPointerCancel = (event: PointerEvent) => {
747
+ if (event.pointerId === this.dragSession?.pointerId) this.endDrag(false);
748
+ };
749
+
750
+ private readonly handleDragKeyDown = (event: KeyboardEvent) => {
751
+ if (event.key !== 'Escape' || !this.dragSession) return;
752
+ event.preventDefault();
753
+ event.stopPropagation();
754
+ this.endDrag(false);
755
+ };
756
+
757
+ private updateDragPosition() {
758
+ const session = this.dragSession;
759
+ const pane = this.selectedWrapper?.parentElement;
760
+ if (!session || !pane) return;
761
+ const box = pane.getBoundingClientRect();
762
+ this.dragPoint = {
763
+ x: session.clientX - box.left,
764
+ y: session.clientY - box.top,
765
+ };
766
+ this.dropIndex = this.dropIndexAt(session.clientX, session.clientY);
767
+ }
768
+
769
+ /** Scrolls the selected list while a drag is near its top or bottom edge. */
770
+ private startAutoScroll() {
771
+ if (this.autoScrollFrame) return;
772
+ const step = () => {
773
+ this.autoScrollFrame = 0;
774
+ const session = this.dragSession;
775
+ const wrapper = this.selectedWrapper;
776
+ if (!session?.active || !wrapper) return;
777
+ const box = wrapper.getBoundingClientRect();
778
+ if (session.clientX < box.left || session.clientX > box.right) return;
779
+ let delta = 0;
780
+ if (session.clientY < box.top + AUTO_SCROLL_EDGE) {
781
+ delta = -Math.min(
782
+ AUTO_SCROLL_SPEED,
783
+ AUTO_SCROLL_EDGE - (session.clientY - box.top),
784
+ );
785
+ } else if (session.clientY > box.bottom - AUTO_SCROLL_EDGE) {
786
+ delta = Math.min(
787
+ AUTO_SCROLL_SPEED,
788
+ AUTO_SCROLL_EDGE - (box.bottom - session.clientY),
789
+ );
790
+ }
791
+ if (!delta) return;
792
+ const before = wrapper.scrollTop;
793
+ wrapper.scrollTop += delta;
794
+ if (wrapper.scrollTop === before) return;
795
+ this.updateDragPosition();
796
+ this.autoScrollFrame = requestAnimationFrame(step);
797
+ };
798
+ this.autoScrollFrame = requestAnimationFrame(step);
799
+ }
800
+
801
+ /** Ends the drag; drops the items when `drop` is set and the pointer is over a drop place. */
802
+ private endDrag(drop: boolean) {
803
+ const session = this.dragSession;
804
+ window.removeEventListener('pointermove', this.handleDragPointerMove);
805
+ window.removeEventListener('pointerup', this.handleDragPointerUp);
806
+ window.removeEventListener('pointercancel', this.handleDragPointerCancel);
807
+ window.removeEventListener('keydown', this.handleDragKeyDown, true);
808
+ if (this.autoScrollFrame) cancelAnimationFrame(this.autoScrollFrame);
809
+ this.autoScrollFrame = 0;
810
+ if (!session) return;
811
+ this.dragSession = undefined;
812
+ try {
813
+ if (session.handle.hasPointerCapture(session.pointerId)) {
814
+ session.handle.releasePointerCapture(session.pointerId);
815
+ }
816
+ } catch {
817
+ // Capture was never taken.
818
+ }
819
+ if (session.active) {
820
+ // The release fires a click on the item; it ends the drag, it does not check.
821
+ this.suppressClick = true;
822
+ setTimeout(() => {
823
+ this.suppressClick = false;
824
+ });
825
+ }
826
+ const index = this.dropIndex;
827
+ this.dragValues = [];
828
+ this.dropIndex = null;
829
+ if (drop && index !== null) this.dropAt(session.values, index);
830
+ }
831
+
832
+ private dropAt(moving: string[], index: number) {
833
+ if (!this.isInteractive || !this.ordered) return;
834
+ const next = this.orderAfterDrop(moving, index);
835
+ if (next.join(',') === this.value) return;
836
+ const position = this.formatCount(next.indexOf(moving[0]) + 1);
837
+ let message: string;
838
+ if (moving.length === 1) {
839
+ const option = this.options.find(o => o.value === moving[0]);
840
+ message = this.i18n.t('transferListPosition')(
841
+ option?.label ?? moving[0],
842
+ position,
843
+ this.formatCount(next.length),
844
+ );
845
+ } else {
846
+ message = this.i18n.t('transferListMovedToPosition')(
847
+ this.formatCount(moving.length),
848
+ position,
849
+ );
850
+ }
851
+ this.commit(next, message);
852
+ this.refocusValue(moving[0]);
853
+ }
854
+
855
+ private handleListClickCapture(event: MouseEvent) {
856
+ if (!this.suppressClick) return;
857
+ this.suppressClick = false;
858
+ event.preventDefault();
859
+ event.stopPropagation();
860
+ }
861
+
563
862
  // ── Render helpers ───────────────────────────────────────────────────────
564
863
 
864
+ private renderDragHandle(option: TransferListOption) {
865
+ if (!this.canDrag || option.disabled) return nothing;
866
+ return html`<wc-icon
867
+ slot="start"
868
+ class="drag-handle"
869
+ name="drag_indicator"
870
+ aria-hidden="true"
871
+ title=${this.i18n.t('dragToReorder')}
872
+ @pointerdown=${(event: PointerEvent) =>
873
+ this.handleDragPointerDown(option.value, event)}
874
+ ></wc-icon>`;
875
+ }
876
+
877
+ /** The drop line, inside the scrolling list so it moves with the items. */
878
+ private renderDropIndicator() {
879
+ if (!this.dragValues.length || this.dropIndex === null) return nothing;
880
+ return html`<div
881
+ class="drop-indicator"
882
+ style=${`top: ${this.dropLineTop(this.dropIndex)}px`}
883
+ ></div>`;
884
+ }
885
+
886
+ /**
887
+ * The lifted copy under the pointer. It sits in the pane, outside the scrolling list, so it
888
+ * never grows the list's scroll area while auto-scroll runs.
889
+ */
890
+ private renderDragPreview() {
891
+ if (!this.dragValues.length) return nothing;
892
+ const first = this.options.find(o => o.value === this.dragValues[0]);
893
+ const count = this.dragValues.length;
894
+ return html`<div
895
+ class="drag-preview"
896
+ aria-hidden="true"
897
+ style=${`left: ${this.dragPoint.x}px; top: ${this.dragPoint.y}px`}
898
+ >
899
+ <wc-icon class="drag-preview-icon" name="drag_indicator"></wc-icon>
900
+ <span class="drag-preview-label"
901
+ >${first?.label ?? this.dragValues[0]}</span
902
+ >
903
+ ${count > 1
904
+ ? html`<span class="drag-count">${this.formatCount(count)}</span>`
905
+ : nothing}
906
+ </div>`;
907
+ }
908
+
565
909
  private renderOption(option: TransferListOption, side: Side) {
910
+ const draggable = side === 'selected';
566
911
  return html`<wc-listbox-option
567
912
  value=${option.value}
913
+ class=${classMap({
914
+ dragging: draggable && this.dragValues.includes(option.value),
915
+ })}
568
916
  ?disabled=${!!option.disabled}
569
917
  ?hidden=${!this.matchesSearch(option, side)}
570
- >${option.label}${option.description
918
+ >${draggable
919
+ ? this.renderDragHandle(option)
920
+ : nothing}${option.label}${option.description
571
921
  ? html`<span slot="supporting-text">${option.description}</span>`
572
922
  : nothing}</wc-listbox-option
573
923
  >`;
@@ -649,6 +999,11 @@ export class TransferList extends BaseInput {
649
999
  }}
650
1000
  @dblclick=${(event: MouseEvent) =>
651
1001
  this.handleListDblClick(side, event)}
1002
+ @click=${{
1003
+ handleEvent: (event: MouseEvent) =>
1004
+ this.handleListClickCapture(event),
1005
+ capture: true,
1006
+ }}
652
1007
  >
653
1008
  <wc-listbox
654
1009
  class=${`list list-${side}`}
@@ -667,7 +1022,9 @@ export class TransferList extends BaseInput {
667
1022
  )}
668
1023
  </wc-listbox>
669
1024
  ${this.renderEmpty(side, options)}
1025
+ ${side === 'selected' ? this.renderDropIndicator() : nothing}
670
1026
  </div>
1027
+ ${side === 'selected' ? this.renderDragPreview() : nothing}
671
1028
  </div>
672
1029
  `;
673
1030
  }