@agnos-ui/core 0.8.0-next.1 → 0.8.0
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-OTiJtxDi.js → accordion-BLVIYePx.js} +1 -1
- package/{accordion-DTQj-TQ1.cjs → accordion-vfnqMstG.cjs} +1 -1
- package/{alert-DH-mO6WX.js → alert-BpepSIHu.js} +1 -1
- package/{alert-BrVkxOnA.cjs → alert-D6W48Ffr.cjs} +1 -1
- package/{common-CcQOJ_hf.cjs → common-BToNPUDq.cjs} +1 -1
- package/{common-Bffx1jJO.js → common-BqUjUBPy.js} +1 -1
- package/components/accordion/index.cjs +1 -1
- package/components/accordion/index.js +1 -1
- package/components/alert/index.cjs +1 -1
- package/components/alert/index.js +1 -1
- package/components/carousel/carousel.d.ts +232 -0
- package/components/carousel/index.cjs +288 -0
- package/components/carousel/index.d.ts +1 -0
- package/components/carousel/index.js +288 -0
- package/components/modal/index.cjs +1 -1
- package/components/modal/index.js +1 -1
- package/components/pagination/index.cjs +1 -1
- package/components/pagination/index.js +1 -1
- package/components/progressbar/index.cjs +1 -1
- package/components/progressbar/index.js +1 -1
- package/components/rating/index.cjs +1 -1
- package/components/rating/index.js +1 -1
- package/components/slider/index.cjs +1 -1
- package/components/slider/index.js +1 -1
- package/components/toast/index.cjs +5 -3
- package/components/toast/index.d.ts +1 -0
- package/components/toast/index.js +3 -1
- package/components/toast/toaster.d.ts +128 -0
- package/components/tree/index.cjs +1 -1
- package/components/tree/index.js +1 -1
- package/config.d.ts +5 -0
- package/index.cjs +15 -12
- package/index.js +20 -17
- package/{modal-85Sw8xuV.js → modal-CGK3h9pR.js} +1 -1
- package/{modal-B7bYoubx.cjs → modal-Dw1MuWPV.cjs} +1 -1
- package/package.json +4 -1
- package/{pagination-5YARuB3V.cjs → pagination-BzyKulaI.cjs} +1 -1
- package/{pagination-4g3N8ktf.js → pagination-CRAKaOuh.js} +1 -1
- package/{progressbar-BoJsBPH1.js → progressbar-Csnqx_Pk.js} +1 -1
- package/{progressbar-BpSrg4HG.cjs → progressbar-D9rvrxXi.cjs} +1 -1
- package/{rating-C8tn9xTO.cjs → rating-C4c8Paz-.cjs} +1 -1
- package/{rating-B3xktzOf.js → rating-CvTnNxgN.js} +1 -1
- package/services/transitions/baseTransitions.cjs +1 -1
- package/services/transitions/baseTransitions.js +1 -1
- package/{slider-B2JFXDLt.cjs → slider-B0ZfAY0K.cjs} +200 -97
- package/{slider-Cs69pziL.js → slider-BF6a0eh_.js} +201 -98
- package/toaster-B2ibv38T.cjs +208 -0
- package/toaster-PwfLC7FH.js +209 -0
- package/{tree-C_goOyCv.js → tree-DUU_TWqy.js} +1 -1
- package/{tree-D4t2SOql.cjs → tree-Dwv2U0ea.cjs} +1 -1
- package/utils/writables.cjs +2 -1
- package/utils/writables.d.ts +7 -0
- package/utils/writables.js +7 -6
- package/{writables-BPAJvaL_.cjs → writables-Bn3uhKEG.cjs} +4 -0
- package/{writables-DCiBdIBK.js → writables-CgpOQ4hA.js} +10 -6
- package/toast-4HGIz3Bu.js +0 -64
- package/toast-CaIcB2sD.cjs +0 -63
package/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { INVALID_VALUE } from "./types.js";
|
|
2
|
-
import { a, c, f, g } from "./accordion-
|
|
3
|
-
import { c as c2, g as g2 } from "./alert-
|
|
4
|
-
import { c as c3, g as g3, a as a2, m } from "./modal-
|
|
5
|
-
import { c as c4, g as g4 } from "./pagination-
|
|
6
|
-
import { c as c5, g as g5 } from "./progressbar-
|
|
7
|
-
import { c as c6, g as g6 } from "./rating-
|
|
2
|
+
import { a, c, f, g } from "./accordion-BLVIYePx.js";
|
|
3
|
+
import { c as c2, g as g2 } from "./alert-BpepSIHu.js";
|
|
4
|
+
import { c as c3, g as g3, a as a2, m } from "./modal-CGK3h9pR.js";
|
|
5
|
+
import { c as c4, g as g4 } from "./pagination-CRAKaOuh.js";
|
|
6
|
+
import { c as c5, g as g5 } from "./progressbar-Csnqx_Pk.js";
|
|
7
|
+
import { c as c6, g as g6 } from "./rating-CvTnNxgN.js";
|
|
8
8
|
import { c as c7, g as g7 } from "./select-C-77MJfC.js";
|
|
9
|
-
import { c as c8, g as g8 } from "./slider-
|
|
10
|
-
import { c as c9, g as g9 } from "./
|
|
11
|
-
import { c as c10, g as g10 } from "./tree-
|
|
9
|
+
import { c as c8, g as g8 } from "./slider-BF6a0eh_.js";
|
|
10
|
+
import { T, c as c9, d, g as g9 } from "./toaster-PwfLC7FH.js";
|
|
11
|
+
import { c as c10, g as g10 } from "./tree-DUU_TWqy.js";
|
|
12
12
|
import { createWidgetsConfig, mergeInto } from "./config.js";
|
|
13
13
|
import { extendWidgetProps } from "./services/extendWidget.js";
|
|
14
14
|
import { createFloatingUI } from "./services/floatingUI.js";
|
|
@@ -23,11 +23,12 @@ import { hash$ } from "./services/hash.js";
|
|
|
23
23
|
import { createTransition, noAnimation } from "./services/transitions/baseTransitions.js";
|
|
24
24
|
import { createCSSTransition, getTransitionDurationMs, hasTransition } from "./services/transitions/cssTransitions.js";
|
|
25
25
|
import { createSimpleClassTransition } from "./services/transitions/simpleClassTransition.js";
|
|
26
|
-
import { o, a as a3, c as c11, b, p, n, g as g11, j, f as f2, h, q, d, e, i, m as m2, k, l, r, s } from "./dom-gfxqXJpK.js";
|
|
26
|
+
import { o, a as a3, c as c11, b, p, n, g as g11, j, f as f2, h, q, d as d2, e, i, m as m2, k, l, r, s } from "./dom-gfxqXJpK.js";
|
|
27
27
|
import { bindableDerived, bindableProp, createPatch, false$, findChangedProperties, idWithDefault, isStore, mergeConfigStores, normalizeConfigStores, stateStores, toReadableStore, toWritableStore, true$, writableWithDefault, writablesForProps, writablesWithDefault } from "./utils/stores.js";
|
|
28
|
-
import {
|
|
28
|
+
import { j as j2, t, i as i2, c as c12, d as d3, g as g12, h as h2, a as a4, b as b2, e as e2, f as f3 } from "./writables-CgpOQ4hA.js";
|
|
29
29
|
export {
|
|
30
30
|
INVALID_VALUE,
|
|
31
|
+
T as Toaster,
|
|
31
32
|
activeElement$,
|
|
32
33
|
o as attributesData,
|
|
33
34
|
a3 as bindDirective,
|
|
@@ -62,10 +63,11 @@ export {
|
|
|
62
63
|
c9 as createToast,
|
|
63
64
|
createTransition,
|
|
64
65
|
c10 as createTree,
|
|
65
|
-
|
|
66
|
+
j2 as createTypeEnum,
|
|
66
67
|
createWidgetsConfig,
|
|
68
|
+
d as defaultToasterProps,
|
|
67
69
|
q as directiveAttributes,
|
|
68
|
-
|
|
70
|
+
d2 as directiveSubscribe,
|
|
69
71
|
e as directiveUpdate,
|
|
70
72
|
extendWidgetProps,
|
|
71
73
|
f as factoryCreateAccordion,
|
|
@@ -107,14 +109,15 @@ export {
|
|
|
107
109
|
toReadableStore,
|
|
108
110
|
toWritableStore,
|
|
109
111
|
true$,
|
|
110
|
-
|
|
112
|
+
i2 as typeArray,
|
|
111
113
|
c12 as typeBoolean,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
d3 as typeBooleanOrNull,
|
|
115
|
+
g12 as typeFunction,
|
|
116
|
+
h2 as typeHTMLElementOrNull,
|
|
115
117
|
a4 as typeNumber,
|
|
116
118
|
b2 as typeNumberInRangeFactory,
|
|
117
119
|
e2 as typeString,
|
|
120
|
+
f3 as typeStringOrNull,
|
|
118
121
|
writableWithDefault,
|
|
119
122
|
writablesForProps,
|
|
120
123
|
writablesWithDefault
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computed, readable } from "@amadeus-it-group/tansu";
|
|
2
|
-
import { c as typeBoolean,
|
|
2
|
+
import { c as typeBoolean, g as typeFunction, e as typeString, h as typeHTMLElementOrNull } from "./writables-CgpOQ4hA.js";
|
|
3
3
|
import { writablesForProps, stateStores } from "./utils/stores.js";
|
|
4
4
|
import { createTransition } from "./services/transitions/baseTransitions.js";
|
|
5
5
|
import { d as promiseFromStore } from "./promise-XSP94FjG.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const tansu = require("@amadeus-it-group/tansu");
|
|
3
|
-
const utils_writables = require("./writables-
|
|
3
|
+
const utils_writables = require("./writables-Bn3uhKEG.cjs");
|
|
4
4
|
const utils_stores = require("./utils/stores.cjs");
|
|
5
5
|
const services_transitions_baseTransitions = require("./services/transitions/baseTransitions.cjs");
|
|
6
6
|
const promise = require("./promise-CxCD3NYv.cjs");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agnos-ui/core",
|
|
3
3
|
"description": "Framework-agnostic headless component library.",
|
|
4
|
-
"version": "0.8.0
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"module": "./index.js",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@amadeus-it-group/tansu": "^2.0.0",
|
|
51
51
|
"@floating-ui/dom": "^1.6.12",
|
|
52
|
+
"embla-carousel": "^8.5.2",
|
|
52
53
|
"esm-env": "^1.2.1"
|
|
53
54
|
},
|
|
54
55
|
"sideEffects": false,
|
|
@@ -65,6 +66,7 @@
|
|
|
65
66
|
"accordion",
|
|
66
67
|
"AgnosUI",
|
|
67
68
|
"alert",
|
|
69
|
+
"carousel",
|
|
68
70
|
"collapse",
|
|
69
71
|
"components",
|
|
70
72
|
"modal",
|
|
@@ -73,6 +75,7 @@
|
|
|
73
75
|
"rating",
|
|
74
76
|
"slider",
|
|
75
77
|
"toast",
|
|
78
|
+
"tree",
|
|
76
79
|
"widgets"
|
|
77
80
|
]
|
|
78
81
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const tansu = require("@amadeus-it-group/tansu");
|
|
3
3
|
const utils_stores = require("./utils/stores.cjs");
|
|
4
|
-
const utils_writables = require("./writables-
|
|
4
|
+
const utils_writables = require("./writables-Bn3uhKEG.cjs");
|
|
5
5
|
const utils_func = require("./utils/func.cjs");
|
|
6
6
|
const utils_directive = require("./dom-CuBx1JPZ.cjs");
|
|
7
7
|
const PAGE_LINK_DEFAULT = "#";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed } from "@amadeus-it-group/tansu";
|
|
2
2
|
import { writablesForProps, bindableProp, stateStores, true$ } from "./utils/stores.js";
|
|
3
|
-
import { e as typeString,
|
|
3
|
+
import { e as typeString, g as typeFunction, c as typeBoolean, a as typeNumber, k as clamp, l as isNumber } from "./writables-CgpOQ4hA.js";
|
|
4
4
|
import { noop } from "./utils/func.js";
|
|
5
5
|
import { n as createAttributesDirective } from "./dom-gfxqXJpK.js";
|
|
6
6
|
const PAGE_LINK_DEFAULT = "#";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as clamp, g as typeFunction, e as typeString, a as typeNumber } from "./writables-CgpOQ4hA.js";
|
|
2
2
|
import { writablesForProps, stateStores } from "./utils/stores.js";
|
|
3
3
|
import { computed, readable } from "@amadeus-it-group/tansu";
|
|
4
4
|
import { n as createAttributesDirective } from "./dom-gfxqXJpK.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const utils_writables = require("./writables-
|
|
2
|
+
const utils_writables = require("./writables-Bn3uhKEG.cjs");
|
|
3
3
|
const utils_stores = require("./utils/stores.cjs");
|
|
4
4
|
const tansu = require("@amadeus-it-group/tansu");
|
|
5
5
|
const utils_directive = require("./dom-CuBx1JPZ.cjs");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const tansu = require("@amadeus-it-group/tansu");
|
|
3
3
|
const types = require("./types.cjs");
|
|
4
4
|
const utils_directive = require("./dom-CuBx1JPZ.cjs");
|
|
5
|
-
const utils_writables = require("./writables-
|
|
5
|
+
const utils_writables = require("./writables-Bn3uhKEG.cjs");
|
|
6
6
|
const utils_func = require("./utils/func.cjs");
|
|
7
7
|
const utils_stores = require("./utils/stores.cjs");
|
|
8
8
|
const defaultConfig = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed, writable, readable } from "@amadeus-it-group/tansu";
|
|
2
2
|
import { INVALID_VALUE } from "./types.js";
|
|
3
3
|
import { n as createAttributesDirective } from "./dom-gfxqXJpK.js";
|
|
4
|
-
import { e as typeString,
|
|
4
|
+
import { e as typeString, g as typeFunction, c as typeBoolean, a as typeNumber, k as clamp, l as isNumber } from "./writables-CgpOQ4hA.js";
|
|
5
5
|
import { noop } from "./utils/func.js";
|
|
6
6
|
import { writablesForProps, bindableProp, stateStores, true$ } from "./utils/stores.js";
|
|
7
7
|
const defaultConfig = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const tansu = require("@amadeus-it-group/tansu");
|
|
4
|
-
const utils_writables = require("../../writables-
|
|
4
|
+
const utils_writables = require("../../writables-Bn3uhKEG.cjs");
|
|
5
5
|
const promise = require("../../promise-CxCD3NYv.cjs");
|
|
6
6
|
const utils_func = require("../../utils/func.cjs");
|
|
7
7
|
const utils_stores = require("../../utils/stores.cjs");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computed, writable, derived, batch } from "@amadeus-it-group/tansu";
|
|
2
|
-
import { d as typeBooleanOrNull,
|
|
2
|
+
import { d as typeBooleanOrNull, g as typeFunction, c as typeBoolean } from "../../writables-CgpOQ4hA.js";
|
|
3
3
|
import { c as promiseWithResolve } from "../../promise-XSP94FjG.js";
|
|
4
4
|
import { noop } from "../../utils/func.js";
|
|
5
5
|
import { writablesForProps, bindableDerived, stateStores } from "../../utils/stores.js";
|
|
@@ -3,7 +3,7 @@ const tansu = require("@amadeus-it-group/tansu");
|
|
|
3
3
|
const utils_directive = require("./dom-CuBx1JPZ.cjs");
|
|
4
4
|
const utils_func = require("./utils/func.cjs");
|
|
5
5
|
const utils_stores = require("./utils/stores.cjs");
|
|
6
|
-
const utils_writables = require("./writables-
|
|
6
|
+
const utils_writables = require("./writables-Bn3uhKEG.cjs");
|
|
7
7
|
const services_resizeObserver = require("./services/resizeObserver.cjs");
|
|
8
8
|
const decimalRegExp = /(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/;
|
|
9
9
|
function getDecimalPrecision(number) {
|
|
@@ -115,6 +115,7 @@ function createSlider(config) {
|
|
|
115
115
|
] = utils_stores.writablesForProps(defaultSliderConfig, config, configValidator);
|
|
116
116
|
const { vertical$, disabled$, readonly$ } = stateProps;
|
|
117
117
|
let _prevCoordinate = -1;
|
|
118
|
+
const _handleElements = /* @__PURE__ */ new Map();
|
|
118
119
|
const min$ = tansu.computed(() => {
|
|
119
120
|
const _dirtyMinimum = _dirtyMinimum$(), _dirtyMaximum = _dirtyMaximum$();
|
|
120
121
|
if (_dirtyMinimum === _dirtyMaximum) {
|
|
@@ -146,8 +147,20 @@ function createSlider(config) {
|
|
|
146
147
|
const { directive: sliderDirective, element$: sliderDom$ } = utils_directive.createBrowserStoreDirective();
|
|
147
148
|
const { directive: minLabelDomDirective, element$: minLabelDom$ } = utils_directive.createBrowserStoreDirective();
|
|
148
149
|
const { directive: maxLabelDomDirective, element$: maxLabelDom$ } = utils_directive.createBrowserStoreDirective();
|
|
150
|
+
const { directive: combinedLabelDomDirective, element$: combinedLabelDom$ } = utils_directive.createBrowserStoreDirective();
|
|
151
|
+
const { directive: handleLabelDirective, elements$: currentLabelDoms$ } = utils_directive.createBrowserStoreArrayDirective();
|
|
149
152
|
const { directive: resizeDirective, dimensions$ } = services_resizeObserver.createResizeObserver();
|
|
150
153
|
const updateSliderSize$ = tansu.writable({});
|
|
154
|
+
const currentLabelDomsRect$ = tansu.computed(
|
|
155
|
+
() => {
|
|
156
|
+
dimensions$();
|
|
157
|
+
updateSliderSize$();
|
|
158
|
+
return currentLabelDoms$().map((element) => element.getBoundingClientRect());
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
equal: Object.is
|
|
162
|
+
}
|
|
163
|
+
);
|
|
151
164
|
const sliderDomRect$ = tansu.computed(
|
|
152
165
|
() => {
|
|
153
166
|
var _a;
|
|
@@ -202,17 +215,43 @@ function createSlider(config) {
|
|
|
202
215
|
});
|
|
203
216
|
const valuesPercent$ = tansu.computed(() => values$().map((val) => percentCompute(val)));
|
|
204
217
|
const sortedValuesPercent$ = tansu.computed(() => [...valuesPercent$()].sort((a, b) => a - b));
|
|
205
|
-
const
|
|
206
|
-
|
|
218
|
+
const minLabelSize$ = tansu.computed(() => {
|
|
219
|
+
const minLabelDomRect = minLabelDomRect$();
|
|
220
|
+
return pixelToPercent(vertical$() ? minLabelDomRect.height : minLabelDomRect.width);
|
|
221
|
+
});
|
|
222
|
+
const maxLabelSize$ = tansu.computed(() => {
|
|
223
|
+
const maxLabelDomRect = maxLabelDomRect$();
|
|
224
|
+
return pixelToPercent(vertical$() ? maxLabelDomRect.height : maxLabelDomRect.width);
|
|
225
|
+
});
|
|
207
226
|
const adjustedShowValueLabels$ = tansu.computed(() => showValueLabels$() && (!showTicks$() || !showTickValues$()));
|
|
227
|
+
const pixelToPercent = (pixels) => pixels ? pixels / sliderDomRectSize$() * 100 : 0;
|
|
228
|
+
const combinedLabelSize$ = tansu.computed(
|
|
229
|
+
() => {
|
|
230
|
+
var _a, _b;
|
|
231
|
+
return pixelToPercent(vertical$() ? (_a = combinedLabelDom$()) == null ? void 0 : _a.getBoundingClientRect().height : (_b = combinedLabelDom$()) == null ? void 0 : _b.getBoundingClientRect().width);
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
const combinedLabelPosition$ = tansu.computed(() => vertical$() ? combinedLabelPositionTop$() : combinedLabelPositionLeft$());
|
|
235
|
+
const currentLabelSizeByIndex = (index) => {
|
|
236
|
+
var _a, _b;
|
|
237
|
+
return pixelToPercent(vertical$() ? (_a = currentLabelDomsRect$()[index]) == null ? void 0 : _a.height : (_b = currentLabelDomsRect$()[index]) == null ? void 0 : _b.width);
|
|
238
|
+
};
|
|
208
239
|
const minValueLabelDisplay$ = tansu.computed(() => {
|
|
209
240
|
if (!showMinMaxLabels$() || showTicks$() && showTickValues$()) {
|
|
210
241
|
return false;
|
|
211
242
|
} else if (!showValueLabels$()) {
|
|
212
243
|
return true;
|
|
213
244
|
}
|
|
214
|
-
const
|
|
215
|
-
|
|
245
|
+
const minLabelSize = minLabelSize$();
|
|
246
|
+
const vertical = vertical$();
|
|
247
|
+
const rtl = rtl$();
|
|
248
|
+
if (combinedLabelDisplay$()) {
|
|
249
|
+
const combinedLabelSize = combinedLabelSize$();
|
|
250
|
+
const combinedLabelPosition = combinedLabelPosition$();
|
|
251
|
+
return rtl && !vertical || vertical && !rtl ? combinedLabelPosition + combinedLabelSize / 2 < 100 - minLabelSize - 1 : combinedLabelPosition - combinedLabelSize / 2 > minLabelSize + 1;
|
|
252
|
+
}
|
|
253
|
+
const sortedValuesPercent = sortedValuesPercent$();
|
|
254
|
+
return rtl ? sortedValuesPercent[0] - currentLabelSizeByIndex(sortedValuesPercent.length - 1) / 2 > minLabelSize + 1 : sortedValuesPercent[0] - currentLabelSizeByIndex(0) / 2 > minLabelSize + 1;
|
|
216
255
|
});
|
|
217
256
|
const maxValueLabelDisplay$ = tansu.computed(() => {
|
|
218
257
|
if (!showMinMaxLabels$() || showTicks$() && showTickValues$()) {
|
|
@@ -220,12 +259,29 @@ function createSlider(config) {
|
|
|
220
259
|
} else if (!showValueLabels$()) {
|
|
221
260
|
return true;
|
|
222
261
|
}
|
|
223
|
-
const
|
|
224
|
-
|
|
262
|
+
const maxLabelSize = maxLabelSize$();
|
|
263
|
+
const vertical = vertical$();
|
|
264
|
+
const rtl = rtl$();
|
|
265
|
+
if (combinedLabelDisplay$()) {
|
|
266
|
+
const combinedLabelSize = combinedLabelSize$();
|
|
267
|
+
const combinedLabelPosition = combinedLabelPosition$();
|
|
268
|
+
return rtl && !vertical || vertical && !rtl ? combinedLabelPosition - combinedLabelSize / 2 > maxLabelSize + 1 : combinedLabelPosition + combinedLabelSize / 2 < 100 - maxLabelSize - 1;
|
|
269
|
+
}
|
|
270
|
+
const sortedValuesPercent = sortedValuesPercent$();
|
|
271
|
+
return rtl ? 100 - sortedValuesPercent[sortedValuesPercent.length - 1] - currentLabelSizeByIndex(0) / 2 > maxLabelSize + 1 : sortedValuesPercent[sortedValuesPercent.length - 1] + currentLabelSizeByIndex(sortedValuesPercent.length - 1) / 2 < 100 - maxLabelSize - 1;
|
|
225
272
|
});
|
|
273
|
+
const storedLabelSize$ = tansu.writable([]);
|
|
226
274
|
const combinedLabelDisplay$ = tansu.computed(() => {
|
|
227
|
-
const values =
|
|
228
|
-
|
|
275
|
+
const values = sortedValuesPercent$();
|
|
276
|
+
if (currentLabelDomsRect$().length === values.length) {
|
|
277
|
+
storedLabelSize$.set(values.map((_, index) => currentLabelSizeByIndex(index) / 2));
|
|
278
|
+
}
|
|
279
|
+
const storedLabelSize = storedLabelSize$();
|
|
280
|
+
const firstLabelSize = (storedLabelSize == null ? void 0 : storedLabelSize[0]) ?? 0;
|
|
281
|
+
const secondLabelSize = (storedLabelSize == null ? void 0 : storedLabelSize[1]) ?? 0;
|
|
282
|
+
const biggestLabelSize = Math.max(firstLabelSize, secondLabelSize);
|
|
283
|
+
const intersectionLimit = biggestLabelSize !== 50 ? biggestLabelSize * 2 + 2 : 15;
|
|
284
|
+
return values.length == 2 && values[1] - secondLabelSize - values[0] + firstLabelSize < intersectionLimit;
|
|
229
285
|
});
|
|
230
286
|
const interactive$ = tansu.computed(() => !disabled$() && !readonly$());
|
|
231
287
|
const combinedLabelPositionLeft$ = tansu.computed(() => {
|
|
@@ -332,11 +388,15 @@ function createSlider(config) {
|
|
|
332
388
|
const closestValue = sortedValues[clickedPercent * 100 <= midPoint ? closestBiggerIndex - 1 : closestBiggerIndex];
|
|
333
389
|
return values.indexOf(closestValue);
|
|
334
390
|
};
|
|
391
|
+
const getClickedPercent = (clickedCoordinate) => {
|
|
392
|
+
const sliderDomRectSize = sliderDomRectSize$(), sliderDomRectOffset = sliderDomRectOffset$();
|
|
393
|
+
let clickedPercent = vertical$() ? (sliderDomRectSize - clickedCoordinate + sliderDomRectOffset) / sliderDomRectSize : (clickedCoordinate - sliderDomRectOffset) / sliderDomRectSize;
|
|
394
|
+
clickedPercent = rtl$() ? 1 - clickedPercent : clickedPercent;
|
|
395
|
+
return clickedPercent;
|
|
396
|
+
};
|
|
335
397
|
const adjustCoordinate = (clickedCoordinate, handleNumber) => {
|
|
336
398
|
if (interactive$()) {
|
|
337
|
-
const
|
|
338
|
-
let clickedPercent = vertical$() ? (sliderDomRectSize - clickedCoordinate + sliderDomRectOffset) / sliderDomRectSize : (clickedCoordinate - sliderDomRectOffset) / sliderDomRectSize;
|
|
339
|
-
clickedPercent = rtl$() ? 1 - clickedPercent : clickedPercent;
|
|
399
|
+
const clickedPercent = getClickedPercent(clickedCoordinate);
|
|
340
400
|
const derivedHandleIndex = handleNumber ?? getClosestSliderHandle(clickedPercent);
|
|
341
401
|
const newValue = clickedPercent * (max$() - min$()) + min$();
|
|
342
402
|
values$.update((dh) => {
|
|
@@ -385,6 +445,77 @@ function createSlider(config) {
|
|
|
385
445
|
"aria-hidden": tansu.readable("true")
|
|
386
446
|
}
|
|
387
447
|
}));
|
|
448
|
+
const handleElementDirective = utils_directive.browserDirective((handleItem, args) => {
|
|
449
|
+
const destroy = () => {
|
|
450
|
+
_handleElements.delete(args.item.id);
|
|
451
|
+
};
|
|
452
|
+
const update = (args2) => {
|
|
453
|
+
_handleElements.set(args2.item.id, handleItem);
|
|
454
|
+
};
|
|
455
|
+
update(args);
|
|
456
|
+
return {
|
|
457
|
+
update,
|
|
458
|
+
destroy
|
|
459
|
+
};
|
|
460
|
+
});
|
|
461
|
+
const mouseDown = (event, handleId) => {
|
|
462
|
+
event.preventDefault();
|
|
463
|
+
const currentTarget = handleId !== void 0 ? _handleElements.get(handleId) : event.target;
|
|
464
|
+
const handleDrag = (e) => {
|
|
465
|
+
e.preventDefault();
|
|
466
|
+
const newCoord = vertical$() ? e.clientY : e.clientX;
|
|
467
|
+
currentTarget == null ? void 0 : currentTarget.focus();
|
|
468
|
+
if (_prevCoordinate !== newCoord) {
|
|
469
|
+
_prevCoordinate = newCoord;
|
|
470
|
+
adjustCoordinate(newCoord, handleId);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
if (interactive$()) {
|
|
474
|
+
updateSliderSize$.set({});
|
|
475
|
+
currentTarget == null ? void 0 : currentTarget.focus();
|
|
476
|
+
document.addEventListener("mousemove", handleDrag);
|
|
477
|
+
document.addEventListener(
|
|
478
|
+
"mouseup",
|
|
479
|
+
() => {
|
|
480
|
+
document.removeEventListener("mousemove", handleDrag);
|
|
481
|
+
},
|
|
482
|
+
{ once: true }
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
const touchStart = (event, handleId) => {
|
|
487
|
+
const currentTarget = handleId !== void 0 ? _handleElements.get(handleId) : event.target;
|
|
488
|
+
const handleDrag = (e) => {
|
|
489
|
+
e.preventDefault();
|
|
490
|
+
const newCoord = vertical$() ? e.touches[0].clientY : e.touches[0].clientX;
|
|
491
|
+
currentTarget == null ? void 0 : currentTarget.focus();
|
|
492
|
+
if (_prevCoordinate !== newCoord) {
|
|
493
|
+
_prevCoordinate = newCoord;
|
|
494
|
+
adjustCoordinate(newCoord, handleId);
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
if (interactive$()) {
|
|
498
|
+
updateSliderSize$.set({});
|
|
499
|
+
currentTarget == null ? void 0 : currentTarget.focus();
|
|
500
|
+
document.addEventListener("touchmove", handleDrag, { passive: false });
|
|
501
|
+
document.addEventListener(
|
|
502
|
+
"touchend",
|
|
503
|
+
() => {
|
|
504
|
+
document.removeEventListener("touchmove", handleDrag);
|
|
505
|
+
document.removeEventListener("touchcancel", handleDrag);
|
|
506
|
+
},
|
|
507
|
+
{ once: true }
|
|
508
|
+
);
|
|
509
|
+
document.addEventListener(
|
|
510
|
+
"touchcancel",
|
|
511
|
+
() => {
|
|
512
|
+
document.removeEventListener("touchmove", handleDrag);
|
|
513
|
+
document.removeEventListener("touchend", handleDrag);
|
|
514
|
+
},
|
|
515
|
+
{ once: true }
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
388
519
|
const handleEventsDirective = utils_directive.createAttributesDirective((handleContext$) => ({
|
|
389
520
|
events: {
|
|
390
521
|
keydown: (event) => {
|
|
@@ -430,61 +561,13 @@ function createSlider(config) {
|
|
|
430
561
|
}
|
|
431
562
|
},
|
|
432
563
|
mousedown: (event) => {
|
|
433
|
-
event.
|
|
434
|
-
|
|
435
|
-
const handleDrag = (e) => {
|
|
436
|
-
e.preventDefault();
|
|
437
|
-
const newCoord = vertical$() ? e.clientY : e.clientX;
|
|
438
|
-
currentTarget.focus();
|
|
439
|
-
if (_prevCoordinate !== newCoord) {
|
|
440
|
-
_prevCoordinate = newCoord;
|
|
441
|
-
adjustCoordinate(newCoord, handleContext$().item.id);
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
if (interactive$()) {
|
|
445
|
-
updateSliderSize$.set({});
|
|
446
|
-
currentTarget.focus();
|
|
447
|
-
document.addEventListener("mousemove", handleDrag);
|
|
448
|
-
document.addEventListener(
|
|
449
|
-
"mouseup",
|
|
450
|
-
() => {
|
|
451
|
-
document.removeEventListener("mousemove", handleDrag);
|
|
452
|
-
},
|
|
453
|
-
{ once: true }
|
|
454
|
-
);
|
|
564
|
+
if (event.button !== 0) {
|
|
565
|
+
return;
|
|
455
566
|
}
|
|
567
|
+
mouseDown(event, handleContext$().item.id);
|
|
456
568
|
},
|
|
457
569
|
touchstart: (event) => {
|
|
458
|
-
|
|
459
|
-
e.preventDefault();
|
|
460
|
-
const newCoord = vertical$() ? e.touches[0].clientY : e.touches[0].clientX;
|
|
461
|
-
event.target.focus();
|
|
462
|
-
if (_prevCoordinate !== newCoord) {
|
|
463
|
-
_prevCoordinate = newCoord;
|
|
464
|
-
adjustCoordinate(newCoord, handleContext$().item.id);
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
if (interactive$()) {
|
|
468
|
-
updateSliderSize$.set({});
|
|
469
|
-
event.target.focus();
|
|
470
|
-
document.addEventListener("touchmove", handleDrag, { passive: false });
|
|
471
|
-
document.addEventListener(
|
|
472
|
-
"touchend",
|
|
473
|
-
() => {
|
|
474
|
-
document.removeEventListener("touchmove", handleDrag);
|
|
475
|
-
document.removeEventListener("touchcancel", handleDrag);
|
|
476
|
-
},
|
|
477
|
-
{ once: true }
|
|
478
|
-
);
|
|
479
|
-
document.addEventListener(
|
|
480
|
-
"touchcancel",
|
|
481
|
-
() => {
|
|
482
|
-
document.removeEventListener("touchmove", handleDrag);
|
|
483
|
-
document.removeEventListener("touchend", handleDrag);
|
|
484
|
-
},
|
|
485
|
-
{ once: true }
|
|
486
|
-
);
|
|
487
|
-
}
|
|
570
|
+
touchStart(event, handleContext$().item.id);
|
|
488
571
|
}
|
|
489
572
|
}
|
|
490
573
|
}));
|
|
@@ -530,8 +613,20 @@ function createSlider(config) {
|
|
|
530
613
|
})),
|
|
531
614
|
clickableAreaDirective: utils_directive.createAttributesDirective(() => ({
|
|
532
615
|
events: {
|
|
533
|
-
|
|
534
|
-
|
|
616
|
+
mousedown: (event) => {
|
|
617
|
+
if (event.button !== 0) {
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
const clickedCoordinate = vertical$() ? event.clientY : event.clientX;
|
|
621
|
+
const closestHandle = getClosestSliderHandle(getClickedPercent(clickedCoordinate));
|
|
622
|
+
adjustCoordinate(clickedCoordinate, closestHandle);
|
|
623
|
+
mouseDown(event, closestHandle);
|
|
624
|
+
},
|
|
625
|
+
touchstart: (event) => {
|
|
626
|
+
const clickedCoordinate = vertical$() ? event.touches[0].clientY : event.touches[0].clientX;
|
|
627
|
+
const closestHandle = getClosestSliderHandle(getClickedPercent(clickedCoordinate));
|
|
628
|
+
adjustCoordinate(clickedCoordinate, closestHandle);
|
|
629
|
+
touchStart(event, closestHandle);
|
|
535
630
|
}
|
|
536
631
|
},
|
|
537
632
|
classNames: {
|
|
@@ -542,6 +637,7 @@ function createSlider(config) {
|
|
|
542
637
|
})),
|
|
543
638
|
handleEventsDirective,
|
|
544
639
|
handleDirective: utils_directive.mergeDirectives(
|
|
640
|
+
handleElementDirective,
|
|
545
641
|
handleEventsDirective,
|
|
546
642
|
utils_directive.createAttributesDirective((handleContext$) => ({
|
|
547
643
|
attributes: {
|
|
@@ -570,36 +666,42 @@ function createSlider(config) {
|
|
|
570
666
|
),
|
|
571
667
|
minLabelDirective: utils_directive.mergeDirectives(minLabelDomDirective, minLabelDirective),
|
|
572
668
|
maxLabelDirective: utils_directive.mergeDirectives(maxLabelDomDirective, maxLabelDirective),
|
|
573
|
-
combinedHandleLabelDisplayDirective: utils_directive.
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
669
|
+
combinedHandleLabelDisplayDirective: utils_directive.mergeDirectives(
|
|
670
|
+
combinedLabelDomDirective,
|
|
671
|
+
utils_directive.createAttributesDirective(() => ({
|
|
672
|
+
classNames: {
|
|
673
|
+
"au-slider-label-vertical": vertical$,
|
|
674
|
+
"au-slider-label-vertical-now": vertical$,
|
|
675
|
+
"au-slider-label": horizontal$,
|
|
676
|
+
"au-slider-label-now": horizontal$
|
|
677
|
+
},
|
|
678
|
+
styles: {
|
|
679
|
+
left: tansu.computed(() => percent(combinedLabelPositionLeft$())),
|
|
680
|
+
top: tansu.computed(() => percent(combinedLabelPositionTop$()))
|
|
681
|
+
},
|
|
682
|
+
attributes: {
|
|
683
|
+
"aria-hidden": tansu.readable("true")
|
|
684
|
+
}
|
|
685
|
+
}))
|
|
686
|
+
),
|
|
687
|
+
handleLabelDisplayDirective: utils_directive.mergeDirectives(
|
|
688
|
+
handleLabelDirective,
|
|
689
|
+
utils_directive.createAttributesDirective((labelDisplayContext$) => ({
|
|
690
|
+
classNames: {
|
|
691
|
+
"au-slider-label-vertical": vertical$,
|
|
692
|
+
"au-slider-label-vertical-now": vertical$,
|
|
693
|
+
"au-slider-label": horizontal$,
|
|
694
|
+
"au-slider-label-now": horizontal$
|
|
695
|
+
},
|
|
696
|
+
styles: {
|
|
697
|
+
left: tansu.computed(() => percent(handleDisplayOptions$()[labelDisplayContext$().index].left)),
|
|
698
|
+
top: tansu.computed(() => percent(handleDisplayOptions$()[labelDisplayContext$().index].top))
|
|
699
|
+
},
|
|
700
|
+
attributes: {
|
|
701
|
+
"aria-hidden": tansu.readable("true")
|
|
702
|
+
}
|
|
703
|
+
}))
|
|
704
|
+
),
|
|
603
705
|
tickDirective: utils_directive.createAttributesDirective((tickContext$) => ({
|
|
604
706
|
classNames: {
|
|
605
707
|
"au-slider-tick": utils_stores.true$,
|
|
@@ -622,7 +724,8 @@ function createSlider(config) {
|
|
|
622
724
|
tickLabelDirective: utils_directive.createAttributesDirective((tickContext$) => ({
|
|
623
725
|
classNames: {
|
|
624
726
|
"au-slider-tick-label": utils_stores.true$,
|
|
625
|
-
"au-slider-tick-label-vertical": vertical
|
|
727
|
+
"au-slider-tick-label-vertical": vertical$,
|
|
728
|
+
"au-slider-tick-label-now": tansu.computed(() => sortedValues$().some((sv) => sv === tickContext$().tick.value))
|
|
626
729
|
},
|
|
627
730
|
styles: {
|
|
628
731
|
left: tansu.computed(() => vertical$() ? null : percent(tickContext$().tick.position)),
|