@agnos-ui/core 0.9.3 → 0.10.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/{accordion-cR5JqWJ8.cjs → accordion-B5LiN1uy.cjs} +15 -20
  2. package/{accordion-CoM4efp-.js → accordion-_zen-g8l.js} +15 -20
  3. package/{alert-DtDozJal.cjs → alert-B-jQDQcB.cjs} +1 -1
  4. package/{alert-YIlqdEPO.js → alert-gGz2CDS9.js} +1 -1
  5. package/{collapse-DwXz2kNw.js → collapse-BV4kD3j9.js} +2 -2
  6. package/{collapse-DRp53EuG.cjs → collapse-gLiT080Y.cjs} +2 -2
  7. package/{common-BToNPUDq.cjs → common-D3QcdJ6S.cjs} +1 -1
  8. package/{common-BqUjUBPy.js → common-DK0ADNTX.js} +1 -1
  9. package/components/accordion/accordion.d.ts +6 -6
  10. package/components/accordion/index.cjs +1 -1
  11. package/components/accordion/index.js +1 -1
  12. package/components/alert/index.cjs +1 -1
  13. package/components/alert/index.js +1 -1
  14. package/components/carousel/carousel.d.ts +15 -0
  15. package/components/carousel/index.cjs +10 -23
  16. package/components/carousel/index.js +10 -23
  17. package/components/collapse/collapse.d.ts +5 -2
  18. package/components/collapse/index.cjs +1 -1
  19. package/components/collapse/index.js +1 -1
  20. package/components/drawer/drawer.d.ts +242 -0
  21. package/components/drawer/index.cjs +5 -0
  22. package/components/drawer/index.d.ts +1 -0
  23. package/components/drawer/index.js +5 -0
  24. package/components/modal/index.cjs +2 -1
  25. package/components/modal/index.js +2 -1
  26. package/components/modal/modal.d.ts +5 -0
  27. package/components/pagination/index.cjs +1 -1
  28. package/components/pagination/index.js +1 -1
  29. package/components/progressbar/index.cjs +1 -1
  30. package/components/progressbar/index.js +1 -1
  31. package/components/rating/index.cjs +1 -1
  32. package/components/rating/index.js +1 -1
  33. package/components/select/index.cjs +1 -1
  34. package/components/select/index.js +1 -1
  35. package/components/slider/index.cjs +1 -1
  36. package/components/slider/index.js +1 -1
  37. package/components/slider/slider.d.ts +4 -4
  38. package/components/toast/index.cjs +1 -1
  39. package/components/toast/index.js +1 -1
  40. package/components/tree/index.cjs +1 -1
  41. package/components/tree/index.js +1 -1
  42. package/components/tree/tree.d.ts +0 -6
  43. package/config.cjs +2 -2
  44. package/config.d.ts +5 -0
  45. package/config.js +2 -2
  46. package/{dom-gfxqXJpK.js → dom-Bcg9ORcA.js} +64 -54
  47. package/{dom-CuBx1JPZ.cjs → dom-C2gi9OCP.cjs} +47 -37
  48. package/drawer-D5SO73ew.js +251 -0
  49. package/drawer-DP7UPojk.cjs +250 -0
  50. package/index.cjs +19 -13
  51. package/index.d.ts +1 -0
  52. package/index.js +36 -30
  53. package/isFocusable-Ckwus82R.js +32 -0
  54. package/isFocusable-DfzDLeAN.cjs +31 -0
  55. package/{modal-D3wGIDlj.js → modal-CAvQW-vo.js} +26 -32
  56. package/{modal-BEnQ6c5M.cjs → modal-DiXZXYjR.cjs} +27 -33
  57. package/package.json +1 -1
  58. package/{pagination-B97wBLok.js → pagination-BKbMROV6.js} +4 -4
  59. package/{pagination-C1TT-oea.cjs → pagination-DvZ2rLsz.cjs} +4 -4
  60. package/{progressbar-BWBlRk_Y.js → progressbar-D8zIcm9n.js} +2 -2
  61. package/{progressbar-CRvhNB5R.cjs → progressbar-i9xfAxb7.cjs} +2 -2
  62. package/{promise-XSP94FjG.js → promise-Y53vc4Ia.js} +5 -5
  63. package/{rating-BXvy9kXq.js → rating-DEXTGWCU.js} +2 -2
  64. package/{rating-DAb6nR67.cjs → rating-DmG4oUkr.cjs} +2 -2
  65. package/scrollbars-CT87iv_6.cjs +30 -0
  66. package/scrollbars-CcxSrnCx.js +31 -0
  67. package/{select-BdjpnE7_.js → select-Bw68Xdu5.js} +4 -5
  68. package/{select-C0rJJQfl.cjs → select-MFjAnIt7.cjs} +4 -5
  69. package/services/extendWidget.cjs +2 -2
  70. package/services/extendWidget.js +2 -2
  71. package/services/floatingUI.cjs +8 -29
  72. package/services/floatingUI.js +9 -30
  73. package/services/focusElement.cjs +46 -0
  74. package/services/focusElement.d.ts +9 -0
  75. package/services/focusElement.js +46 -0
  76. package/services/focustrack.cjs +1 -1
  77. package/services/focustrack.js +1 -1
  78. package/services/matchMedia.cjs +1 -1
  79. package/services/matchMedia.js +1 -1
  80. package/services/navManager.cjs +7 -37
  81. package/services/navManager.js +6 -36
  82. package/services/portal.cjs +7 -10
  83. package/services/portal.js +7 -10
  84. package/services/resizeObserver.cjs +2 -2
  85. package/services/resizeObserver.js +2 -2
  86. package/services/siblingsInert.cjs +9 -8
  87. package/services/siblingsInert.d.ts +13 -3
  88. package/services/siblingsInert.js +9 -8
  89. package/services/transitions/baseTransitions.cjs +9 -10
  90. package/services/transitions/baseTransitions.js +10 -11
  91. package/services/transitions/collapse.cjs +1 -1
  92. package/services/transitions/collapse.js +1 -1
  93. package/services/transitions/cssTransitions.cjs +1 -1
  94. package/services/transitions/cssTransitions.js +2 -2
  95. package/services/transitions/simpleClassTransition.cjs +1 -1
  96. package/services/transitions/simpleClassTransition.js +1 -1
  97. package/{slider-BmxQ3A_u.js → slider-Cx50Eghd.js} +14 -24
  98. package/{slider-DSx5CAce.cjs → slider-Dl4Trh32.cjs} +14 -24
  99. package/toaster-UDglac7x.cjs +187 -0
  100. package/toaster-_p1GTtHI.js +188 -0
  101. package/{tree-BFrXdJox.js → tree-DV0tfPlZ.js} +7 -11
  102. package/{tree-Pvr2rZ-D.cjs → tree-rGHtmCnS.cjs} +7 -11
  103. package/utils/directive.cjs +3 -1
  104. package/utils/directive.d.ts +47 -0
  105. package/utils/directive.js +14 -12
  106. package/utils/stores.cjs +8 -9
  107. package/utils/stores.js +8 -9
  108. package/utils/writables.cjs +1 -1
  109. package/utils/writables.js +1 -1
  110. package/{writables-Bn3uhKEG.cjs → writables-DcGT98a7.cjs} +1 -1
  111. package/{writables-CgpOQ4hA.js → writables-e0tyaQpe.js} +1 -1
  112. package/toaster-Cayg6Lbq.cjs +0 -209
  113. package/toaster-XfzHDqz_.js +0 -210
