@agnos-ui/core 0.3.1 → 0.4.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 (79) hide show
  1. package/accordion-BnaSamoQ.js +322 -0
  2. package/accordion-DmPT0O0j.cjs +321 -0
  3. package/{alert-Dlf-BV98.js → alert-8ilqhLst.js} +1 -1
  4. package/{alert-C4jCg9Pl.cjs → alert-C-V64Qcs.cjs} +1 -1
  5. package/{common-DRdsw5m8.js → common-BCEqowKw.js} +1 -1
  6. package/{common-nJRMXbwj.cjs → common-Kb96q7i4.cjs} +1 -1
  7. package/components/accordion/accordion.d.ts +33 -86
  8. package/components/accordion/index.cjs +1 -1
  9. package/components/accordion/index.js +1 -1
  10. package/components/alert/common.d.ts +1 -1
  11. package/components/alert/index.cjs +2 -2
  12. package/components/alert/index.js +2 -2
  13. package/components/modal/index.cjs +1 -1
  14. package/components/modal/index.js +1 -1
  15. package/components/modal/modal.d.ts +11 -15
  16. package/components/pagination/index.cjs +1 -1
  17. package/components/pagination/index.js +1 -1
  18. package/components/progressbar/index.cjs +1 -1
  19. package/components/progressbar/index.js +1 -1
  20. package/components/rating/index.cjs +1 -1
  21. package/components/rating/index.js +1 -1
  22. package/components/select/index.cjs +1 -1
  23. package/components/select/index.js +1 -1
  24. package/components/select/select.d.ts +4 -5
  25. package/components/slider/index.cjs +1 -1
  26. package/components/slider/index.js +1 -1
  27. package/components/toast/index.cjs +1 -1
  28. package/components/toast/index.js +1 -1
  29. package/components/toast/toast.d.ts +3 -4
  30. package/config.cjs +2 -4
  31. package/config.d.ts +3 -3
  32. package/config.js +2 -4
  33. package/{directive-DCYlDznf.js → directive-3-8yr-ZK.js} +1 -2
  34. package/{directive-BTSEYLF3.cjs → directive-j-xRk-h3.cjs} +1 -2
  35. package/index.cjs +11 -11
  36. package/index.js +11 -11
  37. package/{modal-BI2qUu1M.js → modal-CeTI4jxI.js} +19 -4
  38. package/{modal-rzMpATf5.cjs → modal-D4d8sy85.cjs} +19 -4
  39. package/package.json +4 -4
  40. package/{pagination-EWSWQT1I.cjs → pagination-B9WFv70F.cjs} +1 -1
  41. package/{pagination--GkwduJn.js → pagination-BpPHKQsH.js} +1 -1
  42. package/{progressbar-DuRX7_my.js → progressbar-BybOg5FE.js} +1 -1
  43. package/{progressbar-DH7DHYMp.cjs → progressbar-DXCMeJvL.cjs} +1 -1
  44. package/{rating-CmuYUSxy.cjs → rating-C2Y95r50.cjs} +1 -1
  45. package/{rating-BR5wD7y2.js → rating-D6Tv_4Vx.js} +1 -1
  46. package/{select-BCs6HQWn.js → select-BS0mh7Qk.js} +1 -1
  47. package/{select-CCIKn8WR.cjs → select-CBlGWfZY.cjs} +1 -1
  48. package/services/extendWidget.d.ts +3 -3
  49. package/services/floatingUI.cjs +1 -1
  50. package/services/floatingUI.js +1 -1
  51. package/services/focustrack.cjs +1 -1
  52. package/services/focustrack.js +1 -1
  53. package/services/matchMedia.cjs +1 -1
  54. package/services/matchMedia.js +1 -1
  55. package/services/navManager.cjs +1 -1
  56. package/services/navManager.js +1 -1
  57. package/services/portal.cjs +1 -1
  58. package/services/portal.js +1 -1
  59. package/services/resizeObserver.cjs +1 -1
  60. package/services/resizeObserver.js +1 -1
  61. package/services/siblingsInert.cjs +1 -1
  62. package/services/siblingsInert.js +1 -1
  63. package/services/transitions/baseTransitions.cjs +1 -1
  64. package/services/transitions/baseTransitions.js +1 -1
  65. package/services/transitions/collapse.cjs +1 -1
  66. package/services/transitions/collapse.js +1 -1
  67. package/services/transitions/cssTransitions.cjs +1 -1
  68. package/services/transitions/cssTransitions.js +1 -1
  69. package/services/transitions/simpleClassTransition.cjs +1 -1
  70. package/services/transitions/simpleClassTransition.js +1 -1
  71. package/{slider-DsLvT87U.cjs → slider-BdsZpxJr.cjs} +1 -1
  72. package/{slider-CA_fszn7.js → slider-ByDkbyr1.js} +1 -1
  73. package/{toast-8tWp6x89.js → toast-DN0HwUbs.js} +2 -2
  74. package/{toast-Aw8o0Iwe.cjs → toast-DR8b0zpm.cjs} +2 -2
  75. package/types.d.ts +2 -0
  76. package/utils/directive.cjs +1 -1
  77. package/utils/directive.js +1 -1
  78. package/accordion-BaWN0_n-.js +0 -330
  79. package/accordion-BuIgxZ0S.cjs +0 -329
