@agnos-ui/core 0.2.0 → 0.3.1

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 (143) hide show
  1. package/README.md +3 -3
  2. package/accordion-BaWN0_n-.js +330 -0
  3. package/accordion-BuIgxZ0S.cjs +329 -0
  4. package/alert-C4jCg9Pl.cjs +8 -0
  5. package/alert-Dlf-BV98.js +9 -0
  6. package/common-DRdsw5m8.js +76 -0
  7. package/common-nJRMXbwj.cjs +75 -0
  8. package/components/accordion/accordion.d.ts +38 -49
  9. package/components/accordion/index.cjs +7 -0
  10. package/components/accordion/index.js +7 -1
  11. package/components/alert/alert.d.ts +3 -12
  12. package/components/alert/common.d.ts +4 -13
  13. package/components/alert/index.cjs +10 -0
  14. package/components/alert/index.js +10 -2
  15. package/components/modal/index.cjs +7 -0
  16. package/components/modal/index.js +7 -1
  17. package/components/modal/modal.d.ts +7 -49
  18. package/components/pagination/index.cjs +5 -0
  19. package/components/pagination/index.d.ts +0 -1
  20. package/components/pagination/index.js +5 -2
  21. package/components/pagination/pagination.d.ts +68 -139
  22. package/components/progressbar/index.cjs +5 -0
  23. package/components/progressbar/index.js +5 -1
  24. package/components/progressbar/progressbar.d.ts +6 -22
  25. package/components/rating/index.cjs +5 -0
  26. package/components/rating/index.js +5 -1
  27. package/components/rating/rating.d.ts +16 -11
  28. package/components/select/index.cjs +6 -0
  29. package/components/select/index.js +6 -1
  30. package/components/select/select.d.ts +15 -33
  31. package/components/slider/index.cjs +5 -0
  32. package/components/slider/index.js +5 -1
  33. package/components/slider/slider.d.ts +29 -35
  34. package/components/toast/index.cjs +5 -0
  35. package/components/toast/index.js +5 -1
  36. package/components/toast/toast.d.ts +11 -8
  37. package/config.cjs +38 -0
  38. package/config.d.ts +1 -1
  39. package/config.js +35 -50
  40. package/directive-BTSEYLF3.cjs +404 -0
  41. package/directive-DCYlDznf.js +405 -0
  42. package/func-DR0n-ShK.js +7 -0
  43. package/func-Qd3cD9a3.cjs +6 -0
  44. package/index.cjs +119 -0
  45. package/index.d.ts +1 -1
  46. package/index.js +119 -33
  47. package/modal-BI2qUu1M.js +251 -0
  48. package/modal-rzMpATf5.cjs +250 -0
  49. package/package.json +29 -19
  50. package/pagination--GkwduJn.js +263 -0
  51. package/pagination-EWSWQT1I.cjs +262 -0
  52. package/progressbar-DH7DHYMp.cjs +83 -0
  53. package/progressbar-DuRX7_my.js +84 -0
  54. package/promise-BMJ8qhA8.cjs +118 -0
  55. package/promise-CY2U8bTP.js +119 -0
  56. package/rating-BR5wD7y2.js +173 -0
  57. package/rating-CmuYUSxy.cjs +172 -0
  58. package/select-BCs6HQWn.js +358 -0
  59. package/select-CCIKn8WR.cjs +357 -0
  60. package/services/extendWidget.cjs +32 -0
  61. package/services/extendWidget.d.ts +2 -1
  62. package/services/extendWidget.js +31 -34
  63. package/services/floatingUI.cjs +131 -0
  64. package/services/floatingUI.d.ts +30 -14
  65. package/services/floatingUI.js +128 -102
  66. package/services/focustrack.cjs +47 -0
  67. package/services/focustrack.js +45 -44
  68. package/services/hash.cjs +15 -0
  69. package/services/hash.js +14 -12
  70. package/services/intersection.cjs +53 -0
  71. package/services/intersection.js +48 -50
  72. package/services/matchMedia.cjs +13 -0
  73. package/services/matchMedia.d.ts +7 -0
  74. package/services/matchMedia.js +13 -0
  75. package/services/navManager.cjs +196 -0
  76. package/services/navManager.d.ts +9 -9
  77. package/services/navManager.js +186 -168
  78. package/services/portal.cjs +43 -0
  79. package/services/portal.js +41 -42
  80. package/services/resizeObserver.cjs +32 -0
  81. package/services/resizeObserver.d.ts +1 -1
  82. package/services/resizeObserver.js +31 -28
  83. package/services/siblingsInert.cjs +40 -0
  84. package/services/siblingsInert.js +31 -31
  85. package/services/transitions/baseTransitions.cjs +171 -0
  86. package/services/transitions/baseTransitions.d.ts +16 -16
  87. package/services/transitions/baseTransitions.js +159 -170
  88. package/services/transitions/collapse.cjs +44 -0
  89. package/services/transitions/collapse.js +41 -49
  90. package/services/transitions/cssTransitions.cjs +32 -0
  91. package/services/transitions/cssTransitions.d.ts +2 -1
  92. package/services/transitions/cssTransitions.js +29 -39
  93. package/services/transitions/simpleClassTransition.cjs +31 -0
  94. package/services/transitions/simpleClassTransition.js +30 -41
  95. package/slider-CA_fszn7.js +536 -0
  96. package/slider-DsLvT87U.cjs +535 -0
  97. package/toast-8tWp6x89.js +63 -0
  98. package/toast-Aw8o0Iwe.cjs +62 -0
  99. package/types.cjs +12 -0
  100. package/types.d.ts +21 -1
  101. package/types.js +11 -13
  102. package/utils/directive.cjs +26 -0
  103. package/utils/directive.d.ts +148 -5
  104. package/utils/directive.js +25 -205
  105. package/utils/internal/dom.d.ts +43 -4
  106. package/utils/internal/promise.d.ts +2 -2
  107. package/utils/internal/ssrHTMLElement.d.ts +7 -0
  108. package/utils/stores.cjs +163 -0
  109. package/utils/stores.d.ts +9 -17
  110. package/utils/stores.js +149 -284
  111. package/utils/writables.cjs +13 -0
  112. package/utils/writables.js +12 -71
  113. package/writables-D46sFgGK.cjs +85 -0
  114. package/writables-DoU_XYTX.js +86 -0
  115. package/components/accordion/accordion.js +0 -264
  116. package/components/alert/alert.js +0 -22
  117. package/components/alert/common.js +0 -69
  118. package/components/commonProps.js +0 -1
  119. package/components/modal/modal.js +0 -186
  120. package/components/pagination/bootstrap.d.ts +0 -8
  121. package/components/pagination/bootstrap.js +0 -110
  122. package/components/pagination/pagination.js +0 -195
  123. package/components/progressbar/progressbar.js +0 -78
  124. package/components/rating/rating.js +0 -137
  125. package/components/select/select.js +0 -297
  126. package/components/slider/slider.js +0 -420
  127. package/components/toast/toast.js +0 -43
  128. package/services/transitions/bootstrap/collapse.d.ts +0 -2
  129. package/services/transitions/bootstrap/collapse.js +0 -15
  130. package/services/transitions/bootstrap/fade.d.ts +0 -1
  131. package/services/transitions/bootstrap/fade.js +0 -7
  132. package/services/transitions/bootstrap.d.ts +0 -2
  133. package/services/transitions/bootstrap.js +0 -2
  134. package/utils/internal/checks.js +0 -60
  135. package/utils/internal/dom.js +0 -82
  136. package/utils/internal/func.js +0 -11
  137. package/utils/internal/isFocusable.js +0 -37
  138. package/utils/internal/math.js +0 -13
  139. package/utils/internal/promise.js +0 -169
  140. package/utils/internal/scrollbars.js +0 -33
  141. package/utils/internal/sort.js +0 -28
  142. package/utils/internal/textDirection.js +0 -7
  143. package/utils/internal/traversal.js +0 -105