@@ -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 { k as mergeDirectives, n as createAttributesDirective, b as browserDirective, a as bindDirective } from "./dom-gfxqXJpK.js";
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-CgpOQ4hA.js";
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: ((_a = node.children) == null ? void 0 : _a.length) ? node.isExpanded ?? false : void 0
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 = (_a = getTreeItemInfo(itemToFocus)) == null ? void 0 : _a.htmlElement;
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((_a = getTreeItemInfo(item)) == null ? void 0 : _a.parent);
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((_b = item.children) == null ? void 0 : _b[0]);
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 (_a = item.isExpanded) == null ? void 0 : _a.toString();
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-CuBx1JPZ.cjs");
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-Bn3uhKEG.cjs");
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: ((_a = node.children) == null ? void 0 : _a.length) ? node.isExpanded ?? false : void 0
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 = (_a = getTreeItemInfo(itemToFocus)) == null ? void 0 : _a.htmlElement;
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((_a = getTreeItemInfo(item)) == null ? void 0 : _a.parent);
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((_b = item.children) == null ? void 0 : _b[0]);
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 (_a = item.isExpanded) == null ? void 0 : _a.toString();
213
+ return item.isExpanded?.toString();
218
214
  })
219
215
  }
220
216
  }))
@@ -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-CuBx1JPZ.cjs");
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;
@@ -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.
@@ -1,25 +1,27 @@
1
1
  import "@amadeus-it-group/tansu";
2
2
  import "esm-env";
