@design-factory/core 21.1.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 (176) hide show
  1. package/README.md +3 -0
  2. package/accordion-B0vs8JWM.cjs +314 -0
  3. package/accordion-D9ba0XYq.js +315 -0
  4. package/alert-AhaliJ17.cjs +9 -0
  5. package/alert-Cb9FhbFQ.js +10 -0
  6. package/collapse-Bn8iHKrd.js +95 -0
  7. package/collapse-BnWw4Hnc.cjs +94 -0
  8. package/common-B5jS-Ih_.cjs +73 -0
  9. package/common-DFyZvkII.js +74 -0
  10. package/components/accordion/accordion.d.ts +333 -0
  11. package/components/accordion/index.cjs +7 -0
  12. package/components/accordion/index.d.ts +1 -0
  13. package/components/accordion/index.js +7 -0
  14. package/components/alert/alert.d.ts +37 -0
  15. package/components/alert/common.d.ts +138 -0
  16. package/components/alert/index.cjs +5 -0
  17. package/components/alert/index.d.ts +1 -0
  18. package/components/alert/index.js +5 -0
  19. package/components/carousel/carousel.d.ts +247 -0
  20. package/components/carousel/index.cjs +292 -0
  21. package/components/carousel/index.d.ts +1 -0
  22. package/components/carousel/index.js +292 -0
  23. package/components/collapse/collapse.d.ts +135 -0
  24. package/components/collapse/index.cjs +5 -0
  25. package/components/collapse/index.d.ts +1 -0
  26. package/components/collapse/index.js +5 -0
  27. package/components/commonProps.d.ts +11 -0
  28. package/components/drawer/drawer.d.ts +279 -0
  29. package/components/drawer/index.cjs +5 -0
  30. package/components/drawer/index.d.ts +1 -0
  31. package/components/drawer/index.js +5 -0
  32. package/components/modal/index.cjs +8 -0
  33. package/components/modal/index.d.ts +1 -0
  34. package/components/modal/index.js +8 -0
  35. package/components/modal/modal.d.ts +245 -0
  36. package/components/pagination/index.cjs +5 -0
  37. package/components/pagination/index.d.ts +1 -0
  38. package/components/pagination/index.js +5 -0
  39. package/components/pagination/pagination.d.ts +313 -0
  40. package/components/progressbar/index.cjs +5 -0
  41. package/components/progressbar/index.d.ts +1 -0
  42. package/components/progressbar/index.js +5 -0
  43. package/components/progressbar/progressbar.d.ts +91 -0
  44. package/components/rating/index.cjs +5 -0
  45. package/components/rating/index.d.ts +1 -0
  46. package/components/rating/index.js +5 -0
  47. package/components/rating/rating.d.ts +191 -0
  48. package/components/slider/index.cjs +5 -0
  49. package/components/slider/index.d.ts +1 -0
  50. package/components/slider/index.js +5 -0
  51. package/components/slider/slider-utils.d.ts +25 -0
  52. package/components/slider/slider.d.ts +383 -0
  53. package/components/toast/index.cjs +7 -0
  54. package/components/toast/index.d.ts +2 -0
  55. package/components/toast/index.js +7 -0
  56. package/components/toast/toast.d.ts +66 -0
  57. package/components/toast/toaster.d.ts +128 -0
  58. package/components/tree/index.cjs +5 -0
  59. package/components/tree/index.d.ts +1 -0
  60. package/components/tree/index.js +5 -0
  61. package/components/tree/tree.d.ts +143 -0
  62. package/config.cjs +36 -0
  63. package/config.d.ts +117 -0
  64. package/config.js +36 -0
  65. package/directive-CNNSo5Yn.js +524 -0
  66. package/directive-DyTodNPd.cjs +523 -0
  67. package/drawer-BIIfJa0F.js +329 -0
  68. package/drawer-C8ojtwIn.cjs +328 -0
  69. package/index.cjs +134 -0
  70. package/index.d.ts +29 -0
  71. package/index.js +134 -0
  72. package/isFocusable-Ckwus82R.js +32 -0
  73. package/isFocusable-DfzDLeAN.cjs +31 -0
  74. package/modal-C13G13jV.js +253 -0
  75. package/modal-DWv0VqiG.cjs +252 -0
  76. package/package.json +56 -0
  77. package/pagination-BLVa1UsZ.cjs +254 -0
  78. package/pagination-BQWusWXN.js +255 -0
  79. package/progressbar-RopgvVeA.cjs +86 -0
  80. package/progressbar-S1pNn5rM.js +87 -0
  81. package/promise-CxCD3NYv.cjs +118 -0
  82. package/promise-D-RZVPuv.js +119 -0
  83. package/rating-DWgGgwk3.js +184 -0
  84. package/rating-DZ3OQgtt.cjs +183 -0
  85. package/scrollbars-CT87iv_6.cjs +30 -0
  86. package/scrollbars-CcxSrnCx.js +31 -0
  87. package/services/extendWidget.cjs +41 -0
  88. package/services/extendWidget.d.ts +31 -0
  89. package/services/extendWidget.js +41 -0
  90. package/services/floatingUI.cjs +111 -0
  91. package/services/floatingUI.d.ts +76 -0
  92. package/services/floatingUI.js +111 -0
  93. package/services/focusElement.cjs +46 -0
  94. package/services/focusElement.d.ts +9 -0
  95. package/services/focusElement.js +46 -0
  96. package/services/focustrack.cjs +47 -0
  97. package/services/focustrack.d.ts +40 -0
  98. package/services/focustrack.js +47 -0
  99. package/services/hash.cjs +15 -0
  100. package/services/hash.d.ts +3 -0
  101. package/services/hash.js +15 -0
  102. package/services/intersection.cjs +53 -0
  103. package/services/intersection.d.ts +30 -0
  104. package/services/intersection.js +53 -0
  105. package/services/matchMedia.cjs +14 -0
  106. package/services/matchMedia.d.ts +8 -0
  107. package/services/matchMedia.js +14 -0
  108. package/services/navManager.cjs +166 -0
  109. package/services/navManager.d.ts +144 -0
  110. package/services/navManager.js +166 -0
  111. package/services/pointerdownPosition.cjs +60 -0
  112. package/services/pointerdownPosition.d.ts +42 -0
  113. package/services/pointerdownPosition.js +60 -0
  114. package/services/portal.cjs +42 -0
  115. package/services/portal.d.ts +16 -0
  116. package/services/portal.js +42 -0
  117. package/services/resizeObserver.cjs +54 -0
  118. package/services/resizeObserver.d.ts +18 -0
  119. package/services/resizeObserver.js +54 -0
  120. package/services/siblingsInert.cjs +44 -0
  121. package/services/siblingsInert.d.ts +16 -0
  122. package/services/siblingsInert.js +44 -0
  123. package/services/transitions/baseTransitions.cjs +186 -0
  124. package/services/transitions/baseTransitions.d.ts +166 -0
  125. package/services/transitions/baseTransitions.js +186 -0
  126. package/services/transitions/collapse.cjs +40 -0
  127. package/services/transitions/collapse.d.ts +49 -0
  128. package/services/transitions/collapse.js +40 -0
  129. package/services/transitions/cssTransitions.cjs +32 -0
  130. package/services/transitions/cssTransitions.d.ts +25 -0
  131. package/services/transitions/cssTransitions.js +32 -0
  132. package/services/transitions/simpleClassTransition.cjs +37 -0
  133. package/services/transitions/simpleClassTransition.d.ts +47 -0
  134. package/services/transitions/simpleClassTransition.js +37 -0
  135. package/slider-Br_Qiopx.js +808 -0
  136. package/slider-pgDq1V5r.cjs +807 -0
  137. package/textDirection-cNgt24LJ.js +4 -0
  138. package/textDirection-zqcZ5-eK.cjs +3 -0
  139. package/toaster-BUBzFeJM.js +162 -0
  140. package/toaster-Dlube4Ya.cjs +161 -0
  141. package/tree-Chcy4ulJ.cjs +228 -0
  142. package/tree-vD7ZkV8Z.js +229 -0
  143. package/types.cjs +6 -0
  144. package/types.d.ts +246 -0
  145. package/types.js +6 -0
  146. package/utils/directive.cjs +28 -0
  147. package/utils/directive.d.ts +352 -0
  148. package/utils/directive.js +28 -0
  149. package/utils/func.cjs +7 -0
  150. package/utils/func.d.ts +11 -0
  151. package/utils/func.js +7 -0
  152. package/utils/id.cjs +5 -0
  153. package/utils/id.d.ts +6 -0
  154. package/utils/id.js +5 -0
  155. package/utils/internal/assign.d.ts +10 -0
  156. package/utils/internal/checks.d.ts +57 -0
  157. package/utils/internal/dom.d.ts +75 -0
  158. package/utils/internal/isFocusable.d.ts +9 -0
  159. package/utils/internal/math.d.ts +5 -0
  160. package/utils/internal/promise.d.ts +98 -0
  161. package/utils/internal/scrollbars.d.ts +8 -0
  162. package/utils/internal/sort.d.ts +16 -0
  163. package/utils/internal/ssrHTMLElement.d.ts +17 -0
  164. package/utils/internal/textDirection.d.ts +7 -0
  165. package/utils/internal/traversal.d.ts +54 -0
  166. package/utils/stores.cjs +172 -0
  167. package/utils/stores.d.ts +224 -0
  168. package/utils/stores.js +172 -0
  169. package/utils/widget.cjs +8 -0
  170. package/utils/widget.d.ts +11 -0
  171. package/utils/widget.js +8 -0
  172. package/utils/writables.cjs +16 -0
  173. package/utils/writables.d.ts +95 -0
  174. package/utils/writables.js +16 -0
  175. package/writables-DYGjj5T3.js +103 -0
  176. package/writables-Dt68gADJ.cjs +102 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @design-factory/core