@@ -1,178 +1,196 @@
1
- import { computed, writable } from '@amadeus-it-group/tansu';
2
- import { registrationArray } from '../utils/directive';
3
- import { computeCommonAncestor } from '../utils/internal/dom';
4
- import { isFocusable } from '../utils/internal/isFocusable';
5
- import { compareDomOrder } from '../utils/internal/sort';
6
- import { getTextDirection } from '../utils/internal/textDirection';
7
- // cf https://html.spec.whatwg.org/multipage/input.html#concept-input-apply
8
- const textInputTypes = new Set(['text', 'search', 'url', 'tel', 'password']);
1
+ import { writable, computed } from "@amadeus-it-group/tansu";
2
+ import { r as registrationArray, y as computeCommonAncestor, b as browserDirective } from "../directive-DCYlDznf.js";
3
+ const isInertOrInvisible = (element) => {
4
+ let curElement = element;
5
+ while (curElement) {
6
+ const style = getComputedStyle(curElement);
7
+ if (curElement.inert || curElement.hidden || style.display === "none" || style.visibility === "hidden") {
8
+ return true;
9
+ }
10
+ curElement = curElement.parentElement;
11
+ }
12
+ return false;
13
+ };
14
+ const checkNotDisabled = (element) => {
15
+ var _a;
16
+ if (element.disabled) {
17
+ return false;
18
+ }
19
+ const parentFieldset = (_a = element.parentElement) == null ? void 0 : _a.closest("fieldset");
20
+ return parentFieldset ? checkNotDisabled(parentFieldset) : true;
21
+ };
22
+ const isFocusableOtherTags = (element) => element.isContentEditable || !!element.hasAttribute("tabindex");
23
+ const isFocusableByTagName = {
24
+ INPUT: (element) => element.type !== "hidden" && checkNotDisabled(element),
25
+ SELECT: checkNotDisabled,
26
+ TEXTAREA: checkNotDisabled,
27
+ BUTTON: checkNotDisabled,
28
+ A: (element) => !!element.href || isFocusableOtherTags(element)
29
+ };
30
+ const isFocusable = (element) => {
31
+ return document.contains(element) && !isInertOrInvisible(element) && (isFocusableByTagName[element.tagName] ?? isFocusableOtherTags)(element);
32
+ };
33
+ const compareDomOrder = (element1, element2) => {
34
+ if (element1 === element2) {
35
+ return 0;
36
+ }
37
+ const result = element1.compareDocumentPosition(element2);
38
+ if (result & Node.DOCUMENT_POSITION_FOLLOWING) {
39
+ return -1;
40
+ } else if (result & Node.DOCUMENT_POSITION_PRECEDING) {
41
+ return 1;
42
+ }
43
+ throw new Error("failed to compare elements");
44
+ };
45
+ const getTextDirection = (element) => getComputedStyle(element).direction;
46
+ const textInputTypes = /* @__PURE__ */ new Set(["text", "search", "url", "tel", "password"]);
9
47
  const isTextInput = (element) => element instanceof HTMLInputElement && textInputTypes.has(element.type);
