forty-cdk 0.45.0 → 0.46.0

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 (39) hide show
  1. package/fesm2022/forty-cdk-avatar.mjs +6 -7
  2. package/fesm2022/forty-cdk-avatar.mjs.map +1 -1
  3. package/fesm2022/forty-cdk-combobox.mjs +6 -7
  4. package/fesm2022/forty-cdk-combobox.mjs.map +1 -1
  5. package/fesm2022/forty-cdk-core-anchored.mjs +12 -10
  6. package/fesm2022/forty-cdk-core-anchored.mjs.map +1 -1
  7. package/fesm2022/forty-cdk-core-overlay.mjs +60 -17
  8. package/fesm2022/forty-cdk-core-overlay.mjs.map +1 -1
  9. package/fesm2022/forty-cdk-core.mjs +99 -13
  10. package/fesm2022/forty-cdk-core.mjs.map +1 -1
  11. package/fesm2022/forty-cdk-drag-drop.mjs +5 -4
  12. package/fesm2022/forty-cdk-drag-drop.mjs.map +1 -1
  13. package/fesm2022/forty-cdk-listbox.mjs +73 -22
  14. package/fesm2022/forty-cdk-listbox.mjs.map +1 -1
  15. package/fesm2022/forty-cdk-menubar.mjs +8 -6
  16. package/fesm2022/forty-cdk-menubar.mjs.map +1 -1
  17. package/fesm2022/forty-cdk-navigation-menu.mjs +18 -28
  18. package/fesm2022/forty-cdk-navigation-menu.mjs.map +1 -1
  19. package/fesm2022/forty-cdk-radio-group.mjs +7 -9
  20. package/fesm2022/forty-cdk-radio-group.mjs.map +1 -1
  21. package/fesm2022/forty-cdk-select.mjs +6 -7
  22. package/fesm2022/forty-cdk-select.mjs.map +1 -1
  23. package/fesm2022/forty-cdk-slider.mjs +3 -3
  24. package/fesm2022/forty-cdk-slider.mjs.map +1 -1
  25. package/fesm2022/forty-cdk-table.mjs +19 -15
  26. package/fesm2022/forty-cdk-table.mjs.map +1 -1
  27. package/fesm2022/forty-cdk-tabs.mjs +15 -20
  28. package/fesm2022/forty-cdk-tabs.mjs.map +1 -1
  29. package/fesm2022/forty-cdk-toggle.mjs +6 -10
  30. package/fesm2022/forty-cdk-toggle.mjs.map +1 -1
  31. package/fesm2022/forty-cdk-tree.mjs +35 -11
  32. package/fesm2022/forty-cdk-tree.mjs.map +1 -1
  33. package/listbox/README.md +22 -0
  34. package/package.json +1 -1
  35. package/types/forty-cdk-core-anchored.d.ts +21 -4
  36. package/types/forty-cdk-core-overlay.d.ts +33 -4
  37. package/types/forty-cdk-core.d.ts +48 -25
  38. package/types/forty-cdk-listbox.d.ts +19 -1
  39. package/types/forty-cdk-tabs.d.ts +4 -3
@@ -29,6 +29,54 @@ function afterNextRenderCancellable(fn) {
29
29
  ref.destroy();
30
30
  });
31
31
  }
