@design-factory/angular 21.1.0-next.0 → 21.1.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 (191) hide show
  1. package/fesm2022/design-factory-angular-drawer.mjs +22 -29
  2. package/fesm2022/design-factory-angular-drawer.mjs.map +1 -1
  3. package/fesm2022/design-factory-angular-internals.mjs +5 -5
  4. package/fesm2022/design-factory-angular-internals.mjs.map +1 -1
  5. package/fesm2022/design-factory-angular-sidenav.mjs +139 -62
  6. package/fesm2022/design-factory-angular-sidenav.mjs.map +1 -1
  7. package/fesm2022/design-factory-angular-theme.mjs +1 -1
  8. package/fesm2022/design-factory-angular-theme.mjs.map +1 -1
  9. package/fesm2022/design-factory-angular-topnav.mjs +152 -75
  10. package/fesm2022/design-factory-angular-topnav.mjs.map +1 -1
  11. package/package.json +3 -6
  12. package/types/design-factory-angular-drawer.d.ts +13 -14
  13. package/types/design-factory-angular-internals.d.ts +3 -3
  14. package/types/design-factory-angular-sidenav.d.ts +19 -6
  15. package/types/design-factory-angular-topnav.d.ts +13 -6
  16. package/node_modules/@agnos-ui/core/README.md +0 -5
  17. package/node_modules/@agnos-ui/core/accordion-BC_9xn23.cjs +0 -314
  18. package/node_modules/@agnos-ui/core/accordion-Ca_0T8Bc.js +0 -315
  19. package/node_modules/@agnos-ui/core/alert-AhaliJ17.cjs +0 -9
  20. package/node_modules/@agnos-ui/core/alert-Cb9FhbFQ.js +0 -10
  21. package/node_modules/@agnos-ui/core/collapse-COriZO7o.cjs +0 -94
  22. package/node_modules/@agnos-ui/core/collapse-CP79atna.js +0 -95
  23. package/node_modules/@agnos-ui/core/common-B5jS-Ih_.cjs +0 -73
  24. package/node_modules/@agnos-ui/core/common-DFyZvkII.js +0 -74
  25. package/node_modules/@agnos-ui/core/components/accordion/accordion.d.ts +0 -333
  26. package/node_modules/@agnos-ui/core/components/accordion/index.cjs +0 -7
  27. package/node_modules/@agnos-ui/core/components/accordion/index.d.ts +0 -1
  28. package/node_modules/@agnos-ui/core/components/accordion/index.js +0 -7
  29. package/node_modules/@agnos-ui/core/components/alert/alert.d.ts +0 -37
  30. package/node_modules/@agnos-ui/core/components/alert/common.d.ts +0 -138
  31. package/node_modules/@agnos-ui/core/components/alert/index.cjs +0 -5
  32. package/node_modules/@agnos-ui/core/components/alert/index.d.ts +0 -1
  33. package/node_modules/@agnos-ui/core/components/alert/index.js +0 -5
  34. package/node_modules/@agnos-ui/core/components/carousel/carousel.d.ts +0 -247
  35. package/node_modules/@agnos-ui/core/components/carousel/index.cjs +0 -292
  36. package/node_modules/@agnos-ui/core/components/carousel/index.d.ts +0 -1
  37. package/node_modules/@agnos-ui/core/components/carousel/index.js +0 -292
  38. package/node_modules/@agnos-ui/core/components/collapse/collapse.d.ts +0 -135
  39. package/node_modules/@agnos-ui/core/components/collapse/index.cjs +0 -5
  40. package/node_modules/@agnos-ui/core/components/collapse/index.d.ts +0 -1
  41. package/node_modules/@agnos-ui/core/components/collapse/index.js +0 -5
  42. package/node_modules/@agnos-ui/core/components/commonProps.d.ts +0 -11
  43. package/node_modules/@agnos-ui/core/components/drawer/drawer.d.ts +0 -279
  44. package/node_modules/@agnos-ui/core/components/drawer/index.cjs +0 -5
  45. package/node_modules/@agnos-ui/core/components/drawer/index.d.ts +0 -1
  46. package/node_modules/@agnos-ui/core/components/drawer/index.js +0 -5
  47. package/node_modules/@agnos-ui/core/components/modal/index.cjs +0 -8
  48. package/node_modules/@agnos-ui/core/components/modal/index.d.ts +0 -1
  49. package/node_modules/@agnos-ui/core/components/modal/index.js +0 -8
  50. package/node_modules/@agnos-ui/core/components/modal/modal.d.ts +0 -245
  51. package/node_modules/@agnos-ui/core/components/pagination/index.cjs +0 -5
  52. package/node_modules/@agnos-ui/core/components/pagination/index.d.ts +0 -1
  53. package/node_modules/@agnos-ui/core/components/pagination/index.js +0 -5
  54. package/node_modules/@agnos-ui/core/components/pagination/pagination.d.ts +0 -313
  55. package/node_modules/@agnos-ui/core/components/progressbar/index.cjs +0 -5
  56. package/node_modules/@agnos-ui/core/components/progressbar/index.d.ts +0 -1
  57. package/node_modules/@agnos-ui/core/components/progressbar/index.js +0 -5
  58. package/node_modules/@agnos-ui/core/components/progressbar/progressbar.d.ts +0 -91
  59. package/node_modules/@agnos-ui/core/components/rating/index.cjs +0 -5
  60. package/node_modules/@agnos-ui/core/components/rating/index.d.ts +0 -1
  61. package/node_modules/@agnos-ui/core/components/rating/index.js +0 -5
  62. package/node_modules/@agnos-ui/core/components/rating/rating.d.ts +0 -191
  63. package/node_modules/@agnos-ui/core/components/slider/index.cjs +0 -5
  64. package/node_modules/@agnos-ui/core/components/slider/index.d.ts +0 -1
  65. package/node_modules/@agnos-ui/core/components/slider/index.js +0 -5
  66. package/node_modules/@agnos-ui/core/components/slider/slider-utils.d.ts +0 -25
  67. package/node_modules/@agnos-ui/core/components/slider/slider.d.ts +0 -383
  68. package/node_modules/@agnos-ui/core/components/toast/index.cjs +0 -7
  69. package/node_modules/@agnos-ui/core/components/toast/index.d.ts +0 -2
  70. package/node_modules/@agnos-ui/core/components/toast/index.js +0 -7
  71. package/node_modules/@agnos-ui/core/components/toast/toast.d.ts +0 -66
  72. package/node_modules/@agnos-ui/core/components/toast/toaster.d.ts +0 -128
  73. package/node_modules/@agnos-ui/core/components/tree/index.cjs +0 -5
  74. package/node_modules/@agnos-ui/core/components/tree/index.d.ts +0 -1
  75. package/node_modules/@agnos-ui/core/components/tree/index.js +0 -5
  76. package/node_modules/@agnos-ui/core/components/tree/tree.d.ts +0 -143
  77. package/node_modules/@agnos-ui/core/config.cjs +0 -36
  78. package/node_modules/@agnos-ui/core/config.d.ts +0 -117
  79. package/node_modules/@agnos-ui/core/config.js +0 -36
  80. package/node_modules/@agnos-ui/core/directive-Bsreu2z1.js +0 -523
  81. package/node_modules/@agnos-ui/core/directive-DCaXmRe_.cjs +0 -522
  82. package/node_modules/@agnos-ui/core/drawer-BbFAHV07.cjs +0 -328
  83. package/node_modules/@agnos-ui/core/drawer-C6Qa0xEu.js +0 -329
  84. package/node_modules/@agnos-ui/core/index.cjs +0 -134
  85. package/node_modules/@agnos-ui/core/index.d.ts +0 -29
  86. package/node_modules/@agnos-ui/core/index.js +0 -134
  87. package/node_modules/@agnos-ui/core/isFocusable-Ckwus82R.js +0 -32
  88. package/node_modules/@agnos-ui/core/isFocusable-DfzDLeAN.cjs +0 -31
  89. package/node_modules/@agnos-ui/core/modal-BsNuHhT7.cjs +0 -252
  90. package/node_modules/@agnos-ui/core/modal-CgzY8ezz.js +0 -253
  91. package/node_modules/@agnos-ui/core/package.json +0 -57
  92. package/node_modules/@agnos-ui/core/pagination-ZxGaNWZz.js +0 -255
  93. package/node_modules/@agnos-ui/core/pagination-xbcOHnhd.cjs +0 -254
  94. package/node_modules/@agnos-ui/core/progressbar-CRbMKp4b.cjs +0 -86
  95. package/node_modules/@agnos-ui/core/progressbar-CSEIFnlD.js +0 -87
  96. package/node_modules/@agnos-ui/core/promise-CxCD3NYv.cjs +0 -118
  97. package/node_modules/@agnos-ui/core/promise-D-RZVPuv.js +0 -119
  98. package/node_modules/@agnos-ui/core/rating-BIdiiPUo.js +0 -184
  99. package/node_modules/@agnos-ui/core/rating-qx1xaBmz.cjs +0 -183
  100. package/node_modules/@agnos-ui/core/scrollbars-CT87iv_6.cjs +0 -30
  101. package/node_modules/@agnos-ui/core/scrollbars-CcxSrnCx.js +0 -31
  102. package/node_modules/@agnos-ui/core/services/extendWidget.cjs +0 -41
  103. package/node_modules/@agnos-ui/core/services/extendWidget.d.ts +0 -31
  104. package/node_modules/@agnos-ui/core/services/extendWidget.js +0 -41
  105. package/node_modules/@agnos-ui/core/services/floatingUI.cjs +0 -111
  106. package/node_modules/@agnos-ui/core/services/floatingUI.d.ts +0 -76
  107. package/node_modules/@agnos-ui/core/services/floatingUI.js +0 -111
  108. package/node_modules/@agnos-ui/core/services/focusElement.cjs +0 -46
  109. package/node_modules/@agnos-ui/core/services/focusElement.d.ts +0 -9
  110. package/node_modules/@agnos-ui/core/services/focusElement.js +0 -46
  111. package/node_modules/@agnos-ui/core/services/focustrack.cjs +0 -47
  112. package/node_modules/@agnos-ui/core/services/focustrack.d.ts +0 -40
  113. package/node_modules/@agnos-ui/core/services/focustrack.js +0 -47
  114. package/node_modules/@agnos-ui/core/services/hash.cjs +0 -15
  115. package/node_modules/@agnos-ui/core/services/hash.d.ts +0 -3
  116. package/node_modules/@agnos-ui/core/services/hash.js +0 -15
  117. package/node_modules/@agnos-ui/core/services/intersection.cjs +0 -53
  118. package/node_modules/@agnos-ui/core/services/intersection.d.ts +0 -30
  119. package/node_modules/@agnos-ui/core/services/intersection.js +0 -53
  120. package/node_modules/@agnos-ui/core/services/matchMedia.cjs +0 -14
  121. package/node_modules/@agnos-ui/core/services/matchMedia.d.ts +0 -8
  122. package/node_modules/@agnos-ui/core/services/matchMedia.js +0 -14
  123. package/node_modules/@agnos-ui/core/services/navManager.cjs +0 -166
  124. package/node_modules/@agnos-ui/core/services/navManager.d.ts +0 -144
  125. package/node_modules/@agnos-ui/core/services/navManager.js +0 -166
  126. package/node_modules/@agnos-ui/core/services/pointerdownPosition.cjs +0 -60
  127. package/node_modules/@agnos-ui/core/services/pointerdownPosition.d.ts +0 -42
  128. package/node_modules/@agnos-ui/core/services/pointerdownPosition.js +0 -60
  129. package/node_modules/@agnos-ui/core/services/portal.cjs +0 -42
  130. package/node_modules/@agnos-ui/core/services/portal.d.ts +0 -16
  131. package/node_modules/@agnos-ui/core/services/portal.js +0 -42
  132. package/node_modules/@agnos-ui/core/services/resizeObserver.cjs +0 -54
  133. package/node_modules/@agnos-ui/core/services/resizeObserver.d.ts +0 -18
  134. package/node_modules/@agnos-ui/core/services/resizeObserver.js +0 -54
  135. package/node_modules/@agnos-ui/core/services/siblingsInert.cjs +0 -44
  136. package/node_modules/@agnos-ui/core/services/siblingsInert.d.ts +0 -16
  137. package/node_modules/@agnos-ui/core/services/siblingsInert.js +0 -44
  138. package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.cjs +0 -186
  139. package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.d.ts +0 -166
  140. package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.js +0 -186
  141. package/node_modules/@agnos-ui/core/services/transitions/collapse.cjs +0 -40
  142. package/node_modules/@agnos-ui/core/services/transitions/collapse.d.ts +0 -49
  143. package/node_modules/@agnos-ui/core/services/transitions/collapse.js +0 -40
  144. package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.cjs +0 -32
  145. package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.d.ts +0 -25
  146. package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.js +0 -32
  147. package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.cjs +0 -37
  148. package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.d.ts +0 -47
  149. package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.js +0 -37
  150. package/node_modules/@agnos-ui/core/slider-B93hE0ag.cjs +0 -807
  151. package/node_modules/@agnos-ui/core/slider-Cjiq9FgI.js +0 -808
  152. package/node_modules/@agnos-ui/core/textDirection-cNgt24LJ.js +0 -4
  153. package/node_modules/@agnos-ui/core/textDirection-zqcZ5-eK.cjs +0 -3
  154. package/node_modules/@agnos-ui/core/toaster-BQWqxYv-.cjs +0 -190
  155. package/node_modules/@agnos-ui/core/toaster-BzEkshT2.js +0 -191
  156. package/node_modules/@agnos-ui/core/tree-DY04XPPg.cjs +0 -228
  157. package/node_modules/@agnos-ui/core/tree-HwcvZ0_p.js +0 -229
  158. package/node_modules/@agnos-ui/core/types.cjs +0 -6
  159. package/node_modules/@agnos-ui/core/types.d.ts +0 -246
  160. package/node_modules/@agnos-ui/core/types.js +0 -6
  161. package/node_modules/@agnos-ui/core/utils/directive.cjs +0 -28
  162. package/node_modules/@agnos-ui/core/utils/directive.d.ts +0 -352
  163. package/node_modules/@agnos-ui/core/utils/directive.js +0 -28
  164. package/node_modules/@agnos-ui/core/utils/func.cjs +0 -7
  165. package/node_modules/@agnos-ui/core/utils/func.d.ts +0 -11
  166. package/node_modules/@agnos-ui/core/utils/func.js +0 -7
  167. package/node_modules/@agnos-ui/core/utils/id.cjs +0 -5
  168. package/node_modules/@agnos-ui/core/utils/id.d.ts +0 -6
  169. package/node_modules/@agnos-ui/core/utils/id.js +0 -5
  170. package/node_modules/@agnos-ui/core/utils/internal/assign.d.ts +0 -10
  171. package/node_modules/@agnos-ui/core/utils/internal/checks.d.ts +0 -57
  172. package/node_modules/@agnos-ui/core/utils/internal/dom.d.ts +0 -75
  173. package/node_modules/@agnos-ui/core/utils/internal/isFocusable.d.ts +0 -9
  174. package/node_modules/@agnos-ui/core/utils/internal/math.d.ts +0 -5
  175. package/node_modules/@agnos-ui/core/utils/internal/promise.d.ts +0 -98
  176. package/node_modules/@agnos-ui/core/utils/internal/scrollbars.d.ts +0 -8
  177. package/node_modules/@agnos-ui/core/utils/internal/sort.d.ts +0 -16
  178. package/node_modules/@agnos-ui/core/utils/internal/ssrHTMLElement.d.ts +0 -17
  179. package/node_modules/@agnos-ui/core/utils/internal/textDirection.d.ts +0 -7
  180. package/node_modules/@agnos-ui/core/utils/internal/traversal.d.ts +0 -54
  181. package/node_modules/@agnos-ui/core/utils/stores.cjs +0 -172
  182. package/node_modules/@agnos-ui/core/utils/stores.d.ts +0 -224
  183. package/node_modules/@agnos-ui/core/utils/stores.js +0 -172
  184. package/node_modules/@agnos-ui/core/utils/widget.cjs +0 -8
  185. package/node_modules/@agnos-ui/core/utils/widget.d.ts +0 -11
  186. package/node_modules/@agnos-ui/core/utils/widget.js +0 -8
  187. package/node_modules/@agnos-ui/core/utils/writables.cjs +0 -16
  188. package/node_modules/@agnos-ui/core/utils/writables.d.ts +0 -95
  189. package/node_modules/@agnos-ui/core/utils/writables.js +0 -16
  190. package/node_modules/@agnos-ui/core/writables-DYGjj5T3.js +0 -103
  191. package/node_modules/@agnos-ui/core/writables-Dt68gADJ.cjs +0 -102