10
- /**
11
- * Returns the key name given the keyboard event. The key name is built using event.key (such as ArrowLeft, PageDown...),
12
- * prefixed with the modifiers. If present, modifiers are always in the same order: Meta+Ctrl+Alt+Shift+...
13
- * @param event - keyboard event
14
- * @returns the name of the key, including modifiers
15
- */
16
- export const getKeyName = (event) => {
17
- let key = event.key;
18
- if (event.shiftKey) {
19
- key = `Shift+${key}`;
48
+ const getKeyName = (event) => {
49
+ let key = event.key;
50
+ if (event.shiftKey) {
51
+ key = `Shift+${key}`;
52
+ }
53
+ if (event.altKey) {
54
+ key = `Alt+${key}`;
55
+ }
56
+ if (event.ctrlKey) {
57
+ key = `Ctrl+${key}`;
58
+ }
59
+ if (event.metaKey) {
60
+ key = `Meta+${key}`;
61
+ }
62
+ return key;
63
+ };
64
+ const isInternalInputNavigation = (event) => {
65
+ const { target, key } = event;
66
+ if (isTextInput(target) && (key === "ArrowLeft" || key === "ArrowRight" || key === "Home" || key === "End")) {
67
+ let startPosition;
68
+ if (key === "ArrowLeft" || key === "ArrowRight") {
69
+ const direction = getTextDirection(target);
70
+ startPosition = key === (direction === "ltr" ? "ArrowLeft" : "ArrowRight");
71
+ } else {
72
+ startPosition = key === "Home";
20
73
  }
21
- if (event.altKey) {
22
- key = `Alt+${key}`;
74
+ const cursorPosition = target.selectionStart === target.selectionEnd ? target.selectionStart : null;
75
+ if (startPosition && cursorPosition !== 0 || !startPosition && cursorPosition !== target.value.length) {
76
+ return true;
23
77
  }
24
- if (event.ctrlKey) {
25
- key = `Ctrl+${key}`;
78
+ }
79
+ return false;
80
+ };
81
+ const defaultSelector = (directiveElement) => [directiveElement];
82
+ const createNavManager = () => {
83
+ const directiveInstances$ = registrationArray();
84
+ const elementsRefresh$ = writable({});
85
+ const refreshElements = (now = true) => {
86
+ elementsRefresh$.set({});
87
+ if (now) {
88
+ commonAncestor$();
89
+ elementsInDomOrder$();
26
90
  }
27
- if (event.metaKey) {
28
- key = `Meta+${key}`;
91
+ };
92
+ const elements$ = computed(() => {
93
+ elementsRefresh$();
94
+ const res = [];
95
+ for (const item of directiveInstances$()) {
96
+ res.push(...item());
29
97
  }
30
- return key;
31
- };
32
- /**
33
- * Returns true if the keyboard event is an ArrowLeft, ArrowRight, Home or End key press that should make the cursor move inside
34
- * 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
35
- * because it is already at one end of the input)
36
- * @param event - keyboard event
37
- * @returns true if the keyboard event is an ArrowLeft, ArrowRight, Home or End key press that should make the cursor move inside
38
- * the input and false otherwise.
39
- */
40
- export const isInternalInputNavigation = (event) => {
41
- const { target, key } = event;
42
- if (isTextInput(target) && (key === 'ArrowLeft' || key === 'ArrowRight' || key === 'Home' || key === 'End')) {
43
- let startPosition;
44
- if (key === 'ArrowLeft' || key === 'ArrowRight') {
45
- const direction = getTextDirection(target);
46
- startPosition = key === (direction === 'ltr' ? 'ArrowLeft' : 'ArrowRight');
47
- }
48
- else {
49
- startPosition = key === 'Home';
50
- }
51
- const cursorPosition = target.selectionStart === target.selectionEnd ? target.selectionStart : null;
52
- if ((startPosition && cursorPosition !== 0) || (!startPosition && cursorPosition !== target.value.length)) {
53
- // let the text input process the key
54
- return true;
55
- }
98
+ return res;
99
+ });
100
+ const commonAncestor$ = computed(() => computeCommonAncestor(elements$()), { equal: Object.is });
101
+ const elementsInDomOrder$ = computed(() => [...elements$()].sort(compareDomOrder));
102
+ const ancestorDirection = () => {
103
+ const commonAncestor = commonAncestor$();
104
+ return commonAncestor ? getTextDirection(commonAncestor) : "ltr";
105
+ };
106
+ const preventDefaultIfRelevant = (value, event) => {
107
+ if (value) {
108
+ event == null ? void 0 : event.preventDefault();
56
109
  }
57
- return false;
58
- };
59
- const defaultSelector = (directiveElement) => [directiveElement];
60
- /**
61
- * Returns a new instance of the navigation manager.
62
- *
63
- * The navigation manager simplifies keyboard navigation for a set of DOM elements.
64
- * 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
65
- * (either by directly putting the directive on those elements, or by putting the directive on a parent element and
66
- * specifying which child elements should be included through a selector function).
67
- *
68
- * It provides some utilities to move the focus between those elements (focusFirst/focusLast, focusLeft/focusRight, focusPrevious/focusNext).
69
- *
70
- * @returns a new instance of the navigation manager
71
- */
72
- export const createNavManager = () => {
73
- const directiveInstances$ = registrationArray();
74
- const elementsRefresh$ = writable({});
75
- const refreshElements = (now = true) => {
76
- elementsRefresh$.set({});
77
- if (now) {
78
- commonAncestor$();
79
- elementsInDomOrder$();
80
- }
81
- };
82
- const elements$ = computed(() => {
83
- elementsRefresh$();
84
- const res = [];
85
- for (const item of directiveInstances$()) {
86
- res.push(...item());
87
- }
88
- return res;
89
- });
90
- const commonAncestor$ = computed(() => computeCommonAncestor(elements$()), { equal: Object.is });
91
- const elementsInDomOrder$ = computed(() => [...elements$()].sort(compareDomOrder));
92
- const ancestorDirection = () => {
93
- const commonAncestor = commonAncestor$();
94
- return commonAncestor ? getTextDirection(commonAncestor) : 'ltr';
95
- };
96
- const preventDefaultIfRelevant = (value, event) => {
97
- if (value) {
98
- event?.preventDefault();
99
- }
100
- return value;
101
- };
102
- const focusIndex = (index, moveDirection = 0) => {
103
- const array = elementsInDomOrder$();
104
- while (index >= 0 && index < array.length) {
105
- const newItem = array[index];
106
- if (isFocusable(newItem)) {
107
- newItem.focus();
108
- if (moveDirection != 0 && isTextInput(newItem)) {
109
- const changeDirection = ancestorDirection() !== getTextDirection(newItem);
110
- const position = moveDirection > 0 !== changeDirection ? 0 : newItem.value.length;
111
- newItem.setSelectionRange(position, position, position === 0 ? 'forward' : 'backward');
112
- }
113
- return newItem;
114
- }
115
- if (moveDirection === 0) {
116
- break;
117
- }
118
- else {
119
- index += moveDirection;
120
- }
121
- }
122
- return null;
123
- };
124
- const createFocusNeighbour = (moveDirection) => ({ event, referenceElement = event?.target ?? document.activeElement, } = {}) => {
125
- const curIndex = referenceElement ? elementsInDomOrder$().indexOf(referenceElement) : -1;
126
- if (curIndex > -1) {
127
- return preventDefaultIfRelevant(focusIndex(curIndex + moveDirection, moveDirection), event);
110
+ return value;
111
+ };
112
+ const focusIndex = (index, moveDirection = 0) => {
113
+ const array = elementsInDomOrder$();
114
+ while (index >= 0 && index < array.length) {
115
+ const newItem = array[index];
116
+ if (isFocusable(newItem)) {
117
+ newItem.focus();
118
+ if (moveDirection != 0 && isTextInput(newItem)) {
119
+ const changeDirection = ancestorDirection() !== getTextDirection(newItem);
120
+ const position = moveDirection > 0 !== changeDirection ? 0 : newItem.value.length;
121
+ newItem.setSelectionRange(position, position, position === 0 ? "forward" : "backward");
128
122
  }
129
- return null;
130
- };
131
- const directive = (directiveElement, config) => {
132
- const onKeyDown = (event) => {
133
- if (isInternalInputNavigation(event)) {
134
- return;
135
- }
136
- const keyName = getKeyName(event);
137
- const handler = config.keys?.[keyName];
138
- if (handler) {
139
- refreshElements(false);
140
- handler({ event, directiveElement, navManager, context: config.context });
141
- }
142
- };
143
- directiveElement.addEventListener('keydown', onKeyDown);
144
- const unregister = directiveInstances$.register(() => (config?.selector ?? defaultSelector)(directiveElement));
145
- return {
146
- update(newConfig) {
147
- config = newConfig;
148
- },
149
- destroy() {
150
- directiveElement.removeEventListener('keydown', onKeyDown);
151
- unregister();
152
- },
153
- };
123
+ return newItem;
124
+ }
125
+ if (moveDirection === 0) {
126
+ break;
127
+ } else {
128
+ index += moveDirection;
129
+ }
130
+ }
131
+ return null;
132
+ };
133
+ const createFocusNeighbour = (moveDirection) => ({
134
+ event,
135
+ referenceElement = (event == null ? void 0 : event.target) ?? document.activeElement
136
+ } = {}) => {
137
+ const curIndex = referenceElement ? elementsInDomOrder$().indexOf(referenceElement) : -1;
138
+ if (curIndex > -1) {
139
+ return preventDefaultIfRelevant(focusIndex(curIndex + moveDirection, moveDirection), event);
140
+ }
141
+ return null;
142
+ };
143
+ const directive = browserDirective((directiveElement, config) => {
144
+ const onKeyDown = (event) => {
145
+ var _a;
146
+ if (isInternalInputNavigation(event)) {
147
+ return;
148
+ }
149
+ const keyName = getKeyName(event);
150
+ const handler = (_a = config.keys) == null ? void 0 : _a[keyName];
151
+ if (handler) {
152
+ refreshElements(false);
153
+ handler({ event, directiveElement, navManager, context: config.context });
154
+ }
154
155
  };
155
- const focusPrevious = createFocusNeighbour(-1);
156
- const focusNext = createFocusNeighbour(1);
157
- const focusFirst = ({ event } = {}) => preventDefaultIfRelevant(focusIndex(0, 1), event);
158
- const focusLast = ({ event } = {}) => preventDefaultIfRelevant(focusIndex(elementsInDomOrder$().length - 1, -1), event);
159
- const focusLeft = (...args) => (ancestorDirection() === 'rtl' ? focusNext : focusPrevious)(...args);
160
- const focusRight = (...args) => (ancestorDirection() === 'rtl' ? focusPrevious : focusNext)(...args);
161
- const focusFirstLeft = (...args) => (ancestorDirection() === 'rtl' ? focusLast : focusFirst)(...args);
162
- const focusFirstRight = (...args) => (ancestorDirection() === 'rtl' ? focusFirst : focusLast)(...args);
163
- const navManager = {
164
- elementsInDomOrder$,
165
- directive,
166
- focusIndex,
167
- focusPrevious,
168
- focusNext,
169
- focusFirst,
170
- focusFirstLeft,
171
- focusFirstRight,
172
- focusLast,
173
- focusLeft,
174
- focusRight,
175
- refreshElements,
156
+ directiveElement.addEventListener("keydown", onKeyDown);
157
+ const unregister = directiveInstances$.register(() => ((config == null ? void 0 : config.selector) ?? defaultSelector)(directiveElement));
158
+ return {
159
+ update(newConfig) {
160
+ config = newConfig;
161
+ },
162
+ destroy() {
163
+ directiveElement.removeEventListener("keydown", onKeyDown);
164
+ unregister();
165
+ }
176
166
  };
177
- return navManager;
167
+ });
168
+ const focusPrevious = createFocusNeighbour(-1);
169
+ const focusNext = createFocusNeighbour(1);
170
+ const focusFirst = ({ event } = {}) => preventDefaultIfRelevant(focusIndex(0, 1), event);
171
+ const focusLast = ({ event } = {}) => preventDefaultIfRelevant(focusIndex(elementsInDomOrder$().length - 1, -1), event);
172
+ const focusLeft = (...args) => (ancestorDirection() === "rtl" ? focusNext : focusPrevious)(...args);
173
+ const focusRight = (...args) => (ancestorDirection() === "rtl" ? focusPrevious : focusNext)(...args);
174
+ const focusFirstLeft = (...args) => (ancestorDirection() === "rtl" ? focusLast : focusFirst)(...args);
175
+ const focusFirstRight = (...args) => (ancestorDirection() === "rtl" ? focusFirst : focusLast)(...args);
176
+ const navManager = {
177
+ elementsInDomOrder$,
178
+ directive,
179
+ focusIndex,
180
+ focusPrevious,
181
+ focusNext,
182
+ focusFirst,
183
+ focusFirstLeft,
184
+ focusFirstRight,
185
+ focusLast,
186
+ focusLeft,
187
+ focusRight,
188
+ refreshElements
189
+ };
190
+ return navManager;
191
+ };
192
+ export {
193
+ createNavManager,
194
+ getKeyName,
195
+ isInternalInputNavigation
178
196
  };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const utils_directive = require("../directive-BTSEYLF3.cjs");
4
+ const portal = utils_directive.browserDirective((content, newArg) => {
5
+ let arg;
6
+ let replaceComment;
7
+ const removeReplaceComment = () => {
8
+ var _a;
9
+ if (replaceComment) {
10
+ (_a = replaceComment.parentNode) == null ? void 0 : _a.replaceChild(content, replaceComment);
11
+ replaceComment = null;
12
+ }
13
+ };
14
+ const update = (newArg2) => {
15
+ var _a, _b;
16
+ if (newArg2 !== arg && ((newArg2 == null ? void 0 : newArg2.container) !== (arg == null ? void 0 : arg.container) || (newArg2 == null ? void 0 : newArg2.insertBefore) !== (arg == null ? void 0 : arg.insertBefore))) {
17
+ arg = newArg2;
18
+ const container = (arg == null ? void 0 : arg.container) ?? ((_a = arg == null ? void 0 : arg.insertBefore) == null ? void 0 : _a.parentElement);
19
+ if (container) {
20
+ const insertBefore = (arg == null ? void 0 : arg.insertBefore) ?? null;
21
+ const moveNeeded = content.parentElement !== container || content.nextSibling !== insertBefore;
22
+ if (moveNeeded) {
23
+ if (!replaceComment) {
24
+ replaceComment = (_b = content.parentNode) == null ? void 0 : _b.insertBefore(content.ownerDocument.createComment("portal"), content);
25
+ }
26
+ container.insertBefore(content, insertBefore);
27
+ }
28
+ } else {
29
+ removeReplaceComment();
30
+ }
31
+ }
32
+ };
33
+ update(newArg);
34
+ return {
35
+ update,
36
+ destroy: () => {
37
+ var _a;
38
+ removeReplaceComment();
39
+ (_a = content.parentNode) == null ? void 0 : _a.removeChild(content);
40
+ }
41
+ };
42
+ });
43
+ exports.portal = portal;
@@ -1,44 +1,43 @@
1
- /**
2
- * Creates a portal directive, allowing to attach content to any element.
3
- *
4
- * @param content - the content of the portal
5
- * @param newArg - {@link PortalDirectiveArg} args
6
- * @returns the portal directive
7
- */
8
- export const portal = (content, newArg) => {
9
- let arg;
10
- let replaceComment;
11
- const removeReplaceComment = () => {
12
- if (replaceComment) {
13
- replaceComment.parentNode?.replaceChild(content, replaceComment);
14
- replaceComment = null;
1
+ import { b as browserDirective } from "../directive-DCYlDznf.js";
2
+ const portal = browserDirective((content, newArg) => {
3
+ let arg;
4
+ let replaceComment;
5
+ const removeReplaceComment = () => {
6
+ var _a;
7
+ if (replaceComment) {
8
+ (_a = replaceComment.parentNode) == null ? void 0 : _a.replaceChild(content, replaceComment);
9
+ replaceComment = null;
10
+ }
11
+ };
12
+ const update = (newArg2) => {
13
+ var _a, _b;
14
+ if (newArg2 !== arg && ((newArg2 == null ? void 0 : newArg2.container) !== (arg == null ? void 0 : arg.container) || (newArg2 == null ? void 0 : newArg2.insertBefore) !== (arg == null ? void 0 : arg.insertBefore))) {
15
+ arg = newArg2;
16
+ const container = (arg == null ? void 0 : arg.container) ?? ((_a = arg == null ? void 0 : arg.insertBefore) == null ? void 0 : _a.parentElement);
17
+ if (container) {
18
+ const insertBefore = (arg == null ? void 0 : arg.insertBefore) ?? null;
19
+ const moveNeeded = content.parentElement !== container || content.nextSibling !== insertBefore;
20
+ if (moveNeeded) {
21
+ if (!replaceComment) {
22
+ replaceComment = (_b = content.parentNode) == null ? void 0 : _b.insertBefore(content.ownerDocument.createComment("portal"), content);
23
+ }
24
+ container.insertBefore(content, insertBefore);
15
25
  }
16
- };
17
- const update = (newArg) => {
18
- if (newArg !== arg && (newArg?.container !== arg?.container || newArg?.insertBefore !== arg?.insertBefore)) {
19
- arg = newArg;
20
- const container = arg?.container ?? arg?.insertBefore?.parentElement;
21
- if (container) {
22
- const insertBefore = arg?.insertBefore ?? null;
23
- const moveNeeded = content.parentElement !== container || content.nextSibling !== insertBefore;
24
- if (moveNeeded) {
25
- if (!replaceComment) {
26
- replaceComment = content.parentNode?.insertBefore(content.ownerDocument.createComment('portal'), content);
27
- }
28
- container.insertBefore(content, insertBefore);
29
- }
30
- }
31
- else {
32
- removeReplaceComment();
33
- }
34
- }
35
- };
36
- update(newArg);
37
- return {
38
- update,
39
- destroy: () => {
40
- removeReplaceComment();
41
- content.parentNode?.removeChild(content);
42
- },
43
- };
26
+ } else {
27
+ removeReplaceComment();
28
+ }
29
+ }
30
+ };
31
+ update(newArg);
32
+ return {
33
+ update,
34
+ destroy: () => {
35
+ var _a;
36
+ removeReplaceComment();
37
+ (_a = content.parentNode) == null ? void 0 : _a.removeChild(content);
38
+ }
39
+ };
40
+ });
41
+ export {
42
+ portal
44
43
  };
@@ -0,0 +1,32 @@
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-BTSEYLF3.cjs");
5
+ const func = require("../func-Qd3cD9a3.cjs");
6
+ const createResizeObserver = () => {
7
+ const { element$, directive } = utils_directive.createBrowserStoreDirective();
8
+ const observedElement$ = tansu.derived(
9
+ element$,
10
+ (element, set) => {
11
+ if (element === null) {
12
+ return func.noop;
13
+ }
14
+ const observer = new ResizeObserver((entries) => {
15
+ set(entries[0]);
16
+ });
17
+ observer.observe(element);
18
+ return () => observer == null ? void 0 : observer.disconnect();
19
+ },
20
+ void 0
21
+ );
22
+ return {
23
+ /**
24
+ * Store which contains the dimensions of the observed element (ResizeObserverEntry type)
25
+ * See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry)
26
+ */
27
+ dimensions$: observedElement$,
28
+ /** Directive to be attached to html element in order to listen to resize events */
29
+ directive
30
+ };
31
+ };
32
+ exports.createResizeObserver = createResizeObserver;
@@ -10,5 +10,5 @@ export declare const createResizeObserver: () => {
10
10
  */
11
11
  dimensions$: ReadableSignal<ResizeObserverEntry | undefined>;
12
12
  /** Directive to be attached to html element in order to listen to resize events */
13
- directive: import("..").Directive;
13
+ directive: import("..").Directive<void, import("..").SSRHTMLElement>;
14
14
  };
@@ -1,29 +1,32 @@
1
- import { derived } from '@amadeus-it-group/tansu';
2
- import { createStoreDirective } from '../utils/directive';
3
- import { noop } from '../utils/internal/func';
4
- /**
5
- * Create a resize observer object
6
- * @returns An object containing the store with the dimentions of observed element (ResizeObserverEntry), the directive to be applied to the html element to be observed
7
- */
8
- export const createResizeObserver = () => {
9
- const { element$, directive } = createStoreDirective();
10
- const observedElement$ = derived(element$, (element, set) => {
11
- if (element === null) {
12
- return noop;
13
- }
14
- const observer = new ResizeObserver((entries) => {
15
- set(entries[0]);
16
- });
17
- observer.observe(element);
18
- return () => observer?.disconnect();
19
- }, undefined);
20
- return {
21
- /**
22
- * Store which contains the dimensions of the observed element (ResizeObserverEntry type)
23
- * See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry)
24
- */
25
- dimensions$: observedElement$,
26
- /** Directive to be attached to html element in order to listen to resize events */
27
- directive,
28
- };
1
+ import { derived } from "@amadeus-it-group/tansu";
2
+ import { j as createBrowserStoreDirective } from "../directive-DCYlDznf.js";
3
+ import { n as noop } from "../func-DR0n-ShK.js";
4
+ const createResizeObserver = () => {
5
+ const { element$, directive } = createBrowserStoreDirective();
6
+ const observedElement$ = derived(
7
+ element$,
8
+ (element, set) => {
9
+ if (element === null) {
10
+ return noop;
11
+ }
12
+ const observer = new ResizeObserver((entries) => {
13
+ set(entries[0]);
14
+ });
15
+ observer.observe(element);
16
+ return () => observer == null ? void 0 : observer.disconnect();
17
+ },
18
+ void 0
19
+ );
20
+ return {
21
+ /**
22
+ * Store which contains the dimensions of the observed element (ResizeObserverEntry type)
23
+ * See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry)
24
+ */
25
+ dimensions$: observedElement$,
26
+ /** Directive to be attached to html element in order to listen to resize events */
27
+ directive
28
+ };
29
+ };
30
+ export {
31
+ createResizeObserver
29
32
  };
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const tansu = require("@amadeus-it-group/tansu");
4
+ const func = require("../func-Qd3cD9a3.cjs");
5
+ const utils_directive = require("../directive-BTSEYLF3.cjs");
6
+ const internalSetSiblingsInert = (element) => {
7
+ const inertValues = /* @__PURE__ */ new Map();
8
+ const recursiveHelper = (element2) => {
9
+ const parent = element2.parentElement;
10
+ if (parent && element2 !== document.body) {
11
+ Array.from(parent.children).forEach((sibling) => {
12
+ if (sibling !== element2 && sibling.nodeName !== "SCRIPT") {
13
+ inertValues.set(sibling, sibling.hasAttribute("inert"));
14
+ sibling.toggleAttribute("inert", true);
15
+ }
16
+ });
17
+ recursiveHelper(parent);
18
+ }
19
+ };
20
+ recursiveHelper(element);
21
+ return () => inertValues.forEach((value, element2) => {
22
+ element2.toggleAttribute("inert", value);
23
+ });
24
+ };
25
+ let internalRevert = func.noop;
26
+ const setSiblingsInert = (element) => {
27
+ internalRevert();
28
+ internalRevert = element ? internalSetSiblingsInert(element) : func.noop;
29
+ };
30
+ const { directive: storeArrayDirective, elements$ } = utils_directive.createBrowserStoreArrayDirective();
31
+ const lastElement$ = tansu.computed(
32
+ () => {
33
+ const elements = elements$();
34
+ return elements[elements.length - 1];
35
+ },
36
+ { equal: Object.is }
37
+ );
38
+ const inertAction$ = tansu.computed(() => setSiblingsInert(lastElement$()));
39
+ const sliblingsInert = utils_directive.mergeDirectives(storeArrayDirective, utils_directive.directiveSubscribe(inertAction$));
40
+ exports.sliblingsInert = sliblingsInert;