@agnos-ui/core 0.2.0 → 0.3.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/README.md +3 -3
- package/accordion-BaWN0_n-.js +330 -0
- package/accordion-BuIgxZ0S.cjs +329 -0
- package/alert-C4jCg9Pl.cjs +8 -0
- package/alert-Dlf-BV98.js +9 -0
- package/common-DRdsw5m8.js +76 -0
- package/common-nJRMXbwj.cjs +75 -0
- package/components/accordion/accordion.d.ts +38 -49
- package/components/accordion/index.cjs +7 -0
- package/components/accordion/index.js +7 -1
- package/components/alert/alert.d.ts +3 -12
- package/components/alert/common.d.ts +4 -13
- package/components/alert/index.cjs +10 -0
- package/components/alert/index.js +10 -2
- package/components/modal/index.cjs +7 -0
- package/components/modal/index.js +7 -1
- package/components/modal/modal.d.ts +7 -49
- package/components/pagination/index.cjs +5 -0
- package/components/pagination/index.d.ts +0 -1
- package/components/pagination/index.js +5 -2
- package/components/pagination/pagination.d.ts +68 -139
- package/components/progressbar/index.cjs +5 -0
- package/components/progressbar/index.js +5 -1
- package/components/progressbar/progressbar.d.ts +6 -22
- package/components/rating/index.cjs +5 -0
- package/components/rating/index.js +5 -1
- package/components/rating/rating.d.ts +16 -11
- package/components/select/index.cjs +6 -0
- package/components/select/index.js +6 -1
- package/components/select/select.d.ts +15 -33
- package/components/slider/index.cjs +5 -0
- package/components/slider/index.js +5 -1
- package/components/slider/slider.d.ts +29 -35
- package/components/toast/index.cjs +5 -0
- package/components/toast/index.js +5 -1
- package/components/toast/toast.d.ts +11 -8
- package/config.cjs +38 -0
- package/config.d.ts +1 -1
- package/config.js +35 -50
- package/directive-BTSEYLF3.cjs +404 -0
- package/directive-DCYlDznf.js +405 -0
- package/func-DR0n-ShK.js +7 -0
- package/func-Qd3cD9a3.cjs +6 -0
- package/index.cjs +119 -0
- package/index.d.ts +1 -1
- package/index.js +119 -33
- package/modal-BI2qUu1M.js +251 -0
- package/modal-rzMpATf5.cjs +250 -0
- package/package.json +29 -19
- package/pagination--GkwduJn.js +263 -0
- package/pagination-EWSWQT1I.cjs +262 -0
- package/progressbar-DH7DHYMp.cjs +83 -0
- package/progressbar-DuRX7_my.js +84 -0
- package/promise-BMJ8qhA8.cjs +118 -0
- package/promise-CY2U8bTP.js +119 -0
- package/rating-BR5wD7y2.js +173 -0
- package/rating-CmuYUSxy.cjs +172 -0
- package/select-BCs6HQWn.js +358 -0
- package/select-CCIKn8WR.cjs +357 -0
- package/services/extendWidget.cjs +32 -0
- package/services/extendWidget.d.ts +2 -1
- package/services/extendWidget.js +31 -34
- package/services/floatingUI.cjs +131 -0
- package/services/floatingUI.d.ts +30 -14
- package/services/floatingUI.js +128 -102
- package/services/focustrack.cjs +47 -0
- package/services/focustrack.js +45 -44
- package/services/hash.cjs +15 -0
- package/services/hash.js +14 -12
- package/services/intersection.cjs +53 -0
- package/services/intersection.js +48 -50
- package/services/matchMedia.cjs +13 -0
- package/services/matchMedia.d.ts +7 -0
- package/services/matchMedia.js +13 -0
- package/services/navManager.cjs +196 -0
- package/services/navManager.d.ts +9 -9
- package/services/navManager.js +186 -168
- package/services/portal.cjs +43 -0
- package/services/portal.js +41 -42
- package/services/resizeObserver.cjs +32 -0
- package/services/resizeObserver.d.ts +1 -1
- package/services/resizeObserver.js +31 -28
- package/services/siblingsInert.cjs +40 -0
- package/services/siblingsInert.js +31 -31
- package/services/transitions/baseTransitions.cjs +171 -0
- package/services/transitions/baseTransitions.d.ts +16 -16
- package/services/transitions/baseTransitions.js +159 -170
- package/services/transitions/collapse.cjs +44 -0
- package/services/transitions/collapse.js +41 -49
- package/services/transitions/cssTransitions.cjs +32 -0
- package/services/transitions/cssTransitions.d.ts +2 -1
- package/services/transitions/cssTransitions.js +29 -39
- package/services/transitions/simpleClassTransition.cjs +31 -0
- package/services/transitions/simpleClassTransition.js +30 -41
- package/slider-CA_fszn7.js +536 -0
- package/slider-DsLvT87U.cjs +535 -0
- package/toast-8tWp6x89.js +63 -0
- package/toast-Aw8o0Iwe.cjs +62 -0
- package/types.cjs +12 -0
- package/types.d.ts +21 -1
- package/types.js +11 -13
- package/utils/directive.cjs +26 -0
- package/utils/directive.d.ts +148 -5
- package/utils/directive.js +25 -205
- package/utils/internal/dom.d.ts +43 -4
- package/utils/internal/promise.d.ts +2 -2
- package/utils/internal/ssrHTMLElement.d.ts +7 -0
- package/utils/stores.cjs +163 -0
- package/utils/stores.d.ts +9 -17
- package/utils/stores.js +149 -284
- package/utils/writables.cjs +13 -0
- package/utils/writables.js +12 -71
- package/writables-D46sFgGK.cjs +85 -0
- package/writables-DoU_XYTX.js +86 -0
- package/components/accordion/accordion.js +0 -264
- package/components/alert/alert.js +0 -22
- package/components/alert/common.js +0 -69
- package/components/commonProps.js +0 -1
- package/components/modal/modal.js +0 -186
- package/components/pagination/bootstrap.d.ts +0 -8
- package/components/pagination/bootstrap.js +0 -110
- package/components/pagination/pagination.js +0 -195
- package/components/progressbar/progressbar.js +0 -78
- package/components/rating/rating.js +0 -137
- package/components/select/select.js +0 -297
- package/components/slider/slider.js +0 -420
- package/components/toast/toast.js +0 -43
- package/services/transitions/bootstrap/collapse.d.ts +0 -2
- package/services/transitions/bootstrap/collapse.js +0 -15
- package/services/transitions/bootstrap/fade.d.ts +0 -1
- package/services/transitions/bootstrap/fade.js +0 -7
- package/services/transitions/bootstrap.d.ts +0 -2
- package/services/transitions/bootstrap.js +0 -2
- package/utils/internal/checks.js +0 -60
- package/utils/internal/dom.js +0 -82
- package/utils/internal/func.js +0 -11
- package/utils/internal/isFocusable.js +0 -37
- package/utils/internal/math.js +0 -13
- package/utils/internal/promise.js +0 -169
- package/utils/internal/scrollbars.js +0 -33
- package/utils/internal/sort.js +0 -28
- package/utils/internal/textDirection.js +0 -7
- package/utils/internal/traversal.js +0 -105
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { INVALID_VALUE } from "./types.js";
|
|
2
|
+
function isNumber(value) {
|
|
3
|
+
return typeof value === "number" && !isNaN(value) && Number.isFinite(value);
|
|
4
|
+
}
|
|
5
|
+
function isBoolean(value) {
|
|
6
|
+
return value === true || value === false;
|
|
7
|
+
}
|
|
8
|
+
function isFunction(value) {
|
|
9
|
+
return typeof value === "function";
|
|
10
|
+
}
|
|
11
|
+
function isString(value) {
|
|
12
|
+
return typeof value === "string";
|
|
13
|
+
}
|
|
14
|
+
const isArray = Array.isArray;
|
|
15
|
+
function clamp(value, max, min = 0) {
|
|
16
|
+
return Math.max(Math.min(value, max), min);
|
|
17
|
+
}
|
|
18
|
+
const isHTMLElement = (value) => value instanceof HTMLElement;
|
|
19
|
+
const allowNull = (isType) => (value) => value === null || isType(value);
|
|
20
|
+
const testToNormalizeValue = (filter) => (value) => filter(value) ? value : INVALID_VALUE;
|
|
21
|
+
const numberNormalizeFn = testToNormalizeValue(isNumber);
|
|
22
|
+
const typeNumber = {
|
|
23
|
+
normalizeValue: numberNormalizeFn
|
|
24
|
+
};
|
|
25
|
+
function typeNumberInRangeFactory(min, max, options = {}) {
|
|
26
|
+
const { strict = false, useClamp = true } = options;
|
|
27
|
+
return {
|
|
28
|
+
normalizeValue: (value) => {
|
|
29
|
+
let normalizedNumber = numberNormalizeFn(value);
|
|
30
|
+
if (normalizedNumber !== INVALID_VALUE) {
|
|
31
|
+
if (!strict && useClamp) {
|
|
32
|
+
normalizedNumber = clamp(normalizedNumber, max, min);
|
|
33
|
+
}
|
|
34
|
+
if (normalizedNumber >= min && normalizedNumber <= max) {
|
|
35
|
+
if (!strict || normalizedNumber !== min && normalizedNumber !== max) {
|
|
36
|
+
return normalizedNumber;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return INVALID_VALUE;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const typeBoolean = {
|
|
45
|
+
normalizeValue: testToNormalizeValue(isBoolean)
|
|
46
|
+
};
|
|
47
|
+
const typeBooleanOrNull = {
|
|
48
|
+
normalizeValue: testToNormalizeValue(allowNull(isBoolean))
|
|
49
|
+
};
|
|
50
|
+
const typeString = {
|
|
51
|
+
normalizeValue: testToNormalizeValue(isString)
|
|
52
|
+
};
|
|
53
|
+
const typeFunction = {
|
|
54
|
+
normalizeValue: testToNormalizeValue(isFunction),
|
|
55
|
+
equal: Object.is
|
|
56
|
+
};
|
|
57
|
+
const typeHTMLElementOrNull = {
|
|
58
|
+
normalizeValue: testToNormalizeValue(allowNull(isHTMLElement)),
|
|
59
|
+
equal: Object.is
|
|
60
|
+
};
|
|
61
|
+
const typeArray = {
|
|
62
|
+
normalizeValue: testToNormalizeValue(isArray),
|
|
63
|
+
equal: (a, b) => {
|
|
64
|
+
if (a === b) {
|
|
65
|
+
return true;
|
|
66
|
+
} else {
|
|
67
|
+
if ((a == null ? void 0 : a.length) !== (b == null ? void 0 : b.length)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return a.every((val, index) => val === b[index]);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
typeNumber as a,
|
|
76
|
+
typeNumberInRangeFactory as b,
|
|
77
|
+
typeBoolean as c,
|
|
78
|
+
typeBooleanOrNull as d,
|
|
79
|
+
typeString as e,
|
|
80
|
+
typeFunction as f,
|
|
81
|
+
typeHTMLElementOrNull as g,
|
|
82
|
+
typeArray as h,
|
|
83
|
+
clamp as i,
|
|
84
|
+
isNumber as j,
|
|
85
|
+
testToNormalizeValue as t
|
|
86
|
+
};
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import { stateStores, writablesForProps, normalizeConfigStores, mergeConfigStores } from '../../utils/stores';
|
|
2
|
-
import { createTransition } from '../../services/transitions/baseTransitions';
|
|
3
|
-
import { collapseVerticalTransition } from '../../services/transitions/bootstrap/collapse';
|
|
4
|
-
import { computed, writable } from '@amadeus-it-group/tansu';
|
|
5
|
-
import { noop } from '../../utils/internal/func';
|
|
6
|
-
import { typeBoolean, typeFunction, typeString } from '../../utils/writables';
|
|
7
|
-
import { bindDirectiveNoArg, directiveSubscribe, registrationArray } from '../../utils/directive';
|
|
8
|
-
import { generateId } from '../../utils/internal/dom';
|
|
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
|
-
}
|
|
15
|
-
else if (openItems.length > 2) {
|
|
16
|
-
//this case can happen when you have multiple items open and you toggle the close others
|
|
17
|
-
keepOpen = openItems[0];
|
|
18
|
-
}
|
|
19
|
-
if (keepOpen) {
|
|
20
|
-
items.forEach((item) => {
|
|
21
|
-
if (item.state$().itemId !== keepOpen && item.state$().itemVisible) {
|
|
22
|
-
item.patch({ itemVisible: false });
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return items;
|
|
27
|
-
}
|
|
28
|
-
function getItem(items, itemId) {
|
|
29
|
-
return items.find((item) => item.state$().itemId === itemId);
|
|
30
|
-
}
|
|
31
|
-
const defaultAccordionConfig = {
|
|
32
|
-
closeOthers: false,
|
|
33
|
-
onShown: noop,
|
|
34
|
-
onHidden: noop,
|
|
35
|
-
className: '',
|
|
36
|
-
itemId: '',
|
|
37
|
-
itemDestroyOnHide: true,
|
|
38
|
-
itemDisabled: false,
|
|
39
|
-
itemVisible: false,
|
|
40
|
-
itemAnimation: true,
|
|
41
|
-
itemTransition: collapseVerticalTransition,
|
|
42
|
-
itemHeadingTag: '',
|
|
43
|
-
onItemShown: noop,
|
|
44
|
-
onItemHidden: noop,
|
|
45
|
-
onItemVisibleChange: noop,
|
|
46
|
-
slotItemStructure: undefined,
|
|
47
|
-
slotItemBody: undefined,
|
|
48
|
-
slotItemHeader: undefined,
|
|
49
|
-
itemClass: '',
|
|
50
|
-
itemHeaderClass: '',
|
|
51
|
-
itemButtonClass: '',
|
|
52
|
-
itemBodyContainerClass: '',
|
|
53
|
-
itemBodyClass: '',
|
|
54
|
-
};
|
|
55
|
-
const defaultItemConfig = {
|
|
56
|
-
itemId: defaultAccordionConfig.itemId,
|
|
57
|
-
itemDestroyOnHide: defaultAccordionConfig.itemDestroyOnHide,
|
|
58
|
-
itemDisabled: defaultAccordionConfig.itemDisabled,
|
|
59
|
-
itemVisible: defaultAccordionConfig.itemVisible,
|
|
60
|
-
itemAnimation: defaultAccordionConfig.itemAnimation,
|
|
61
|
-
itemTransition: defaultAccordionConfig.itemTransition,
|
|
62
|
-
onItemShown: defaultAccordionConfig.onItemShown,
|
|
63
|
-
onItemHidden: defaultAccordionConfig.onItemHidden,
|
|
64
|
-
onItemVisibleChange: defaultAccordionConfig.onItemVisibleChange,
|
|
65
|
-
slotItemStructure: defaultAccordionConfig.slotItemStructure,
|
|
66
|
-
slotItemBody: defaultAccordionConfig.slotItemBody,
|
|
67
|
-
slotItemHeader: defaultAccordionConfig.slotItemHeader,
|
|
68
|
-
itemClass: defaultAccordionConfig.itemClass,
|
|
69
|
-
itemHeaderClass: defaultAccordionConfig.itemHeaderClass,
|
|
70
|
-
itemButtonClass: defaultAccordionConfig.itemButtonClass,
|
|
71
|
-
itemBodyContainerClass: defaultAccordionConfig.itemBodyContainerClass,
|
|
72
|
-
itemBodyClass: defaultAccordionConfig.itemBodyClass,
|
|
73
|
-
itemHeadingTag: defaultAccordionConfig.itemHeadingTag,
|
|
74
|
-
};
|
|
75
|
-
const accordionItemProps = Object.keys(defaultItemConfig);
|
|
76
|
-
/**
|
|
77
|
-
* Retrieve a shallow copy of the default accordion config
|
|
78
|
-
* @returns the default accordion config
|
|
79
|
-
*/
|
|
80
|
-
export function getAccordionDefaultConfig() {
|
|
81
|
-
return { ...defaultAccordionConfig };
|
|
82
|
-
}
|
|
83
|
-
const configAccordionValidator = {
|
|
84
|
-
closeOthers: typeBoolean,
|
|
85
|
-
onShown: typeFunction,
|
|
86
|
-
onHidden: typeFunction,
|
|
87
|
-
itemId: typeString,
|
|
88
|
-
itemDestroyOnHide: typeBoolean,
|
|
89
|
-
itemDisabled: typeBoolean,
|
|
90
|
-
itemVisible: typeBoolean,
|
|
91
|
-
itemAnimation: typeBoolean,
|
|
92
|
-
itemTransition: typeFunction,
|
|
93
|
-
onItemShown: typeFunction,
|
|
94
|
-
onItemHidden: typeFunction,
|
|
95
|
-
onItemVisibleChange: typeFunction,
|
|
96
|
-
itemClass: typeString,
|
|
97
|
-
itemHeaderClass: typeString,
|
|
98
|
-
itemButtonClass: typeString,
|
|
99
|
-
itemBodyContainerClass: typeString,
|
|
100
|
-
itemBodyClass: typeString,
|
|
101
|
-
itemHeadingTag: typeString,
|
|
102
|
-
};
|
|
103
|
-
const configItemValidator = {
|
|
104
|
-
itemId: typeString,
|
|
105
|
-
itemDestroyOnHide: typeBoolean,
|
|
106
|
-
itemDisabled: typeBoolean,
|
|
107
|
-
itemVisible: typeBoolean,
|
|
108
|
-
itemAnimation: typeBoolean,
|
|
109
|
-
itemTransition: typeFunction,
|
|
110
|
-
onItemShown: typeFunction,
|
|
111
|
-
onItemHidden: typeFunction,
|
|
112
|
-
onItemVisibleChange: typeFunction,
|
|
113
|
-
itemClass: typeString,
|
|
114
|
-
itemHeaderClass: typeString,
|
|
115
|
-
itemButtonClass: typeString,
|
|
116
|
-
itemBodyContainerClass: typeString,
|
|
117
|
-
itemBodyClass: typeString,
|
|
118
|
-
itemHeadingTag: typeString,
|
|
119
|
-
};
|
|
120
|
-
function createAccordionItem(accordionOnShown, accordionOnHidden, config) {
|
|
121
|
-
const [{ itemAnimation$, itemTransition$, itemDestroyOnHide$, onItemShown$, onItemHidden$, onItemVisibleChange$, itemVisible$, itemId$: _dirtyItemId$, itemDisabled$, ...stateProps }, patch,] = writablesForProps(defaultItemConfig, config, configItemValidator);
|
|
122
|
-
const initDone$ = writable(false);
|
|
123
|
-
const _autoItemId$ = computed(() => generateId());
|
|
124
|
-
const itemId$ = computed(() => _dirtyItemId$() || _autoItemId$());
|
|
125
|
-
const shouldBeInDOM$ = computed(() => itemDestroyOnHide$() === false || !itemTransition.state$().hidden);
|
|
126
|
-
const itemTransition = createTransition({
|
|
127
|
-
props: {
|
|
128
|
-
transition: itemTransition$,
|
|
129
|
-
visible: itemVisible$,
|
|
130
|
-
onVisibleChange: onItemVisibleChange$,
|
|
131
|
-
animation: itemAnimation$,
|
|
132
|
-
animationOnInit: false,
|
|
133
|
-
initDone: initDone$,
|
|
134
|
-
onHidden: () => {
|
|
135
|
-
accordionOnHidden()(itemId$());
|
|
136
|
-
onItemHidden$()();
|
|
137
|
-
},
|
|
138
|
-
onShown: () => {
|
|
139
|
-
accordionOnShown()(itemId$());
|
|
140
|
-
onItemShown$()();
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
return {
|
|
145
|
-
...stateStores({
|
|
146
|
-
itemVisible$,
|
|
147
|
-
itemId$,
|
|
148
|
-
shouldBeInDOM$,
|
|
149
|
-
itemDisabled$,
|
|
150
|
-
...stateProps,
|
|
151
|
-
}),
|
|
152
|
-
patch,
|
|
153
|
-
actions: {
|
|
154
|
-
click: () => {
|
|
155
|
-
if (!itemDisabled$()) {
|
|
156
|
-
itemVisible$.update((c) => !c);
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
api: {
|
|
161
|
-
initDone: () => {
|
|
162
|
-
initDone$.set(true);
|
|
163
|
-
},
|
|
164
|
-
collapse: () => {
|
|
165
|
-
itemVisible$.set(false);
|
|
166
|
-
},
|
|
167
|
-
expand: () => {
|
|
168
|
-
itemVisible$.set(true);
|
|
169
|
-
},
|
|
170
|
-
toggle: () => {
|
|
171
|
-
itemVisible$.update((c) => !c);
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
directives: { collapseDirective: bindDirectiveNoArg(itemTransition.directives.directive), accordionItemDirective: noop },
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Creates a new Accordion widget instance.
|
|
179
|
-
* @param config - config of the accordion, either as a store or as an object containing values or stores.
|
|
180
|
-
* @returns a new accordion widget instance
|
|
181
|
-
*/
|
|
182
|
-
export function createAccordion(config) {
|
|
183
|
-
const [{ closeOthers$, onShown$, onHidden$, itemId$, itemAnimation$, itemClass$, itemDisabled$, itemVisible$, itemTransition$, itemDestroyOnHide$, itemBodyClass$, itemButtonClass$, itemBodyContainerClass$, itemHeaderClass$, itemHeadingTag$, onItemVisibleChange$, onItemHidden$, onItemShown$, slotItemStructure$, slotItemBody$, slotItemHeader$, ...stateProps }, patch,] = writablesForProps(defaultAccordionConfig, config, configAccordionValidator);
|
|
184
|
-
const accordionItemConfig = {
|
|
185
|
-
itemId: itemId$,
|
|
186
|
-
itemClass: itemClass$,
|
|
187
|
-
itemAnimation: itemAnimation$,
|
|
188
|
-
itemDisabled: itemDisabled$,
|
|
189
|
-
itemVisible: itemVisible$,
|
|
190
|
-
itemTransition: itemTransition$,
|
|
191
|
-
itemDestroyOnHide: itemDestroyOnHide$,
|
|
192
|
-
itemBodyClass: itemBodyClass$,
|
|
193
|
-
itemButtonClass: itemButtonClass$,
|
|
194
|
-
itemBodyContainerClass: itemBodyContainerClass$,
|
|
195
|
-
itemHeaderClass: itemHeaderClass$,
|
|
196
|
-
itemHeadingTag: itemHeadingTag$,
|
|
197
|
-
onItemVisibleChange: onItemVisibleChange$,
|
|
198
|
-
onItemHidden: onItemHidden$,
|
|
199
|
-
onItemShown: onItemShown$,
|
|
200
|
-
slotItemStructure: slotItemStructure$,
|
|
201
|
-
slotItemBody: slotItemBody$,
|
|
202
|
-
slotItemHeader: slotItemHeader$,
|
|
203
|
-
};
|
|
204
|
-
const itemsWidget$ = registrationArray();
|
|
205
|
-
const openItems$ = computed(() => {
|
|
206
|
-
const openItems = [];
|
|
207
|
-
itemsWidget$().forEach((item) => {
|
|
208
|
-
if (item.state$().itemVisible) {
|
|
209
|
-
openItems.push(item.state$().itemId);
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
return openItems;
|
|
213
|
-
});
|
|
214
|
-
const oldOpenItem$ = writable(openItems$()[0]);
|
|
215
|
-
const checkCloseOthersAction$ = computed(() => {
|
|
216
|
-
if (closeOthers$()) {
|
|
217
|
-
adjustItemsCloseOthers(itemsWidget$(), openItems$(), oldOpenItem$());
|
|
218
|
-
oldOpenItem$.set(openItems$()[0]);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
const action$ = computed(() => {
|
|
222
|
-
checkCloseOthersAction$();
|
|
223
|
-
});
|
|
224
|
-
return {
|
|
225
|
-
...stateStores({ itemsWidget$, ...stateProps }),
|
|
226
|
-
patch,
|
|
227
|
-
actions: {},
|
|
228
|
-
api: {
|
|
229
|
-
isExpanded: (id) => {
|
|
230
|
-
const item = getItem(itemsWidget$(), id);
|
|
231
|
-
if (item) {
|
|
232
|
-
return item.state$().itemVisible;
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
expand: (id) => {
|
|
239
|
-
getItem(itemsWidget$(), id)?.api.expand();
|
|
240
|
-
},
|
|
241
|
-
collapse: (id) => {
|
|
242
|
-
getItem(itemsWidget$(), id)?.api.collapse();
|
|
243
|
-
},
|
|
244
|
-
toggle: (id) => {
|
|
245
|
-
getItem(itemsWidget$(), id)?.api.toggle();
|
|
246
|
-
},
|
|
247
|
-
expandAll: () => {
|
|
248
|
-
itemsWidget$().forEach((i) => i.api.expand());
|
|
249
|
-
},
|
|
250
|
-
collapseAll: () => {
|
|
251
|
-
itemsWidget$().forEach((i) => i.api.collapse());
|
|
252
|
-
},
|
|
253
|
-
registerItem: (propsConfig) => {
|
|
254
|
-
const item = createAccordionItem(onShown$, onHidden$, {
|
|
255
|
-
config: mergeConfigStores(accordionItemProps, normalizeConfigStores(accordionItemProps, propsConfig?.config), accordionItemConfig),
|
|
256
|
-
props: propsConfig?.props,
|
|
257
|
-
});
|
|
258
|
-
item.directives.accordionItemDirective = () => ({ destroy: itemsWidget$.register(item) });
|
|
259
|
-
return item;
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
directives: { accordionDirective: directiveSubscribe(action$) },
|
|
263
|
-
};
|
|
264
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createCommonAlert, getCommonAlertDefaultConfig } from './common';
|
|
2
|
-
import { extendWidgetProps } from '../../services/extendWidget';
|
|
3
|
-
import { typeString } from '../../utils/writables';
|
|
4
|
-
const alertDefaultConfig = {
|
|
5
|
-
type: 'primary',
|
|
6
|
-
};
|
|
7
|
-
const alertConfigValidator = {
|
|
8
|
-
type: typeString,
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Retrieve a shallow copy of the default alert config
|
|
12
|
-
* @returns the default alert config
|
|
13
|
-
*/
|
|
14
|
-
export function getAlertDefaultConfig() {
|
|
15
|
-
return { ...getCommonAlertDefaultConfig(), ...alertDefaultConfig };
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Create an AlertWidget with given config props
|
|
19
|
-
* @param config - an optional alert config
|
|
20
|
-
* @returns an AlertWidget
|
|
21
|
-
*/
|
|
22
|
-
export const createAlert = extendWidgetProps(createCommonAlert, alertDefaultConfig, alertConfigValidator);
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { createTransition } from '../../services/transitions/baseTransitions';
|
|
2
|
-
import { noop } from '../../utils/internal/func';
|
|
3
|
-
import { fadeTransition } from '../../services/transitions/bootstrap/fade';
|
|
4
|
-
import { stateStores, writablesForProps } from '../../utils/stores';
|
|
5
|
-
import { bindDirectiveNoArg } from '../../utils/directive';
|
|
6
|
-
import { typeBoolean } from '../../utils/writables';
|
|
7
|
-
export const defaultCommonAlertConfig = {
|
|
8
|
-
visible: true,
|
|
9
|
-
dismissible: true,
|
|
10
|
-
ariaCloseButtonLabel: 'Close',
|
|
11
|
-
onVisibleChange: noop,
|
|
12
|
-
onShown: noop,
|
|
13
|
-
onHidden: noop,
|
|
14
|
-
slotStructure: undefined,
|
|
15
|
-
slotDefault: undefined,
|
|
16
|
-
animation: true,
|
|
17
|
-
animationOnInit: false,
|
|
18
|
-
transition: fadeTransition,
|
|
19
|
-
className: '',
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Retrieve a shallow copy of the default alert config
|
|
23
|
-
* @returns the default alert config
|
|
24
|
-
*/
|
|
25
|
-
export function getCommonAlertDefaultConfig() {
|
|
26
|
-
return { ...defaultCommonAlertConfig };
|
|
27
|
-
}
|
|
28
|
-
export const commonAlertConfigValidator = {
|
|
29
|
-
dismissible: typeBoolean,
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Create an AlertWidget with given config props
|
|
33
|
-
* @param config - an optional alert config
|
|
34
|
-
* @returns an AlertWidget
|
|
35
|
-
*/
|
|
36
|
-
export function createCommonAlert(config) {
|
|
37
|
-
const [{ transition$, animationOnInit$, animation$, visible$: requestedVisible$, onVisibleChange$, onHidden$, onShown$, ...stateProps }, patch,] = writablesForProps(defaultCommonAlertConfig, config, commonAlertConfigValidator);
|
|
38
|
-
const transition = createTransition({
|
|
39
|
-
props: {
|
|
40
|
-
transition: transition$,
|
|
41
|
-
visible: requestedVisible$,
|
|
42
|
-
animation: animation$,
|
|
43
|
-
animationOnInit: animationOnInit$,
|
|
44
|
-
onVisibleChange: onVisibleChange$,
|
|
45
|
-
onHidden: onHidden$,
|
|
46
|
-
onShown: onShown$,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
const close = () => {
|
|
50
|
-
patch({ visible: false });
|
|
51
|
-
};
|
|
52
|
-
const open = () => {
|
|
53
|
-
patch({ visible: true });
|
|
54
|
-
};
|
|
55
|
-
const visible$ = transition.stores.visible$;
|
|
56
|
-
const hidden$ = transition.stores.hidden$;
|
|
57
|
-
return {
|
|
58
|
-
...stateStores({ ...stateProps, visible$, hidden$ }),
|
|
59
|
-
patch,
|
|
60
|
-
api: {
|
|
61
|
-
open,
|
|
62
|
-
close,
|
|
63
|
-
},
|
|
64
|
-
directives: {
|
|
65
|
-
transitionDirective: bindDirectiveNoArg(transition.directives.directive),
|
|
66
|
-
},
|
|
67
|
-
actions: {},
|
|
68
|
-
};
|
|
69
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { computed, readable } from '@amadeus-it-group/tansu';
|
|
2
|
-
import { typeBoolean, typeFunction, typeHTMLElementOrNull, typeString } from '../../utils/writables';
|
|
3
|
-
import { stateStores, writablesForProps } from '../../utils/stores';
|
|
4
|
-
import { createTransition } from '../../services/transitions/baseTransitions';
|
|
5
|
-
import { fadeTransition } from '../../services/transitions/bootstrap/fade';
|
|
6
|
-
import { promiseFromStore } from '../../utils/internal/promise';
|
|
7
|
-
import { noop } from '../../utils/internal/func';
|
|
8
|
-
import { removeScrollbars, revertScrollbars } from '../../utils/internal/scrollbars';
|
|
9
|
-
import { bindDirective, bindDirectiveNoArg, directiveSubscribe, mergeDirectives, registrationArray } from '../../utils/directive';
|
|
10
|
-
import { portal } from '../../services/portal';
|
|
11
|
-
import { sliblingsInert } from '../../services/siblingsInert';
|
|
12
|
-
/**
|
|
13
|
-
* Value present in the {@link ModalBeforeCloseEvent.result|result} property of the {@link ModalProps.onBeforeClose|onBeforeClose} event
|
|
14
|
-
* and returned by the {@link ModalApi.open|open} method, when the modal is closed by a click inside the viewport but outside the modal.
|
|
15
|
-
*/
|
|
16
|
-
export const modalOutsideClick = Symbol();
|
|
17
|
-
/**
|
|
18
|
-
* Value present in the {@link ModalBeforeCloseEvent.result|result} property of the {@link ModalProps.onBeforeClose|onBeforeClose} event
|
|
19
|
-
* and returned by the {@link ModalApi.open|open} method, when the modal is closed by a click on the close button.
|
|
20
|
-
*/
|
|
21
|
-
export const modalCloseButtonClick = Symbol();
|
|
22
|
-
const defaultConfig = {
|
|
23
|
-
animation: true,
|
|
24
|
-
ariaCloseButtonLabel: 'Close',
|
|
25
|
-
backdrop: true,
|
|
26
|
-
backdropClass: '',
|
|
27
|
-
backdropTransition: fadeTransition, // TODO: is it ok to depend on bootstrap transition?
|
|
28
|
-
closeButton: true,
|
|
29
|
-
closeOnOutsideClick: true,
|
|
30
|
-
container: typeof window !== 'undefined' ? document.body : null,
|
|
31
|
-
className: '',
|
|
32
|
-
modalTransition: fadeTransition, // TODO: is it ok to depend on bootstrap transition?
|
|
33
|
-
onBeforeClose: noop,
|
|
34
|
-
onVisibleChange: noop,
|
|
35
|
-
onHidden: noop,
|
|
36
|
-
onShown: noop,
|
|
37
|
-
slotDefault: undefined,
|
|
38
|
-
slotFooter: undefined,
|
|
39
|
-
slotHeader: undefined,
|
|
40
|
-
slotStructure: undefined,
|
|
41
|
-
slotTitle: undefined,
|
|
42
|
-
visible: false,
|
|
43
|
-
contentData: undefined,
|
|
44
|
-
};
|
|
45
|
-
const configValidator = {
|
|
46
|
-
animation: typeBoolean,
|
|
47
|
-
ariaCloseButtonLabel: typeString,
|
|
48
|
-
backdrop: typeBoolean,
|
|
49
|
-
backdropClass: typeString,
|
|
50
|
-
backdropTransition: typeFunction,
|
|
51
|
-
closeButton: typeBoolean,
|
|
52
|
-
closeOnOutsideClick: typeBoolean,
|
|
53
|
-
container: typeHTMLElementOrNull,
|
|
54
|
-
className: typeString,
|
|
55
|
-
modalTransition: typeFunction,
|
|
56
|
-
onBeforeClose: typeFunction,
|
|
57
|
-
onVisibleChange: typeFunction,
|
|
58
|
-
onHidden: typeFunction,
|
|
59
|
-
onShown: typeFunction,
|
|
60
|
-
visible: typeBoolean,
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Returns a copy of the default modal config.
|
|
64
|
-
* @returns a copy of the default modal config
|
|
65
|
-
*/
|
|
66
|
-
export function getModalDefaultConfig() {
|
|
67
|
-
return { ...defaultConfig };
|
|
68
|
-
}
|
|
69
|
-
const modals$ = registrationArray();
|
|
70
|
-
const hasModals$ = computed(() => modals$().length > 0);
|
|
71
|
-
const scrollbarsAction$ = computed(() => {
|
|
72
|
-
if (hasModals$()) {
|
|
73
|
-
removeScrollbars();
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
revertScrollbars();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
const modalsAction$ = computed(() => {
|
|
80
|
-
scrollbarsAction$();
|
|
81
|
-
});
|
|
82
|
-
/**
|
|
83
|
-
* Creates a new modal widget instance.
|
|
84
|
-
* @param config$ - config of the modal, either as a store or as an object containing values or stores.
|
|
85
|
-
* @returns a new modal widget instance
|
|
86
|
-
*/
|
|
87
|
-
export function createModal(config$) {
|
|
88
|
-
const [{ animation$, backdrop$, backdropTransition$, closeOnOutsideClick$, container$, modalTransition$, onBeforeClose$, onVisibleChange$, onHidden$, onShown$, visible$: requestedVisible$, ...stateProps }, patch,] = writablesForProps(defaultConfig, config$, configValidator);
|
|
89
|
-
const modalTransition = createTransition({
|
|
90
|
-
props: {
|
|
91
|
-
transition: modalTransition$,
|
|
92
|
-
visible: requestedVisible$,
|
|
93
|
-
animation: animation$,
|
|
94
|
-
animationOnInit: animation$,
|
|
95
|
-
onVisibleChange: onVisibleChange$,
|
|
96
|
-
// TODO: for onHidden and onShown, should we combine with information from the backdrop transition?
|
|
97
|
-
// (especially in case one of the two transitions takes more time than the other)
|
|
98
|
-
onHidden: onHidden$,
|
|
99
|
-
onShown: onShown$,
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
const visible$ = modalTransition.stores.visible$;
|
|
103
|
-
const backdropTransition = createTransition({
|
|
104
|
-
props: {
|
|
105
|
-
transition: backdropTransition$,
|
|
106
|
-
visible: requestedVisible$,
|
|
107
|
-
animation: animation$,
|
|
108
|
-
animationOnInit: animation$,
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
const transitioning$ = computed(() => modalTransition.stores.transitioning$() || (backdrop$() && backdropTransition.stores.transitioning$()));
|
|
112
|
-
const hidden$ = computed(() => !transitioning$() && !visible$());
|
|
113
|
-
const backdropHidden$ = computed(() => !backdrop$() || hidden$());
|
|
114
|
-
let hideResult;
|
|
115
|
-
const close = (result) => {
|
|
116
|
-
hideResult = result;
|
|
117
|
-
const beforeCloseEvent = {
|
|
118
|
-
get result() {
|
|
119
|
-
return hideResult;
|
|
120
|
-
},
|
|
121
|
-
set result(value) {
|
|
122
|
-
hideResult = value;
|
|
123
|
-
},
|
|
124
|
-
cancel: false,
|
|
125
|
-
};
|
|
126
|
-
onBeforeClose$()(beforeCloseEvent);
|
|
127
|
-
if (beforeCloseEvent.cancel) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
patch({ visible: false });
|
|
131
|
-
};
|
|
132
|
-
const modalPortalDirective = bindDirective(portal, computed(() => ({ container: container$() })));
|
|
133
|
-
const backdropPortalDirective = bindDirective(portal, computed(() => {
|
|
134
|
-
const container = container$();
|
|
135
|
-
const element = container ? modalTransition.stores.element$() : undefined;
|
|
136
|
-
return {
|
|
137
|
-
container,
|
|
138
|
-
insertBefore: element?.parentElement === container ? element : undefined,
|
|
139
|
-
};
|
|
140
|
-
}));
|
|
141
|
-
const registerModalAction$ = readable(undefined, () => modals$.register(res));
|
|
142
|
-
const action$ = computed(() => {
|
|
143
|
-
if (modalTransition.stores.elementPresent$() && !hidden$()) {
|
|
144
|
-
registerModalAction$();
|
|
145
|
-
}
|
|
146
|
-
modalsAction$();
|
|
147
|
-
});
|
|
148
|
-
const res = {
|
|
149
|
-
...stateStores({
|
|
150
|
-
backdropHidden$,
|
|
151
|
-
container$,
|
|
152
|
-
hidden$,
|
|
153
|
-
transitioning$,
|
|
154
|
-
visible$,
|
|
155
|
-
modalElement$: modalTransition.stores.element$,
|
|
156
|
-
...stateProps,
|
|
157
|
-
}),
|
|
158
|
-
directives: {
|
|
159
|
-
modalPortalDirective,
|
|
160
|
-
backdropPortalDirective,
|
|
161
|
-
backdropDirective: bindDirectiveNoArg(backdropTransition.directives.directive),
|
|
162
|
-
modalDirective: mergeDirectives(bindDirectiveNoArg(modalTransition.directives.directive), sliblingsInert, directiveSubscribe(action$)),
|
|
163
|
-
},
|
|
164
|
-
patch,
|
|
165
|
-
api: {
|
|
166
|
-
close,
|
|
167
|
-
async open() {
|
|
168
|
-
patch({ visible: true });
|
|
169
|
-
await promiseFromStore(hidden$).promise;
|
|
170
|
-
return hideResult;
|
|
171
|
-
},
|
|
172
|
-
patch,
|
|
173
|
-
},
|
|
174
|
-
actions: {
|
|
175
|
-
modalClick(event) {
|
|
176
|
-
if (event.currentTarget === event.target && closeOnOutsideClick$()) {
|
|
177
|
-
close(modalOutsideClick);
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
closeButtonClick(event) {
|
|
181
|
-
close(modalCloseButtonClick);
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
};
|
|
185
|
-
return res;
|
|
186
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is the pagination algorithm used by ng-bootstrap. While this is not the default implementation of our widget, we export it to ease the migration from ng-bootstrap pagination.
|
|
3
|
-
* @param maxSize - the max size
|
|
4
|
-
* @param rotate - rotate the pages
|
|
5
|
-
* @param ellipses - enable ellipses
|
|
6
|
-
* @returns the pages
|
|
7
|
-
*/
|
|
8
|
-
export declare function ngBootstrapPagination(maxSize: number, rotate: boolean, ellipses: boolean): (page: number, pageCount: number) => number[];
|