@@ -1,166 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const tansu = require("@amadeus-it-group/tansu");
4
- const utils_directive = require("../directive-DCaXmRe_.cjs");
5
- const isFocusable = require("../isFocusable-DfzDLeAN.cjs");
6
- const textDirection = require("../textDirection-zqcZ5-eK.cjs");
7
- const compareDomOrder = (element1, element2) => {
8
- if (element1 === element2) {
9
- return 0;
10
- }
11
- const result = element1.compareDocumentPosition(element2);
12
- if (result & Node.DOCUMENT_POSITION_FOLLOWING) {
13
- return -1;
14
- } else if (result & Node.DOCUMENT_POSITION_PRECEDING) {
15
- return 1;
16
- }
17
- throw new Error("failed to compare elements");
18
- };
19
- const textInputTypes = /* @__PURE__ */ new Set(["text", "search", "url", "tel", "password"]);
20
- const isTextInput = (element) => element instanceof HTMLInputElement && textInputTypes.has(element.type);
21
- const getKeyName = (event) => {
22
- let key = event.key;
23
- if (event.shiftKey) {
24
- key = `Shift+${key}`;
25
- }
26
- if (event.altKey) {
27
- key = `Alt+${key}`;
28
- }
29
- if (event.ctrlKey) {
30
- key = `Ctrl+${key}`;
31
- }
32
- if (event.metaKey) {
33
- key = `Meta+${key}`;
34
- }
35
- return key;
36
- };
37
- const isInternalInputNavigation = (event) => {
38
- const { target, key } = event;
39
- if (isTextInput(target) && (key === "ArrowLeft" || key === "ArrowRight" || key === "Home" || key === "End")) {
40
- let startPosition;
41
- if (key === "ArrowLeft" || key === "ArrowRight") {
42
- const direction = textDirection.getTextDirection(target);
43
- startPosition = key === (direction === "ltr" ? "ArrowLeft" : "ArrowRight");
44
- } else {
45
- startPosition = key === "Home";
46
- }
47
- const cursorPosition = target.selectionStart === target.selectionEnd ? target.selectionStart : null;
48
- if (startPosition && cursorPosition !== 0 || !startPosition && cursorPosition !== target.value.length) {
49
- return true;
50
- }
51
- }
52
- return false;
53
- };
54
- const defaultSelector = (directiveElement) => [directiveElement];
55
- const createNavManager = () => {
56
- const directiveInstances$ = utils_directive.registrationArray();
57
- const elementsRefresh$ = tansu.writable({});
58
- const refreshElements = (now = true) => {
59
- elementsRefresh$.set({});
60
- if (now) {
61
- commonAncestor$();
62
- elementsInDomOrder$();
63
- }
64
- };
65
- const elements$ = tansu.computed(() => {
66
- elementsRefresh$();
67
- const res = [];
68
- for (const item of directiveInstances$()) {
69
- res.push(...item());
70
- }
71
- return res;
72
- });
73
- const commonAncestor$ = tansu.computed(() => utils_directive.computeCommonAncestor(elements$()), { equal: Object.is });
74
- const elementsInDomOrder$ = tansu.computed(() => [...elements$()].sort(compareDomOrder));
75
- const ancestorDirection = () => {
76
- const commonAncestor = commonAncestor$();
77
- return commonAncestor ? textDirection.getTextDirection(commonAncestor) : "ltr";
78
- };
79
- const preventDefaultIfRelevant = (value, event) => {
80
- if (value) {
81
- event?.preventDefault();
82
- }
83
- return value;
84
- };
85
- const focusIndex = (index, moveDirection = 0) => {
86
- const array = elementsInDomOrder$();
87
- while (index >= 0 && index < array.length) {
88
- const newItem = array[index];
89
- if (isFocusable.isFocusable(newItem)) {
90
- newItem.focus();
91
- if (moveDirection != 0 && isTextInput(newItem)) {
92
- const changeDirection = ancestorDirection() !== textDirection.getTextDirection(newItem);
93
- const position = moveDirection > 0 !== changeDirection ? 0 : newItem.value.length;
94
- newItem.setSelectionRange(position, position, position === 0 ? "forward" : "backward");
95
- }
96
- return newItem;
97
- }
98
- if (moveDirection === 0) {
99
- break;
100
- } else {
101
- index += moveDirection;
102
- }
103
- }
104
- return null;
105
- };
106
- const createFocusNeighbour = (moveDirection) => ({
107
- event,
108
- referenceElement = event?.target ?? document.activeElement
109
- } = {}) => {
110
- const curIndex = referenceElement ? elementsInDomOrder$().indexOf(referenceElement) : -1;
111
- if (curIndex > -1) {
112
- return preventDefaultIfRelevant(focusIndex(curIndex + moveDirection, moveDirection), event);
113
- }
114
- return null;
115
- };
116
- const directive = utils_directive.browserDirective((directiveElement, config) => {
117
- const onKeyDown = (event) => {
118
- if (isInternalInputNavigation(event)) {
119
- return;
120
- }
121
- const keyName = getKeyName(event);
122
- const handler = config.keys?.[keyName];
123
- if (handler) {
124
- refreshElements(false);
125
- handler({ event, directiveElement, navManager, context: config.context });
126
- }
127
- };
128
- directiveElement.addEventListener("keydown", onKeyDown);
129
- const unregister = directiveInstances$.register(() => (config?.selector ?? defaultSelector)(directiveElement));
130
- return {
131
- update(newConfig) {
132
- config = newConfig;
133
- },
134
- destroy() {
135
- directiveElement.removeEventListener("keydown", onKeyDown);
136
- unregister();
137
- }
138
- };
139
- });
140
- const focusPrevious = createFocusNeighbour(-1);
141
- const focusNext = createFocusNeighbour(1);
142
- const focusFirst = ({ event } = {}) => preventDefaultIfRelevant(focusIndex(0, 1), event);
143
- const focusLast = ({ event } = {}) => preventDefaultIfRelevant(focusIndex(elementsInDomOrder$().length - 1, -1), event);
144
- const focusLeft = (...args) => (ancestorDirection() === "rtl" ? focusNext : focusPrevious)(...args);
145
- const focusRight = (...args) => (ancestorDirection() === "rtl" ? focusPrevious : focusNext)(...args);
146
- const focusFirstLeft = (...args) => (ancestorDirection() === "rtl" ? focusLast : focusFirst)(...args);
147
- const focusFirstRight = (...args) => (ancestorDirection() === "rtl" ? focusFirst : focusLast)(...args);
148
- const navManager = {
149
- elementsInDomOrder$,
150
- directive,
151
- focusIndex,
152
- focusPrevious,
153
- focusNext,
154
- focusFirst,
155
- focusFirstLeft,
156
- focusFirstRight,
157
- focusLast,
158
- focusLeft,
159
- focusRight,
160
- refreshElements
161
- };
162
- return navManager;
163
- };
164
- exports.createNavManager = createNavManager;
165
- exports.getKeyName = getKeyName;
166
- exports.isInternalInputNavigation = isInternalInputNavigation;
@@ -1,144 +0,0 @@
1
- import { type ReadableSignal } from '@amadeus-it-group/tansu';
2
- import type { Directive, SSRHTMLElement } from '../types';
3
- /**
4
- * A type representing a function that determines the neighboring element to focus on.
5
- * @returns The next HTMLElement to focus on, or null if no suitable element is found.
6
- */
7
- export type FocusNeighbour = (arg?: {
8
- event?: Event;
9
- referenceElement?: HTMLElement | null;
10
- }) => HTMLElement | null;
11
- /**
12
- * A type representing a function that focuses on the end element.
13
- * @returns The HTMLElement that was focused, or null if no element was focused.
14
- */
15
- export type FocusEnd = (arg?: {
16
- event?: Event;
17
- }) => HTMLElement | null;
18
- /**
19
- * Represents a navigation manager that handles focusable elements in the DOM.
20
- *
21
- * @template T - The type of the configuration for the navigation manager items.
22
- */
23
- export type NavManager<T> = {
24
- /**
25
- * Store containing the navigable elements in DOM order
26
- */
27
- elementsInDomOrder$: ReadableSignal<HTMLElement[]>;
28
- /**
29
- * Directive to attach the nav manager
30
- */
31
- directive: Directive<NavManagerItemConfig<T>, SSRHTMLElement>;
32
- /**
33
- * Refresh the elements list.
34
- * @param now force the instant refresh of the elements
35
- */
36
- refreshElements: (now?: boolean) => void;
37
- /**
38
- * Focus the element at the given idex.
39
- * If the element at the given index is not focusable, use the moveDirection to step into the next focusable element.
40
- * @param index the index of the element to focus
41
- * @param moveDirection a move direction
42
- * @returns the new focusable element if found, null otherwise
43
- */
44
- focusIndex: (index: number, moveDirection: -1 | 0 | 1) => HTMLElement | null;
45
- /**
46
- * Focus the previous element, respecting the ancestor direction.
47
- */
48
- focusPrevious: FocusNeighbour;
49
- /**
50
- * Focus the next element, respecting the ancestor direction.
51
- */
52
- focusNext: FocusNeighbour;
53
- /**
54
- * Focus the first element, respecting the ancestor direction.
55
- */
56
- focusFirst: FocusEnd;
57
- /**
58
- * Focus the element at the left-end of the list.
59
- */
60
- focusFirstLeft: FocusEnd;
61
- /**
62
- * Focus the element at the right-end of the list.
63
- */
64
- focusFirstRight: FocusEnd;
65
- /**
66
- * Focus the last element, respecting the ancestor direction.
67
- */
68
- focusLast: FocusEnd;
69
- /**
70
- * Focus the next focusable element to the left of the currently focused element.
71
- */
72
- focusLeft: FocusNeighbour;
73
- /**
74
- * Focus the next focusable element to the right of the currently focused element.
75
- */
76
- focusRight: FocusNeighbour;
77
- };
78
- /**
79
- * Returns the key name given the keyboard event. The key name is built using event.key (such as ArrowLeft, PageDown...),
80
- * prefixed with the modifiers. If present, modifiers are always in the same order: Meta+Ctrl+Alt+Shift+...
81
- * @param event - keyboard event
82
- * @returns the name of the key, including modifiers
83
- */
84
- export declare const getKeyName: (event: KeyboardEvent) => string;
85
- /**
86
- * Returns true if the keyboard event is an ArrowLeft, ArrowRight, Home or End key press that should make the cursor move inside
87
- * the input and false otherwise (i.e. the key is not ArrowLeft, ArrowRight, Home or End key, or that would not make the cursor move
88
- * because it is already at one end of the input)
89
- * @param event - keyboard event
90
- * @returns true if the keyboard event is an ArrowLeft, ArrowRight, Home or End key press that should make the cursor move inside
91
- * the input and false otherwise.
92
- */
93
- export declare const isInternalInputNavigation: (event: KeyboardEvent) => boolean;
94
- /**
95
- * Type of a key handler of the navigation manager.
96
- * A key handler receives an object as its parameter, with the following properties:
97
- * - event: key event
98
- * - directiveElement: DOM element which has the navigation manager directive
99
- * - navManager: navigation manager instance
100
- * @template T - The type of the context object, defaults to `any`.
101
- */
102
- export type NavManagerKeyHandler<T = any> = (info: {
103
- directiveElement: HTMLElement;
104
- event: Event;
105
- navManager: NavManager<T>;
106
- context?: T;
107
- }) => void;
108
- /**
109
- * Configuration object for a navigation manager item.
110
- *
111
- * @template T - The type of the context object.
112
- */
113
- export interface NavManagerItemConfig<T = any> {
114
- /**
115
- * Map of key handlers.
116
- * The key in the map should match the result of calling {@link getKeyName} on the key event (for example "ArrowLeft" or "Ctrl+PageDown").
117
- * The value in the map is the corresponding key handler.
118
- */
119
- keys?: Record<string, NavManagerKeyHandler<T>>;
120
- /**
121
- * Function returning DOM elements to include in the navigation manager.
122
- * It receives as a parameter the DOM element on which the navigation manager directive is used.
123
- * If not specified, the default selector function only returns the element on which the navigation manager directive is used.
124
- */
125
- selector?: (directiveElement: HTMLElement) => Iterable<HTMLElement>;
126
- /**
127
- *
128
- */
129
- context?: T;
130
- }
131
- /**
132
- * Returns a new instance of the navigation manager.
133
- *
134
- * The navigation manager simplifies keyboard navigation for a set of DOM elements.
135
- * It provides a directive to use on some DOM elements, both to add the keydown event handler and to specify which elements should be managed
136
- * (either by directly putting the directive on those elements, or by putting the directive on a parent element and
137
- * specifying which child elements should be included through a selector function).
138
- *
139
- * It provides some utilities to move the focus between those elements (focusFirst/focusLast, focusLeft/focusRight, focusPrevious/focusNext).
140
- *
141
- * @template T - The type of the context object used in the navigation manager.
142
- * @returns An object containing methods and properties for managing focus navigation.
143
- */
144
- export declare const createNavManager: <T>() => NavManager<T>;
@@ -1,166 +0,0 @@
1
- import { writable, computed } from "@amadeus-it-group/tansu";
2
- import { u as registrationArray, A as computeCommonAncestor, d as browserDirective } from "../directive-Bsreu2z1.js";
3
- import { i as isFocusable } from "../isFocusable-Ckwus82R.js";
4
- import { g as getTextDirection } from "../textDirection-cNgt24LJ.js";
5
- const compareDomOrder = (element1, element2) => {
6
- if (element1 === element2) {
7
- return 0;
8
- }
9
- const result = element1.compareDocumentPosition(element2);
10
- if (result & Node.DOCUMENT_POSITION_FOLLOWING) {
11
- return -1;
12
- } else if (result & Node.DOCUMENT_POSITION_PRECEDING) {
13
- return 1;
14
- }
15
- throw new Error("failed to compare elements");
16
- };
17
- const textInputTypes = /* @__PURE__ */ new Set(["text", "search", "url", "tel", "password"]);
18
- const isTextInput = (element) => element instanceof HTMLInputElement && textInputTypes.has(element.type);
19
- const getKeyName = (event) => {
20
- let key = event.key;
21
- if (event.shiftKey) {
22
- key = `Shift+${key}`;
23
- }
24
- if (event.altKey) {
25
- key = `Alt+${key}`;
26
- }
27
- if (event.ctrlKey) {
28
- key = `Ctrl+${key}`;
29
- }
30
- if (event.metaKey) {
31
- key = `Meta+${key}`;
32
- }
33
- return key;
34
- };
35
- const isInternalInputNavigation = (event) => {
36
- const { target, key } = event;
37
- if (isTextInput(target) && (key === "ArrowLeft" || key === "ArrowRight" || key === "Home" || key === "End")) {
38
- let startPosition;
39
- if (key === "ArrowLeft" || key === "ArrowRight") {
40
- const direction = getTextDirection(target);
41
- startPosition = key === (direction === "ltr" ? "ArrowLeft" : "ArrowRight");
42
- } else {
43
- startPosition = key === "Home";
44
- }
45
- const cursorPosition = target.selectionStart === target.selectionEnd ? target.selectionStart : null;
46
- if (startPosition && cursorPosition !== 0 || !startPosition && cursorPosition !== target.value.length) {
47
- return true;
48
- }
49
- }
50
- return false;
51
- };
52
- const defaultSelector = (directiveElement) => [directiveElement];
53
- const createNavManager = () => {
54
- const directiveInstances$ = registrationArray();
55
- const elementsRefresh$ = writable({});
56
- const refreshElements = (now = true) => {
57
- elementsRefresh$.set({});
58
- if (now) {
59
- commonAncestor$();
60
- elementsInDomOrder$();
61
- }
62
- };
63
- const elements$ = computed(() => {
64
- elementsRefresh$();
65
- const res = [];
66
- for (const item of directiveInstances$()) {
67
- res.push(...item());
68
- }
69
- return res;
70
- });
71
- const commonAncestor$ = computed(() => computeCommonAncestor(elements$()), { equal: Object.is });
72
- const elementsInDomOrder$ = computed(() => [...elements$()].sort(compareDomOrder));
73
- const ancestorDirection = () => {
74
- const commonAncestor = commonAncestor$();
75
- return commonAncestor ? getTextDirection(commonAncestor) : "ltr";
76
- };
77
- const preventDefaultIfRelevant = (value, event) => {
78
- if (value) {
79
- event?.preventDefault();
80
- }
81
- return value;
82
- };
83
- const focusIndex = (index, moveDirection = 0) => {
84
- const array = elementsInDomOrder$();
85
- while (index >= 0 && index < array.length) {
86
- const newItem = array[index];
87
- if (isFocusable(newItem)) {
88
- newItem.focus();
89
- if (moveDirection != 0 && isTextInput(newItem)) {
90
- const changeDirection = ancestorDirection() !== getTextDirection(newItem);
91
- const position = moveDirection > 0 !== changeDirection ? 0 : newItem.value.length;
92
- newItem.setSelectionRange(position, position, position === 0 ? "forward" : "backward");
93
- }
94
- return newItem;
95
- }
96
- if (moveDirection === 0) {
97
- break;
98
- } else {
99
- index += moveDirection;
100
- }
101
- }
102
- return null;
103
- };
104
- const createFocusNeighbour = (moveDirection) => ({
105
- event,
106
- referenceElement = event?.target ?? document.activeElement
107
- } = {}) => {
108
- const curIndex = referenceElement ? elementsInDomOrder$().indexOf(referenceElement) : -1;
109
- if (curIndex > -1) {
110
- return preventDefaultIfRelevant(focusIndex(curIndex + moveDirection, moveDirection), event);
111
- }
112
- return null;
113
- };
114
- const directive = browserDirective((directiveElement, config) => {
115
- const onKeyDown = (event) => {
116
- if (isInternalInputNavigation(event)) {
117
- return;
118
- }
119
- const keyName = getKeyName(event);
120
- const handler = config.keys?.[keyName];
121
- if (handler) {
122
- refreshElements(false);
123
- handler({ event, directiveElement, navManager, context: config.context });
124
- }
125
- };
126
- directiveElement.addEventListener("keydown", onKeyDown);
127
- const unregister = directiveInstances$.register(() => (config?.selector ?? defaultSelector)(directiveElement));
128
- return {
129
- update(newConfig) {
130
- config = newConfig;
131
- },
132
- destroy() {
133
- directiveElement.removeEventListener("keydown", onKeyDown);
134
- unregister();
135
- }
136
- };
137
- });
138
- const focusPrevious = createFocusNeighbour(-1);
139
- const focusNext = createFocusNeighbour(1);
140
- const focusFirst = ({ event } = {}) => preventDefaultIfRelevant(focusIndex(0, 1), event);
141
- const focusLast = ({ event } = {}) => preventDefaultIfRelevant(focusIndex(elementsInDomOrder$().length - 1, -1), event);
142
- const focusLeft = (...args) => (ancestorDirection() === "rtl" ? focusNext : focusPrevious)(...args);
143
- const focusRight = (...args) => (ancestorDirection() === "rtl" ? focusPrevious : focusNext)(...args);
144
- const focusFirstLeft = (...args) => (ancestorDirection() === "rtl" ? focusLast : focusFirst)(...args);
145
- const focusFirstRight = (...args) => (ancestorDirection() === "rtl" ? focusFirst : focusLast)(...args);
146
- const navManager = {
147
- elementsInDomOrder$,
148
- directive,
149
- focusIndex,
150
- focusPrevious,
151
- focusNext,
152
- focusFirst,
153
- focusFirstLeft,
154
- focusFirstRight,
155
- focusLast,
156
- focusLeft,
157
- focusRight,
158
- refreshElements
159
- };
160
- return navManager;
161
- };
162
- export {
163
- createNavManager,
164
- getKeyName,
165
- isInternalInputNavigation
166
- };
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const utils_directive = require("../directive-DCaXmRe_.cjs");
4
- const utils_func = require("../utils/func.cjs");
5
- const createPointerdownPositionDirective = (onStart) => utils_directive.browserDirective((element, arg) => {
6
- let activePointerId = null;
7
- let activeHandlers = null;
8
- let removePointerMoveEvent = utils_func.noop;
9
- let removePointerUpEvent = utils_func.noop;
10
- let removePointerCancelEvent = utils_func.noop;
11
- const onMove = (e) => {
12
- if (e.pointerId === activePointerId) {
13
- e.preventDefault();
14
- activeHandlers?.onMove?.(e);
15
- }
16
- };
17
- const endCurrent = (e) => {
18
- removePointerMoveEvent();
19
- removePointerUpEvent();
20
- removePointerCancelEvent();
21
- removePointerMoveEvent = utils_func.noop;
22
- removePointerUpEvent = utils_func.noop;
23
- removePointerCancelEvent = utils_func.noop;
24
- const handlers = activeHandlers;
25
- activeHandlers = null;
26
- activePointerId = null;
27
- handlers?.onEnd?.(e);
28
- };
29
- const onEnd = (e) => {
30
- if (e.pointerId === activePointerId) {
31
- e.preventDefault();
32
- endCurrent(e);
33
- }
34
- };
35
- const removePointerDownEvent = utils_directive.addEvent(element, "pointerdown", (e) => {
36
- if (activeHandlers) {
37
- endCurrent();
38
- }
39
- const pointerId = e.pointerId;
40
- const startResult = onStart(e, arg);
41
- if (startResult) {
42
- e.preventDefault();
43
- activePointerId = pointerId;
44
- activeHandlers = startResult;
45
- removePointerMoveEvent = utils_directive.addEvent(document, "pointermove", onMove);
46
- removePointerUpEvent = utils_directive.addEvent(document, "pointerup", onEnd);
47
- removePointerCancelEvent = utils_directive.addEvent(document, "pointercancel", onEnd);
48
- }
49
- });
50
- return {
51
- update(newArg) {
52
- arg = newArg;
53
- },
54
- destroy() {
55
- removePointerDownEvent();
56
- endCurrent();
57
- }
58
- };
59
- });
60
- exports.createPointerdownPositionDirective = createPointerdownPositionDirective;
@@ -1,42 +0,0 @@
1
- import type { Directive } from '../types';
2
- /**
3
- * Configuration options for tracking pointer position after a pointerdown event.
4
- */
5
- export interface PointerPositionHandlers {
6
- /**
7
- * Callback function invoked when the mouse moves after a pointerdown event.
8
- * @param position - The current mouse position information including origin and current coordinates.
9
- */
10
- onMove?: (event: PointerEvent) => void;
11
- /**
12
- * Callback function invoked when the move ends after a pointerdown event.
13
- */
14
- onEnd?: (event?: PointerEvent) => void;
15
- }
16
- /**
17
- * Creates a directive for tracking pointer position during drag operations.
18
- *
19
- * This function sets up event listeners that track pointer movements from an initial pointerdown event
20
- * through pointermover and pointerup events. It provides a directive that can be attached to DOM elements
21
- * to enable drag tracking functionality.
22
- *
23
- * @param onStart - Callback function invoked when the pointerdown event happens.
24
- *
25
- * @returns The pointerdownPositionDirective that can be applied to elements.
26
- *
27
- * @example
28
- * ```typescript
29
- * const pointerPositionDirective = createPointerdownPositionDirective((event) => {
30
- * console.log(`Drag started at (${event.clientX}, ${event.clientY})`);
31
- * return {
32
- * onMove: (event) => {
33
- * console.log(`Dragging: ${event.clientX}, dy=${event.clientY}`);
34
- * },
35
- * onEnd: () => {
36
- * console.log(`Drag ended`);
37
- * }
38
- * };
39
- * });
40
- * ```
41
- */
42
- export declare const createPointerdownPositionDirective: <T = void>(onStart: (position: PointerEvent, arg: T) => PointerPositionHandlers | undefined) => Directive<T>;
@@ -1,60 +0,0 @@
1
- import { d as browserDirective, w as addEvent } from "../directive-Bsreu2z1.js";
2
- import { noop } from "../utils/func.js";
3
- const createPointerdownPositionDirective = (onStart) => browserDirective((element, arg) => {
4
- let activePointerId = null;
5
- let activeHandlers = null;
6
- let removePointerMoveEvent = noop;
7
- let removePointerUpEvent = noop;
8
- let removePointerCancelEvent = noop;
9
- const onMove = (e) => {
10
- if (e.pointerId === activePointerId) {
11
- e.preventDefault();
12
- activeHandlers?.onMove?.(e);
13
- }
14
- };
15
- const endCurrent = (e) => {
16
- removePointerMoveEvent();
17
- removePointerUpEvent();
18
- removePointerCancelEvent();
19
- removePointerMoveEvent = noop;
20
- removePointerUpEvent = noop;
21
- removePointerCancelEvent = noop;
22
- const handlers = activeHandlers;
23
- activeHandlers = null;
24
- activePointerId = null;
25
- handlers?.onEnd?.(e);
26
- };
27
- const onEnd = (e) => {
28
- if (e.pointerId === activePointerId) {
29
- e.preventDefault();
30
- endCurrent(e);
31
- }
32
- };
33
- const removePointerDownEvent = addEvent(element, "pointerdown", (e) => {
34
- if (activeHandlers) {
35
- endCurrent();
36
- }
37
- const pointerId = e.pointerId;
38
- const startResult = onStart(e, arg);
39
- if (startResult) {
40
- e.preventDefault();
41
- activePointerId = pointerId;
42
- activeHandlers = startResult;
43
- removePointerMoveEvent = addEvent(document, "pointermove", onMove);
44
- removePointerUpEvent = addEvent(document, "pointerup", onEnd);
45
- removePointerCancelEvent = addEvent(document, "pointercancel", onEnd);
46
- }
47
- });
48
- return {
49
- update(newArg) {
50
- arg = newArg;
51
- },
52
- destroy() {
53
- removePointerDownEvent();
54
- endCurrent();
55
- }
56
- };
57
- });
58
- export {
59
- createPointerdownPositionDirective
60
- };
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const utils_directive = require("../directive-DCaXmRe_.cjs");
4
- const portal = utils_directive.browserDirective(
5
- (content, newArg) => {
6
- let arg;
7
- let replaceComment;
8
- const removeReplaceComment = () => {
9
- if (replaceComment) {
10
- replaceComment.parentNode?.replaceChild(content, replaceComment);
11
- replaceComment = null;
12
- }
13
- };
14
- const update = (newArg2) => {
15
- if (newArg2 !== arg && (newArg2?.container !== arg?.container || newArg2?.insertBefore !== arg?.insertBefore)) {
16
- arg = newArg2;
17
- const container = arg?.container ?? arg?.insertBefore?.parentElement;
18
- if (container) {
19
- const insertBefore = arg?.insertBefore ?? null;
20
- const moveNeeded = content.parentElement !== container || content.nextSibling !== insertBefore;
21
- if (moveNeeded) {
22
- if (!replaceComment) {
23
- replaceComment = content.parentNode?.insertBefore(content.ownerDocument.createComment("portal"), content);
24
- }
25
- container.insertBefore(content, insertBefore);
26
- }
27
- } else {
28
- removeReplaceComment();
29
- }
30
- }
31
- };
32
- update(newArg);
33
- return {
34
- update,
35
- destroy: () => {
36
- removeReplaceComment();
37
- content.parentNode?.removeChild(content);
38
- }
39
- };
40
- }
41
- );
42
- exports.portal = portal;