@agnos-ui/core 0.8.0-next.1 → 0.8.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 (57) hide show
  1. package/{accordion-OTiJtxDi.js → accordion-BLVIYePx.js} +1 -1
  2. package/{accordion-DTQj-TQ1.cjs → accordion-vfnqMstG.cjs} +1 -1
  3. package/{alert-DH-mO6WX.js → alert-BpepSIHu.js} +1 -1
  4. package/{alert-BrVkxOnA.cjs → alert-D6W48Ffr.cjs} +1 -1
  5. package/{common-CcQOJ_hf.cjs → common-BToNPUDq.cjs} +1 -1
  6. package/{common-Bffx1jJO.js → common-BqUjUBPy.js} +1 -1
  7. package/components/accordion/index.cjs +1 -1
  8. package/components/accordion/index.js +1 -1
  9. package/components/alert/index.cjs +1 -1
  10. package/components/alert/index.js +1 -1
  11. package/components/carousel/carousel.d.ts +232 -0
  12. package/components/carousel/index.cjs +288 -0
  13. package/components/carousel/index.d.ts +1 -0
  14. package/components/carousel/index.js +288 -0
  15. package/components/modal/index.cjs +1 -1
  16. package/components/modal/index.js +1 -1
  17. package/components/pagination/index.cjs +1 -1
  18. package/components/pagination/index.js +1 -1
  19. package/components/progressbar/index.cjs +1 -1
  20. package/components/progressbar/index.js +1 -1
  21. package/components/rating/index.cjs +1 -1
  22. package/components/rating/index.js +1 -1
  23. package/components/slider/index.cjs +1 -1
  24. package/components/slider/index.js +1 -1
  25. package/components/toast/index.cjs +5 -3
  26. package/components/toast/index.d.ts +1 -0
  27. package/components/toast/index.js +3 -1
  28. package/components/toast/toaster.d.ts +128 -0
  29. package/components/tree/index.cjs +1 -1
  30. package/components/tree/index.js +1 -1
  31. package/config.d.ts +5 -0
  32. package/index.cjs +15 -12
  33. package/index.js +20 -17
  34. package/{modal-85Sw8xuV.js → modal-CGK3h9pR.js} +1 -1
  35. package/{modal-B7bYoubx.cjs → modal-Dw1MuWPV.cjs} +1 -1
  36. package/package.json +4 -1
  37. package/{pagination-5YARuB3V.cjs → pagination-BzyKulaI.cjs} +1 -1
  38. package/{pagination-4g3N8ktf.js → pagination-CRAKaOuh.js} +1 -1
  39. package/{progressbar-BoJsBPH1.js → progressbar-Csnqx_Pk.js} +1 -1
  40. package/{progressbar-BpSrg4HG.cjs → progressbar-D9rvrxXi.cjs} +1 -1
  41. package/{rating-C8tn9xTO.cjs → rating-C4c8Paz-.cjs} +1 -1
  42. package/{rating-B3xktzOf.js → rating-CvTnNxgN.js} +1 -1
  43. package/services/transitions/baseTransitions.cjs +1 -1
  44. package/services/transitions/baseTransitions.js +1 -1
  45. package/{slider-B2JFXDLt.cjs → slider-B0ZfAY0K.cjs} +200 -97
  46. package/{slider-Cs69pziL.js → slider-BF6a0eh_.js} +201 -98
  47. package/toaster-B2ibv38T.cjs +208 -0
  48. package/toaster-PwfLC7FH.js +209 -0
  49. package/{tree-C_goOyCv.js → tree-DUU_TWqy.js} +1 -1
  50. package/{tree-D4t2SOql.cjs → tree-Dwv2U0ea.cjs} +1 -1
  51. package/utils/writables.cjs +2 -1
  52. package/utils/writables.d.ts +7 -0
  53. package/utils/writables.js +7 -6
  54. package/{writables-BPAJvaL_.cjs → writables-Bn3uhKEG.cjs} +4 -0
  55. package/{writables-DCiBdIBK.js → writables-CgpOQ4hA.js} +10 -6
  56. package/toast-4HGIz3Bu.js +0 -64
  57. package/toast-CaIcB2sD.cjs +0 -63
