@agnos-ui/core 0.0.1-alpha.4 → 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.
Files changed (97) hide show
  1. package/{accordion.d.ts → components/accordion/accordion.d.ts} +3 -4
  2. package/{accordion.js → components/accordion/accordion.js} +10 -9
  3. package/components/alert/alert.d.ts +32 -0
  4. package/components/alert/alert.js +23 -0
  5. package/{alert.d.ts → components/alert/common.d.ts} +17 -21
  6. package/{alert.js → components/alert/common.js} +12 -12
  7. package/{modal → components/modal}/modal.d.ts +28 -21
  8. package/{modal → components/modal}/modal.js +39 -13
  9. package/{pagination.d.ts → components/pagination/pagination.d.ts} +3 -3
  10. package/{pagination.js → components/pagination/pagination.js} +6 -4
  11. package/{progressbar.d.ts → components/progressbar/progressbar.d.ts} +2 -3
  12. package/{progressbar.js → components/progressbar/progressbar.js} +6 -6
  13. package/{rating.d.ts → components/rating/rating.d.ts} +2 -3
  14. package/{rating.js → components/rating/rating.js} +6 -9
  15. package/components/select/select.d.ts +337 -0
  16. package/components/select/select.js +266 -0
  17. package/{slider.d.ts → components/slider/slider.d.ts} +60 -14
  18. package/components/slider/slider.js +389 -0
  19. package/config.d.ts +9 -9
  20. package/config.js +3 -3
  21. package/index.d.ts +23 -13
  22. package/index.js +29 -13
  23. package/package.json +30 -3
  24. package/services/extendWidget.d.ts +23 -0
  25. package/{extendWidget.js → services/extendWidget.js} +8 -1
  26. package/services/floatingUI.d.ts +48 -0
  27. package/services/floatingUI.js +97 -0
  28. package/services/focustrack.js +1 -1
  29. package/services/intersection.d.ts +1 -1
  30. package/services/intersection.js +2 -2
  31. package/services/navManager.d.ts +83 -1
  32. package/services/navManager.js +153 -37
  33. package/services/portal.js +8 -4
  34. package/services/siblingsInert.d.ts +2 -1
  35. package/services/siblingsInert.js +2 -2
  36. package/{transitions → services/transitions}/baseTransitions.d.ts +1 -2
  37. package/{transitions → services/transitions}/baseTransitions.js +7 -10
  38. package/services/transitions/bootstrap/collapse.d.ts +2 -0
  39. package/services/transitions/bootstrap/fade.d.ts +1 -0
  40. package/services/transitions/bootstrap.d.ts +2 -0
  41. package/services/transitions/bootstrap.js +2 -0
  42. package/{transitions → services/transitions}/collapse.js +1 -1
  43. package/{transitions → services/transitions}/cssTransitions.js +2 -4
  44. package/{transitions → services/transitions}/simpleClassTransition.js +1 -1
  45. package/types.d.ts +37 -4
  46. package/types.js +1 -0
  47. package/{services/directiveUtils.js → utils/directive.js} +1 -1
  48. package/{services → utils/internal}/checks.d.ts +12 -0
  49. package/{services → utils/internal}/checks.js +12 -0
  50. package/utils/internal/dom.d.ts +13 -0
  51. package/utils/internal/dom.js +49 -0
  52. package/utils/internal/math.d.ts +5 -0
  53. package/utils/internal/math.js +13 -0
  54. package/utils/internal/promise.d.ts +31 -0
  55. package/utils/internal/promise.js +113 -0
  56. package/{modal → utils/internal}/scrollbars.js +1 -1
  57. package/utils/internal/textDirection.d.ts +1 -0
  58. package/utils/internal/textDirection.js +1 -0
  59. package/utils/internal/traversal.d.ts +54 -0
  60. package/utils/internal/traversal.js +105 -0
  61. package/{services → utils}/stores.d.ts +11 -35
  62. package/{services → utils}/stores.js +21 -19
  63. package/utils/writables.d.ts +26 -0
  64. package/utils/writables.js +66 -0
  65. package/extendWidget.d.ts +0 -3
  66. package/select.d.ts +0 -196
  67. package/select.js +0 -240
  68. package/services/index.d.ts +0 -9
  69. package/services/index.js +0 -9
  70. package/services/writables.d.ts +0 -8
  71. package/services/writables.js +0 -30
  72. package/slider.js +0 -289
  73. package/transitions/bootstrap/collapse.d.ts +0 -2
  74. package/transitions/bootstrap/fade.d.ts +0 -1
  75. package/transitions/bootstrap/index.d.ts +0 -2
  76. package/transitions/bootstrap/index.js +0 -2
  77. package/transitions/index.d.ts +0 -5
  78. package/transitions/index.js +0 -5
  79. package/transitions/utils.d.ts +0 -20
  80. package/transitions/utils.js +0 -83
  81. /package/{commonProps.d.ts → components/commonProps.d.ts} +0 -0
  82. /package/{commonProps.js → components/commonProps.js} +0 -0
  83. /package/{pagination.utils.d.ts → components/pagination/bootstrap.d.ts} +0 -0
  84. /package/{pagination.utils.js → components/pagination/bootstrap.js} +0 -0
  85. /package/{transitions → services/transitions}/bootstrap/collapse.js +0 -0
  86. /package/{transitions → services/transitions}/bootstrap/fade.js +0 -0
  87. /package/{transitions → services/transitions}/collapse.d.ts +0 -0
  88. /package/{transitions → services/transitions}/cssTransitions.d.ts +0 -0
  89. /package/{transitions → services/transitions}/simpleClassTransition.d.ts +0 -0
  90. /package/{services/directiveUtils.d.ts → utils/directive.d.ts} +0 -0
  91. /package/{utils.d.ts → utils/internal/func.d.ts} +0 -0
  92. /package/{utils.js → utils/internal/func.js} +0 -0
  93. /package/{services → utils/internal}/isFocusable.d.ts +0 -0
  94. /package/{services → utils/internal}/isFocusable.js +0 -0
  95. /package/{modal → utils/internal}/scrollbars.d.ts +0 -0
  96. /package/{services/sortUtils.d.ts → utils/internal/sort.d.ts} +0 -0
  97. /package/{services/sortUtils.js → utils/internal/sort.js} +0 -0
