@design-factory/core 21.1.0 → 22.0.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.
- package/{accordion-D9ba0XYq.js → accordion-DUFLBQkV.js} +90 -28
- package/alert-Db6cG6JE.js +125 -0
- package/{collapse-Bn8iHKrd.js → collapse-D8Jo56k9.js} +2 -2
- package/{common-DFyZvkII.js → common-CP4amR0Z.js} +2 -2
- package/components/accordion/accordion.d.ts +80 -22
- package/components/accordion/index.js +1 -1
- package/components/alert/alert.d.ts +77 -8
- package/components/alert/common.d.ts +9 -9
- package/components/alert/index.js +2 -3
- package/components/carousel/index.js +2 -2
- package/components/collapse/index.js +1 -1
- package/components/drawer/drawer.d.ts +13 -0
- package/components/drawer/index.js +1 -1
- package/components/dropdown/dropdown.d.ts +110 -0
- package/components/dropdown/index.d.ts +1 -0
- package/components/dropdown/index.js +5 -0
- package/components/modal/index.js +1 -1
- package/components/pagination/index.js +1 -1
- package/components/progressbar/index.js +1 -1
- package/components/rating/index.js +1 -1
- package/components/slider/index.js +1 -1
- package/components/slider/slider.d.ts +23 -4
- package/components/toast/index.js +1 -1
- package/components/tooltip/index.d.ts +1 -0
- package/components/tooltip/index.js +174 -0
- package/components/tooltip/tooltip.d.ts +63 -0
- package/components/tree/index.js +1 -1
- package/{directive-CNNSo5Yn.js → directive-CMT2vEDg.js} +7 -4
- package/{drawer-CoBXUPyv.js → drawer-D4xSbhcT.js} +19 -5
- package/dropdown-Bjj2ql6d.js +246 -0
- package/index.d.ts +3 -1
- package/index.js +45 -39
- package/isFocusable-C2iRr0zh.js +72 -0
- package/{modal-BH9nrwVz.js → modal-CQWh2Sm5.js} +3 -3
- package/package.json +1 -1
- package/{pagination-BQWusWXN.js → pagination-DIRcpdRE.js} +2 -2
- package/{progressbar-S1pNn5rM.js → progressbar-Bth8r3Qu.js} +2 -2
- package/{promise-D-RZVPuv.js → promise-CkIc0KKt.js} +3 -3
- package/{rating-DWgGgwk3.js → rating-DLsgFSyB.js} +2 -2
- package/services/extendWidget.d.ts +1 -1
- package/services/focusElement.js +2 -2
- package/services/focustrack.js +2 -2
- package/services/matchMedia.js +1 -1
- package/services/mousetrack.d.ts +34 -0
- package/services/mousetrack.js +41 -0
- package/services/navManager.js +2 -2
- package/services/pointerdownPosition.js +1 -1
- package/services/portal.js +1 -1
- package/services/positioning.d.ts +101 -0
- package/services/positioning.js +104 -0
- package/services/resizeObserver.js +1 -1
- package/services/siblingsInert.js +1 -1
- package/services/transitions/baseTransitions.js +8 -8
- package/services/transitions/collapse.d.ts +4 -0
- package/services/transitions/collapse.js +23 -19
- package/services/transitions/cssTransitions.js +2 -2
- package/services/transitions/simpleClassTransition.js +1 -1
- package/{slider-Br_Qiopx.js → slider-tH5g55yQ.js} +132 -97
- package/{toaster-BUBzFeJM.js → toaster-BS9qeRLF.js} +3 -3
- package/{tree-vD7ZkV8Z.js → tree-DW6iLxdw.js} +2 -2
- package/types.d.ts +8 -1
- package/utils/debounceSignal.d.ts +11 -0
- package/utils/debounceSignal.js +18 -0
- package/utils/directive.js +1 -1
- package/utils/edgeState.d.ts +23 -0
- package/utils/edgeState.js +43 -0
- package/utils/internal/isFocusable.d.ts +40 -0
- package/utils/stores.d.ts +2 -16
- package/utils/stores.js +5 -24
- package/utils/writables.d.ts +27 -13
- package/utils/writables.js +12 -11
- package/{writables-DYGjj5T3.js → writables-_7BriMb2.js} +37 -12
- package/accordion-B0vs8JWM.cjs +0 -314
- package/alert-AhaliJ17.cjs +0 -9
- package/alert-Cb9FhbFQ.js +0 -10
- package/collapse-BnWw4Hnc.cjs +0 -94
- package/common-B5jS-Ih_.cjs +0 -73
- package/components/accordion/index.cjs +0 -7
- package/components/alert/index.cjs +0 -5
- package/components/carousel/index.cjs +0 -292
- package/components/collapse/index.cjs +0 -5
- package/components/drawer/index.cjs +0 -5
- package/components/modal/index.cjs +0 -8
- package/components/pagination/index.cjs +0 -5
- package/components/progressbar/index.cjs +0 -5
- package/components/rating/index.cjs +0 -5
- package/components/slider/index.cjs +0 -5
- package/components/toast/index.cjs +0 -7
- package/components/tree/index.cjs +0 -5
- package/config.cjs +0 -36
- package/directive-DyTodNPd.cjs +0 -523
- package/drawer-Ca_ktkEs.cjs +0 -328
- package/index.cjs +0 -134
- package/isFocusable-Ckwus82R.js +0 -32
- package/isFocusable-DfzDLeAN.cjs +0 -31
- package/modal-Dxdw2Pkv.cjs +0 -252
- package/pagination-BLVa1UsZ.cjs +0 -254
- package/progressbar-RopgvVeA.cjs +0 -86
- package/promise-CxCD3NYv.cjs +0 -118
- package/rating-DZ3OQgtt.cjs +0 -183
- package/scrollbars-f651ntzz.cjs +0 -33
- package/services/extendWidget.cjs +0 -41
- package/services/floatingUI.cjs +0 -111
- package/services/floatingUI.d.ts +0 -76
- package/services/floatingUI.js +0 -111
- package/services/focusElement.cjs +0 -46
- package/services/focustrack.cjs +0 -47
- package/services/hash.cjs +0 -15
- package/services/intersection.cjs +0 -53
- package/services/matchMedia.cjs +0 -14
- package/services/navManager.cjs +0 -166
- package/services/pointerdownPosition.cjs +0 -60
- package/services/portal.cjs +0 -42
- package/services/resizeObserver.cjs +0 -54
- package/services/siblingsInert.cjs +0 -44
- package/services/transitions/baseTransitions.cjs +0 -186
- package/services/transitions/collapse.cjs +0 -40
- package/services/transitions/cssTransitions.cjs +0 -32
- package/services/transitions/simpleClassTransition.cjs +0 -37
- package/slider-pgDq1V5r.cjs +0 -807
- package/textDirection-zqcZ5-eK.cjs +0 -3
- package/toaster-Dlube4Ya.cjs +0 -161
- package/tree-Chcy4ulJ.cjs +0 -228
- package/types.cjs +0 -6
- package/utils/directive.cjs +0 -28
- package/utils/func.cjs +0 -7
- package/utils/id.cjs +0 -5
- package/utils/stores.cjs +0 -172
- package/utils/widget.cjs +0 -8
- package/utils/writables.cjs +0 -16
- package/writables-Dt68gADJ.cjs +0 -102
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { writablesForProps, idWithDefault, stateStores,
|
|
1
|
+
import { writablesForProps, idWithDefault, stateStores, mergeConfigStores, normalizeConfigStores } from "./utils/stores.js";
|
|
2
2
|
import { createTransition } from "./services/transitions/baseTransitions.js";
|
|
3
|
+
import { createCollapseTransition } from "./services/transitions/collapse.js";
|
|
3
4
|
import { writable, computed, readable, asWritable } from "@amadeus-it-group/tansu";
|
|
4
5
|
import { noop } from "./utils/func.js";
|
|
5
|
-
import {
|
|
6
|
-
import { s as mergeDirectives, g as createAttributesDirective, u as registrationArray, o as directiveSubscribe } from "./directive-
|
|
6
|
+
import { k as typeString, d as typeBoolean, f as typeFunction, c as createTypeEnum } from "./writables-_7BriMb2.js";
|
|
7
|
+
import { s as mergeDirectives, g as createAttributesDirective, u as registrationArray, o as directiveSubscribe } from "./directive-CMT2vEDg.js";
|
|
7
8
|
import { createWidgetFactory } from "./utils/widget.js";
|
|
8
9
|
function adjustItemsCloseOthers(items, openItems, oldOpen) {
|
|
9
10
|
let keepOpen;
|
|
@@ -15,8 +16,8 @@ function adjustItemsCloseOthers(items, openItems, oldOpen) {
|
|
|
15
16
|
}
|
|
16
17
|
if (keepOpen) {
|
|
17
18
|
items.forEach((item) => {
|
|
18
|
-
if (item.stores.id$() !== keepOpen && item.stores.
|
|
19
|
-
item.patch({
|
|
19
|
+
if (item.stores.id$() !== keepOpen && item.stores.expanded$()) {
|
|
20
|
+
item.patch({ expanded: false });
|
|
20
21
|
}
|
|
21
22
|
});
|
|
22
23
|
}
|
|
@@ -25,31 +26,44 @@ function adjustItemsCloseOthers(items, openItems, oldOpen) {
|
|
|
25
26
|
function getItem(items, id) {
|
|
26
27
|
return items.find((item) => item.stores.id$() === id);
|
|
27
28
|
}
|
|
29
|
+
const accordionItemCollapseTransition = createCollapseTransition({
|
|
30
|
+
showClasses: ["df-collapse-show"],
|
|
31
|
+
hideClasses: ["df-collapse-hide"],
|
|
32
|
+
animationPendingClasses: ["df-collapse-collapsing"]
|
|
33
|
+
});
|
|
28
34
|
const defaultAccordionConfig = {
|
|
29
35
|
closeOthers: false,
|
|
36
|
+
selectable: false,
|
|
30
37
|
onItemShown: noop,
|
|
31
38
|
onItemHidden: noop,
|
|
32
39
|
className: "",
|
|
33
40
|
itemDestroyOnHide: true,
|
|
34
|
-
|
|
41
|
+
animated: true,
|
|
35
42
|
itemTransition: noop,
|
|
36
43
|
itemHeadingLevel: 2,
|
|
37
44
|
itemClassName: "",
|
|
38
45
|
itemHeaderClassName: "",
|
|
39
46
|
itemButtonClassName: "",
|
|
40
47
|
itemBodyContainerClassName: "",
|
|
41
|
-
itemBodyClassName: ""
|
|
48
|
+
itemBodyClassName: "",
|
|
49
|
+
size: "md",
|
|
50
|
+
arrowPosition: "end",
|
|
51
|
+
addon: "none",
|
|
52
|
+
subtitleType: "none",
|
|
53
|
+
separator: false,
|
|
54
|
+
ariaToggleButtonLabel: "Toggle item",
|
|
55
|
+
id: ""
|
|
42
56
|
};
|
|
43
57
|
const defaultItemConfig = {
|
|
44
58
|
id: "",
|
|
45
59
|
destroyOnHide: defaultAccordionConfig.itemDestroyOnHide,
|
|
46
60
|
disabled: false,
|
|
47
|
-
|
|
48
|
-
animated: defaultAccordionConfig.
|
|
61
|
+
expanded: false,
|
|
62
|
+
animated: defaultAccordionConfig.animated,
|
|
49
63
|
transition: defaultAccordionConfig.itemTransition,
|
|
50
64
|
onShown: noop,
|
|
51
65
|
onHidden: noop,
|
|
52
|
-
|
|
66
|
+
onExpandedChange: noop,
|
|
53
67
|
className: defaultAccordionConfig.itemClassName,
|
|
54
68
|
headerClassName: defaultAccordionConfig.itemHeaderClassName,
|
|
55
69
|
buttonClassName: defaultAccordionConfig.itemButtonClassName,
|
|
@@ -63,29 +77,37 @@ function getAccordionDefaultConfig() {
|
|
|
63
77
|
}
|
|
64
78
|
const configAccordionValidator = {
|
|
65
79
|
closeOthers: typeBoolean,
|
|
80
|
+
selectable: typeBoolean,
|
|
66
81
|
onItemShown: typeFunction,
|
|
67
82
|
onItemHidden: typeFunction,
|
|
68
83
|
className: typeString,
|
|
69
84
|
itemDestroyOnHide: typeBoolean,
|
|
70
|
-
|
|
85
|
+
animated: typeBoolean,
|
|
71
86
|
itemTransition: typeFunction,
|
|
72
87
|
itemClassName: typeString,
|
|
73
88
|
itemHeaderClassName: typeString,
|
|
74
89
|
itemButtonClassName: typeString,
|
|
75
90
|
itemBodyContainerClassName: typeString,
|
|
76
91
|
itemBodyClassName: typeString,
|
|
77
|
-
itemHeadingLevel: createTypeEnum([1, 2, 3, 4, 5, 6])
|
|
92
|
+
itemHeadingLevel: createTypeEnum([1, 2, 3, 4, 5, 6]),
|
|
93
|
+
size: createTypeEnum(["sm", "md", "lg"]),
|
|
94
|
+
arrowPosition: createTypeEnum(["start", "end"]),
|
|
95
|
+
addon: createTypeEnum(["none", "icon", "number"]),
|
|
96
|
+
subtitleType: createTypeEnum(["none", "inline", "block"]),
|
|
97
|
+
separator: typeBoolean,
|
|
98
|
+
ariaToggleButtonLabel: typeString,
|
|
99
|
+
id: typeString
|
|
78
100
|
};
|
|
79
101
|
const configItemValidator = {
|
|
80
102
|
id: typeString,
|
|
81
103
|
destroyOnHide: typeBoolean,
|
|
82
104
|
disabled: typeBoolean,
|
|
83
|
-
|
|
105
|
+
expanded: typeBoolean,
|
|
84
106
|
animated: typeBoolean,
|
|
85
107
|
transition: typeFunction,
|
|
86
108
|
onShown: typeFunction,
|
|
87
109
|
onHidden: typeFunction,
|
|
88
|
-
|
|
110
|
+
onExpandedChange: typeFunction,
|
|
89
111
|
className: typeString,
|
|
90
112
|
headerClassName: typeString,
|
|
91
113
|
buttonClassName: typeString,
|
|
@@ -105,8 +127,8 @@ function createAccordionItem(config) {
|
|
|
105
127
|
destroyOnHide$,
|
|
106
128
|
onShown$,
|
|
107
129
|
onHidden$,
|
|
108
|
-
|
|
109
|
-
|
|
130
|
+
onExpandedChange$,
|
|
131
|
+
expanded$: requestedExpanded$,
|
|
110
132
|
id$: _dirtyId$,
|
|
111
133
|
disabled$,
|
|
112
134
|
...stateProps
|
|
@@ -118,8 +140,8 @@ function createAccordionItem(config) {
|
|
|
118
140
|
const transition = createTransition({
|
|
119
141
|
props: {
|
|
120
142
|
transition: transition$,
|
|
121
|
-
visible:
|
|
122
|
-
onVisibleChange:
|
|
143
|
+
visible: requestedExpanded$,
|
|
144
|
+
onVisibleChange: onExpandedChange$,
|
|
123
145
|
animated: animated$,
|
|
124
146
|
animatedOnInit: false,
|
|
125
147
|
initDone: initDone$,
|
|
@@ -131,16 +153,17 @@ function createAccordionItem(config) {
|
|
|
131
153
|
}
|
|
132
154
|
}
|
|
133
155
|
});
|
|
156
|
+
const expanded$ = transition.stores.visible$;
|
|
134
157
|
const shouldBeInDOM$ = computed(() => !destroyOnHide$() || !transition.stores.hidden$());
|
|
135
158
|
const toggleDirective = createAttributesDirective(() => ({
|
|
136
159
|
attributes: {
|
|
137
160
|
id: computed(() => `${id$()}-toggle`),
|
|
138
|
-
"aria-expanded": computed(() => `${
|
|
161
|
+
"aria-expanded": computed(() => `${expanded$()}`),
|
|
139
162
|
"aria-disabled": computed(() => `${disabled$()}`),
|
|
140
163
|
"aria-controls": computed(() => `${id$()}-body-container`),
|
|
141
164
|
disabled: disabled$
|
|
142
165
|
},
|
|
143
|
-
classNames: { collapsed: computed(() => !
|
|
166
|
+
classNames: { "df-collapsed": computed(() => !expanded$()) },
|
|
144
167
|
events: {
|
|
145
168
|
click: () => {
|
|
146
169
|
if (!disabled$()) {
|
|
@@ -160,7 +183,7 @@ function createAccordionItem(config) {
|
|
|
160
183
|
}));
|
|
161
184
|
return {
|
|
162
185
|
...stateStores({
|
|
163
|
-
|
|
186
|
+
expanded$,
|
|
164
187
|
id$,
|
|
165
188
|
shouldBeInDOM$,
|
|
166
189
|
disabled$,
|
|
@@ -202,15 +225,35 @@ function createAccordionItem(config) {
|
|
|
202
225
|
function factoryCreateAccordion(itemFactory = createAccordionItem, accordionItemProps = coreAccordionItemProps, accordionConfig = defaultAccordionConfig, accordionValidator = configAccordionValidator) {
|
|
203
226
|
return createWidgetFactory("accordion", (config) => {
|
|
204
227
|
const [writables, patch] = writablesForProps(accordionConfig, config, accordionValidator);
|
|
205
|
-
const {
|
|
228
|
+
const {
|
|
229
|
+
closeOthers$,
|
|
230
|
+
selectable$,
|
|
231
|
+
onItemShown$,
|
|
232
|
+
onItemHidden$,
|
|
233
|
+
className$,
|
|
234
|
+
size$,
|
|
235
|
+
addon$,
|
|
236
|
+
subtitleType$,
|
|
237
|
+
separator$,
|
|
238
|
+
animated$,
|
|
239
|
+
id$: _dirtyId$,
|
|
240
|
+
...stateStores$
|
|
241
|
+
} = writables;
|
|
242
|
+
const id$ = idWithDefault(_dirtyId$);
|
|
206
243
|
const accordionItemConfig = Object.fromEntries(
|
|
207
244
|
Object.entries(writables).filter((entry) => entry[0].startsWith("item")).map((entry) => [entry[0].charAt(4).toLowerCase() + entry[0].slice(5, -1), entry[1]])
|
|
208
245
|
);
|
|
246
|
+
const accordionClassName$ = computed(() => {
|
|
247
|
+
const size = size$();
|
|
248
|
+
const sizeClass = size === "sm" ? "df-accordion-sm " : size === "lg" ? "df-accordion-lg " : "";
|
|
249
|
+
const separatorClass = separator$() ? "df-accordion-separator " : "";
|
|
250
|
+
return `${sizeClass}${separatorClass}`.trim();
|
|
251
|
+
});
|
|
209
252
|
const itemWidgets$ = registrationArray();
|
|
210
253
|
const openItems$ = computed(() => {
|
|
211
254
|
const openItems = [];
|
|
212
255
|
itemWidgets$().forEach((item) => {
|
|
213
|
-
if (item.stores.
|
|
256
|
+
if (item.stores.expanded$()) {
|
|
214
257
|
openItems.push(item.stores.id$());
|
|
215
258
|
}
|
|
216
259
|
});
|
|
@@ -218,7 +261,7 @@ function factoryCreateAccordion(itemFactory = createAccordionItem, accordionItem
|
|
|
218
261
|
});
|
|
219
262
|
const oldOpenItem$ = writable(openItems$()[0]);
|
|
220
263
|
const checkCloseOthersAction$ = computed(() => {
|
|
221
|
-
if (closeOthers$()) {
|
|
264
|
+
if (selectable$() || closeOthers$()) {
|
|
222
265
|
adjustItemsCloseOthers(itemWidgets$(), openItems$(), oldOpenItem$());
|
|
223
266
|
oldOpenItem$.set(openItems$()[0]);
|
|
224
267
|
}
|
|
@@ -227,22 +270,39 @@ function factoryCreateAccordion(itemFactory = createAccordionItem, accordionItem
|
|
|
227
270
|
checkCloseOthersAction$();
|
|
228
271
|
});
|
|
229
272
|
return {
|
|
230
|
-
...stateStores({
|
|
273
|
+
...stateStores({
|
|
274
|
+
itemWidgets$,
|
|
275
|
+
className$,
|
|
276
|
+
size$,
|
|
277
|
+
addon$,
|
|
278
|
+
subtitleType$,
|
|
279
|
+
separator$,
|
|
280
|
+
animated$,
|
|
281
|
+
accordionClassName$,
|
|
282
|
+
id$,
|
|
283
|
+
...stateStores$
|
|
284
|
+
}),
|
|
231
285
|
patch,
|
|
232
286
|
api: {
|
|
233
287
|
expand: async (id, animated) => {
|
|
234
288
|
await getItem(itemWidgets$(), id)?.api.expand(animated);
|
|
235
289
|
},
|
|
236
290
|
collapse: async (id, animated) => {
|
|
291
|
+
if (selectable$()) return;
|
|
237
292
|
await getItem(itemWidgets$(), id)?.api.collapse(animated);
|
|
238
293
|
},
|
|
239
294
|
toggle: async (id, animated) => {
|
|
240
|
-
|
|
295
|
+
if (selectable$()) {
|
|
296
|
+
await getItem(itemWidgets$(), id)?.api.expand(animated);
|
|
297
|
+
} else {
|
|
298
|
+
await getItem(itemWidgets$(), id)?.api.toggle(animated);
|
|
299
|
+
}
|
|
241
300
|
},
|
|
242
301
|
expandAll: async (animated) => {
|
|
243
302
|
await Promise.all(itemWidgets$().map((i) => i.api.expand(animated)));
|
|
244
303
|
},
|
|
245
304
|
collapseAll: async (animated) => {
|
|
305
|
+
if (selectable$()) return;
|
|
246
306
|
await Promise.all(itemWidgets$().map((i) => i.api.collapse(animated)));
|
|
247
307
|
},
|
|
248
308
|
registerItem: (propsConfig) => {
|
|
@@ -257,12 +317,15 @@ function factoryCreateAccordion(itemFactory = createAccordionItem, accordionItem
|
|
|
257
317
|
onHidden: defaultItemConfig.onHidden,
|
|
258
318
|
onShown: defaultItemConfig.onShown
|
|
259
319
|
},
|
|
320
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
260
321
|
{ config: config2, props: propsConfig?.props }
|
|
261
322
|
);
|
|
262
323
|
const item = itemFactory({
|
|
263
324
|
config: config2,
|
|
264
325
|
props: {
|
|
326
|
+
transition: accordionItemCollapseTransition,
|
|
265
327
|
...propsConfig?.props,
|
|
328
|
+
animated: animated$,
|
|
266
329
|
onHidden: asWritable(
|
|
267
330
|
readable(() => {
|
|
268
331
|
onItemHidden$()(item.stores.id$());
|
|
@@ -298,8 +361,7 @@ function factoryCreateAccordion(itemFactory = createAccordionItem, accordionItem
|
|
|
298
361
|
accordionDirective: mergeDirectives(
|
|
299
362
|
directiveSubscribe(action$),
|
|
300
363
|
createAttributesDirective(() => ({
|
|
301
|
-
attributes: { class: className$ }
|
|
302
|
-
classNames: { "au-accordion": true$ }
|
|
364
|
+
attributes: { class: className$ }
|
|
303
365
|
}))
|
|
304
366
|
)
|
|
305
367
|
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { computed } from "@amadeus-it-group/tansu";
|
|
2
|
+
import { c as createCommonAlert } from "./common-CP4amR0Z.js";
|
|
3
|
+
import { c as createCollapse } from "./collapse-D8Jo56k9.js";
|
|
4
|
+
import { createCollapseTransition } from "./services/transitions/collapse.js";
|
|
5
|
+
import { createSimpleClassTransition } from "./services/transitions/simpleClassTransition.js";
|
|
6
|
+
import { extendWidgetProps } from "./services/extendWidget.js";
|
|
7
|
+
import { noop } from "./utils/func.js";
|
|
8
|
+
import { stateStores } from "./utils/stores.js";
|
|
9
|
+
import { f as typeFunction, d as typeBoolean, k as typeString, c as createTypeEnum, t as testToNormalizeValue } from "./writables-_7BriMb2.js";
|
|
10
|
+
import { createWidgetFactory } from "./utils/widget.js";
|
|
11
|
+
const alertRoles = {
|
|
12
|
+
success: "status",
|
|
13
|
+
info: "status",
|
|
14
|
+
tip: "status",
|
|
15
|
+
warning: "alert",
|
|
16
|
+
danger: "alert"
|
|
17
|
+
};
|
|
18
|
+
const typeIcons = {
|
|
19
|
+
normalizeValue: testToNormalizeValue(
|
|
20
|
+
(value) => !!value && typeof value === "object" && !Array.isArray(value)
|
|
21
|
+
)
|
|
22
|
+
};
|
|
23
|
+
const alertCollapseTransition = createCollapseTransition({
|
|
24
|
+
showClasses: ["df-collapse-show"],
|
|
25
|
+
hideClasses: ["df-collapse-hide"],
|
|
26
|
+
animationPendingClasses: ["df-collapse-collapsing"]
|
|
27
|
+
});
|
|
28
|
+
const alertFadeTransition = createSimpleClassTransition({
|
|
29
|
+
animationPendingClasses: ["df-fade"],
|
|
30
|
+
animationPendingShowClasses: ["df-show"],
|
|
31
|
+
showClasses: ["df-show", "df-fade"],
|
|
32
|
+
hideClasses: ["df-hidden", "df-fade"]
|
|
33
|
+
});
|
|
34
|
+
const alertDefaultConfig = {
|
|
35
|
+
type: "warning",
|
|
36
|
+
appearance: "default",
|
|
37
|
+
size: "md",
|
|
38
|
+
icons: {
|
|
39
|
+
success: "fa-solid fa-check-circle",
|
|
40
|
+
warning: "fa-solid fa-exclamation-triangle",
|
|
41
|
+
danger: "fa-solid fa-octagon-xmark",
|
|
42
|
+
tip: "fa-solid fa-lightbulb",
|
|
43
|
+
info: "fa-solid fa-info-circle",
|
|
44
|
+
default: "fa-solid fa-info-circle"
|
|
45
|
+
},
|
|
46
|
+
collapseIcon: "fa-light fa-chevron-up",
|
|
47
|
+
expandIcon: "fa-light fa-chevron-down",
|
|
48
|
+
expandLabel: "Show more",
|
|
49
|
+
collapseLabel: "See less",
|
|
50
|
+
expandable: false,
|
|
51
|
+
expanded: false,
|
|
52
|
+
onCollapsed: noop,
|
|
53
|
+
onExpanded: noop
|
|
54
|
+
};
|
|
55
|
+
const alertConfigValidator = {
|
|
56
|
+
type: createTypeEnum(["success", "info", "warning", "danger", "tip"]),
|
|
57
|
+
appearance: createTypeEnum(["default", "banner"]),
|
|
58
|
+
size: createTypeEnum(["sm", "md", "lg"]),
|
|
59
|
+
icons: typeIcons,
|
|
60
|
+
collapseIcon: typeString,
|
|
61
|
+
expandIcon: typeString,
|
|
62
|
+
expandLabel: typeString,
|
|
63
|
+
collapseLabel: typeString,
|
|
64
|
+
expandable: typeBoolean,
|
|
65
|
+
expanded: typeBoolean,
|
|
66
|
+
onCollapsed: typeFunction,
|
|
67
|
+
onExpanded: typeFunction
|
|
68
|
+
};
|
|
69
|
+
const createExtendedAlert = extendWidgetProps(
|
|
70
|
+
createCommonAlert,
|
|
71
|
+
alertDefaultConfig,
|
|
72
|
+
alertConfigValidator,
|
|
73
|
+
{
|
|
74
|
+
transition: alertFadeTransition
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
const createAlert = createWidgetFactory(
|
|
78
|
+
"alert",
|
|
79
|
+
(config) => {
|
|
80
|
+
const extendedAlert = createExtendedAlert(config);
|
|
81
|
+
const { onCollapsed$, onExpanded$, ...extendedAlertStores } = extendedAlert.stores;
|
|
82
|
+
const { icons$, type$, animated$, expandable$, expanded$: requestedExpanded$ } = extendedAlertStores;
|
|
83
|
+
const collapse = createCollapse({
|
|
84
|
+
config: {
|
|
85
|
+
visible: computed(() => expandable$() ? requestedExpanded$() : true),
|
|
86
|
+
animated: animated$,
|
|
87
|
+
animatedOnInit: false,
|
|
88
|
+
transition: alertCollapseTransition,
|
|
89
|
+
onHidden: () => {
|
|
90
|
+
if (expandable$()) {
|
|
91
|
+
onCollapsed$()();
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
onShown: () => {
|
|
95
|
+
if (expandable$()) {
|
|
96
|
+
onExpanded$()();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const expanded$ = computed(() => expandable$() ? collapse.stores.visible$() : false);
|
|
102
|
+
const icon$ = computed(() => {
|
|
103
|
+
const icons = icons$();
|
|
104
|
+
return icons[type$()] ?? icons.default ?? "";
|
|
105
|
+
});
|
|
106
|
+
const role$ = computed(() => alertRoles[type$()]);
|
|
107
|
+
return {
|
|
108
|
+
...extendedAlert,
|
|
109
|
+
...stateStores({
|
|
110
|
+
...extendedAlertStores,
|
|
111
|
+
expanded$,
|
|
112
|
+
icon$,
|
|
113
|
+
role$
|
|
114
|
+
}),
|
|
115
|
+
directives: {
|
|
116
|
+
...extendedAlert.directives,
|
|
117
|
+
collapseDirective: collapse.directives.collapseDirective,
|
|
118
|
+
collapseTriggerDirective: collapse.directives.triggerDirective
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
export {
|
|
124
|
+
createAlert as c
|
|
125
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createTransition } from "./services/transitions/baseTransitions.js";
|
|
2
2
|
import { writablesForProps, idWithDefault, stateStores } from "./utils/stores.js";
|
|
3
|
-
import { g as createAttributesDirective, s as mergeDirectives } from "./directive-
|
|
4
|
-
import {
|
|
3
|
+
import { g as createAttributesDirective, s as mergeDirectives } from "./directive-CMT2vEDg.js";
|
|
4
|
+
import { f as typeFunction, k as typeString, d as typeBoolean } from "./writables-_7BriMb2.js";
|
|
5
5
|
import { computed } from "@amadeus-it-group/tansu";
|
|
6
6
|
import { noop } from "./utils/func.js";
|
|
7
7
|
import { createWidgetFactory } from "./utils/widget.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createTransition } from "./services/transitions/baseTransitions.js";
|
|
2
2
|
import { noop } from "./utils/func.js";
|
|
3
3
|
import { writablesForProps, stateStores } from "./utils/stores.js";
|
|
4
|
-
import {
|
|
4
|
+
import { k as typeString, d as typeBoolean, f as typeFunction } from "./writables-_7BriMb2.js";
|
|
5
5
|
const defaultCommonAlertConfig = {
|
|
6
6
|
visible: true,
|
|
7
7
|
dismissible: true,
|
|
@@ -57,7 +57,7 @@ function createCommonAlert(config) {
|
|
|
57
57
|
const visible$ = transition.stores.visible$;
|
|
58
58
|
const hidden$ = transition.stores.hidden$;
|
|
59
59
|
return {
|
|
60
|
-
...stateStores({ ...stateProps, visible$, hidden$ }),
|
|
60
|
+
...stateStores({ ...stateProps, animated$, visible$, hidden$ }),
|
|
61
61
|
patch,
|
|
62
62
|
api: {
|
|
63
63
|
open: transition.api.show,
|
|
@@ -1,16 +1,82 @@
|
|
|
1
1
|
import type { TransitionFn } from '../../services/transitions/baseTransitions';
|
|
2
2
|
import type { ConfigValidator, Directive, PropsConfig, Widget, WidgetFactory } from '../../types';
|
|
3
3
|
import type { WidgetsCommonPropsAndState } from '../commonProps';
|
|
4
|
+
/**
|
|
5
|
+
* Interface representing the common properties and state for an accordion.
|
|
6
|
+
*/
|
|
7
|
+
interface AccordionCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
8
|
+
/**
|
|
9
|
+
* Defines how the subtitle is displayed on accordion items.
|
|
10
|
+
*
|
|
11
|
+
* @defaultValue `'none'`
|
|
12
|
+
*/
|
|
13
|
+
subtitleType: 'none' | 'inline' | 'block';
|
|
14
|
+
/**
|
|
15
|
+
* The HTML heading level to use for the accordion-item-header.
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue `2`
|
|
18
|
+
*/
|
|
19
|
+
itemHeadingLevel: 1 | 2 | 3 | 4 | 5 | 6;
|
|
20
|
+
/**
|
|
21
|
+
* Accessibility label for the accordion-item toggle button in the interactive variant.
|
|
22
|
+
*
|
|
23
|
+
* @defaultValue `'Toggle item'`
|
|
24
|
+
*/
|
|
25
|
+
ariaToggleButtonLabel: string;
|
|
26
|
+
/**
|
|
27
|
+
* The size of the accordion.
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue `'md'`
|
|
30
|
+
*/
|
|
31
|
+
size: 'sm' | 'md' | 'lg';
|
|
32
|
+
/**
|
|
33
|
+
* Position of the expandable icon on the accordion header.
|
|
34
|
+
*
|
|
35
|
+
* @defaultValue `'end'`
|
|
36
|
+
*/
|
|
37
|
+
arrowPosition: 'start' | 'end';
|
|
38
|
+
/**
|
|
39
|
+
* Addon type to show on the left side of the accordion header.
|
|
40
|
+
*
|
|
41
|
+
* @defaultValue `'none'`
|
|
42
|
+
*/
|
|
43
|
+
addon: 'none' | 'icon' | 'number';
|
|
44
|
+
/**
|
|
45
|
+
* When an item is expanded, a separator line is shown below the item header.
|
|
46
|
+
*
|
|
47
|
+
* @defaultValue `false`
|
|
48
|
+
*/
|
|
49
|
+
separator: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The id of the accordion. It is used in the accordion selectable variant.
|
|
52
|
+
*
|
|
53
|
+
* @defaultValue `dfId-[number]`
|
|
54
|
+
*/
|
|
55
|
+
id: string;
|
|
56
|
+
/**
|
|
57
|
+
* If `true`, accordion items will be animated.
|
|
58
|
+
*
|
|
59
|
+
* @defaultValue `true`
|
|
60
|
+
*/
|
|
61
|
+
animated: boolean;
|
|
62
|
+
}
|
|
4
63
|
/**
|
|
5
64
|
* Properties for the Accordion component.
|
|
6
65
|
*/
|
|
7
|
-
export interface AccordionProps extends
|
|
66
|
+
export interface AccordionProps extends AccordionCommonPropsAndState {
|
|
8
67
|
/**
|
|
9
68
|
* If `true`, only one accordion-item at the time can stay open.
|
|
10
69
|
*
|
|
11
70
|
* @defaultValue `false`
|
|
12
71
|
*/
|
|
13
72
|
closeOthers: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* If `true`, the accordion uses a radio-group pattern: `closeOthers` is always enforced
|
|
75
|
+
* and the last open item cannot be collapsed.
|
|
76
|
+
*
|
|
77
|
+
* @defaultValue `false`
|
|
78
|
+
*/
|
|
79
|
+
selectable: boolean;
|
|
14
80
|
/**
|
|
15
81
|
* An event fired when an item is shown.
|
|
16
82
|
*
|
|
@@ -39,12 +105,6 @@ export interface AccordionProps extends WidgetsCommonPropsAndState {
|
|
|
39
105
|
* @defaultValue `true`
|
|
40
106
|
*/
|
|
41
107
|
itemDestroyOnHide: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* If `true`, accordion-item will be animated.
|
|
44
|
-
*
|
|
45
|
-
* @defaultValue `true`
|
|
46
|
-
*/
|
|
47
|
-
itemAnimated: boolean;
|
|
48
108
|
/**
|
|
49
109
|
* The transition to use for the accordion-item body-container when the accordion-item is toggled.
|
|
50
110
|
*
|
|
@@ -85,21 +145,19 @@ export interface AccordionProps extends WidgetsCommonPropsAndState {
|
|
|
85
145
|
* @defaultValue `''`
|
|
86
146
|
*/
|
|
87
147
|
itemBodyClassName: string;
|
|
88
|
-
/**
|
|
89
|
-
* The html heading level to use for the accordion-item-header.
|
|
90
|
-
*
|
|
91
|
-
* @defaultValue `2`
|
|
92
|
-
*/
|
|
93
|
-
itemHeadingLevel: 1 | 2 | 3 | 4 | 5 | 6;
|
|
94
148
|
}
|
|
95
149
|
/**
|
|
96
150
|
* Represents the state of an Accordion component.
|
|
97
151
|
*/
|
|
98
|
-
export interface AccordionState extends
|
|
152
|
+
export interface AccordionState extends AccordionCommonPropsAndState {
|
|
99
153
|
/**
|
|
100
154
|
* Array containing all the accordion-items contained in the accordion.
|
|
101
155
|
*/
|
|
102
156
|
itemWidgets: AccordionItemWidget[];
|
|
157
|
+
/**
|
|
158
|
+
* Computed CSS class name for the accordion based on its visual configuration.
|
|
159
|
+
*/
|
|
160
|
+
accordionClassName: string;
|
|
103
161
|
}
|
|
104
162
|
/**
|
|
105
163
|
* Interface representing the API for an accordion component.
|
|
@@ -125,7 +183,7 @@ export interface AccordionApi {
|
|
|
125
183
|
* @returns A promise that resolves when the toggle operation is completed.
|
|
126
184
|
* If the itemId is not valid, nothing will happen.
|
|
127
185
|
*/
|
|
128
|
-
toggle(itemId: string): Promise<void>;
|
|
186
|
+
toggle(itemId: string, animated?: boolean): Promise<void>;
|
|
129
187
|
/**
|
|
130
188
|
* It will expand all the items in the accordion.
|
|
131
189
|
*
|
|
@@ -224,9 +282,9 @@ export interface AccordionItemDirectives {
|
|
|
224
282
|
*/
|
|
225
283
|
interface AccordionItemCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
226
284
|
/**
|
|
227
|
-
* If `true`, the accordion-item will be
|
|
285
|
+
* If `true`, the accordion-item will be expanded. Otherwise, it will be collapsed.
|
|
228
286
|
*/
|
|
229
|
-
|
|
287
|
+
expanded: boolean;
|
|
230
288
|
/**
|
|
231
289
|
* If `true`, the accordion-item will be disabled.
|
|
232
290
|
* It will not react to user's clicks, but still will be possible to toggle programmatically.
|
|
@@ -254,7 +312,7 @@ interface AccordionItemCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
|
254
312
|
*/
|
|
255
313
|
bodyClassName: string;
|
|
256
314
|
/**
|
|
257
|
-
* The
|
|
315
|
+
* The HTML heading level to use for the accordion-item-header.
|
|
258
316
|
*/
|
|
259
317
|
headingLevel: 1 | 2 | 3 | 4 | 5 | 6;
|
|
260
318
|
}
|
|
@@ -283,11 +341,11 @@ export interface AccordionItemProps extends AccordionItemCommonPropsAndState {
|
|
|
283
341
|
*/
|
|
284
342
|
onHidden: () => void;
|
|
285
343
|
/**
|
|
286
|
-
* An event fired when the `
|
|
344
|
+
* An event fired when the `expanded` value changes.
|
|
287
345
|
*
|
|
288
|
-
* Event payload is the new value of
|
|
346
|
+
* Event payload is the new value of expanded.
|
|
289
347
|
*/
|
|
290
|
-
|
|
348
|
+
onExpandedChange: (expanded: boolean) => void;
|
|
291
349
|
}
|
|
292
350
|
/**
|
|
293
351
|
* Represents the state of an accordion item.
|
|
@@ -295,7 +353,7 @@ export interface AccordionItemProps extends AccordionItemCommonPropsAndState {
|
|
|
295
353
|
export interface AccordionItemState extends AccordionItemCommonPropsAndState {
|
|
296
354
|
/**
|
|
297
355
|
* If `true` the content of the accordion-item collapse should be in DOM. Its value depends on the
|
|
298
|
-
* value of the `
|
|
356
|
+
* value of the `expanded` and `destroyOnHide`.
|
|
299
357
|
*/
|
|
300
358
|
shouldBeInDOM: boolean;
|
|
301
359
|
}
|