@@ -0,0 +1,209 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
+ var __privateWrapper = (obj, member, setter, getter) => ({
12
+ set _(value) {
13
+ __privateSet(obj, member, value, setter);
14
+ },
15
+ get _() {
16
+ return __privateGet(obj, member, getter);
17
+ }
18
+ });
19
+ var _idCount, _toasts, _timers;
20
+ import { computed, readable, writable } from "@amadeus-it-group/tansu";
21
+ import { extendWidgetProps } from "./services/extendWidget.js";
22
+ import { n as createAttributesDirective, d as directiveSubscribe } from "./dom-gfxqXJpK.js";
23
+ import { true$ } from "./utils/stores.js";
24
+ import { b as typeNumberInRangeFactory, c as typeBoolean } from "./writables-CgpOQ4hA.js";
25
+ import { g as getCommonAlertDefaultConfig, c as createCommonAlert } from "./common-BqUjUBPy.js";
26
+ const toastDefaultConfig = {
27
+ autoHide: true,
28
+ delay: 5e3
29
+ };
30
+ const toastConfigValidator = {
31
+ autoHide: typeBoolean,
32
+ delay: typeNumberInRangeFactory(0, Infinity, { strict: true })
33
+ };
34
+ function getToastDefaultConfig() {
35
+ return { ...getCommonAlertDefaultConfig(), ...toastDefaultConfig };
36
+ }
37
+ function createToast(config) {
38
+ let _timeout;
39
+ const extendedAlert = extendWidgetProps(
40
+ createCommonAlert,
41
+ toastDefaultConfig,
42
+ toastConfigValidator
43
+ )(config);
44
+ const time$ = computed(() => {
45
+ clearTimeout(_timeout);
46
+ if (extendedAlert.stores.autoHide$()) {
47
+ _timeout = setTimeout(() => extendedAlert.api.close(), extendedAlert.stores.delay$());
48
+ }
49
+ });
50
+ const bodyDirective = createAttributesDirective(() => ({
51
+ attributes: {
52
+ role: readable("alert"),
53
+ "aria-atomic": readable("true"),
54
+ class: computed(() => extendedAlert.stores.className$())
55
+ },
56
+ classNames: {
57
+ "au-toast": true$,
58
+ toast: true$
59
+ }
60
+ }));
61
+ const closeButtonDirective = createAttributesDirective(() => ({
62
+ attributes: {
63
+ type: readable("button"),
64
+ "aria-label": computed(() => extendedAlert.stores.ariaCloseButtonLabel$())
65
+ },
66
+ events: {
67
+ click: extendedAlert.api.close
68
+ }
69
+ }));
70
+ return {
71
+ ...extendedAlert,
72
+ directives: {
73
+ ...extendedAlert.directives,
74
+ autoHideDirective: directiveSubscribe(time$),
75
+ bodyDirective,
76
+ closeButtonDirective
77
+ }
78
+ };
79
+ }
80
+ const defaultToasterProps = {
81
+ duration: 5e3,
82
+ position: "bottomRight",
83
+ dismissible: false
84
+ };
85
+ class Toaster {
86
+ constructor(props) {
87
+ __privateAdd(this, _idCount, 0);
88
+ __privateAdd(this, _toasts, writable([]));
89
+ /**
90
+ * Get the toasts value from the store
91
+ * @returns The array of toasts.
92
+ */
93
+ __publicField(this, "toasts", computed(
94
+ () => __privateGet(this, _toasts).call(this).sort((a, b) => b.id - a.id).slice(0, this.options().limit)
95
+ ));
96
+ __publicField(this, "options", writable(defaultToasterProps));
97
+ __privateAdd(this, _timers, /* @__PURE__ */ new Map());
98
+ /**
99
+ * Add timer for a toast
100
+ * @param id Id of the toast
101
+ * @param duration Duration of the timer, by default taken from options
102
+ */
103
+ __publicField(this, "addTimer", (id, duration = this.options().duration) => {
104
+ if (duration > 0) {
105
+ __privateGet(this, _timers).set(id, {
106
+ timeout: setTimeout(() => this.removeToast(id), duration),
107
+ started: performance.now(),
108
+ duration
109
+ });
110
+ }
111
+ });
112
+ /**
113
+ * Pause a timer for a toast
114
+ * @param id Id of the toast
115
+ */
116
+ __publicField(this, "pauseTimer", (id) => {
117
+ if (__privateGet(this, _timers).has(id)) {
118
+ const timer = __privateGet(this, _timers).get(id);
119
+ if (timer && timer.timeout) {
120
+ clearTimeout(timer.timeout);
121
+ timer.timeout = null;
122
+ timer.paused = performance.now();
123
+ }
124
+ }
125
+ });
126
+ /**
127
+ * Resume a timer for a toast
128
+ * @param id Id of the toast
129
+ */
130
+ __publicField(this, "resumeTimer", (id) => {
131
+ if (__privateGet(this, _timers).has(id)) {
132
+ const timer = __privateGet(this, _timers).get(id);
133
+ if (timer) {
134
+ const paused = timer.paused ?? timer.started;
135
+ const elapsed = paused - timer.started;
136
+ const remaining = (timer.duration ?? 0) - elapsed;
137
+ this.addTimer(id, remaining);
138
+ timer.duration = remaining;
139
+ timer.paused = void 0;
140
+ }
141
+ }
142
+ });
143
+ /**
144
+ * Events directive is used to set events on the Toast component, to keep track for example of pointer enter/leave,
145
+ * used to pause / resume the timer in case of duration and pauseOnHover are specified.
146
+ */
147
+ __publicField(this, "eventsDirective", createAttributesDirective((id) => ({
148
+ events: {
149
+ pointerenter: () => this.options().pauseOnHover && this.pauseTimer(id()),
150
+ pointerleave: () => this.options().pauseOnHover && this.resumeTimer(id())
151
+ }
152
+ })));
153
+ /**
154
+ * Helper to add a toast to the viewport.
155
+ * @param props Options for the toast.
156
+ * @returns The ID of the added toast.
157
+ */
158
+ __publicField(this, "addToast", (props) => {
159
+ const autoHide = props.autoHide ?? this.options().duration > 0;
160
+ __privateGet(this, _toasts).update((toasts) => [...toasts, { id: __privateWrapper(this, _idCount)._++, props }]);
161
+ if (autoHide) {
162
+ this.addTimer(__privateGet(this, _idCount) - 1, props.delay);
163
+ }
164
+ return __privateGet(this, _idCount) - 1;
165
+ });
166
+ /**
167
+ * Helper to remove a toast to the viewport.
168
+ * @param id Id of the toast to remove.
169
+ */
170
+ __publicField(this, "removeToast", (id) => {
171
+ __privateGet(this, _timers).delete(id);
172
+ __privateGet(this, _toasts).update((toasts) => toasts.filter((toast) => toast.id !== id));
173
+ });
174
+ /** Helper to update toasts when options change */
175
+ __publicField(this, "updateToasts", () => {
176
+ if (this.options().duration === 0) {
177
+ this.options().dismissible = true;
178
+ }
179
+ });
180
+ /** Helper to close all toasts at once */
181
+ __publicField(this, "closeAll", () => {
182
+ __privateGet(this, _toasts).set([]);
183
+ __privateGet(this, _timers).clear();
184
+ });
185
+ this.options.set({
186
+ ...defaultToasterProps,
187
+ ...props
188
+ });
189
+ this.options.subscribe(() => {
190
+ this.updateToasts();
191
+ });
192
+ }
193
+ /**
194
+ * Get the timers value from the store
195
+ * @returns The map of timers.
196
+ */
197
+ get timers() {
198
+ return new Map(__privateGet(this, _timers));
199
+ }
200
+ }
201
+ _idCount = new WeakMap();
202
+ _toasts = new WeakMap();
203
+ _timers = new WeakMap();
204
+ export {
205
+ Toaster as T,
206
+ createToast as c,
207
+ defaultToasterProps as d,
208
+ getToastDefaultConfig as g
209
+ };
@@ -3,7 +3,7 @@ import { createNavManager } from "./services/navManager.js";
3
3
  import { k as mergeDirectives, n as createAttributesDirective, b as browserDirective, a as bindDirective } from "./dom-gfxqXJpK.js";
