@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.
- package/dist/{BaseField-Cpcwp4yU.js → BaseField-DPyW5Zm5.js} +3 -3
- package/dist/{BaseField-Cpcwp4yU.js.map → BaseField-DPyW5Zm5.js.map} +1 -1
- package/dist/{BaseInput-E7kPUiiZ.js → BaseInput-FhjvfMjF.js} +2 -2
- package/dist/{BaseInput-E7kPUiiZ.js.map → BaseInput-FhjvfMjF.js.map} +1 -1
- package/dist/ai-badge.js +2 -2
- package/dist/ai-summary.js +2 -2
- package/dist/alert.js +2 -2
- package/dist/anchor-nav.js +2 -2
- package/dist/app-shell.js +2 -2
- package/dist/assistant-panel.js +2 -2
- package/dist/assistant-step.js +2 -2
- package/dist/assistant-steps.js +2 -2
- package/dist/avatar-group.js +2 -2
- package/dist/banner.js +2 -2
- package/dist/{base-progress-DDWoywDO.js → base-progress-D8-x6XS4.js} +2 -2
- package/dist/{base-progress-DDWoywDO.js.map → base-progress-D8-x6XS4.js.map} +1 -1
- package/dist/bottom-sheet.js +2 -2
- package/dist/breadcrumb.js +2 -2
- package/dist/calendar.js +2 -2
- package/dist/{canvas-base-Cyo5f6KN.js → canvas-base-CjxNdEsR.js} +2 -2
- package/dist/{canvas-base-Cyo5f6KN.js.map → canvas-base-CjxNdEsR.js.map} +1 -1
- package/dist/carousel.js +2 -2
- package/dist/{cartesian-chart-CO5Vrevp.js → cartesian-chart-D30aTNVm.js} +2 -2
- package/dist/{cartesian-chart-CO5Vrevp.js.map → cartesian-chart-D30aTNVm.js.map} +1 -1
- package/dist/{cb-group-base-C2N3ohXb.js → cb-group-base-Crt0BSzR.js} +2 -2
- package/dist/{cb-group-base-C2N3ohXb.js.map → cb-group-base-Crt0BSzR.js.map} +1 -1
- package/dist/cb-group.js +3 -3
- package/dist/cb-rule.js +3 -3
- package/dist/chart-area.js +4 -4
- package/dist/chart-bar.js +4 -4
- package/dist/{chart-base-C8oWNR3Q.js → chart-base-D2kPte5J.js} +2 -2
- package/dist/{chart-base-C8oWNR3Q.js.map → chart-base-D2kPte5J.js.map} +1 -1
- package/dist/chart-doughnut.js +3 -3
- package/dist/chart-line.js +4 -4
- package/dist/chart-pie.js +3 -3
- package/dist/chat-event.js +2 -2
- package/dist/chat-message.js +2 -2
- package/dist/chat-thread.js +2 -2
- package/dist/checkbox-group.js +3 -3
- package/dist/checkbox.js +3 -3
- package/dist/chip-set.js +2 -2
- package/dist/chip.js +2 -2
- package/dist/circular-progress.js +3 -3
- package/dist/citation.js +2 -2
- package/dist/code-editor.js +3 -3
- package/dist/code-highlighter.js +2 -2
- package/dist/color-field.js +4 -4
- package/dist/color-picker.js +2 -2
- package/dist/command-palette.js +2 -2
- package/dist/comment-composer.js +4 -4
- package/dist/condition-builder.js +3 -3
- package/dist/confirm-dialog.js +2 -2
- package/dist/copy-button.js +2 -2
- package/dist/currency-field.js +4 -4
- package/dist/custom-elements-jsdocs.json +1 -1
- package/dist/custom-elements.json +302 -1
- package/dist/date-field.js +5 -5
- package/dist/date-picker.js +2 -2
- package/dist/date-range-field.js +5 -5
- package/dist/datetime-field.js +5 -5
- package/dist/dependency-map.js +3 -3
- package/dist/description-item.js +2 -2
- package/dist/description-list.js +2 -2
- package/dist/{diagram-BT-BZLZf.js → diagram-BFGq2POp.js} +2 -2
- package/dist/{diagram-BT-BZLZf.js.map → diagram-BFGq2POp.js.map} +1 -1
- package/dist/diagram-controls.js +2 -2
- package/dist/diagram-minimap.js +2 -2
- package/dist/diagram.js +4 -4
- package/dist/diff-viewer.js +2 -2
- package/dist/discussion-activity.js +2 -2
- package/dist/discussion-comment.js +2 -2
- package/dist/discussion.js +4 -4
- package/dist/{document-editor-B4ePud1R.js → document-editor-CC7MTHMO.js} +2 -2
- package/dist/{document-editor-B4ePud1R.js.map → document-editor-CC7MTHMO.js.map} +1 -1
- package/dist/document-editor.js +3 -3
- package/dist/draft-card.js +2 -2
- package/dist/erd.js +3 -3
- package/dist/file-upload.js +3 -3
- package/dist/filter-bar.js +2 -2
- package/dist/flow.js +4 -4
- package/dist/form.js +2 -2
- package/dist/{generative-view-xGY15iNe.js → generative-view-DoT9YwHL.js} +2 -2
- package/dist/{generative-view-xGY15iNe.js.map → generative-view-DoT9YwHL.js.map} +1 -1
- package/dist/generative-view.js +3 -3
- package/dist/html-editor.js +4 -4
- package/dist/{i18n-controller-D6HbL-Ru.js → i18n-controller-Co6pasNo.js} +2 -2
- package/dist/{i18n-controller-D6HbL-Ru.js.map → i18n-controller-Co6pasNo.js.map} +1 -1
- package/dist/image.js +2 -2
- package/dist/index.js +17 -17
- package/dist/inline-edit.js +2 -2
- package/dist/input.js +3 -3
- package/dist/json-viewer.js +2 -2
- package/dist/kanban.js +2 -2
- package/dist/kbd.js +2 -2
- package/dist/linear-progress.js +3 -3
- package/dist/listbox.js +2 -2
- package/dist/loader-full.js +10 -10
- package/dist/loader.js +10 -10
- package/dist/markdown-editor.js +4 -4
- package/dist/mention-input.js +4 -4
- package/dist/modal.js +2 -2
- package/dist/navigation-bar.js +2 -2
- package/dist/navigation-drawer.js +2 -2
- package/dist/navigation-rail.js +2 -2
- package/dist/notification-center.js +2 -2
- package/dist/number-field.js +4 -4
- package/dist/page-header.js +2 -2
- package/dist/pagination.js +2 -2
- package/dist/password-field.js +4 -4
- package/dist/password-rules.js +2 -2
- package/dist/phone-field.js +4 -4
- package/dist/{picker-field-DJkGHGLP.js → picker-field-BliKNENo.js} +3 -3
- package/dist/{picker-field-DJkGHGLP.js.map → picker-field-BliKNENo.js.map} +1 -1
- package/dist/pin-input.js +4 -4
- package/dist/presence-indicator.js +2 -2
- package/dist/prompt-input.js +4 -4
- package/dist/radio.js +3 -3
- package/dist/rating.js +3 -3
- package/dist/redvars-loader.js +2 -2
- package/dist/relative-time.js +2 -2
- package/dist/resizable-panels.js +2 -2
- package/dist/{rich-text-input-BFZN9JqO.js → rich-text-input-YeqK1or-.js} +3 -3
- package/dist/{rich-text-input-BFZN9JqO.js.map → rich-text-input-YeqK1or-.js.map} +1 -1
- package/dist/{schema-D-luMxHL.js → schema-CuHBNpzo.js} +2 -2
- package/dist/{schema-D-luMxHL.js.map → schema-CuHBNpzo.js.map} +1 -1
- package/dist/search.js +3 -3
- package/dist/select.js +4 -4
- package/dist/side-sheet.js +2 -2
- package/dist/signature-pad.js +3 -3
- package/dist/site-header.js +2 -2
- package/dist/slider.js +3 -3
- package/dist/snackbar.js +2 -2
- package/dist/sparkline.js +2 -2
- package/dist/split-button.js +2 -2
- package/dist/src/__internal/i18n/strings.d.ts +2 -0
- package/dist/src/transfer-list/transfer-list.d.ts +49 -1
- package/dist/stat.js +2 -2
- package/dist/status-indicator.js +2 -2
- package/dist/step.js +2 -2
- package/dist/stepper.js +2 -2
- package/dist/{strings-CXI3T-AI.js → strings-DYwXSSu_.js} +3 -1
- package/dist/strings-DYwXSSu_.js.map +1 -0
- package/dist/svg.js +2 -2
- package/dist/switch.js +3 -3
- package/dist/table.js +2 -2
- package/dist/textarea.js +4 -4
- package/dist/time-field.js +5 -5
- package/dist/time-picker.js +2 -2
- package/dist/timeline-item.js +2 -2
- package/dist/timeline.js +2 -2
- package/dist/{toggle-base-B05ckmj_.js → toggle-base-B-HOnUIy.js} +2 -2
- package/dist/{toggle-base-B05ckmj_.js.map → toggle-base-B-HOnUIy.js.map} +1 -1
- package/dist/tour.js +2 -2
- package/dist/transfer-list.js +427 -6
- package/dist/transfer-list.js.map +1 -1
- package/dist/tree-chart.js +3 -3
- package/dist/tree-item.js +2 -2
- package/dist/tree.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing-indicator.js +2 -2
- package/dist/url-field.js +4 -4
- package/dist/user-menu.js +2 -2
- package/dist/{video-CZJ4TypQ.js → video-u-Vs7M9g.js} +2 -2
- package/dist/{video-CZJ4TypQ.js.map → video-u-Vs7M9g.js.map} +1 -1
- package/dist/video.js +3 -3
- package/dist/virtual-list.js +2 -2
- package/dist/workflow-timeline.js +2 -2
- package/dist/workflow.js +3 -3
- package/dist/workspace-switcher.js +2 -2
- package/package.json +1 -1
- package/src/__internal/i18n/strings.ts +3 -0
- package/src/transfer-list/transfer-list.scss +95 -1
- package/src/transfer-list/transfer-list.ts +359 -2
- package/dist/strings-CXI3T-AI.js.map +0 -1
package/dist/transfer-list.js
CHANGED
|
@@ -5,13 +5,13 @@ import { e } from './query-CHb9Ft_d.js';
|
|
|
5
5
|
import { e as e$1 } from './class-map-NDIkZErE.js';
|
|
6
6
|
import { l } from './live-D_5OfuGD.js';
|
|
7
7
|
import { c } from './repeat-D_ERDRYT.js';
|
|
8
|
-
import { I as I18nController } from './i18n-controller-
|
|
8
|
+
import { I as I18nController } from './i18n-controller-Co6pasNo.js';
|
|
9
9
|
import { g as getFormValue } from './form-associated-BHbg72PG.js';
|
|
10
|
-
import { B as BaseInput } from './BaseInput-
|
|
10
|
+
import { B as BaseInput } from './BaseInput-FhjvfMjF.js';
|
|
11
11
|
import './base-Cl6v8-BZ.js';
|
|
12
12
|
import './directive-ZPhl09Yt.js';
|
|
13
13
|
import './directive-helpers-Bx3mu42O.js';
|
|
14
|
-
import './strings-
|
|
14
|
+
import './strings-DYwXSSu_.js';
|
|
15
15
|
import './locale-DEsJZCQG.js';
|
|
16
16
|
import './element-internals-QME0yEz4.js';
|
|
17
17
|
import './suggestion-controller-7YRQqkaI.js';
|
|
@@ -101,6 +101,7 @@ var css_248z = i`* {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
.pane {
|
|
104
|
+
position: relative;
|
|
104
105
|
display: flex;
|
|
105
106
|
flex-direction: column;
|
|
106
107
|
min-inline-size: 0;
|
|
@@ -144,7 +145,7 @@ var css_248z = i`* {
|
|
|
144
145
|
|
|
145
146
|
.list-wrapper {
|
|
146
147
|
position: relative;
|
|
147
|
-
flex: 1;
|
|
148
|
+
flex: 1 0 auto;
|
|
148
149
|
block-size: var(--_list-block-size);
|
|
149
150
|
overflow-y: auto;
|
|
150
151
|
}
|
|
@@ -159,6 +160,95 @@ var css_248z = i`* {
|
|
|
159
160
|
background: transparent;
|
|
160
161
|
}
|
|
161
162
|
|
|
163
|
+
.drag-handle {
|
|
164
|
+
--icon-size: 1.25rem;
|
|
165
|
+
--icon-color: currentColor;
|
|
166
|
+
flex: none;
|
|
167
|
+
color: var(--color-on-surface-variant);
|
|
168
|
+
cursor: grab;
|
|
169
|
+
touch-action: none;
|
|
170
|
+
}
|
|
171
|
+
.drag-handle:hover {
|
|
172
|
+
color: var(--color-on-surface);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
wc-listbox-option.dragging {
|
|
176
|
+
opacity: 0.38;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.drop-indicator {
|
|
180
|
+
position: absolute;
|
|
181
|
+
inset-inline: var(--spacing-100);
|
|
182
|
+
block-size: 0.125rem;
|
|
183
|
+
margin-block-start: -0.0625rem;
|
|
184
|
+
border-radius: var(--shape-corner-full);
|
|
185
|
+
background-color: var(--color-primary);
|
|
186
|
+
pointer-events: none;
|
|
187
|
+
}
|
|
188
|
+
.drop-indicator::before {
|
|
189
|
+
content: "";
|
|
190
|
+
position: absolute;
|
|
191
|
+
inset-inline-start: -0.25rem;
|
|
192
|
+
inset-block-start: -0.1875rem;
|
|
193
|
+
inline-size: 0.5rem;
|
|
194
|
+
block-size: 0.5rem;
|
|
195
|
+
border-radius: var(--shape-corner-full);
|
|
196
|
+
background-color: var(--color-primary);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.drag-preview {
|
|
200
|
+
font-family: var(--typography-body-large-font-family) !important;
|
|
201
|
+
font-size: var(--typography-body-large-font-size) !important;
|
|
202
|
+
font-weight: var(--typography-body-large-font-weight) !important;
|
|
203
|
+
line-height: var(--typography-body-large-line-height) !important;
|
|
204
|
+
letter-spacing: var(--typography-body-large-letter-spacing) !important;
|
|
205
|
+
position: absolute;
|
|
206
|
+
z-index: 1;
|
|
207
|
+
display: flex;
|
|
208
|
+
align-items: center;
|
|
209
|
+
gap: var(--spacing-100);
|
|
210
|
+
max-inline-size: 70%;
|
|
211
|
+
padding: var(--spacing-100) var(--spacing-150);
|
|
212
|
+
transform: translate(calc(-1 * (var(--spacing-150) + 0.625rem)), -50%);
|
|
213
|
+
border-radius: var(--shape-corner-small);
|
|
214
|
+
background-color: var(--color-surface-container-high);
|
|
215
|
+
box-shadow: var(--elevation-level2);
|
|
216
|
+
color: var(--color-on-surface);
|
|
217
|
+
cursor: grabbing;
|
|
218
|
+
pointer-events: none;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.drag-preview-icon {
|
|
222
|
+
--icon-size: 1.25rem;
|
|
223
|
+
--icon-color: currentColor;
|
|
224
|
+
flex: none;
|
|
225
|
+
color: var(--color-on-surface-variant);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.drag-preview-label {
|
|
229
|
+
overflow: hidden;
|
|
230
|
+
white-space: nowrap;
|
|
231
|
+
text-overflow: ellipsis;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.drag-count {
|
|
235
|
+
font-family: var(--typography-label-small-font-family) !important;
|
|
236
|
+
font-size: var(--typography-label-small-font-size) !important;
|
|
237
|
+
font-weight: var(--typography-label-small-font-weight) !important;
|
|
238
|
+
line-height: var(--typography-label-small-line-height) !important;
|
|
239
|
+
letter-spacing: var(--typography-label-small-letter-spacing) !important;
|
|
240
|
+
position: absolute;
|
|
241
|
+
inset-inline-end: -0.5rem;
|
|
242
|
+
inset-block-start: -0.5rem;
|
|
243
|
+
min-inline-size: 1.25rem;
|
|
244
|
+
padding-inline: var(--spacing-050);
|
|
245
|
+
border-radius: var(--shape-corner-full);
|
|
246
|
+
background-color: var(--color-primary);
|
|
247
|
+
color: var(--color-on-primary);
|
|
248
|
+
text-align: center;
|
|
249
|
+
line-height: 1.25rem;
|
|
250
|
+
}
|
|
251
|
+
|
|
162
252
|
.empty {
|
|
163
253
|
font-family: var(--typography-body-medium-font-family) !important;
|
|
164
254
|
font-size: var(--typography-body-medium-font-size) !important;
|
|
@@ -229,6 +319,12 @@ var css_248z = i`* {
|
|
|
229
319
|
}
|
|
230
320
|
}`;
|
|
231
321
|
|
|
322
|
+
/** Pointer travel in pixels before a handle press becomes a drag. */
|
|
323
|
+
const DRAG_THRESHOLD = 4;
|
|
324
|
+
/** Distance in pixels from a list edge at which a drag scrolls the list. */
|
|
325
|
+
const AUTO_SCROLL_EDGE = 24;
|
|
326
|
+
/** Pixels a drag scrolls the list per frame at the very edge. */
|
|
327
|
+
const AUTO_SCROLL_SPEED = 12;
|
|
232
328
|
function isListboxOption(node) {
|
|
233
329
|
return node instanceof Element && node.localName === 'wc-listbox-option';
|
|
234
330
|
}
|
|
@@ -255,7 +351,9 @@ let transferListCount = 0;
|
|
|
255
351
|
* <p>Without <code>ordered</code> the value keeps the order of <code>options</code>. With
|
|
256
352
|
* <code>ordered</code> the selected list keeps the person's order: moved items join at the end,
|
|
257
353
|
* the Move up and Move down buttons move the checked items, and Alt+Up and Alt+Down move the
|
|
258
|
-
* focused one
|
|
354
|
+
* focused one. Each selected item also gets a drag handle: dragging it moves the item, or all
|
|
355
|
+
* checked items when it is checked, to where the drop line shows. Escape or a release outside
|
|
356
|
+
* the list cancels the drag.</p>
|
|
259
357
|
* <p>The value follows <code>wc-listbox multiple</code>: <code>value</code> is a comma-separated
|
|
260
358
|
* list (so option values must not contain commas) and <code>values</code> the same as an array.
|
|
261
359
|
* Inside a <code><form></code> each value is submitted under <code>name</code>;
|
|
@@ -325,12 +423,64 @@ let TransferList = class TransferList extends BaseInput {
|
|
|
325
423
|
this.selectedQuery = '';
|
|
326
424
|
/** Text of the polite live region. */
|
|
327
425
|
this.announcement = '';
|
|
426
|
+
/** The values being dragged in the selected list; empty while no drag is active. */
|
|
427
|
+
this.dragValues = [];
|
|
428
|
+
/** Where a drag would drop, as an index among the shown selected items; `null` for nowhere. */
|
|
429
|
+
this.dropIndex = null;
|
|
430
|
+
/** Pointer position inside the selected list wrapper, for the dragged copy. */
|
|
431
|
+
this.dragPoint = { x: 0, y: 0 };
|
|
328
432
|
// ── Private fields ───────────────────────────────────────────────────────
|
|
329
433
|
this.idPrefix = `wc-transfer-list-${(transferListCount += 1)}`;
|
|
330
434
|
/** Peacock's strings for the headlines, buttons and announcements. */
|
|
331
435
|
this.i18n = new I18nController(this);
|
|
436
|
+
/** Frame of the auto-scroll loop while a drag is near a list edge. */
|
|
437
|
+
this.autoScrollFrame = 0;
|
|
438
|
+
/** Swallows the click that ends a drag, so it does not also check the item. */
|
|
439
|
+
this.suppressClick = false;
|
|
440
|
+
this.handleDragPointerMove = (event) => {
|
|
441
|
+
const session = this.dragSession;
|
|
442
|
+
if (!session || event.pointerId !== session.pointerId)
|
|
443
|
+
return;
|
|
444
|
+
session.clientX = event.clientX;
|
|
445
|
+
session.clientY = event.clientY;
|
|
446
|
+
if (!session.active) {
|
|
447
|
+
const travel = Math.hypot(event.clientX - session.startX, event.clientY - session.startY);
|
|
448
|
+
if (travel < DRAG_THRESHOLD)
|
|
449
|
+
return;
|
|
450
|
+
session.active = true;
|
|
451
|
+
this.dragValues = [...session.values];
|
|
452
|
+
}
|
|
453
|
+
event.preventDefault();
|
|
454
|
+
this.updateDragPosition();
|
|
455
|
+
this.startAutoScroll();
|
|
456
|
+
};
|
|
457
|
+
this.handleDragPointerUp = (event) => {
|
|
458
|
+
const session = this.dragSession;
|
|
459
|
+
if (!session || event.pointerId !== session.pointerId)
|
|
460
|
+
return;
|
|
461
|
+
session.clientX = event.clientX;
|
|
462
|
+
session.clientY = event.clientY;
|
|
463
|
+
if (session.active)
|
|
464
|
+
this.updateDragPosition();
|
|
465
|
+
this.endDrag(session.active);
|
|
466
|
+
};
|
|
467
|
+
this.handleDragPointerCancel = (event) => {
|
|
468
|
+
if (event.pointerId === this.dragSession?.pointerId)
|
|
469
|
+
this.endDrag(false);
|
|
470
|
+
};
|
|
471
|
+
this.handleDragKeyDown = (event) => {
|
|
472
|
+
if (event.key !== 'Escape' || !this.dragSession)
|
|
473
|
+
return;
|
|
474
|
+
event.preventDefault();
|
|
475
|
+
event.stopPropagation();
|
|
476
|
+
this.endDrag(false);
|
|
477
|
+
};
|
|
332
478
|
}
|
|
333
479
|
// ── Lifecycle ────────────────────────────────────────────────────────────
|
|
480
|
+
disconnectedCallback() {
|
|
481
|
+
super.disconnectedCallback();
|
|
482
|
+
this.endDrag(false);
|
|
483
|
+
}
|
|
334
484
|
willUpdate(changed) {
|
|
335
485
|
super.willUpdate(changed);
|
|
336
486
|
if (changed.has('options') && !Array.isArray(this.options)) {
|
|
@@ -647,13 +797,266 @@ let TransferList = class TransferList extends BaseInput {
|
|
|
647
797
|
this.keepFocus(button, 'selected');
|
|
648
798
|
}
|
|
649
799
|
}
|
|
800
|
+
/** Whether selected items show a drag handle. */
|
|
801
|
+
get canDrag() {
|
|
802
|
+
return this.ordered && this.isInteractive;
|
|
803
|
+
}
|
|
804
|
+
/** The selected values a drag from `value` moves: all checked ones if it is checked. */
|
|
805
|
+
dragGroup(value) {
|
|
806
|
+
const checked = this.movableChecked('selected');
|
|
807
|
+
return checked.includes(value) ? checked : [value];
|
|
808
|
+
}
|
|
809
|
+
/** The order after moving `moving` to the drop index among the shown selected items. */
|
|
810
|
+
orderAfterDrop(moving, index) {
|
|
811
|
+
const shown = this.sideOptions('selected')
|
|
812
|
+
.filter(option => this.matchesSearch(option, 'selected'))
|
|
813
|
+
.map(option => option.value);
|
|
814
|
+
const rest = this.values.filter(value => !moving.includes(value));
|
|
815
|
+
const ordered = this.values.filter(value => moving.includes(value));
|
|
816
|
+
// Before the first shown item at or below the line that stays where it is.
|
|
817
|
+
const before = shown.slice(index).find(value => !moving.includes(value));
|
|
818
|
+
let at;
|
|
819
|
+
if (before !== undefined) {
|
|
820
|
+
at = rest.indexOf(before);
|
|
821
|
+
}
|
|
822
|
+
else {
|
|
823
|
+
// Below the last shown item, so hidden items after it keep their places.
|
|
824
|
+
const after = shown
|
|
825
|
+
.slice(0, index)
|
|
826
|
+
.reverse()
|
|
827
|
+
.find(value => !moving.includes(value));
|
|
828
|
+
at = after === undefined ? rest.length : rest.indexOf(after) + 1;
|
|
829
|
+
}
|
|
830
|
+
return [...rest.slice(0, at), ...ordered, ...rest.slice(at)];
|
|
831
|
+
}
|
|
832
|
+
/** The shown options of the selected list, in display order. */
|
|
833
|
+
shownSelectedOptions() {
|
|
834
|
+
return (this.selectedList?.options ?? []).filter(option => !option.hidden);
|
|
835
|
+
}
|
|
836
|
+
/** The drop index for a pointer at `clientY`, or `null` outside the list or for no change. */
|
|
837
|
+
dropIndexAt(clientX, clientY) {
|
|
838
|
+
const wrapper = this.selectedWrapper;
|
|
839
|
+
const session = this.dragSession;
|
|
840
|
+
if (!wrapper || !session)
|
|
841
|
+
return null;
|
|
842
|
+
const box = wrapper.getBoundingClientRect();
|
|
843
|
+
if (clientX < box.left ||
|
|
844
|
+
clientX > box.right ||
|
|
845
|
+
clientY < box.top ||
|
|
846
|
+
clientY > box.bottom) {
|
|
847
|
+
return null;
|
|
848
|
+
}
|
|
849
|
+
const shown = this.shownSelectedOptions();
|
|
850
|
+
let index = shown.length;
|
|
851
|
+
for (let i = 0; i < shown.length; i += 1) {
|
|
852
|
+
const rect = shown[i].getBoundingClientRect();
|
|
853
|
+
if (clientY < rect.top + rect.height / 2) {
|
|
854
|
+
index = i;
|
|
855
|
+
break;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
const next = this.orderAfterDrop(session.values, index);
|
|
859
|
+
return next.join(',') === this.value ? null : index;
|
|
860
|
+
}
|
|
861
|
+
/** Top of the drop line, in the selected list wrapper's scrolled coordinates. */
|
|
862
|
+
dropLineTop(index) {
|
|
863
|
+
const wrapper = this.selectedWrapper;
|
|
864
|
+
const shown = this.shownSelectedOptions();
|
|
865
|
+
if (!wrapper || !shown.length)
|
|
866
|
+
return 0;
|
|
867
|
+
const origin = wrapper.getBoundingClientRect().top - wrapper.scrollTop;
|
|
868
|
+
if (index < shown.length) {
|
|
869
|
+
return shown[index].getBoundingClientRect().top - origin;
|
|
870
|
+
}
|
|
871
|
+
return shown[shown.length - 1].getBoundingClientRect().bottom - origin;
|
|
872
|
+
}
|
|
873
|
+
handleDragPointerDown(value, event) {
|
|
874
|
+
if (!this.canDrag || event.button !== 0 || this.dragSession)
|
|
875
|
+
return;
|
|
876
|
+
// Keep the press from reaching the listbox, which would focus or check the item.
|
|
877
|
+
event.preventDefault();
|
|
878
|
+
event.stopPropagation();
|
|
879
|
+
const handle = event.currentTarget;
|
|
880
|
+
this.dragSession = {
|
|
881
|
+
pointerId: event.pointerId,
|
|
882
|
+
handle,
|
|
883
|
+
startX: event.clientX,
|
|
884
|
+
startY: event.clientY,
|
|
885
|
+
values: this.dragGroup(value),
|
|
886
|
+
active: false,
|
|
887
|
+
clientX: event.clientX,
|
|
888
|
+
clientY: event.clientY,
|
|
889
|
+
};
|
|
890
|
+
try {
|
|
891
|
+
handle.setPointerCapture(event.pointerId);
|
|
892
|
+
}
|
|
893
|
+
catch {
|
|
894
|
+
// The pointer is gone already; the window listeners still end the drag.
|
|
895
|
+
}
|
|
896
|
+
window.addEventListener('pointermove', this.handleDragPointerMove);
|
|
897
|
+
window.addEventListener('pointerup', this.handleDragPointerUp);
|
|
898
|
+
window.addEventListener('pointercancel', this.handleDragPointerCancel);
|
|
899
|
+
window.addEventListener('keydown', this.handleDragKeyDown, true);
|
|
900
|
+
}
|
|
901
|
+
updateDragPosition() {
|
|
902
|
+
const session = this.dragSession;
|
|
903
|
+
const pane = this.selectedWrapper?.parentElement;
|
|
904
|
+
if (!session || !pane)
|
|
905
|
+
return;
|
|
906
|
+
const box = pane.getBoundingClientRect();
|
|
907
|
+
this.dragPoint = {
|
|
908
|
+
x: session.clientX - box.left,
|
|
909
|
+
y: session.clientY - box.top,
|
|
910
|
+
};
|
|
911
|
+
this.dropIndex = this.dropIndexAt(session.clientX, session.clientY);
|
|
912
|
+
}
|
|
913
|
+
/** Scrolls the selected list while a drag is near its top or bottom edge. */
|
|
914
|
+
startAutoScroll() {
|
|
915
|
+
if (this.autoScrollFrame)
|
|
916
|
+
return;
|
|
917
|
+
const step = () => {
|
|
918
|
+
this.autoScrollFrame = 0;
|
|
919
|
+
const session = this.dragSession;
|
|
920
|
+
const wrapper = this.selectedWrapper;
|
|
921
|
+
if (!session?.active || !wrapper)
|
|
922
|
+
return;
|
|
923
|
+
const box = wrapper.getBoundingClientRect();
|
|
924
|
+
if (session.clientX < box.left || session.clientX > box.right)
|
|
925
|
+
return;
|
|
926
|
+
let delta = 0;
|
|
927
|
+
if (session.clientY < box.top + AUTO_SCROLL_EDGE) {
|
|
928
|
+
delta = -Math.min(AUTO_SCROLL_SPEED, AUTO_SCROLL_EDGE - (session.clientY - box.top));
|
|
929
|
+
}
|
|
930
|
+
else if (session.clientY > box.bottom - AUTO_SCROLL_EDGE) {
|
|
931
|
+
delta = Math.min(AUTO_SCROLL_SPEED, AUTO_SCROLL_EDGE - (box.bottom - session.clientY));
|
|
932
|
+
}
|
|
933
|
+
if (!delta)
|
|
934
|
+
return;
|
|
935
|
+
const before = wrapper.scrollTop;
|
|
936
|
+
wrapper.scrollTop += delta;
|
|
937
|
+
if (wrapper.scrollTop === before)
|
|
938
|
+
return;
|
|
939
|
+
this.updateDragPosition();
|
|
940
|
+
this.autoScrollFrame = requestAnimationFrame(step);
|
|
941
|
+
};
|
|
942
|
+
this.autoScrollFrame = requestAnimationFrame(step);
|
|
943
|
+
}
|
|
944
|
+
/** Ends the drag; drops the items when `drop` is set and the pointer is over a drop place. */
|
|
945
|
+
endDrag(drop) {
|
|
946
|
+
const session = this.dragSession;
|
|
947
|
+
window.removeEventListener('pointermove', this.handleDragPointerMove);
|
|
948
|
+
window.removeEventListener('pointerup', this.handleDragPointerUp);
|
|
949
|
+
window.removeEventListener('pointercancel', this.handleDragPointerCancel);
|
|
950
|
+
window.removeEventListener('keydown', this.handleDragKeyDown, true);
|
|
951
|
+
if (this.autoScrollFrame)
|
|
952
|
+
cancelAnimationFrame(this.autoScrollFrame);
|
|
953
|
+
this.autoScrollFrame = 0;
|
|
954
|
+
if (!session)
|
|
955
|
+
return;
|
|
956
|
+
this.dragSession = undefined;
|
|
957
|
+
try {
|
|
958
|
+
if (session.handle.hasPointerCapture(session.pointerId)) {
|
|
959
|
+
session.handle.releasePointerCapture(session.pointerId);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
catch {
|
|
963
|
+
// Capture was never taken.
|
|
964
|
+
}
|
|
965
|
+
if (session.active) {
|
|
966
|
+
// The release fires a click on the item; it ends the drag, it does not check.
|
|
967
|
+
this.suppressClick = true;
|
|
968
|
+
setTimeout(() => {
|
|
969
|
+
this.suppressClick = false;
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
const index = this.dropIndex;
|
|
973
|
+
this.dragValues = [];
|
|
974
|
+
this.dropIndex = null;
|
|
975
|
+
if (drop && index !== null)
|
|
976
|
+
this.dropAt(session.values, index);
|
|
977
|
+
}
|
|
978
|
+
dropAt(moving, index) {
|
|
979
|
+
if (!this.isInteractive || !this.ordered)
|
|
980
|
+
return;
|
|
981
|
+
const next = this.orderAfterDrop(moving, index);
|
|
982
|
+
if (next.join(',') === this.value)
|
|
983
|
+
return;
|
|
984
|
+
const position = this.formatCount(next.indexOf(moving[0]) + 1);
|
|
985
|
+
let message;
|
|
986
|
+
if (moving.length === 1) {
|
|
987
|
+
const option = this.options.find(o => o.value === moving[0]);
|
|
988
|
+
message = this.i18n.t('transferListPosition')(option?.label ?? moving[0], position, this.formatCount(next.length));
|
|
989
|
+
}
|
|
990
|
+
else {
|
|
991
|
+
message = this.i18n.t('transferListMovedToPosition')(this.formatCount(moving.length), position);
|
|
992
|
+
}
|
|
993
|
+
this.commit(next, message);
|
|
994
|
+
this.refocusValue(moving[0]);
|
|
995
|
+
}
|
|
996
|
+
handleListClickCapture(event) {
|
|
997
|
+
if (!this.suppressClick)
|
|
998
|
+
return;
|
|
999
|
+
this.suppressClick = false;
|
|
1000
|
+
event.preventDefault();
|
|
1001
|
+
event.stopPropagation();
|
|
1002
|
+
}
|
|
650
1003
|
// ── Render helpers ───────────────────────────────────────────────────────
|
|
1004
|
+
renderDragHandle(option) {
|
|
1005
|
+
if (!this.canDrag || option.disabled)
|
|
1006
|
+
return A;
|
|
1007
|
+
return b `<wc-icon
|
|
1008
|
+
slot="start"
|
|
1009
|
+
class="drag-handle"
|
|
1010
|
+
name="drag_indicator"
|
|
1011
|
+
aria-hidden="true"
|
|
1012
|
+
title=${this.i18n.t('dragToReorder')}
|
|
1013
|
+
@pointerdown=${(event) => this.handleDragPointerDown(option.value, event)}
|
|
1014
|
+
></wc-icon>`;
|
|
1015
|
+
}
|
|
1016
|
+
/** The drop line, inside the scrolling list so it moves with the items. */
|
|
1017
|
+
renderDropIndicator() {
|
|
1018
|
+
if (!this.dragValues.length || this.dropIndex === null)
|
|
1019
|
+
return A;
|
|
1020
|
+
return b `<div
|
|
1021
|
+
class="drop-indicator"
|
|
1022
|
+
style=${`top: ${this.dropLineTop(this.dropIndex)}px`}
|
|
1023
|
+
></div>`;
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* The lifted copy under the pointer. It sits in the pane, outside the scrolling list, so it
|
|
1027
|
+
* never grows the list's scroll area while auto-scroll runs.
|
|
1028
|
+
*/
|
|
1029
|
+
renderDragPreview() {
|
|
1030
|
+
if (!this.dragValues.length)
|
|
1031
|
+
return A;
|
|
1032
|
+
const first = this.options.find(o => o.value === this.dragValues[0]);
|
|
1033
|
+
const count = this.dragValues.length;
|
|
1034
|
+
return b `<div
|
|
1035
|
+
class="drag-preview"
|
|
1036
|
+
aria-hidden="true"
|
|
1037
|
+
style=${`left: ${this.dragPoint.x}px; top: ${this.dragPoint.y}px`}
|
|
1038
|
+
>
|
|
1039
|
+
<wc-icon class="drag-preview-icon" name="drag_indicator"></wc-icon>
|
|
1040
|
+
<span class="drag-preview-label"
|
|
1041
|
+
>${first?.label ?? this.dragValues[0]}</span
|
|
1042
|
+
>
|
|
1043
|
+
${count > 1
|
|
1044
|
+
? b `<span class="drag-count">${this.formatCount(count)}</span>`
|
|
1045
|
+
: A}
|
|
1046
|
+
</div>`;
|
|
1047
|
+
}
|
|
651
1048
|
renderOption(option, side) {
|
|
1049
|
+
const draggable = side === 'selected';
|
|
652
1050
|
return b `<wc-listbox-option
|
|
653
1051
|
value=${option.value}
|
|
1052
|
+
class=${e$1({
|
|
1053
|
+
dragging: draggable && this.dragValues.includes(option.value),
|
|
1054
|
+
})}
|
|
654
1055
|
?disabled=${!!option.disabled}
|
|
655
1056
|
?hidden=${!this.matchesSearch(option, side)}
|
|
656
|
-
>${
|
|
1057
|
+
>${draggable
|
|
1058
|
+
? this.renderDragHandle(option)
|
|
1059
|
+
: A}${option.label}${option.description
|
|
657
1060
|
? b `<span slot="supporting-text">${option.description}</span>`
|
|
658
1061
|
: A}</wc-listbox-option
|
|
659
1062
|
>`;
|
|
@@ -726,6 +1129,10 @@ let TransferList = class TransferList extends BaseInput {
|
|
|
726
1129
|
capture: true,
|
|
727
1130
|
}}
|
|
728
1131
|
@dblclick=${(event) => this.handleListDblClick(side, event)}
|
|
1132
|
+
@click=${{
|
|
1133
|
+
handleEvent: (event) => this.handleListClickCapture(event),
|
|
1134
|
+
capture: true,
|
|
1135
|
+
}}
|
|
729
1136
|
>
|
|
730
1137
|
<wc-listbox
|
|
731
1138
|
class=${`list list-${side}`}
|
|
@@ -739,7 +1146,9 @@ let TransferList = class TransferList extends BaseInput {
|
|
|
739
1146
|
${c(options, option => option.value, option => this.renderOption(option, side))}
|
|
740
1147
|
</wc-listbox>
|
|
741
1148
|
${this.renderEmpty(side, options)}
|
|
1149
|
+
${side === 'selected' ? this.renderDropIndicator() : A}
|
|
742
1150
|
</div>
|
|
1151
|
+
${side === 'selected' ? this.renderDragPreview() : A}
|
|
743
1152
|
</div>
|
|
744
1153
|
`;
|
|
745
1154
|
}
|
|
@@ -853,12 +1262,24 @@ __decorate([
|
|
|
853
1262
|
__decorate([
|
|
854
1263
|
r()
|
|
855
1264
|
], TransferList.prototype, "announcement", void 0);
|
|
1265
|
+
__decorate([
|
|
1266
|
+
r()
|
|
1267
|
+
], TransferList.prototype, "dragValues", void 0);
|
|
1268
|
+
__decorate([
|
|
1269
|
+
r()
|
|
1270
|
+
], TransferList.prototype, "dropIndex", void 0);
|
|
1271
|
+
__decorate([
|
|
1272
|
+
r()
|
|
1273
|
+
], TransferList.prototype, "dragPoint", void 0);
|
|
856
1274
|
__decorate([
|
|
857
1275
|
e('.list-available')
|
|
858
1276
|
], TransferList.prototype, "availableList", void 0);
|
|
859
1277
|
__decorate([
|
|
860
1278
|
e('.list-selected')
|
|
861
1279
|
], TransferList.prototype, "selectedList", void 0);
|
|
1280
|
+
__decorate([
|
|
1281
|
+
e('.pane-selected .list-wrapper')
|
|
1282
|
+
], TransferList.prototype, "selectedWrapper", void 0);
|
|
862
1283
|
TransferList = __decorate([
|
|
863
1284
|
IndividualComponent
|
|
864
1285
|
], TransferList);
|