32
+ function sameEntries(a, b) {
33
+ if (a === b) return true;
34
+ if (a.size !== b.size) return false;
35
+ for (const [key, value] of a) if (!b.has(key) || !Object.is(b.get(key), value)) return false;
36
+ return true;
37
+ }
38
+ function buckets(items, fold, equal) {
39
+ return computed(() => {
40
+ const list = items();
41
+ const result = [];
42
+ for (let start = 0; start < list.length; start += 32) {
43
+ const end = Math.min(start + 32, list.length);
44
+ result.push(computed(() => fold(list, start, end), equal ? { equal } : void 0));
45
+ }
46
+ return result;
47
+ });
48
+ }
49
+ function bucketedFind(items, match) {
50
+ const slices = buckets(items, (list, start, end) => {
51
+ for (let i = start; i < end; i++) {
52
+ const item = list[i];
53
+ if (match(item)) return item;
54
+ }
55
+ });
56
+ return computed(() => {
57
+ for (const bucket of slices()) {
58
+ const found = bucket();
59
+ if (found !== void 0) return found;
60
+ }
61
+ });
62
+ }
63
+ function bucketedLookup(items, entry) {
64
+ const slices = buckets(items, (list, start, end) => {
65
+ const map = /* @__PURE__ */ new Map();
66
+ for (let i = start; i < end; i++) {
67
+ const pair = entry(list[i]);
68
+ if (pair !== null && !map.has(pair[0])) map.set(pair[0], pair[1]);
69
+ }
70
+ return map;
71
+ }, sameEntries);
72
+ return (key) => {
73
+ for (const bucket of slices()) {
74
+ const map = bucket();
75
+ if (map.has(key)) return map.get(key);
76
+ }
77
+ };
78
+ }
79
+ const MIN_HANDLES_FOR_SIBLING_WALK = 16;
32
80
  function sameSequence(a, b) {
33
81
  if (a === b) return true;
34
82
  if (a.length !== b.length) return false;
@@ -95,6 +143,28 @@ var Collection = class {
95
143
  }
96
144
  #sortByDomOrder(handles) {
97
145
  if (handles.length < 2) return handles;
146
+ return this.#sortBySiblingRank(handles) ?? this.#sortByComparison(handles);
147
+ }
148
+ #sortBySiblingRank(handles) {
149
+ if (handles.length < MIN_HANDLES_FOR_SIBLING_WALK) return null;
150
+ let parent = null;
151
+ const pending = /* @__PURE__ */ new Set();
152
+ for (const handle of handles) {
153
+ const host = handle.host;
154
+ if (!host.isConnected) continue;
155
+ const hostParent = host.parentNode;
156
+ if (hostParent === null || parent !== null && hostParent !== parent) return null;
157
+ parent = hostParent;
158
+ pending.add(host);
159
+ }
160
+ if (parent === null) return null;
161
+ const rank = /* @__PURE__ */ new Map();
162
+ for (let node = parent.firstChild; node !== null && pending.size > 0; node = node.nextSibling) if (pending.delete(node)) rank.set(node, rank.size);
163
+ if (pending.size > 0) return null;
164
+ const detachedRank = rank.size;
165
+ return handles.sort((a, b) => (rank.get(a.host) ?? detachedRank) - (rank.get(b.host) ?? detachedRank));
166
+ }
167
+ #sortByComparison(handles) {
98
168
  const position = new Map(handles.map((h, i) => [h, i]));
99
169
  const indexOrder = (a, b) => position.get(a) - position.get(b);
