@agnos-ui/core 0.9.2 → 0.9.4
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/collapse-DRp53EuG.cjs +81 -0
- package/collapse-DwXz2kNw.js +82 -0
- package/components/collapse/collapse.d.ts +132 -0
- package/components/collapse/index.cjs +5 -0
- package/components/collapse/index.d.ts +1 -0
- package/components/collapse/index.js +5 -0
- package/components/slider/index.cjs +1 -1
- package/components/slider/index.js +1 -1
- package/config.d.ts +5 -0
- package/index.cjs +5 -1
- package/index.d.ts +1 -0
- package/index.js +35 -31
- package/package.json +1 -1
- package/services/resizeObserver.cjs +39 -19
- package/services/resizeObserver.d.ts +10 -2
- package/services/resizeObserver.js +41 -21
- package/{slider-BmxQ3A_u.js → slider-BZ2kIKCL.js} +48 -45
- package/{slider-DSx5CAce.cjs → slider-BdwTKTRg.cjs} +46 -43
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const services_transitions_baseTransitions = require("./services/transitions/baseTransitions.cjs");
|
|
3
|
+
const utils_stores = require("./utils/stores.cjs");
|
|
4
|
+
const utils_directive = require("./dom-CuBx1JPZ.cjs");
|
|
5
|
+
const utils_writables = require("./writables-Bn3uhKEG.cjs");
|
|
6
|
+
const tansu = require("@amadeus-it-group/tansu");
|
|
7
|
+
const utils_func = require("./utils/func.cjs");
|
|
8
|
+
const utils_widget = require("./utils/widget.cjs");
|
|
9
|
+
const defaultCollapseConfig = {
|
|
10
|
+
visible: false,
|
|
11
|
+
onVisibleChange: utils_func.noop,
|
|
12
|
+
onShown: utils_func.noop,
|
|
13
|
+
onHidden: utils_func.noop,
|
|
14
|
+
animated: true,
|
|
15
|
+
animatedOnInit: false,
|
|
16
|
+
id: "",
|
|
17
|
+
transition: utils_func.noop
|
|
18
|
+
};
|
|
19
|
+
function getCollapseDefaultConfig() {
|
|
20
|
+
return { ...defaultCollapseConfig };
|
|
21
|
+
}
|
|
22
|
+
const commonCollapseConfigValidator = {
|
|
23
|
+
onVisibleChange: utils_writables.typeFunction,
|
|
24
|
+
onHidden: utils_writables.typeFunction,
|
|
25
|
+
onShown: utils_writables.typeFunction,
|
|
26
|
+
animatedOnInit: utils_writables.typeBoolean,
|
|
27
|
+
animated: utils_writables.typeBoolean,
|
|
28
|
+
visible: utils_writables.typeBoolean,
|
|
29
|
+
id: utils_writables.typeString,
|
|
30
|
+
transition: utils_writables.typeFunction
|
|
31
|
+
};
|
|
32
|
+
const createCollapse = utils_widget.createWidgetFactory("collapse", (config) => {
|
|
33
|
+
const [
|
|
34
|
+
{ transition$, animatedOnInit$, animated$, visible$: requestedVisible$, onVisibleChange$, onHidden$, onShown$, id$: _dirtyId$, ...stateProps },
|
|
35
|
+
patch
|
|
36
|
+
] = utils_stores.writablesForProps(defaultCollapseConfig, config, commonCollapseConfigValidator);
|
|
37
|
+
const id$ = utils_stores.idWithDefault(_dirtyId$);
|
|
38
|
+
const transition = services_transitions_baseTransitions.createTransition({
|
|
39
|
+
props: {
|
|
40
|
+
transition: transition$,
|
|
41
|
+
visible: requestedVisible$,
|
|
42
|
+
animated: animated$,
|
|
43
|
+
animatedOnInit: animatedOnInit$,
|
|
44
|
+
onVisibleChange: onVisibleChange$,
|
|
45
|
+
onHidden: onHidden$,
|
|
46
|
+
onShown: onShown$
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const visible$ = transition.stores.visible$;
|
|
50
|
+
const hidden$ = transition.stores.hidden$;
|
|
51
|
+
return {
|
|
52
|
+
...utils_stores.stateStores({ ...stateProps, visible$, hidden$ }),
|
|
53
|
+
patch,
|
|
54
|
+
api: {
|
|
55
|
+
open: transition.api.show,
|
|
56
|
+
close: transition.api.hide,
|
|
57
|
+
toggle: transition.api.toggle
|
|
58
|
+
},
|
|
59
|
+
directives: {
|
|
60
|
+
collapseDirective: utils_directive.mergeDirectives(
|
|
61
|
+
transition.directives.directive,
|
|
62
|
+
utils_directive.createAttributesDirective(() => ({
|
|
63
|
+
attributes: {
|
|
64
|
+
id: id$
|
|
65
|
+
}
|
|
66
|
+
}))
|
|
67
|
+
),
|
|
68
|
+
triggerDirective: utils_directive.createAttributesDirective(() => ({
|
|
69
|
+
attributes: {
|
|
70
|
+
"aria-expanded": tansu.computed(() => `${visible$()}`),
|
|
71
|
+
"aria-controls": id$
|
|
72
|
+
},
|
|
73
|
+
events: {
|
|
74
|
+
click: () => transition.api.toggle()
|
|
75
|
+
}
|
|
76
|
+
}))
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
exports.createCollapse = createCollapse;
|
|
81
|
+
exports.getCollapseDefaultConfig = getCollapseDefaultConfig;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createTransition } from "./services/transitions/baseTransitions.js";
|
|
2
|
+
import { writablesForProps, idWithDefault, stateStores } from "./utils/stores.js";
|
|
3
|
+
import { n as createAttributesDirective, k as mergeDirectives } from "./dom-gfxqXJpK.js";
|
|
4
|
+
import { g as typeFunction, e as typeString, c as typeBoolean } from "./writables-CgpOQ4hA.js";
|
|
5
|
+
import { computed } from "@amadeus-it-group/tansu";
|
|
6
|
+
import { noop } from "./utils/func.js";
|
|
7
|
+
import { createWidgetFactory } from "./utils/widget.js";
|
|
8
|
+
const defaultCollapseConfig = {
|
|
9
|
+
visible: false,
|
|
10
|
+
onVisibleChange: noop,
|
|
11
|
+
onShown: noop,
|
|
12
|
+
onHidden: noop,
|
|
13
|
+
animated: true,
|
|
14
|
+
animatedOnInit: false,
|
|
15
|
+
id: "",
|
|
16
|
+
transition: noop
|
|
17
|
+
};
|
|
18
|
+
function getCollapseDefaultConfig() {
|
|
19
|
+
return { ...defaultCollapseConfig };
|
|
20
|
+
}
|
|
21
|
+
const commonCollapseConfigValidator = {
|
|
22
|
+
onVisibleChange: typeFunction,
|
|
23
|
+
onHidden: typeFunction,
|
|
24
|
+
onShown: typeFunction,
|
|
25
|
+
animatedOnInit: typeBoolean,
|
|
26
|
+
animated: typeBoolean,
|
|
27
|
+
visible: typeBoolean,
|
|
28
|
+
id: typeString,
|
|
29
|
+
transition: typeFunction
|
|
30
|
+
};
|
|
31
|
+
const createCollapse = createWidgetFactory("collapse", (config) => {
|
|
32
|
+
const [
|
|
33
|
+
{ transition$, animatedOnInit$, animated$, visible$: requestedVisible$, onVisibleChange$, onHidden$, onShown$, id$: _dirtyId$, ...stateProps },
|
|
34
|
+
patch
|
|
35
|
+
] = writablesForProps(defaultCollapseConfig, config, commonCollapseConfigValidator);
|
|
36
|
+
const id$ = idWithDefault(_dirtyId$);
|
|
37
|
+
const transition = createTransition({
|
|
38
|
+
props: {
|
|
39
|
+
transition: transition$,
|
|
40
|
+
visible: requestedVisible$,
|
|
41
|
+
animated: animated$,
|
|
42
|
+
animatedOnInit: animatedOnInit$,
|
|
43
|
+
onVisibleChange: onVisibleChange$,
|
|
44
|
+
onHidden: onHidden$,
|
|
45
|
+
onShown: onShown$
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const visible$ = transition.stores.visible$;
|
|
49
|
+
const hidden$ = transition.stores.hidden$;
|
|
50
|
+
return {
|
|
51
|
+
...stateStores({ ...stateProps, visible$, hidden$ }),
|
|
52
|
+
patch,
|
|
53
|
+
api: {
|
|
54
|
+
open: transition.api.show,
|
|
55
|
+
close: transition.api.hide,
|
|
56
|
+
toggle: transition.api.toggle
|
|
57
|
+
},
|
|
58
|
+
directives: {
|
|
59
|
+
collapseDirective: mergeDirectives(
|
|
60
|
+
transition.directives.directive,
|
|
61
|
+
createAttributesDirective(() => ({
|
|
62
|
+
attributes: {
|
|
63
|
+
id: id$
|
|
64
|
+
}
|
|
65
|
+
}))
|
|
66
|
+
),
|
|
67
|
+
triggerDirective: createAttributesDirective(() => ({
|
|
68
|
+
attributes: {
|
|
69
|
+
"aria-expanded": computed(() => `${visible$()}`),
|
|
70
|
+
"aria-controls": id$
|
|
71
|
+
},
|
|
72
|
+
events: {
|
|
73
|
+
click: () => transition.api.toggle()
|
|
74
|
+
}
|
|
75
|
+
}))
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
export {
|
|
80
|
+
createCollapse as c,
|
|
81
|
+
getCollapseDefaultConfig as g
|
|
82
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { type TransitionFn } from '../../services/transitions/baseTransitions';
|
|
2
|
+
import type { Directive, Widget, WidgetFactory } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the common properties and state for a collapse component.
|
|
5
|
+
*/
|
|
6
|
+
interface CollapseCommonPropsAndState {
|
|
7
|
+
/**
|
|
8
|
+
* If `true` the collapse is visible to the user
|
|
9
|
+
*
|
|
10
|
+
* @defaultValue `true`
|
|
11
|
+
*/
|
|
12
|
+
visible: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Represents the state of a Collapse component.
|
|
16
|
+
*/
|
|
17
|
+
export interface CollapseState extends CollapseCommonPropsAndState {
|
|
18
|
+
/**
|
|
19
|
+
* Is `true` when the collapse is hidden. Compared to `visible`, this is updated after the transition is executed.
|
|
20
|
+
*/
|
|
21
|
+
hidden: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Properties for the Collapse component.
|
|
25
|
+
*/
|
|
26
|
+
export interface CollapseProps extends CollapseCommonPropsAndState {
|
|
27
|
+
/**
|
|
28
|
+
* Callback called when the collapse visibility changed.
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue
|
|
31
|
+
* ```ts
|
|
32
|
+
* () => {}
|
|
33
|
+
* ```
|
|
34
|
+
* @param visible - The new visibility state of the collapse.
|
|
35
|
+
*/
|
|
36
|
+
onVisibleChange: (visible: boolean) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Callback called when the collapse is hidden.
|
|
39
|
+
*
|
|
40
|
+
* @defaultValue
|
|
41
|
+
* ```ts
|
|
42
|
+
* () => {}
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
onHidden: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Callback called when the collapse is shown.
|
|
48
|
+
*
|
|
49
|
+
* @defaultValue
|
|
50
|
+
* ```ts
|
|
51
|
+
* () => {}
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
onShown: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* If `true`, collapse opening will be animated at init time.
|
|
57
|
+
*
|
|
58
|
+
* @defaultValue `false`
|
|
59
|
+
*/
|
|
60
|
+
animatedOnInit: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* If `true`, collapse closing and opening will be animated.
|
|
63
|
+
*
|
|
64
|
+
* @defaultValue `true`
|
|
65
|
+
*/
|
|
66
|
+
animated: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* id of the collapse
|
|
69
|
+
*
|
|
70
|
+
* @defaultValue `''`
|
|
71
|
+
*/
|
|
72
|
+
id: string;
|
|
73
|
+
/**
|
|
74
|
+
* The transition function will be executed when the collapse is displayed or hidden.
|
|
75
|
+
*
|
|
76
|
+
* Depending on the value of `animatedOnInit`, the animation can be optionally skipped during the showing process.
|
|
77
|
+
*
|
|
78
|
+
* @defaultValue `() => {}`
|
|
79
|
+
*/
|
|
80
|
+
transition: TransitionFn;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Interface representing the API for a collapsible component.
|
|
84
|
+
*/
|
|
85
|
+
export interface CollapseApi {
|
|
86
|
+
/**
|
|
87
|
+
* Triggers collapse closing programmatically.
|
|
88
|
+
*/
|
|
89
|
+
close(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Triggers the collapse content to be displayed for the user.
|
|
92
|
+
*/
|
|
93
|
+
open(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Toggles the collapse content visibility.
|
|
96
|
+
*/
|
|
97
|
+
toggle(): void;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Interface representing the directives used in a collapse component.
|
|
101
|
+
*/
|
|
102
|
+
export interface CollapseDirectives {
|
|
103
|
+
/**
|
|
104
|
+
* Directive to apply the collapse.
|
|
105
|
+
*/
|
|
106
|
+
collapseDirective: Directive;
|
|
107
|
+
/**
|
|
108
|
+
* Directive to apply to a trigger;
|
|
109
|
+
*/
|
|
110
|
+
triggerDirective: Directive;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Represents a widget for handling collapse functionality.
|
|
114
|
+
*
|
|
115
|
+
* This type defines the structure of a CollapseWidget, which includes properties, state, API, and directives
|
|
116
|
+
* necessary for managing the collapse behavior in the UI.
|
|
117
|
+
*
|
|
118
|
+
* @type {Widget<CollapseProps, CollapseState, CollapseApi, CollapseDirectives>}
|
|
119
|
+
*/
|
|
120
|
+
export type CollapseWidget = Widget<CollapseProps, CollapseState, CollapseApi, CollapseDirectives>;
|
|
121
|
+
/**
|
|
122
|
+
* Retrieve a shallow copy of the default collapse config
|
|
123
|
+
* @returns the default collapse config
|
|
124
|
+
*/
|
|
125
|
+
export declare function getCollapseDefaultConfig(): CollapseProps;
|
|
126
|
+
/**
|
|
127
|
+
* Create an CollapseWidget factory
|
|
128
|
+
* @param transitionFn - the transition function that will be used for the collapse
|
|
129
|
+
* @returns an CollapseWidget
|
|
130
|
+
*/
|
|
131
|
+
export declare const createCollapse: WidgetFactory<CollapseWidget>;
|
|
132
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './collapse';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const slider = require("../../slider-
|
|
3
|
+
const slider = require("../../slider-BdwTKTRg.cjs");
|
|
4
4
|
exports.createSlider = slider.createSlider;
|
|
5
5
|
exports.getSliderDefaultConfig = slider.getSliderDefaultConfig;
|
package/config.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { SliderProps } from './components/slider/slider';
|
|
|
10
10
|
import type { ToastProps } from './components/toast/toast';
|
|
11
11
|
import type { TreeProps } from './components/tree/tree';
|
|
12
12
|
import type { CarouselProps } from './components/carousel';
|
|
13
|
+
import type { CollapseProps } from './components/collapse';
|
|
13
14
|
/**
|
|
14
15
|
* A utility type that makes all properties of an object type `T` optional,
|
|
15
16
|
* and also makes all properties of the nested objects within `T` optional.
|
|
@@ -109,4 +110,8 @@ export type WidgetsConfig = {
|
|
|
109
110
|
* carousel widget config
|
|
110
111
|
*/
|
|
111
112
|
carousel: CarouselProps;
|
|
113
|
+
/**
|
|
114
|
+
* collapse widget config
|
|
115
|
+
*/
|
|
116
|
+
collapse: CollapseProps;
|
|
112
117
|
};
|
package/index.cjs
CHANGED
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const types = require("./types.cjs");
|
|
4
4
|
const accordion = require("./accordion-cR5JqWJ8.cjs");
|
|
5
5
|
const alert = require("./alert-DtDozJal.cjs");
|
|
6
|
+
const collapse = require("./collapse-DRp53EuG.cjs");
|
|
6
7
|
const modal = require("./modal-BEnQ6c5M.cjs");
|
|
7
8
|
const pagination = require("./pagination-C1TT-oea.cjs");
|
|
8
9
|
const progressbar = require("./progressbar-CRvhNB5R.cjs");
|
|
9
10
|
const rating = require("./rating-DAb6nR67.cjs");
|
|
10
11
|
const select = require("./select-C0rJJQfl.cjs");
|
|
11
|
-
const slider = require("./slider-
|
|
12
|
+
const slider = require("./slider-BdwTKTRg.cjs");
|
|
12
13
|
const toaster = require("./toaster-Cayg6Lbq.cjs");
|
|
13
14
|
const tree = require("./tree-Pvr2rZ-D.cjs");
|
|
14
15
|
const config = require("./config.cjs");
|
|
@@ -36,6 +37,8 @@ exports.factoryCreateAccordion = accordion.factoryCreateAccordion;
|
|
|
36
37
|
exports.getAccordionDefaultConfig = accordion.getAccordionDefaultConfig;
|
|
37
38
|
exports.createAlert = alert.createAlert;
|
|
38
39
|
exports.getAlertDefaultConfig = alert.getAlertDefaultConfig;
|
|
40
|
+
exports.createCollapse = collapse.createCollapse;
|
|
41
|
+
exports.getCollapseDefaultConfig = collapse.getCollapseDefaultConfig;
|
|
39
42
|
exports.createModal = modal.createModal;
|
|
40
43
|
exports.getModalDefaultConfig = modal.getModalDefaultConfig;
|
|
41
44
|
exports.modalCloseButtonClick = modal.modalCloseButtonClick;
|
|
@@ -69,6 +72,7 @@ exports.getKeyName = services_navManager.getKeyName;
|
|
|
69
72
|
exports.isInternalInputNavigation = services_navManager.isInternalInputNavigation;
|
|
70
73
|
exports.portal = services_portal.portal;
|
|
71
74
|
exports.createResizeObserver = services_resizeObserver.createResizeObserver;
|
|
75
|
+
exports.createResizeObserverMap = services_resizeObserver.createResizeObserverMap;
|
|
72
76
|
exports.siblingsInert = services_siblingsInert.siblingsInert;
|
|
73
77
|
exports.hash$ = services_hash.hash$;
|
|
74
78
|
exports.createTransition = services_transitions_baseTransitions.createTransition;
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './types';
|
|
2
2
|
export * from './components/accordion';
|
|
3
3
|
export * from './components/alert';
|
|
4
|
+
export * from './components/collapse';
|
|
4
5
|
export * from './components/modal';
|
|
5
6
|
export * from './components/pagination';
|
|
6
7
|
export * from './components/progressbar';
|
package/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { FACTORY_WIDGET_NAME, INVALID_VALUE } from "./types.js";
|
|
2
2
|
import { a, c, f, g } from "./accordion-CoM4efp-.js";
|
|
3
3
|
import { c as c2, g as g2 } from "./alert-YIlqdEPO.js";
|
|
4
|
-
import { c as c3, g as g3
|
|
5
|
-
import { c as c4, g as g4 } from "./
|
|
6
|
-
import { c as c5, g as g5 } from "./
|
|
7
|
-
import { c as c6, g as g6 } from "./
|
|
8
|
-
import { c as c7, g as g7 } from "./
|
|
9
|
-
import { c as c8, g as g8 } from "./
|
|
10
|
-
import {
|
|
11
|
-
import { c as c10, g as g10 } from "./
|
|
4
|
+
import { c as c3, g as g3 } from "./collapse-DwXz2kNw.js";
|
|
5
|
+
import { c as c4, g as g4, a as a2, m } from "./modal-D3wGIDlj.js";
|
|
6
|
+
import { c as c5, g as g5 } from "./pagination-B97wBLok.js";
|
|
7
|
+
import { c as c6, g as g6 } from "./progressbar-BWBlRk_Y.js";
|
|
8
|
+
import { c as c7, g as g7 } from "./rating-BXvy9kXq.js";
|
|
9
|
+
import { c as c8, g as g8 } from "./select-BdjpnE7_.js";
|
|
10
|
+
import { c as c9, g as g9 } from "./slider-BZ2kIKCL.js";
|
|
11
|
+
import { T, c as c10, d, g as g10 } from "./toaster-XfzHDqz_.js";
|
|
12
|
+
import { c as c11, g as g11 } from "./tree-BFrXdJox.js";
|
|
12
13
|
import { createWidgetsConfig, mergeInto } from "./config.js";
|
|
13
14
|
import { extendWidgetProps } from "./services/extendWidget.js";
|
|
14
15
|
import { createFloatingUI } from "./services/floatingUI.js";
|
|
@@ -17,15 +18,15 @@ import { createIntersection } from "./services/intersection.js";
|
|
|
17
18
|
import { createMatchMedia } from "./services/matchMedia.js";
|
|
18
19
|
import { createNavManager, getKeyName, isInternalInputNavigation } from "./services/navManager.js";
|
|
19
20
|
import { portal } from "./services/portal.js";
|
|
20
|
-
import { createResizeObserver } from "./services/resizeObserver.js";
|
|
21
|
+
import { createResizeObserver, createResizeObserverMap } from "./services/resizeObserver.js";
|
|
21
22
|
import { siblingsInert } from "./services/siblingsInert.js";
|
|
22
23
|
import { hash$ } from "./services/hash.js";
|
|
23
24
|
import { createTransition, noAnimation } from "./services/transitions/baseTransitions.js";
|
|
24
25
|
import { createCSSTransition, getTransitionDurationMs, hasTransition } from "./services/transitions/cssTransitions.js";
|
|
25
26
|
import { createSimpleClassTransition } from "./services/transitions/simpleClassTransition.js";
|
|
26
|
-
import { o, a as a3, c as
|
|
27
|
+
import { o, a as a3, c as c12, b, p, n, g as g12, j, f as f2, h, q, d as d2, e, i, m as m2, k, l, r, s } from "./dom-gfxqXJpK.js";
|
|
27
28
|
import { bindableDerived, bindableProp, createPatch, false$, findChangedProperties, idWithDefault, isStore, mergeConfigStores, normalizeConfigStores, stateStores, toReadableStore, toWritableStore, true$, writableWithDefault, writablesForProps, writablesWithDefault } from "./utils/stores.js";
|
|
28
|
-
import { j as j2, t, i as i2, c as
|
|
29
|
+
import { j as j2, t, i as i2, c as c13, d as d3, g as g13, h as h2, a as a4, b as b2, e as e2, f as f3 } from "./writables-CgpOQ4hA.js";
|
|
29
30
|
export {
|
|
30
31
|
FACTORY_WIDGET_NAME,
|
|
31
32
|
INVALID_VALUE,
|
|
@@ -33,7 +34,7 @@ export {
|
|
|
33
34
|
activeElement$,
|
|
34
35
|
o as attributesData,
|
|
35
36
|
a3 as bindDirective,
|
|
36
|
-
|
|
37
|
+
c12 as bindDirectiveNoArg,
|
|
37
38
|
bindableDerived,
|
|
38
39
|
bindableProp,
|
|
39
40
|
b as browserDirective,
|
|
@@ -42,28 +43,30 @@ export {
|
|
|
42
43
|
c as createAccordionItem,
|
|
43
44
|
c2 as createAlert,
|
|
44
45
|
n as createAttributesDirective,
|
|
45
|
-
|
|
46
|
+
g12 as createBrowserStoreArrayDirective,
|
|
46
47
|
j as createBrowserStoreDirective,
|
|
47
48
|
createCSSTransition,
|
|
49
|
+
c3 as createCollapse,
|
|
48
50
|
createFloatingUI,
|
|
49
51
|
createHasFocus,
|
|
50
52
|
createIntersection,
|
|
51
53
|
createMatchMedia,
|
|
52
|
-
|
|
54
|
+
c4 as createModal,
|
|
53
55
|
createNavManager,
|
|
54
|
-
|
|
56
|
+
c5 as createPagination,
|
|
55
57
|
createPatch,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
c6 as createProgressbar,
|
|
59
|
+
c7 as createRating,
|
|
58
60
|
createResizeObserver,
|
|
59
|
-
|
|
61
|
+
createResizeObserverMap,
|
|
62
|
+
c8 as createSelect,
|
|
60
63
|
createSimpleClassTransition,
|
|
61
|
-
|
|
64
|
+
c9 as createSlider,
|
|
62
65
|
f2 as createStoreArrayDirective,
|
|
63
66
|
h as createStoreDirective,
|
|
64
|
-
|
|
67
|
+
c10 as createToast,
|
|
65
68
|
createTransition,
|
|
66
|
-
|
|
69
|
+
c11 as createTree,
|
|
67
70
|
j2 as createTypeEnum,
|
|
68
71
|
createWidgetsConfig,
|
|
69
72
|
d as defaultToasterProps,
|
|
@@ -76,16 +79,17 @@ export {
|
|
|
76
79
|
findChangedProperties,
|
|
77
80
|
g as getAccordionDefaultConfig,
|
|
78
81
|
g2 as getAlertDefaultConfig,
|
|
82
|
+
g3 as getCollapseDefaultConfig,
|
|
79
83
|
getKeyName,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
g4 as getModalDefaultConfig,
|
|
85
|
+
g5 as getPaginationDefaultConfig,
|
|
86
|
+
g6 as getProgressbarDefaultConfig,
|
|
87
|
+
g7 as getRatingDefaultConfig,
|
|
88
|
+
g8 as getSelectDefaultConfig,
|
|
89
|
+
g9 as getSliderDefaultConfig,
|
|
90
|
+
g10 as getToastDefaultConfig,
|
|
87
91
|
getTransitionDurationMs,
|
|
88
|
-
|
|
92
|
+
g11 as getTreeDefaultConfig,
|
|
89
93
|
hasTransition,
|
|
90
94
|
hash$,
|
|
91
95
|
idWithDefault,
|
|
@@ -111,9 +115,9 @@ export {
|
|
|
111
115
|
toWritableStore,
|
|
112
116
|
true$,
|
|
113
117
|
i2 as typeArray,
|
|
114
|
-
|
|
118
|
+
c13 as typeBoolean,
|
|
115
119
|
d3 as typeBooleanOrNull,
|
|
116
|
-
|
|
120
|
+
g13 as typeFunction,
|
|
117
121
|
h2 as typeHTMLElementOrNull,
|
|
118
122
|
a4 as typeNumber,
|
|
119
123
|
b2 as typeNumberInRangeFactory,
|
package/package.json
CHANGED
|
@@ -3,30 +3,50 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const tansu = require("@amadeus-it-group/tansu");
|
|
4
4
|
const utils_directive = require("../dom-CuBx1JPZ.cjs");
|
|
5
5
|
const utils_func = require("../utils/func.cjs");
|
|
6
|
-
const
|
|
7
|
-
const {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
(
|
|
11
|
-
|
|
6
|
+
const createResizeObserverMap = () => {
|
|
7
|
+
const { elements$, directive } = utils_directive.createBrowserStoreArrayDirective();
|
|
8
|
+
const dimensionsMap$ = tansu.derived(
|
|
9
|
+
elements$,
|
|
10
|
+
(elements, set) => {
|
|
11
|
+
const dimensionsMap = /* @__PURE__ */ new Map();
|
|
12
|
+
if (elements.length === 0) {
|
|
13
|
+
set(dimensionsMap);
|
|
12
14
|
return utils_func.noop;
|
|
13
15
|
}
|
|
14
16
|
const observer = new ResizeObserver((entries) => {
|
|
15
|
-
set(
|
|
17
|
+
entries.forEach((entry) => dimensionsMap.set(entry.target, entry));
|
|
18
|
+
set(dimensionsMap);
|
|
16
19
|
});
|
|
17
|
-
observer.observe(element);
|
|
18
|
-
return () => observer
|
|
20
|
+
elements.forEach((element) => observer.observe(element));
|
|
21
|
+
return () => observer.disconnect();
|
|
19
22
|
},
|
|
20
|
-
|
|
23
|
+
/* @__PURE__ */ new Map()
|
|
21
24
|
);
|
|
22
|
-
return {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
return { dimensionsMap$, directive };
|
|
26
|
+
};
|
|
27
|
+
const createResizeObserver = () => {
|
|
28
|
+
const { dimensionsMap$, directive: arrayDirective } = createResizeObserverMap();
|
|
29
|
+
let firstElement = null;
|
|
30
|
+
const directive = utils_directive.browserDirective((element) => {
|
|
31
|
+
if (firstElement === null) {
|
|
32
|
+
firstElement = element;
|
|
33
|
+
} else {
|
|
34
|
+
console.error("createResizeObserver directive can only be applied to a single element. Use createResizeObserverMap for multiple elements.");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const result = arrayDirective(element);
|
|
38
|
+
if (!result) return;
|
|
39
|
+
const originalDestroy = result.destroy;
|
|
40
|
+
return {
|
|
41
|
+
...result,
|
|
42
|
+
destroy: () => {
|
|
43
|
+
firstElement = null;
|
|
44
|
+
originalDestroy == null ? void 0 : originalDestroy();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
const dimensions$ = tansu.derived(dimensionsMap$, (map) => firstElement ? map.get(firstElement) : void 0, void 0);
|
|
49
|
+
return { dimensions$, directive };
|
|
31
50
|
};
|
|
32
51
|
exports.createResizeObserver = createResizeObserver;
|
|
52
|
+
exports.createResizeObserverMap = createResizeObserverMap;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { ReadableSignal } from '@amadeus-it-group/tansu';
|
|
2
2
|
import type { Directive, SSRHTMLElement } from '../types';
|
|
3
3
|
/**
|
|
4
|
-
* Create a resize observer
|
|
5
|
-
* @returns An object containing the store with the
|
|
4
|
+
* Create a resize observer that can be applied to multiple elements
|
|
5
|
+
* @returns An object containing the store with the dimensions map of observed elements (ResizeObserverEntry), the directive to be applied to the html element to be observed
|
|
6
|
+
*/
|
|
7
|
+
export declare const createResizeObserverMap: () => {
|
|
8
|
+
dimensionsMap$: ReadableSignal<Map<HTMLElement, ResizeObserverEntry>>;
|
|
9
|
+
directive: Directive<void, SSRHTMLElement>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Create a resize observer object for a single element
|
|
13
|
+
* @returns An object containing the store with the dimensions of observed element (ResizeObserverEntry), the directive to be applied to the html element to be observed
|
|
6
14
|
*/
|
|
7
15
|
export declare const createResizeObserver: () => {
|
|
8
16
|
dimensions$: ReadableSignal<ResizeObserverEntry | undefined>;
|
|
@@ -1,32 +1,52 @@
|
|
|
1
1
|
import { derived } from "@amadeus-it-group/tansu";
|
|
2
|
-
import {
|
|
2
|
+
import { g as createBrowserStoreArrayDirective, b as browserDirective } from "../dom-gfxqXJpK.js";
|
|
3
3
|
import { noop } from "../utils/func.js";
|
|
4
|
-
const
|
|
5
|
-
const {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
(
|
|
9
|
-
|
|
4
|
+
const createResizeObserverMap = () => {
|
|
5
|
+
const { elements$, directive } = createBrowserStoreArrayDirective();
|
|
6
|
+
const dimensionsMap$ = derived(
|
|
7
|
+
elements$,
|
|
8
|
+
(elements, set) => {
|
|
9
|
+
const dimensionsMap = /* @__PURE__ */ new Map();
|
|
10
|
+
if (elements.length === 0) {
|
|
11
|
+
set(dimensionsMap);
|
|
10
12
|
return noop;
|
|
11
13
|
}
|
|
12
14
|
const observer = new ResizeObserver((entries) => {
|
|
13
|
-
set(
|
|
15
|
+
entries.forEach((entry) => dimensionsMap.set(entry.target, entry));
|
|
16
|
+
set(dimensionsMap);
|
|
14
17
|
});
|
|
15
|
-
observer.observe(element);
|
|
16
|
-
return () => observer
|
|
18
|
+
elements.forEach((element) => observer.observe(element));
|
|
19
|
+
return () => observer.disconnect();
|
|
17
20
|
},
|
|
18
|
-
|
|
21
|
+
/* @__PURE__ */ new Map()
|
|
19
22
|
);
|
|
20
|
-
return {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
return { dimensionsMap$, directive };
|
|
24
|
+
};
|
|
25
|
+
const createResizeObserver = () => {
|
|
26
|
+
const { dimensionsMap$, directive: arrayDirective } = createResizeObserverMap();
|
|
27
|
+
let firstElement = null;
|
|
28
|
+
const directive = browserDirective((element) => {
|
|
29
|
+
if (firstElement === null) {
|
|
30
|
+
firstElement = element;
|
|
31
|
+
} else {
|
|
32
|
+
console.error("createResizeObserver directive can only be applied to a single element. Use createResizeObserverMap for multiple elements.");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const result = arrayDirective(element);
|
|
36
|
+
if (!result) return;
|
|
37
|
+
const originalDestroy = result.destroy;
|
|
38
|
+
return {
|
|
39
|
+
...result,
|
|
40
|
+
destroy: () => {
|
|
41
|
+
firstElement = null;
|
|
42
|
+
originalDestroy == null ? void 0 : originalDestroy();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
const dimensions$ = derived(dimensionsMap$, (map) => firstElement ? map.get(firstElement) : void 0, void 0);
|
|
47
|
+
return { dimensions$, directive };
|
|
29
48
|
};
|
|
30
49
|
export {
|
|
31
|
-
createResizeObserver
|
|
50
|
+
createResizeObserver,
|
|
51
|
+
createResizeObserverMap
|
|
32
52
|
};
|
|
@@ -2,8 +2,8 @@ import { computed, writable, readable } from "@amadeus-it-group/tansu";
|
|
|
2
2
|
import { j as createBrowserStoreDirective, g as createBrowserStoreArrayDirective, k as mergeDirectives, n as createAttributesDirective, b as browserDirective } from "./dom-gfxqXJpK.js";
|
|
3
3
|
import { noop } from "./utils/func.js";
|
|
4
4
|
import { writablesForProps, bindableProp, stateStores, true$ } from "./utils/stores.js";
|
|
5
|
-
import { i as typeArray, c as typeBoolean, b as typeNumberInRangeFactory, e as typeString, g as typeFunction, a as typeNumber } from "./writables-CgpOQ4hA.js";
|
|
6
|
-
import { createResizeObserver } from "./services/resizeObserver.js";
|
|
5
|
+
import { i as typeArray, k as clamp, c as typeBoolean, b as typeNumberInRangeFactory, e as typeString, g as typeFunction, a as typeNumber } from "./writables-CgpOQ4hA.js";
|
|
6
|
+
import { createResizeObserver, createResizeObserverMap } from "./services/resizeObserver.js";
|
|
7
7
|
import { createWidgetFactory } from "./utils/widget.js";
|
|
8
8
|
const decimalRegExp = /(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/;
|
|
9
9
|
function getDecimalPrecision(number) {
|
|
@@ -239,20 +239,11 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
239
239
|
const { directive: sliderDirective, element$: sliderDom$ } = createBrowserStoreDirective();
|
|
240
240
|
const { directive: minLabelDomDirective, element$: minLabelDom$ } = createBrowserStoreDirective();
|
|
241
241
|
const { directive: maxLabelDomDirective, element$: maxLabelDom$ } = createBrowserStoreDirective();
|
|
242
|
-
const { directive: combinedLabelDomDirective, element$: combinedLabelDom$ } = createBrowserStoreDirective();
|
|
243
242
|
const { directive: handleLabelDirective, elements$: currentLabelDoms$ } = createBrowserStoreArrayDirective();
|
|
244
243
|
const { directive: resizeDirective, dimensions$ } = createResizeObserver();
|
|
244
|
+
const { directive: resizeLabelsDirective, dimensionsMap$: handleDimensions$ } = createResizeObserverMap();
|
|
245
|
+
const { directive: resizeCombineLabelDirective, dimensions$: combinedDimensions$ } = createResizeObserver();
|
|
245
246
|
const updateSliderSize$ = writable({});
|
|
246
|
-
const currentLabelDomsRect$ = computed(
|
|
247
|
-
() => {
|
|
248
|
-
dimensions$();
|
|
249
|
-
updateSliderSize$();
|
|
250
|
-
return currentLabelDoms$().map((element) => element.getBoundingClientRect());
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
equal: Object.is
|
|
254
|
-
}
|
|
255
|
-
);
|
|
256
247
|
const sliderDomRect$ = computed(
|
|
257
248
|
() => {
|
|
258
249
|
var _a;
|
|
@@ -286,8 +277,8 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
286
277
|
equal: (a, b) => Object.is(a, b)
|
|
287
278
|
}
|
|
288
279
|
);
|
|
289
|
-
const sliderDomRectOffset$ = computed(() => vertical$() ?
|
|
290
|
-
const sliderDomRectSize$ = computed(() => vertical$() ?
|
|
280
|
+
const sliderDomRectOffset$ = computed(() => sliderDomRect$()[vertical$() ? "top" : "left"]);
|
|
281
|
+
const sliderDomRectSize$ = computed(() => sliderDomRect$()[vertical$() ? "height" : "width"]);
|
|
291
282
|
const sortedValues$ = computed(() => [...values$()].sort((a, b) => a - b));
|
|
292
283
|
const _sortedHandlesValues$ = computed(() => {
|
|
293
284
|
return values$().map((val, index) => {
|
|
@@ -307,26 +298,20 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
307
298
|
});
|
|
308
299
|
const valuesPercent$ = computed(() => values$().map((val) => percentCompute(val)));
|
|
309
300
|
const sortedValuesPercent$ = computed(() => [...valuesPercent$()].sort((a, b) => a - b));
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const maxLabelSize$ = computed(() => {
|
|
315
|
-
const maxLabelDomRect = maxLabelDomRect$();
|
|
316
|
-
return pixelToPercent(vertical$() ? maxLabelDomRect.height : maxLabelDomRect.width);
|
|
317
|
-
});
|
|
301
|
+
const activeDimension$ = computed(() => vertical$() ? "height" : "width");
|
|
302
|
+
const activePosition$ = computed(() => vertical$() ? "top" : "left");
|
|
303
|
+
const minLabelSize$ = computed(() => pixelToPercent(minLabelDomRect$()[activeDimension$()]));
|
|
304
|
+
const maxLabelSize$ = computed(() => pixelToPercent(maxLabelDomRect$()[activeDimension$()]));
|
|
318
305
|
const adjustedShowValueLabels$ = computed(() => showValueLabels$() && (!showTicks$() || !showTickValues$()));
|
|
319
306
|
const pixelToPercent = (pixels) => pixels ? pixels / sliderDomRectSize$() * 100 : 0;
|
|
320
|
-
const combinedLabelSize$ = computed(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
);
|
|
307
|
+
const combinedLabelSize$ = computed(() => {
|
|
308
|
+
var _a;
|
|
309
|
+
return pixelToPercent((_a = combinedDimensions$()) == null ? void 0 : _a.contentRect[activeDimension$()]);
|
|
310
|
+
});
|
|
326
311
|
const combinedLabelPosition$ = computed(() => vertical$() ? combinedLabelPositionTop$() : combinedLabelPositionLeft$());
|
|
327
312
|
const currentLabelSizeByIndex = (index) => {
|
|
328
|
-
var _a
|
|
329
|
-
return pixelToPercent(
|
|
313
|
+
var _a;
|
|
314
|
+
return pixelToPercent((_a = handleDimensions$().get(currentLabelDoms$()[index])) == null ? void 0 : _a.contentRect[activeDimension$()]);
|
|
330
315
|
};
|
|
331
316
|
const minValueLabelDisplay$ = computed(() => {
|
|
332
317
|
if (!showMinMaxLabels$() || showTicks$() && showTickValues$()) {
|
|
@@ -362,23 +347,34 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
362
347
|
const sortedValuesPercent = sortedValuesPercent$();
|
|
363
348
|
return rtl ? 100 - sortedValuesPercent[sortedValuesPercent.length - 1] - currentLabelSizeByIndex(0) / 2 > maxLabelSize + 1 : sortedValuesPercent[sortedValuesPercent.length - 1] + currentLabelSizeByIndex(sortedValuesPercent.length - 1) / 2 < 100 - maxLabelSize - 1;
|
|
364
349
|
});
|
|
365
|
-
const storedLabelSize$ = writable([]);
|
|
366
350
|
const combinedLabelDisplay$ = computed(() => {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
storedLabelSize$.set(values.map((_, index) => currentLabelSizeByIndex(index) / 2));
|
|
351
|
+
if (currentLabelDoms$().length == 2) {
|
|
352
|
+
return doLabelsIntersect();
|
|
370
353
|
}
|
|
371
|
-
|
|
372
|
-
const firstLabelSize = (storedLabelSize == null ? void 0 : storedLabelSize[0]) ?? 0;
|
|
373
|
-
const secondLabelSize = (storedLabelSize == null ? void 0 : storedLabelSize[1]) ?? 0;
|
|
374
|
-
const biggestLabelSize = Math.max(firstLabelSize, secondLabelSize);
|
|
375
|
-
const intersectionLimit = biggestLabelSize !== 50 ? biggestLabelSize * 2 + 2 : 15;
|
|
376
|
-
return values.length == 2 && values[1] - secondLabelSize - values[0] + firstLabelSize < intersectionLimit;
|
|
354
|
+
return false;
|
|
377
355
|
});
|
|
356
|
+
function doLabelsIntersect() {
|
|
357
|
+
const handleOptions = handleDisplayOptions$();
|
|
358
|
+
const activePosition = activePosition$();
|
|
359
|
+
const labelPosition1 = labelPosition(handleOptions[0][activePosition], currentLabelSizeByIndex(0));
|
|
360
|
+
const labelPosition2 = labelPosition(handleOptions[1][activePosition], currentLabelSizeByIndex(1));
|
|
361
|
+
const labelSize1 = currentLabelSizeByIndex(0);
|
|
362
|
+
const labelSize2 = currentLabelSizeByIndex(1);
|
|
363
|
+
if (labelSize1 === 100 || labelSize2 === 100) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
const labelStart1 = labelPosition1 - labelSize1;
|
|
367
|
+
const labelEnd1 = labelPosition1 + labelSize1;
|
|
368
|
+
const labelStart2 = labelPosition2 - labelSize2;
|
|
369
|
+
const labelEnd2 = labelPosition2 + labelSize2;
|
|
370
|
+
return !(labelEnd1 < labelStart2 || labelStart1 > labelEnd2);
|
|
371
|
+
}
|
|
378
372
|
const interactive$ = computed(() => !disabled$() && !readonly$());
|
|
379
373
|
const combinedLabelPositionLeft$ = computed(() => {
|
|
380
374
|
const sortedValuesPercent = sortedValuesPercent$();
|
|
381
|
-
const
|
|
375
|
+
const combinedLabelSize = combinedLabelSize$();
|
|
376
|
+
let combinedPosition = (sortedValuesPercent[0] + sortedValuesPercent[1]) / 2;
|
|
377
|
+
combinedPosition = labelPosition(combinedPosition, combinedLabelSize);
|
|
382
378
|
return vertical$() || sortedValuesPercent.length != 2 ? 0 : rtl$() ? 100 - combinedPosition : combinedPosition;
|
|
383
379
|
});
|
|
384
380
|
const combinedLabelPositionTop$ = computed(() => {
|
|
@@ -395,6 +391,7 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
395
391
|
};
|
|
396
392
|
});
|
|
397
393
|
});
|
|
394
|
+
const labelPosition = (initialPosition, labelSize) => clamp(initialPosition, 100 - labelSize / 2, labelSize / 2);
|
|
398
395
|
const progressDisplayOptions$ = computed(() => {
|
|
399
396
|
const vertical = vertical$(), sortedValuesPercent = sortedValuesPercent$(), rtl = rtl$();
|
|
400
397
|
if (sortedValuesPercent.length === 1) {
|
|
@@ -771,7 +768,7 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
771
768
|
minLabelDirective: mergeDirectives(minLabelDomDirective, minLabelDirective),
|
|
772
769
|
maxLabelDirective: mergeDirectives(maxLabelDomDirective, maxLabelDirective),
|
|
773
770
|
combinedHandleLabelDisplayDirective: mergeDirectives(
|
|
774
|
-
|
|
771
|
+
resizeCombineLabelDirective,
|
|
775
772
|
createAttributesDirective(() => ({
|
|
776
773
|
classNames: {
|
|
777
774
|
"au-slider-label-vertical": vertical$,
|
|
@@ -790,6 +787,7 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
790
787
|
),
|
|
791
788
|
handleLabelDisplayDirective: mergeDirectives(
|
|
792
789
|
handleLabelDirective,
|
|
790
|
+
resizeLabelsDirective,
|
|
793
791
|
createAttributesDirective((labelDisplayContext$) => ({
|
|
794
792
|
classNames: {
|
|
795
793
|
"au-slider-label-vertical": vertical$,
|
|
@@ -798,8 +796,13 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
798
796
|
"au-slider-label-now": horizontal$
|
|
799
797
|
},
|
|
800
798
|
styles: {
|
|
801
|
-
left: computed(() =>
|
|
802
|
-
|
|
799
|
+
left: computed(() => {
|
|
800
|
+
const handleIndex = labelDisplayContext$().index;
|
|
801
|
+
const leftPosition = handleDisplayOptions$()[handleIndex].left;
|
|
802
|
+
return leftPosition === null ? "" : percent(labelPosition(leftPosition, currentLabelSizeByIndex(handleIndex)));
|
|
803
|
+
}),
|
|
804
|
+
top: computed(() => percent(handleDisplayOptions$()[labelDisplayContext$().index].top)),
|
|
805
|
+
opacity: computed(() => combinedLabelDisplay$() ? "0" : "1")
|
|
803
806
|
},
|
|
804
807
|
attributes: {
|
|
805
808
|
"aria-hidden": readable("true")
|
|
@@ -240,20 +240,11 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
240
240
|
const { directive: sliderDirective, element$: sliderDom$ } = utils_directive.createBrowserStoreDirective();
|
|
241
241
|
const { directive: minLabelDomDirective, element$: minLabelDom$ } = utils_directive.createBrowserStoreDirective();
|
|
242
242
|
const { directive: maxLabelDomDirective, element$: maxLabelDom$ } = utils_directive.createBrowserStoreDirective();
|
|
243
|
-
const { directive: combinedLabelDomDirective, element$: combinedLabelDom$ } = utils_directive.createBrowserStoreDirective();
|
|
244
243
|
const { directive: handleLabelDirective, elements$: currentLabelDoms$ } = utils_directive.createBrowserStoreArrayDirective();
|
|
245
244
|
const { directive: resizeDirective, dimensions$ } = services_resizeObserver.createResizeObserver();
|
|
245
|
+
const { directive: resizeLabelsDirective, dimensionsMap$: handleDimensions$ } = services_resizeObserver.createResizeObserverMap();
|
|
246
|
+
const { directive: resizeCombineLabelDirective, dimensions$: combinedDimensions$ } = services_resizeObserver.createResizeObserver();
|
|
246
247
|
const updateSliderSize$ = tansu.writable({});
|
|
247
|
-
const currentLabelDomsRect$ = tansu.computed(
|
|
248
|
-
() => {
|
|
249
|
-
dimensions$();
|
|
250
|
-
updateSliderSize$();
|
|
251
|
-
return currentLabelDoms$().map((element) => element.getBoundingClientRect());
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
equal: Object.is
|
|
255
|
-
}
|
|
256
|
-
);
|
|
257
248
|
const sliderDomRect$ = tansu.computed(
|
|
258
249
|
() => {
|
|
259
250
|
var _a;
|
|
@@ -287,8 +278,8 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
287
278
|
equal: (a, b) => Object.is(a, b)
|
|
288
279
|
}
|
|
289
280
|
);
|
|
290
|
-
const sliderDomRectOffset$ = tansu.computed(() => vertical$() ?
|
|
291
|
-
const sliderDomRectSize$ = tansu.computed(() => vertical$() ?
|
|
281
|
+
const sliderDomRectOffset$ = tansu.computed(() => sliderDomRect$()[vertical$() ? "top" : "left"]);
|
|
282
|
+
const sliderDomRectSize$ = tansu.computed(() => sliderDomRect$()[vertical$() ? "height" : "width"]);
|
|
292
283
|
const sortedValues$ = tansu.computed(() => [...values$()].sort((a, b) => a - b));
|
|
293
284
|
const _sortedHandlesValues$ = tansu.computed(() => {
|
|
294
285
|
return values$().map((val, index) => {
|
|
@@ -308,26 +299,20 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
308
299
|
});
|
|
309
300
|
const valuesPercent$ = tansu.computed(() => values$().map((val) => percentCompute(val)));
|
|
310
301
|
const sortedValuesPercent$ = tansu.computed(() => [...valuesPercent$()].sort((a, b) => a - b));
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const maxLabelSize$ = tansu.computed(() => {
|
|
316
|
-
const maxLabelDomRect = maxLabelDomRect$();
|
|
317
|
-
return pixelToPercent(vertical$() ? maxLabelDomRect.height : maxLabelDomRect.width);
|
|
318
|
-
});
|
|
302
|
+
const activeDimension$ = tansu.computed(() => vertical$() ? "height" : "width");
|
|
303
|
+
const activePosition$ = tansu.computed(() => vertical$() ? "top" : "left");
|
|
304
|
+
const minLabelSize$ = tansu.computed(() => pixelToPercent(minLabelDomRect$()[activeDimension$()]));
|
|
305
|
+
const maxLabelSize$ = tansu.computed(() => pixelToPercent(maxLabelDomRect$()[activeDimension$()]));
|
|
319
306
|
const adjustedShowValueLabels$ = tansu.computed(() => showValueLabels$() && (!showTicks$() || !showTickValues$()));
|
|
320
307
|
const pixelToPercent = (pixels) => pixels ? pixels / sliderDomRectSize$() * 100 : 0;
|
|
321
|
-
const combinedLabelSize$ = tansu.computed(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
);
|
|
308
|
+
const combinedLabelSize$ = tansu.computed(() => {
|
|
309
|
+
var _a;
|
|
310
|
+
return pixelToPercent((_a = combinedDimensions$()) == null ? void 0 : _a.contentRect[activeDimension$()]);
|
|
311
|
+
});
|
|
327
312
|
const combinedLabelPosition$ = tansu.computed(() => vertical$() ? combinedLabelPositionTop$() : combinedLabelPositionLeft$());
|
|
328
313
|
const currentLabelSizeByIndex = (index) => {
|
|
329
|
-
var _a
|
|
330
|
-
return pixelToPercent(
|
|
314
|
+
var _a;
|
|
315
|
+
return pixelToPercent((_a = handleDimensions$().get(currentLabelDoms$()[index])) == null ? void 0 : _a.contentRect[activeDimension$()]);
|
|
331
316
|
};
|
|
332
317
|
const minValueLabelDisplay$ = tansu.computed(() => {
|
|
333
318
|
if (!showMinMaxLabels$() || showTicks$() && showTickValues$()) {
|
|
@@ -363,23 +348,34 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
363
348
|
const sortedValuesPercent = sortedValuesPercent$();
|
|
364
349
|
return rtl ? 100 - sortedValuesPercent[sortedValuesPercent.length - 1] - currentLabelSizeByIndex(0) / 2 > maxLabelSize + 1 : sortedValuesPercent[sortedValuesPercent.length - 1] + currentLabelSizeByIndex(sortedValuesPercent.length - 1) / 2 < 100 - maxLabelSize - 1;
|
|
365
350
|
});
|
|
366
|
-
const storedLabelSize$ = tansu.writable([]);
|
|
367
351
|
const combinedLabelDisplay$ = tansu.computed(() => {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
storedLabelSize$.set(values.map((_, index) => currentLabelSizeByIndex(index) / 2));
|
|
352
|
+
if (currentLabelDoms$().length == 2) {
|
|
353
|
+
return doLabelsIntersect();
|
|
371
354
|
}
|
|
372
|
-
|
|
373
|
-
const firstLabelSize = (storedLabelSize == null ? void 0 : storedLabelSize[0]) ?? 0;
|
|
374
|
-
const secondLabelSize = (storedLabelSize == null ? void 0 : storedLabelSize[1]) ?? 0;
|
|
375
|
-
const biggestLabelSize = Math.max(firstLabelSize, secondLabelSize);
|
|
376
|
-
const intersectionLimit = biggestLabelSize !== 50 ? biggestLabelSize * 2 + 2 : 15;
|
|
377
|
-
return values.length == 2 && values[1] - secondLabelSize - values[0] + firstLabelSize < intersectionLimit;
|
|
355
|
+
return false;
|
|
378
356
|
});
|
|
357
|
+
function doLabelsIntersect() {
|
|
358
|
+
const handleOptions = handleDisplayOptions$();
|
|
359
|
+
const activePosition = activePosition$();
|
|
360
|
+
const labelPosition1 = labelPosition(handleOptions[0][activePosition], currentLabelSizeByIndex(0));
|
|
361
|
+
const labelPosition2 = labelPosition(handleOptions[1][activePosition], currentLabelSizeByIndex(1));
|
|
362
|
+
const labelSize1 = currentLabelSizeByIndex(0);
|
|
363
|
+
const labelSize2 = currentLabelSizeByIndex(1);
|
|
364
|
+
if (labelSize1 === 100 || labelSize2 === 100) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
const labelStart1 = labelPosition1 - labelSize1;
|
|
368
|
+
const labelEnd1 = labelPosition1 + labelSize1;
|
|
369
|
+
const labelStart2 = labelPosition2 - labelSize2;
|
|
370
|
+
const labelEnd2 = labelPosition2 + labelSize2;
|
|
371
|
+
return !(labelEnd1 < labelStart2 || labelStart1 > labelEnd2);
|
|
372
|
+
}
|
|
379
373
|
const interactive$ = tansu.computed(() => !disabled$() && !readonly$());
|
|
380
374
|
const combinedLabelPositionLeft$ = tansu.computed(() => {
|
|
381
375
|
const sortedValuesPercent = sortedValuesPercent$();
|
|
382
|
-
const
|
|
376
|
+
const combinedLabelSize = combinedLabelSize$();
|
|
377
|
+
let combinedPosition = (sortedValuesPercent[0] + sortedValuesPercent[1]) / 2;
|
|
378
|
+
combinedPosition = labelPosition(combinedPosition, combinedLabelSize);
|
|
383
379
|
return vertical$() || sortedValuesPercent.length != 2 ? 0 : rtl$() ? 100 - combinedPosition : combinedPosition;
|
|
384
380
|
});
|
|
385
381
|
const combinedLabelPositionTop$ = tansu.computed(() => {
|
|
@@ -396,6 +392,7 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
396
392
|
};
|
|
397
393
|
});
|
|
398
394
|
});
|
|
395
|
+
const labelPosition = (initialPosition, labelSize) => utils_writables.clamp(initialPosition, 100 - labelSize / 2, labelSize / 2);
|
|
399
396
|
const progressDisplayOptions$ = tansu.computed(() => {
|
|
400
397
|
const vertical = vertical$(), sortedValuesPercent = sortedValuesPercent$(), rtl = rtl$();
|
|
401
398
|
if (sortedValuesPercent.length === 1) {
|
|
@@ -772,7 +769,7 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
772
769
|
minLabelDirective: utils_directive.mergeDirectives(minLabelDomDirective, minLabelDirective),
|
|
773
770
|
maxLabelDirective: utils_directive.mergeDirectives(maxLabelDomDirective, maxLabelDirective),
|
|
774
771
|
combinedHandleLabelDisplayDirective: utils_directive.mergeDirectives(
|
|
775
|
-
|
|
772
|
+
resizeCombineLabelDirective,
|
|
776
773
|
utils_directive.createAttributesDirective(() => ({
|
|
777
774
|
classNames: {
|
|
778
775
|
"au-slider-label-vertical": vertical$,
|
|
@@ -791,6 +788,7 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
791
788
|
),
|
|
792
789
|
handleLabelDisplayDirective: utils_directive.mergeDirectives(
|
|
793
790
|
handleLabelDirective,
|
|
791
|
+
resizeLabelsDirective,
|
|
794
792
|
utils_directive.createAttributesDirective((labelDisplayContext$) => ({
|
|
795
793
|
classNames: {
|
|
796
794
|
"au-slider-label-vertical": vertical$,
|
|
@@ -799,8 +797,13 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
799
797
|
"au-slider-label-now": horizontal$
|
|
800
798
|
},
|
|
801
799
|
styles: {
|
|
802
|
-
left: tansu.computed(() =>
|
|
803
|
-
|
|
800
|
+
left: tansu.computed(() => {
|
|
801
|
+
const handleIndex = labelDisplayContext$().index;
|
|
802
|
+
const leftPosition = handleDisplayOptions$()[handleIndex].left;
|
|
803
|
+
return leftPosition === null ? "" : percent(labelPosition(leftPosition, currentLabelSizeByIndex(handleIndex)));
|
|
804
|
+
}),
|
|
805
|
+
top: tansu.computed(() => percent(handleDisplayOptions$()[labelDisplayContext$().index].top)),
|
|
806
|
+
opacity: tansu.computed(() => combinedLabelDisplay$() ? "0" : "1")
|
|
804
807
|
},
|
|
805
808
|
attributes: {
|
|
806
809
|
"aria-hidden": tansu.readable("true")
|