@@ -1,7 +1,6 @@
1
- import type { PropsConfig } from './services';
2
- import type { TransitionFn } from './transitions';
3
- import type { Directive, SlotContent, Widget, WidgetSlotContext } from './types';
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.
@@ -1,8 +1,10 @@
1
- import { bindDirectiveNoArg, bindableDerived, directiveSubscribe, registrationArray, stateStores, typeBoolean, typeFunction, typeString, writablesForProps, normalizeConfigStores, mergeConfigStores, } from './services';
2
- import { createTransition } from './transitions';
3
- import { collapseVerticalTransition } from './transitions/bootstrap';
4
- import { computed, readable, writable } from '@amadeus-it-group/tansu';
5
- import { noop } from './utils';
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++}`;
@@ -121,10 +123,9 @@ const configItemValidator = {
121
123
  function createAccordionItem(accordionOnShown, accordionOnHidden, config) {
122
124
  const [{ itemAnimation$, itemTransition$, itemDestroyOnHide$, onItemShown$, onItemHidden$, onItemVisibleChange$, itemVisible$, itemId$: _dirtyItemId$, itemDisabled$, ...stateProps }, patch,] = writablesForProps(defaultItemConfig, config, configItemValidator);
123
125
  const initDone$ = writable(false);
124
- const itemId$ = bindableDerived(readable(noop), [_dirtyItemId$], ([dirtyItemId]) => (dirtyItemId ? dirtyItemId : getItemId()));
125
- const shouldBeInDOM$ = computed(() => {
126
- return itemDestroyOnHide$() === false || !itemTransition.state$().hidden;
127
- });
126
+ const _autoItemId$ = computed(() => getItemId());
127
+ const itemId$ = computed(() => _dirtyItemId$() || _autoItemId$());
128
+ const shouldBeInDOM$ = computed(() => itemDestroyOnHide$() === false || !itemTransition.state$().hidden);
128
129
  const itemTransition = createTransition({
129
130
  props: {
130
131
  transition: itemTransition$,
@@ -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 { WidgetsCommonPropsAndState } from './commonProps';
2
- import type { PropsConfig } from './services';
3
- import type { TransitionFn } from './transitions';
4
- import type { Directive, SlotContent, Widget, WidgetSlotContext } from './types';
5
- export type AlertContext = WidgetSlotContext<AlertWidget>;
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<AlertContext>;
14
+ slotDefault: SlotContent<CommonAlertContext>;
21
15
  /**
22
16
  * Global template for the alert component
23
17
  */
24
- slotStructure: SlotContent<AlertContext>;
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 AlertState extends AlertCommonPropsAndState {
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 AlertProps extends AlertCommonPropsAndState {
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 AlertProps.animationOnInit}, the animation can be optionally skipped during the showing process.
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 AlertApi {
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 AlertDirectives {
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 AlertWidget = Widget<AlertProps, AlertState, AlertApi, object, AlertDirectives>;
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 getAlertDefaultConfig(): AlertProps;
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 createAlert(config?: PropsConfig<AlertProps>): AlertWidget;
97
+ export declare function createCommonAlert(config?: PropsConfig<CommonAlertProps>): CommonAlertWidget;
@@ -1,11 +1,12 @@
1
- import { bindDirectiveNoArg, stateStores, typeBoolean, typeString, writablesForProps } from './services';
2
- import { createTransition } from './transitions';
3
- import { fadeTransition } from './transitions/bootstrap';
4
- import { noop } from './utils';
5
- const defaultConfig = {
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 getAlertDefaultConfig() {
25
- return { ...defaultConfig };
25
+ export function getCommonAlertDefaultConfig() {
26
+ return { ...defaultCommonAlertConfig };
26
27
  }
27
- const configValidator = {
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 createAlert(config) {
37
- const [{ transition$, animationOnInit$, animation$, visible$: requestedVisible$, onVisibleChange$, onHidden$, onShown$, ...stateProps }, patch,] = writablesForProps(defaultConfig, config, configValidator);
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, ModalState, ModalApi, ModalActions, ModalDirectives>;
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 const createModal: (config$?: PropsConfig<ModalProps>) => ModalWidget;
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 { sliblingsInert, bindDirective, bindDirectiveNoArg, directiveSubscribe, mergeDirectives, portal, registrationArray, stateStores, writablesForProps, } from '../services';
3
- import { createTransition } from '../transitions';
4
- import { fadeTransition } from '../transitions/bootstrap/fade';
5
- import { promiseFromStore } from '../transitions/utils';
6
- import { noop } from '../utils';
7
- import { removeScrollbars, revertScrollbars } from './scrollbars';
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 const createModal = (config$) => {
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: container$(),
113
- insertBefore: container$() && modalTransition.stores.element$()?.parentElement === container$() ? modalTransition.stores.element$() : undefined,
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 './services';
2
- import type { Widget, SlotContent, WidgetSlotContext } from './types';
3
- import type { WidgetsCommonPropsAndState } from './commonProps';
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 { bindableDerived, INVALID_VALUE, stateStores, writablesForProps } from './services';
3
- import { clamp, isNumber } from './services/checks';
4
- import { typeBoolean, typeFunction, typeNumber, typeString } from './services/writables';
5
- import { noop } from './utils';
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 './services';
2
- import type { SlotContent, Widget, WidgetSlotContext } from './types';
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 './services/checks';
2
- import { bindableDerived, stateStores, typeBoolean, typeFunction, typeNumber, typeString, writablesForProps } from './services';
3
- import { computed, readable } from '@amadeus-it-group/tansu';
4
- import { noop } from './utils';
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$ = bindableDerived(readable(noop), [_dirtyMaximum$, min$], ([dirtyMaximum, minimum]) => Math.max(minimum, dirtyMaximum));
48
- const value$ = bindableDerived(readable(noop), [_dirtyValue$, min$, max$], ([dirtyValue, min, max]) => clamp(dirtyValue, max, min));
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 './services';
2
- import type { SlotContent, Widget } from './types';
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, bindableDerived, stateStores, writablesForProps } from './services';
3
- import { isNumber } from './services/checks';
4
- import { typeBoolean, typeFunction, typeNumber, typeString } from './services/writables';
5
- // TODO use getValueInRange
6
- function adjustRating(rating, maxRating) {
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]) => adjustRating(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