@agnos-ui/core 0.2.0 → 0.3.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 (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,40 +1,40 @@
1
- import { computed } from '@amadeus-it-group/tansu';
2
- import { noop } from '../utils/internal/func';
3
- import { createStoreArrayDirective, directiveSubscribe, mergeDirectives } from '../utils/directive';
1
+ import { computed } from "@amadeus-it-group/tansu";
2
+ import { n as noop } from "../func-DR0n-ShK.js";
3
+ import { g as createBrowserStoreArrayDirective, k as mergeDirectives, d as directiveSubscribe } from "../directive-DCYlDznf.js";
4
4
  const internalSetSiblingsInert = (element) => {
5
- const inertValues = new Map();
6
- const recursiveHelper = (element) => {
7
- const parent = element.parentElement;
8
- if (parent && element !== document.body) {
9
- Array.from(parent.children).forEach((sibling) => {
10
- if (sibling !== element && sibling.nodeName !== 'SCRIPT') {
11
- inertValues.set(sibling, sibling.hasAttribute('inert'));
12
- sibling.toggleAttribute('inert', true);
13
- }
14
- });
15
- recursiveHelper(parent);
5
+ const inertValues = /* @__PURE__ */ new Map();
6
+ const recursiveHelper = (element2) => {
7
+ const parent = element2.parentElement;
8
+ if (parent && element2 !== document.body) {
9
+ Array.from(parent.children).forEach((sibling) => {
10
+ if (sibling !== element2 && sibling.nodeName !== "SCRIPT") {
11
+ inertValues.set(sibling, sibling.hasAttribute("inert"));
12
+ sibling.toggleAttribute("inert", true);
16
13
  }
17
- };
18
- recursiveHelper(element);
19
- return () => inertValues.forEach((value, element) => {
20
- element.toggleAttribute('inert', value);
21
- });
14
+ });
15
+ recursiveHelper(parent);
16
+ }
17
+ };
18
+ recursiveHelper(element);
19
+ return () => inertValues.forEach((value, element2) => {
20
+ element2.toggleAttribute("inert", value);
21
+ });
22
22
  };
23
23
  let internalRevert = noop;
24
24
  const setSiblingsInert = (element) => {
25
- internalRevert();
26
- internalRevert = element ? internalSetSiblingsInert(element) : noop;
25
+ internalRevert();
26
+ internalRevert = element ? internalSetSiblingsInert(element) : noop;
27
27
  };
28
- const { directive: storeArrayDirective, elements$ } = createStoreArrayDirective();
29
- const lastElement$ = computed(() => {
28
+ const { directive: storeArrayDirective, elements$ } = createBrowserStoreArrayDirective();
29
+ const lastElement$ = computed(
30
+ () => {
30
31
  const elements = elements$();
31
32
  return elements[elements.length - 1];
32
- }, { equal: Object.is });
33
+ },
34
+ { equal: Object.is }
35
+ );
33
36
  const inertAction$ = computed(() => setSiblingsInert(lastElement$()));
34
- /**
35
- * sliblingsInert directive
36
- * When used on an element, all siblings of the element and of its ancestors will be inert with the inert attribute.
37
- * In case it is used on multiple elements, only the last one has an effect (the directive keeps a stack of elements
38
- * on which it is used, so when the last one disappears, the previous one in the list becomes the one in effect).
39
- */
40
- export const sliblingsInert = mergeDirectives(storeArrayDirective, directiveSubscribe(inertAction$));
37
+ const sliblingsInert = mergeDirectives(storeArrayDirective, directiveSubscribe(inertAction$));
38
+ export {
39
+ sliblingsInert
40
+ };
@@ -0,0 +1,171 @@
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-D46sFgGK.cjs");
5
+ const promise = require("../../promise-BMJ8qhA8.cjs");
6
+ const func = require("../../func-Qd3cD9a3.cjs");
7
+ const utils_stores = require("../../utils/stores.cjs");
8
+ const utils_directive = require("../../directive-BTSEYLF3.cjs");
9
+ const neverEndingPromise = new Promise(func.noop);
10
+ const noAnimation = async (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: func.noop,
20
+ onHidden: func.noop,
21
+ onVisibleChange: 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 [{ animated$, initDone$, visible$: requestedVisible$, transition$, onShown$, onHidden$, onVisibleChange$, animatedOnInit$ }, patch] = utils_stores.writablesForProps(defaultValues, config, configValidator);
35
+ const { element$, directive: storeDirective } = utils_directive.createStoreDirective();
36
+ const elementPresent$ = tansu.computed(() => !!element$());
37
+ const visible$ = utils_stores.bindableDerived(onVisibleChange$, [requestedVisible$], ([visible]) => visible);
38
+ const currentTransition$ = tansu.writable(
39
+ null
40
+ );
41
+ const transitioning$ = tansu.computed(() => !!currentTransition$());
42
+ const stop = () => {
43
+ let context;
44
+ currentTransition$.update((currentTransition) => {
45
+ currentTransition == null ? void 0 : currentTransition.abort.abort();
46
+ context = currentTransition == null ? void 0 : currentTransition.context;
47
+ return null;
48
+ });
49
+ return context;
50
+ };
51
+ const runTransition = (visible, animated, element, transitionFn) => tansu.batch(() => {
52
+ const abort = new AbortController();
53
+ const signal = abort.signal;
54
+ const context = stop() ?? {};
55
+ const { promise: promise$1, resolve } = promise.promiseWithResolve();
56
+ const currentTransition = {
57
+ abort,
58
+ animated,
59
+ visible,
60
+ context,
61
+ element,
62
+ transitionFn,
63
+ promise: promise$1
64
+ };
65
+ currentTransition$.set(currentTransition);
66
+ resolve(
67
+ (async () => {
68
+ var _a;
69
+ try {
70
+ await transitionFn(element, visible ? "show" : "hide", animated, signal, context);
71
+ } finally {
72
+ if (signal.aborted) {
73
+ await neverEndingPromise;
74
+ } else {
75
+ currentTransition$.set(null);
76
+ (_a = (visible ? onShown$ : onHidden$)()) == null ? void 0 : _a();
77
+ }
78
+ }
79
+ })()
80
+ );
81
+ return currentTransition;
82
+ });
83
+ const shown$ = tansu.computed(() => !transitioning$() && visible$() && elementPresent$());
84
+ const hidden$ = tansu.computed(() => !transitioning$() && !visible$());
85
+ const effectiveAnimation$ = tansu.computed(() => initDone$() ? animated$() : animatedOnInit$());
86
+ const animationFromToggle$ = tansu.writable(null);
87
+ let previousElement;
88
+ let previousVisible = requestedVisible$();
89
+ let pendingTransition = null;
90
+ const visibleAction$ = tansu.derived(
91
+ [visible$, element$, effectiveAnimation$, animationFromToggle$, transition$, currentTransition$],
92
+ ([visible, element, animated, animationFromToggle, transition, currentTransition]) => {
93
+ const elementChanged = previousElement !== element;
94
+ previousElement = element;
95
+ const visibleChanged = previousVisible !== visible;
96
+ previousVisible = visible;
97
+ if (element) {
98
+ if (initDone$() == null) {
99
+ initDone$.set(true);
100
+ }
101
+ const interruptAnimation = animationFromToggle != null && currentTransition && currentTransition.animated != animationFromToggle;
102
+ if (elementChanged || visibleChanged || interruptAnimation) {
103
+ if (visibleChanged || animationFromToggle != null) {
104
+ pendingTransition = null;
105
+ }
106
+ const animate = animationFromToggle ?? (pendingTransition == null ? void 0 : pendingTransition.animated) ?? (elementChanged && !visible ? false : animated);
107
+ currentTransition = runTransition(visible, animate, element, transition);
108
+ pendingTransition == null ? void 0 : pendingTransition.resolve(currentTransition.promise);
109
+ pendingTransition = null;
110
+ }
111
+ } else {
112
+ if (elementChanged) {
113
+ stop();
114
+ currentTransition = null;
115
+ }
116
+ if (visibleChanged || visible && (pendingTransition == null ? void 0 : pendingTransition.animated) !== animationFromToggle) {
117
+ pendingTransition = visible && animationFromToggle != null ? {
118
+ // toggle was called to display the element, but the element is not yet in the DOM
119
+ // let's keep the animation setting from toggle and provide the promise for the end of toggle
120
+ animated: animationFromToggle,
121
+ ...promise.promiseWithResolve()
122
+ } : null;
123
+ }
124
+ }
125
+ return (pendingTransition == null ? void 0 : pendingTransition.promise) ?? (currentTransition == null ? void 0 : currentTransition.promise);
126
+ }
127
+ );
128
+ let lastToggle = {};
129
+ const toggle = async (visible = !requestedVisible$(), animated = effectiveAnimation$()) => {
130
+ const currentToggle = {};
131
+ lastToggle = currentToggle;
132
+ try {
133
+ await tansu.batch(() => {
134
+ try {
135
+ animationFromToggle$.set(animated);
136
+ requestedVisible$.set(visible);
137
+ return visibleAction$();
138
+ } finally {
139
+ animationFromToggle$.set(null);
140
+ }
141
+ });
142
+ } finally {
143
+ if (lastToggle !== currentToggle) {
144
+ await neverEndingPromise;
145
+ }
146
+ }
147
+ };
148
+ const directive = utils_directive.mergeDirectives(storeDirective, utils_directive.directiveUpdate(patch), utils_directive.directiveSubscribe(visibleAction$));
149
+ return {
150
+ ...utils_stores.stateStores({
151
+ visible$,
152
+ element$,
153
+ elementPresent$,
154
+ transitioning$,
155
+ shown$,
156
+ hidden$
157
+ }),
158
+ patch,
159
+ directives: {
160
+ directive
161
+ },
162
+ actions: {},
163
+ api: {
164
+ show: toggle.bind(null, true),
165
+ hide: toggle.bind(null, false),
166
+ toggle
167
+ }
168
+ };
169
+ };
170
+ exports.createTransition = createTransition;
171
+ exports.noAnimation = noAnimation;
@@ -1,4 +1,4 @@
1
- import type { Directive, PropsConfig, Widget } from '../../types';
1
+ import type { Directive, PropsConfig, SSRHTMLElement, Widget } from '../../types';
2
2
  /**
3
3
  * Function that implements a transition.
4
4
  */
@@ -6,7 +6,7 @@ export type TransitionFn = (
6
6
  /**
7
7
  * Element on which the transition should be applied.
8
8
  */
9
- element: HTMLElement,
9
+ element: SSRHTMLElement,
10
10
  /**
11
11
  * Whether the element should be shown or hidden.
12
12
  */
@@ -14,7 +14,7 @@ direction: 'show' | 'hide',
14
14
  /**
15
15
  * Whether the transition should be animated.
16
16
  */
17
- animation: boolean,
17
+ animated: boolean,
18
18
  /**
19
19
  * Signal allowing to stop the transition while running.
20
20
  */
@@ -35,17 +35,17 @@ export interface TransitionProps {
35
35
  /**
36
36
  * Whether the transition should be animated.
37
37
  */
38
- animation: boolean;
38
+ animated: boolean;
39
39
  /**
40
40
  * If the element is initially visible, whether the element should be animated when first displayed.
41
41
  */
42
- animationOnInit: boolean;
42
+ animatedOnInit: boolean;
43
43
  /**
44
- * Whether initialization is finished. It determines which setting between {@link TransitionProps.animation}
45
- * and {@link TransitionProps.animationOnInit} is used to enable or disable animations.
44
+ * Whether initialization is finished. It determines which setting between {@link TransitionProps.animated}
45
+ * and {@link TransitionProps.animatedOnInit} is used to enable or disable animations.
46
46
  * @remarks
47
- * If it is `true`, initialization is considered finished, and {@link TransitionProps.animationOnInit} is no longer used.
48
- * Otherwise, initialization is considered unfinished and {@link TransitionProps.animationOnInit} is used instead of {@link TransitionProps.animation}.
47
+ * If it is `true`, initialization is considered finished, and {@link TransitionProps.animatedOnInit} is no longer used.
48
+ * Otherwise, initialization is considered unfinished and {@link TransitionProps.animatedOnInit} is used instead of {@link TransitionProps.animated}.
49
49
  * If it is `null`, it will be set to `true` automatically when the directive is called with a DOM element.
50
50
  * If it is `false`, it will not be updated automatically.
51
51
  */
@@ -98,31 +98,31 @@ export interface TransitionApi {
98
98
  /**
99
99
  * Runs the transition to show the element. It is equivalent to {@link TransitionApi.toggle | toggle} with true as the first parameter.
100
100
  *
101
- * @param animation - whether the transition should be animated. If the parameter is not defined, the {@link TransitionProps.animation | animation } property is used.
101
+ * @param animated - whether the transition should be animated. If the parameter is not defined, the {@link TransitionProps.animated | animated } property is used.
102
102
  *
103
103
  * @returns A promise that is fulfilled when the transition is completed. If the transition is canceled, or if the same transition was
104
104
  * already running, the promise never completes.
105
105
  */
106
- show: (animation?: boolean) => Promise<void>;
106
+ show: (animated?: boolean) => Promise<void>;
107
107
  /**
108
108
  * Runs the transition to hide the element. It is equivalent to {@link TransitionApi.toggle | toggle} with false as the first parameter.
109
109
  *
110
- * @param animation - whether the transition should be animated. If the parameter is not defined, the {@link TransitionProps.animation | animation } property is used.
110
+ * @param animated - whether the transition should be animated. If the parameter is not defined, the {@link TransitionProps.animated | animated } property is used.
111
111
  *
112
112
  * @returns A promise that is fulfilled when the transition is completed. If the transition is canceled, or if the same transition was
113
113
  * already running, the promise never completes.
114
114
  */
115
- hide: (animation?: boolean) => Promise<void>;
115
+ hide: (animated?: boolean) => Promise<void>;
116
116
  /**
117
117
  * Runs the transition to show or hide the element depending on the first parameter.
118
118
  *
119
119
  * @param visible - whether the element should be made visible or not. If the parameter is not defined, the opposite of the current {@link TransitionProps.visible | visible } property is used.
120
- * @param animation - whether the transition should be animated. If the parameter is not defined, the {@link TransitionProps.animation | animation } property is used.
120
+ * @param animated - whether the transition should be animated. If the parameter is not defined, the {@link TransitionProps.animated | animated } property is used.
121
121
  *
122
122
  * @returns A promise that is fulfilled when the transition is completed. If the transition is canceled, or if the same transition was
123
123
  * already running, the promise never completes.
124
124
  */
125
- toggle: (visible?: boolean, animation?: boolean) => Promise<void>;
125
+ toggle: (visible?: boolean, animated?: boolean) => Promise<void>;
126
126
  }
127
127
  export interface TransitionDirectives {
128
128
  /**
@@ -132,7 +132,7 @@ export interface TransitionDirectives {
132
132
  }
133
133
  export type TransitionWidget = Widget<TransitionProps, TransitionState, TransitionApi, object, TransitionDirectives>;
134
134
  /**
135
- * A transition to show / hide an element without any animation. It uses the HTML `display` attribute.
135
+ * A transition to show / hide an element without any animated. It uses the HTML `display` attribute.
136
136
  *
137
137
  * @param element - the element to animate
138
138
  * @param direction - the direction