@agnos-ui/core 0.9.0-next.0 → 0.9.1
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/components/carousel/index.cjs +3 -3
- package/components/carousel/index.js +3 -3
- package/components/slider/index.cjs +1 -1
- package/components/slider/index.js +1 -1
- package/components/slider/slider-utils.d.ts +25 -0
- package/components/slider/slider.d.ts +25 -0
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/{slider-DVthNbSG.js → slider-BmxQ3A_u.js} +109 -5
- package/{slider-xEieAbBb.cjs → slider-DSx5CAce.cjs} +108 -4
|
@@ -156,11 +156,11 @@ const createCarousel = utils_widget.createWidgetFactory("carousel", (config) =>
|
|
|
156
156
|
const {
|
|
157
157
|
stores: { slideNodes$, ...emblaStores }
|
|
158
158
|
} = emblaCarousel;
|
|
159
|
-
const { directive: navDirective, refreshElements,
|
|
159
|
+
const { directive: navDirective, refreshElements, focusLeft, focusRight, focusFirst, focusLast } = services_navManager.createNavManager();
|
|
160
160
|
const navManagerConfig = {
|
|
161
161
|
keys: {
|
|
162
|
-
ArrowLeft:
|
|
163
|
-
ArrowRight:
|
|
162
|
+
ArrowLeft: focusLeft,
|
|
163
|
+
ArrowRight: focusRight,
|
|
164
164
|
Home: focusFirst,
|
|
165
165
|
End: focusLast
|
|
166
166
|
},
|
|
@@ -154,11 +154,11 @@ const createCarousel = createWidgetFactory("carousel", (config) => {
|
|
|
154
154
|
const {
|
|
155
155
|
stores: { slideNodes$, ...emblaStores }
|
|
156
156
|
} = emblaCarousel;
|
|
157
|
-
const { directive: navDirective, refreshElements,
|
|
157
|
+
const { directive: navDirective, refreshElements, focusLeft, focusRight, focusFirst, focusLast } = createNavManager();
|
|
158
158
|
const navManagerConfig = {
|
|
159
159
|
keys: {
|
|
160
|
-
ArrowLeft:
|
|
161
|
-
ArrowRight:
|
|
160
|
+
ArrowLeft: focusLeft,
|
|
161
|
+
ArrowRight: focusRight,
|
|
162
162
|
Home: focusFirst,
|
|
163
163
|
End: focusLast
|
|
164
164
|
},
|
|
@@ -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-DSx5CAce.cjs");
|
|
4
4
|
exports.createSlider = slider.createSlider;
|
|
5
5
|
exports.getSliderDefaultConfig = slider.getSliderDefaultConfig;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages minimum and maximum range constraints for values in an array by adjusting adjacent values.
|
|
3
|
+
*
|
|
4
|
+
* This function ensures that the value at the specified index maintains proper minimum and maximum
|
|
5
|
+
* distance constraints with its neighboring values. It pushes adjacent handles when necessary to
|
|
6
|
+
* maintain the required range constraints.
|
|
7
|
+
*
|
|
8
|
+
* @param values - Array of numeric values to be managed (typically slider handle positions)
|
|
9
|
+
* @param index - Index of the value in the array that serves as the reference point
|
|
10
|
+
* @param minRange - Minimum allowed distance between adjacent values
|
|
11
|
+
* @param maxRange - Maximum allowed distance between adjacent values
|
|
12
|
+
* @param min - Minimum boundary of the slider
|
|
13
|
+
* @param max - Maximum boundary of the slider
|
|
14
|
+
* @param pushRange - Whether to enable pushing of adjacent values to maintain range constraints
|
|
15
|
+
*
|
|
16
|
+
* @returns The modified values array with range constraints applied
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const values = [10, 20, 30, 40];
|
|
21
|
+
* const result = manageMinMaxRange(values, 1, 5, 15, 0, 50, true);
|
|
22
|
+
* // Result ensures value at index 1 maintains 5-15 unit distance from neighbors
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const manageMinMaxRange: (values: number[], index: number, minRange: number, maxRange: number, min: number, max: number, pushRange: boolean) => number[];
|
|
@@ -276,6 +276,27 @@ export interface SliderProps extends SliderCommonPropsAndState {
|
|
|
276
276
|
* @defaultValue `true`
|
|
277
277
|
*/
|
|
278
278
|
showTickValues: boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Minimum distance between two values.
|
|
281
|
+
* When set to 0, no minimum distance constraint is applied.
|
|
282
|
+
*
|
|
283
|
+
* @defaultValue 0
|
|
284
|
+
*/
|
|
285
|
+
minRange: number;
|
|
286
|
+
/**
|
|
287
|
+
* Maximum distance between two values
|
|
288
|
+
* When set to 0, no maximum distance constraint is applied.
|
|
289
|
+
*
|
|
290
|
+
* @defaultValue 0
|
|
291
|
+
*/
|
|
292
|
+
maxRange: number;
|
|
293
|
+
/**
|
|
294
|
+
* When true, if moving a value would break the minRange or maxRange constraint,
|
|
295
|
+
* it will instead push or pull the neighboring values to keep the allowed range rather than just stopping.
|
|
296
|
+
*
|
|
297
|
+
* @defaultValue false
|
|
298
|
+
*/
|
|
299
|
+
pushRange: boolean;
|
|
279
300
|
}
|
|
280
301
|
/**
|
|
281
302
|
* Interface representing various directives used in the slider component.
|
|
@@ -285,6 +306,10 @@ export interface SliderDirectives {
|
|
|
285
306
|
* Directive to get the slider component elementRef
|
|
286
307
|
*/
|
|
287
308
|
sliderDirective: Directive;
|
|
309
|
+
/**
|
|
310
|
+
* Directive to apply to the slider container wrapping the slider content
|
|
311
|
+
*/
|
|
312
|
+
containerDirective: Directive;
|
|
288
313
|
/**
|
|
289
314
|
* Directive used to style the progress display for each handle
|
|
290
315
|
*/
|
package/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@ const pagination = require("./pagination-C1TT-oea.cjs");
|
|
|
8
8
|
const progressbar = require("./progressbar-CRvhNB5R.cjs");
|
|
9
9
|
const rating = require("./rating-DAb6nR67.cjs");
|
|
10
10
|
const select = require("./select-C0rJJQfl.cjs");
|
|
11
|
-
const slider = require("./slider-
|
|
11
|
+
const slider = require("./slider-DSx5CAce.cjs");
|
|
12
12
|
const toaster = require("./toaster-Cayg6Lbq.cjs");
|
|
13
13
|
const tree = require("./tree-Pvr2rZ-D.cjs");
|
|
14
14
|
const config = require("./config.cjs");
|
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { c as c4, g as g4 } from "./pagination-B97wBLok.js";
|
|
|
6
6
|
import { c as c5, g as g5 } from "./progressbar-BWBlRk_Y.js";
|
|
7
7
|
import { c as c6, g as g6 } from "./rating-BXvy9kXq.js";
|
|
8
8
|
import { c as c7, g as g7 } from "./select-BdjpnE7_.js";
|
|
9
|
-
import { c as c8, g as g8 } from "./slider-
|
|
9
|
+
import { c as c8, g as g8 } from "./slider-BmxQ3A_u.js";
|
|
10
10
|
import { T, c as c9, d, g as g9 } from "./toaster-XfzHDqz_.js";
|
|
11
11
|
import { c as c10, g as g10 } from "./tree-BFrXdJox.js";
|
|
12
12
|
import { createWidgetsConfig, mergeInto } from "./config.js";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ 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,
|
|
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
6
|
import { createResizeObserver } from "./services/resizeObserver.js";
|
|
7
7
|
import { createWidgetFactory } from "./utils/widget.js";
|
|
8
8
|
const decimalRegExp = /(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/;
|
|
@@ -16,6 +16,59 @@ function getDecimalPrecision(number) {
|
|
|
16
16
|
(+matches[2] || 0)
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
|
+
const pushHandle = (values, index, currentValue, direction, minRange, min, max, pushRange) => {
|
|
20
|
+
let nextValue = values[index + direction];
|
|
21
|
+
if (nextValue == null || Math.abs(nextValue - currentValue) >= minRange) {
|
|
22
|
+
return currentValue;
|
|
23
|
+
}
|
|
24
|
+
if (pushRange) {
|
|
25
|
+
const targetValue = currentValue + minRange * direction;
|
|
26
|
+
nextValue = pushHandle(values, index + direction, targetValue, direction, minRange, min, max, pushRange);
|
|
27
|
+
nextValue = Math.max(Math.min(nextValue, max), min);
|
|
28
|
+
values[index + direction] = nextValue;
|
|
29
|
+
}
|
|
30
|
+
if (Math.abs(nextValue - currentValue) < minRange) {
|
|
31
|
+
currentValue = nextValue - minRange * direction;
|
|
32
|
+
values[index] = currentValue;
|
|
33
|
+
}
|
|
34
|
+
return currentValue;
|
|
35
|
+
};
|
|
36
|
+
const pullHandle = (values, index, currentValue, direction, maxRange, min, max, pushRange) => {
|
|
37
|
+
let nextValue = values[index + direction];
|
|
38
|
+
if (nextValue == null || Math.abs(nextValue - currentValue) <= maxRange) {
|
|
39
|
+
return currentValue;
|
|
40
|
+
}
|
|
41
|
+
if (pushRange) {
|
|
42
|
+
const targetValue = currentValue + maxRange * direction;
|
|
43
|
+
nextValue = pullHandle(values, index + direction, targetValue, direction, maxRange, min, max, pushRange);
|
|
44
|
+
nextValue = Math.max(Math.min(nextValue, max), min);
|
|
45
|
+
values[index + direction] = nextValue;
|
|
46
|
+
}
|
|
47
|
+
if (Math.abs(nextValue - currentValue) > maxRange) {
|
|
48
|
+
currentValue = nextValue - maxRange * direction;
|
|
49
|
+
values[index] = currentValue;
|
|
50
|
+
}
|
|
51
|
+
return currentValue;
|
|
52
|
+
};
|
|
53
|
+
const manageMinMaxRange = (values, index, minRange, maxRange, min, max, pushRange) => {
|
|
54
|
+
let current = values[index];
|
|
55
|
+
const previous = values[index - 1];
|
|
56
|
+
const next = values[index + 1];
|
|
57
|
+
if (previous != null && current < previous) {
|
|
58
|
+
current = values[index] = previous;
|
|
59
|
+
} else if (next != null && current > next) {
|
|
60
|
+
current = values[index] = next;
|
|
61
|
+
}
|
|
62
|
+
if (minRange) {
|
|
63
|
+
current = pushHandle(values, index, current, 1, minRange, min, max, pushRange);
|
|
64
|
+
current = pushHandle(values, index, current, -1, minRange, min, max, pushRange);
|
|
65
|
+
}
|
|
66
|
+
if (maxRange) {
|
|
67
|
+
current = pullHandle(values, index, current, 1, maxRange, min, max, pushRange);
|
|
68
|
+
pullHandle(values, index, current, -1, maxRange, min, max, pushRange);
|
|
69
|
+
}
|
|
70
|
+
return values;
|
|
71
|
+
};
|
|
19
72
|
const defaultSliderConfig = {
|
|
20
73
|
min: 0,
|
|
21
74
|
max: 100,
|
|
@@ -34,6 +87,9 @@ const defaultSliderConfig = {
|
|
|
34
87
|
showTicks: false,
|
|
35
88
|
showTickValues: true,
|
|
36
89
|
tickInterval: 0,
|
|
90
|
+
minRange: 0,
|
|
91
|
+
maxRange: 0,
|
|
92
|
+
pushRange: false,
|
|
37
93
|
rtl: false
|
|
38
94
|
};
|
|
39
95
|
function getSliderDefaultConfig() {
|
|
@@ -57,7 +113,10 @@ const configValidator = {
|
|
|
57
113
|
showTickValues: typeBoolean,
|
|
58
114
|
tickInterval: typeNumberInRangeFactory(0, Infinity, { strict: true }),
|
|
59
115
|
rtl: typeBoolean,
|
|
60
|
-
className: typeString
|
|
116
|
+
className: typeString,
|
|
117
|
+
minRange: typeNumberInRangeFactory(0, Infinity),
|
|
118
|
+
maxRange: typeNumberInRangeFactory(0, Infinity),
|
|
119
|
+
pushRange: typeBoolean
|
|
61
120
|
};
|
|
62
121
|
const computeCleanValue = (value, min, max, intStepSize, decimalPrecision) => {
|
|
63
122
|
const magnitude = Math.pow(10, decimalPrecision);
|
|
@@ -97,6 +156,9 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
97
156
|
// dirty inputs that need adjustment:
|
|
98
157
|
min$: _dirtyMinimum$,
|
|
99
158
|
max$: _dirtyMaximum$,
|
|
159
|
+
minRange$: _dirtyMinimumRange$,
|
|
160
|
+
maxRange$: _dirtyMaximumRange$,
|
|
161
|
+
pushRange$,
|
|
100
162
|
stepSize$,
|
|
101
163
|
rtl$,
|
|
102
164
|
values$: _dirtyValues$,
|
|
@@ -130,8 +192,25 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
130
192
|
}
|
|
131
193
|
return Math.max(_dirtyMinimum, _dirtyMaximum);
|
|
132
194
|
});
|
|
195
|
+
const minRange$ = computed(() => {
|
|
196
|
+
const _dirtyMinimumRange = _dirtyMinimumRange$();
|
|
197
|
+
if (_dirtyMinimumRange <= 0) {
|
|
198
|
+
return 0;
|
|
199
|
+
}
|
|
200
|
+
const _dirtyMaximumRange = _dirtyMaximumRange$();
|
|
201
|
+
return _dirtyMaximumRange === 0 ? _dirtyMinimumRange : Math.min(_dirtyMinimumRange, _dirtyMaximumRange);
|
|
202
|
+
});
|
|
203
|
+
const maxRange$ = computed(() => {
|
|
204
|
+
const _dirtyMaximumRange = _dirtyMaximumRange$();
|
|
205
|
+
if (_dirtyMaximumRange <= 0) {
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
208
|
+
const _dirtyMinimumRange = _dirtyMinimumRange$();
|
|
209
|
+
return _dirtyMinimumRange === 0 ? _dirtyMaximumRange : Math.max(_dirtyMinimumRange, _dirtyMaximumRange);
|
|
210
|
+
});
|
|
133
211
|
const _decimalPrecision$ = computed(() => Math.max(getDecimalPrecision(stepSize$()), getDecimalPrecision(min$()), getDecimalPrecision(max$())));
|
|
134
212
|
const _intStepSize$ = computed(() => stepSize$() * Math.pow(10, _decimalPrecision$()));
|
|
213
|
+
let previousValues = _dirtyValues$();
|
|
135
214
|
const values$ = bindableProp(
|
|
136
215
|
_dirtyValues$,
|
|
137
216
|
onValuesChange$,
|
|
@@ -140,7 +219,20 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
140
219
|
const max = max$();
|
|
141
220
|
const intStepSize = _intStepSize$();
|
|
142
221
|
const decimalPrecision = _decimalPrecision$();
|
|
143
|
-
|
|
222
|
+
const newValues = dirtyValues.map((dv) => computeCleanValue(dv, min, max, intStepSize, decimalPrecision));
|
|
223
|
+
if (dirtyValues.length > 1) {
|
|
224
|
+
const minRange = minRange$();
|
|
225
|
+
const maxRange = maxRange$();
|
|
226
|
+
if (minRange || maxRange) {
|
|
227
|
+
const pushRange = pushRange$();
|
|
228
|
+
const changedIndex = newValues.findIndex((dv, index) => dv !== previousValues[index]);
|
|
229
|
+
if (changedIndex !== -1) {
|
|
230
|
+
manageMinMaxRange(newValues, changedIndex, minRange, maxRange, min, max, pushRange);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
previousValues = newValues;
|
|
235
|
+
return newValues;
|
|
144
236
|
},
|
|
145
237
|
typeArray.equal
|
|
146
238
|
);
|
|
@@ -408,14 +500,25 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
408
500
|
};
|
|
409
501
|
const horizontal$ = computed(() => !vertical$());
|
|
410
502
|
const containerDirective = createAttributesDirective(() => ({
|
|
503
|
+
classNames: {
|
|
504
|
+
"au-slider": true$,
|
|
505
|
+
"au-slider-vertical": vertical$,
|
|
506
|
+
"au-slider-horizontal": horizontal$
|
|
507
|
+
},
|
|
508
|
+
attributes: {
|
|
509
|
+
class: stateProps.className$
|
|
510
|
+
}
|
|
511
|
+
}));
|
|
512
|
+
const contentDirective = createAttributesDirective(() => ({
|
|
411
513
|
attributes: {
|
|
412
514
|
"aria-disabled": computed(() => disabled$() ? "true" : void 0),
|
|
413
515
|
class: stateProps.className$
|
|
414
516
|
},
|
|
415
517
|
classNames: {
|
|
416
|
-
"au-slider": true$,
|
|
518
|
+
"au-slider-content": true$,
|
|
417
519
|
"au-slider-vertical": vertical$,
|
|
418
520
|
"au-slider-horizontal": horizontal$,
|
|
521
|
+
"au-slider-with-labels": computed(() => showValueLabels$() || showMinMaxLabels$() || showTickValues$() && showTicks$()),
|
|
419
522
|
disabled: disabled$
|
|
420
523
|
}
|
|
421
524
|
}));
|
|
@@ -597,7 +700,8 @@ const createSlider = createWidgetFactory("slider", (config) => {
|
|
|
597
700
|
patch,
|
|
598
701
|
api: {},
|
|
599
702
|
directives: {
|
|
600
|
-
sliderDirective: mergeDirectives(sliderDirective, resizeDirective,
|
|
703
|
+
sliderDirective: mergeDirectives(sliderDirective, resizeDirective, contentDirective),
|
|
704
|
+
containerDirective,
|
|
601
705
|
progressDisplayDirective: createAttributesDirective((progressContext$) => ({
|
|
602
706
|
styles: {
|
|
603
707
|
left: computed(() => percent(progressContext$().option.left)),
|
|
@@ -17,6 +17,59 @@ function getDecimalPrecision(number) {
|
|
|
17
17
|
(+matches[2] || 0)
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
+
const pushHandle = (values, index, currentValue, direction, minRange, min, max, pushRange) => {
|
|
21
|
+
let nextValue = values[index + direction];
|
|
22
|
+
if (nextValue == null || Math.abs(nextValue - currentValue) >= minRange) {
|
|
23
|
+
return currentValue;
|
|
24
|
+
}
|
|
25
|
+
if (pushRange) {
|
|
26
|
+
const targetValue = currentValue + minRange * direction;
|
|
27
|
+
nextValue = pushHandle(values, index + direction, targetValue, direction, minRange, min, max, pushRange);
|
|
28
|
+
nextValue = Math.max(Math.min(nextValue, max), min);
|
|
29
|
+
values[index + direction] = nextValue;
|
|
30
|
+
}
|
|
31
|
+
if (Math.abs(nextValue - currentValue) < minRange) {
|
|
32
|
+
currentValue = nextValue - minRange * direction;
|
|
33
|
+
values[index] = currentValue;
|
|
34
|
+
}
|
|
35
|
+
return currentValue;
|
|
36
|
+
};
|
|
37
|
+
const pullHandle = (values, index, currentValue, direction, maxRange, min, max, pushRange) => {
|
|
38
|
+
let nextValue = values[index + direction];
|
|
39
|
+
if (nextValue == null || Math.abs(nextValue - currentValue) <= maxRange) {
|
|
40
|
+
return currentValue;
|
|
41
|
+
}
|
|
42
|
+
if (pushRange) {
|
|
43
|
+
const targetValue = currentValue + maxRange * direction;
|
|
44
|
+
nextValue = pullHandle(values, index + direction, targetValue, direction, maxRange, min, max, pushRange);
|
|
45
|
+
nextValue = Math.max(Math.min(nextValue, max), min);
|
|
46
|
+
values[index + direction] = nextValue;
|
|
47
|
+
}
|
|
48
|
+
if (Math.abs(nextValue - currentValue) > maxRange) {
|
|
49
|
+
currentValue = nextValue - maxRange * direction;
|
|
50
|
+
values[index] = currentValue;
|
|
51
|
+
}
|
|
52
|
+
return currentValue;
|
|
53
|
+
};
|
|
54
|
+
const manageMinMaxRange = (values, index, minRange, maxRange, min, max, pushRange) => {
|
|
55
|
+
let current = values[index];
|
|
56
|
+
const previous = values[index - 1];
|
|
57
|
+
const next = values[index + 1];
|
|
58
|
+
if (previous != null && current < previous) {
|
|
59
|
+
current = values[index] = previous;
|
|
60
|
+
} else if (next != null && current > next) {
|
|
61
|
+
current = values[index] = next;
|
|
62
|
+
}
|
|
63
|
+
if (minRange) {
|
|
64
|
+
current = pushHandle(values, index, current, 1, minRange, min, max, pushRange);
|
|
65
|
+
current = pushHandle(values, index, current, -1, minRange, min, max, pushRange);
|
|
66
|
+
}
|
|
67
|
+
if (maxRange) {
|
|
68
|
+
current = pullHandle(values, index, current, 1, maxRange, min, max, pushRange);
|
|
69
|
+
pullHandle(values, index, current, -1, maxRange, min, max, pushRange);
|
|
70
|
+
}
|
|
71
|
+
return values;
|
|
72
|
+
};
|
|
20
73
|
const defaultSliderConfig = {
|
|
21
74
|
min: 0,
|
|
22
75
|
max: 100,
|
|
@@ -35,6 +88,9 @@ const defaultSliderConfig = {
|
|
|
35
88
|
showTicks: false,
|
|
36
89
|
showTickValues: true,
|
|
37
90
|
tickInterval: 0,
|
|
91
|
+
minRange: 0,
|
|
92
|
+
maxRange: 0,
|
|
93
|
+
pushRange: false,
|
|
38
94
|
rtl: false
|
|
39
95
|
};
|
|
40
96
|
function getSliderDefaultConfig() {
|
|
@@ -58,7 +114,10 @@ const configValidator = {
|
|
|
58
114
|
showTickValues: utils_writables.typeBoolean,
|
|
59
115
|
tickInterval: utils_writables.typeNumberInRangeFactory(0, Infinity, { strict: true }),
|
|
60
116
|
rtl: utils_writables.typeBoolean,
|
|
61
|
-
className: utils_writables.typeString
|
|
117
|
+
className: utils_writables.typeString,
|
|
118
|
+
minRange: utils_writables.typeNumberInRangeFactory(0, Infinity),
|
|
119
|
+
maxRange: utils_writables.typeNumberInRangeFactory(0, Infinity),
|
|
120
|
+
pushRange: utils_writables.typeBoolean
|
|
62
121
|
};
|
|
63
122
|
const computeCleanValue = (value, min, max, intStepSize, decimalPrecision) => {
|
|
64
123
|
const magnitude = Math.pow(10, decimalPrecision);
|
|
@@ -98,6 +157,9 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
98
157
|
// dirty inputs that need adjustment:
|
|
99
158
|
min$: _dirtyMinimum$,
|
|
100
159
|
max$: _dirtyMaximum$,
|
|
160
|
+
minRange$: _dirtyMinimumRange$,
|
|
161
|
+
maxRange$: _dirtyMaximumRange$,
|
|
162
|
+
pushRange$,
|
|
101
163
|
stepSize$,
|
|
102
164
|
rtl$,
|
|
103
165
|
values$: _dirtyValues$,
|
|
@@ -131,8 +193,25 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
131
193
|
}
|
|
132
194
|
return Math.max(_dirtyMinimum, _dirtyMaximum);
|
|
133
195
|
});
|
|
196
|
+
const minRange$ = tansu.computed(() => {
|
|
197
|
+
const _dirtyMinimumRange = _dirtyMinimumRange$();
|
|
198
|
+
if (_dirtyMinimumRange <= 0) {
|
|
199
|
+
return 0;
|
|
200
|
+
}
|
|
201
|
+
const _dirtyMaximumRange = _dirtyMaximumRange$();
|
|
202
|
+
return _dirtyMaximumRange === 0 ? _dirtyMinimumRange : Math.min(_dirtyMinimumRange, _dirtyMaximumRange);
|
|
203
|
+
});
|
|
204
|
+
const maxRange$ = tansu.computed(() => {
|
|
205
|
+
const _dirtyMaximumRange = _dirtyMaximumRange$();
|
|
206
|
+
if (_dirtyMaximumRange <= 0) {
|
|
207
|
+
return 0;
|
|
208
|
+
}
|
|
209
|
+
const _dirtyMinimumRange = _dirtyMinimumRange$();
|
|
210
|
+
return _dirtyMinimumRange === 0 ? _dirtyMaximumRange : Math.max(_dirtyMinimumRange, _dirtyMaximumRange);
|
|
211
|
+
});
|
|
134
212
|
const _decimalPrecision$ = tansu.computed(() => Math.max(getDecimalPrecision(stepSize$()), getDecimalPrecision(min$()), getDecimalPrecision(max$())));
|
|
135
213
|
const _intStepSize$ = tansu.computed(() => stepSize$() * Math.pow(10, _decimalPrecision$()));
|
|
214
|
+
let previousValues = _dirtyValues$();
|
|
136
215
|
const values$ = utils_stores.bindableProp(
|
|
137
216
|
_dirtyValues$,
|
|
138
217
|
onValuesChange$,
|
|
@@ -141,7 +220,20 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
141
220
|
const max = max$();
|
|
142
221
|
const intStepSize = _intStepSize$();
|
|
143
222
|
const decimalPrecision = _decimalPrecision$();
|
|
144
|
-
|
|
223
|
+
const newValues = dirtyValues.map((dv) => computeCleanValue(dv, min, max, intStepSize, decimalPrecision));
|
|
224
|
+
if (dirtyValues.length > 1) {
|
|
225
|
+
const minRange = minRange$();
|
|
226
|
+
const maxRange = maxRange$();
|
|
227
|
+
if (minRange || maxRange) {
|
|
228
|
+
const pushRange = pushRange$();
|
|
229
|
+
const changedIndex = newValues.findIndex((dv, index) => dv !== previousValues[index]);
|
|
230
|
+
if (changedIndex !== -1) {
|
|
231
|
+
manageMinMaxRange(newValues, changedIndex, minRange, maxRange, min, max, pushRange);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
previousValues = newValues;
|
|
236
|
+
return newValues;
|
|
145
237
|
},
|
|
146
238
|
utils_writables.typeArray.equal
|
|
147
239
|
);
|
|
@@ -409,14 +501,25 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
409
501
|
};
|
|
410
502
|
const horizontal$ = tansu.computed(() => !vertical$());
|
|
411
503
|
const containerDirective = utils_directive.createAttributesDirective(() => ({
|
|
504
|
+
classNames: {
|
|
505
|
+
"au-slider": utils_stores.true$,
|
|
506
|
+
"au-slider-vertical": vertical$,
|
|
507
|
+
"au-slider-horizontal": horizontal$
|
|
508
|
+
},
|
|
509
|
+
attributes: {
|
|
510
|
+
class: stateProps.className$
|
|
511
|
+
}
|
|
512
|
+
}));
|
|
513
|
+
const contentDirective = utils_directive.createAttributesDirective(() => ({
|
|
412
514
|
attributes: {
|
|
413
515
|
"aria-disabled": tansu.computed(() => disabled$() ? "true" : void 0),
|
|
414
516
|
class: stateProps.className$
|
|
415
517
|
},
|
|
416
518
|
classNames: {
|
|
417
|
-
"au-slider": utils_stores.true$,
|
|
519
|
+
"au-slider-content": utils_stores.true$,
|
|
418
520
|
"au-slider-vertical": vertical$,
|
|
419
521
|
"au-slider-horizontal": horizontal$,
|
|
522
|
+
"au-slider-with-labels": tansu.computed(() => showValueLabels$() || showMinMaxLabels$() || showTickValues$() && showTicks$()),
|
|
420
523
|
disabled: disabled$
|
|
421
524
|
}
|
|
422
525
|
}));
|
|
@@ -598,7 +701,8 @@ const createSlider = utils_widget.createWidgetFactory("slider", (config) => {
|
|
|
598
701
|
patch,
|
|
599
702
|
api: {},
|
|
600
703
|
directives: {
|
|
601
|
-
sliderDirective: utils_directive.mergeDirectives(sliderDirective, resizeDirective,
|
|
704
|
+
sliderDirective: utils_directive.mergeDirectives(sliderDirective, resizeDirective, contentDirective),
|
|
705
|
+
containerDirective,
|
|
602
706
|
progressDisplayDirective: utils_directive.createAttributesDirective((progressContext$) => ({
|
|
603
707
|
styles: {
|
|
604
708
|
left: tansu.computed(() => percent(progressContext$().option.left)),
|