@design-factory/core 21.1.0 → 22.0.0-next.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 (130) hide show
  1. package/{accordion-D9ba0XYq.js → accordion-B5RqDwi3.js} +76 -15
  2. package/alert-Db6cG6JE.js +125 -0
  3. package/{collapse-Bn8iHKrd.js → collapse-D8Jo56k9.js} +2 -2
  4. package/{common-DFyZvkII.js → common-CP4amR0Z.js} +2 -2
  5. package/components/accordion/accordion.d.ts +73 -15
  6. package/components/accordion/index.js +1 -1
  7. package/components/alert/alert.d.ts +77 -8
  8. package/components/alert/common.d.ts +9 -9
  9. package/components/alert/index.js +2 -3
  10. package/components/carousel/index.js +2 -2
  11. package/components/collapse/index.js +1 -1
  12. package/components/drawer/drawer.d.ts +6 -0
  13. package/components/drawer/index.js +1 -1
  14. package/components/dropdown/dropdown.d.ts +110 -0
  15. package/components/dropdown/index.d.ts +1 -0
  16. package/components/dropdown/index.js +5 -0
  17. package/components/modal/index.js +1 -1
  18. package/components/pagination/index.js +1 -1
  19. package/components/progressbar/index.js +1 -1
  20. package/components/rating/index.js +1 -1
  21. package/components/slider/index.js +1 -1
  22. package/components/slider/slider.d.ts +23 -4
  23. package/components/toast/index.js +1 -1
  24. package/components/tooltip/index.d.ts +1 -0
  25. package/components/tooltip/index.js +174 -0
  26. package/components/tooltip/tooltip.d.ts +63 -0
  27. package/components/tree/index.js +1 -1
  28. package/{directive-CNNSo5Yn.js → directive-CMT2vEDg.js} +7 -4
  29. package/{drawer-CoBXUPyv.js → drawer-CpGnS2ln.js} +11 -4
  30. package/dropdown-Bjj2ql6d.js +246 -0
  31. package/index.d.ts +3 -1
  32. package/index.js +44 -37
  33. package/isFocusable-C2iRr0zh.js +72 -0
  34. package/{modal-BH9nrwVz.js → modal-CQWh2Sm5.js} +3 -3
  35. package/package.json +1 -1
  36. package/{pagination-BQWusWXN.js → pagination-DIRcpdRE.js} +2 -2
  37. package/{progressbar-S1pNn5rM.js → progressbar-Bth8r3Qu.js} +2 -2
  38. package/{promise-D-RZVPuv.js → promise-CkIc0KKt.js} +3 -3
  39. package/{rating-DWgGgwk3.js → rating-DLsgFSyB.js} +2 -2
  40. package/services/extendWidget.d.ts +1 -1
  41. package/services/focusElement.js +2 -2
  42. package/services/focustrack.js +2 -2
  43. package/services/matchMedia.js +1 -1
  44. package/services/mousetrack.d.ts +34 -0
  45. package/services/mousetrack.js +41 -0
  46. package/services/navManager.js +2 -2
  47. package/services/pointerdownPosition.js +1 -1
  48. package/services/portal.js +1 -1
  49. package/services/positioning.d.ts +101 -0
  50. package/services/positioning.js +104 -0
  51. package/services/resizeObserver.js +1 -1
  52. package/services/siblingsInert.js +1 -1
  53. package/services/transitions/baseTransitions.js +3 -3
  54. package/services/transitions/collapse.js +4 -7
  55. package/services/transitions/cssTransitions.js +2 -2
  56. package/services/transitions/simpleClassTransition.js +1 -1
  57. package/{slider-Br_Qiopx.js → slider-b9cVFNAL.js} +96 -58
  58. package/{toaster-BUBzFeJM.js → toaster-BS9qeRLF.js} +3 -3
  59. package/{tree-vD7ZkV8Z.js → tree-DW6iLxdw.js} +2 -2
  60. package/types.d.ts +8 -1
  61. package/utils/debounceSignal.d.ts +11 -0
  62. package/utils/debounceSignal.js +18 -0
  63. package/utils/directive.js +1 -1
  64. package/utils/edgeState.d.ts +23 -0
  65. package/utils/edgeState.js +43 -0
  66. package/utils/internal/isFocusable.d.ts +40 -0
  67. package/utils/stores.d.ts +1 -1
  68. package/utils/stores.js +4 -1
  69. package/utils/writables.d.ts +27 -13
  70. package/utils/writables.js +12 -11
  71. package/{writables-DYGjj5T3.js → writables-_7BriMb2.js} +37 -12
  72. package/accordion-B0vs8JWM.cjs +0 -314
  73. package/alert-AhaliJ17.cjs +0 -9
  74. package/alert-Cb9FhbFQ.js +0 -10
  75. package/collapse-BnWw4Hnc.cjs +0 -94
  76. package/common-B5jS-Ih_.cjs +0 -73
  77. package/components/accordion/index.cjs +0 -7
  78. package/components/alert/index.cjs +0 -5
  79. package/components/carousel/index.cjs +0 -292
  80. package/components/collapse/index.cjs +0 -5
  81. package/components/drawer/index.cjs +0 -5
  82. package/components/modal/index.cjs +0 -8
  83. package/components/pagination/index.cjs +0 -5
  84. package/components/progressbar/index.cjs +0 -5
  85. package/components/rating/index.cjs +0 -5
  86. package/components/slider/index.cjs +0 -5
  87. package/components/toast/index.cjs +0 -7
  88. package/components/tree/index.cjs +0 -5
  89. package/config.cjs +0 -36
  90. package/directive-DyTodNPd.cjs +0 -523
  91. package/drawer-Ca_ktkEs.cjs +0 -328
  92. package/index.cjs +0 -134
  93. package/isFocusable-Ckwus82R.js +0 -32
  94. package/isFocusable-DfzDLeAN.cjs +0 -31
  95. package/modal-Dxdw2Pkv.cjs +0 -252
  96. package/pagination-BLVa1UsZ.cjs +0 -254
  97. package/progressbar-RopgvVeA.cjs +0 -86
  98. package/promise-CxCD3NYv.cjs +0 -118
  99. package/rating-DZ3OQgtt.cjs +0 -183
  100. package/scrollbars-f651ntzz.cjs +0 -33
  101. package/services/extendWidget.cjs +0 -41
  102. package/services/floatingUI.cjs +0 -111
  103. package/services/floatingUI.d.ts +0 -76
  104. package/services/floatingUI.js +0 -111
  105. package/services/focusElement.cjs +0 -46
  106. package/services/focustrack.cjs +0 -47
  107. package/services/hash.cjs +0 -15
  108. package/services/intersection.cjs +0 -53
  109. package/services/matchMedia.cjs +0 -14
  110. package/services/navManager.cjs +0 -166
  111. package/services/pointerdownPosition.cjs +0 -60
  112. package/services/portal.cjs +0 -42
  113. package/services/resizeObserver.cjs +0 -54
  114. package/services/siblingsInert.cjs +0 -44
  115. package/services/transitions/baseTransitions.cjs +0 -186
  116. package/services/transitions/collapse.cjs +0 -40
  117. package/services/transitions/cssTransitions.cjs +0 -32
  118. package/services/transitions/simpleClassTransition.cjs +0 -37
  119. package/slider-pgDq1V5r.cjs +0 -807
  120. package/textDirection-zqcZ5-eK.cjs +0 -3
  121. package/toaster-Dlube4Ya.cjs +0 -161
  122. package/tree-Chcy4ulJ.cjs +0 -228
  123. package/types.cjs +0 -6
  124. package/utils/directive.cjs +0 -28
  125. package/utils/func.cjs +0 -7
  126. package/utils/id.cjs +0 -5
  127. package/utils/stores.cjs +0 -172
  128. package/utils/widget.cjs +0 -8
  129. package/utils/writables.cjs +0 -16
  130. package/writables-Dt68gADJ.cjs +0 -102
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const tansu = require("@amadeus-it-group/tansu");
4
- const utils_func = require("../utils/func.cjs");
5
- const utils_stores = require("../utils/stores.cjs");
6
- const defaultValues = {
7
- elements: [],
8
- options: void 0
9
- };
10
- const createIntersection = (config) => {
11
- const [{ elements$, options$ }, patch] = utils_stores.writablesForProps(defaultValues, config);
12
- const visibleElements$ = tansu.derived(
13
- [elements$, options$],
14
- ([elements, options], set) => {
15
- if (elements.length) {
16
- const visibleElements = /* @__PURE__ */ new Map();
17
- const observer = new IntersectionObserver((entries) => {
18
- for (const entry of entries) {
19
- const { target, isIntersecting } = entry;
20
- if (isIntersecting) {
21
- visibleElements.set(target, entry);
22
- } else {
23
- visibleElements.delete(target);
24
- }
25
- }
26
- set(visibleElements);
27
- }, options);
28
- for (const element of elements) {
29
- observer.observe(element);
30
- }
31
- return () => {
32
- observer.disconnect();
33
- };
34
- }
35
- return utils_func.noop;
36
- },
37
- /* @__PURE__ */ new Map()
38
- );
39
- return {
40
- /**
41
- * Readable of observed elements
42
- */
43
- elements$: tansu.asReadable(elements$),
44
- /**
45
- * Store of map that contains the visible elements (for the key) and the corresponding entries
46
- *
47
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry | MDN documentation}
48
- */
49
- visibleElements$: tansu.asReadable(visibleElements$),
50
- patch
51
- };
52
- };
53
- exports.createIntersection = createIntersection;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const tansu = require("@amadeus-it-group/tansu");
4
- const esmEnv = require("esm-env");
5
- const utils_directive = require("../directive-DyTodNPd.cjs");
6
- const utils_stores = require("../utils/stores.cjs");
7
- const createMatchMedia = (query) => esmEnv.BROWSER ? tansu.readable(false, {
8
- onUse({ set }) {
9
- const mql = window.matchMedia(query.trim());
10
- set(mql.matches);
11
- return utils_directive.addEvent(mql, "change", (val) => set(val.matches));
12
- }
13
- }) : utils_stores.false$;
14
- exports.createMatchMedia = createMatchMedia;
@@ -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-DyTodNPd.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,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const utils_directive = require("../directive-DyTodNPd.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
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const utils_directive = require("../directive-DyTodNPd.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;
@@ -1,54 +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-DyTodNPd.cjs");
5
- const utils_func = require("../utils/func.cjs");
6
- const createResizeObserverMap = () => {
7
- const { elements$, directive } = utils_directive.createBrowserStoreArrayDirective();
8
- const dimensionsMap$ = tansu.derived(
9
- elements$,
10
- (elements, set) => {
11
- const dimensionsMap = /* @__PURE__ */ new Map();
12
- if (elements.length === 0) {
13
- set(dimensionsMap);
14
- return utils_func.noop;
15
- }
16
- const observer = new ResizeObserver((entries) => {
17
- entries.forEach((entry) => dimensionsMap.set(entry.target, entry));
18
- set(dimensionsMap);
19
- });
20
- elements.forEach((element) => observer.observe(element));
21
- return () => observer.disconnect();
22
- },
23
- /* @__PURE__ */ new Map()
24
- );
25
- return { dimensionsMap$, directive };
26
- };
27
- const createResizeObserver = () => {
28
- const { dimensionsMap$, directive: arrayDirective } = createResizeObserverMap();
29
- let firstElement = null;
30
- const directive = utils_directive.browserDirective((element) => {
31
- if (firstElement === null) {
32
- firstElement = element;
33
- } else {
34
- console.error(
35
- "createResizeObserver directive can only be applied to a single element. Use createResizeObserverMap for multiple elements."
36
- );
37
- return;
38
- }
39
- const result = arrayDirective(element);
40
- if (!result) return;
41
- const originalDestroy = result.destroy;
42
- return {
43
- ...result,
44
- destroy: () => {
45
- firstElement = null;
46
- originalDestroy?.();
47
- }
48
- };
49
- });
50
- const dimensions$ = tansu.derived(dimensionsMap$, (map) => firstElement ? map.get(firstElement) : void 0, void 0);
51
- return { dimensions$, directive };
52
- };
53
- exports.createResizeObserver = createResizeObserver;
54
- exports.createResizeObserverMap = createResizeObserverMap;
@@ -1,44 +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-DyTodNPd.cjs");
5
- const utils_func = require("../utils/func.cjs");
6
- const ignoreInertAttributeName = "data-agnos-ignore-inert";
7
- const applyInertToSiblingsRecursively = (element) => {
8
- const inertValues = /* @__PURE__ */ new Map();
9
- const recursiveHelper = (element2) => {
10
- const parent = element2.parentElement;
11
- if (parent && element2 !== document.body) {
12
- Array.from(parent.children).forEach((sibling) => {
13
- if (sibling !== element2 && sibling.nodeName !== "SCRIPT" && !sibling.hasAttribute(ignoreInertAttributeName)) {
14
- inertValues.set(sibling, sibling.hasAttribute("inert"));
15
- sibling.toggleAttribute("inert", true);
16
- }
17
- });
18
- recursiveHelper(parent);
19
- }
20
- };
21
- recursiveHelper(element);
22
- return () => inertValues.forEach((value, element2) => {
23
- element2.toggleAttribute("inert", value);
24
- });
25
- };
26
- let internalRevert = utils_func.noop;
27
- const setSiblingsInert = (element) => {
28
- internalRevert();
29
- internalRevert = element ? applyInertToSiblingsRecursively(element) : utils_func.noop;
30
- };
31
- const { directive: storeArrayDirective, elements$ } = utils_directive.createConditionalBrowserStoreArrayDirective();
32
- const lastTrackedElement$ = tansu.computed(
33
- () => {
34
- const elements = elements$();
35
- return elements[elements.length - 1];
36
- },
37
- { equal: Object.is }
38
- );
39
- const updateInertState$ = tansu.computed(() => setSiblingsInert(lastTrackedElement$()));
40
- const siblingsInert = utils_directive.mergeDirectives(
41
- storeArrayDirective,
42
- utils_directive.directiveSubscribe(updateInertState$)
43
- );
44
- exports.siblingsInert = siblingsInert;
@@ -1,186 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const tansu = require("@amadeus-it-group/tansu");
4
- const utils_writables = require("../../writables-Dt68gADJ.cjs");
5
- const promise = require("../../promise-CxCD3NYv.cjs");
6
- const utils_func = require("../../utils/func.cjs");
7
- const utils_stores = require("../../utils/stores.cjs");
8
- const utils_directive = require("../../directive-DyTodNPd.cjs");
9
- const neverEndingPromise = new Promise(utils_func.noop);
10
- const noAnimation = (element, direction) => {
11
- element.style.display = direction === "show" ? "" : "none";
12
- };
13
- const defaultValues = {
14
- animated: true,
15
- animatedOnInit: false,
16
- initDone: null,
17
- visible: true,
18
- transition: noAnimation,
19
- onShown: utils_func.noop,
20
- onHidden: utils_func.noop,
21
- onVisibleChange: utils_func.noop
22
- };
23
- const configValidator = {
24
- animated: utils_writables.typeBoolean,
25
- animatedOnInit: utils_writables.typeBoolean,
26
- visible: utils_writables.typeBoolean,
27
- transition: utils_writables.typeFunction,
28
- onShown: utils_writables.typeFunction,
29
- onHidden: utils_writables.typeFunction,
30
- onVisibleChange: utils_writables.typeFunction,
31
- initDone: utils_writables.typeBooleanOrNull
32
- };
33
- const createTransition = (config) => {
34
- const [
35
- {
36
- animated$,
37
- initDone$,
38
- visible$: requestedVisible$,
39
- transition$,
40
- onShown$,
41
- onHidden$,
42
- onVisibleChange$,
43
- animatedOnInit$
44
- },
45
- patch
46
- ] = utils_stores.writablesForProps(defaultValues, config, configValidator);
47
- const { element$, directive: storeDirective } = utils_directive.createStoreDirective();
48
- const elementPresent$ = tansu.computed(() => !!element$());
49
- const visible$ = utils_stores.bindableDerived(onVisibleChange$, [requestedVisible$], ([visible]) => visible);
50
- const currentTransition$ = tansu.writable(
51
- null
52
- );
53
- const stop = () => {
54
- let context;
55
- currentTransition$.update((currentTransition) => {
56
- currentTransition?.abort.abort();
57
- context = currentTransition?.context;
58
- return null;
59
- });
60
- return context;
61
- };
62
- const runTransition = (visible, animated, element, transitionFn) => tansu.batch(() => {
63
- const abort = new AbortController();
64
- const signal = abort.signal;
65
- const context = stop() ?? {};
66
- const { promise: promise$1, resolve } = promise.promiseWithResolve();
67
- const currentTransition = {
68
- abort,
69
- animated,
70
- visible,
71
- context,
72
- element,
73
- transitionFn,
74
- promise: promise$1
75
- };
76
- currentTransition$.set(currentTransition);
77
- resolve(
78
- (async () => {
79
- try {
80
- await transitionFn(element, visible ? "show" : "hide", animated, signal, context);
81
- } finally {
82
- if (signal.aborted) {
83
- await neverEndingPromise;
84
- } else {
85
- currentTransition$.set(null);
86
- (visible ? onShown$ : onHidden$)()?.();
87
- }
88
- }
89
- })()
90
- );
91
- return currentTransition;
92
- });
93
- const effectiveAnimation$ = tansu.computed(() => initDone$() ? animated$() : animatedOnInit$());
94
- const animationFromToggle$ = tansu.writable(null);
95
- let previousElement;
96
- let previousVisible = requestedVisible$();
97
- let pendingTransition = null;
98
- const visibleAction$ = tansu.derived(
99
- [visible$, element$, effectiveAnimation$, animationFromToggle$, transition$, currentTransition$],
100
- ([visible, element, animated, animationFromToggle, transition, currentTransition]) => {
101
- const elementChanged = previousElement !== element;
102
- previousElement = element;
103
- const visibleChanged = previousVisible !== visible;
104
- previousVisible = visible;
105
- if (element) {
106
- if (initDone$() == null) {
107
- initDone$.set(true);
108
- }
109
- const interruptAnimation = animationFromToggle != null && currentTransition && currentTransition.animated != animationFromToggle;
110
- if (elementChanged || visibleChanged || interruptAnimation) {
111
- if (visibleChanged || animationFromToggle != null) {
112
- pendingTransition = null;
113
- }
114
- const animate = animationFromToggle ?? pendingTransition?.animated ?? (elementChanged && !visible ? false : animated);
115
- currentTransition = runTransition(visible, animate, element, transition);
116
- pendingTransition?.resolve(currentTransition.promise);
117
- pendingTransition = null;
118
- }
119
- } else {
120
- if (elementChanged) {
121
- stop();
122
- currentTransition = null;
123
- }
124
- if (visibleChanged || visible && pendingTransition?.animated !== animationFromToggle) {
125
- pendingTransition = visible && animationFromToggle != null ? {
126
- // toggle was called to display the element, but the element is not yet in the DOM
127
- // let's keep the animation setting from toggle and provide the promise for the end of toggle
128
- animated: animationFromToggle,
129
- ...promise.promiseWithResolve()
130
- } : null;
131
- }
132
- }
133
- return pendingTransition?.promise ?? currentTransition?.promise;
134
- }
135
- );
136
- let lastToggle = {};
137
- const toggle = async (visible = !requestedVisible$(), animated = effectiveAnimation$()) => {
138
- const currentToggle = {};
139
- lastToggle = currentToggle;
140
- try {
141
- await tansu.batch(() => {
142
- try {
143
- animationFromToggle$.set(animated);
144
- requestedVisible$.set(visible);
145
- return visibleAction$();
146
- } finally {
147
- animationFromToggle$.set(null);
148
- }
149
- });
150
- } finally {
151
- if (lastToggle !== currentToggle) {
152
- await neverEndingPromise;
153
- }
154
- }
155
- };
156
- const transitioning$ = tansu.computed(() => {
157
- if (elementPresent$()) {
158
- void visibleAction$();
159
- }
160
- return !!currentTransition$();
161
- });
162
- const shown$ = tansu.computed(() => !transitioning$() && visible$() && elementPresent$());
163
- const hidden$ = tansu.computed(() => !transitioning$() && !visible$());
164
- const directive = utils_directive.mergeDirectives(storeDirective, utils_directive.directiveSubscribe(visibleAction$));
165
- return {
166
- ...utils_stores.stateStores({
167
- visible$,
168
- element$,
169
- elementPresent$,
170
- transitioning$,
171
- shown$,
172
- hidden$
173
- }),
174
- patch,
175
- directives: {
176
- directive
177
- },
178
- api: {
179
- show: toggle.bind(null, true),
180
- hide: toggle.bind(null, false),
181
- toggle
182
- }
183
- };
184
- };
185
- exports.createTransition = createTransition;
186
- exports.noAnimation = noAnimation;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const utils_directive = require("../../directive-DyTodNPd.cjs");
4
- const services_transitions_cssTransitions = require("./cssTransitions.cjs");
5
- const createCollapseTransition = ({
6
- dimension = "height",
7
- showClasses,
8
- hideClasses,
9
- animationPendingClasses
10
- } = {}) => services_transitions_cssTransitions.createCSSTransition((element, direction, animated, context) => {
11
- if (animated && utils_directive.isBrowserHTMLElement(element)) {
12
- let { maxSize, minSize } = context;
13
- utils_directive.removeClasses(element, animationPendingClasses);
14
- utils_directive.removeClasses(element, hideClasses);
15
- utils_directive.addClasses(element, showClasses);
16
- maxSize = element.getBoundingClientRect()[dimension] + "px";
17
- context.maxSize = maxSize;
18
- utils_directive.removeClasses(element, animationPendingClasses);
19
- utils_directive.removeClasses(element, showClasses);
20
- utils_directive.addClasses(element, hideClasses);
21
- minSize = element.getBoundingClientRect()[dimension] + "px";
22
- context.minSize = minSize;
23
- utils_directive.removeClasses(element, showClasses);
24
- utils_directive.removeClasses(element, hideClasses);
25
- const values = direction === "show" ? [minSize, maxSize] : [maxSize, minSize];
26
- element.style[dimension] = values[0];
27
- utils_directive.reflow(element);
28
- utils_directive.addClasses(element, animationPendingClasses);
29
- utils_directive.reflow(element);
30
- element.style[dimension] = values[1];
31
- } else {
32
- utils_directive.removeClasses(element, direction === "show" ? hideClasses : showClasses);
33
- }
34
- return () => {
35
- utils_directive.removeClasses(element, animationPendingClasses);
36
- utils_directive.addClasses(element, direction === "show" ? showClasses : hideClasses);
37
- element.style[dimension] = "";
38
- };
39
- });
40
- exports.createCollapseTransition = createCollapseTransition;