100
170
  return handles.sort((a, b) => {
@@ -571,9 +641,8 @@ function hostId(prefix) {
571
641
  const host = inject(ElementRef).nativeElement;
572
642
  return signal(resolveHostId(host, prefix)).asReadonly();
573
643
  }
574
- function registerHandle(target, register, unregister, scheduling = "sync") {
575
- if (scheduling === "afterNextRender") afterNextRender(() => register(target));
576
- else register(target);
644
+ function registerHandle(target, register, unregister) {
645
+ register(target);
577
646
  inject(DestroyRef).onDestroy(() => unregister(target));
578
647
  }
579
648
  function registerA11yName(owner, prefix) {
@@ -695,6 +764,23 @@ function composedPrecedes(a, b) {
695
764
  }
696
765
  return false;
697
766
  }
767
+ function findOwningHandle(index, node, boundary, options) {
768
+ let current = options?.includeSelf ? node : composedParentNode(node);
769
+ while (current !== null && current !== boundary) {
770
+ const owner = index.get(current);
771
+ if (owner !== void 0) return owner;
772
+ current = composedParentNode(current);
773
+ }
774
+ }
775
+ function indexByHost(items) {
776
+ const index = /* @__PURE__ */ new Map();
777
+ for (const item of items) index.set(item.host, item);
778
+ return index;
779
+ }
780
+ function composedParentNode(node) {
781
+ const parent = node.parentNode;
782
+ return parent !== null && isShadowRoot(parent) ? parent.host : parent;
783
+ }
698
784
  function hostChainOf(node) {
699
785
  const chain = [node];
700
786
  let host = shadowHostOf(node);
@@ -1774,10 +1860,12 @@ var ForDateTimeSegmentBase = class ForDateTimeSegmentBase {
1774
1860
  return this.ctx.delegate.isFirstSegmentType(this.segment()) ? 0 : -1;
1775
1861
  }, ...ngDevMode ? [{ debugName: "tabindex" }] : /* istanbul ignore next */ []);
1776
1862
  registerSegment() {
1777
- registerHandle({
1863
+ const handle = {
1778
1864
  host: this.host.nativeElement,
1779
1865
  type: this.segment
1780
- }, (h) => this.ctx.delegate.registerSegment(h), (h) => this.ctx.delegate.unregisterSegment(h), "afterNextRender");
1866
+ };
1867
+ afterNextRender(() => this.ctx.delegate.registerSegment(handle));
1868
+ inject(DestroyRef).onDestroy(() => this.ctx.delegate.unregisterSegment(handle));
1781
1869
  }
1782
1870
  onFocus() {
1783
1871
  this.ctx.delegate.focusSegment(this.segment());
@@ -2963,9 +3051,7 @@ function layoutPlaceholderInSlot(nodes, lifted) {
2963
3051
  }
2964
3052
  function findPressedDragItem(items, target) {
2965
3053
  if (!(target instanceof Node)) return null;
2966
- let pressed = null;
2967
- for (const item of items) if (item.host.contains(target) && (pressed === null || pressed.host.contains(item.host))) pressed = item;
2968
- return pressed;
3054
+ return findOwningHandle(indexByHost(items), target, null, { includeSelf: true }) ?? null;
2969
3055
  }
2970
3056
  function resolvePressedDragItem(items, target) {
2971
3057
  const pressed = findPressedDragItem(items, target);
@@ -4914,12 +5000,12 @@ function injectPointerMove(handler) {
4914
5000
  const host = inject(ElementRef).nativeElement;
4915
5001
  const moves = inject(StationaryPointerMoves);
4916
5002
  const release = moves.acquire();
4917
- const controller = new AbortController();
4918
- host.addEventListener("pointermove", (event) => {
5003
+ const listener = (event) => {
4919
5004
  if (!moves.isStationary(event)) handler(event);
4920
- }, { signal: controller.signal });
5005
+ };
5006
+ host.addEventListener("pointermove", listener);
4921
5007
  inject(DestroyRef).onDestroy(() => {
4922
- controller.abort();
5008
+ host.removeEventListener("pointermove", listener);
4923
5009
  release();
4924
5010
  });
4925
5011
  }
@@ -5761,6 +5847,6 @@ var VirtualizedResume = class {
5761
5847
  return this.resolve()?.pos ?? null;
5762
5848
  }
5763
5849
  };
5764
- export { BOTH_DRAG_AXES, Collection, DRAG_DEAD_ZONE_PX, DateFieldEngine, DragAnnouncer, DragItemHosts, EscapeArbiter, FLICK_STALE_VELOCITY_MS, FLICK_VELOCITY_PX_PER_MS, FOR_DATE_FIELD_HOST, FOR_FIELDSET_CONTEXT, FOR_FIELD_ANCHOR_CONTEXT, FOR_FIELD_CONTEXT, FOR_HOST_ROVING_CONTEXT, FOR_PICKER_SOURCE_HOST, FOR_TIME_FIELD_HOST, FOR_TIME_VALUE_SOURCE, ForDateTimeLiteralBase, ForDateTimeSegmentBase, ForVisuallyHidden, FormUiControlBase, HIDDEN_UNTIL_FOUND, IdGenerator, LabelCache, LiveAnnouncer, MODAL_EXEMPT_ATTRIBUTE, MODAL_PEER_ATTRIBUTE, MediaQueryRegistry, ModalOwnedRegions, NO_DRAG_AXES, PreviewController, RangeFieldComposer, RangeSelectionEngine, ReturnFocusResolver, RootedRegistry, RovingFocusYield, RovingTabindex, TABLE_REGISTRATION_CONTEXT, TABLE_ROW_REGISTRATION_CONTEXT, TextValueControlBase, TimeFieldEngine, VirtualizedNavigator, VirtualizedResume, accessibleTextContent, adoptHostId, adoptedSegmentContext, afterNextRenderCancellable, appendMissing, arbitrateLiftPress, assertInputBound, assertRootContext, assertTimeCapable, assertVirtualizedSelectionFollowsFocusSupported, attachSwipeDismiss, awaitTransformTransition, boundEntries, clamp, clampDragIndex, clampPreviewPosition, clampToBounds, compareDateOf, composeWithTime, composedClosest, composedContains, composedParentElement, consumeUnmappedLiftedKey, createDragPreview, createKeyboardDragMediator, createPointerDragSession, createPointerHighlight, createPointerSuppression, createPressFocus, createSingleSlot, createTemplatePreview, createVetoableEvent, createVetoableNativeEvent, crossesInteractiveContent, decimalPlaces, dedupeValues, defaultCompareWith, defaultItemToFormValue, dismissMarksTouched, dragAnnouncementLabel, dragHandleTouchAction, dragSurfaceTouchAction, emitVetoableEvent, emitVetoableNativeEvent, findFirstFocusable, findPressedDragItem, findRelocatedTabStop, findTabbableEdges, findTypeaheadMatch, firstEnabledHandle, firstEnabledHost, flickVelocity, focusAfterPress, focusWhenMounted, foldTypeaheadText, formatLocaleDigits, fortyError, fortyWarn, handleDisabledRovingItemKey, hostAriaLabel, hostButtonType, hostDescribedBy, hostId, hostLabelledBy, hostStaticAttribute, injectAmbientDirection, injectDateAdapter, injectDisabledClickGuard, injectElementSize, injectFieldAnchor, injectFieldLabelExemption, injectFieldWiring, injectFocusTrap, injectHasFocusableContent, injectHiddenInput, injectHostCarriesDragItem, injectHostScrollAxes, injectNativeFormReset, injectNativeFormResetToInitial, injectPauseController, injectPointerMove, injectPortal, injectPrefersReducedMotion, injectReflectedDirection, injectRovingFocusRestore, injectSwipeMotion, injectSyntheticActivation, injectTextDirection, injectTypeahead, injectVetoableEmitter, isDragLiftKey, isHistoryChord, isHoverCapablePointer, isImeComposing, isInArray, isInitialFocusTarget, isLiftedPassthroughKey, isNonTouchPointer, isRangeSelectShortcut, isScrollableAtEdge, isShortcutChord, isUnset, keepHiddenUntilFound, lastEnabledHandle, lastEnabledHost, layoutPlaceholderInSlot, leavesControl, leavesTabSequence, lookupByValue, markDragItemHost, membership, mirrorExternalValue, mirrorValue, mouseFocusTarget, moveGridIndex, moveIndex, navigateFromRovingItem, nextEnabledHandle, orphanContextError, pressFocusesDescendant, preventPointerFocus, reflectDisabled, reflectRequired, registerA11yDescription, registerA11yName, registerHandle, resolveActiveElement, resolveBoundaryElement, resolveCommittedPosition, resolveConfigClass, resolveDropTarget, resolveEventTarget, resolveGridNavigation, resolveHostId, resolveLiftedDragControl, resolveListNavigation, resolveListTypeahead, resolvePressedDragItem, resolveText, resolveTextInput, resolveTextRecord, resolveTreeExpandCollapse, resolveTreegridExpandCollapse, resolveWindowedReorder, roundToDecimals, roundToStepPrecision, rovingListTarget, rovingTabStop, runVirtualizedNavigatorBridge, secondsOfDay, selectionMembership, selectionTabStop, serializeISODate, serializeISOTime, singleSelected, snapToStep, staticHostId, stepDragTarget, stepFocusableCycle, stepOnGrid, swipeTouchAction, throwUnsupportedVirtualizedRangeSelect, timeGraftBaseDay, timeSentinel, toggleInArray, translateWindowReorder, unresolvedRootError, unsetInput, warnOnDuplicateRegistration };
5850
+ export { BOTH_DRAG_AXES, Collection, DRAG_DEAD_ZONE_PX, DateFieldEngine, DragAnnouncer, DragItemHosts, EscapeArbiter, FLICK_STALE_VELOCITY_MS, FLICK_VELOCITY_PX_PER_MS, FOR_DATE_FIELD_HOST, FOR_FIELDSET_CONTEXT, FOR_FIELD_ANCHOR_CONTEXT, FOR_FIELD_CONTEXT, FOR_HOST_ROVING_CONTEXT, FOR_PICKER_SOURCE_HOST, FOR_TIME_FIELD_HOST, FOR_TIME_VALUE_SOURCE, ForDateTimeLiteralBase, ForDateTimeSegmentBase, ForVisuallyHidden, FormUiControlBase, HIDDEN_UNTIL_FOUND, IdGenerator, LabelCache, LiveAnnouncer, MODAL_EXEMPT_ATTRIBUTE, MODAL_PEER_ATTRIBUTE, MediaQueryRegistry, ModalOwnedRegions, NO_DRAG_AXES, PreviewController, RangeFieldComposer, RangeSelectionEngine, ReturnFocusResolver, RootedRegistry, RovingFocusYield, RovingTabindex, TABLE_REGISTRATION_CONTEXT, TABLE_ROW_REGISTRATION_CONTEXT, TextValueControlBase, TimeFieldEngine, VirtualizedNavigator, VirtualizedResume, accessibleTextContent, adoptHostId, adoptedSegmentContext, afterNextRenderCancellable, appendMissing, arbitrateLiftPress, assertInputBound, assertRootContext, assertTimeCapable, assertVirtualizedSelectionFollowsFocusSupported, attachSwipeDismiss, awaitTransformTransition, boundEntries, bucketedFind, bucketedLookup, clamp, clampDragIndex, clampPreviewPosition, clampToBounds, compareDateOf, composeWithTime, composedClosest, composedContains, composedParentElement, consumeUnmappedLiftedKey, createDragPreview, createKeyboardDragMediator, createPointerDragSession, createPointerHighlight, createPointerSuppression, createPressFocus, createSingleSlot, createTemplatePreview, createVetoableEvent, createVetoableNativeEvent, crossesInteractiveContent, decimalPlaces, dedupeValues, defaultCompareWith, defaultItemToFormValue, dismissMarksTouched, dragAnnouncementLabel, dragHandleTouchAction, dragSurfaceTouchAction, emitVetoableEvent, emitVetoableNativeEvent, findFirstFocusable, findOwningHandle, findPressedDragItem, findRelocatedTabStop, findTabbableEdges, findTypeaheadMatch, firstEnabledHandle, firstEnabledHost, flickVelocity, focusAfterPress, focusWhenMounted, foldTypeaheadText, formatLocaleDigits, fortyError, fortyWarn, handleDisabledRovingItemKey, hostAriaLabel, hostButtonType, hostDescribedBy, hostId, hostLabelledBy, hostStaticAttribute, indexByHost, injectAmbientDirection, injectDateAdapter, injectDisabledClickGuard, injectElementSize, injectFieldAnchor, injectFieldLabelExemption, injectFieldWiring, injectFocusTrap, injectHasFocusableContent, injectHiddenInput, injectHostCarriesDragItem, injectHostScrollAxes, injectNativeFormReset, injectNativeFormResetToInitial, injectPauseController, injectPointerMove, injectPortal, injectPrefersReducedMotion, injectReflectedDirection, injectRovingFocusRestore, injectSwipeMotion, injectSyntheticActivation, injectTextDirection, injectTypeahead, injectVetoableEmitter, isDragLiftKey, isHistoryChord, isHoverCapablePointer, isImeComposing, isInArray, isInitialFocusTarget, isLiftedPassthroughKey, isNonTouchPointer, isRangeSelectShortcut, isScrollableAtEdge, isShortcutChord, isUnset, keepHiddenUntilFound, lastEnabledHandle, lastEnabledHost, layoutPlaceholderInSlot, leavesControl, leavesTabSequence, lookupByValue, markDragItemHost, membership, mirrorExternalValue, mirrorValue, mouseFocusTarget, moveGridIndex, moveIndex, navigateFromRovingItem, nextEnabledHandle, orphanContextError, pressFocusesDescendant, preventPointerFocus, reflectDisabled, reflectRequired, registerA11yDescription, registerA11yName, registerHandle, resolveActiveElement, resolveBoundaryElement, resolveCommittedPosition, resolveConfigClass, resolveDropTarget, resolveEventTarget, resolveGridNavigation, resolveHostId, resolveLiftedDragControl, resolveListNavigation, resolveListTypeahead, resolvePressedDragItem, resolveText, resolveTextInput, resolveTextRecord, resolveTreeExpandCollapse, resolveTreegridExpandCollapse, resolveWindowedReorder, roundToDecimals, roundToStepPrecision, rovingListTarget, rovingTabStop, runVirtualizedNavigatorBridge, secondsOfDay, selectionMembership, selectionTabStop, serializeISODate, serializeISOTime, singleSelected, snapToStep, staticHostId, stepDragTarget, stepFocusableCycle, stepOnGrid, swipeTouchAction, throwUnsupportedVirtualizedRangeSelect, timeGraftBaseDay, timeSentinel, toggleInArray, translateWindowReorder, unresolvedRootError, unsetInput, warnOnDuplicateRegistration };
5765
5851
 
5766
5852
  //# sourceMappingURL=forty-cdk-core.mjs.map