@agnos-ui/core 0.0.1-alpha.0 → 0.0.1-alpha.10
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 +4 -4
- package/{dist/lib → components/accordion}/accordion.d.ts +29 -25
- package/{dist/lib → components/accordion}/accordion.js +81 -77
- package/components/accordion/index.d.ts +1 -0
- package/components/accordion/index.js +1 -0
- package/components/alert/alert.d.ts +31 -0
- package/components/alert/alert.js +22 -0
- package/{dist/lib/alert.d.ts → components/alert/common.d.ts} +17 -20
- package/{dist/lib/alert.js → components/alert/common.js} +22 -19
- package/components/alert/index.d.ts +2 -0
- package/components/alert/index.js +2 -0
- package/components/commonProps.d.ts +6 -0
- package/components/commonProps.js +1 -0
- package/components/modal/index.d.ts +1 -0
- package/components/modal/index.js +1 -0
- package/{dist/lib → components}/modal/modal.d.ts +30 -29
- package/{dist/lib → components}/modal/modal.js +59 -29
- package/components/pagination/index.d.ts +2 -0
- package/components/pagination/index.js +2 -0
- package/{dist/lib → components/pagination}/pagination.d.ts +5 -14
- package/{dist/lib → components/pagination}/pagination.js +6 -5
- package/components/progressbar/index.d.ts +1 -0
- package/components/progressbar/index.js +1 -0
- package/components/progressbar/progressbar.d.ts +86 -0
- package/components/progressbar/progressbar.js +78 -0
- package/components/rating/index.d.ts +1 -0
- package/components/rating/index.js +1 -0
- package/{dist/lib → components/rating}/rating.d.ts +6 -13
- package/{dist/lib → components/rating}/rating.js +6 -9
- package/components/select/index.d.ts +1 -0
- package/components/select/index.js +1 -0
- package/components/select/select.d.ts +337 -0
- package/components/select/select.js +266 -0
- package/components/slider/index.d.ts +1 -0
- package/components/slider/index.js +1 -0
- package/components/slider/slider.d.ts +245 -0
- package/components/slider/slider.js +413 -0
- package/{dist/lib/config.d.ts → config.d.ts} +17 -7
- package/{dist/lib/config.js → config.js} +3 -3
- package/index.d.ts +25 -0
- package/index.js +31 -0
- package/package.json +42 -28
- package/services/extendWidget.d.ts +23 -0
- package/services/extendWidget.js +35 -0
- package/services/floatingUI.d.ts +56 -0
- package/services/floatingUI.js +105 -0
- package/{dist/lib/services → services}/focustrack.js +5 -5
- package/services/intersection.d.ts +34 -0
- package/services/intersection.js +55 -0
- package/services/navManager.d.ts +93 -0
- package/services/navManager.js +172 -0
- package/{dist/lib/services → services}/portal.d.ts +7 -0
- package/services/portal.js +44 -0
- package/{dist/lib/services → services}/siblingsInert.d.ts +2 -1
- package/{dist/lib/services → services}/siblingsInert.js +2 -2
- package/{dist/lib → services}/transitions/baseTransitions.d.ts +15 -2
- package/{dist/lib → services}/transitions/baseTransitions.js +21 -10
- package/services/transitions/bootstrap/collapse.d.ts +2 -0
- package/services/transitions/bootstrap/fade.d.ts +1 -0
- package/services/transitions/bootstrap.d.ts +2 -0
- package/services/transitions/bootstrap.js +2 -0
- package/services/transitions/collapse.d.ts +43 -0
- package/{dist/lib → services}/transitions/collapse.js +15 -2
- package/{dist/lib → services}/transitions/cssTransitions.d.ts +6 -0
- package/{dist/lib → services}/transitions/cssTransitions.js +8 -4
- package/{dist/lib → services}/transitions/simpleClassTransition.d.ts +12 -1
- package/services/transitions/simpleClassTransition.js +42 -0
- package/{dist/lib/types.d.ts → types.d.ts} +43 -4
- package/types.js +14 -0
- package/{dist/lib/services/directiveUtils.js → utils/directive.js} +1 -1
- package/utils/internal/checks.d.ts +49 -0
- package/utils/internal/checks.js +60 -0
- package/utils/internal/dom.d.ts +25 -0
- package/utils/internal/dom.js +61 -0
- package/utils/internal/func.d.ts +11 -0
- package/utils/internal/func.js +11 -0
- package/utils/internal/isFocusable.d.ts +9 -0
- package/utils/internal/isFocusable.js +35 -0
- package/utils/internal/math.d.ts +5 -0
- package/utils/internal/math.js +13 -0
- package/utils/internal/promise.d.ts +87 -0
- package/utils/internal/promise.js +169 -0
- package/utils/internal/scrollbars.d.ts +8 -0
- package/{dist/lib/modal → utils/internal}/scrollbars.js +7 -1
- package/utils/internal/sort.d.ts +16 -0
- package/utils/internal/sort.js +28 -0
- package/utils/internal/textDirection.d.ts +7 -0
- package/utils/internal/textDirection.js +7 -0
- package/utils/internal/traversal.d.ts +54 -0
- package/utils/internal/traversal.js +105 -0
- package/{dist/lib/services → utils}/stores.d.ts +67 -33
- package/{dist/lib/services → utils}/stores.js +121 -59
- package/utils/writables.d.ts +32 -0
- package/utils/writables.js +72 -0
- package/dist/lib/index.d.ts +0 -11
- package/dist/lib/index.js +0 -11
- package/dist/lib/modal/scrollbars.d.ts +0 -2
- package/dist/lib/select.d.ts +0 -199
- package/dist/lib/select.js +0 -240
- package/dist/lib/services/checks.d.ts +0 -32
- package/dist/lib/services/checks.js +0 -43
- package/dist/lib/services/index.d.ts +0 -6
- package/dist/lib/services/index.js +0 -6
- package/dist/lib/services/portal.js +0 -33
- package/dist/lib/services/writables.d.ts +0 -7
- package/dist/lib/services/writables.js +0 -16
- package/dist/lib/transitions/bootstrap/collapse.d.ts +0 -2
- package/dist/lib/transitions/bootstrap/fade.d.ts +0 -1
- package/dist/lib/transitions/bootstrap/index.d.ts +0 -2
- package/dist/lib/transitions/bootstrap/index.js +0 -2
- package/dist/lib/transitions/collapse.d.ts +0 -29
- package/dist/lib/transitions/index.d.ts +0 -5
- package/dist/lib/transitions/index.js +0 -5
- package/dist/lib/transitions/simpleClassTransition.js +0 -28
- package/dist/lib/transitions/utils.d.ts +0 -20
- package/dist/lib/transitions/utils.js +0 -83
- package/dist/lib/tsdoc-metadata.json +0 -11
- package/dist/lib/types.js +0 -7
- package/dist/lib/utils.d.ts +0 -2
- package/dist/lib/utils.js +0 -2
- /package/{dist/lib/pagination.utils.d.ts → components/pagination/bootstrap.d.ts} +0 -0
- /package/{dist/lib/pagination.utils.js → components/pagination/bootstrap.js} +0 -0
- /package/{dist/lib/services → services}/focustrack.d.ts +0 -0
- /package/{dist/lib → services}/transitions/bootstrap/collapse.js +0 -0
- /package/{dist/lib → services}/transitions/bootstrap/fade.js +0 -0
- /package/{dist/lib/services/directiveUtils.d.ts → utils/directive.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './modal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './modal';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { TransitionFn } from '
|
|
3
|
-
import type {
|
|
1
|
+
import type { WidgetsCommonPropsAndState } from '../commonProps';
|
|
2
|
+
import type { TransitionFn } from '../../services/transitions/baseTransitions';
|
|
3
|
+
import type { Directive, PropsConfig, SlotContent, Widget, WidgetSlotContext } from '../../types';
|
|
4
4
|
/**
|
|
5
5
|
* Value present in the {@link ModalBeforeCloseEvent.result|result} property of the {@link ModalProps.onBeforeClose|onBeforeClose} event
|
|
6
6
|
* and returned by the {@link ModalApi.open|open} method, when the modal is closed by a click inside the viewport but outside the modal.
|
|
@@ -14,11 +14,11 @@ export declare const modalCloseButtonClick: unique symbol;
|
|
|
14
14
|
/**
|
|
15
15
|
* Context of the modal slots.
|
|
16
16
|
*/
|
|
17
|
-
export type ModalContext = WidgetSlotContext<ModalWidget
|
|
17
|
+
export type ModalContext<Data> = WidgetSlotContext<ModalWidget<Data>>;
|
|
18
18
|
/**
|
|
19
19
|
* Properties of the modal widget that are also in the state of the modal.
|
|
20
20
|
*/
|
|
21
|
-
export interface ModalCommonPropsAndState {
|
|
21
|
+
export interface ModalCommonPropsAndState<Data> extends WidgetsCommonPropsAndState {
|
|
22
22
|
/**
|
|
23
23
|
* Value of the aria-label attribute to put on the close button.
|
|
24
24
|
*/
|
|
@@ -37,35 +37,35 @@ export interface ModalCommonPropsAndState {
|
|
|
37
37
|
* Otherwise, they stay where the widget is located.
|
|
38
38
|
*/
|
|
39
39
|
container: HTMLElement | null;
|
|
40
|
-
/**
|
|
41
|
-
* Classes to add on the modal DOM element.
|
|
42
|
-
*/
|
|
43
|
-
modalClass: string;
|
|
44
40
|
/**
|
|
45
41
|
* Body of the modal.
|
|
46
42
|
*/
|
|
47
|
-
slotDefault: SlotContent<ModalContext
|
|
43
|
+
slotDefault: SlotContent<ModalContext<Data>>;
|
|
48
44
|
/**
|
|
49
45
|
* Footer of the modal.
|
|
50
46
|
*/
|
|
51
|
-
slotFooter: SlotContent<ModalContext
|
|
47
|
+
slotFooter: SlotContent<ModalContext<Data>>;
|
|
52
48
|
/**
|
|
53
49
|
* Header of the modal. The default header includes {@link ModalCommonPropsAndState.slotTitle|slotTitle}.
|
|
54
50
|
*/
|
|
55
|
-
slotHeader: SlotContent<ModalContext
|
|
51
|
+
slotHeader: SlotContent<ModalContext<Data>>;
|
|
56
52
|
/**
|
|
57
53
|
* Structure of the modal.
|
|
58
54
|
* The default structure uses {@link ModalCommonPropsAndState.slotHeader|slotHeader}, {@link ModalCommonPropsAndState.slotDefault|slotDefault} and {@link ModalCommonPropsAndState.slotFooter|slotFooter}.
|
|
59
55
|
*/
|
|
60
|
-
slotStructure: SlotContent<ModalContext
|
|
56
|
+
slotStructure: SlotContent<ModalContext<Data>>;
|
|
61
57
|
/**
|
|
62
58
|
* Title of the modal.
|
|
63
59
|
*/
|
|
64
|
-
slotTitle: SlotContent<ModalContext
|
|
60
|
+
slotTitle: SlotContent<ModalContext<Data>>;
|
|
65
61
|
/**
|
|
66
62
|
* Whether the modal should be visible when the transition is completed.
|
|
67
63
|
*/
|
|
68
64
|
visible: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Data to use in content slots
|
|
67
|
+
*/
|
|
68
|
+
contentData: Data;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Type of the parameter of {@link ModalProps.onBeforeClose|onBeforeClose}.
|
|
@@ -86,7 +86,7 @@ export interface ModalBeforeCloseEvent {
|
|
|
86
86
|
/**
|
|
87
87
|
* Properties of the modal widget.
|
|
88
88
|
*/
|
|
89
|
-
export interface ModalProps extends ModalCommonPropsAndState {
|
|
89
|
+
export interface ModalProps<Data> extends ModalCommonPropsAndState<Data> {
|
|
90
90
|
/**
|
|
91
91
|
* Whether the modal and its backdrop (if present) should be animated when shown or hidden.
|
|
92
92
|
*/
|
|
@@ -132,7 +132,7 @@ export interface ModalProps extends ModalCommonPropsAndState {
|
|
|
132
132
|
/**
|
|
133
133
|
* State of the modal widget.
|
|
134
134
|
*/
|
|
135
|
-
export interface ModalState extends ModalCommonPropsAndState {
|
|
135
|
+
export interface ModalState<Data> extends ModalCommonPropsAndState<Data> {
|
|
136
136
|
/**
|
|
137
137
|
* Whether the backdrop is fully hidden. This can be true either because {@link ModalProps.backdrop|backdrop} is false or
|
|
138
138
|
* because {@link ModalCommonPropsAndState.visible|visible} is false and there is no current transition.
|
|
@@ -154,7 +154,7 @@ export interface ModalState extends ModalCommonPropsAndState {
|
|
|
154
154
|
/**
|
|
155
155
|
* API of the modal widget.
|
|
156
156
|
*/
|
|
157
|
-
export interface ModalApi {
|
|
157
|
+
export interface ModalApi<Data> {
|
|
158
158
|
/**
|
|
159
159
|
* Closes the modal with the given result.
|
|
160
160
|
*
|
|
@@ -171,7 +171,7 @@ export interface ModalApi {
|
|
|
171
171
|
/**
|
|
172
172
|
* Method to change some modal properties.
|
|
173
173
|
*/
|
|
174
|
-
patch: ModalWidget['patch'];
|
|
174
|
+
patch: ModalWidget<Data>['patch'];
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
177
|
* Actions of the modal widget.
|
|
@@ -215,7 +215,7 @@ export interface ModalDirectives {
|
|
|
215
215
|
/**
|
|
216
216
|
* Modal widget.
|
|
217
217
|
*/
|
|
218
|
-
export type ModalWidget = Widget<ModalProps
|
|
218
|
+
export type ModalWidget<Data> = Widget<ModalProps<Data>, ModalState<Data>, ModalApi<Data>, ModalActions, ModalDirectives>;
|
|
219
219
|
/**
|
|
220
220
|
* Returns a copy of the default modal config.
|
|
221
221
|
* @returns a copy of the default modal config
|
|
@@ -280,39 +280,40 @@ export declare function getModalDefaultConfig(): {
|
|
|
280
280
|
* Otherwise, they stay where the widget is located.
|
|
281
281
|
*/
|
|
282
282
|
container: HTMLElement | null;
|
|
283
|
-
/**
|
|
284
|
-
* Classes to add on the modal DOM element.
|
|
285
|
-
*/
|
|
286
|
-
modalClass: string;
|
|
287
283
|
/**
|
|
288
284
|
* Body of the modal.
|
|
289
285
|
*/
|
|
290
|
-
slotDefault: SlotContent<ModalContext
|
|
286
|
+
slotDefault: SlotContent<ModalContext<any>>;
|
|
291
287
|
/**
|
|
292
288
|
* Footer of the modal.
|
|
293
289
|
*/
|
|
294
|
-
slotFooter: SlotContent<ModalContext
|
|
290
|
+
slotFooter: SlotContent<ModalContext<any>>;
|
|
295
291
|
/**
|
|
296
292
|
* Header of the modal. The default header includes {@link ModalCommonPropsAndState.slotTitle|slotTitle}.
|
|
297
293
|
*/
|
|
298
|
-
slotHeader: SlotContent<ModalContext
|
|
294
|
+
slotHeader: SlotContent<ModalContext<any>>;
|
|
299
295
|
/**
|
|
300
296
|
* Structure of the modal.
|
|
301
297
|
* The default structure uses {@link ModalCommonPropsAndState.slotHeader|slotHeader}, {@link ModalCommonPropsAndState.slotDefault|slotDefault} and {@link ModalCommonPropsAndState.slotFooter|slotFooter}.
|
|
302
298
|
*/
|
|
303
|
-
slotStructure: SlotContent<ModalContext
|
|
299
|
+
slotStructure: SlotContent<ModalContext<any>>;
|
|
304
300
|
/**
|
|
305
301
|
* Title of the modal.
|
|
306
302
|
*/
|
|
307
|
-
slotTitle: SlotContent<ModalContext
|
|
303
|
+
slotTitle: SlotContent<ModalContext<any>>;
|
|
308
304
|
/**
|
|
309
305
|
* Whether the modal should be visible when the transition is completed.
|
|
310
306
|
*/
|
|
311
307
|
visible: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Data to use in content slots
|
|
310
|
+
*/
|
|
311
|
+
contentData: any;
|
|
312
|
+
className: string;
|
|
312
313
|
};
|
|
313
314
|
/**
|
|
314
315
|
* Creates a new modal widget instance.
|
|
315
316
|
* @param config$ - config of the modal, either as a store or as an object containing values or stores.
|
|
316
317
|
* @returns a new modal widget instance
|
|
317
318
|
*/
|
|
318
|
-
export declare
|
|
319
|
+
export declare function createModal<Data>(config$?: PropsConfig<ModalProps<Data>>): ModalWidget<Data>;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { computed, readable } from '@amadeus-it-group/tansu';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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';
|
|
8
12
|
/**
|
|
9
13
|
* Value present in the {@link ModalBeforeCloseEvent.result|result} property of the {@link ModalProps.onBeforeClose|onBeforeClose} event
|
|
10
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.
|
|
@@ -20,12 +24,12 @@ const defaultConfig = {
|
|
|
20
24
|
ariaCloseButtonLabel: 'Close',
|
|
21
25
|
backdrop: true,
|
|
22
26
|
backdropClass: '',
|
|
23
|
-
backdropTransition: fadeTransition,
|
|
27
|
+
backdropTransition: fadeTransition, // TODO: is it ok to depend on bootstrap transition?
|
|
24
28
|
closeButton: true,
|
|
25
29
|
closeOnOutsideClick: true,
|
|
26
30
|
container: typeof window !== 'undefined' ? document.body : null,
|
|
27
|
-
|
|
28
|
-
modalTransition: fadeTransition,
|
|
31
|
+
className: '',
|
|
32
|
+
modalTransition: fadeTransition, // TODO: is it ok to depend on bootstrap transition?
|
|
29
33
|
onBeforeClose: noop,
|
|
30
34
|
onVisibleChange: noop,
|
|
31
35
|
onHidden: noop,
|
|
@@ -36,6 +40,24 @@ const defaultConfig = {
|
|
|
36
40
|
slotStructure: undefined,
|
|
37
41
|
slotTitle: undefined,
|
|
38
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,
|
|
39
61
|
};
|
|
40
62
|
/**
|
|
41
63
|
* Returns a copy of the default modal config.
|
|
@@ -62,25 +84,29 @@ const modalsAction$ = computed(() => {
|
|
|
62
84
|
* @param config$ - config of the modal, either as a store or as an object containing values or stores.
|
|
63
85
|
* @returns a new modal widget instance
|
|
64
86
|
*/
|
|
65
|
-
export
|
|
66
|
-
const [{ animation$, backdrop$, backdropTransition$, closeOnOutsideClick$, container$, modalTransition$, onBeforeClose$, onVisibleChange$, onHidden$, onShown$, visible$: requestedVisible$, ...stateProps }, patch,] = writablesForProps(defaultConfig, config
|
|
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);
|
|
67
89
|
const modalTransition = createTransition({
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
+
},
|
|
77
101
|
});
|
|
78
102
|
const visible$ = modalTransition.stores.visible$;
|
|
79
103
|
const backdropTransition = createTransition({
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
104
|
+
props: {
|
|
105
|
+
transition: backdropTransition$,
|
|
106
|
+
visible: requestedVisible$,
|
|
107
|
+
animation: animation$,
|
|
108
|
+
animationOnInit: animation$,
|
|
109
|
+
},
|
|
84
110
|
});
|
|
85
111
|
const transitioning$ = computed(() => modalTransition.stores.transitioning$() || (backdrop$() && backdropTransition.stores.transitioning$()));
|
|
86
112
|
const hidden$ = computed(() => !transitioning$() && !visible$());
|
|
@@ -104,10 +130,14 @@ export const createModal = (config$) => {
|
|
|
104
130
|
patch({ visible: false });
|
|
105
131
|
};
|
|
106
132
|
const modalPortalDirective = bindDirective(portal, computed(() => ({ container: container$() })));
|
|
107
|
-
const backdropPortalDirective = bindDirective(portal, computed(() =>
|
|
108
|
-
container
|
|
109
|
-
|
|
110
|
-
|
|
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
|
+
}));
|
|
111
141
|
const registerModalAction$ = readable(undefined, () => modals$.register(res));
|
|
112
142
|
const action$ = computed(() => {
|
|
113
143
|
if (modalTransition.stores.elementPresent$() && !hidden$()) {
|
|
@@ -153,4 +183,4 @@ export const createModal = (config$) => {
|
|
|
153
183
|
},
|
|
154
184
|
};
|
|
155
185
|
return res;
|
|
156
|
-
}
|
|
186
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PropsConfig } from '
|
|
2
|
-
import type {
|
|
1
|
+
import type { PropsConfig, Widget, SlotContent, WidgetSlotContext } from '../../types';
|
|
2
|
+
import type { WidgetsCommonPropsAndState } from '../commonProps';
|
|
3
3
|
/**
|
|
4
4
|
* A type for the slot context of the pagination widget
|
|
5
5
|
*/
|
|
@@ -13,7 +13,7 @@ export interface PaginationNumberContext extends PaginationContext {
|
|
|
13
13
|
*/
|
|
14
14
|
displayedPage: number;
|
|
15
15
|
}
|
|
16
|
-
export interface PaginationCommonPropsAndState {
|
|
16
|
+
export interface PaginationCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
17
17
|
/**
|
|
18
18
|
* The current page.
|
|
19
19
|
*
|
|
@@ -86,11 +86,6 @@ export interface PaginationCommonPropsAndState {
|
|
|
86
86
|
* @defaultValue false
|
|
87
87
|
*/
|
|
88
88
|
boundaryLinks: boolean;
|
|
89
|
-
/**
|
|
90
|
-
* An input to add a custom class to the UL
|
|
91
|
-
* @defaultValue ''
|
|
92
|
-
*/
|
|
93
|
-
className: string;
|
|
94
89
|
/**
|
|
95
90
|
* The template to use for the ellipsis slot
|
|
96
91
|
* for I18n, we suggest to use the global configuration
|
|
@@ -398,11 +393,6 @@ export declare function getPaginationDefaultConfig(): {
|
|
|
398
393
|
* @defaultValue false
|
|
399
394
|
*/
|
|
400
395
|
boundaryLinks: boolean;
|
|
401
|
-
/**
|
|
402
|
-
* An input to add a custom class to the UL
|
|
403
|
-
* @defaultValue ''
|
|
404
|
-
*/
|
|
405
|
-
className: string;
|
|
406
396
|
/**
|
|
407
397
|
* The template to use for the ellipsis slot
|
|
408
398
|
* for I18n, we suggest to use the global configuration
|
|
@@ -455,10 +445,11 @@ export declare function getPaginationDefaultConfig(): {
|
|
|
455
445
|
* @param displayedPage - The current page number
|
|
456
446
|
*/
|
|
457
447
|
slotNumberLabel: SlotContent<PaginationNumberContext>;
|
|
448
|
+
className: string;
|
|
458
449
|
};
|
|
459
450
|
/**
|
|
460
451
|
* Create a PaginationWidget with given config props
|
|
461
|
-
* @param config - an optional
|
|
452
|
+
* @param config - an optional pagination config
|
|
462
453
|
* @returns a PaginationWidget
|
|
463
454
|
*/
|
|
464
455
|
export declare function createPagination(config?: PropsConfig<PaginationProps>): PaginationWidget;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { computed } from '@amadeus-it-group/tansu';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { INVALID_VALUE } from '../../types';
|
|
3
|
+
import { bindableDerived, stateStores, writablesForProps } from '../../utils/stores';
|
|
4
|
+
import { clamp, isNumber } from '../../utils/internal/checks';
|
|
5
|
+
import { typeBoolean, typeFunction, typeNumber, typeString } from '../../utils/writables';
|
|
6
|
+
import { noop } from '../../utils/internal/func';
|
|
6
7
|
const defaultConfig = {
|
|
7
8
|
page: 1,
|
|
8
9
|
collectionSize: 0,
|
|
@@ -64,7 +65,7 @@ const configValidator = {
|
|
|
64
65
|
};
|
|
65
66
|
/**
|
|
66
67
|
* Create a PaginationWidget with given config props
|
|
67
|
-
* @param config - an optional
|
|
68
|
+
* @param config - an optional pagination config
|
|
68
69
|
* @returns a PaginationWidget
|
|
69
70
|
*/
|
|
70
71
|
export function createPagination(config) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './progressbar';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './progressbar';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { PropsConfig, SlotContent, Widget, WidgetSlotContext } from '../../types';
|
|
2
|
+
import type { WidgetsCommonPropsAndState } from '../commonProps';
|
|
3
|
+
export type ProgressbarContext = WidgetSlotContext<ProgressbarWidget>;
|
|
4
|
+
export interface ProgressbarCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
5
|
+
/**
|
|
6
|
+
* The minimum value.
|
|
7
|
+
* @defaultValue 0
|
|
8
|
+
*/
|
|
9
|
+
min: number;
|
|
10
|
+
/**
|
|
11
|
+
* The maximum value.
|
|
12
|
+
* @defaultValue 100
|
|
13
|
+
*/
|
|
14
|
+
max: number;
|
|
15
|
+
/**
|
|
16
|
+
* The current value.
|
|
17
|
+
* @defaultValue 0
|
|
18
|
+
*/
|
|
19
|
+
value: number;
|
|
20
|
+
/**
|
|
21
|
+
* The aria label.
|
|
22
|
+
*/
|
|
23
|
+
ariaLabel: string;
|
|
24
|
+
/**
|
|
25
|
+
* Global template for the Progressbar content.
|
|
26
|
+
*/
|
|
27
|
+
slotContent: SlotContent<ProgressbarContext>;
|
|
28
|
+
/**
|
|
29
|
+
* Label of the progress.
|
|
30
|
+
*/
|
|
31
|
+
slotDefault: SlotContent<ProgressbarContext>;
|
|
32
|
+
/**
|
|
33
|
+
* Height of the progressbar, can be any valid css height value.
|
|
34
|
+
*/
|
|
35
|
+
height: string;
|
|
36
|
+
/**
|
|
37
|
+
* If `true`, shows a striped progressbar.
|
|
38
|
+
*/
|
|
39
|
+
striped: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* If `true`, animates a striped progressbar.
|
|
42
|
+
* Takes effect only for browsers supporting CSS3 animations, and if `striped` is `true`.
|
|
43
|
+
*/
|
|
44
|
+
animated: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface ProgressbarState extends ProgressbarCommonPropsAndState {
|
|
47
|
+
/**
|
|
48
|
+
* Percentage of completion.
|
|
49
|
+
*/
|
|
50
|
+
percentage: number;
|
|
51
|
+
/**
|
|
52
|
+
* `true` if the value is above its minimum value.
|
|
53
|
+
*/
|
|
54
|
+
started: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* `true` if the value has reached its maximum value.
|
|
57
|
+
*/
|
|
58
|
+
finished: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The aria value text.
|
|
61
|
+
*/
|
|
62
|
+
ariaValueText: string | undefined;
|
|
63
|
+
}
|
|
64
|
+
export interface ProgressbarProps extends ProgressbarCommonPropsAndState {
|
|
65
|
+
/**
|
|
66
|
+
* Return the value for the 'aria-valuetext' attribute.
|
|
67
|
+
* @param value - current value
|
|
68
|
+
* @param minimum - minimum value
|
|
69
|
+
* @param maximum - maximum value
|
|
70
|
+
*/
|
|
71
|
+
ariaValueTextFn: (value: number, minimum: number, maximum: number) => string | undefined;
|
|
72
|
+
}
|
|
73
|
+
export interface ProgressbarApi {
|
|
74
|
+
}
|
|
75
|
+
export type ProgressbarWidget = Widget<ProgressbarProps, ProgressbarState, ProgressbarApi, object, object>;
|
|
76
|
+
/**
|
|
77
|
+
* Retrieve a shallow copy of the default Progressbar config
|
|
78
|
+
* @returns the default Progressbar config
|
|
79
|
+
*/
|
|
80
|
+
export declare function getProgressbarDefaultConfig(): ProgressbarProps;
|
|
81
|
+
/**
|
|
82
|
+
* Create an ProgressbarWidget with given config props
|
|
83
|
+
* @param config - an optional progress bar config
|
|
84
|
+
* @returns an ProgressbarWidget
|
|
85
|
+
*/
|
|
86
|
+
export declare function createProgressbar(config?: PropsConfig<ProgressbarProps>): ProgressbarWidget;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { clamp } from '../../utils/internal/checks';
|
|
2
|
+
import { typeBoolean, typeFunction, typeNumber, typeString } from '../../utils/writables';
|
|
3
|
+
import { stateStores, writablesForProps } from '../../utils/stores';
|
|
4
|
+
import { computed } from '@amadeus-it-group/tansu';
|
|
5
|
+
const defaultConfig = {
|
|
6
|
+
min: 0,
|
|
7
|
+
max: 100,
|
|
8
|
+
value: 0,
|
|
9
|
+
ariaLabel: 'Progressbar',
|
|
10
|
+
className: '',
|
|
11
|
+
slotContent: undefined,
|
|
12
|
+
slotDefault: undefined,
|
|
13
|
+
height: '',
|
|
14
|
+
striped: false,
|
|
15
|
+
animated: false,
|
|
16
|
+
ariaValueTextFn: () => undefined,
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Retrieve a shallow copy of the default Progressbar config
|
|
20
|
+
* @returns the default Progressbar config
|
|
21
|
+
*/
|
|
22
|
+
export function getProgressbarDefaultConfig() {
|
|
23
|
+
return { ...defaultConfig };
|
|
24
|
+
}
|
|
25
|
+
const configValidator = {
|
|
26
|
+
min: typeNumber,
|
|
27
|
+
max: typeNumber,
|
|
28
|
+
value: typeNumber,
|
|
29
|
+
ariaLabel: typeString,
|
|
30
|
+
className: typeString,
|
|
31
|
+
height: typeString,
|
|
32
|
+
striped: typeBoolean,
|
|
33
|
+
animated: typeBoolean,
|
|
34
|
+
ariaValueTextFn: typeFunction,
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Create an ProgressbarWidget with given config props
|
|
38
|
+
* @param config - an optional progress bar config
|
|
39
|
+
* @returns an ProgressbarWidget
|
|
40
|
+
*/
|
|
41
|
+
export function createProgressbar(config) {
|
|
42
|
+
const [{
|
|
43
|
+
// dirty inputs that need adjustment:
|
|
44
|
+
max$: _dirtyMaximum$, value$: _dirtyValue$,
|
|
45
|
+
// clean inputs
|
|
46
|
+
min$, ariaValueTextFn$, ...stateProps }, patch,] = writablesForProps(defaultConfig, config, configValidator);
|
|
47
|
+
const max$ = computed(() => Math.max(min$(), _dirtyMaximum$()));
|
|
48
|
+
const value$ = computed(() => clamp(_dirtyValue$(), max$(), min$()));
|
|
49
|
+
const percentage$ = computed(() => {
|
|
50
|
+
const max = max$();
|
|
51
|
+
const min = min$();
|
|
52
|
+
if (max > min) {
|
|
53
|
+
return clamp(((value$() - min) * 100) / (max - min), 100, 0);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const started$ = computed(() => value$() > min$());
|
|
60
|
+
const finished$ = computed(() => value$() === max$());
|
|
61
|
+
const ariaValueText$ = computed(() => ariaValueTextFn$()(value$(), min$(), max$()));
|
|
62
|
+
return {
|
|
63
|
+
...stateStores({
|
|
64
|
+
min$,
|
|
65
|
+
max$,
|
|
66
|
+
value$,
|
|
67
|
+
percentage$,
|
|
68
|
+
started$,
|
|
69
|
+
finished$,
|
|
70
|
+
ariaValueText$,
|
|
71
|
+
...stateProps,
|
|
72
|
+
}),
|
|
73
|
+
patch,
|
|
74
|
+
api: {},
|
|
75
|
+
directives: {},
|
|
76
|
+
actions: {},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rating';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rating';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PropsConfig } from '
|
|
2
|
-
import type {
|
|
1
|
+
import type { PropsConfig, SlotContent, Widget } from '../../types';
|
|
2
|
+
import type { WidgetsCommonPropsAndState } from '../commonProps';
|
|
3
3
|
export interface StarContext {
|
|
4
4
|
/**
|
|
5
5
|
* indicates how much the current star is filled, from 0 to 100
|
|
@@ -10,7 +10,7 @@ export interface StarContext {
|
|
|
10
10
|
*/
|
|
11
11
|
index: number;
|
|
12
12
|
}
|
|
13
|
-
export interface RatingCommonPropsAndState {
|
|
13
|
+
export interface RatingCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
14
14
|
/**
|
|
15
15
|
* The current rating. Could be a decimal value like `3.75`.
|
|
16
16
|
*/
|
|
@@ -38,10 +38,6 @@ export interface RatingCommonPropsAndState {
|
|
|
38
38
|
* If the component is disabled, `tabindex` will still be set to `-1`.
|
|
39
39
|
*/
|
|
40
40
|
tabindex: number;
|
|
41
|
-
/**
|
|
42
|
-
* Classname to be applied on the rating container
|
|
43
|
-
*/
|
|
44
|
-
className: string;
|
|
45
41
|
/**
|
|
46
42
|
* The template to override the way each star is displayed.
|
|
47
43
|
*/
|
|
@@ -57,7 +53,7 @@ export interface RatingCommonPropsAndState {
|
|
|
57
53
|
}
|
|
58
54
|
export interface RatingProps extends RatingCommonPropsAndState {
|
|
59
55
|
/**
|
|
60
|
-
* Return the value for the 'aria-
|
|
56
|
+
* Return the value for the 'aria-valuetext' attribute.
|
|
61
57
|
* @param rating - Current rating value.
|
|
62
58
|
* @param maxRating - maxRating value.
|
|
63
59
|
*/
|
|
@@ -134,7 +130,7 @@ export type RatingWidget = Widget<RatingProps, RatingState, object, RatingAction
|
|
|
134
130
|
*/
|
|
135
131
|
export declare function getRatingDefaultConfig(): {
|
|
136
132
|
/**
|
|
137
|
-
* Return the value for the 'aria-
|
|
133
|
+
* Return the value for the 'aria-valuetext' attribute.
|
|
138
134
|
* @param rating - Current rating value.
|
|
139
135
|
* @param maxRating - maxRating value.
|
|
140
136
|
*/
|
|
@@ -184,10 +180,6 @@ export declare function getRatingDefaultConfig(): {
|
|
|
184
180
|
* If the component is disabled, `tabindex` will still be set to `-1`.
|
|
185
181
|
*/
|
|
186
182
|
tabindex: number;
|
|
187
|
-
/**
|
|
188
|
-
* Classname to be applied on the rating container
|
|
189
|
-
*/
|
|
190
|
-
className: string;
|
|
191
183
|
/**
|
|
192
184
|
* The template to override the way each star is displayed.
|
|
193
185
|
*/
|
|
@@ -200,6 +192,7 @@ export declare function getRatingDefaultConfig(): {
|
|
|
200
192
|
* The aria labelled by
|
|
201
193
|
*/
|
|
202
194
|
ariaLabelledBy: string;
|
|
195
|
+
className: string;
|
|
203
196
|
};
|
|
204
197
|
/**
|
|
205
198
|
* Create a RatingWidget with given config props
|