4
4
  import { noop } from "./utils/func.js";
5
5
  import { writablesForProps, stateStores, true$ } from "./utils/stores.js";
6
- import { f as typeFunction, h as typeArray, e as typeString } from "./writables-DCiBdIBK.js";
6
+ import { g as typeFunction, i as typeArray, e as typeString } from "./writables-CgpOQ4hA.js";
7
7
  function getTreeDefaultConfig() {
8
8
  return {
9
9
  ...defaultTreeConfig
@@ -4,7 +4,7 @@ const services_navManager = require("./services/navManager.cjs");
4
4
  const utils_directive = require("./dom-CuBx1JPZ.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-BPAJvaL_.cjs");
7
+ const utils_writables = require("./writables-Bn3uhKEG.cjs");
8
8
  function getTreeDefaultConfig() {
9
9
  return {
10
10
  ...defaultTreeConfig
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const utils_writables = require("../writables-BPAJvaL_.cjs");
3
+ const utils_writables = require("../writables-Bn3uhKEG.cjs");
4
4
  require("../types.cjs");
5
5
  exports.createTypeEnum = utils_writables.createTypeEnum;
6
6
  exports.testToNormalizeValue = utils_writables.testToNormalizeValue;
@@ -12,3 +12,4 @@ exports.typeHTMLElementOrNull = utils_writables.typeHTMLElementOrNull;
12
12
  exports.typeNumber = utils_writables.typeNumber;
13
13
  exports.typeNumberInRangeFactory = utils_writables.typeNumberInRangeFactory;
14
14
  exports.typeString = utils_writables.typeString;
15
+ exports.typeStringOrNull = utils_writables.typeStringOrNull;
@@ -56,6 +56,13 @@ export declare const typeBooleanOrNull: WritableWithDefaultOptions<boolean | nul
56
56
  * with the `isString` validator.
57
57
  */
58
58
  export declare const typeString: WritableWithDefaultOptions<string>;
59
+ /**
60
+ * A writable with default options that normalizes its value to a string or null.
61
+ *
62
+ * This object provides a normalized value for strings using the `testToNormalizeValue` function
63
+ * with the `isString` validator.
64
+ */
65
+ export declare const typeStringOrNull: WritableWithDefaultOptions<string | null>;
59
66
  /**
60
67
  * A writable object that holds a function type with default options.
61
68
  */
@@ -1,14 +1,15 @@
1
- import { i, t, h, c, d, f, g, a, b, e } from "../writables-DCiBdIBK.js";
1
+ import { j, t, i, c, d, g, h, a, b, e, f } from "../writables-CgpOQ4hA.js";
2
2
  import "../types.js";
3
3
  export {
4
- i as createTypeEnum,
4
+ j as createTypeEnum,
5
5
  t as testToNormalizeValue,
6
- h as typeArray,
6
+ i as typeArray,
7
7
  c as typeBoolean,
8
8
  d as typeBooleanOrNull,
9
- f as typeFunction,
10
- g as typeHTMLElementOrNull,
9
+ g as typeFunction,
10
+ h as typeHTMLElementOrNull,
11
11
  a as typeNumber,
12
12
  b as typeNumberInRangeFactory,
13
- e as typeString
13
+ e as typeString,
14
+ f as typeStringOrNull
14
15
  };
@@ -54,6 +54,9 @@ const typeBooleanOrNull = {
54
54
  const typeString = {
55
55
  normalizeValue: testToNormalizeValue(isString)
56
56
  };
57
+ const typeStringOrNull = {
58
+ normalizeValue: testToNormalizeValue(allowNull(isString))
59
+ };
57
60
  const typeFunction = {
58
61
  normalizeValue: testToNormalizeValue(isFunction),
59
62
  equal: Object.is
@@ -92,3 +95,4 @@ exports.typeHTMLElementOrNull = typeHTMLElementOrNull;
92
95
  exports.typeNumber = typeNumber;
93
96
  exports.typeNumberInRangeFactory = typeNumberInRangeFactory;
94
97
  exports.typeString = typeString;
98
+ exports.typeStringOrNull = typeStringOrNull;
@@ -53,6 +53,9 @@ const typeBooleanOrNull = {
53
53
  const typeString = {
54
54
  normalizeValue: testToNormalizeValue(isString)
55
55
  };
56
+ const typeStringOrNull = {
57
+ normalizeValue: testToNormalizeValue(allowNull(isString))
58
+ };
56
59
  const typeFunction = {
57
60
  normalizeValue: testToNormalizeValue(isFunction),
58
61
  equal: Object.is
@@ -85,11 +88,12 @@ export {
85
88
  typeBoolean as c,
86
89
  typeBooleanOrNull as d,
87
90
  typeString as e,
88
- typeFunction as f,
89
- typeHTMLElementOrNull as g,
90
- typeArray as h,
91
- createTypeEnum as i,
92
- clamp as j,
93
- isNumber as k,
91
+ typeStringOrNull as f,
92
+ typeFunction as g,
93
+ typeHTMLElementOrNull as h,
94
+ typeArray as i,
95
+ createTypeEnum as j,
96
+ clamp as k,
97
+ isNumber as l,
94
98
  testToNormalizeValue as t
95
99
  };
package/toast-4HGIz3Bu.js DELETED
@@ -1,64 +0,0 @@
1
- import { computed, readable } from "@amadeus-it-group/tansu";
2
- import { extendWidgetProps } from "./services/extendWidget.js";
3
- import { n as createAttributesDirective, d as directiveSubscribe } from "./dom-gfxqXJpK.js";
4
- import { true$ } from "./utils/stores.js";
5
- import { b as typeNumberInRangeFactory, c as typeBoolean } from "./writables-DCiBdIBK.js";
6
- import { g as getCommonAlertDefaultConfig, c as createCommonAlert } from "./common-Bffx1jJO.js";
7
- const toastDefaultConfig = {
8
- autoHide: true,
9
- delay: 5e3
10
- };
11
- const toastConfigValidator = {
12
- autoHide: typeBoolean,
13
- delay: typeNumberInRangeFactory(0, Infinity, { strict: true })
14
- };
15
- function getToastDefaultConfig() {
16
- return { ...getCommonAlertDefaultConfig(), ...toastDefaultConfig };
17
- }
18
- function createToast(config) {
19
- let _timeout;
20
- const extendedAlert = extendWidgetProps(
21
- createCommonAlert,
22
- toastDefaultConfig,
23
- toastConfigValidator
24
- )(config);
25
- const time$ = computed(() => {
26
- clearTimeout(_timeout);
27
- if (extendedAlert.stores.autoHide$()) {
28
- _timeout = setTimeout(() => extendedAlert.api.close(), extendedAlert.stores.delay$());
29
- }
30
- });
31
- const bodyDirective = createAttributesDirective(() => ({
32
- attributes: {
33
- role: readable("alert"),
34
- "aria-atomic": readable("true"),
35
- class: computed(() => extendedAlert.stores.className$())
36
- },
37
- classNames: {
38
- "au-toast": true$,
39
- toast: true$
40
- }
41
- }));
42
- const closeButtonDirective = createAttributesDirective(() => ({
43
- attributes: {
44
- type: readable("button"),
45
- "aria-label": computed(() => extendedAlert.stores.ariaCloseButtonLabel$())
46
- },
47
- events: {
48
- click: extendedAlert.api.close
49
- }
50
- }));
51
- return {
52
- ...extendedAlert,
53
- directives: {
54
- ...extendedAlert.directives,
55
- autoHideDirective: directiveSubscribe(time$),
56
- bodyDirective,
57
- closeButtonDirective
58
- }
59
- };
60
- }
61
- export {
62
- createToast as c,
63
- getToastDefaultConfig as g
64
- };
@@ -1,63 +0,0 @@
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-CuBx1JPZ.cjs");
5
- const utils_stores = require("./utils/stores.cjs");
6
- const utils_writables = require("./writables-BPAJvaL_.cjs");
7
- const common = require("./common-CcQOJ_hf.cjs");
8
- const toastDefaultConfig = {
9
- autoHide: true,
10
- delay: 5e3
11
- };
12
- const toastConfigValidator = {
13
- autoHide: utils_writables.typeBoolean,
14
- delay: utils_writables.typeNumberInRangeFactory(0, Infinity, { strict: true })
15
- };
16
- function getToastDefaultConfig() {
17
- return { ...common.getCommonAlertDefaultConfig(), ...toastDefaultConfig };
18
- }
19
- function createToast(config) {
20
- let _timeout;
21
- const extendedAlert = services_extendWidget.extendWidgetProps(
22
- common.createCommonAlert,
23
- toastDefaultConfig,
24
- toastConfigValidator
25
- )(config);
26
- const time$ = tansu.computed(() => {
27
- clearTimeout(_timeout);
28
- if (extendedAlert.stores.autoHide$()) {
29
- _timeout = setTimeout(() => extendedAlert.api.close(), extendedAlert.stores.delay$());
30
- }
31
- });
32
- const bodyDirective = utils_directive.createAttributesDirective(() => ({
33
- attributes: {
34
- role: tansu.readable("alert"),
35
- "aria-atomic": tansu.readable("true"),
36
- class: tansu.computed(() => extendedAlert.stores.className$())
37
- },
38
- classNames: {
39
- "au-toast": utils_stores.true$,
40
- toast: utils_stores.true$
41
- }
42
- }));
43
- const closeButtonDirective = utils_directive.createAttributesDirective(() => ({
44
- attributes: {
45
- type: tansu.readable("button"),
46
- "aria-label": tansu.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: utils_directive.directiveSubscribe(time$),
57
- bodyDirective,
58
- closeButtonDirective
59
- }
60
- };
61
- }
62
- exports.createToast = createToast;
63
- exports.getToastDefaultConfig = getToastDefaultConfig;