@agnos-ui/core 0.0.1-alpha.3 → 0.0.1-alpha.5
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.d.ts → components/accordion/accordion.d.ts} +13 -4
- package/{accordion.js → components/accordion/accordion.js} +17 -11
- package/components/alert/alert.d.ts +32 -0
- package/components/alert/alert.js +23 -0
- package/{alert.d.ts → components/alert/common.d.ts} +17 -21
- package/{alert.js → components/alert/common.js} +12 -12
- package/{modal → components/modal}/modal.d.ts +28 -21
- package/{modal → components/modal}/modal.js +39 -13
- package/{pagination.d.ts → components/pagination/pagination.d.ts} +3 -3
- package/{pagination.js → components/pagination/pagination.js} +6 -4
- package/{progressbar.d.ts → components/progressbar/progressbar.d.ts} +2 -3
- package/{progressbar.js → components/progressbar/progressbar.js} +6 -6
- package/{rating.d.ts → components/rating/rating.d.ts} +2 -3
- package/{rating.js → components/rating/rating.js} +6 -9
- package/components/select/select.d.ts +337 -0
- package/components/select/select.js +266 -0
- package/components/slider/slider.d.ts +239 -0
- package/components/slider/slider.js +389 -0
- package/config.d.ts +13 -8
- package/config.js +3 -3
- package/index.d.ts +23 -12
- package/index.js +29 -12
- package/package.json +32 -4
- package/services/extendWidget.d.ts +23 -0
- package/{extendWidget.js → services/extendWidget.js} +8 -1
- package/services/floatingUI.d.ts +48 -0
- package/services/floatingUI.js +97 -0
- package/services/focustrack.js +1 -1
- package/services/intersection.d.ts +1 -1
- package/services/intersection.js +2 -2
- package/services/navManager.d.ts +83 -1
- package/services/navManager.js +153 -37
- package/services/portal.js +8 -4
- package/services/siblingsInert.d.ts +2 -1
- package/services/siblingsInert.js +2 -2
- package/{transitions → services/transitions}/baseTransitions.d.ts +1 -2
- package/{transitions → services/transitions}/baseTransitions.js +7 -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/{transitions → services/transitions}/collapse.js +1 -1
- package/{transitions → services/transitions}/cssTransitions.js +2 -4
- package/{transitions → services/transitions}/simpleClassTransition.js +1 -1
- package/types.d.ts +37 -4
- package/types.js +1 -0
- package/{services/directiveUtils.js → utils/directive.js} +1 -1
- package/{services → utils/internal}/checks.d.ts +12 -0
- package/{services → utils/internal}/checks.js +12 -0
- package/utils/internal/dom.d.ts +13 -0
- package/utils/internal/dom.js +49 -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 +31 -0
- package/utils/internal/promise.js +113 -0
- package/{modal → utils/internal}/scrollbars.js +1 -1
- package/utils/internal/textDirection.d.ts +1 -0
- package/utils/internal/textDirection.js +1 -0
- package/utils/internal/traversal.d.ts +54 -0
- package/utils/internal/traversal.js +105 -0
- package/{services → utils}/stores.d.ts +11 -35
- package/{services → utils}/stores.js +21 -19
- package/utils/writables.d.ts +26 -0
- package/utils/writables.js +66 -0
- package/extendWidget.d.ts +0 -3
- package/select.d.ts +0 -196
- package/select.js +0 -240
- package/services/index.d.ts +0 -8
- package/services/index.js +0 -8
- package/services/writables.d.ts +0 -8
- package/services/writables.js +0 -30
- package/transitions/bootstrap/collapse.d.ts +0 -2
- package/transitions/bootstrap/fade.d.ts +0 -1
- package/transitions/bootstrap/index.d.ts +0 -2
- package/transitions/bootstrap/index.js +0 -2
- package/transitions/index.d.ts +0 -5
- package/transitions/index.js +0 -5
- package/transitions/utils.d.ts +0 -20
- package/transitions/utils.js +0 -83
- /package/{commonProps.d.ts → components/commonProps.d.ts} +0 -0
- /package/{commonProps.js → components/commonProps.js} +0 -0
- /package/{pagination.utils.d.ts → components/pagination/bootstrap.d.ts} +0 -0
- /package/{pagination.utils.js → components/pagination/bootstrap.js} +0 -0
- /package/{transitions → services/transitions}/bootstrap/collapse.js +0 -0
- /package/{transitions → services/transitions}/bootstrap/fade.js +0 -0
- /package/{transitions → services/transitions}/collapse.d.ts +0 -0
- /package/{transitions → services/transitions}/cssTransitions.d.ts +0 -0
- /package/{transitions → services/transitions}/simpleClassTransition.d.ts +0 -0
- /package/{services/directiveUtils.d.ts → utils/directive.d.ts} +0 -0
- /package/{utils.d.ts → utils/internal/func.d.ts} +0 -0
- /package/{utils.js → utils/internal/func.js} +0 -0
- /package/{modal → utils/internal}/scrollbars.d.ts +0 -0
- /package/{services/sortUtils.d.ts → utils/internal/sort.d.ts} +0 -0
- /package/{services/sortUtils.js → utils/internal/sort.js} +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { WidgetsCommonPropsAndState } from './commonProps';
|
|
1
|
+
import type { TransitionFn } from '../../services/transitions/baseTransitions';
|
|
2
|
+
import type { Directive, PropsConfig, SlotContent, Widget, WidgetSlotContext } from '../../types';
|
|
3
|
+
import type { WidgetsCommonPropsAndState } from '../commonProps';
|
|
5
4
|
export interface AccordionProps extends WidgetsCommonPropsAndState {
|
|
6
5
|
/**
|
|
7
6
|
* If `true`, only one item at the time can stay open.
|
|
@@ -126,6 +125,12 @@ export interface AccordionProps extends WidgetsCommonPropsAndState {
|
|
|
126
125
|
* It is a prop of the accordion-item.
|
|
127
126
|
*/
|
|
128
127
|
itemBodyClass: string;
|
|
128
|
+
/**
|
|
129
|
+
* The html tag to use for the accordion-item-header.
|
|
130
|
+
*
|
|
131
|
+
* It is a prop of the accordion-item.
|
|
132
|
+
*/
|
|
133
|
+
itemHeadingTag: string;
|
|
129
134
|
}
|
|
130
135
|
export interface AccordionState extends WidgetsCommonPropsAndState {
|
|
131
136
|
/**
|
|
@@ -263,6 +268,10 @@ export interface AccordionItemCommonPropsAndState {
|
|
|
263
268
|
* Classes to add on the accordion-item body DOM element.
|
|
264
269
|
*/
|
|
265
270
|
itemBodyClass: string;
|
|
271
|
+
/**
|
|
272
|
+
* The html tag to use for the accordion-item-header.
|
|
273
|
+
*/
|
|
274
|
+
itemHeadingTag: string;
|
|
266
275
|
}
|
|
267
276
|
export interface AccordionItemProps extends AccordionItemCommonPropsAndState {
|
|
268
277
|
/**
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createTransition } from '
|
|
3
|
-
import { collapseVerticalTransition } from '
|
|
4
|
-
import { computed,
|
|
5
|
-
import { noop } from '
|
|
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';
|
|
6
8
|
let itemId = 0;
|
|
7
9
|
function getItemId() {
|
|
8
10
|
return `accordion-item-${itemId++}`;
|
|
@@ -35,11 +37,12 @@ const defaultAccordionConfig = {
|
|
|
35
37
|
onHidden: noop,
|
|
36
38
|
className: '',
|
|
37
39
|
itemId: '',
|
|
38
|
-
itemDestroyOnHide:
|
|
40
|
+
itemDestroyOnHide: true,
|
|
39
41
|
itemDisabled: false,
|
|
40
42
|
itemVisible: false,
|
|
41
43
|
itemAnimation: true,
|
|
42
44
|
itemTransition: collapseVerticalTransition,
|
|
45
|
+
itemHeadingTag: '',
|
|
43
46
|
onItemShown: noop,
|
|
44
47
|
onItemHidden: noop,
|
|
45
48
|
onItemVisibleChange: noop,
|
|
@@ -70,6 +73,7 @@ const defaultItemConfig = {
|
|
|
70
73
|
itemButtonClass: defaultAccordionConfig.itemButtonClass,
|
|
71
74
|
itemCollapseClass: defaultAccordionConfig.itemCollapseClass,
|
|
72
75
|
itemBodyClass: defaultAccordionConfig.itemBodyClass,
|
|
76
|
+
itemHeadingTag: defaultAccordionConfig.itemHeadingTag,
|
|
73
77
|
};
|
|
74
78
|
const accordionItemProps = Object.keys(defaultItemConfig);
|
|
75
79
|
/**
|
|
@@ -97,6 +101,7 @@ const configAccordionValidator = {
|
|
|
97
101
|
itemButtonClass: typeString,
|
|
98
102
|
itemCollapseClass: typeString,
|
|
99
103
|
itemBodyClass: typeString,
|
|
104
|
+
itemHeadingTag: typeString,
|
|
100
105
|
};
|
|
101
106
|
const configItemValidator = {
|
|
102
107
|
itemId: typeString,
|
|
@@ -113,14 +118,14 @@ const configItemValidator = {
|
|
|
113
118
|
itemButtonClass: typeString,
|
|
114
119
|
itemCollapseClass: typeString,
|
|
115
120
|
itemBodyClass: typeString,
|
|
121
|
+
itemHeadingTag: typeString,
|
|
116
122
|
};
|
|
117
123
|
function createAccordionItem(accordionOnShown, accordionOnHidden, config) {
|
|
118
124
|
const [{ itemAnimation$, itemTransition$, itemDestroyOnHide$, onItemShown$, onItemHidden$, onItemVisibleChange$, itemVisible$, itemId$: _dirtyItemId$, itemDisabled$, ...stateProps }, patch,] = writablesForProps(defaultItemConfig, config, configItemValidator);
|
|
119
125
|
const initDone$ = writable(false);
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
});
|
|
126
|
+
const _autoItemId$ = computed(() => getItemId());
|
|
127
|
+
const itemId$ = computed(() => _dirtyItemId$() || _autoItemId$());
|
|
128
|
+
const shouldBeInDOM$ = computed(() => itemDestroyOnHide$() === false || !itemTransition.state$().hidden);
|
|
124
129
|
const itemTransition = createTransition({
|
|
125
130
|
props: {
|
|
126
131
|
transition: itemTransition$,
|
|
@@ -178,7 +183,7 @@ function createAccordionItem(accordionOnShown, accordionOnHidden, config) {
|
|
|
178
183
|
* @returns a new accordion widget instance
|
|
179
184
|
*/
|
|
180
185
|
export function createAccordion(config) {
|
|
181
|
-
const [{ closeOthers$, onShown$, onHidden$, itemId$, itemAnimation$, itemClass$, itemDisabled$, itemVisible$, itemTransition$, itemDestroyOnHide$, itemBodyClass$, itemButtonClass$, itemCollapseClass$, itemHeaderClass$, onItemVisibleChange$, onItemHidden$, onItemShown$, slotItemStructure$, slotItemBody$, slotItemHeader$, ...stateProps }, patch,] = writablesForProps(defaultAccordionConfig, config, configAccordionValidator);
|
|
186
|
+
const [{ closeOthers$, onShown$, onHidden$, itemId$, itemAnimation$, itemClass$, itemDisabled$, itemVisible$, itemTransition$, itemDestroyOnHide$, itemBodyClass$, itemButtonClass$, itemCollapseClass$, itemHeaderClass$, itemHeadingTag$, onItemVisibleChange$, onItemHidden$, onItemShown$, slotItemStructure$, slotItemBody$, slotItemHeader$, ...stateProps }, patch,] = writablesForProps(defaultAccordionConfig, config, configAccordionValidator);
|
|
182
187
|
const accordionItemConfig = {
|
|
183
188
|
itemId: itemId$,
|
|
184
189
|
itemClass: itemClass$,
|
|
@@ -191,6 +196,7 @@ export function createAccordion(config) {
|
|
|
191
196
|
itemButtonClass: itemButtonClass$,
|
|
192
197
|
itemCollapseClass: itemCollapseClass$,
|
|
193
198
|
itemHeaderClass: itemHeaderClass$,
|
|
199
|
+
itemHeadingTag: itemHeadingTag$,
|
|
194
200
|
onItemVisibleChange: onItemVisibleChange$,
|
|
195
201
|
onItemHidden: onItemHidden$,
|
|
196
202
|
onItemShown: onItemShown$,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CommonAlertApi, CommonAlertDirectives, CommonAlertProps, CommonAlertState } from './common';
|
|
2
|
+
import type { ExtendWidgetAdaptSlotWidgetProps } from '../../services/extendWidget';
|
|
3
|
+
import type { Widget, WidgetFactory, WidgetSlotContext } from '../../types';
|
|
4
|
+
export * from './common';
|
|
5
|
+
export type AlertContext = WidgetSlotContext<AlertWidget>;
|
|
6
|
+
export interface AlertExtraProps {
|
|
7
|
+
/**
|
|
8
|
+
* Type of the alert.
|
|
9
|
+
* There are the following types: 'success', 'info', 'warning', 'danger', 'primary', 'secondary', 'light' and 'dark'.
|
|
10
|
+
*/
|
|
11
|
+
type: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AlertState extends ExtendWidgetAdaptSlotWidgetProps<CommonAlertState, AlertExtraProps> {
|
|
14
|
+
}
|
|
15
|
+
export interface AlertProps extends ExtendWidgetAdaptSlotWidgetProps<CommonAlertProps, AlertExtraProps> {
|
|
16
|
+
}
|
|
17
|
+
export interface AlertApi extends CommonAlertApi {
|
|
18
|
+
}
|
|
19
|
+
export interface AlertDirectives extends CommonAlertDirectives {
|
|
20
|
+
}
|
|
21
|
+
export type AlertWidget = Widget<AlertProps, AlertState, AlertApi, object, AlertDirectives>;
|
|
22
|
+
/**
|
|
23
|
+
* Retrieve a shallow copy of the default alert config
|
|
24
|
+
* @returns the default alert config
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAlertDefaultConfig(): AlertProps;
|
|
27
|
+
/**
|
|
28
|
+
* Create an AlertWidget with given config props
|
|
29
|
+
* @param config - an optional alert config
|
|
30
|
+
* @returns an AlertWidget
|
|
31
|
+
*/
|
|
32
|
+
export declare const createAlert: WidgetFactory<AlertWidget>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createCommonAlert, getCommonAlertDefaultConfig } from './common';
|
|
2
|
+
import { extendWidgetProps } from '../../services/extendWidget';
|
|
3
|
+
import { typeString } from '../../utils/writables';
|
|
4
|
+
export * from './common';
|
|
5
|
+
const alertDefaultConfig = {
|
|
6
|
+
type: 'primary',
|
|
7
|
+
};
|
|
8
|
+
const alertConfigValidator = {
|
|
9
|
+
type: typeString,
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Retrieve a shallow copy of the default alert config
|
|
13
|
+
* @returns the default alert config
|
|
14
|
+
*/
|
|
15
|
+
export function getAlertDefaultConfig() {
|
|
16
|
+
return { ...getCommonAlertDefaultConfig(), ...alertDefaultConfig };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create an AlertWidget with given config props
|
|
20
|
+
* @param config - an optional alert config
|
|
21
|
+
* @returns an AlertWidget
|
|
22
|
+
*/
|
|
23
|
+
export const createAlert = extendWidgetProps(createCommonAlert, alertDefaultConfig, alertConfigValidator);
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export interface AlertCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
1
|
+
import type { TransitionFn } from '../../services/transitions/baseTransitions';
|
|
2
|
+
import type { WidgetsCommonPropsAndState } from '../commonProps';
|
|
3
|
+
import type { ConfigValidator, Directive, PropsConfig, SlotContent, Widget, WidgetSlotContext } from '../../types';
|
|
4
|
+
export type CommonAlertContext = WidgetSlotContext<CommonAlertWidget>;
|
|
5
|
+
export interface CommonAlertCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
7
6
|
/**
|
|
8
7
|
* If `true`, alert can be dismissed by the user.
|
|
9
8
|
* The close button (×) will be displayed and you can be notified of the event with the (close) output.
|
|
10
9
|
*/
|
|
11
10
|
dismissible: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Type of the alert.
|
|
14
|
-
* There are the following types: 'success', 'info', 'warning', 'danger', 'primary', 'secondary', 'light' and 'dark'.
|
|
15
|
-
*/
|
|
16
|
-
type: string;
|
|
17
11
|
/**
|
|
18
12
|
* Template for the alert content
|
|
19
13
|
*/
|
|
20
|
-
slotDefault: SlotContent<
|
|
14
|
+
slotDefault: SlotContent<CommonAlertContext>;
|
|
21
15
|
/**
|
|
22
16
|
* Global template for the alert component
|
|
23
17
|
*/
|
|
24
|
-
slotStructure: SlotContent<
|
|
18
|
+
slotStructure: SlotContent<CommonAlertContext>;
|
|
25
19
|
/**
|
|
26
20
|
* If `true` the alert is visible to the user
|
|
27
21
|
*/
|
|
@@ -31,13 +25,13 @@ export interface AlertCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
|
31
25
|
*/
|
|
32
26
|
ariaCloseButtonLabel: string;
|
|
33
27
|
}
|
|
34
|
-
export interface
|
|
28
|
+
export interface CommonAlertState extends CommonAlertCommonPropsAndState {
|
|
35
29
|
/**
|
|
36
30
|
* Is `true` when the alert is hidden. Compared to `visible`, this is updated after the transition is executed.
|
|
37
31
|
*/
|
|
38
32
|
hidden: boolean;
|
|
39
33
|
}
|
|
40
|
-
export interface
|
|
34
|
+
export interface CommonAlertProps extends CommonAlertCommonPropsAndState {
|
|
41
35
|
/**
|
|
42
36
|
* Callback called when the alert visibility changed.
|
|
43
37
|
*/
|
|
@@ -53,7 +47,7 @@ export interface AlertProps extends AlertCommonPropsAndState {
|
|
|
53
47
|
/**
|
|
54
48
|
* The transition function will be executed when the alert is displayed or hidden.
|
|
55
49
|
*
|
|
56
|
-
* Depending on the value of {@link
|
|
50
|
+
* Depending on the value of {@link CommonAlertProps.animationOnInit}, the animation can be optionally skipped during the showing process.
|
|
57
51
|
*/
|
|
58
52
|
transition: TransitionFn;
|
|
59
53
|
/**
|
|
@@ -71,7 +65,7 @@ export interface AlertProps extends AlertCommonPropsAndState {
|
|
|
71
65
|
*/
|
|
72
66
|
animation: boolean;
|
|
73
67
|
}
|
|
74
|
-
export interface
|
|
68
|
+
export interface CommonAlertApi {
|
|
75
69
|
/**
|
|
76
70
|
* Triggers alert closing programmatically (same as clicking on the close button (×)).
|
|
77
71
|
*/
|
|
@@ -81,21 +75,23 @@ export interface AlertApi {
|
|
|
81
75
|
*/
|
|
82
76
|
open(): void;
|
|
83
77
|
}
|
|
84
|
-
export interface
|
|
78
|
+
export interface CommonAlertDirectives {
|
|
85
79
|
/**
|
|
86
80
|
* the transition directive, piloting what is the visual effect of going from hidden to visible
|
|
87
81
|
*/
|
|
88
82
|
transitionDirective: Directive;
|
|
89
83
|
}
|
|
90
|
-
export type
|
|
84
|
+
export type CommonAlertWidget = Widget<CommonAlertProps, CommonAlertState, CommonAlertApi, object, CommonAlertDirectives>;
|
|
85
|
+
export declare const defaultCommonAlertConfig: CommonAlertProps;
|
|
91
86
|
/**
|
|
92
87
|
* Retrieve a shallow copy of the default alert config
|
|
93
88
|
* @returns the default alert config
|
|
94
89
|
*/
|
|
95
|
-
export declare function
|
|
90
|
+
export declare function getCommonAlertDefaultConfig(): CommonAlertProps;
|
|
91
|
+
export declare const commonAlertConfigValidator: ConfigValidator<CommonAlertProps>;
|
|
96
92
|
/**
|
|
97
93
|
* Create an AlertWidget with given config props
|
|
98
94
|
* @param config - an optional alert config
|
|
99
95
|
* @returns an AlertWidget
|
|
100
96
|
*/
|
|
101
|
-
export declare function
|
|
97
|
+
export declare function createCommonAlert(config?: PropsConfig<CommonAlertProps>): CommonAlertWidget;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { fadeTransition } from '
|
|
4
|
-
import {
|
|
5
|
-
|
|
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 = {
|
|
6
8
|
visible: true,
|
|
7
9
|
dismissible: true,
|
|
8
|
-
type: 'primary',
|
|
9
10
|
ariaCloseButtonLabel: 'Close',
|
|
10
11
|
onVisibleChange: noop,
|
|
11
12
|
onShown: noop,
|
|
@@ -21,20 +22,19 @@ const defaultConfig = {
|
|
|
21
22
|
* Retrieve a shallow copy of the default alert config
|
|
22
23
|
* @returns the default alert config
|
|
23
24
|
*/
|
|
24
|
-
export function
|
|
25
|
-
return { ...
|
|
25
|
+
export function getCommonAlertDefaultConfig() {
|
|
26
|
+
return { ...defaultCommonAlertConfig };
|
|
26
27
|
}
|
|
27
|
-
const
|
|
28
|
+
export const commonAlertConfigValidator = {
|
|
28
29
|
dismissible: typeBoolean,
|
|
29
|
-
type: typeString,
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Create an AlertWidget with given config props
|
|
33
33
|
* @param config - an optional alert config
|
|
34
34
|
* @returns an AlertWidget
|
|
35
35
|
*/
|
|
36
|
-
export function
|
|
37
|
-
const [{ transition$, animationOnInit$, animation$, visible$: requestedVisible$, onVisibleChange$, onHidden$, onShown$, ...stateProps }, patch,] = writablesForProps(
|
|
36
|
+
export function createCommonAlert(config) {
|
|
37
|
+
const [{ transition$, animationOnInit$, animation$, visible$: requestedVisible$, onVisibleChange$, onHidden$, onShown$, ...stateProps }, patch,] = writablesForProps(defaultCommonAlertConfig, config, commonAlertConfigValidator);
|
|
38
38
|
const transition = createTransition({
|
|
39
39
|
props: {
|
|
40
40
|
transition: transition$,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { PropsConfig } from '../services';
|
|
2
|
-
import type { TransitionFn } from '../transitions';
|
|
3
|
-
import type { Widget, Directive, SlotContent, WidgetSlotContext } from '../types';
|
|
4
1
|
import type { WidgetsCommonPropsAndState } from '../commonProps';
|
|
2
|
+
import type { TransitionFn } from '../../services/transitions/baseTransitions';
|
|
3
|
+
import type { Directive, PropsConfig, SlotContent, Widget, WidgetSlotContext } from '../../types';
|
|
5
4
|
/**
|
|
6
5
|
* Value present in the {@link ModalBeforeCloseEvent.result|result} property of the {@link ModalProps.onBeforeClose|onBeforeClose} event
|
|
7
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.
|
|
@@ -15,11 +14,11 @@ export declare const modalCloseButtonClick: unique symbol;
|
|
|
15
14
|
/**
|
|
16
15
|
* Context of the modal slots.
|
|
17
16
|
*/
|
|
18
|
-
export type ModalContext = WidgetSlotContext<ModalWidget
|
|
17
|
+
export type ModalContext<Data> = WidgetSlotContext<ModalWidget<Data>>;
|
|
19
18
|
/**
|
|
20
19
|
* Properties of the modal widget that are also in the state of the modal.
|
|
21
20
|
*/
|
|
22
|
-
export interface ModalCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
21
|
+
export interface ModalCommonPropsAndState<Data> extends WidgetsCommonPropsAndState {
|
|
23
22
|
/**
|
|
24
23
|
* Value of the aria-label attribute to put on the close button.
|
|
25
24
|
*/
|
|
@@ -41,28 +40,32 @@ export interface ModalCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
|
41
40
|
/**
|
|
42
41
|
* Body of the modal.
|
|
43
42
|
*/
|
|
44
|
-
slotDefault: SlotContent<ModalContext
|
|
43
|
+
slotDefault: SlotContent<ModalContext<Data>>;
|
|
45
44
|
/**
|
|
46
45
|
* Footer of the modal.
|
|
47
46
|
*/
|
|
48
|
-
slotFooter: SlotContent<ModalContext
|
|
47
|
+
slotFooter: SlotContent<ModalContext<Data>>;
|
|
49
48
|
/**
|
|
50
49
|
* Header of the modal. The default header includes {@link ModalCommonPropsAndState.slotTitle|slotTitle}.
|
|
51
50
|
*/
|
|
52
|
-
slotHeader: SlotContent<ModalContext
|
|
51
|
+
slotHeader: SlotContent<ModalContext<Data>>;
|
|
53
52
|
/**
|
|
54
53
|
* Structure of the modal.
|
|
55
54
|
* The default structure uses {@link ModalCommonPropsAndState.slotHeader|slotHeader}, {@link ModalCommonPropsAndState.slotDefault|slotDefault} and {@link ModalCommonPropsAndState.slotFooter|slotFooter}.
|
|
56
55
|
*/
|
|
57
|
-
slotStructure: SlotContent<ModalContext
|
|
56
|
+
slotStructure: SlotContent<ModalContext<Data>>;
|
|
58
57
|
/**
|
|
59
58
|
* Title of the modal.
|
|
60
59
|
*/
|
|
61
|
-
slotTitle: SlotContent<ModalContext
|
|
60
|
+
slotTitle: SlotContent<ModalContext<Data>>;
|
|
62
61
|
/**
|
|
63
62
|
* Whether the modal should be visible when the transition is completed.
|
|
64
63
|
*/
|
|
65
64
|
visible: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Data to use in content slots
|
|
67
|
+
*/
|
|
68
|
+
contentData: Data;
|
|
66
69
|
}
|
|
67
70
|
/**
|
|
68
71
|
* Type of the parameter of {@link ModalProps.onBeforeClose|onBeforeClose}.
|
|
@@ -83,7 +86,7 @@ export interface ModalBeforeCloseEvent {
|
|
|
83
86
|
/**
|
|
84
87
|
* Properties of the modal widget.
|
|
85
88
|
*/
|
|
86
|
-
export interface ModalProps extends ModalCommonPropsAndState {
|
|
89
|
+
export interface ModalProps<Data> extends ModalCommonPropsAndState<Data> {
|
|
87
90
|
/**
|
|
88
91
|
* Whether the modal and its backdrop (if present) should be animated when shown or hidden.
|
|
89
92
|
*/
|
|
@@ -129,7 +132,7 @@ export interface ModalProps extends ModalCommonPropsAndState {
|
|
|
129
132
|
/**
|
|
130
133
|
* State of the modal widget.
|
|
131
134
|
*/
|
|
132
|
-
export interface ModalState extends ModalCommonPropsAndState {
|
|
135
|
+
export interface ModalState<Data> extends ModalCommonPropsAndState<Data> {
|
|
133
136
|
/**
|
|
134
137
|
* Whether the backdrop is fully hidden. This can be true either because {@link ModalProps.backdrop|backdrop} is false or
|
|
135
138
|
* because {@link ModalCommonPropsAndState.visible|visible} is false and there is no current transition.
|
|
@@ -151,7 +154,7 @@ export interface ModalState extends ModalCommonPropsAndState {
|
|
|
151
154
|
/**
|
|
152
155
|
* API of the modal widget.
|
|
153
156
|
*/
|
|
154
|
-
export interface ModalApi {
|
|
157
|
+
export interface ModalApi<Data> {
|
|
155
158
|
/**
|
|
156
159
|
* Closes the modal with the given result.
|
|
157
160
|
*
|
|
@@ -168,7 +171,7 @@ export interface ModalApi {
|
|
|
168
171
|
/**
|
|
169
172
|
* Method to change some modal properties.
|
|
170
173
|
*/
|
|
171
|
-
patch: ModalWidget['patch'];
|
|
174
|
+
patch: ModalWidget<Data>['patch'];
|
|
172
175
|
}
|
|
173
176
|
/**
|
|
174
177
|
* Actions of the modal widget.
|
|
@@ -212,7 +215,7 @@ export interface ModalDirectives {
|
|
|
212
215
|
/**
|
|
213
216
|
* Modal widget.
|
|
214
217
|
*/
|
|
215
|
-
export type ModalWidget = Widget<ModalProps
|
|
218
|
+
export type ModalWidget<Data> = Widget<ModalProps<Data>, ModalState<Data>, ModalApi<Data>, ModalActions, ModalDirectives>;
|
|
216
219
|
/**
|
|
217
220
|
* Returns a copy of the default modal config.
|
|
218
221
|
* @returns a copy of the default modal config
|
|
@@ -280,28 +283,32 @@ export declare function getModalDefaultConfig(): {
|
|
|
280
283
|
/**
|
|
281
284
|
* Body of the modal.
|
|
282
285
|
*/
|
|
283
|
-
slotDefault: SlotContent<ModalContext
|
|
286
|
+
slotDefault: SlotContent<ModalContext<any>>;
|
|
284
287
|
/**
|
|
285
288
|
* Footer of the modal.
|
|
286
289
|
*/
|
|
287
|
-
slotFooter: SlotContent<ModalContext
|
|
290
|
+
slotFooter: SlotContent<ModalContext<any>>;
|
|
288
291
|
/**
|
|
289
292
|
* Header of the modal. The default header includes {@link ModalCommonPropsAndState.slotTitle|slotTitle}.
|
|
290
293
|
*/
|
|
291
|
-
slotHeader: SlotContent<ModalContext
|
|
294
|
+
slotHeader: SlotContent<ModalContext<any>>;
|
|
292
295
|
/**
|
|
293
296
|
* Structure of the modal.
|
|
294
297
|
* The default structure uses {@link ModalCommonPropsAndState.slotHeader|slotHeader}, {@link ModalCommonPropsAndState.slotDefault|slotDefault} and {@link ModalCommonPropsAndState.slotFooter|slotFooter}.
|
|
295
298
|
*/
|
|
296
|
-
slotStructure: SlotContent<ModalContext
|
|
299
|
+
slotStructure: SlotContent<ModalContext<any>>;
|
|
297
300
|
/**
|
|
298
301
|
* Title of the modal.
|
|
299
302
|
*/
|
|
300
|
-
slotTitle: SlotContent<ModalContext
|
|
303
|
+
slotTitle: SlotContent<ModalContext<any>>;
|
|
301
304
|
/**
|
|
302
305
|
* Whether the modal should be visible when the transition is completed.
|
|
303
306
|
*/
|
|
304
307
|
visible: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Data to use in content slots
|
|
310
|
+
*/
|
|
311
|
+
contentData: any;
|
|
305
312
|
className: string;
|
|
306
313
|
};
|
|
307
314
|
/**
|
|
@@ -309,4 +316,4 @@ export declare function getModalDefaultConfig(): {
|
|
|
309
316
|
* @param config$ - config of the modal, either as a store or as an object containing values or stores.
|
|
310
317
|
* @returns a new modal widget instance
|
|
311
318
|
*/
|
|
312
|
-
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.
|
|
@@ -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,8 +84,8 @@ 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
90
|
props: {
|
|
69
91
|
transition: modalTransition$,
|
|
@@ -108,10 +130,14 @@ export const createModal = (config$) => {
|
|
|
108
130
|
patch({ visible: false });
|
|
109
131
|
};
|
|
110
132
|
const modalPortalDirective = bindDirective(portal, computed(() => ({ container: container$() })));
|
|
111
|
-
const backdropPortalDirective = bindDirective(portal, computed(() =>
|
|
112
|
-
container
|
|
113
|
-
|
|
114
|
-
|
|
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
|
+
}));
|
|
115
141
|
const registerModalAction$ = readable(undefined, () => modals$.register(res));
|
|
116
142
|
const action$ = computed(() => {
|
|
117
143
|
if (modalTransition.stores.elementPresent$() && !hidden$()) {
|
|
@@ -157,4 +183,4 @@ export const createModal = (config$) => {
|
|
|
157
183
|
},
|
|
158
184
|
};
|
|
159
185
|
return res;
|
|
160
|
-
}
|
|
186
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { PropsConfig } from '
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import type { PropsConfig, Widget, SlotContent, WidgetSlotContext } from '../../types';
|
|
2
|
+
import type { WidgetsCommonPropsAndState } from '../commonProps';
|
|
3
|
+
export * from './bootstrap';
|
|
4
4
|
/**
|
|
5
5
|
* A type for the slot context of the pagination widget
|
|
6
6
|
*/
|
|
@@ -1,8 +1,10 @@
|
|
|
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';
|
|
7
|
+
export * from './bootstrap';
|
|
6
8
|
const defaultConfig = {
|
|
7
9
|
page: 1,
|
|
8
10
|
collectionSize: 0,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { PropsConfig } from '
|
|
2
|
-
import type {
|
|
3
|
-
import type { WidgetsCommonPropsAndState } from './commonProps';
|
|
1
|
+
import type { PropsConfig, SlotContent, Widget, WidgetSlotContext } from '../../types';
|
|
2
|
+
import type { WidgetsCommonPropsAndState } from '../commonProps';
|
|
4
3
|
export type ProgressbarContext = WidgetSlotContext<ProgressbarWidget>;
|
|
5
4
|
export interface ProgressbarCommonPropsAndState extends WidgetsCommonPropsAndState {
|
|
6
5
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { clamp } from '
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
5
|
const defaultConfig = {
|
|
6
6
|
min: 0,
|
|
7
7
|
max: 100,
|
|
@@ -44,8 +44,8 @@ export function createProgressbar(config) {
|
|
|
44
44
|
max$: _dirtyMaximum$, value$: _dirtyValue$,
|
|
45
45
|
// clean inputs
|
|
46
46
|
min$, ariaValueTextFn$, ...stateProps }, patch,] = writablesForProps(defaultConfig, config, configValidator);
|
|
47
|
-
const max$ =
|
|
48
|
-
const value$ =
|
|
47
|
+
const max$ = computed(() => Math.max(min$(), _dirtyMaximum$()));
|
|
48
|
+
const value$ = computed(() => clamp(_dirtyValue$(), max$(), min$()));
|
|
49
49
|
const percentage$ = computed(() => {
|
|
50
50
|
const max = max$();
|
|
51
51
|
const min = min$();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { PropsConfig } from '
|
|
2
|
-
import type {
|
|
3
|
-
import type { WidgetsCommonPropsAndState } from './commonProps';
|
|
1
|
+
import type { PropsConfig, SlotContent, Widget } from '../../types';
|
|
2
|
+
import type { WidgetsCommonPropsAndState } from '../commonProps';
|
|
4
3
|
export interface StarContext {
|
|
5
4
|
/**
|
|
6
5
|
* indicates how much the current star is filled, from 0 to 100
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { computed, writable } from '@amadeus-it-group/tansu';
|
|
2
|
-
import { INVALID_VALUE
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return Math.max(Math.min(rating, maxRating), 0);
|
|
8
|
-
}
|
|
9
|
-
const noop = () => { };
|
|
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';
|
|
10
7
|
const defaultConfig = {
|
|
11
8
|
rating: 0,
|
|
12
9
|
tabindex: 0,
|
|
@@ -60,7 +57,7 @@ export function createRating(config) {
|
|
|
60
57
|
const { maxRating$, disabled$, readonly$, resettable$ } = stateProps;
|
|
61
58
|
// clean inputs adjustment to valid range
|
|
62
59
|
const tabindex$ = computed(() => (disabled$() ? -1 : _dirtyTabindex$()));
|
|
63
|
-
const rating$ = bindableDerived(onRatingChange$, [_dirtyRating$, maxRating$], ([dirtyRating, maxRating]) =>
|
|
60
|
+
const rating$ = bindableDerived(onRatingChange$, [_dirtyRating$, maxRating$], ([dirtyRating, maxRating]) => clamp(dirtyRating, maxRating));
|
|
64
61
|
// internal inputs
|
|
65
62
|
const _hoveredRating$ = writable(0);
|
|
66
63
|
// computed
|