3
- import { o, a, c, b, p, n, g, j, f, h, q, d, e, i, m, k, l, r, s } from "../dom-gfxqXJpK.js";
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
- o as attributesData,
6
+ q as attributesData,
7
7
  a as bindDirective,
8
8
  c as bindDirectiveNoArg,
9
9
  b as browserDirective,
10
- p as classDirective,
11
- n as createAttributesDirective,
12
- g as createBrowserStoreArrayDirective,
13
- j as createBrowserStoreDirective,
14
- f as createStoreArrayDirective,
15
- h as createStoreDirective,
16
- q as directiveAttributes,
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
- k as mergeDirectives,
22
- l as multiDirective,
23
+ n as mergeDirectives,
24
+ o as multiDirective,
23
25
  r as registrationArray,
24
- s as ssrAttributes
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-CuBx1JPZ.cjs");
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
- (_a = stores[`${name}$`]) == null ? void 0 : _a.set(value);
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 == null ? void 0 : config1[key];
78
- const config2Store = config2 == null ? void 0 : config2[key];
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 == null ? void 0 : propsConfig.config);
87
- const props = propsConfig == null ? void 0 : propsConfig.props;
85
+ const configStores = normalizeConfigStores(keys, propsConfig?.config);
86
+ const props = propsConfig?.props;
88
87
  for (const key of keys) {
89
- const propValue = props == null ? void 0 : props[key];
90
- res[`${key}$`] = writableWithDefault(defConfig[key], configStores[key], options == null ? void 0 : options[key], toWritableStore(propValue));
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
  };
package/utils/stores.js CHANGED
@@ -1,13 +1,12 @@
1
1
  import { readable, writable, asWritable, equal, batch, computed, asReadable, get, derived } from "@amadeus-it-group/tansu";
2
2
  import { INVALID_VALUE } from "../types.js";
3
3
  import { identity } from "./func.js";
