@agnos-ui/core 0.9.3 → 0.10.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.
- package/{accordion-CoM4efp-.js → accordion-CcirvrjR.js} +10 -15
- package/{accordion-cR5JqWJ8.cjs → accordion-yD-czBna.cjs} +10 -15
- package/{alert-DtDozJal.cjs → alert-B-jQDQcB.cjs} +1 -1
- package/{alert-YIlqdEPO.js → alert-gGz2CDS9.js} +1 -1
- package/{collapse-DwXz2kNw.js → collapse-BV4kD3j9.js} +2 -2
- package/{collapse-DRp53EuG.cjs → collapse-gLiT080Y.cjs} +2 -2
- package/{common-BToNPUDq.cjs → common-D3QcdJ6S.cjs} +1 -1
- package/{common-BqUjUBPy.js → common-DK0ADNTX.js} +1 -1
- package/components/accordion/index.cjs +1 -1
- package/components/accordion/index.js +1 -1
- package/components/alert/index.cjs +1 -1
- package/components/alert/index.js +1 -1
- package/components/carousel/index.cjs +10 -23
- package/components/carousel/index.js +10 -23
- package/components/collapse/index.cjs +1 -1
- package/components/collapse/index.js +1 -1
- package/components/drawer/drawer.d.ts +222 -0
- package/components/drawer/index.cjs +5 -0
- package/components/drawer/index.d.ts +1 -0
- package/components/drawer/index.js +5 -0
- package/components/modal/index.cjs +2 -1
- package/components/modal/index.js +2 -1
- package/components/modal/modal.d.ts +5 -0
- package/components/pagination/index.cjs +1 -1
- package/components/pagination/index.js +1 -1
- package/components/progressbar/index.cjs +1 -1
- package/components/progressbar/index.js +1 -1
- package/components/rating/index.cjs +1 -1
- package/components/rating/index.js +1 -1
- package/components/select/index.cjs +1 -1
- package/components/select/index.js +1 -1
- package/components/slider/index.cjs +1 -1
- package/components/slider/index.js +1 -1
- package/components/toast/index.cjs +1 -1
- package/components/toast/index.js +1 -1
- package/components/tree/index.cjs +1 -1
- package/components/tree/index.js +1 -1
- package/config.cjs +2 -2
- package/config.d.ts +5 -0
- package/config.js +2 -2
- package/{dom-gfxqXJpK.js → dom-Bcg9ORcA.js} +64 -54
- package/{dom-CuBx1JPZ.cjs → dom-C2gi9OCP.cjs} +47 -37
- package/drawer-D5SO73ew.js +251 -0
- package/drawer-DP7UPojk.cjs +250 -0
- package/index.cjs +19 -13
- package/index.d.ts +1 -0
- package/index.js +36 -30
- package/isFocusable-Ckwus82R.js +32 -0
- package/isFocusable-DfzDLeAN.cjs +31 -0
- package/{modal-D3wGIDlj.js → modal-CAvQW-vo.js} +26 -32
- package/{modal-BEnQ6c5M.cjs → modal-DiXZXYjR.cjs} +27 -33
- package/package.json +1 -1
- package/{pagination-B97wBLok.js → pagination-BKbMROV6.js} +4 -4
- package/{pagination-C1TT-oea.cjs → pagination-DvZ2rLsz.cjs} +4 -4
- package/{progressbar-BWBlRk_Y.js → progressbar-D8zIcm9n.js} +2 -2
- package/{progressbar-CRvhNB5R.cjs → progressbar-i9xfAxb7.cjs} +2 -2
- package/{promise-XSP94FjG.js → promise-Y53vc4Ia.js} +5 -5
- package/{rating-BXvy9kXq.js → rating-DEXTGWCU.js} +2 -2
- package/{rating-DAb6nR67.cjs → rating-DmG4oUkr.cjs} +2 -2
- package/scrollbars-CT87iv_6.cjs +30 -0
- package/scrollbars-CcxSrnCx.js +31 -0
- package/{select-BdjpnE7_.js → select-Bw68Xdu5.js} +4 -5
- package/{select-C0rJJQfl.cjs → select-MFjAnIt7.cjs} +4 -5
- package/services/extendWidget.cjs +2 -2
- package/services/extendWidget.js +2 -2
- package/services/floatingUI.cjs +8 -29
- package/services/floatingUI.js +9 -30
- package/services/focusElement.cjs +46 -0
- package/services/focusElement.d.ts +9 -0
- package/services/focusElement.js +46 -0
- package/services/focustrack.cjs +1 -1
- package/services/focustrack.js +1 -1
- package/services/matchMedia.cjs +1 -1
- package/services/matchMedia.js +1 -1
- package/services/navManager.cjs +7 -37
- package/services/navManager.js +6 -36
- package/services/portal.cjs +7 -10
- package/services/portal.js +7 -10
- package/services/resizeObserver.cjs +2 -2
- package/services/resizeObserver.js +2 -2
- package/services/siblingsInert.cjs +9 -8
- package/services/siblingsInert.d.ts +13 -3
- package/services/siblingsInert.js +9 -8
- package/services/transitions/baseTransitions.cjs +9 -10
- package/services/transitions/baseTransitions.js +10 -11
- package/services/transitions/collapse.cjs +1 -1
- package/services/transitions/collapse.js +1 -1
- package/services/transitions/cssTransitions.cjs +1 -1
- package/services/transitions/cssTransitions.js +2 -2
- package/services/transitions/simpleClassTransition.cjs +1 -1
- package/services/transitions/simpleClassTransition.js +1 -1
- package/{slider-BmxQ3A_u.js → slider-Cx50Eghd.js} +14 -24
- package/{slider-DSx5CAce.cjs → slider-Dl4Trh32.cjs} +14 -24
- package/toaster-UDglac7x.cjs +187 -0
- package/toaster-_p1GTtHI.js +188 -0
- package/{tree-BFrXdJox.js → tree-DV0tfPlZ.js} +7 -11
- package/{tree-Pvr2rZ-D.cjs → tree-rGHtmCnS.cjs} +7 -11
- package/utils/directive.cjs +3 -1
- package/utils/directive.d.ts +47 -0
- package/utils/directive.js +14 -12
- package/utils/stores.cjs +8 -9
- package/utils/stores.js +8 -9
- package/utils/writables.cjs +1 -1
- package/utils/writables.js +1 -1
- package/{writables-Bn3uhKEG.cjs → writables-DcGT98a7.cjs} +1 -1
- package/{writables-CgpOQ4hA.js → writables-e0tyaQpe.js} +1 -1
- package/toaster-Cayg6Lbq.cjs +0 -209
- package/toaster-XfzHDqz_.js +0 -210
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const tansu = require("@amadeus-it-group/tansu");
|
|
3
|
+
const services_extendWidget = require("./services/extendWidget.cjs");
|
|
4
|
+
const utils_directive = require("./dom-C2gi9OCP.cjs");
|
|
5
|
+
const utils_stores = require("./utils/stores.cjs");
|
|
6
|
+
const utils_writables = require("./writables-DcGT98a7.cjs");
|
|
7
|
+
const common = require("./common-D3QcdJ6S.cjs");
|
|
8
|
+
const utils_widget = require("./utils/widget.cjs");
|
|
9
|
+
const toastDefaultConfig = {
|
|
10
|
+
autoHide: true,
|
|
11
|
+
delay: 5e3
|
|
12
|
+
};
|
|
13
|
+
const toastConfigValidator = {
|
|
14
|
+
autoHide: utils_writables.typeBoolean,
|
|
15
|
+
delay: utils_writables.typeNumberInRangeFactory(0, Infinity, { strict: true })
|
|
16
|
+
};
|
|
17
|
+
function getToastDefaultConfig() {
|
|
18
|
+
return { ...common.getCommonAlertDefaultConfig(), ...toastDefaultConfig };
|
|
19
|
+
}
|
|
20
|
+
const createToast = utils_widget.createWidgetFactory("toast", (config) => {
|
|
21
|
+
let _timeout;
|
|
22
|
+
const extendedAlert = services_extendWidget.extendWidgetProps(
|
|
23
|
+
common.createCommonAlert,
|
|
24
|
+
toastDefaultConfig,
|
|
25
|
+
toastConfigValidator
|
|
26
|
+
)(config);
|
|
27
|
+
const time$ = tansu.computed(() => {
|
|
28
|
+
clearTimeout(_timeout);
|
|
29
|
+
if (extendedAlert.stores.autoHide$()) {
|
|
30
|
+
_timeout = setTimeout(() => extendedAlert.api.close(), extendedAlert.stores.delay$());
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const bodyDirective = utils_directive.createAttributesDirective(() => ({
|
|
34
|
+
attributes: {
|
|
35
|
+
role: tansu.readable("alert"),
|
|
36
|
+
"aria-atomic": tansu.readable("true"),
|
|
37
|
+
class: tansu.computed(() => extendedAlert.stores.className$())
|
|
38
|
+
},
|
|
39
|
+
classNames: {
|
|
40
|
+
"au-toast": utils_stores.true$,
|
|
41
|
+
toast: utils_stores.true$
|
|
42
|
+
}
|
|
43
|
+
}));
|
|
44
|
+
const closeButtonDirective = utils_directive.createAttributesDirective(() => ({
|
|
45
|
+
attributes: {
|
|
46
|
+
type: tansu.readable("button"),
|
|
47
|
+
"aria-label": tansu.computed(() => extendedAlert.stores.ariaCloseButtonLabel$())
|
|
48
|
+
},
|
|
49
|
+
events: {
|
|
50
|
+
click: extendedAlert.api.close
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
return {
|
|
54
|
+
...extendedAlert,
|
|
55
|
+
directives: {
|
|
56
|
+
...extendedAlert.directives,
|
|
57
|
+
autoHideDirective: utils_directive.directiveSubscribe(time$),
|
|
58
|
+
bodyDirective,
|
|
59
|
+
closeButtonDirective
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
const defaultToasterProps = {
|
|
64
|
+
duration: 5e3,
|
|
65
|
+
position: "bottomRight",
|
|
66
|
+
dismissible: false
|
|
67
|
+
};
|
|
68
|
+
class Toaster {
|
|
69
|
+
#idCount = 0;
|
|
70
|
+
#toasts = tansu.writable([]);
|
|
71
|
+
/**
|
|
72
|
+
* Get the toasts value from the store
|
|
73
|
+
* @returns The array of toasts.
|
|
74
|
+
*/
|
|
75
|
+
toasts = tansu.computed(
|
|
76
|
+
() => this.#toasts().sort((a, b) => b.id - a.id).slice(0, this.options().limit)
|
|
77
|
+
);
|
|
78
|
+
options = tansu.writable(defaultToasterProps);
|
|
79
|
+
#timers = /* @__PURE__ */ new Map();
|
|
80
|
+
/**
|
|
81
|
+
* Get the timers value from the store
|
|
82
|
+
* @returns The map of timers.
|
|
83
|
+
*/
|
|
84
|
+
get timers() {
|
|
85
|
+
return new Map(this.#timers);
|
|
86
|
+
}
|
|
87
|
+
constructor(props) {
|
|
88
|
+
this.options.set({
|
|
89
|
+
...defaultToasterProps,
|
|
90
|
+
...props
|
|
91
|
+
});
|
|
92
|
+
this.options.subscribe(() => {
|
|
93
|
+
this.updateToasts();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Add timer for a toast
|
|
98
|
+
* @param id Id of the toast
|
|
99
|
+
* @param duration Duration of the timer, by default taken from options
|
|
100
|
+
*/
|
|
101
|
+
addTimer = (id, duration = this.options().duration) => {
|
|
102
|
+
if (duration > 0) {
|
|
103
|
+
this.#timers.set(id, {
|
|
104
|
+
timeout: setTimeout(() => this.removeToast(id), duration),
|
|
105
|
+
started: performance.now(),
|
|
106
|
+
duration
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Pause a timer for a toast
|
|
112
|
+
* @param id Id of the toast
|
|
113
|
+
*/
|
|
114
|
+
pauseTimer = (id) => {
|
|
115
|
+
if (this.#timers.has(id)) {
|
|
116
|
+
const timer = this.#timers.get(id);
|
|
117
|
+
if (timer && timer.timeout) {
|
|
118
|
+
clearTimeout(timer.timeout);
|
|
119
|
+
timer.timeout = null;
|
|
120
|
+
timer.paused = performance.now();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Resume a timer for a toast
|
|
126
|
+
* @param id Id of the toast
|
|
127
|
+
*/
|
|
128
|
+
resumeTimer = (id) => {
|
|
129
|
+
if (this.#timers.has(id)) {
|
|
130
|
+
const timer = this.#timers.get(id);
|
|
131
|
+
if (timer) {
|
|
132
|
+
const paused = timer.paused ?? timer.started;
|
|
133
|
+
const elapsed = paused - timer.started;
|
|
134
|
+
const remaining = (timer.duration ?? 0) - elapsed;
|
|
135
|
+
this.addTimer(id, remaining);
|
|
136
|
+
timer.duration = remaining;
|
|
137
|
+
timer.paused = void 0;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Events directive is used to set events on the Toast component, to keep track for example of pointer enter/leave,
|
|
143
|
+
* used to pause / resume the timer in case of duration and pauseOnHover are specified.
|
|
144
|
+
*/
|
|
145
|
+
eventsDirective = utils_directive.createAttributesDirective((id) => ({
|
|
146
|
+
events: {
|
|
147
|
+
pointerenter: () => this.options().pauseOnHover && this.pauseTimer(id()),
|
|
148
|
+
pointerleave: () => this.options().pauseOnHover && this.resumeTimer(id())
|
|
149
|
+
}
|
|
150
|
+
}));
|
|
151
|
+
/**
|
|
152
|
+
* Helper to add a toast to the viewport.
|
|
153
|
+
* @param props Options for the toast.
|
|
154
|
+
* @returns The ID of the added toast.
|
|
155
|
+
*/
|
|
156
|
+
addToast = (props) => {
|
|
157
|
+
const autoHide = props.autoHide ?? this.options().duration > 0;
|
|
158
|
+
this.#toasts.update((toasts) => [...toasts, { id: this.#idCount++, props }]);
|
|
159
|
+
if (autoHide) {
|
|
160
|
+
this.addTimer(this.#idCount - 1, props.delay);
|
|
161
|
+
}
|
|
162
|
+
return this.#idCount - 1;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Helper to remove a toast to the viewport.
|
|
166
|
+
* @param id Id of the toast to remove.
|
|
167
|
+
*/
|
|
168
|
+
removeToast = (id) => {
|
|
169
|
+
this.#timers.delete(id);
|
|
170
|
+
this.#toasts.update((toasts) => toasts.filter((toast) => toast.id !== id));
|
|
171
|
+
};
|
|
172
|
+
/** Helper to update toasts when options change */
|
|
173
|
+
updateToasts = () => {
|
|
174
|
+
if (this.options().duration === 0) {
|
|
175
|
+
this.options().dismissible = true;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
/** Helper to close all toasts at once */
|
|
179
|
+
closeAll = () => {
|
|
180
|
+
this.#toasts.set([]);
|
|
181
|
+
this.#timers.clear();
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
exports.Toaster = Toaster;
|
|
185
|
+
exports.createToast = createToast;
|
|
186
|
+
exports.defaultToasterProps = defaultToasterProps;
|
|
187
|
+
exports.getToastDefaultConfig = getToastDefaultConfig;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { computed, readable, writable } from "@amadeus-it-group/tansu";
|
|
2
|
+
import { extendWidgetProps } from "./services/extendWidget.js";
|
|
3
|
+
import { p as createAttributesDirective, d as directiveSubscribe } from "./dom-Bcg9ORcA.js";
|
|
4
|
+
import { true$ } from "./utils/stores.js";
|
|
5
|
+
import { b as typeNumberInRangeFactory, c as typeBoolean } from "./writables-e0tyaQpe.js";
|
|
6
|
+
import { g as getCommonAlertDefaultConfig, c as createCommonAlert } from "./common-DK0ADNTX.js";
|
|
7
|
+
import { createWidgetFactory } from "./utils/widget.js";
|
|
8
|
+
const toastDefaultConfig = {
|
|
9
|
+
autoHide: true,
|
|
10
|
+
delay: 5e3
|
|
11
|
+
};
|
|
12
|
+
const toastConfigValidator = {
|
|
13
|
+
autoHide: typeBoolean,
|
|
14
|
+
delay: typeNumberInRangeFactory(0, Infinity, { strict: true })
|
|
15
|
+
};
|
|
16
|
+
function getToastDefaultConfig() {
|
|
17
|
+
return { ...getCommonAlertDefaultConfig(), ...toastDefaultConfig };
|
|
18
|
+
}
|
|
19
|
+
const createToast = createWidgetFactory("toast", (config) => {
|
|
20
|
+
let _timeout;
|
|
21
|
+
const extendedAlert = extendWidgetProps(
|
|
22
|
+
createCommonAlert,
|
|
23
|
+
toastDefaultConfig,
|
|
24
|
+
toastConfigValidator
|
|
25
|
+
)(config);
|
|
26
|
+
const time$ = computed(() => {
|
|
27
|
+
clearTimeout(_timeout);
|
|
28
|
+
if (extendedAlert.stores.autoHide$()) {
|
|
29
|
+
_timeout = setTimeout(() => extendedAlert.api.close(), extendedAlert.stores.delay$());
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const bodyDirective = createAttributesDirective(() => ({
|
|
33
|
+
attributes: {
|
|
34
|
+
role: readable("alert"),
|
|
35
|
+
"aria-atomic": readable("true"),
|
|
36
|
+
class: computed(() => extendedAlert.stores.className$())
|
|
37
|
+
},
|
|
38
|
+
classNames: {
|
|
39
|
+
"au-toast": true$,
|
|
40
|
+
toast: true$
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
const closeButtonDirective = createAttributesDirective(() => ({
|
|
44
|
+
attributes: {
|
|
45
|
+
type: readable("button"),
|
|
46
|
+
"aria-label": computed(() => extendedAlert.stores.ariaCloseButtonLabel$())
|
|
47
|
+
},
|
|
48
|
+
events: {
|
|
49
|
+
click: extendedAlert.api.close
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
return {
|
|
53
|
+
...extendedAlert,
|
|
54
|
+
directives: {
|
|
55
|
+
...extendedAlert.directives,
|
|
56
|
+
autoHideDirective: directiveSubscribe(time$),
|
|
57
|
+
bodyDirective,
|
|
58
|
+
closeButtonDirective
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
const defaultToasterProps = {
|
|
63
|
+
duration: 5e3,
|
|
64
|
+
position: "bottomRight",
|
|
65
|
+
dismissible: false
|
|
66
|
+
};
|
|
67
|
+
class Toaster {
|
|
68
|
+
#idCount = 0;
|
|
69
|
+
#toasts = writable([]);
|
|
70
|
+
/**
|
|
71
|
+
* Get the toasts value from the store
|
|
72
|
+
* @returns The array of toasts.
|
|
73
|
+
*/
|
|
74
|
+
toasts = computed(
|
|
75
|
+
() => this.#toasts().sort((a, b) => b.id - a.id).slice(0, this.options().limit)
|
|
76
|
+
);
|
|
77
|
+
options = writable(defaultToasterProps);
|
|
78
|
+
#timers = /* @__PURE__ */ new Map();
|
|
79
|
+
/**
|
|
80
|
+
* Get the timers value from the store
|
|
81
|
+
* @returns The map of timers.
|
|
82
|
+
*/
|
|
83
|
+
get timers() {
|
|
84
|
+
return new Map(this.#timers);
|
|
85
|
+
}
|
|
86
|
+
constructor(props) {
|
|
87
|
+
this.options.set({
|
|
88
|
+
...defaultToasterProps,
|
|
89
|
+
...props
|
|
90
|
+
});
|
|
91
|
+
this.options.subscribe(() => {
|
|
92
|
+
this.updateToasts();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Add timer for a toast
|
|
97
|
+
* @param id Id of the toast
|
|
98
|
+
* @param duration Duration of the timer, by default taken from options
|
|
99
|
+
*/
|
|
100
|
+
addTimer = (id, duration = this.options().duration) => {
|
|
101
|
+
if (duration > 0) {
|
|
102
|
+
this.#timers.set(id, {
|
|
103
|
+
timeout: setTimeout(() => this.removeToast(id), duration),
|
|
104
|
+
started: performance.now(),
|
|
105
|
+
duration
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Pause a timer for a toast
|
|
111
|
+
* @param id Id of the toast
|
|
112
|
+
*/
|
|
113
|
+
pauseTimer = (id) => {
|
|
114
|
+
if (this.#timers.has(id)) {
|
|
115
|
+
const timer = this.#timers.get(id);
|
|
116
|
+
if (timer && timer.timeout) {
|
|
117
|
+
clearTimeout(timer.timeout);
|
|
118
|
+
timer.timeout = null;
|
|
119
|
+
timer.paused = performance.now();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Resume a timer for a toast
|
|
125
|
+
* @param id Id of the toast
|
|
126
|
+
*/
|
|
127
|
+
resumeTimer = (id) => {
|
|
128
|
+
if (this.#timers.has(id)) {
|
|
129
|
+
const timer = this.#timers.get(id);
|
|
130
|
+
if (timer) {
|
|
131
|
+
const paused = timer.paused ?? timer.started;
|
|
132
|
+
const elapsed = paused - timer.started;
|
|
133
|
+
const remaining = (timer.duration ?? 0) - elapsed;
|
|
134
|
+
this.addTimer(id, remaining);
|
|
135
|
+
timer.duration = remaining;
|
|
136
|
+
timer.paused = void 0;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Events directive is used to set events on the Toast component, to keep track for example of pointer enter/leave,
|
|
142
|
+
* used to pause / resume the timer in case of duration and pauseOnHover are specified.
|
|
143
|
+
*/
|
|
144
|
+
eventsDirective = createAttributesDirective((id) => ({
|
|
145
|
+
events: {
|
|
146
|
+
pointerenter: () => this.options().pauseOnHover && this.pauseTimer(id()),
|
|
147
|
+
pointerleave: () => this.options().pauseOnHover && this.resumeTimer(id())
|
|
148
|
+
}
|
|
149
|
+
}));
|
|
150
|
+
/**
|
|
151
|
+
* Helper to add a toast to the viewport.
|
|
152
|
+
* @param props Options for the toast.
|
|
153
|
+
* @returns The ID of the added toast.
|
|
154
|
+
*/
|
|
155
|
+
addToast = (props) => {
|
|
156
|
+
const autoHide = props.autoHide ?? this.options().duration > 0;
|
|
157
|
+
this.#toasts.update((toasts) => [...toasts, { id: this.#idCount++, props }]);
|
|
158
|
+
if (autoHide) {
|
|
159
|
+
this.addTimer(this.#idCount - 1, props.delay);
|
|
160
|
+
}
|
|
161
|
+
return this.#idCount - 1;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Helper to remove a toast to the viewport.
|
|
165
|
+
* @param id Id of the toast to remove.
|
|
166
|
+
*/
|
|
167
|
+
removeToast = (id) => {
|
|
168
|
+
this.#timers.delete(id);
|
|
169
|
+
this.#toasts.update((toasts) => toasts.filter((toast) => toast.id !== id));
|
|
170
|
+
};
|
|
171
|
+
/** Helper to update toasts when options change */
|
|
172
|
+
updateToasts = () => {
|
|
173
|
+
if (this.options().duration === 0) {
|
|
174
|
+
this.options().dismissible = true;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
/** Helper to close all toasts at once */
|
|
178
|
+
closeAll = () => {
|
|
179
|
+
this.#toasts.set([]);
|
|
180
|
+
this.#timers.clear();
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
export {
|
|
184
|
+
Toaster as T,
|
|
185
|
+
createToast as c,
|
|
186
|
+
defaultToasterProps as d,
|
|
187
|
+
getToastDefaultConfig as g
|
|
188
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { writable, computed, readable } from "@amadeus-it-group/tansu";
|
|
2
2
|
import { createNavManager } from "./services/navManager.js";
|
|
3
|
-
import {
|
|
3
|
+
import { n as mergeDirectives, p as createAttributesDirective, b as browserDirective, a as bindDirective } from "./dom-Bcg9ORcA.js";
|
|
4
4
|
import { noop } from "./utils/func.js";
|
|
5
5
|
import { writablesForProps, stateStores, true$ } from "./utils/stores.js";
|
|
6
|
-
import { g as typeFunction, i as typeArray, e as typeString } from "./writables-
|
|
6
|
+
import { g as typeFunction, i as typeArray, e as typeString } from "./writables-e0tyaQpe.js";
|
|
7
7
|
import { createWidgetFactory } from "./utils/widget.js";
|
|
8
8
|
function getTreeDefaultConfig() {
|
|
9
9
|
return {
|
|
@@ -62,13 +62,12 @@ const createTree = createWidgetFactory("tree", (config) => {
|
|
|
62
62
|
selector: navSelector$()
|
|
63
63
|
}));
|
|
64
64
|
const traverseTree = (node, level, parent) => {
|
|
65
|
-
var _a;
|
|
66
65
|
const copyNode = {
|
|
67
66
|
...node,
|
|
68
67
|
ariaLabel: node.ariaLabel ?? node.label,
|
|
69
68
|
level,
|
|
70
69
|
children: [],
|
|
71
|
-
isExpanded:
|
|
70
|
+
isExpanded: node.children?.length ? node.isExpanded ?? false : void 0
|
|
72
71
|
};
|
|
73
72
|
treeMap.set(copyNode, {
|
|
74
73
|
parent
|
|
@@ -117,9 +116,8 @@ const createTree = createWidgetFactory("tree", (config) => {
|
|
|
117
116
|
}
|
|
118
117
|
);
|
|
119
118
|
const focusElementIfExists = (itemToFocus) => {
|
|
120
|
-
var _a;
|
|
121
119
|
if (itemToFocus) {
|
|
122
|
-
const mapItemHtml =
|
|
120
|
+
const mapItemHtml = getTreeItemInfo(itemToFocus)?.htmlElement;
|
|
123
121
|
if (mapItemHtml) {
|
|
124
122
|
const index = elementsInDomOrder$().indexOf(mapItemHtml);
|
|
125
123
|
focusIndex(index, 0);
|
|
@@ -137,7 +135,6 @@ const createTree = createWidgetFactory("tree", (config) => {
|
|
|
137
135
|
toggleExpanded(item);
|
|
138
136
|
},
|
|
139
137
|
keydown: (event) => {
|
|
140
|
-
var _a, _b;
|
|
141
138
|
const { key } = event;
|
|
142
139
|
const { item } = treeItemContext$();
|
|
143
140
|
const isExpanded = item.isExpanded;
|
|
@@ -151,14 +148,14 @@ const createTree = createWidgetFactory("tree", (config) => {
|
|
|
151
148
|
if (isExpanded) {
|
|
152
149
|
toggleExpanded(item);
|
|
153
150
|
} else {
|
|
154
|
-
focusElementIfExists(
|
|
151
|
+
focusElementIfExists(getTreeItemInfo(item)?.parent);
|
|
155
152
|
}
|
|
156
153
|
break;
|
|
157
154
|
case "ArrowRight":
|
|
158
155
|
if (!isExpanded) {
|
|
159
156
|
toggleExpanded(item);
|
|
160
157
|
} else {
|
|
161
|
-
focusElementIfExists(
|
|
158
|
+
focusElementIfExists(item.children?.[0]);
|
|
162
159
|
}
|
|
163
160
|
break;
|
|
164
161
|
default:
|
|
@@ -210,10 +207,9 @@ const createTree = createWidgetFactory("tree", (config) => {
|
|
|
210
207
|
"aria-selected": readable("false"),
|
|
211
208
|
// TODO: adapt aria-selected to the actual selected state
|
|
212
209
|
"aria-expanded": computed(() => {
|
|
213
|
-
var _a;
|
|
214
210
|
const { item } = treeItemContext$();
|
|
215
211
|
_toggleChange$();
|
|
216
|
-
return
|
|
212
|
+
return item.isExpanded?.toString();
|
|
217
213
|
})
|
|
218
214
|
}
|
|
219
215
|
}))
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const tansu = require("@amadeus-it-group/tansu");
|
|
3
3
|
const services_navManager = require("./services/navManager.cjs");
|
|
4
|
-
const utils_directive = require("./dom-
|
|
4
|
+
const utils_directive = require("./dom-C2gi9OCP.cjs");
|
|
5
5
|
const utils_func = require("./utils/func.cjs");
|
|
6
6
|
const utils_stores = require("./utils/stores.cjs");
|
|
7
|
-
const utils_writables = require("./writables-
|
|
7
|
+
const utils_writables = require("./writables-DcGT98a7.cjs");
|
|
8
8
|
const utils_widget = require("./utils/widget.cjs");
|
|
9
9
|
function getTreeDefaultConfig() {
|
|
10
10
|
return {
|
|
@@ -63,13 +63,12 @@ const createTree = utils_widget.createWidgetFactory("tree", (config) => {
|
|
|
63
63
|
selector: navSelector$()
|
|
64
64
|
}));
|
|
65
65
|
const traverseTree = (node, level, parent) => {
|
|
66
|
-
var _a;
|
|
67
66
|
const copyNode = {
|
|
68
67
|
...node,
|
|
69
68
|
ariaLabel: node.ariaLabel ?? node.label,
|
|
70
69
|
level,
|
|
71
70
|
children: [],
|
|
72
|
-
isExpanded:
|
|
71
|
+
isExpanded: node.children?.length ? node.isExpanded ?? false : void 0
|
|
73
72
|
};
|
|
74
73
|
treeMap.set(copyNode, {
|
|
75
74
|
parent
|
|
@@ -118,9 +117,8 @@ const createTree = utils_widget.createWidgetFactory("tree", (config) => {
|
|
|
118
117
|
}
|
|
119
118
|
);
|
|
120
119
|
const focusElementIfExists = (itemToFocus) => {
|
|
121
|
-
var _a;
|
|
122
120
|
if (itemToFocus) {
|
|
123
|
-
const mapItemHtml =
|
|
121
|
+
const mapItemHtml = getTreeItemInfo(itemToFocus)?.htmlElement;
|
|
124
122
|
if (mapItemHtml) {
|
|
125
123
|
const index = elementsInDomOrder$().indexOf(mapItemHtml);
|
|
126
124
|
focusIndex(index, 0);
|
|
@@ -138,7 +136,6 @@ const createTree = utils_widget.createWidgetFactory("tree", (config) => {
|
|
|
138
136
|
toggleExpanded(item);
|
|
139
137
|
},
|
|
140
138
|
keydown: (event) => {
|
|
141
|
-
var _a, _b;
|
|
142
139
|
const { key } = event;
|
|
143
140
|
const { item } = treeItemContext$();
|
|
144
141
|
const isExpanded = item.isExpanded;
|
|
@@ -152,14 +149,14 @@ const createTree = utils_widget.createWidgetFactory("tree", (config) => {
|
|
|
152
149
|
if (isExpanded) {
|
|
153
150
|
toggleExpanded(item);
|
|
154
151
|
} else {
|
|
155
|
-
focusElementIfExists(
|
|
152
|
+
focusElementIfExists(getTreeItemInfo(item)?.parent);
|
|
156
153
|
}
|
|
157
154
|
break;
|
|
158
155
|
case "ArrowRight":
|
|
159
156
|
if (!isExpanded) {
|
|
160
157
|
toggleExpanded(item);
|
|
161
158
|
} else {
|
|
162
|
-
focusElementIfExists(
|
|
159
|
+
focusElementIfExists(item.children?.[0]);
|
|
163
160
|
}
|
|
164
161
|
break;
|
|
165
162
|
default:
|
|
@@ -211,10 +208,9 @@ const createTree = utils_widget.createWidgetFactory("tree", (config) => {
|
|
|
211
208
|
"aria-selected": tansu.readable("false"),
|
|
212
209
|
// TODO: adapt aria-selected to the actual selected state
|
|
213
210
|
"aria-expanded": tansu.computed(() => {
|
|
214
|
-
var _a;
|
|
215
211
|
const { item } = treeItemContext$();
|
|
216
212
|
_toggleChange$();
|
|
217
|
-
return
|
|
213
|
+
return item.isExpanded?.toString();
|
|
218
214
|
})
|
|
219
215
|
}
|
|
220
216
|
}))
|
package/utils/directive.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("@amadeus-it-group/tansu");
|
|
4
4
|
require("esm-env");
|
|
5
|
-
const utils_directive = require("../dom-
|
|
5
|
+
const utils_directive = require("../dom-C2gi9OCP.cjs");
|
|
6
6
|
require("./func.cjs");
|
|
7
7
|
exports.attributesData = utils_directive.attributesData;
|
|
8
8
|
exports.bindDirective = utils_directive.bindDirective;
|
|
@@ -12,6 +12,8 @@ exports.classDirective = utils_directive.classDirective;
|
|
|
12
12
|
exports.createAttributesDirective = utils_directive.createAttributesDirective;
|
|
13
13
|
exports.createBrowserStoreArrayDirective = utils_directive.createBrowserStoreArrayDirective;
|
|
14
14
|
exports.createBrowserStoreDirective = utils_directive.createBrowserStoreDirective;
|
|
15
|
+
exports.createConditionalBrowserStoreArrayDirective = utils_directive.createConditionalBrowserStoreArrayDirective;
|
|
16
|
+
exports.createConditionalStoreArrayDirective = utils_directive.createConditionalStoreArrayDirective;
|
|
15
17
|
exports.createStoreArrayDirective = utils_directive.createStoreArrayDirective;
|
|
16
18
|
exports.createStoreDirective = utils_directive.createStoreDirective;
|
|
17
19
|
exports.directiveAttributes = utils_directive.directiveAttributes;
|
package/utils/directive.d.ts
CHANGED
|
@@ -88,6 +88,30 @@ export declare const directiveUpdate: <T>(update: (arg: T) => void) => Directive
|
|
|
88
88
|
export declare const registrationArray: <T>() => ReadableSignal<T[]> & {
|
|
89
89
|
register: (element: T) => () => void;
|
|
90
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* Returns a directive and a store. The store contains at any time the array of all the DOM elements on which the directive is
|
|
93
|
+
* currently used.
|
|
94
|
+
*
|
|
95
|
+
* The directive is applied depending on the value of its argument:
|
|
96
|
+
* - `true` or `undefined`: Apply directive to the element.
|
|
97
|
+
* - `false`: Do not apply apply directive to the element.
|
|
98
|
+
*
|
|
99
|
+
* @remarks
|
|
100
|
+
* It is the same as {@link createConditionalBrowserStoreArrayDirective}, but the returned directive is also executed in a server environment
|
|
101
|
+
* and the type of the elements is {@link SSRHTMLElement} instead of HTMLElement.
|
|
102
|
+
*
|
|
103
|
+
* If the directive is intended to be used on a single element element, it may be more appropriate to use
|
|
104
|
+
* {@link createStoreDirective} instead.
|
|
105
|
+
*
|
|
106
|
+
*
|
|
107
|
+
* @returns An object with two properties: the `directive` property that is the directive to use on some DOM elements,
|
|
108
|
+
* and the `elements$` property that is the store containing an array of all the elements on which the directive is currently
|
|
109
|
+
* used.
|
|
110
|
+
*/
|
|
111
|
+
export declare const createConditionalStoreArrayDirective: () => {
|
|
112
|
+
directive: Directive<boolean | undefined>;
|
|
113
|
+
elements$: ReadableSignal<SSRHTMLElement[]>;
|
|
114
|
+
};
|
|
91
115
|
/**
|
|
92
116
|
* Returns a directive and a store. The store contains at any time the array of all the DOM elements on which the directive is
|
|
93
117
|
* currently used.
|
|
@@ -126,6 +150,29 @@ export declare const createBrowserStoreArrayDirective: () => {
|
|
|
126
150
|
directive: Directive<void, SSRHTMLElement>;
|
|
127
151
|
elements$: ReadableSignal<HTMLElement[]>;
|
|
128
152
|
};
|
|
153
|
+
/**
|
|
154
|
+
* Returns a directive and a store. The store contains at any time the array of all the DOM elements on which the directive is
|
|
155
|
+
* currently used.
|
|
156
|
+
*
|
|
157
|
+
* The directive is applied depending on the value of its argument:
|
|
158
|
+
* - `true` or `undefined`: Apply directive to the element.
|
|
159
|
+
* - `false`: Do not apply apply directive to the element.
|
|
160
|
+
*
|
|
161
|
+
* @remarks
|
|
162
|
+
* It is the same as {@link createConditionalStoreArrayDirective}, but the returned directive is only executed in a browser environment
|
|
163
|
+
* and the type of the elements is HTMLElement instead of {@link SSRHTMLElement}.
|
|
164
|
+
*
|
|
165
|
+
* If the directive is intended to be used on a single element element, it may be more appropriate to use
|
|
166
|
+
* {@link createBrowserStoreDirective} instead.
|
|
167
|
+
*
|
|
168
|
+
* @returns An object with two properties: the `directive` property that is the directive to use on some DOM elements,
|
|
169
|
+
* and the `elements$` property that is the store containing an array of all the elements on which the directive is currently
|
|
170
|
+
* used.
|
|
171
|
+
*/
|
|
172
|
+
export declare const createConditionalBrowserStoreArrayDirective: () => {
|
|
173
|
+
directive: Directive<boolean | undefined, SSRHTMLElement>;
|
|
174
|
+
elements$: ReadableSignal<HTMLElement[]>;
|
|
175
|
+
};
|
|
129
176
|
/**
|
|
130
177
|
* Returns a directive and a store. When the directive is used on a DOM element, the store contains that DOM element.
|
|
131
178
|
* When the directive is not used, the store contains null.
|
package/utils/directive.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import "@amadeus-it-group/tansu";
|
|
2
2
|
import "esm-env";
|
|
3
|
-
import {
|
|
3
|
+
import { q, a, c, b, s, p, h, l, j, f, g, k, t, d, e, i, m, n, o, r, u } from "../dom-Bcg9ORcA.js";
|
|
4
4
|
import "./func.js";
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
q as attributesData,
|
|
7
7
|
a as bindDirective,
|
|
8
8
|
c as bindDirectiveNoArg,
|
|
9
9
|
b as browserDirective,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
s as classDirective,
|
|
11
|
+
p as createAttributesDirective,
|
|
12
|
+
h as createBrowserStoreArrayDirective,
|
|
13
|
+
l as createBrowserStoreDirective,
|
|
14
|
+
j as createConditionalBrowserStoreArrayDirective,
|
|
15
|
+
f as createConditionalStoreArrayDirective,
|
|
16
|
+
g as createStoreArrayDirective,
|
|
17
|
+
k as createStoreDirective,
|
|
18
|
+
t as directiveAttributes,
|
|
17
19
|
d as directiveSubscribe,
|
|
18
20
|
e as directiveUpdate,
|
|
19
21
|
i as isBrowserHTMLElement,
|
|
20
22
|
m as mapDirectiveArg,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
n as mergeDirectives,
|
|
24
|
+
o as multiDirective,
|
|
23
25
|
r as registrationArray,
|
|
24
|
-
|
|
26
|
+
u as ssrAttributes
|
|
25
27
|
};
|
package/utils/stores.cjs
CHANGED
|
@@ -3,13 +3,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const tansu = require("@amadeus-it-group/tansu");
|
|
4
4
|
const types = require("../types.cjs");
|
|
5
5
|
const utils_func = require("./func.cjs");
|
|
6
|
-
const utils_directive = require("../dom-
|
|
6
|
+
const utils_directive = require("../dom-C2gi9OCP.cjs");
|
|
7
7
|
function createPatch(stores) {
|
|
8
8
|
return function(storesValues) {
|
|
9
9
|
tansu.batch(() => {
|
|
10
|
-
var _a;
|
|
11
10
|
for (const [name, value] of Object.entries(storesValues)) {
|
|
12
|
-
|
|
11
|
+
stores[`${name}$`]?.set(value);
|
|
13
12
|
}
|
|
14
13
|
});
|
|
15
14
|
};
|
|
@@ -74,8 +73,8 @@ const normalizeConfigStores = (keys, config) => {
|
|
|
74
73
|
const mergeConfigStores = (keys, config1, config2) => {
|
|
75
74
|
const res = {};
|
|
76
75
|
for (const key of keys) {
|
|
77
|
-
const config1Store = config1
|
|
78
|
-
const config2Store = config2
|
|
76
|
+
const config1Store = config1?.[key];
|
|
77
|
+
const config2Store = config2?.[key];
|
|
79
78
|
res[key] = config1Store && config2Store ? tansu.computed(() => config1Store() ?? config2Store()) : config1Store || config2Store;
|
|
80
79
|
}
|
|
81
80
|
return res;
|
|
@@ -83,11 +82,11 @@ const mergeConfigStores = (keys, config1, config2) => {
|
|
|
83
82
|
const writablesWithDefault = (defConfig, propsConfig, options) => {
|
|
84
83
|
const res = {};
|
|
85
84
|
const keys = Object.keys(defConfig);
|
|
86
|
-
const configStores = normalizeConfigStores(keys, propsConfig
|
|
87
|
-
const props = propsConfig
|
|
85
|
+
const configStores = normalizeConfigStores(keys, propsConfig?.config);
|
|
86
|
+
const props = propsConfig?.props;
|
|
88
87
|
for (const key of keys) {
|
|
89
|
-
const propValue = props
|
|
90
|
-
res[`${key}$`] = writableWithDefault(defConfig[key], configStores[key], options
|
|
88
|
+
const propValue = props?.[key];
|
|
89
|
+
res[`${key}$`] = writableWithDefault(defConfig[key], configStores[key], options?.[key], toWritableStore(propValue));
|
|
91
90
|
}
|
|
92
91
|
return res;
|
|
93
92
|
};
|