2
+
3
+ This is an internal package used by the [Design Factory](https://www.npmjs.com/package/@design-factory/angular).
@@ -0,0 +1,314 @@
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 utils_func = require("./utils/func.cjs");
6
+ const utils_writables = require("./writables-Dt68gADJ.cjs");
7
+ const utils_directive = require("./directive-DyTodNPd.cjs");
8
+ const utils_widget = require("./utils/widget.cjs");
9
+ function adjustItemsCloseOthers(items, openItems, oldOpen) {
10
+ let keepOpen;
11
+ if (openItems.length == 2) {
12
+ oldOpen = oldOpen ?? openItems[0];
13
+ keepOpen = openItems.find((id) => id !== oldOpen);
14
+ } else if (openItems.length > 2) {
15
+ keepOpen = openItems[0];
16
+ }
17
+ if (keepOpen) {
18
+ items.forEach((item) => {
19
+ if (item.stores.id$() !== keepOpen && item.stores.visible$()) {
20
+ item.patch({ visible: false });
21
+ }
22
+ });
23
+ }
24
+ return items;
25
+ }
26
+ function getItem(items, id) {
27
+ return items.find((item) => item.stores.id$() === id);
28
+ }
29
+ const defaultAccordionConfig = {
30
+ closeOthers: false,
31
+ onItemShown: utils_func.noop,
32
+ onItemHidden: utils_func.noop,
33
+ className: "",
34
+ itemDestroyOnHide: true,
35
+ itemAnimated: true,
36
+ itemTransition: utils_func.noop,
37
+ itemHeadingLevel: 2,
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: utils_func.noop,
52
+ onHidden: utils_func.noop,
53
+ onVisibleChange: utils_func.noop,
54
+ className: defaultAccordionConfig.itemClassName,
55
+ headerClassName: defaultAccordionConfig.itemHeaderClassName,
56
+ buttonClassName: defaultAccordionConfig.itemButtonClassName,
57
+ bodyContainerClassName: defaultAccordionConfig.itemBodyContainerClassName,
58
+ bodyClassName: defaultAccordionConfig.itemBodyClassName,
59
+ headingLevel: defaultAccordionConfig.itemHeadingLevel
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
+ itemHeadingLevel: utils_writables.createTypeEnum([1, 2, 3, 4, 5, 6])
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
+ headingLevel: utils_writables.createTypeEnum([1, 2, 3, 4, 5, 6])
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 id$ = utils_stores.idWithDefault(_dirtyId$);
119
+ const transition = services_transitions_baseTransitions.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$ = tansu.computed(() => !destroyOnHide$() || !transition.stores.hidden$());
136
+ const toggleDirective = utils_directive.createAttributesDirective(() => ({
137
+ attributes: {
138
+ id: tansu.computed(() => `${id$()}-toggle`),
139
+ "aria-expanded": tansu.computed(() => `${visible$()}`),
140
+ "aria-disabled": tansu.computed(() => `${disabled$()}`),
141
+ "aria-controls": tansu.computed(() => `${id$()}-body-container`),
142
+ disabled: disabled$
143
+ },
144
+ classNames: { collapsed: tansu.computed(() => !visible$()) },
145
+ events: {
146
+ click: () => {
147
+ if (!disabled$()) {
148
+ void transition.api.toggle();
149
+ }
150
+ }
151
+ }
152
+ }));
153
+ const transitionDirective = 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
+ role: tansu.readable("region")
160
+ }
161
+ }));
162
+ return {
163
+ ...utils_stores.stateStores({
164
+ visible$,
165
+ id$,
166
+ shouldBeInDOM$,
167
+ disabled$,
168
+ bodyClassName$,
169
+ buttonClassName$,
170
+ bodyContainerClassName$,
171
+ headerClassName$,
172
+ ...stateProps
173
+ }),
174
+ patch,
175
+ api: {
176
+ initDone: () => {
177
+ initDone$.set(true);
178
+ },
179
+ collapse: transition.api.hide,
180
+ expand: transition.api.show,
181
+ toggle: (animated) => transition.api.toggle(void 0, animated)
182
+ },
183
+ directives: {
184
+ toggleDirective,
185
+ buttonDirective: utils_directive.mergeDirectives(
186
+ toggleDirective,
187
+ utils_directive.createAttributesDirective(() => ({
188
+ attributes: {
189
+ type: tansu.readable("button"),
190
+ class: buttonClassName$
191
+ }
192
+ }))
193
+ ),
194
+ headerDirective: utils_directive.createAttributesDirective(() => ({ attributes: { class: headerClassName$ } })),
195
+ bodyDirective: utils_directive.createAttributesDirective(() => ({ attributes: { class: bodyClassName$ } })),
196
+ transitionDirective,
197
+ bodyContainerAttrsDirective,
198
+ bodyContainerDirective: utils_directive.mergeDirectives(transitionDirective, bodyContainerAttrsDirective),
199
+ itemDirective: utils_func.noop
200
+ }
201
+ };
202
+ }
203
+ function factoryCreateAccordion(itemFactory = createAccordionItem, accordionItemProps = coreAccordionItemProps, accordionConfig = defaultAccordionConfig, accordionValidator = configAccordionValidator) {
204
+ return utils_widget.createWidgetFactory("accordion", (config) => {
205
+ const [writables, patch] = utils_stores.writablesForProps(accordionConfig, config, accordionValidator);
206
+ const { closeOthers$, onItemShown$, onItemHidden$, className$ } = writables;
207
+ const accordionItemConfig = Object.fromEntries(
208
+ Object.entries(writables).filter((entry) => entry[0].startsWith("item")).map((entry) => [entry[0].charAt(4).toLowerCase() + entry[0].slice(5, -1), entry[1]])
209
+ );
210
+ const itemWidgets$ = utils_directive.registrationArray();
211
+ const openItems$ = tansu.computed(() => {
212
+ const openItems = [];
213
+ itemWidgets$().forEach((item) => {
214
+ if (item.stores.visible$()) {
215
+ openItems.push(item.stores.id$());
216
+ }
217
+ });
218
+ return openItems;
219
+ });
220
+ const oldOpenItem$ = tansu.writable(openItems$()[0]);
221
+ const checkCloseOthersAction$ = tansu.computed(() => {
222
+ if (closeOthers$()) {
223
+ adjustItemsCloseOthers(itemWidgets$(), openItems$(), oldOpenItem$());
224
+ oldOpenItem$.set(openItems$()[0]);
225
+ }
226
+ });
227
+ const action$ = tansu.computed(() => {
228
+ checkCloseOthersAction$();
229
+ });
230
+ return {
231
+ ...utils_stores.stateStores({ itemWidgets$, className$ }),
232
+ patch,
233
+ api: {
234
+ expand: async (id, animated) => {
235
+ await getItem(itemWidgets$(), id)?.api.expand(animated);
236
+ },
237
+ collapse: async (id, animated) => {
238
+ await getItem(itemWidgets$(), id)?.api.collapse(animated);
239
+ },
240
+ toggle: async (id, animated) => {
241
+ await getItem(itemWidgets$(), id)?.api.toggle(animated);
242
+ },
243
+ expandAll: async (animated) => {
244
+ await Promise.all(itemWidgets$().map((i) => i.api.expand(animated)));
245
+ },
246
+ collapseAll: async (animated) => {
247
+ await Promise.all(itemWidgets$().map((i) => i.api.collapse(animated)));
248
+ },
249
+ registerItem: (propsConfig) => {
250
+ const itemProps = accordionItemProps;
251
+ const config2 = utils_stores.mergeConfigStores(
252
+ itemProps,
253
+ utils_stores.normalizeConfigStores(itemProps, propsConfig?.config),
254
+ accordionItemConfig
255
+ );
256
+ const [{ onHidden$, onShown$ }] = utils_stores.writablesForProps(
257
+ {
258
+ onHidden: defaultItemConfig.onHidden,
259
+ onShown: defaultItemConfig.onShown
260
+ },
261
+ { config: config2, props: propsConfig?.props }
262
+ );
263
+ const item = itemFactory({
264
+ config: config2,
265
+ props: {
266
+ ...propsConfig?.props,
267
+ onHidden: tansu.asWritable(
268
+ tansu.readable(() => {
269
+ onItemHidden$()(item.stores.id$());
270
+ onHidden$()?.();
271
+ }),
272
+ (val) => {
273
+ onItemHidden$.set(val);
274
+ }
275
+ ),
276
+ onShown: tansu.asWritable(
277
+ tansu.readable(() => {
278
+ onItemShown$()(item.stores.id$());
279
+ onShown$()?.();
280
+ }),
281
+ (val) => {
282
+ onItemShown$.set(val);
283
+ }
284
+ )
285
+ }
286
+ });
287
+ item.directives.itemDirective = utils_directive.mergeDirectives(
288
+ () => ({
289
+ destroy: itemWidgets$.register(item)
290
+ }),
291
+ utils_directive.createAttributesDirective(() => ({
292
+ attributes: { class: item.stores.className$, id: item.stores.id$ }
293
+ }))
294
+ );
295
+ return item;
296
+ }
297
+ },
298
+ directives: {
299
+ accordionDirective: utils_directive.mergeDirectives(
300
+ utils_directive.directiveSubscribe(action$),
301
+ utils_directive.createAttributesDirective(() => ({
302
+ attributes: { class: className$ },
303
+ classNames: { "au-accordion": utils_stores.true$ }
304
+ }))
305
+ )
306
+ }
307
+ };
308
+ });
309
+ }
310
+ const createAccordion = factoryCreateAccordion();
311
+ exports.createAccordion = createAccordion;
312
+ exports.createAccordionItem = createAccordionItem;
313
+ exports.factoryCreateAccordion = factoryCreateAccordion;
314
+ exports.getAccordionDefaultConfig = getAccordionDefaultConfig;
@@ -0,0 +1,315 @@
1
+ import { writablesForProps, idWithDefault, stateStores, true$, mergeConfigStores, normalizeConfigStores } from "./utils/stores.js";
2
+ import { createTransition } from "./services/transitions/baseTransitions.js";
3
+ import { writable, computed, readable, asWritable } from "@amadeus-it-group/tansu";
4
+ import { noop } from "./utils/func.js";
5
+ import { j as typeString, e as typeFunction, b as typeBoolean, c as createTypeEnum } from "./writables-DYGjj5T3.js";
6
+ import { s as mergeDirectives, g as createAttributesDirective, u as registrationArray, o as directiveSubscribe } from "./directive-CNNSo5Yn.js";
7
+ import { createWidgetFactory } from "./utils/widget.js";
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: noop,
31
+ onItemHidden: noop,
32
+ className: "",
33
+ itemDestroyOnHide: true,
34
+ itemAnimated: true,
35
+ itemTransition: noop,
36
+ itemHeadingLevel: 2,
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
+ headingLevel: defaultAccordionConfig.itemHeadingLevel
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
+ itemHeadingLevel: createTypeEnum([1, 2, 3, 4, 5, 6])
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
+ headingLevel: createTypeEnum([1, 2, 3, 4, 5, 6])
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 id$ = idWithDefault(_dirtyId$);
118
+ const transition = createTransition({
119
+ props: {
120
+ transition: transition$,
121
+ visible: visible$,
122
+ onVisibleChange: onVisibleChange$,
123
+ animated: animated$,
124
+ animatedOnInit: false,
125
+ initDone: initDone$,
126
+ onHidden: () => {
127
+ onHidden$()();
128
+ },
129
+ onShown: () => {
130
+ onShown$()();
131
+ }
132
+ }
133
+ });
134
+ const shouldBeInDOM$ = computed(() => !destroyOnHide$() || !transition.stores.hidden$());
135
+ const toggleDirective = createAttributesDirective(() => ({
136
+ attributes: {
137
+ id: computed(() => `${id$()}-toggle`),
138
+ "aria-expanded": computed(() => `${visible$()}`),
139
+ "aria-disabled": computed(() => `${disabled$()}`),
140
+ "aria-controls": computed(() => `${id$()}-body-container`),
141
+ disabled: disabled$
142
+ },
143
+ classNames: { collapsed: computed(() => !visible$()) },
144
+ events: {
145
+ click: () => {
146
+ if (!disabled$()) {
147
+ void transition.api.toggle();
148
+ }
149
+ }
150
+ }
151
+ }));
152
+ const transitionDirective = 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
+ role: readable("region")
159
+ }
160
+ }));
161
+ return {
162
+ ...stateStores({
163
+ visible$,
164
+ id$,
165
+ shouldBeInDOM$,
166
+ disabled$,
167
+ bodyClassName$,
168
+ buttonClassName$,
169
+ bodyContainerClassName$,
170
+ headerClassName$,
171
+ ...stateProps
172
+ }),
173
+ patch,
174
+ api: {
175
+ initDone: () => {
176
+ initDone$.set(true);
177
+ },
178
+ collapse: transition.api.hide,
179
+ expand: transition.api.show,
180
+ toggle: (animated) => transition.api.toggle(void 0, animated)
181
+ },
182
+ directives: {
183
+ toggleDirective,
184
+ buttonDirective: mergeDirectives(
185
+ toggleDirective,
186
+ createAttributesDirective(() => ({
187
+ attributes: {
188
+ type: readable("button"),
189
+ class: buttonClassName$
190
+ }
191
+ }))
192
+ ),
193
+ headerDirective: createAttributesDirective(() => ({ attributes: { class: headerClassName$ } })),
194
+ bodyDirective: createAttributesDirective(() => ({ attributes: { class: bodyClassName$ } })),
195
+ transitionDirective,
196
+ bodyContainerAttrsDirective,
197
+ bodyContainerDirective: mergeDirectives(transitionDirective, bodyContainerAttrsDirective),
198
+ itemDirective: noop
199
+ }
200
+ };
201
+ }
202
+ function factoryCreateAccordion(itemFactory = createAccordionItem, accordionItemProps = coreAccordionItemProps, accordionConfig = defaultAccordionConfig, accordionValidator = configAccordionValidator) {
203
+ return createWidgetFactory("accordion", (config) => {
204
+ const [writables, patch] = writablesForProps(accordionConfig, config, accordionValidator);
205
+ const { closeOthers$, onItemShown$, onItemHidden$, className$ } = writables;
206
+ const accordionItemConfig = Object.fromEntries(
207
+ Object.entries(writables).filter((entry) => entry[0].startsWith("item")).map((entry) => [entry[0].charAt(4).toLowerCase() + entry[0].slice(5, -1), entry[1]])
208
+ );
209
+ const itemWidgets$ = registrationArray();
210
+ const openItems$ = computed(() => {
211
+ const openItems = [];
212
+ itemWidgets$().forEach((item) => {
213
+ if (item.stores.visible$()) {
214
+ openItems.push(item.stores.id$());
215
+ }
216
+ });
217
+ return openItems;
218
+ });
219
+ const oldOpenItem$ = writable(openItems$()[0]);
220
+ const checkCloseOthersAction$ = computed(() => {
221
+ if (closeOthers$()) {
222
+ adjustItemsCloseOthers(itemWidgets$(), openItems$(), oldOpenItem$());
223
+ oldOpenItem$.set(openItems$()[0]);
224
+ }
225
+ });
226
+ const action$ = computed(() => {
227
+ checkCloseOthersAction$();
228
+ });
229
+ return {
230
+ ...stateStores({ itemWidgets$, className$ }),
231
+ patch,
232
+ api: {
233
+ expand: async (id, animated) => {
234
+ await getItem(itemWidgets$(), id)?.api.expand(animated);
235
+ },
236
+ collapse: async (id, animated) => {
237
+ await getItem(itemWidgets$(), id)?.api.collapse(animated);
238
+ },
239
+ toggle: async (id, animated) => {
240
+ await getItem(itemWidgets$(), id)?.api.toggle(animated);
241
+ },
242
+ expandAll: async (animated) => {
243
+ await Promise.all(itemWidgets$().map((i) => i.api.expand(animated)));
244
+ },
245
+ collapseAll: async (animated) => {
246
+ await Promise.all(itemWidgets$().map((i) => i.api.collapse(animated)));
247
+ },
248
+ registerItem: (propsConfig) => {
249
+ const itemProps = accordionItemProps;
250
+ const config2 = mergeConfigStores(
251
+ itemProps,
252
+ normalizeConfigStores(itemProps, propsConfig?.config),
253
+ accordionItemConfig
254
+ );
255
+ const [{ onHidden$, onShown$ }] = writablesForProps(
256
+ {
257
+ onHidden: defaultItemConfig.onHidden,
258
+ onShown: defaultItemConfig.onShown
259
+ },
260
+ { config: config2, props: propsConfig?.props }
261
+ );
262
+ const item = itemFactory({
263
+ config: config2,
264
+ props: {
265
+ ...propsConfig?.props,
266
+ onHidden: asWritable(
267
+ readable(() => {
268
+ onItemHidden$()(item.stores.id$());
269
+ onHidden$()?.();
270
+ }),
271
+ (val) => {
272
+ onItemHidden$.set(val);
273
+ }
274
+ ),
275
+ onShown: asWritable(
276
+ readable(() => {
277
+ onItemShown$()(item.stores.id$());
278
+ onShown$()?.();
279
+ }),
280
+ (val) => {
281
+ onItemShown$.set(val);
282
+ }
283
+ )
284
+ }
285
+ });
286
+ item.directives.itemDirective = mergeDirectives(
287
+ () => ({
288
+ destroy: itemWidgets$.register(item)
289
+ }),
290
+ createAttributesDirective(() => ({
291
+ attributes: { class: item.stores.className$, id: item.stores.id$ }
292
+ }))
293
+ );
294
+ return item;
295
+ }
296
+ },
297
+ directives: {
298
+ accordionDirective: mergeDirectives(
299
+ directiveSubscribe(action$),
300
+ createAttributesDirective(() => ({
301
+ attributes: { class: className$ },
302
+ classNames: { "au-accordion": true$ }
303
+ }))
304
+ )
305
+ }
306
+ };
307
+ });
308
+ }
309
+ const createAccordion = factoryCreateAccordion();
310
+ export {
311
+ createAccordionItem as a,
312
+ createAccordion as c,
313
+ factoryCreateAccordion as f,
314
+ getAccordionDefaultConfig as g
315
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ const common = require("./common-B5jS-Ih_.cjs");
3
+ const utils_widget = require("./utils/widget.cjs");
4
+ function getAlertDefaultConfig() {
5
+ return { ...common.getCommonAlertDefaultConfig() };
6
+ }
7
+ const createAlert = utils_widget.createWidgetFactory("alert", common.createCommonAlert);
8
+ exports.createAlert = createAlert;
9
+ exports.getAlertDefaultConfig = getAlertDefaultConfig;
@@ -0,0 +1,10 @@
1
+ import { g as getCommonAlertDefaultConfig, c as createCommonAlert } from "./common-DFyZvkII.js";
2
+ import { createWidgetFactory } from "./utils/widget.js";
3
+ function getAlertDefaultConfig() {
4
+ return { ...getCommonAlertDefaultConfig() };
5
+ }
6
+ const createAlert = createWidgetFactory("alert", createCommonAlert);
7
+ export {
8
+ createAlert as c,
9
+ getAlertDefaultConfig as g
10
+ };