4
- import { t as generateId } from "../dom-gfxqXJpK.js";
4
+ import { v as generateId } from "../dom-Bcg9ORcA.js";
5
5
  function createPatch(stores) {
6
6
  return function(storesValues) {
7
7
  batch(() => {
8
- var _a;
9
8
  for (const [name, value] of Object.entries(storesValues)) {
10
- (_a = stores[`${name}$`]) == null ? void 0 : _a.set(value);
9
+ stores[`${name}$`]?.set(value);
11
10
  }
12
11
  });
13
12
  };
@@ -72,8 +71,8 @@ const normalizeConfigStores = (keys, config) => {
72
71
  const mergeConfigStores = (keys, config1, config2) => {
73
72
  const res = {};
74
73
  for (const key of keys) {
75
- const config1Store = config1 == null ? void 0 : config1[key];
76
- const config2Store = config2 == null ? void 0 : config2[key];
74
+ const config1Store = config1?.[key];
75
+ const config2Store = config2?.[key];
77
76
  res[key] = config1Store && config2Store ? computed(() => config1Store() ?? config2Store()) : config1Store || config2Store;
78
77
  }
79
78
  return res;
@@ -81,11 +80,11 @@ const mergeConfigStores = (keys, config1, config2) => {
81
80
  const writablesWithDefault = (defConfig, propsConfig, options) => {
82
81
  const res = {};
83
82
  const keys = Object.keys(defConfig);
84
- const configStores = normalizeConfigStores(keys, propsConfig == null ? void 0 : propsConfig.config);
85
- const props = propsConfig == null ? void 0 : propsConfig.props;
83
+ const configStores = normalizeConfigStores(keys, propsConfig?.config);
84
+ const props = propsConfig?.props;
86
85
  for (const key of keys) {
87
- const propValue = props == null ? void 0 : props[key];
88
- res[`${key}$`] = writableWithDefault(defConfig[key], configStores[key], options == null ? void 0 : options[key], toWritableStore(propValue));
86
+ const propValue = props?.[key];
87
+ res[`${key}$`] = writableWithDefault(defConfig[key], configStores[key], options?.[key], toWritableStore(propValue));
89
88
  }
90
89
  return res;
91
90
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const utils_writables = require("../writables-Bn3uhKEG.cjs");
3
+ const utils_writables = require("../writables-DcGT98a7.cjs");
4
4
  require("../types.cjs");
5
5
  exports.createTypeEnum = utils_writables.createTypeEnum;
6
6
  exports.testToNormalizeValue = utils_writables.testToNormalizeValue;
@@ -1,4 +1,4 @@
1
- import { j, t, i, c, d, g, h, a, b, e, f } from "../writables-CgpOQ4hA.js";
1
+ import { j, t, i, c, d, g, h, a, b, e, f } from "../writables-e0tyaQpe.js";
2
2
  import "../types.js";
3
3
  export {
4
4
  j as createTypeEnum,
@@ -71,7 +71,7 @@ const typeArray = {
71
71
  if (a === b) {
72
72
  return true;
73
73
  } else {
74
- if ((a == null ? void 0 : a.length) !== (b == null ? void 0 : b.length)) {
74
+ if (a?.length !== b?.length) {
75
75
  return false;
76
76
  }
77
77
  return a.every((val, index) => val === b[index]);
@@ -70,7 +70,7 @@ const typeArray = {
70
70
  if (a === b) {
71
71
  return true;
72
72
  } else {
73
- if ((a == null ? void 0 : a.length) !== (b == null ? void 0 : b.length)) {
73
+ if (a?.length !== b?.length) {
74
74
  return false;
75
75
  }
76
76
  return a.every((val, index) => val === b[index]);
@@ -1,209 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __typeError = (msg) => {
4
- throw TypeError(msg);
5
- };
6
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
9
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
10
- 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);
11
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
12
- var __privateWrapper = (obj, member, setter, getter) => ({
13
- set _(value) {
14
- __privateSet(obj, member, value, setter);
15
- },
16
- get _() {
17
- return __privateGet(obj, member, getter);
18
- }
19
- });
20
- var _idCount, _toasts, _timers;
21
- const tansu = require("@amadeus-it-group/tansu");
22
- const services_extendWidget = require("./services/extendWidget.cjs");
23
- const utils_directive = require("./dom-CuBx1JPZ.cjs");
24
- const utils_stores = require("./utils/stores.cjs");
25
- const utils_writables = require("./writables-Bn3uhKEG.cjs");
26
- const common = require("./common-BToNPUDq.cjs");
27
- const utils_widget = require("./utils/widget.cjs");
28
- const toastDefaultConfig = {
29
- autoHide: true,
30
- delay: 5e3
31
- };
32
- const toastConfigValidator = {
33
- autoHide: utils_writables.typeBoolean,
34
- delay: utils_writables.typeNumberInRangeFactory(0, Infinity, { strict: true })
35
- };
36
- function getToastDefaultConfig() {
37
- return { ...common.getCommonAlertDefaultConfig(), ...toastDefaultConfig };
38
- }
39
- const createToast = utils_widget.createWidgetFactory("toast", (config) => {
40
- let _timeout;
41
- const extendedAlert = services_extendWidget.extendWidgetProps(
42
- common.createCommonAlert,
43
- toastDefaultConfig,
44
- toastConfigValidator
45
- )(config);
46
- const time$ = tansu.computed(() => {
47
- clearTimeout(_timeout);
48
- if (extendedAlert.stores.autoHide$()) {
49
- _timeout = setTimeout(() => extendedAlert.api.close(), extendedAlert.stores.delay$());
50
- }
51
- });
52
- const bodyDirective = utils_directive.createAttributesDirective(() => ({
53
- attributes: {
54
- role: tansu.readable("alert"),
55
- "aria-atomic": tansu.readable("true"),
56
- class: tansu.computed(() => extendedAlert.stores.className$())
57
- },
58
- classNames: {
59
- "au-toast": utils_stores.true$,
60
- toast: utils_stores.true$
61
- }
62
- }));
63
- const closeButtonDirective = utils_directive.createAttributesDirective(() => ({
64
- attributes: {
65
- type: tansu.readable("button"),
66
- "aria-label": tansu.computed(() => extendedAlert.stores.ariaCloseButtonLabel$())
67
- },
68
- events: {
69
- click: extendedAlert.api.close
70
- }
71
- }));
72
- return {
73
- ...extendedAlert,
74
- directives: {
75
- ...extendedAlert.directives,
76
- autoHideDirective: utils_directive.directiveSubscribe(time$),
77
- bodyDirective,
78
- closeButtonDirective
79
- }
80
- };
81
- });
82
- const defaultToasterProps = {
83
- duration: 5e3,
84
- position: "bottomRight",
85
- dismissible: false
86
- };
87
- class Toaster {
88
- constructor(props) {
89
- __privateAdd(this, _idCount, 0);
90
- __privateAdd(this, _toasts, tansu.writable([]));
91
- /**
92
- * Get the toasts value from the store
93
- * @returns The array of toasts.
94
- */
95
- __publicField(this, "toasts", tansu.computed(
96
- () => __privateGet(this, _toasts).call(this).sort((a, b) => b.id - a.id).slice(0, this.options().limit)
97
- ));
98
- __publicField(this, "options", tansu.writable(defaultToasterProps));
99
- __privateAdd(this, _timers, /* @__PURE__ */ new Map());
100
- /**
101
- * Add timer for a toast
102
- * @param id Id of the toast
103
- * @param duration Duration of the timer, by default taken from options
104
- */
105
- __publicField(this, "addTimer", (id, duration = this.options().duration) => {
106
- if (duration > 0) {
107
- __privateGet(this, _timers).set(id, {
108
- timeout: setTimeout(() => this.removeToast(id), duration),
109
- started: performance.now(),
110
- duration
111
- });
112
- }
113
- });
114
- /**
115
- * Pause a timer for a toast
116
- * @param id Id of the toast
117
- */
118
- __publicField(this, "pauseTimer", (id) => {
119
- if (__privateGet(this, _timers).has(id)) {
120
- const timer = __privateGet(this, _timers).get(id);
121
- if (timer && timer.timeout) {
122
- clearTimeout(timer.timeout);
123
- timer.timeout = null;
124
- timer.paused = performance.now();
125
- }
126
- }
127
- });
128
- /**
129
- * Resume a timer for a toast
130
- * @param id Id of the toast
131
- */
132
- __publicField(this, "resumeTimer", (id) => {
133
- if (__privateGet(this, _timers).has(id)) {
134
- const timer = __privateGet(this, _timers).get(id);
135
- if (timer) {
136
- const paused = timer.paused ?? timer.started;
137
- const elapsed = paused - timer.started;
138
- const remaining = (timer.duration ?? 0) - elapsed;
139
- this.addTimer(id, remaining);
140
- timer.duration = remaining;
141
- timer.paused = void 0;
142
- }
143
- }
144
- });
145
- /**
146
- * Events directive is used to set events on the Toast component, to keep track for example of pointer enter/leave,
147
- * used to pause / resume the timer in case of duration and pauseOnHover are specified.
148
- */
149
- __publicField(this, "eventsDirective", utils_directive.createAttributesDirective((id) => ({
150
- events: {
151
- pointerenter: () => this.options().pauseOnHover && this.pauseTimer(id()),
152
- pointerleave: () => this.options().pauseOnHover && this.resumeTimer(id())
153
- }
154
- })));
155
- /**
156
- * Helper to add a toast to the viewport.
157
- * @param props Options for the toast.
158
- * @returns The ID of the added toast.
159
- */
160
- __publicField(this, "addToast", (props) => {
161
- const autoHide = props.autoHide ?? this.options().duration > 0;
162
- __privateGet(this, _toasts).update((toasts) => [...toasts, { id: __privateWrapper(this, _idCount)._++, props }]);
163
- if (autoHide) {
164
- this.addTimer(__privateGet(this, _idCount) - 1, props.delay);
165
- }
166
- return __privateGet(this, _idCount) - 1;
167
- });
168
- /**
169
- * Helper to remove a toast to the viewport.
170
- * @param id Id of the toast to remove.
171
- */
172
- __publicField(this, "removeToast", (id) => {
173
- __privateGet(this, _timers).delete(id);
174
- __privateGet(this, _toasts).update((toasts) => toasts.filter((toast) => toast.id !== id));
175
- });
176
- /** Helper to update toasts when options change */
177
- __publicField(this, "updateToasts", () => {
178
- if (this.options().duration === 0) {
179
- this.options().dismissible = true;
180
- }
181
- });
182
- /** Helper to close all toasts at once */
183
- __publicField(this, "closeAll", () => {
184
- __privateGet(this, _toasts).set([]);
185
- __privateGet(this, _timers).clear();
186
- });
187
- this.options.set({
188
- ...defaultToasterProps,
189
- ...props
190
- });
191
- this.options.subscribe(() => {
192
- this.updateToasts();
193
- });
194
- }
195
- /**
196
- * Get the timers value from the store
197
- * @returns The map of timers.
198
- */
199
- get timers() {
200
- return new Map(__privateGet(this, _timers));
201
- }
202
- }
203
- _idCount = new WeakMap();
204
- _toasts = new WeakMap();
205
- _timers = new WeakMap();
206
- exports.Toaster = Toaster;
207
- exports.createToast = createToast;
208
- exports.defaultToasterProps = defaultToasterProps;
209
- exports.getToastDefaultConfig = getToastDefaultConfig;