@nanoporetech-digital/components 5.1.1 → 5.1.2

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 (72) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/nano-components.cjs.js +1 -1
  4. package/dist/cjs/nano-input.cjs.entry.js +2 -2
  5. package/dist/cjs/nano-input.cjs.entry.js.map +1 -1
  6. package/dist/cjs/nano-sortable.cjs.entry.js +68 -43
  7. package/dist/cjs/nano-sortable.cjs.entry.js.map +1 -1
  8. package/dist/cjs/nano-tab-group.cjs.entry.js +2 -0
  9. package/dist/cjs/nano-tab-group.cjs.entry.js.map +1 -1
  10. package/dist/cjs/{nano-table-66318604.js → nano-table-0a720c5f.js} +8 -3
  11. package/dist/cjs/nano-table-0a720c5f.js.map +1 -0
  12. package/dist/cjs/nano-table.cjs.entry.js +1 -1
  13. package/dist/cjs/{table.worker-e102343e.js → table.worker-347d4d31.js} +2 -2
  14. package/dist/cjs/table.worker-347d4d31.js.map +1 -0
  15. package/dist/collection/components/input/input.js +2 -2
  16. package/dist/collection/components/input/input.js.map +1 -1
  17. package/dist/collection/components/sortable/sortable.js +69 -44
  18. package/dist/collection/components/sortable/sortable.js.map +1 -1
  19. package/dist/collection/components/table/table.js +28 -1
  20. package/dist/collection/components/table/table.js.map +1 -1
  21. package/dist/collection/components/tabs/tab-group.js +2 -0
  22. package/dist/collection/components/tabs/tab-group.js.map +1 -1
  23. package/dist/components/input.js +2 -2
  24. package/dist/components/input.js.map +1 -1
  25. package/dist/components/nano-sortable.js +68 -43
  26. package/dist/components/nano-sortable.js.map +1 -1
  27. package/dist/components/nano-tab-group.js +2 -0
  28. package/dist/components/nano-tab-group.js.map +1 -1
  29. package/dist/components/table.js +7 -1
  30. package/dist/components/table.js.map +1 -1
  31. package/dist/esm/loader.js +1 -1
  32. package/dist/esm/nano-components.js +1 -1
  33. package/dist/esm/nano-input.entry.js +2 -2
  34. package/dist/esm/nano-input.entry.js.map +1 -1
  35. package/dist/esm/nano-sortable.entry.js +68 -43
  36. package/dist/esm/nano-sortable.entry.js.map +1 -1
  37. package/dist/esm/nano-tab-group.entry.js +2 -0
  38. package/dist/esm/nano-tab-group.entry.js.map +1 -1
  39. package/dist/esm/{nano-table-eda322db.js → nano-table-9767860f.js} +8 -3
  40. package/dist/esm/nano-table-9767860f.js.map +1 -0
  41. package/dist/esm/nano-table.entry.js +1 -1
  42. package/dist/esm/{table.worker-245a7006.js → table.worker-d252307c.js} +2 -2
  43. package/dist/esm/table.worker-d252307c.js.map +1 -0
  44. package/dist/nano-components/nano-components.esm.js +1 -1
  45. package/dist/nano-components/nano-components.esm.js.map +1 -1
  46. package/dist/nano-components/{p-f7535f45.entry.js → p-1b687f96.entry.js} +2 -2
  47. package/dist/nano-components/p-1b687f96.entry.js.map +1 -0
  48. package/dist/nano-components/{p-99167ef0.js → p-633c778c.js} +2 -2
  49. package/dist/nano-components/p-633c778c.js.map +1 -0
  50. package/dist/nano-components/p-66631f50.js +5 -0
  51. package/dist/nano-components/{p-40b1c72f.entry.js → p-75735a91.entry.js} +2 -2
  52. package/dist/nano-components/{p-40b1c72f.entry.js.map → p-75735a91.entry.js.map} +1 -1
  53. package/dist/nano-components/{p-5157d7ba.entry.js → p-8a79a7ca.entry.js} +2 -2
  54. package/dist/nano-components/p-c8ccb57a.entry.js +5 -0
  55. package/dist/nano-components/p-c8ccb57a.entry.js.map +1 -0
  56. package/dist/types/components/sortable/sortable.d.ts +2 -3
  57. package/dist/types/components/table/table.d.ts +1 -0
  58. package/dist/types/components.d.ts +2 -0
  59. package/docs-json.json +19 -2
  60. package/hydrate/index.js +79 -46
  61. package/package.json +2 -2
  62. package/dist/cjs/nano-table-66318604.js.map +0 -1
  63. package/dist/cjs/table.worker-e102343e.js.map +0 -1
  64. package/dist/esm/nano-table-eda322db.js.map +0 -1
  65. package/dist/esm/table.worker-245a7006.js.map +0 -1
  66. package/dist/nano-components/p-99167ef0.js.map +0 -1
  67. package/dist/nano-components/p-d79c6862.entry.js +0 -5
  68. package/dist/nano-components/p-d79c6862.entry.js.map +0 -1
  69. package/dist/nano-components/p-df264b79.js +0 -5
  70. package/dist/nano-components/p-f7535f45.entry.js.map +0 -1
  71. /package/dist/nano-components/{p-5157d7ba.entry.js.map → p-66631f50.js.map} +0 -0
  72. /package/dist/nano-components/{p-df264b79.js.map → p-8a79a7ca.entry.js.map} +0 -0
@@ -263,6 +263,11 @@ const Sortable = class {
263
263
  return node.parentNode.appendChild(clone);
264
264
  }
265
265
  /// Event handlers ///