@@ -0,0 +1,322 @@
1
+ import { writablesForProps, stateStores, mergeConfigStores, normalizeConfigStores } from "./utils/stores.js";
2
+ import { createTransition } from "./services/transitions/baseTransitions.js";
3
+ import { writable, computed, asWritable, readable } from "@amadeus-it-group/tansu";
4
+ import { n as noop } from "./func-DR0n-ShK.js";
5
+ import { c as typeBoolean, f as typeFunction, e as typeString } from "./writables-DoU_XYTX.js";
6
+ import { t as generateId, c as bindDirectiveNoArg, k as mergeDirectives, n as createAttributesDirective, r as registrationArray, d as directiveSubscribe } from "./directive-3-8yr-ZK.js";
7
+ function adjustItemsCloseOthers(items, openItems, oldOpen) {
8
+ let keepOpen;
9
+ if (openItems.length == 2) {
10
+ oldOpen = oldOpen ?? openItems[0];
11
+ keepOpen = openItems.find((id) => id !== oldOpen);
12
+ } else if (openItems.length > 2) {
13
+ keepOpen = openItems[0];
14
+ }
15
+ if (keepOpen) {
16
+ items.forEach((item) => {
17
+ if (item.stores.id$() !== keepOpen && item.stores.visible$()) {
18
+ item.patch({ visible: false });
19
+ }
20
+ });
21
+ }
22
+ return items;
23
+ }
24
+ function getItem(items, id) {
25
+ return items.find((item) => item.stores.id$() === id);
26
+ }
27
+ const defaultAccordionConfig = {
28
+ closeOthers: false,
29
+ onItemShown: noop,
30
+ onItemHidden: noop,
31
+ className: "",
32
+ itemDestroyOnHide: true,
33
+ itemAnimated: true,
34
+ itemTransition: async () => {
35
+ },
36
+ itemHeadingTag: "",
37
+ itemClassName: "",
38
+ itemHeaderClassName: "",
39
+ itemButtonClassName: "",
40
+ itemBodyContainerClassName: "",
41
+ itemBodyClassName: ""
42
+ };
43
+ const defaultItemConfig = {
44
+ id: "",
45
+ destroyOnHide: defaultAccordionConfig.itemDestroyOnHide,
46
+ disabled: false,
47
+ visible: false,
48
+ animated: defaultAccordionConfig.itemAnimated,
49
+ transition: defaultAccordionConfig.itemTransition,
50
+ onShown: noop,
51
+ onHidden: noop,
52
+ onVisibleChange: noop,
53
+ className: defaultAccordionConfig.itemClassName,
54
+ headerClassName: defaultAccordionConfig.itemHeaderClassName,
55
+ buttonClassName: defaultAccordionConfig.itemButtonClassName,
56
+ bodyContainerClassName: defaultAccordionConfig.itemBodyContainerClassName,
57
+ bodyClassName: defaultAccordionConfig.itemBodyClassName,
58
+ headingTag: defaultAccordionConfig.itemHeadingTag
59
+ };
60
+ const coreAccordionItemProps = Object.keys(defaultItemConfig);
61
+ function getAccordionDefaultConfig() {
62
+ return { ...defaultAccordionConfig };
63
+ }
64
+ const configAccordionValidator = {
65
+ closeOthers: typeBoolean,
66
+ onItemShown: typeFunction,
67
+ onItemHidden: typeFunction,
68
+ className: typeString,
69
+ itemDestroyOnHide: typeBoolean,
70
+ itemAnimated: typeBoolean,
71
+ itemTransition: typeFunction,
72
+ itemClassName: typeString,
73
+ itemHeaderClassName: typeString,
74
+ itemButtonClassName: typeString,
75
+ itemBodyContainerClassName: typeString,
76
+ itemBodyClassName: typeString,
77
+ itemHeadingTag: typeString
78
+ };
79
+ const configItemValidator = {
80
+ id: typeString,
81
+ destroyOnHide: typeBoolean,
82
+ disabled: typeBoolean,
83
+ visible: typeBoolean,
84
+ animated: typeBoolean,
85
+ transition: typeFunction,
86
+ onShown: typeFunction,
87
+ onHidden: typeFunction,
88
+ onVisibleChange: typeFunction,
89
+ className: typeString,
90
+ headerClassName: typeString,
91
+ buttonClassName: typeString,
92
+ bodyContainerClassName: typeString,
93
+ bodyClassName: typeString,
94
+ headingTag: typeString
95
+ };
96
+ function createAccordionItem(config) {
97
+ const [
98
+ {
99
+ bodyClassName$,
100
+ buttonClassName$,
101
+ bodyContainerClassName$,
102
+ headerClassName$,
103
+ animated$,
104
+ transition$,
105
+ destroyOnHide$,
106
+ onShown$,
107
+ onHidden$,
108
+ onVisibleChange$,
109
+ visible$,
110
+ id$: _dirtyId$,
111
+ disabled$,
112
+ ...stateProps
113
+ },
114
+ patch
115
+ ] = writablesForProps(defaultItemConfig, config, configItemValidator);
116
+ const initDone$ = writable(false);
117
+ const _autoId$ = computed(() => generateId());
118
+ const id$ = computed(() => _dirtyId$() || _autoId$());
119
+ const transition = createTransition({
120
+ props: {
121
+ transition: transition$,
122
+ visible: visible$,
123
+ onVisibleChange: onVisibleChange$,
124
+ animated: animated$,
125
+ animatedOnInit: false,
126
+ initDone: initDone$,
127
+ onHidden: () => {
128
+ onHidden$()();
129
+ },
130
+ onShown: () => {
131
+ onShown$()();
132
+ }
133
+ }
134
+ });
135
+ const shouldBeInDOM$ = computed(() => destroyOnHide$() === false || !transition.stores.hidden$());
136
+ const clickAction = () => {
137
+ if (!disabled$()) {
138
+ visible$.update((c) => !c);
139
+ }
140
+ };
141
+ const toggleDirective = createAttributesDirective(() => ({
142
+ attributes: {
143
+ id: computed(() => `${id$()}-toggle`),
144
+ "aria-expanded": computed(() => `${visible$()}`),
145
+ "aria-disabled": computed(() => `${disabled$()}`),
146
+ "aria-controls": computed(() => `${id$()}-body-container`),
147
+ disabled: disabled$
148
+ },
149
+ classNames: { collapsed: computed(() => !visible$()) },
150
+ events: { click: clickAction }
151
+ }));
152
+ const transitionDirective = bindDirectiveNoArg(transition.directives.directive);
153
+ const bodyContainerAttrsDirective = createAttributesDirective(() => ({
154
+ attributes: {
155
+ id: computed(() => `${id$()}-body-container`),
156
+ class: bodyContainerClassName$(),
157
+ "aria-labelledby": computed(() => `${id$()}-toggle`)
158
+ }
159
+ }));
160
+ return {
161
+ ...stateStores({
162
+ visible$,
163
+ id$,
164
+ shouldBeInDOM$,
165
+ disabled$,
166
+ bodyClassName$,
167
+ buttonClassName$,
168
+ bodyContainerClassName$,
169
+ headerClassName$,
170
+ ...stateProps
171
+ }),
172
+ patch,
173
+ actions: {
174
+ click: clickAction
175
+ },
176
+ api: {
177
+ initDone: () => {
178
+ initDone$.set(true);
179
+ },
180
+ collapse: () => {
181
+ visible$.set(false);
182
+ },
183
+ expand: () => {
184
+ visible$.set(true);
185
+ },
186
+ toggle: () => {
187
+ visible$.update((c) => !c);
188
+ }
189
+ },
190
+ directives: {
191
+ toggleDirective,
192
+ buttonDirective: mergeDirectives(
193
+ toggleDirective,
194
+ createAttributesDirective(() => ({
195
+ attributes: {
196
+ type: "button",
197
+ class: buttonClassName$()
198
+ }
199
+ }))
200
+ ),
201
+ headerDirective: createAttributesDirective(() => ({ attributes: { class: headerClassName$() } })),
202
+ bodyDirective: createAttributesDirective(() => ({ attributes: { class: bodyClassName$() } })),
203
+ transitionDirective,
204
+ bodyContainerAttrsDirective,
205
+ bodyContainerDirective: mergeDirectives(transitionDirective, bodyContainerAttrsDirective),
206
+ itemDirective: noop
207
+ }
208
+ };
209
+ }
210
+ function factoryCreateAccordion(itemFactory = createAccordionItem, accordionItemProps = coreAccordionItemProps, accordionConfig = defaultAccordionConfig, accordionValidator = configAccordionValidator) {
211
+ return (config) => {
212
+ const [writables, patch] = writablesForProps(accordionConfig, config, accordionValidator);
213
+ const { closeOthers$, onItemShown$, onItemHidden$, className$ } = writables;
214
+ const accordionItemConfig = Object.fromEntries(
215
+ Object.entries(writables).filter((entry) => entry[0].startsWith("item")).map((entry) => [entry[0].charAt(4).toLowerCase() + entry[0].slice(5, -1), entry[1]])
216
+ );
217
+ const itemWidgets$ = registrationArray();
218
+ const openItems$ = computed(() => {
219
+ const openItems = [];
220
+ itemWidgets$().forEach((item) => {
221
+ if (item.stores.visible$()) {
222
+ openItems.push(item.stores.id$());
223
+ }
224
+ });
225
+ return openItems;
226
+ });
227
+ const oldOpenItem$ = writable(openItems$()[0]);
228
+ const checkCloseOthersAction$ = computed(() => {
229
+ if (closeOthers$()) {
230
+ adjustItemsCloseOthers(itemWidgets$(), openItems$(), oldOpenItem$());
231
+ oldOpenItem$.set(openItems$()[0]);
232
+ }
233
+ });
234
+ const action$ = computed(() => {
235
+ checkCloseOthersAction$();
236
+ });
237
+ return {
238
+ ...stateStores({ itemWidgets$, className$ }),
239
+ patch,
240
+ actions: {},
241
+ api: {
242
+ expand: (id) => {
243
+ var _a;
244
+ (_a = getItem(itemWidgets$(), id)) == null ? void 0 : _a.api.expand();
245
+ },
246
+ collapse: (id) => {
247
+ var _a;
248
+ (_a = getItem(itemWidgets$(), id)) == null ? void 0 : _a.api.collapse();
249
+ },
250
+ toggle: (id) => {
251
+ var _a;
252
+ (_a = getItem(itemWidgets$(), id)) == null ? void 0 : _a.api.toggle();
253
+ },
254
+ expandAll: () => {
255
+ itemWidgets$().forEach((i) => i.api.expand());
256
+ },
257
+ collapseAll: () => {
258
+ itemWidgets$().forEach((i) => i.api.collapse());
259
+ },
260
+ registerItem: (propsConfig) => {
261
+ const itemProps = accordionItemProps;
262
+ const config2 = mergeConfigStores(itemProps, normalizeConfigStores(itemProps, propsConfig == null ? void 0 : propsConfig.config), accordionItemConfig);
263
+ const [{ onHidden$, onShown$ }] = writablesForProps(
264
+ {
265
+ onHidden: defaultItemConfig.onHidden,
266
+ onShown: defaultItemConfig.onShown
267
+ },
268
+ { config: config2, props: propsConfig == null ? void 0 : propsConfig.props }
269
+ );
270
+ const item = itemFactory({
271
+ config: config2,
272
+ props: {
273
+ ...propsConfig == null ? void 0 : propsConfig.props,
274
+ onHidden: asWritable(
275
+ readable(() => {
276
+ var _a;
277
+ onItemHidden$()(item.stores.id$());
278
+ (_a = onHidden$()) == null ? void 0 : _a();
279
+ }),
280
+ (val) => {
281
+ onItemHidden$.set(val);
282
+ }
283
+ ),
284
+ onShown: asWritable(
285
+ readable(() => {
286
+ var _a;
287
+ onItemShown$()(item.stores.id$());
288
+ (_a = onShown$()) == null ? void 0 : _a();
289
+ }),
290
+ (val) => {
291
+ onItemShown$.set(val);
292
+ }
293
+ )
294
+ }
295
+ });
296
+ item.directives.itemDirective = mergeDirectives(
297
+ () => ({
298
+ destroy: itemWidgets$.register(item)
299
+ }),
300
+ createAttributesDirective(() => ({
301
+ attributes: { class: item.stores.className$, id: item.stores.id$ }
302
+ }))
303
+ );
304
+ return item;
305
+ }
306
+ },
307
+ directives: {
308
+ accordionDirective: mergeDirectives(
309
+ directiveSubscribe(action$),
310
+ createAttributesDirective(() => ({ attributes: { class: className$() }, classNames: { "au-accordion": true } }))
311
+ )
312
+ }
313
+ };
314
+ };
315
+ }
316
+ const createAccordion = factoryCreateAccordion();
317
+ export {
318
+ createAccordion as a,
319
+ createAccordionItem as c,
320
+ factoryCreateAccordion as f,
321
+ getAccordionDefaultConfig as g
322
+ };
@@ -0,0 +1,321 @@
1
+ "use strict";
2
+ const utils_stores = require("./utils/stores.cjs");
3
+ const services_transitions_baseTransitions = require("./services/transitions/baseTransitions.cjs");
4
+ const tansu = require("@amadeus-it-group/tansu");
5
+ const func = require("./func-Qd3cD9a3.cjs");
6
+ const utils_writables = require("./writables-D46sFgGK.cjs");
7
+ const utils_directive = require("./directive-j-xRk-h3.cjs");
8
+ function adjustItemsCloseOthers(items, openItems, oldOpen) {
9
+ let keepOpen;
10
+ if (openItems.length == 2) {
11
+ oldOpen = oldOpen ?? openItems[0];
12
+ keepOpen = openItems.find((id) => id !== oldOpen);
13
+ } else if (openItems.length > 2) {
14
+ keepOpen = openItems[0];
15
+ }
16
+ if (keepOpen) {
17
+ items.forEach((item) => {
18
+ if (item.stores.id$() !== keepOpen && item.stores.visible$()) {
19
+ item.patch({ visible: false });
20
+ }
21
+ });
22
+ }
23
+ return items;
24
+ }
25
+ function getItem(items, id) {
26
+ return items.find((item) => item.stores.id$() === id);
27
+ }
28
+ const defaultAccordionConfig = {
29
+ closeOthers: false,
30
+ onItemShown: func.noop,
31
+ onItemHidden: func.noop,
32
+ className: "",
33
+ itemDestroyOnHide: true,
34
+ itemAnimated: true,
35
+ itemTransition: async () => {
36
+ },
37
+ itemHeadingTag: "",
38
+ itemClassName: "",
39
+ itemHeaderClassName: "",
40
+ itemButtonClassName: "",
41
+ itemBodyContainerClassName: "",
42
+ itemBodyClassName: ""
43
+ };
44
+ const defaultItemConfig = {
45
+ id: "",
46
+ destroyOnHide: defaultAccordionConfig.itemDestroyOnHide,
47
+ disabled: false,
48
+ visible: false,
49
+ animated: defaultAccordionConfig.itemAnimated,
50
+ transition: defaultAccordionConfig.itemTransition,
51
+ onShown: func.noop,
52
+ onHidden: func.noop,
53
+ onVisibleChange: func.noop,
54
+ className: defaultAccordionConfig.itemClassName,
55
+ headerClassName: defaultAccordionConfig.itemHeaderClassName,
56
+ buttonClassName: defaultAccordionConfig.itemButtonClassName,
57
+ bodyContainerClassName: defaultAccordionConfig.itemBodyContainerClassName,
58
+ bodyClassName: defaultAccordionConfig.itemBodyClassName,
59
+ headingTag: defaultAccordionConfig.itemHeadingTag
60
+ };
61
+ const coreAccordionItemProps = Object.keys(defaultItemConfig);
62
+ function getAccordionDefaultConfig() {
63
+ return { ...defaultAccordionConfig };
64
+ }
65
+ const configAccordionValidator = {
66
+ closeOthers: utils_writables.typeBoolean,
67
+ onItemShown: utils_writables.typeFunction,
68
+ onItemHidden: utils_writables.typeFunction,
69
+ className: utils_writables.typeString,
70
+ itemDestroyOnHide: utils_writables.typeBoolean,
71
+ itemAnimated: utils_writables.typeBoolean,
72
+ itemTransition: utils_writables.typeFunction,
73
+ itemClassName: utils_writables.typeString,
74
+ itemHeaderClassName: utils_writables.typeString,
75
+ itemButtonClassName: utils_writables.typeString,
76
+ itemBodyContainerClassName: utils_writables.typeString,
77
+ itemBodyClassName: utils_writables.typeString,
78
+ itemHeadingTag: utils_writables.typeString
79
+ };
80
+ const configItemValidator = {
81
+ id: utils_writables.typeString,
82
+ destroyOnHide: utils_writables.typeBoolean,
83
+ disabled: utils_writables.typeBoolean,
84
+ visible: utils_writables.typeBoolean,
85
+ animated: utils_writables.typeBoolean,
86
+ transition: utils_writables.typeFunction,
87
+ onShown: utils_writables.typeFunction,
88
+ onHidden: utils_writables.typeFunction,
89
+ onVisibleChange: utils_writables.typeFunction,
90
+ className: utils_writables.typeString,
91
+ headerClassName: utils_writables.typeString,
92
+ buttonClassName: utils_writables.typeString,
93
+ bodyContainerClassName: utils_writables.typeString,
94
+ bodyClassName: utils_writables.typeString,
95
+ headingTag: utils_writables.typeString
96
+ };
97
+ function createAccordionItem(config) {
98
+ const [
99
+ {
100
+ bodyClassName$,
101
+ buttonClassName$,
102
+ bodyContainerClassName$,
103
+ headerClassName$,
104
+ animated$,
105
+ transition$,
106
+ destroyOnHide$,
107
+ onShown$,
108
+ onHidden$,
109
+ onVisibleChange$,
110
+ visible$,
111
+ id$: _dirtyId$,
112
+ disabled$,
113
+ ...stateProps
114
+ },
115
+ patch
116
+ ] = utils_stores.writablesForProps(defaultItemConfig, config, configItemValidator);
117
+ const initDone$ = tansu.writable(false);
118
+ const _autoId$ = tansu.computed(() => utils_directive.generateId());
119
+ const id$ = tansu.computed(() => _dirtyId$() || _autoId$());
120
+ const transition = services_transitions_baseTransitions.createTransition({
121
+ props: {
122
+ transition: transition$,
123
+ visible: visible$,
124
+ onVisibleChange: onVisibleChange$,
125
+ animated: animated$,
126
+ animatedOnInit: false,
127
+ initDone: initDone$,
128
+ onHidden: () => {
129
+ onHidden$()();
130
+ },
131
+ onShown: () => {
132
+ onShown$()();
133
+ }
134
+ }
135
+ });
136
+ const shouldBeInDOM$ = tansu.computed(() => destroyOnHide$() === false || !transition.stores.hidden$());
137
+ const clickAction = () => {
138
+ if (!disabled$()) {
139
+ visible$.update((c) => !c);
140
+ }
141
+ };
142
+ const toggleDirective = utils_directive.createAttributesDirective(() => ({
143
+ attributes: {
144
+ id: tansu.computed(() => `${id$()}-toggle`),
145
+ "aria-expanded": tansu.computed(() => `${visible$()}`),
146
+ "aria-disabled": tansu.computed(() => `${disabled$()}`),
147
+ "aria-controls": tansu.computed(() => `${id$()}-body-container`),
148
+ disabled: disabled$
149
+ },
150
+ classNames: { collapsed: tansu.computed(() => !visible$()) },
151
+ events: { click: clickAction }
152
+ }));
153
+ const transitionDirective = utils_directive.bindDirectiveNoArg(transition.directives.directive);
154
+ const bodyContainerAttrsDirective = utils_directive.createAttributesDirective(() => ({
155
+ attributes: {
156
+ id: tansu.computed(() => `${id$()}-body-container`),
157
+ class: bodyContainerClassName$(),
158
+ "aria-labelledby": tansu.computed(() => `${id$()}-toggle`)
159
+ }
160
+ }));
161
+ return {
162
+ ...utils_stores.stateStores({
163
+ visible$,
164
+ id$,
165
+ shouldBeInDOM$,
166
+ disabled$,
167
+ bodyClassName$,
168
+ buttonClassName$,
169
+ bodyContainerClassName$,
170
+ headerClassName$,
171
+ ...stateProps
172
+ }),
173
+ patch,
174
+ actions: {
175
+ click: clickAction
176
+ },
177
+ api: {
178
+ initDone: () => {
179
+ initDone$.set(true);
180
+ },
181
+ collapse: () => {
182
+ visible$.set(false);
183
+ },
184
+ expand: () => {
185
+ visible$.set(true);
186
+ },
187
+ toggle: () => {
188
+ visible$.update((c) => !c);
189
+ }
190
+ },
191
+ directives: {
192
+ toggleDirective,
193
+ buttonDirective: utils_directive.mergeDirectives(
194
+ toggleDirective,
195
+ utils_directive.createAttributesDirective(() => ({
196
+ attributes: {
197
+ type: "button",
198
+ class: buttonClassName$()
199
+ }
200
+ }))
201
+ ),
202
+ headerDirective: utils_directive.createAttributesDirective(() => ({ attributes: { class: headerClassName$() } })),
203
+ bodyDirective: utils_directive.createAttributesDirective(() => ({ attributes: { class: bodyClassName$() } })),
204
+ transitionDirective,
205
+ bodyContainerAttrsDirective,
206
+ bodyContainerDirective: utils_directive.mergeDirectives(transitionDirective, bodyContainerAttrsDirective),
207
+ itemDirective: func.noop
208
+ }
209
+ };
210
+ }
211
+ function factoryCreateAccordion(itemFactory = createAccordionItem, accordionItemProps = coreAccordionItemProps, accordionConfig = defaultAccordionConfig, accordionValidator = configAccordionValidator) {
212
+ return (config) => {
213
+ const [writables, patch] = utils_stores.writablesForProps(accordionConfig, config, accordionValidator);
214
+ const { closeOthers$, onItemShown$, onItemHidden$, className$ } = writables;
215
+ const accordionItemConfig = Object.fromEntries(
216
+ Object.entries(writables).filter((entry) => entry[0].startsWith("item")).map((entry) => [entry[0].charAt(4).toLowerCase() + entry[0].slice(5, -1), entry[1]])
217
+ );
218
+ const itemWidgets$ = utils_directive.registrationArray();
219
+ const openItems$ = tansu.computed(() => {
220
+ const openItems = [];
221
+ itemWidgets$().forEach((item) => {
222
+ if (item.stores.visible$()) {
223
+ openItems.push(item.stores.id$());
224
+ }
225
+ });
226
+ return openItems;
227
+ });
228
+ const oldOpenItem$ = tansu.writable(openItems$()[0]);
229
+ const checkCloseOthersAction$ = tansu.computed(() => {
230
+ if (closeOthers$()) {
231
+ adjustItemsCloseOthers(itemWidgets$(), openItems$(), oldOpenItem$());
232
+ oldOpenItem$.set(openItems$()[0]);
233
+ }
234
+ });
235
+ const action$ = tansu.computed(() => {
236
+ checkCloseOthersAction$();
237
+ });
238
+ return {
239
+ ...utils_stores.stateStores({ itemWidgets$, className$ }),
240
+ patch,
241
+ actions: {},
242
+ api: {
243
+ expand: (id) => {
244
+ var _a;
245
+ (_a = getItem(itemWidgets$(), id)) == null ? void 0 : _a.api.expand();
246
+ },
247
+ collapse: (id) => {
248
+ var _a;
249
+ (_a = getItem(itemWidgets$(), id)) == null ? void 0 : _a.api.collapse();
250
+ },
251
+ toggle: (id) => {
252
+ var _a;
253
+ (_a = getItem(itemWidgets$(), id)) == null ? void 0 : _a.api.toggle();
254
+ },
255
+ expandAll: () => {
256
+ itemWidgets$().forEach((i) => i.api.expand());
257
+ },
258
+ collapseAll: () => {
259
+ itemWidgets$().forEach((i) => i.api.collapse());
260
+ },
261
+ registerItem: (propsConfig) => {
262
+ const itemProps = accordionItemProps;
263
+ const config2 = utils_stores.mergeConfigStores(itemProps, utils_stores.normalizeConfigStores(itemProps, propsConfig == null ? void 0 : propsConfig.config), accordionItemConfig);
264
+ const [{ onHidden$, onShown$ }] = utils_stores.writablesForProps(
265
+ {
266
+ onHidden: defaultItemConfig.onHidden,
267
+ onShown: defaultItemConfig.onShown
268
+ },
269
+ { config: config2, props: propsConfig == null ? void 0 : propsConfig.props }
270
+ );
271
+ const item = itemFactory({
272
+ config: config2,
273
+ props: {
274
+ ...propsConfig == null ? void 0 : propsConfig.props,
275
+ onHidden: tansu.asWritable(
276
+ tansu.readable(() => {
277
+ var _a;
278
+ onItemHidden$()(item.stores.id$());
279
+ (_a = onHidden$()) == null ? void 0 : _a();
280
+ }),
281
+ (val) => {
282
+ onItemHidden$.set(val);
283
+ }
284
+ ),
285
+ onShown: tansu.asWritable(
286
+ tansu.readable(() => {
287
+ var _a;
288
+ onItemShown$()(item.stores.id$());
289
+ (_a = onShown$()) == null ? void 0 : _a();
290
+ }),
291
+ (val) => {
292
+ onItemShown$.set(val);
293
+ }
294
+ )
295
+ }
296
+ });
297
+ item.directives.itemDirective = utils_directive.mergeDirectives(
298
+ () => ({
299
+ destroy: itemWidgets$.register(item)
300
+ }),
301
+ utils_directive.createAttributesDirective(() => ({
302
+ attributes: { class: item.stores.className$, id: item.stores.id$ }
303
+ }))
304
+ );
305
+ return item;
306
+ }
307
+ },
308
+ directives: {
309
+ accordionDirective: utils_directive.mergeDirectives(
310
+ utils_directive.directiveSubscribe(action$),
311
+ utils_directive.createAttributesDirective(() => ({ attributes: { class: className$() }, classNames: { "au-accordion": true } }))
312
+ )
313
+ }
314
+ };
315
+ };
316
+ }
317
+ const createAccordion = factoryCreateAccordion();
318
+ exports.createAccordion = createAccordion;
319
+ exports.createAccordionItem = createAccordionItem;
320
+ exports.factoryCreateAccordion = factoryCreateAccordion;
321
+ exports.getAccordionDefaultConfig = getAccordionDefaultConfig;
@@ -1,4 +1,4 @@
1
- import { g as getCommonAlertDefaultConfig, a as createCommonAlert } from "./common-DRdsw5m8.js";
1
+ import { g as getCommonAlertDefaultConfig, a as createCommonAlert } from "./common-BCEqowKw.js";
2
2
  function getAlertDefaultConfig() {
3
3
  return { ...getCommonAlertDefaultConfig() };
4
4
  }
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const common = require("./common-nJRMXbwj.cjs");
2
+ const common = require("./common-Kb96q7i4.cjs");
3
3
  function getAlertDefaultConfig() {
4
4
  return { ...common.getCommonAlertDefaultConfig() };
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import { createTransition } from "./services/transitions/baseTransitions.js";
2
2
  import { n as noop } from "./func-DR0n-ShK.js";
3
3
  import { writablesForProps, stateStores } from "./utils/stores.js";
4
- import { c as bindDirectiveNoArg } from "./directive-DCYlDznf.js";
4
+ import { c as bindDirectiveNoArg } from "./directive-3-8yr-ZK.js";
5
5
  import { c as typeBoolean } from "./writables-DoU_XYTX.js";
6
6
  const defaultCommonAlertConfig = {
7
7
  visible: true,
@@ -2,7 +2,7 @@
2
2
  const services_transitions_baseTransitions = require("./services/transitions/baseTransitions.cjs");
3
3
  const func = require("./func-Qd3cD9a3.cjs");
4
4
  const utils_stores = require("./utils/stores.cjs");
5
- const utils_directive = require("./directive-BTSEYLF3.cjs");
5
+ const utils_directive = require("./directive-j-xRk-h3.cjs");
6
6
  const utils_writables = require("./writables-D46sFgGK.cjs");
7
7
  const defaultCommonAlertConfig = {
8
8
  visible: true,