266
+ addListeners(el, events, fn, opts) {
267
+ events
268
+ .split(' ')
269
+ .forEach((e) => el.addEventListener(e, fn, opts));
270
+ }
266
271
  removeEventHandlers(ele) {
267
272
  ele = ele || this.sortableHost;
268
273
  ele.removeEventListener('mousedown', this.handleTrack);
@@ -271,8 +276,7 @@ const Sortable = class {
271
276
  }
272
277
  addEventHandlers(ele) {
273
278
  ele = ele || this.sortableHost;
274
- ele.addEventListener('mousedown', this.handleTrack);
275
- ele.addEventListener('touchstart', this.handleTrack);
279
+ this.addListeners(ele, 'mousedown touchstart', this.handleTrack);
276
280
  ele.addEventListener('keydown', this.handleKeydown);
277
281
  }
278
282
  /**
@@ -414,16 +418,35 @@ const Sortable = class {
414
418
  else
415
419
  focus();
416
420
  }
417
- /**
418
- * Tracks a pointer from touchstart/mousedown to touchend/mouseup. Note that the start state is fired following
419
- * the first actual move event following a touchstart/mousedown */
421
+ /** Tracks a pointer from touchstart/mousedown to touchend/mouseup. */
420
422
  handleTrack(e) {
423
+ // ignore if we've started dragging or right click
421
424
  if (this.dragRequestPending || (e.button && e.button !== 1))
422
425
  return;
423
- clearTimeout(this.mouseDownTimer);
426
+ // ignore touchmove events (namespace it so we can remove it)
427
+ const handleMove = (e) => {
428
+ if (e.cancelable)
429
+ e.preventDefault();
430
+ clearTimeout(this.mouseDownTimer);
431
+ };
432
+ // remove temporary events and reset timer
433
+ const resetTrack = () => {
434
+ clearTimeout(this.mouseDownTimer);
435
+ document.removeEventListener('touchmove', handleMove);
436
+ document.removeEventListener('contextmenu', this.finishOrder);
437
+ };
438
+ resetTrack();
439
+ // start a timer - only start dragging if pressed for 150ms
424
440
  this.mouseDownTimer = window === null || window === void 0 ? void 0 : window.setTimeout(() => {
441
+ // ignore if this is not a valid drag target
425
442
  if (!this.trackStart(e))
426
443
  return;
444
+ // ignore touchmove events (they scroll the screen)
445
+ document.addEventListener('touchmove', handleMove, {
446
+ passive: false,
447
+ });
448
+ // cancel if user presses and holds (without move) for context menu
449
+ document.addEventListener('contextmenu', this.finishOrder);
427
450
  this.addAriaMsg(this.grabbedHelperText(this.draggedElement));
428
451
  drag.drag(this.sortableHost, {
429
452
  initialEvent: e,
@@ -433,6 +456,7 @@ const Sortable = class {
433
456
  },
434
457
  onStop: () => {
435
458
  this.nanoDropped.emit({ element: this.draggedElement });
459
+ resetTrack();
436
460
  const didStop = () => {
437
461
  this.addAriaMsg(this.droppedHelperText(this.draggedElement));
438
462
  requestAnimationFrame(() => this.finishOrder());
@@ -444,8 +468,9 @@ const Sortable = class {
444
468
  didStop();
445
469
  },
446
470
  });
447
- }, 100);
448
- document.addEventListener('mouseup', () => clearTimeout(this.mouseDownTimer), { once: true });
471
+ }, 150);
472
+ // reset track timer & cancel DnD on mouseup / touchend / touchmove
473
+ this.addListeners(document, 'mouseup touchend touchmove', () => clearTimeout(this.mouseDownTimer), { once: true });
449
474
  }
450
475
  /**
451
476
  * Initialized a drag and drop sequence if a child node was clicked that matches the itemSelector property.
@@ -488,40 +513,6 @@ const Sortable = class {
488
513
  this.draggedElement.classList.add(this.placeholderClass);
489
514
  return true;
490
515
  }
491
- /** Ends re-ordering */
492
- finishOrder() {
493
- if (!this.draggedElement)
494
- return;
495
- const updated = Array.from(this.sortableHost.querySelectorAll(this.itemSelector)).filter((ele) => ele !== this.draggedElementClone);
496
- const originalIndex = this.sortableNodes.indexOf(this.draggedElement);
497
- const targetIndex = updated.indexOf(this.draggedElement);
498
- if (this.handleSelector) {
499
- const targetHandle = this.draggedElement.querySelector(this.handleSelector);
500
- targetHandle.classList.remove(this.handleDraggedClass);
501
- }
502
- if (originalIndex !== targetIndex) {
503
- const orderChangeEv = this.nanoOrderChange.emit({
504
- element: this.draggedElement,
505
- originalIndex,
506
- targetIndex,
507
- });
508
- if (orderChangeEv.defaultPrevented) {
509
- /** Event was prevented, wait a moment to send element back to whence it came - gives a nicer visual queue */
510
- this.animationPromise = new Promise((resolve) => {
511
- setTimeout(() => {
512
- this.insertAtTarget(this.draggedElement, updated[originalIndex]);
513
- this.reset();
514
- this.dragRequestPending = false;
515
- resolve();
516
- }, 200);
517
- });
518
- return;
519
- }
520
- this.addAriaMsg(this.reorderHelperText(this.draggedElement, updated, targetIndex + 1));
521
- }
522
- this.reset();
523
- this.dragRequestPending = false;
524
- }
525
516
  /// Component lifecycle ///
526
517
  constructor(hostRef) {
527
518
  index.registerInstance(this, hostRef);
@@ -534,6 +525,40 @@ const Sortable = class {
534
525
  this.animatedElements = [];
535
526
  this.keyboardHandleMap = new Map();
536
527
  this.sortableId = `nano-sortable-${sortableIds++}`;
528
+ /** Ends re-ordering */
529
+ this.finishOrder = () => {
530
+ if (!this.draggedElement)
531
+ return;
532
+ const updated = Array.from(this.sortableHost.querySelectorAll(this.itemSelector)).filter((ele) => ele !== this.draggedElementClone);
533
+ const originalIndex = this.sortableNodes.indexOf(this.draggedElement);
534
+ const targetIndex = updated.indexOf(this.draggedElement);
535
+ if (this.handleSelector) {
536
+ const targetHandle = this.draggedElement.querySelector(this.handleSelector);
537
+ targetHandle.classList.remove(this.handleDraggedClass);
538
+ }
539
+ if (originalIndex !== targetIndex) {
540
+ const orderChangeEv = this.nanoOrderChange.emit({
541
+ element: this.draggedElement,
542
+ originalIndex,
543
+ targetIndex,
544
+ });
545
+ if (orderChangeEv.defaultPrevented) {
546
+ /** Event was prevented, wait a moment to send element back to whence it came - gives a nicer visual queue */
547
+ this.animationPromise = new Promise((resolve) => {
548
+ setTimeout(() => {
549
+ this.insertAtTarget(this.draggedElement, updated[originalIndex]);
550
+ this.reset();
551
+ this.dragRequestPending = false;
552
+ resolve();
553
+ }, 200);
554
+ });
555
+ return;
556
+ }
557
+ this.addAriaMsg(this.reorderHelperText(this.draggedElement, updated, targetIndex + 1));
558
+ }
559
+ this.reset();
560
+ this.dragRequestPending = false;
561
+ };
537
562
  /**
538
563
  * Moves the active node's clone to follow the pointer. The node that the clone intersects with (via hitTest) is
539
564
  * the insert point for updated sorting */
@@ -584,7 +609,7 @@ const Sortable = class {
584
609
  this.dropzoneSelector = undefined;
585
610
  this.helperText = 'Press "Space" or "Enter" to enable element reordering and use the arrow keys to reorder items.' +
586
611
  'Press "Escape" to cancel reordering. Alternatively, use your mouse to drag / reorder.';
587
- this.itemDescriptor = (el) => `"${el.textContent.trim()}"`;
612
+ this.itemDescriptor = (el) => `"${el === null || el === void 0 ? void 0 : el.textContent.trim()}"`;
588
613
  this.grabbedHelperText = (el) => `${this.itemDescriptor(el)} grabbed`;
589
614
  this.droppedHelperText = (el) => `${this.itemDescriptor(el)} dropped`;
590
615
  this.reorderHelperText = (el, elements, position) => `The list has been reordered, ${this.itemDescriptor(el)} is now item ${position} of ${elements.length}`;
@@ -1 +1 @@
1
- {"file":"nano-sortable.entry.cjs.js","mappings":";;;;;;;;;;;AAAA,MAAM,WAAW,GAAG,8UAA8U;;ACmBlW;AACA,MAAM,cAAc,GAAG;EACrB,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;EAC1B,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;CACzB,CAAC;AAEF,IAAI,WAAW,GAAG,CAAC,CAAC;MAkBP,QAAQ;EAMnB,wBAAwB;IACtB,IAAI,CAAC,sBAAsB,EAAE,CAAC;GAC/B;EAOD,0BAA0B;IACxB,IAAI,CAAC,sBAAsB,EAA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AM;IACJ,QACEC,QAACC,UAAI,QACHD,iBACE,KAAK,EAAC,uBAAuB,eACnB,QAAQ,mBACJ,WAAW,iBACb,MAAM,EAClB,IAAI,EAAC,KAAK,EACV,IAAI,EAAC,eAAe,IAEnB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,MACzBA,qBAAM,GAAG,CAAO,CACjB,CAAC,CACE,EACNA,qBAAQ,CACH,EACP;GACH;;;;;;;;;;;;;","names":["writeTask","drag","readTask","nanoDebounce","h","Host"],"sources":["./src/components/sortable/sortable.scss?tag=nano-sortable&encapsulation=shadow","./src/components/sortable/sortable.tsx"],"sourcesContent":["@use '../../global/style/utilities/globals' as g;\n\n:host {\n position: relative;\n display: block;\n}\n\n.sortable__live-region {\n @include g.visually-hide();\n}\n","import {\n Prop,\n Element,\n Event,\n EventEmitter,\n h,\n Component,\n ComponentInterface,\n Watch,\n Method,\n State,\n Host,\n readTask,\n writeTask,\n Build,\n} from '@stencil/core';\nimport { drag } from '../../utils/drag';\nimport { nanoDebounce } from '../..';\n\n// Orientation map to limit dragging to horizontal or vertical.\nconst orientationMap = {\n horizontal: { x: 1, y: 0 },\n vertical: { x: 0, y: 1 },\n};\n\nlet sortableIds = 0;\n\n/**\n * An accessible and flexible re-order / sort utility component.\n *\n *- Drag and drop via mouse, touch or keyboard\n *- Live announcements for screen readers\n *- Works with or without an explicit handle (although with is preferable)\n\n * @part announcements - the a11y, live region. Visually hidden by default\n *\n * @slot - The default slot containing any items you might want to sort\n */\n@Component({\n tag: 'nano-sortable',\n shadow: true,\n styleUrl: 'sortable.scss',\n})\nexport class Sortable implements ComponentInterface {\n /// Public API & surface ///\n\n /** A css query selector which matches a set of elements that should be sortable. e.g. `<li>` or `<tr>` */\n @Prop() itemSelector = 'li';\n @Watch('itemSelector')\n handleItemSelectorChange() {\n this.refreshKeyboardHandles();\n }\n\n /** A css query selector which matches an element *within* the `itemSelector` element\n * which will act like a drag handle. **Note** For keyboard a11y it's recommended\n * to use `handleSelector` when possible. Alternatively, the `createKeyboardHandle` prop will be used */\n @Prop() handleSelector?: string;\n @Watch('handleSelector')\n handleHandleSelectorChange() {\n this.refreshKeyboardHandles();\n this.attachMutationObserver();\n }\n\n /** When dragging between grouped collections of items, it is possible to drag all sortable items from one group to another.\n * At that point, you will not be able to drag items back to the original group.\n * A `dropzoneSelector` allows you to define a placeholder area where items can always be dropped.\n */\n @Prop() dropzoneSelector?: string;\n\n /** Accessibility helper text applied to handle controls */\n @Prop() helperText =\n 'Press \"Space\" or \"Enter\" to enable element reordering and use the arrow keys to reorder items.' +\n 'Press \"Escape\" to cancel reordering. Alternatively, use your mouse to drag / reorder.';\n\n /**\n * As a sortable element is interacted with, announcements are made to screen readers\n * - informing the user what is changing.\n * By default, the text from the element is extracted to describe the interacted with element.\n * Use this function to provide a more meaningful, concise item descriptor\n * @param el the element being interacted with\n * @returns a string, describing the element being interacted with\n */\n @Prop() itemDescriptor = (el: Element) => `\"${el.textContent.trim()}\"`;\n\n /**\n * Used to generate a screen reader live update, informing the user of the current element being grabbed.\n * @param el the element that has been grabbed by the user\n * @returns a string, describing the element being grabbed\n */\n @Prop() grabbedHelperText = (el: Element) =>\n `${this.itemDescriptor(el)} grabbed`;\n\n /**\n * Used to generate a screen reader live update, informing the user of the current element being dropped.\n * @param el the element that has been dropped by the user\n * @returns a string, describing the element that has been dropped\n */\n @Prop() droppedHelperText = (el: Element) =>\n `${this.itemDescriptor(el)} dropped`;\n\n /**\n * Used to generate a screen reader live update, informing the user when items have been reordered.\n * @param el the element that has been reordered by the user\n * @param elements the elements in the sortable list\n * @param position the new position of the dropped element\n * @returns a string, describing the element being dropped\n */\n @Prop() reorderHelperText = (\n el: Element,\n elements: Element[],\n position: number\n ) =>\n `The list has been reordered, ${this.itemDescriptor(\n el\n )} is now item ${position} of ${elements.length}`;\n\n /**\n * A function that should attach a keyboard accessible control.\n * When a `handleSelector` is not used - to allow keyboard accessibility -\n * `createKeyboardHandle` should render a focusable element.\n *\n * If your sortable item is itself focusable,\n * you must use this function to render a control *outside* of the focusable element.\n * @param _number\n * @param _element\n * @returns a function that attaches a keyboard accessible handle control element.\n * The function itself *must* return the handle element.\n */\n @Prop() createKeyboardHandle = (_number: number, _element: Element) => {\n const handleTpl = /* html */ `\n <nano-icon-button\n slot=\"end\"\n icon-name=\"light/arrows\"\n class=\"nano-sortable__keyboard-handle visually-hidden\"\n label=\"Re-order this item\"\n ></nano-icon-button>`;\n const div = globalThis.document.createElement('div');\n div.innerHTML = handleTpl;\n\n const handle = div.children[0] as HTMLElement;\n _element.append(handle);\n return handle;\n };\n @Watch('createKeyboardHandle')\n handleCreateKeyboardHandleChange() {\n this.refreshKeyboardHandles();\n }\n\n /** use `sortableHostElement` to watch a sortable list without needing to wrap in `nano-sortable`.\n * Note that the `sortableHostElement` element css `position` will be set to `relative` */\n @Prop() sortableHostElement?: HTMLElement;\n @Watch('sortableHostElement')\n handleSortableHostElement(_newVal?, oldVal?: HTMLElement) {\n if (oldVal) this.removeEventHandlers(oldVal);\n\n this.addEventHandlers();\n this.refreshKeyboardHandles();\n this.attachMutationObserver();\n\n if (this.sortableHostElement) {\n // sortable host must have position relative\n this.sortableHostElement.style.position = 'relative';\n }\n }\n\n /** Items being sorted will animate into place */\n @Prop() animationEnabled = true;\n\n /** Use this class to change how the element looks whilst being sorted */\n @Prop() draggedClass = 'nano-sortable__dragged';\n\n /** Use this class to change how the handle looks whilst being sorted */\n @Prop() handleDraggedClass = 'nano-sortable__handle-dragged';\n\n /** Use this class to change how the element looks when acting as a placeholder */\n @Prop() placeholderClass = 'nano-sortable__placeholder';\n\n /** Used in-conjunction with `dropzoneSelector`, applied when a dropzone is dragged over */\n @Prop() dropzoneActiveClass?: string = '';\n\n /** The css animation timing applied when `animationEnabled` is `true` */\n @Prop() animationTiming: any = { duration: 200, easing: 'ease-out' };\n\n /** The axis to lock dragging elements to. `undefined` means any axis */\n @Prop() orientation?: 'horizontal' | 'vertical';\n\n /** Dragged items by default, will take whatever default css is applied in situ.\n * When sortable items' dimensions are dynamic (i.e they can shrink / grow via the space allowed) dragging items can look 'wrong'.\n * Apply `dragResize` to read & recreate the dragged items current dimensions when dragged. */\n @Prop() dragResize = false;\n\n /** Fired when an the order changes. Use this to update any underlying data model.\n * `event.preventDefault()` to prevent the element being moved; will revert to original position. */\n @Event() nanoOrderChange: EventEmitter<{\n element: HTMLElement;\n originalIndex: number;\n targetIndex: number;\n }>;\n\n /** Fired when a sortable element is picked-up; via keyboard, mouse or touch.\n * `event.preventDefault()` to prevent the element being picked-up. */\n @Event() nanoGrabbed: EventEmitter<{ element: HTMLElement; index: number }>;\n\n /** Fired when a sortable element is dropped after having been picked up. */\n @Event() nanoDropped: EventEmitter<{ element: HTMLElement }>;\n\n /** If sortable elements change dynamically, use this method to add handle controls to new elements */\n @Method()\n async refreshKeyboardHandles() {\n if (this.handleSelector) {\n if (this.keyboardHandleMap?.size) {\n this.keyboardHandleMap.clear();\n }\n\n this.sortableHost\n .querySelectorAll<HTMLElement>(this.handleSelector)\n .forEach((handle) => {\n if (!handle.getAttribute('aria-describedby'))\n handle.setAttribute('aria-describedby', this.sortableId);\n const sortEle = handle.closest<HTMLElement>(this.itemSelector);\n if (sortEle) this.keyboardHandleMap.set(handle, sortEle);\n });\n return;\n }\n\n if (this.keyboardHandleMap?.size) {\n this.keyboardHandleMap?.forEach((_ele, handle) => handle.remove());\n this.keyboardHandleMap.clear();\n }\n this.sortableHost\n .querySelectorAll<HTMLElement>(this.itemSelector)\n .forEach((ele, i) => {\n const handle = this.createKeyboardHandle(i, ele);\n if (!handle) {\n console.error(\n '`createKeyboardHandle` *must* return the handle element it creates'\n );\n return;\n }\n this.keyboardHandleMap.set(handle, ele);\n handle.setAttribute('aria-describedby', this.sortableId);\n });\n }\n\n /// Private state & logic ///\n\n @Element() host: HTMLNanoSortableElement;\n private dragRequestPending = false;\n private draggedElement?: HTMLElement;\n private draggedElementClone?: HTMLElement;\n private draggedElementOrigin?: HTMLElement;\n private sortableNodes: HTMLElement[] = [];\n private dropzoneNodes: HTMLElement[] = [];\n private animatedElements: HTMLElement[] = [];\n private animationPromise?: Promise<void>;\n private keyboardHandleMap: Map<HTMLElement, HTMLElement> = new Map();\n private sortableId = `nano-sortable-${sortableIds++}`;\n private mouseDownTimer: number;\n private mutationObserver: MutationObserver;\n\n @State() keyboardSortActive = false;\n @State() ariaTextList: string[] = [];\n\n /**\n * Get instance of sortable host.\n * By default it is `nano-sortable` which can be overridden by property `sortableHostElement`\n */\n get sortableHost() {\n if (this.sortableHostElement) return this.sortableHostElement;\n return this.host;\n }\n\n /**\n * Queues aria messages which are then displayed in a 'live' region.\n * Messages are cleared after 10s\n * @param msg aria message to announce\n */\n private addAriaMsg(msg: string) {\n this.ariaTextList = [...this.ariaTextList, msg];\n\n setTimeout(() => {\n const mIdx = this.ariaTextList.indexOf(msg);\n this.ariaTextList.splice(mIdx, 1);\n this.ariaTextList = [...this.ariaTextList];\n }, 10000);\n }\n\n /**\n * Try to stop text highlight whilst dragging\n * @param userSelect\n */\n private updateUserSelectStyle(userSelect: '' | 'none') {\n this.host.style.userSelect = userSelect;\n // @ts-ignore\n this.host.style.MozUserSelect = userSelect;\n // @ts-ignore\n this.host.style.msUserSelect = userSelect;\n this.host.style.webkitUserSelect = userSelect;\n }\n\n /**\n * Fast and simple hit test to check whether the center of a node intersects with the rectangle of any of the\n * given targets. Returns an array of matches.\n * @param node\n * @param targets\n * @returns all the items that currently intersect with the target node\n */\n private hitTest(node: HTMLElement, targets: HTMLElement[]): HTMLElement[] {\n const {\n left: l,\n top: t,\n width: w,\n height: h,\n } = node.getBoundingClientRect();\n const x = l + w / 2;\n const y = t + h / 2;\n\n return targets.filter((item) => {\n const { left, right, top, bottom } = item.getBoundingClientRect();\n return !(x < left || x > right || y < top || y > bottom);\n });\n }\n\n /**\n * Returns a boolean indicating whether the node is currently in an animation.\n * @param node\n * @returns whether a node is currently animating or not\n */\n private isAnimating(node: HTMLElement) {\n return this.animatedElements.indexOf(node) !== -1;\n }\n\n /**\n * Triggers a CSS animation on a node with the given dx and dy. Used following dom updates to make it appear as\n * if nodes animate from their old to their new position in the dom. */\n private animateNode(node: HTMLElement, dx = 0, dy = 0) {\n if (!node.animate) {\n return;\n }\n\n // keep a stack of currently animating nodes to exclude as drag & drop targets.\n this.animatedElements.push(node);\n\n node.style.willChange = 'transform';\n\n // animate from dx/dy (old node position) to none (new node position)\n writeTask(() => {\n this.animationPromise = new Promise((resolve) => {\n node\n .animate(\n [\n { transform: `translate3d(${dx}px, ${dy}px, 0)` },\n { transform: 'none' },\n ],\n this.animationTiming\n )\n .addEventListener(\n 'finish',\n () => {\n const index = this.animatedElements.indexOf(node);\n node.style.willChange = '';\n\n if (index !== -1) {\n // splice out when done to unlock as a valid target\n this.animatedElements.splice(index, 1);\n }\n\n resolve();\n delete this.animationPromise;\n },\n { once: true }\n );\n });\n });\n }\n\n /**\n * Inserts node at target to update sibling sorting. If the node precedes the target, it is inserted after it;\n * If it follows the target, it is inserted before it. This ensures any node can be dragged from the very\n * beginning to the very end and vice versa. The animateNode function is called for all nodes that moved because\n * of this dom update */\n private insertAtTarget(node: Element, target: HTMLElement) {\n if (!node || !target) return;\n\n let offsets: any[] = [];\n if (this.animationEnabled) {\n offsets = this.sortableNodes.map((item) => ({\n x: item.offsetLeft,\n y: item.offsetTop,\n }));\n }\n\n if (!node.isConnected || !target.isConnected) return;\n\n if (this.dropzoneNodes.indexOf(target) > -1) {\n target.append(node);\n } else {\n const nodeComparison = node.compareDocumentPosition(target);\n let position;\n\n if (nodeComparison & this.host.DOCUMENT_POSITION_FOLLOWING) {\n position =\n target.parentNode === node.parentNode ? 'afterend' : 'beforebegin';\n }\n if (nodeComparison & this.host.DOCUMENT_POSITION_PRECEDING) {\n position =\n target.parentNode === node.parentNode ? 'beforebegin' : 'afterend';\n }\n if (position) target.insertAdjacentElement(position, node);\n }\n\n if (this.animationEnabled) {\n this.sortableNodes.forEach((sortableNode, i) => {\n const { x, y } = offsets[i];\n const dx = x - sortableNode.offsetLeft;\n const dy = y - sortableNode.offsetTop;\n if (dx !== 0 || dy !== 0) {\n this.animateNode(sortableNode, dx, dy);\n }\n });\n }\n }\n\n private reset() {\n if (\n this.draggedElementClone !== undefined &&\n this.draggedElementClone.parentNode !== null\n ) {\n this.draggedElementClone.parentNode.removeChild(this.draggedElementClone);\n }\n\n if (\n this.draggedElement &&\n this.draggedElement.parentNode &&\n this.draggedElementOrigin\n ) {\n this.draggedElement.classList.remove(this.placeholderClass);\n }\n\n if (this.dropzoneActiveClass && this.dropzoneNodes.length) {\n this.dropzoneNodes.forEach((dze) =>\n dze.classList.remove(this.dropzoneActiveClass)\n );\n }\n\n delete this.draggedElementClone;\n delete this.draggedElement;\n\n this.dropzoneNodes = [];\n this.sortableNodes = [];\n this.animatedElements = [];\n this.dragRequestPending = false;\n this.updateUserSelectStyle('');\n }\n\n /**\n * Clones a given node to visually drag around. The original node is left in the same flow as its siblings.\n * Clone styles are added onto the style object directly, since the ::slotted()\n * selector can't universally target nodes that may be nested an unknown amount of shadow dom levels deep\n * @param node html node to clone\n * @returns the cloned html node\n */\n private createClone(node: HTMLElement): HTMLElement {\n const clone = node.cloneNode(true) as HTMLElement;\n if (node.id) clone.id = 'clone__' + clone.id;\n\n /**\n * Bugfix for table row sorting.\n * During dragging table rows shrink, so we manually set them width of original node.\n */\n Array.from(clone.children).forEach((nodeChild: HTMLElement, index) => {\n const clonedNodeChild = nodeChild;\n const originalNodeChild = node.children.item(index) as HTMLElement;\n\n if (originalNodeChild) {\n clonedNodeChild.style.width = `${originalNodeChild.offsetWidth}px`;\n }\n });\n const {\n offsetLeft: x,\n offsetTop: y,\n offsetWidth: w,\n offsetHeight: h,\n } = node;\n\n Object.assign(clone.style, {\n position: 'absolute',\n left: `calc(${x}px - var(--grab-offset-x, 0px))`,\n top: `calc(${y}px - var(--grab-offset-y, 0px))`,\n height: this.dragResize ? `${h}px` : undefined,\n width: this.dragResize ? `${w}px` : undefined,\n willChange: 'transform,opacity',\n });\n\n clone.classList.add(this.draggedClass);\n\n return node.parentNode!.appendChild(clone);\n }\n\n /// Event handlers ///\n\n private removeEventHandlers(ele?: HTMLElement) {\n ele = ele || this.sortableHost;\n ele.removeEventListener('mousedown', this.handleTrack);\n ele.removeEventListener('touchstart', this.handleTrack);\n ele.removeEventListener('keydown', this.handleKeydown);\n }\n\n private addEventHandlers(ele?: HTMLElement) {\n ele = ele || this.sortableHost;\n ele.addEventListener('mousedown', this.handleTrack);\n ele.addEventListener('touchstart', this.handleTrack);\n ele.addEventListener('keydown', this.handleKeydown);\n }\n\n /**\n * Watch for any changes in grab-able handle elements.\n */\n private attachMutationObserver() {\n if (!Build.isBrowser) return;\n\n if (this.mutationObserver) {\n this.mutationObserver.disconnect();\n this.mutationObserver = undefined;\n }\n\n this.mutationObserver = new MutationObserver(() => {\n const currHandles = Array.from(this.keyboardHandleMap.values());\n const newHandles = Array.from(\n this.sortableHost.querySelectorAll<HTMLElement>(this.itemSelector)\n );\n\n // simple test for equality\n if (\n currHandles.length !== newHandles.length ||\n !!newHandles.find((h) => !currHandles.includes(h))\n ) {\n this.refreshKeyboardHandles();\n }\n });\n this.mutationObserver.observe(this.sortableHost, {\n subtree: true,\n childList: true,\n });\n }\n\n private handleKeydown(e: KeyboardEvent) {\n const targetElement = e.target as HTMLElement;\n let foundHandle: HTMLElement;\n let sortEle: HTMLElement;\n\n if (this.handleSelector) {\n foundHandle = targetElement.closest(this.handleSelector);\n sortEle = targetElement.closest(this.itemSelector);\n } else {\n sortEle = this.keyboardHandleMap.get(targetElement);\n foundHandle = targetElement;\n }\n\n // have we found a handle and matching sort element from the keydown element\n if (!foundHandle || !sortEle) return;\n\n const activateSort = (isActive: boolean) => {\n this.keyboardSortActive = isActive;\n this.draggedElement = isActive ? sortEle : undefined;\n sortEle.classList.toggle(this.draggedClass, isActive);\n foundHandle.classList.toggle(this.handleDraggedClass, isActive);\n\n if (isActive) {\n this.addAriaMsg(this.grabbedHelperText(sortEle));\n document.addEventListener('mousedown', () => activateSort(false), {\n once: true,\n });\n } else {\n this.addAriaMsg(this.droppedHelperText(sortEle));\n }\n };\n\n // start editing this element's order?\n if ([' ', 'Space', 'Enter'].includes(e.key)) {\n e.preventDefault();\n\n if (!this.keyboardSortActive) {\n // grabbed the element\n activateSort(true);\n\n this.sortableNodes =\n Array.from(this.sortableHost.querySelectorAll(this.itemSelector)) ||\n [];\n const nanoGrabbedEv = this.nanoGrabbed.emit({\n element: sortEle,\n index: this.sortableNodes.indexOf(sortEle),\n });\n\n if (nanoGrabbedEv.defaultPrevented) {\n activateSort(false);\n return;\n }\n } else {\n // dropped the element\n activateSort(false);\n this.nanoDropped.emit({ element: sortEle });\n }\n return;\n }\n if (!this.keyboardSortActive) return;\n\n // Tabbing away from this handle - deactivate\n if (['Escape', 'Tab'].includes(e.key)) activateSort(false);\n\n let moveKeys = ['Home', 'End'];\n if (!this.orientation || this.orientation === 'horizontal')\n moveKeys = [...moveKeys, 'ArrowRight', 'ArrowLeft'];\n if (!this.orientation || this.orientation === 'vertical')\n moveKeys = [...moveKeys, 'ArrowUp', 'ArrowDown'];\n\n if (!moveKeys.includes(e.key)) return;\n\n // move the element with the keyboard\n e.preventDefault();\n\n /** Collect all elements that have drag positions.\n * Both sortable elements and 'dropzones' (placeholders where items can always be placed) */\n\n this.sortableNodes =\n Array.from(this.sortableHost.querySelectorAll(this.itemSelector)) || [];\n this.dropzoneNodes =\n Array.from(this.sortableHost.querySelectorAll(this.dropzoneSelector)) ||\n [];\n const currIdx = this.sortableNodes.indexOf(this.draggedElement);\n let curDzIdx: number = -1;\n\n if (this.dropzoneNodes.length) {\n const curDropzone = this.draggedElement.closest<HTMLElement>(\n this.dropzoneSelector\n );\n curDzIdx = this.dropzoneNodes.indexOf(curDropzone);\n curDzIdx = curDzIdx > -1 ? curDzIdx : -1;\n }\n\n /** If we don't have a next / prev sortable element in our list, test to see if there's a dropzone instead */\n const prevEle =\n currIdx - 1 < 0 && curDzIdx > -1\n ? this.dropzoneNodes[curDzIdx - 1]\n : this.sortableNodes[currIdx - 1];\n const nextEle =\n currIdx + 1 === this.sortableNodes.length && curDzIdx > -1\n ? this.dropzoneNodes[curDzIdx + 1]\n : this.sortableNodes[currIdx + 1];\n\n if (e.key === 'Home') {\n this.insertAtTarget(this.draggedElement, this.sortableNodes[0]);\n }\n if (e.key === 'End') {\n this.insertAtTarget(\n this.draggedElement,\n this.sortableNodes[this.sortableNodes.length - 1]\n );\n }\n if (['ArrowRight', 'ArrowDown'].includes(e.key)) {\n this.insertAtTarget(this.draggedElement, nextEle);\n }\n if (['ArrowLeft', 'ArrowUp'].includes(e.key)) {\n this.insertAtTarget(this.draggedElement, prevEle);\n }\n\n this.finishOrder();\n this.draggedElement = sortEle;\n\n const focus = () => {\n requestAnimationFrame(() => {\n typeof foundHandle['setFocus'] === 'function'\n ? (foundHandle as HTMLNanoIconButtonElement).setFocus()\n : foundHandle.focus();\n });\n };\n\n // replace focus to handle so we don't 'drop' the element\n if (this.animationPromise) this.animationPromise.then(() => focus());\n else focus();\n }\n\n /**\n * Tracks a pointer from touchstart/mousedown to touchend/mouseup. Note that the start state is fired following\n * the first actual move event following a touchstart/mousedown */\n private handleTrack(e: PointerEvent) {\n if (this.dragRequestPending || (e.button && e.button !== 1)) return;\n\n clearTimeout(this.mouseDownTimer);\n this.mouseDownTimer = window?.setTimeout(() => {\n if (!this.trackStart(e)) return;\n\n this.addAriaMsg(this.grabbedHelperText(this.draggedElement));\n\n drag(this.sortableHost, {\n initialEvent: e,\n relative: true,\n onMove: (x, y) => {\n this.trackMove(x, y);\n },\n onStop: () => {\n this.nanoDropped.emit({ element: this.draggedElement });\n\n const didStop = () => {\n this.addAriaMsg(this.droppedHelperText(this.draggedElement));\n requestAnimationFrame(() => this.finishOrder());\n };\n if (this.animationPromise) {\n this.animationPromise.then(() => didStop());\n } else didStop();\n },\n });\n }, 100);\n document.addEventListener(\n 'mouseup',\n () => clearTimeout(this.mouseDownTimer),\n { once: true }\n );\n }\n\n /**\n * Initialized a drag and drop sequence if a child node was clicked that matches the itemSelector property.\n * OR If a handleSelector is defined, a node matching this selector must be clicked instead\n * @returns boolean - whether tracking for this event should continue or not\n */\n private trackStart(e: Event) {\n const targetElement = e.target as HTMLElement;\n let targetHandle: HTMLElement;\n\n // If we have a handle set, return now if not being pressed\n if (this.handleSelector) {\n targetHandle = targetElement.closest(this.handleSelector);\n\n if (!targetHandle) return;\n targetHandle.classList.add(this.handleDraggedClass);\n }\n\n // Check that we've found the target element via itemSelector\n const node = targetElement.closest<HTMLElement>(this.itemSelector);\n if (!node) return false;\n\n this.sortableNodes =\n Array.from(this.sortableHost.querySelectorAll(this.itemSelector)) || [];\n const nanoGrabbedEv = this.nanoGrabbed.emit({\n element: node,\n index: this.sortableNodes.indexOf(node),\n });\n if (nanoGrabbedEv.defaultPrevented) return false;\n\n // Element found... start everything\n e.preventDefault();\n this.updateUserSelectStyle('none');\n this.dragRequestPending = true;\n this.draggedElement = node;\n this.dropzoneNodes =\n Array.from(this.sortableHost.querySelectorAll(this.dropzoneSelector)) ||\n [];\n this.draggedElementClone = this.createClone(node);\n this.draggedElementOrigin = node.nextSibling as HTMLElement;\n this.animatedElements = [];\n this.draggedElement!.classList.add(this.placeholderClass);\n return true;\n }\n\n /** Ends re-ordering */\n private finishOrder() {\n if (!this.draggedElement) return;\n\n const updated = Array.from(\n this.sortableHost.querySelectorAll<HTMLElement>(this.itemSelector)\n ).filter((ele) => ele !== this.draggedElementClone);\n const originalIndex = this.sortableNodes.indexOf(this.draggedElement);\n const targetIndex = updated.indexOf(this.draggedElement);\n\n if (this.handleSelector) {\n const targetHandle = this.draggedElement.querySelector(\n this.handleSelector\n );\n targetHandle.classList.remove(this.handleDraggedClass);\n }\n\n if (originalIndex !== targetIndex) {\n const orderChangeEv = this.nanoOrderChange.emit({\n element: this.draggedElement,\n originalIndex,\n targetIndex,\n });\n\n if (orderChangeEv.defaultPrevented) {\n /** Event was prevented, wait a moment to send element back to whence it came - gives a nicer visual queue */\n this.animationPromise = new Promise((resolve) => {\n setTimeout(() => {\n this.insertAtTarget(this.draggedElement, updated[originalIndex]);\n this.reset();\n this.dragRequestPending = false;\n resolve();\n }, 200);\n });\n return;\n }\n this.addAriaMsg(\n this.reorderHelperText(this.draggedElement, updated, targetIndex + 1)\n );\n }\n\n this.reset();\n this.dragRequestPending = false;\n }\n\n /**\n * Moves the active node's clone to follow the pointer. The node that the clone intersects with (via hitTest) is\n * the insert point for updated sorting */\n private trackMove = (x: number, y: number) => {\n if (!this.draggedElementClone) {\n return;\n }\n\n if (this.orientation) {\n x = x * orientationMap[this.orientation].x;\n y = y * orientationMap[this.orientation].y;\n }\n\n writeTask(() => {\n Object.assign(this.draggedElementClone!.style, {\n transform: `translate3d(${x}px, ${y}px, 0)`,\n });\n });\n\n let target = this.hitTest(this.draggedElementClone!, this.sortableNodes)[0];\n let activeDropzone: HTMLElement;\n\n if (this.dropzoneSelector && this.dropzoneActiveClass) {\n readTask(() => {\n activeDropzone = this.draggedElement.closest(this.dropzoneSelector);\n\n writeTask(() => {\n this.dropzoneNodes\n .filter((dze) => dze !== activeDropzone)\n .forEach((dze) => dze.classList.remove(this.dropzoneActiveClass));\n activeDropzone.classList.add(this.dropzoneActiveClass);\n });\n });\n }\n\n // didn't find a target - let's test to see if we can use a drop-zone instead\n if (!target && this.dropzoneNodes.length) {\n target = this.hitTest(this.draggedElementClone!, this.dropzoneNodes)[0];\n if (this.draggedElement.closest(this.dropzoneSelector) === target) return;\n }\n\n if (\n // if clone intersects with a valid target,\n target &&\n // other than its own origin,\n target !== this.draggedElement &&\n // and the target isn't currently animating, which causes false hit tests,\n !this.isAnimating(target)\n ) {\n this.insertAtTarget(this.draggedElement!, target);\n }\n };\n\n /// Component lifecycle ///\n\n constructor() {\n this.handleTrack = this.handleTrack.bind(this);\n this.handleKeydown = this.handleKeydown.bind(this);\n this.refreshKeyboardHandles = this.refreshKeyboardHandles.bind(this);\n this.refreshKeyboardHandles = nanoDebounce(\n this.refreshKeyboardHandles,\n 500\n );\n }\n\n connectedCallback() {\n this.addEventHandlers();\n this.refreshKeyboardHandles();\n this.attachMutationObserver();\n\n if (Build.isBrowser && !this.host.querySelector(`#${this.sortableId}`)) {\n // inject a light-dom / a11y description that we can connect sortable items to\n this.host.insertAdjacentHTML(\n 'beforeend',\n `<div class=\"visually-hidden\" id=\"${this.sortableId}\">${this.helperText}</div>`\n );\n }\n }\n\n disconnectedCallback() {\n this.removeEventHandlers();\n this.host.querySelector(`#${this.sortableId}`)?.remove();\n\n if (this.mutationObserver) {\n this.mutationObserver.disconnect();\n this.mutationObserver = undefined;\n }\n }\n\n render() {\n return (\n <Host>\n <div\n class=\"sortable__live-region\"\n aria-live=\"polite\"\n aria-relevant=\"additions\"\n aria-atomic=\"true\"\n role=\"log\"\n part=\"announcements\"\n >\n {this.ariaTextList.map((str) => (\n <div>{str}</div>\n ))}\n </div>\n <slot />\n </Host>\n );\n }\n}\n"],"version":3}
1
+ {"file":"nano-sortable.entry.cjs.js","mappings":";;;;;;;;;;;AAAA,MAAM,WAAW,GAAG,8UAA8U;;ACmBlW;AACA,MAAM,cAAc,GAAG;EACrB,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;EAC1B,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;CACzB,CAAC;AAEF,IAAI,WAAW,GAAG,CAAC,CAAC;MAkBP,QAAQ;EAMnB,wBAAwB;IACtB,IAAI,CAAC,sBAAsB,EAAE,CAAC;GAC/B;EAOD,0BAA0B;IACxB,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAC9B,IAAI,CAAC,sBAAsB,EAAE,CAAC;GAC/B;EAmFD,gCAAgC;IAC9B,IAAI,CAAC,sBAAsB,EAAE,CAAC;GAC/B;EAMD,yBAAyB,CAAC,OAAQ,EAAE,MAAoB;IACtD,IAAI,MAAM;MAAE,IAAI,CAAC,mBAAmB,C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AC,sBAAsB,EAAE,CAAC;IAE9B,IAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE;;MAEtE,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAC1B,WAAW,EACX,oCAAoC,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,UAAU,QAAQ,CAChF,CAAC;KACH;GACF;EAED,oBAAoB;;IAClB,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC3B,MAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,0CAAE,MAAM,EAAE,CAAC;IAEzD,IAAI,IAAI,CAAC,gBAAgB,EAAE;MACzB,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC;MACnC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;KACnC;GACF;EAED,MAAM;IACJ,QACEC,QAACC,UAAI,QACHD,iBACE,KAAK,EAAC,uBAAuB,eACnB,QAAQ,mBACJ,WAAW,iBACb,MAAM,EAClB,IAAI,EAAC,KAAK,EACV,IAAI,EAAC,eAAe,IAEnB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,MACzBA,qBAAM,GAAG,CAAO,CACjB,CAAC,CACE,EACNA,qBAAQ,CACH,EACP;GACH;;;;;;;;;;;;;","names":["writeTask","drag","readTask","nanoDebounce","h","Host"],"sources":["./src/components/sortable/sortable.scss?tag=nano-sortable&encapsulation=shadow","./src/components/sortable/sortable.tsx"],"sourcesContent":["@use '../../global/style/utilities/globals' as g;\n\n:host {\n position: relative;\n display: block;\n}\n\n.sortable__live-region {\n @include g.visually-hide();\n}\n","import {\n Prop,\n Element,\n Event,\n EventEmitter,\n h,\n Component,\n ComponentInterface,\n Watch,\n Method,\n State,\n Host,\n readTask,\n writeTask,\n Build,\n} from '@stencil/core';\nimport { drag } from '../../utils/drag';\nimport { nanoDebounce } from '../..';\n\n// Orientation map to limit dragging to horizontal or vertical.\nconst orientationMap = {\n horizontal: { x: 1, y: 0 },\n vertical: { x: 0, y: 1 },\n};\n\nlet sortableIds = 0;\n\n/**\n * An accessible and flexible re-order / sort utility component.\n *\n *- Drag and drop via mouse, touch or keyboard\n *- Live announcements for screen readers\n *- Works with or without an explicit handle (although with is preferable)\n\n * @part announcements - the a11y, live region. Visually hidden by default\n *\n * @slot - The default slot containing any items you might want to sort\n */\n@Component({\n tag: 'nano-sortable',\n shadow: true,\n styleUrl: 'sortable.scss',\n})\nexport class Sortable implements ComponentInterface {\n /// Public API & surface ///\n\n /** A css query selector which matches a set of elements that should be sortable. e.g. `<li>` or `<tr>` */\n @Prop() itemSelector = 'li';\n @Watch('itemSelector')\n handleItemSelectorChange() {\n this.refreshKeyboardHandles();\n }\n\n /** A css query selector which matches an element *within* the `itemSelector` element\n * which will act like a drag handle. **Note** For keyboard a11y it's recommended\n * to use `handleSelector` when possible. Alternatively, the `createKeyboardHandle` prop will be used */\n @Prop() handleSelector?: string;\n @Watch('handleSelector')\n handleHandleSelectorChange() {\n this.refreshKeyboardHandles();\n this.attachMutationObserver();\n }\n\n /** When dragging between grouped collections of items, it is possible to drag all sortable items from one group to another.\n * At that point, you will not be able to drag items back to the original group.\n * A `dropzoneSelector` allows you to define a placeholder area where items can always be dropped.\n */\n @Prop() dropzoneSelector?: string;\n\n /** Accessibility helper text applied to handle controls */\n @Prop() helperText =\n 'Press \"Space\" or \"Enter\" to enable element reordering and use the arrow keys to reorder items.' +\n 'Press \"Escape\" to cancel reordering. Alternatively, use your mouse to drag / reorder.';\n\n /**\n * As a sortable element is interacted with, announcements are made to screen readers\n * - informing the user what is changing.\n * By default, the text from the element is extracted to describe the interacted with element.\n * Use this function to provide a more meaningful, concise item descriptor\n * @param el the element being interacted with\n * @returns a string, describing the element being interacted with\n */\n @Prop() itemDescriptor = (el: Element) => `\"${el?.textContent.trim()}\"`;\n\n /**\n * Used to generate a screen reader live update, informing the user of the current element being grabbed.\n * @param el the element that has been grabbed by the user\n * @returns a string, describing the element being grabbed\n */\n @Prop() grabbedHelperText = (el: Element) =>\n `${this.itemDescriptor(el)} grabbed`;\n\n /**\n * Used to generate a screen reader live update, informing the user of the current element being dropped.\n * @param el the element that has been dropped by the user\n * @returns a string, describing the element that has been dropped\n */\n @Prop() droppedHelperText = (el: Element) =>\n `${this.itemDescriptor(el)} dropped`;\n\n /**\n * Used to generate a screen reader live update, informing the user when items have been reordered.\n * @param el the element that has been reordered by the user\n * @param elements the elements in the sortable list\n * @param position the new position of the dropped element\n * @returns a string, describing the element being dropped\n */\n @Prop() reorderHelperText = (\n el: Element,\n elements: Element[],\n position: number\n ) =>\n `The list has been reordered, ${this.itemDescriptor(\n el\n )} is now item ${position} of ${elements.length}`;\n\n /**\n * A function that should attach a keyboard accessible control.\n * When a `handleSelector` is not used - to allow keyboard accessibility -\n * `createKeyboardHandle` should render a focusable element.\n *\n * If your sortable item is itself focusable,\n * you must use this function to render a control *outside* of the focusable element.\n * @param _number\n * @param _element\n * @returns a function that attaches a keyboard accessible handle control element.\n * The function itself *must* return the handle element.\n */\n @Prop() createKeyboardHandle = (_number: number, _element: Element) => {\n const handleTpl = /* html */ `\n <nano-icon-button\n slot=\"end\"\n icon-name=\"light/arrows\"\n class=\"nano-sortable__keyboard-handle visually-hidden\"\n label=\"Re-order this item\"\n ></nano-icon-button>`;\n const div = globalThis.document.createElement('div');\n div.innerHTML = handleTpl;\n\n const handle = div.children[0] as HTMLElement;\n _element.append(handle);\n return handle;\n };\n @Watch('createKeyboardHandle')\n handleCreateKeyboardHandleChange() {\n this.refreshKeyboardHandles();\n }\n\n /** use `sortableHostElement` to watch a sortable list without needing to wrap in `nano-sortable`.\n * Note that the `sortableHostElement` element css `position` will be set to `relative` */\n @Prop() sortableHostElement?: HTMLElement;\n @Watch('sortableHostElement')\n handleSortableHostElement(_newVal?, oldVal?: HTMLElement) {\n if (oldVal) this.removeEventHandlers(oldVal);\n\n this.addEventHandlers();\n this.refreshKeyboardHandles();\n this.attachMutationObserver();\n\n if (this.sortableHostElement) {\n // sortable host must have position relative\n this.sortableHostElement.style.position = 'relative';\n }\n }\n\n /** Items being sorted will animate into place */\n @Prop() animationEnabled = true;\n\n /** Use this class to change how the element looks whilst being sorted */\n @Prop() draggedClass = 'nano-sortable__dragged';\n\n /** Use this class to change how the handle looks whilst being sorted */\n @Prop() handleDraggedClass = 'nano-sortable__handle-dragged';\n\n /** Use this class to change how the element looks when acting as a placeholder */\n @Prop() placeholderClass = 'nano-sortable__placeholder';\n\n /** Used in-conjunction with `dropzoneSelector`, applied when a dropzone is dragged over */\n @Prop() dropzoneActiveClass?: string = '';\n\n /** The css animation timing applied when `animationEnabled` is `true` */\n @Prop() animationTiming: any = { duration: 200, easing: 'ease-out' };\n\n /** The axis to lock dragging elements to. `undefined` means any axis */\n @Prop() orientation?: 'horizontal' | 'vertical';\n\n /** Dragged items by default, will take whatever default css is applied in situ.\n * When sortable items' dimensions are dynamic (i.e they can shrink / grow via the space allowed) dragging items can look 'wrong'.\n * Apply `dragResize` to read & recreate the dragged items current dimensions when dragged. */\n @Prop() dragResize = false;\n\n /** Fired when an the order changes. Use this to update any underlying data model.\n * `event.preventDefault()` to prevent the element being moved; will revert to original position. */\n @Event() nanoOrderChange: EventEmitter<{\n element: HTMLElement;\n originalIndex: number;\n targetIndex: number;\n }>;\n\n /** Fired when a sortable element is picked-up; via keyboard, mouse or touch.\n * `event.preventDefault()` to prevent the element being picked-up. */\n @Event() nanoGrabbed: EventEmitter<{ element: HTMLElement; index: number }>;\n\n /** Fired when a sortable element is dropped after having been picked up. */\n @Event() nanoDropped: EventEmitter<{ element: HTMLElement }>;\n\n /** If sortable elements change dynamically, use this method to add handle controls to new elements */\n @Method()\n async refreshKeyboardHandles() {\n if (this.handleSelector) {\n if (this.keyboardHandleMap?.size) {\n this.keyboardHandleMap.clear();\n }\n\n this.sortableHost\n .querySelectorAll<HTMLElement>(this.handleSelector)\n .forEach((handle) => {\n if (!handle.getAttribute('aria-describedby'))\n handle.setAttribute('aria-describedby', this.sortableId);\n const sortEle = handle.closest<HTMLElement>(this.itemSelector);\n if (sortEle) this.keyboardHandleMap.set(handle, sortEle);\n });\n return;\n }\n\n if (this.keyboardHandleMap?.size) {\n this.keyboardHandleMap?.forEach((_ele, handle) => handle.remove());\n this.keyboardHandleMap.clear();\n }\n this.sortableHost\n .querySelectorAll<HTMLElement>(this.itemSelector)\n .forEach((ele, i) => {\n const handle = this.createKeyboardHandle(i, ele);\n if (!handle) {\n console.error(\n '`createKeyboardHandle` *must* return the handle element it creates'\n );\n return;\n }\n this.keyboardHandleMap.set(handle, ele);\n handle.setAttribute('aria-describedby', this.sortableId);\n });\n }\n\n /// Private state & logic ///\n\n @Element() host: HTMLNanoSortableElement;\n private dragRequestPending = false;\n private draggedElement?: HTMLElement;\n private draggedElementClone?: HTMLElement;\n private draggedElementOrigin?: HTMLElement;\n private sortableNodes: HTMLElement[] = [];\n private dropzoneNodes: HTMLElement[] = [];\n private animatedElements: HTMLElement[] = [];\n private animationPromise?: Promise<void>;\n private keyboardHandleMap: Map<HTMLElement, HTMLElement> = new Map();\n private sortableId = `nano-sortable-${sortableIds++}`;\n private mouseDownTimer: number;\n private mutationObserver: MutationObserver;\n\n @State() keyboardSortActive = false;\n @State() ariaTextList: string[] = [];\n\n /**\n * Get instance of sortable host.\n * By default it is `nano-sortable` which can be overridden by property `sortableHostElement`\n */\n get sortableHost() {\n if (this.sortableHostElement) return this.sortableHostElement;\n return this.host;\n }\n\n /**\n * Queues aria messages which are then displayed in a 'live' region.\n * Messages are cleared after 10s\n * @param msg aria message to announce\n */\n private addAriaMsg(msg: string) {\n this.ariaTextList = [...this.ariaTextList, msg];\n\n setTimeout(() => {\n const mIdx = this.ariaTextList.indexOf(msg);\n this.ariaTextList.splice(mIdx, 1);\n this.ariaTextList = [...this.ariaTextList];\n }, 10000);\n }\n\n /**\n * Try to stop text highlight whilst dragging\n * @param userSelect\n */\n private updateUserSelectStyle(userSelect: '' | 'none') {\n this.host.style.userSelect = userSelect;\n // @ts-ignore\n this.host.style.MozUserSelect = userSelect;\n // @ts-ignore\n this.host.style.msUserSelect = userSelect;\n this.host.style.webkitUserSelect = userSelect;\n }\n\n /**\n * Fast and simple hit test to check whether the center of a node intersects with the rectangle of any of the\n * given targets. Returns an array of matches.\n * @param node\n * @param targets\n * @returns all the items that currently intersect with the target node\n */\n private hitTest(node: HTMLElement, targets: HTMLElement[]): HTMLElement[] {\n const {\n left: l,\n top: t,\n width: w,\n height: h,\n } = node.getBoundingClientRect();\n const x = l + w / 2;\n const y = t + h / 2;\n\n return targets.filter((item) => {\n const { left, right, top, bottom } = item.getBoundingClientRect();\n return !(x < left || x > right || y < top || y > bottom);\n });\n }\n\n /**\n * Returns a boolean indicating whether the node is currently in an animation.\n * @param node\n * @returns whether a node is currently animating or not\n */\n private isAnimating(node: HTMLElement) {\n return this.animatedElements.indexOf(node) !== -1;\n }\n\n /**\n * Triggers a CSS animation on a node with the given dx and dy. Used following dom updates to make it appear as\n * if nodes animate from their old to their new position in the dom. */\n private animateNode(node: HTMLElement, dx = 0, dy = 0) {\n if (!node.animate) {\n return;\n }\n\n // keep a stack of currently animating nodes to exclude as drag & drop targets.\n this.animatedElements.push(node);\n\n node.style.willChange = 'transform';\n\n // animate from dx/dy (old node position) to none (new node position)\n writeTask(() => {\n this.animationPromise = new Promise((resolve) => {\n node\n .animate(\n [\n { transform: `translate3d(${dx}px, ${dy}px, 0)` },\n { transform: 'none' },\n ],\n this.animationTiming\n )\n .addEventListener(\n 'finish',\n () => {\n const index = this.animatedElements.indexOf(node);\n node.style.willChange = '';\n\n if (index !== -1) {\n // splice out when done to unlock as a valid target\n this.animatedElements.splice(index, 1);\n }\n\n resolve();\n delete this.animationPromise;\n },\n { once: true }\n );\n });\n });\n }\n\n /**\n * Inserts node at target to update sibling sorting. If the node precedes the target, it is inserted after it;\n * If it follows the target, it is inserted before it. This ensures any node can be dragged from the very\n * beginning to the very end and vice versa. The animateNode function is called for all nodes that moved because\n * of this dom update */\n private insertAtTarget(node: Element, target: HTMLElement) {\n if (!node || !target) return;\n\n let offsets: any[] = [];\n if (this.animationEnabled) {\n offsets = this.sortableNodes.map((item) => ({\n x: item.offsetLeft,\n y: item.offsetTop,\n }));\n }\n\n if (!node.isConnected || !target.isConnected) return;\n\n if (this.dropzoneNodes.indexOf(target) > -1) {\n target.append(node);\n } else {\n const nodeComparison = node.compareDocumentPosition(target);\n let position;\n\n if (nodeComparison & this.host.DOCUMENT_POSITION_FOLLOWING) {\n position =\n target.parentNode === node.parentNode ? 'afterend' : 'beforebegin';\n }\n if (nodeComparison & this.host.DOCUMENT_POSITION_PRECEDING) {\n position =\n target.parentNode === node.parentNode ? 'beforebegin' : 'afterend';\n }\n if (position) target.insertAdjacentElement(position, node);\n }\n\n if (this.animationEnabled) {\n this.sortableNodes.forEach((sortableNode, i) => {\n const { x, y } = offsets[i];\n const dx = x - sortableNode.offsetLeft;\n const dy = y - sortableNode.offsetTop;\n if (dx !== 0 || dy !== 0) {\n this.animateNode(sortableNode, dx, dy);\n }\n });\n }\n }\n\n private reset() {\n if (\n this.draggedElementClone !== undefined &&\n this.draggedElementClone.parentNode !== null\n ) {\n this.draggedElementClone.parentNode.removeChild(this.draggedElementClone);\n }\n\n if (\n this.draggedElement &&\n this.draggedElement.parentNode &&\n this.draggedElementOrigin\n ) {\n this.draggedElement.classList.remove(this.placeholderClass);\n }\n\n if (this.dropzoneActiveClass && this.dropzoneNodes.length) {\n this.dropzoneNodes.forEach((dze) =>\n dze.classList.remove(this.dropzoneActiveClass)\n );\n }\n\n delete this.draggedElementClone;\n delete this.draggedElement;\n\n this.dropzoneNodes = [];\n this.sortableNodes = [];\n this.animatedElements = [];\n this.dragRequestPending = false;\n this.updateUserSelectStyle('');\n }\n\n /**\n * Clones a given node to visually drag around. The original node is left in the same flow as its siblings.\n * Clone styles are added onto the style object directly, since the ::slotted()\n * selector can't universally target nodes that may be nested an unknown amount of shadow dom levels deep\n * @param node html node to clone\n * @returns the cloned html node\n */\n private createClone(node: HTMLElement): HTMLElement {\n const clone = node.cloneNode(true) as HTMLElement;\n if (node.id) clone.id = 'clone__' + clone.id;\n\n /**\n * Bugfix for table row sorting.\n * During dragging table rows shrink, so we manually set them width of original node.\n */\n Array.from(clone.children).forEach((nodeChild: HTMLElement, index) => {\n const clonedNodeChild = nodeChild;\n const originalNodeChild = node.children.item(index) as HTMLElement;\n\n if (originalNodeChild) {\n clonedNodeChild.style.width = `${originalNodeChild.offsetWidth}px`;\n }\n });\n const {\n offsetLeft: x,\n offsetTop: y,\n offsetWidth: w,\n offsetHeight: h,\n } = node;\n\n Object.assign(clone.style, {\n position: 'absolute',\n left: `calc(${x}px - var(--grab-offset-x, 0px))`,\n top: `calc(${y}px - var(--grab-offset-y, 0px))`,\n height: this.dragResize ? `${h}px` : undefined,\n width: this.dragResize ? `${w}px` : undefined,\n willChange: 'transform,opacity',\n });\n\n clone.classList.add(this.draggedClass);\n\n return node.parentNode!.appendChild(clone);\n }\n\n /// Event handlers ///\n\n private addListeners(\n el: Element | Document,\n events: string,\n fn: (e: Event) => void,\n opts?: AddEventListenerOptions\n ) {\n events\n .split(' ')\n .forEach((e) =>\n el.addEventListener(e as keyof HTMLElementEventMap, fn, opts)\n );\n }\n\n private removeEventHandlers(ele?: HTMLElement) {\n ele = ele || this.sortableHost;\n ele.removeEventListener('mousedown', this.handleTrack);\n ele.removeEventListener('touchstart', this.handleTrack);\n ele.removeEventListener('keydown', this.handleKeydown);\n }\n\n private addEventHandlers(ele?: HTMLElement) {\n ele = ele || this.sortableHost;\n this.addListeners(ele, 'mousedown touchstart', this.handleTrack);\n ele.addEventListener('keydown', this.handleKeydown);\n }\n\n /**\n * Watch for any changes in grab-able handle elements.\n */\n private attachMutationObserver() {\n if (!Build.isBrowser) return;\n\n if (this.mutationObserver) {\n this.mutationObserver.disconnect();\n this.mutationObserver = undefined;\n }\n\n this.mutationObserver = new MutationObserver(() => {\n const currHandles = Array.from(this.keyboardHandleMap.values());\n const newHandles = Array.from(\n this.sortableHost.querySelectorAll<HTMLElement>(this.itemSelector)\n );\n\n // simple test for equality\n if (\n currHandles.length !== newHandles.length ||\n !!newHandles.find((h) => !currHandles.includes(h))\n ) {\n this.refreshKeyboardHandles();\n }\n });\n this.mutationObserver.observe(this.sortableHost, {\n subtree: true,\n childList: true,\n });\n }\n\n private handleKeydown(e: KeyboardEvent) {\n const targetElement = e.target as HTMLElement;\n let foundHandle: HTMLElement;\n let sortEle: HTMLElement;\n\n if (this.handleSelector) {\n foundHandle = targetElement.closest(this.handleSelector);\n sortEle = targetElement.closest(this.itemSelector);\n } else {\n sortEle = this.keyboardHandleMap.get(targetElement);\n foundHandle = targetElement;\n }\n\n // have we found a handle and matching sort element from the keydown element\n if (!foundHandle || !sortEle) return;\n\n const activateSort = (isActive: boolean) => {\n this.keyboardSortActive = isActive;\n this.draggedElement = isActive ? sortEle : undefined;\n sortEle.classList.toggle(this.draggedClass, isActive);\n foundHandle.classList.toggle(this.handleDraggedClass, isActive);\n\n if (isActive) {\n this.addAriaMsg(this.grabbedHelperText(sortEle));\n document.addEventListener('mousedown', () => activateSort(false), {\n once: true,\n });\n } else {\n this.addAriaMsg(this.droppedHelperText(sortEle));\n }\n };\n\n // start editing this element's order?\n if ([' ', 'Space', 'Enter'].includes(e.key)) {\n e.preventDefault();\n\n if (!this.keyboardSortActive) {\n // grabbed the element\n activateSort(true);\n\n this.sortableNodes =\n Array.from(this.sortableHost.querySelectorAll(this.itemSelector)) ||\n [];\n const nanoGrabbedEv = this.nanoGrabbed.emit({\n element: sortEle,\n index: this.sortableNodes.indexOf(sortEle),\n });\n\n if (nanoGrabbedEv.defaultPrevented) {\n activateSort(false);\n return;\n }\n } else {\n // dropped the element\n activateSort(false);\n this.nanoDropped.emit({ element: sortEle });\n }\n return;\n }\n if (!this.keyboardSortActive) return;\n\n // Tabbing away from this handle - deactivate\n if (['Escape', 'Tab'].includes(e.key)) activateSort(false);\n\n let moveKeys = ['Home', 'End'];\n if (!this.orientation || this.orientation === 'horizontal')\n moveKeys = [...moveKeys, 'ArrowRight', 'ArrowLeft'];\n if (!this.orientation || this.orientation === 'vertical')\n moveKeys = [...moveKeys, 'ArrowUp', 'ArrowDown'];\n\n if (!moveKeys.includes(e.key)) return;\n\n // move the element with the keyboard\n e.preventDefault();\n\n /** Collect all elements that have drag positions.\n * Both sortable elements and 'dropzones' (placeholders where items can always be placed) */\n\n this.sortableNodes =\n Array.from(this.sortableHost.querySelectorAll(this.itemSelector)) || [];\n this.dropzoneNodes =\n Array.from(this.sortableHost.querySelectorAll(this.dropzoneSelector)) ||\n [];\n const currIdx = this.sortableNodes.indexOf(this.draggedElement);\n let curDzIdx: number = -1;\n\n if (this.dropzoneNodes.length) {\n const curDropzone = this.draggedElement.closest<HTMLElement>(\n this.dropzoneSelector\n );\n curDzIdx = this.dropzoneNodes.indexOf(curDropzone);\n curDzIdx = curDzIdx > -1 ? curDzIdx : -1;\n }\n\n /** If we don't have a next / prev sortable element in our list, test to see if there's a dropzone instead */\n const prevEle =\n currIdx - 1 < 0 && curDzIdx > -1\n ? this.dropzoneNodes[curDzIdx - 1]\n : this.sortableNodes[currIdx - 1];\n const nextEle =\n currIdx + 1 === this.sortableNodes.length && curDzIdx > -1\n ? this.dropzoneNodes[curDzIdx + 1]\n : this.sortableNodes[currIdx + 1];\n\n if (e.key === 'Home') {\n this.insertAtTarget(this.draggedElement, this.sortableNodes[0]);\n }\n if (e.key === 'End') {\n this.insertAtTarget(\n this.draggedElement,\n this.sortableNodes[this.sortableNodes.length - 1]\n );\n }\n if (['ArrowRight', 'ArrowDown'].includes(e.key)) {\n this.insertAtTarget(this.draggedElement, nextEle);\n }\n if (['ArrowLeft', 'ArrowUp'].includes(e.key)) {\n this.insertAtTarget(this.draggedElement, prevEle);\n }\n\n this.finishOrder();\n this.draggedElement = sortEle;\n\n const focus = () => {\n requestAnimationFrame(() => {\n typeof foundHandle['setFocus'] === 'function'\n ? (foundHandle as HTMLNanoIconButtonElement).setFocus()\n : foundHandle.focus();\n });\n };\n\n // replace focus to handle so we don't 'drop' the element\n if (this.animationPromise) this.animationPromise.then(() => focus());\n else focus();\n }\n\n /** Tracks a pointer from touchstart/mousedown to touchend/mouseup. */\n private handleTrack(e: PointerEvent) {\n // ignore if we've started dragging or right click\n if (this.dragRequestPending || (e.button && e.button !== 1)) return;\n\n // ignore touchmove events (namespace it so we can remove it)\n const handleMove = (e: Event) => {\n if (e.cancelable) e.preventDefault();\n clearTimeout(this.mouseDownTimer);\n };\n\n // remove temporary events and reset timer\n const resetTrack = () => {\n clearTimeout(this.mouseDownTimer);\n document.removeEventListener('touchmove', handleMove);\n document.removeEventListener('contextmenu', this.finishOrder);\n };\n resetTrack();\n\n // start a timer - only start dragging if pressed for 150ms\n this.mouseDownTimer = window?.setTimeout(() => {\n // ignore if this is not a valid drag target\n if (!this.trackStart(e)) return;\n\n // ignore touchmove events (they scroll the screen)\n document.addEventListener('touchmove', handleMove, {\n passive: false,\n });\n // cancel if user presses and holds (without move) for context menu\n document.addEventListener('contextmenu', this.finishOrder);\n\n this.addAriaMsg(this.grabbedHelperText(this.draggedElement));\n\n drag(this.sortableHost, {\n initialEvent: e,\n relative: true,\n onMove: (x, y) => {\n this.trackMove(x, y);\n },\n onStop: () => {\n this.nanoDropped.emit({ element: this.draggedElement });\n resetTrack();\n\n const didStop = () => {\n this.addAriaMsg(this.droppedHelperText(this.draggedElement));\n requestAnimationFrame(() => this.finishOrder());\n };\n if (this.animationPromise) {\n this.animationPromise.then(() => didStop());\n } else didStop();\n },\n });\n }, 150);\n\n // reset track timer & cancel DnD on mouseup / touchend / touchmove\n this.addListeners(\n document,\n 'mouseup touchend touchmove',\n () => clearTimeout(this.mouseDownTimer),\n { once: true }\n );\n }\n\n /**\n * Initialized a drag and drop sequence if a child node was clicked that matches the itemSelector property.\n * OR If a handleSelector is defined, a node matching this selector must be clicked instead\n * @returns boolean - whether tracking for this event should continue or not\n */\n private trackStart(e: Event) {\n const targetElement = e.target as HTMLElement;\n let targetHandle: HTMLElement;\n\n // If we have a handle set, return now if not being pressed\n if (this.handleSelector) {\n targetHandle = targetElement.closest(this.handleSelector);\n\n if (!targetHandle) return;\n targetHandle.classList.add(this.handleDraggedClass);\n }\n\n // Check that we've found the target element via itemSelector\n const node = targetElement.closest<HTMLElement>(this.itemSelector);\n if (!node) return false;\n\n this.sortableNodes =\n Array.from(this.sortableHost.querySelectorAll(this.itemSelector)) || [];\n const nanoGrabbedEv = this.nanoGrabbed.emit({\n element: node,\n index: this.sortableNodes.indexOf(node),\n });\n if (nanoGrabbedEv.defaultPrevented) return false;\n\n // Element found... start everything\n e.preventDefault();\n this.updateUserSelectStyle('none');\n this.dragRequestPending = true;\n this.draggedElement = node;\n this.dropzoneNodes =\n Array.from(this.sortableHost.querySelectorAll(this.dropzoneSelector)) ||\n [];\n this.draggedElementClone = this.createClone(node);\n this.draggedElementOrigin = node.nextSibling as HTMLElement;\n this.animatedElements = [];\n this.draggedElement!.classList.add(this.placeholderClass);\n return true;\n }\n\n /** Ends re-ordering */\n private finishOrder = () => {\n if (!this.draggedElement) return;\n\n const updated = Array.from(\n this.sortableHost.querySelectorAll<HTMLElement>(this.itemSelector)\n ).filter((ele) => ele !== this.draggedElementClone);\n const originalIndex = this.sortableNodes.indexOf(this.draggedElement);\n const targetIndex = updated.indexOf(this.draggedElement);\n\n if (this.handleSelector) {\n const targetHandle = this.draggedElement.querySelector(\n this.handleSelector\n );\n targetHandle.classList.remove(this.handleDraggedClass);\n }\n\n if (originalIndex !== targetIndex) {\n const orderChangeEv = this.nanoOrderChange.emit({\n element: this.draggedElement,\n originalIndex,\n targetIndex,\n });\n\n if (orderChangeEv.defaultPrevented) {\n /** Event was prevented, wait a moment to send element back to whence it came - gives a nicer visual queue */\n this.animationPromise = new Promise((resolve) => {\n setTimeout(() => {\n this.insertAtTarget(this.draggedElement, updated[originalIndex]);\n this.reset();\n this.dragRequestPending = false;\n resolve();\n }, 200);\n });\n return;\n }\n this.addAriaMsg(\n this.reorderHelperText(this.draggedElement, updated, targetIndex + 1)\n );\n }\n\n this.reset();\n this.dragRequestPending = false;\n };\n\n /**\n * Moves the active node's clone to follow the pointer. The node that the clone intersects with (via hitTest) is\n * the insert point for updated sorting */\n private trackMove = (x: number, y: number) => {\n if (!this.draggedElementClone) {\n return;\n }\n\n if (this.orientation) {\n x = x * orientationMap[this.orientation].x;\n y = y * orientationMap[this.orientation].y;\n }\n\n writeTask(() => {\n Object.assign(this.draggedElementClone!.style, {\n transform: `translate3d(${x}px, ${y}px, 0)`,\n });\n });\n\n let target = this.hitTest(this.draggedElementClone!, this.sortableNodes)[0];\n let activeDropzone: HTMLElement;\n\n if (this.dropzoneSelector && this.dropzoneActiveClass) {\n readTask(() => {\n activeDropzone = this.draggedElement.closest(this.dropzoneSelector);\n\n writeTask(() => {\n this.dropzoneNodes\n .filter((dze) => dze !== activeDropzone)\n .forEach((dze) => dze.classList.remove(this.dropzoneActiveClass));\n activeDropzone.classList.add(this.dropzoneActiveClass);\n });\n });\n }\n\n // didn't find a target - let's test to see if we can use a drop-zone instead\n if (!target && this.dropzoneNodes.length) {\n target = this.hitTest(this.draggedElementClone!, this.dropzoneNodes)[0];\n if (this.draggedElement.closest(this.dropzoneSelector) === target) return;\n }\n\n if (\n // if clone intersects with a valid target,\n target &&\n // other than its own origin,\n target !== this.draggedElement &&\n // and the target isn't currently animating, which causes false hit tests,\n !this.isAnimating(target)\n ) {\n this.insertAtTarget(this.draggedElement!, target);\n }\n };\n\n /// Component lifecycle ///\n\n constructor() {\n this.handleTrack = this.handleTrack.bind(this);\n this.handleKeydown = this.handleKeydown.bind(this);\n this.refreshKeyboardHandles = this.refreshKeyboardHandles.bind(this);\n this.refreshKeyboardHandles = nanoDebounce(\n this.refreshKeyboardHandles,\n 500\n );\n }\n\n connectedCallback() {\n this.addEventHandlers();\n this.refreshKeyboardHandles();\n this.attachMutationObserver();\n\n if (Build.isBrowser && !this.host.querySelector(`#${this.sortableId}`)) {\n // inject a light-dom / a11y description that we can connect sortable items to\n this.host.insertAdjacentHTML(\n 'beforeend',\n `<div class=\"visually-hidden\" id=\"${this.sortableId}\">${this.helperText}</div>`\n );\n }\n }\n\n disconnectedCallback() {\n this.removeEventHandlers();\n this.host.querySelector(`#${this.sortableId}`)?.remove();\n\n if (this.mutationObserver) {\n this.mutationObserver.disconnect();\n this.mutationObserver = undefined;\n }\n }\n\n render() {\n return (\n <Host>\n <div\n class=\"sortable__live-region\"\n aria-live=\"polite\"\n aria-relevant=\"additions\"\n aria-atomic=\"true\"\n role=\"log\"\n part=\"announcements\"\n >\n {this.ariaTextList.map((str) => (\n <div>{str}</div>\n ))}\n </div>\n <slot />\n </Host>\n );\n }\n}\n"],"version":3}
@@ -320,6 +320,8 @@ const TabGroup = class {
320
320
  var _a;
321
321
  this.getAllTabs.forEach((tab) => tab.setAttribute('direction', this.placement === 'top' ? 'horizontal' : 'vertical'));
322
322
  const tab = this.getActiveTab;
323
+ if (!tab)
324
+ return;
323
325
  const width = ((_a = tab.shadowRoot.querySelector('.nanotab')) === null || _a === void 0 ? void 0 : _a.clientWidth) || 0;
324
326
  const height = tab.clientHeight;
325
327
  const offset = dom.getOffset(tab, this.tabs);