@design-factory/angular 21.0.4 → 21.1.0-next.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/drawer/README.md +54 -0
- package/fesm2022/design-factory-angular-drawer.mjs +202 -67
- package/fesm2022/design-factory-angular-drawer.mjs.map +1 -1
- package/fesm2022/design-factory-angular-internals.mjs +439 -17
- package/fesm2022/design-factory-angular-internals.mjs.map +1 -1
- package/fesm2022/design-factory-angular-sidenav.mjs +223 -210
- package/fesm2022/design-factory-angular-sidenav.mjs.map +1 -1
- package/fesm2022/design-factory-angular-theme.mjs +198 -0
- package/fesm2022/design-factory-angular-theme.mjs.map +1 -0
- package/fesm2022/design-factory-angular-topnav.mjs +1538 -0
- package/fesm2022/design-factory-angular-topnav.mjs.map +1 -0
- package/node_modules/@agnos-ui/core/README.md +5 -0
- package/node_modules/@agnos-ui/core/accordion-BC_9xn23.cjs +314 -0
- package/node_modules/@agnos-ui/core/accordion-Ca_0T8Bc.js +315 -0
- package/node_modules/@agnos-ui/core/alert-AhaliJ17.cjs +9 -0
- package/node_modules/@agnos-ui/core/alert-Cb9FhbFQ.js +10 -0
- package/node_modules/@agnos-ui/core/collapse-COriZO7o.cjs +94 -0
- package/node_modules/@agnos-ui/core/collapse-CP79atna.js +95 -0
- package/node_modules/@agnos-ui/core/common-B5jS-Ih_.cjs +73 -0
- package/node_modules/@agnos-ui/core/common-DFyZvkII.js +74 -0
- package/node_modules/@agnos-ui/core/components/accordion/accordion.d.ts +333 -0
- package/node_modules/@agnos-ui/core/components/accordion/index.cjs +7 -0
- package/node_modules/@agnos-ui/core/components/accordion/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/accordion/index.js +7 -0
- package/node_modules/@agnos-ui/core/components/alert/alert.d.ts +37 -0
- package/node_modules/@agnos-ui/core/components/alert/common.d.ts +138 -0
- package/node_modules/@agnos-ui/core/components/alert/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/alert/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/alert/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/carousel/carousel.d.ts +247 -0
- package/node_modules/@agnos-ui/core/components/carousel/index.cjs +292 -0
- package/node_modules/@agnos-ui/core/components/carousel/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/carousel/index.js +292 -0
- package/node_modules/@agnos-ui/core/components/collapse/collapse.d.ts +135 -0
- package/node_modules/@agnos-ui/core/components/collapse/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/collapse/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/collapse/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/commonProps.d.ts +11 -0
- package/node_modules/@agnos-ui/core/components/drawer/drawer.d.ts +279 -0
- package/node_modules/@agnos-ui/core/components/drawer/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/drawer/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/drawer/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/modal/index.cjs +8 -0
- package/node_modules/@agnos-ui/core/components/modal/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/modal/index.js +8 -0
- package/node_modules/@agnos-ui/core/components/modal/modal.d.ts +245 -0
- package/node_modules/@agnos-ui/core/components/pagination/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/pagination/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/pagination/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/pagination/pagination.d.ts +313 -0
- package/node_modules/@agnos-ui/core/components/progressbar/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/progressbar/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/progressbar/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/progressbar/progressbar.d.ts +91 -0
- package/node_modules/@agnos-ui/core/components/rating/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/rating/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/rating/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/rating/rating.d.ts +191 -0
- package/node_modules/@agnos-ui/core/components/slider/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/slider/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/slider/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/slider/slider-utils.d.ts +25 -0
- package/node_modules/@agnos-ui/core/components/slider/slider.d.ts +383 -0
- package/node_modules/@agnos-ui/core/components/toast/index.cjs +7 -0
- package/node_modules/@agnos-ui/core/components/toast/index.d.ts +2 -0
- package/node_modules/@agnos-ui/core/components/toast/index.js +7 -0
- package/node_modules/@agnos-ui/core/components/toast/toast.d.ts +66 -0
- package/node_modules/@agnos-ui/core/components/toast/toaster.d.ts +128 -0
- package/node_modules/@agnos-ui/core/components/tree/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/tree/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/tree/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/tree/tree.d.ts +143 -0
- package/node_modules/@agnos-ui/core/config.cjs +36 -0
- package/node_modules/@agnos-ui/core/config.d.ts +117 -0
- package/node_modules/@agnos-ui/core/config.js +36 -0
- package/node_modules/@agnos-ui/core/directive-Bsreu2z1.js +523 -0
- package/node_modules/@agnos-ui/core/directive-DCaXmRe_.cjs +522 -0
- package/node_modules/@agnos-ui/core/drawer-BbFAHV07.cjs +328 -0
- package/node_modules/@agnos-ui/core/drawer-C6Qa0xEu.js +329 -0
- package/node_modules/@agnos-ui/core/index.cjs +134 -0
- package/node_modules/@agnos-ui/core/index.d.ts +29 -0
- package/node_modules/@agnos-ui/core/index.js +134 -0
- package/node_modules/@agnos-ui/core/isFocusable-Ckwus82R.js +32 -0
- package/node_modules/@agnos-ui/core/isFocusable-DfzDLeAN.cjs +31 -0
- package/node_modules/@agnos-ui/core/modal-BsNuHhT7.cjs +252 -0
- package/node_modules/@agnos-ui/core/modal-CgzY8ezz.js +253 -0
- package/node_modules/@agnos-ui/core/package.json +57 -0
- package/node_modules/@agnos-ui/core/pagination-ZxGaNWZz.js +255 -0
- package/node_modules/@agnos-ui/core/pagination-xbcOHnhd.cjs +254 -0
- package/node_modules/@agnos-ui/core/progressbar-CRbMKp4b.cjs +86 -0
- package/node_modules/@agnos-ui/core/progressbar-CSEIFnlD.js +87 -0
- package/node_modules/@agnos-ui/core/promise-CxCD3NYv.cjs +118 -0
- package/node_modules/@agnos-ui/core/promise-D-RZVPuv.js +119 -0
- package/node_modules/@agnos-ui/core/rating-BIdiiPUo.js +184 -0
- package/node_modules/@agnos-ui/core/rating-qx1xaBmz.cjs +183 -0
- package/node_modules/@agnos-ui/core/scrollbars-CT87iv_6.cjs +30 -0
- package/node_modules/@agnos-ui/core/scrollbars-CcxSrnCx.js +31 -0
- package/node_modules/@agnos-ui/core/services/extendWidget.cjs +41 -0
- package/node_modules/@agnos-ui/core/services/extendWidget.d.ts +31 -0
- package/node_modules/@agnos-ui/core/services/extendWidget.js +41 -0
- package/node_modules/@agnos-ui/core/services/floatingUI.cjs +111 -0
- package/node_modules/@agnos-ui/core/services/floatingUI.d.ts +76 -0
- package/node_modules/@agnos-ui/core/services/floatingUI.js +111 -0
- package/node_modules/@agnos-ui/core/services/focusElement.cjs +46 -0
- package/node_modules/@agnos-ui/core/services/focusElement.d.ts +9 -0
- package/node_modules/@agnos-ui/core/services/focusElement.js +46 -0
- package/node_modules/@agnos-ui/core/services/focustrack.cjs +47 -0
- package/node_modules/@agnos-ui/core/services/focustrack.d.ts +40 -0
- package/node_modules/@agnos-ui/core/services/focustrack.js +47 -0
- package/node_modules/@agnos-ui/core/services/hash.cjs +15 -0
- package/node_modules/@agnos-ui/core/services/hash.d.ts +3 -0
- package/node_modules/@agnos-ui/core/services/hash.js +15 -0
- package/node_modules/@agnos-ui/core/services/intersection.cjs +53 -0
- package/node_modules/@agnos-ui/core/services/intersection.d.ts +30 -0
- package/node_modules/@agnos-ui/core/services/intersection.js +53 -0
- package/node_modules/@agnos-ui/core/services/matchMedia.cjs +14 -0
- package/node_modules/@agnos-ui/core/services/matchMedia.d.ts +8 -0
- package/node_modules/@agnos-ui/core/services/matchMedia.js +14 -0
- package/node_modules/@agnos-ui/core/services/navManager.cjs +166 -0
- package/node_modules/@agnos-ui/core/services/navManager.d.ts +144 -0
- package/node_modules/@agnos-ui/core/services/navManager.js +166 -0
- package/node_modules/@agnos-ui/core/services/pointerdownPosition.cjs +60 -0
- package/node_modules/@agnos-ui/core/services/pointerdownPosition.d.ts +42 -0
- package/node_modules/@agnos-ui/core/services/pointerdownPosition.js +60 -0
- package/node_modules/@agnos-ui/core/services/portal.cjs +42 -0
- package/node_modules/@agnos-ui/core/services/portal.d.ts +16 -0
- package/node_modules/@agnos-ui/core/services/portal.js +42 -0
- package/node_modules/@agnos-ui/core/services/resizeObserver.cjs +54 -0
- package/node_modules/@agnos-ui/core/services/resizeObserver.d.ts +18 -0
- package/node_modules/@agnos-ui/core/services/resizeObserver.js +54 -0
- package/node_modules/@agnos-ui/core/services/siblingsInert.cjs +44 -0
- package/node_modules/@agnos-ui/core/services/siblingsInert.d.ts +16 -0
- package/node_modules/@agnos-ui/core/services/siblingsInert.js +44 -0
- package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.cjs +186 -0
- package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.d.ts +166 -0
- package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.js +186 -0
- package/node_modules/@agnos-ui/core/services/transitions/collapse.cjs +40 -0
- package/node_modules/@agnos-ui/core/services/transitions/collapse.d.ts +49 -0
- package/node_modules/@agnos-ui/core/services/transitions/collapse.js +40 -0
- package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.cjs +32 -0
- package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.d.ts +25 -0
- package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.js +32 -0
- package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.cjs +37 -0
- package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.d.ts +47 -0
- package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.js +37 -0
- package/node_modules/@agnos-ui/core/slider-B93hE0ag.cjs +807 -0
- package/node_modules/@agnos-ui/core/slider-Cjiq9FgI.js +808 -0
- package/node_modules/@agnos-ui/core/textDirection-cNgt24LJ.js +4 -0
- package/node_modules/@agnos-ui/core/textDirection-zqcZ5-eK.cjs +3 -0
- package/node_modules/@agnos-ui/core/toaster-BQWqxYv-.cjs +190 -0
- package/node_modules/@agnos-ui/core/toaster-BzEkshT2.js +191 -0
- package/node_modules/@agnos-ui/core/tree-DY04XPPg.cjs +228 -0
- package/node_modules/@agnos-ui/core/tree-HwcvZ0_p.js +229 -0
- package/node_modules/@agnos-ui/core/types.cjs +6 -0
- package/node_modules/@agnos-ui/core/types.d.ts +246 -0
- package/node_modules/@agnos-ui/core/types.js +6 -0
- package/node_modules/@agnos-ui/core/utils/directive.cjs +28 -0
- package/node_modules/@agnos-ui/core/utils/directive.d.ts +352 -0
- package/node_modules/@agnos-ui/core/utils/directive.js +28 -0
- package/node_modules/@agnos-ui/core/utils/func.cjs +7 -0
- package/node_modules/@agnos-ui/core/utils/func.d.ts +11 -0
- package/node_modules/@agnos-ui/core/utils/func.js +7 -0
- package/node_modules/@agnos-ui/core/utils/id.cjs +5 -0
- package/node_modules/@agnos-ui/core/utils/id.d.ts +6 -0
- package/node_modules/@agnos-ui/core/utils/id.js +5 -0
- package/node_modules/@agnos-ui/core/utils/internal/assign.d.ts +10 -0
- package/node_modules/@agnos-ui/core/utils/internal/checks.d.ts +57 -0
- package/node_modules/@agnos-ui/core/utils/internal/dom.d.ts +75 -0
- package/node_modules/@agnos-ui/core/utils/internal/isFocusable.d.ts +9 -0
- package/node_modules/@agnos-ui/core/utils/internal/math.d.ts +5 -0
- package/node_modules/@agnos-ui/core/utils/internal/promise.d.ts +98 -0
- package/node_modules/@agnos-ui/core/utils/internal/scrollbars.d.ts +8 -0
- package/node_modules/@agnos-ui/core/utils/internal/sort.d.ts +16 -0
- package/node_modules/@agnos-ui/core/utils/internal/ssrHTMLElement.d.ts +17 -0
- package/node_modules/@agnos-ui/core/utils/internal/textDirection.d.ts +7 -0
- package/node_modules/@agnos-ui/core/utils/internal/traversal.d.ts +54 -0
- package/node_modules/@agnos-ui/core/utils/stores.cjs +172 -0
- package/node_modules/@agnos-ui/core/utils/stores.d.ts +224 -0
- package/node_modules/@agnos-ui/core/utils/stores.js +172 -0
- package/node_modules/@agnos-ui/core/utils/widget.cjs +8 -0
- package/node_modules/@agnos-ui/core/utils/widget.d.ts +11 -0
- package/node_modules/@agnos-ui/core/utils/widget.js +8 -0
- package/node_modules/@agnos-ui/core/utils/writables.cjs +16 -0
- package/node_modules/@agnos-ui/core/utils/writables.d.ts +95 -0
- package/node_modules/@agnos-ui/core/utils/writables.js +16 -0
- package/node_modules/@agnos-ui/core/writables-DYGjj5T3.js +103 -0
- package/node_modules/@agnos-ui/core/writables-Dt68gADJ.cjs +102 -0
- package/package.json +25 -6
- package/schematics/collection.json +1 -1
- package/types/design-factory-angular-drawer.d.ts +71 -13
- package/types/design-factory-angular-internals.d.ts +220 -31
- package/types/design-factory-angular-sidenav.d.ts +15 -7
- package/types/design-factory-angular-theme.d.ts +122 -0
- package/types/design-factory-angular-topnav.d.ts +435 -0
|
@@ -0,0 +1,808 @@
|
|
|
1
|
+
import { computed, writable, readable } from "@amadeus-it-group/tansu";
|
|
2
|
+
import { i as createBrowserStoreDirective, h as createBrowserStoreArrayDirective, s as mergeDirectives, g as createAttributesDirective, d as browserDirective } from "./directive-Bsreu2z1.js";
|
|
3
|
+
import { noop } from "./utils/func.js";
|
|
4
|
+
import { writablesForProps, bindableProp, true$, stateStores } from "./utils/stores.js";
|
|
5
|
+
import { h as typeNumberInRangeFactory, b as typeBoolean, j as typeString, a as typeArray, e as typeFunction, g as typeNumber, l as clamp } from "./writables-DYGjj5T3.js";
|
|
6
|
+
import { createResizeObserver, createResizeObserverMap } from "./services/resizeObserver.js";
|
|
7
|
+
import { createPointerdownPositionDirective } from "./services/pointerdownPosition.js";
|
|
8
|
+
import { createWidgetFactory } from "./utils/widget.js";
|
|
9
|
+
const decimalRegExp = /(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/;
|
|
10
|
+
function getDecimalPrecision(number) {
|
|
11
|
+
const matches = ("" + number).match(decimalRegExp);
|
|
12
|
+
return Math.max(
|
|
13
|
+
0,
|
|
14
|
+
// Number of digits right of decimal point.
|
|
15
|
+
(matches[1]?.length ?? 0) - // Adjust for exponential notation.
|
|
16
|
+
(+matches[2] || 0)
|
|
17
|
+
);
|
|
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
|
+
};
|
|
72
|
+
const defaultSliderConfig = {
|
|
73
|
+
min: 0,
|
|
74
|
+
max: 100,
|
|
75
|
+
stepSize: 1,
|
|
76
|
+
readonly: false,
|
|
77
|
+
disabled: false,
|
|
78
|
+
vertical: false,
|
|
79
|
+
className: "",
|
|
80
|
+
ariaLabel: () => "Value",
|
|
81
|
+
ariaLabelledBy: () => "",
|
|
82
|
+
ariaValueText: () => "",
|
|
83
|
+
onValuesChange: noop,
|
|
84
|
+
values: [0],
|
|
85
|
+
showValueLabels: true,
|
|
86
|
+
showMinMaxLabels: true,
|
|
87
|
+
showTicks: false,
|
|
88
|
+
showTickValues: true,
|
|
89
|
+
tickInterval: 0,
|
|
90
|
+
minRange: 0,
|
|
91
|
+
maxRange: 0,
|
|
92
|
+
pushRange: false,
|
|
93
|
+
rtl: false
|
|
94
|
+
};
|
|
95
|
+
function getSliderDefaultConfig() {
|
|
96
|
+
return { ...defaultSliderConfig };
|
|
97
|
+
}
|
|
98
|
+
const configValidator = {
|
|
99
|
+
min: typeNumber,
|
|
100
|
+
max: typeNumber,
|
|
101
|
+
stepSize: typeNumberInRangeFactory(0, Infinity, { strict: true }),
|
|
102
|
+
readonly: typeBoolean,
|
|
103
|
+
disabled: typeBoolean,
|
|
104
|
+
vertical: typeBoolean,
|
|
105
|
+
ariaLabel: typeFunction,
|
|
106
|
+
ariaLabelledBy: typeFunction,
|
|
107
|
+
ariaValueText: typeFunction,
|
|
108
|
+
onValuesChange: typeFunction,
|
|
109
|
+
values: typeArray,
|
|
110
|
+
showValueLabels: typeBoolean,
|
|
111
|
+
showMinMaxLabels: typeBoolean,
|
|
112
|
+
showTicks: typeBoolean,
|
|
113
|
+
showTickValues: typeBoolean,
|
|
114
|
+
tickInterval: typeNumberInRangeFactory(0, Infinity, { strict: true }),
|
|
115
|
+
rtl: typeBoolean,
|
|
116
|
+
className: typeString,
|
|
117
|
+
minRange: typeNumberInRangeFactory(0, Infinity),
|
|
118
|
+
maxRange: typeNumberInRangeFactory(0, Infinity),
|
|
119
|
+
pushRange: typeBoolean
|
|
120
|
+
};
|
|
121
|
+
const computeCleanValue = (value, min, max, intStepSize, decimalPrecision) => {
|
|
122
|
+
const magnitude = Math.pow(10, decimalPrecision);
|
|
123
|
+
if (value >= max) {
|
|
124
|
+
return max;
|
|
125
|
+
} else if (value <= min) {
|
|
126
|
+
return min;
|
|
127
|
+
}
|
|
128
|
+
const indexMin = Math.floor((value - min) * magnitude / intStepSize);
|
|
129
|
+
return +(((value - min) * magnitude % intStepSize < intStepSize / 2 ? indexMin : indexMin + 1) * intStepSize / magnitude + min).toFixed(decimalPrecision);
|
|
130
|
+
};
|
|
131
|
+
const updateValue = (handleIndex, values$, stepSize, updateDirection) => {
|
|
132
|
+
values$.update((value) => {
|
|
133
|
+
value = [...value];
|
|
134
|
+
value[handleIndex] = value[handleIndex] + stepSize * updateDirection;
|
|
135
|
+
return value;
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const getUpdateDirection = (vertical, rtl, keysVertical) => {
|
|
139
|
+
if (vertical && rtl) {
|
|
140
|
+
return keysVertical ? 1 : -1;
|
|
141
|
+
} else if (vertical && !rtl) {
|
|
142
|
+
return -1;
|
|
143
|
+
} else if (!vertical && rtl) {
|
|
144
|
+
return keysVertical ? -1 : 1;
|
|
145
|
+
} else if (!vertical && !rtl) {
|
|
146
|
+
return -1;
|
|
147
|
+
}
|
|
148
|
+
return 1;
|
|
149
|
+
};
|
|
150
|
+
const percent = (value) => value != null ? `${value}%` : "";
|
|
151
|
+
const createSlider = createWidgetFactory(
|
|
152
|
+
"slider",
|
|
153
|
+
(config) => {
|
|
154
|
+
const [
|
|
155
|
+
{
|
|
156
|
+
// dirty inputs that need adjustment:
|
|
157
|
+
min$: _dirtyMinimum$,
|
|
158
|
+
max$: _dirtyMaximum$,
|
|
159
|
+
minRange$: _dirtyMinimumRange$,
|
|
160
|
+
maxRange$: _dirtyMaximumRange$,
|
|
161
|
+
pushRange$,
|
|
162
|
+
stepSize$,
|
|
163
|
+
rtl$,
|
|
164
|
+
values$: _dirtyValues$,
|
|
165
|
+
ariaLabel$,
|
|
166
|
+
ariaLabelledBy$,
|
|
167
|
+
ariaValueText$,
|
|
168
|
+
onValuesChange$,
|
|
169
|
+
showValueLabels$,
|
|
170
|
+
showMinMaxLabels$,
|
|
171
|
+
showTicks$,
|
|
172
|
+
showTickValues$,
|
|
173
|
+
tickInterval$,
|
|
174
|
+
...stateProps
|
|
175
|
+
},
|
|
176
|
+
patch
|
|
177
|
+
] = writablesForProps(defaultSliderConfig, config, configValidator);
|
|
178
|
+
const { vertical$, disabled$, readonly$ } = stateProps;
|
|
179
|
+
const _handleElements = /* @__PURE__ */ new Map();
|
|
180
|
+
const min$ = computed(() => {
|
|
181
|
+
const _dirtyMinimum = _dirtyMinimum$(), _dirtyMaximum = _dirtyMaximum$();
|
|
182
|
+
if (_dirtyMinimum === _dirtyMaximum) {
|
|
183
|
+
return defaultSliderConfig.min;
|
|
184
|
+
}
|
|
185
|
+
return Math.min(_dirtyMinimum, _dirtyMaximum);
|
|
186
|
+
});
|
|
187
|
+
const max$ = computed(() => {
|
|
188
|
+
const _dirtyMinimum = _dirtyMinimum$(), _dirtyMaximum = _dirtyMaximum$();
|
|
189
|
+
if (_dirtyMinimum === _dirtyMaximum) {
|
|
190
|
+
return defaultSliderConfig.max;
|
|
191
|
+
}
|
|
192
|
+
return Math.max(_dirtyMinimum, _dirtyMaximum);
|
|
193
|
+
});
|
|
194
|
+
const minRange$ = computed(() => {
|
|
195
|
+
const _dirtyMinimumRange = _dirtyMinimumRange$();
|
|
196
|
+
if (_dirtyMinimumRange <= 0) {
|
|
197
|
+
return 0;
|
|
198
|
+
}
|
|
199
|
+
const _dirtyMaximumRange = _dirtyMaximumRange$();
|
|
200
|
+
return _dirtyMaximumRange === 0 ? _dirtyMinimumRange : Math.min(_dirtyMinimumRange, _dirtyMaximumRange);
|
|
201
|
+
});
|
|
202
|
+
const maxRange$ = computed(() => {
|
|
203
|
+
const _dirtyMaximumRange = _dirtyMaximumRange$();
|
|
204
|
+
if (_dirtyMaximumRange <= 0) {
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
const _dirtyMinimumRange = _dirtyMinimumRange$();
|
|
208
|
+
return _dirtyMinimumRange === 0 ? _dirtyMaximumRange : Math.max(_dirtyMinimumRange, _dirtyMaximumRange);
|
|
209
|
+
});
|
|
210
|
+
const _decimalPrecision$ = computed(
|
|
211
|
+
() => Math.max(getDecimalPrecision(stepSize$()), getDecimalPrecision(min$()), getDecimalPrecision(max$()))
|
|
212
|
+
);
|
|
213
|
+
const _intStepSize$ = computed(() => stepSize$() * Math.pow(10, _decimalPrecision$()));
|
|
214
|
+
let previousValues = _dirtyValues$();
|
|
215
|
+
const values$ = bindableProp(
|
|
216
|
+
_dirtyValues$,
|
|
217
|
+
onValuesChange$,
|
|
218
|
+
(dirtyValues) => {
|
|
219
|
+
const min = min$();
|
|
220
|
+
const max = max$();
|
|
221
|
+
const intStepSize = _intStepSize$();
|
|
222
|
+
const decimalPrecision = _decimalPrecision$();
|
|
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;
|
|
237
|
+
},
|
|
238
|
+
typeArray.equal
|
|
239
|
+
);
|
|
240
|
+
const { directive: sliderDirective, element$: sliderDom$ } = createBrowserStoreDirective();
|
|
241
|
+
const { directive: minLabelDomDirective, element$: minLabelDom$ } = createBrowserStoreDirective();
|
|
242
|
+
const { directive: maxLabelDomDirective, element$: maxLabelDom$ } = createBrowserStoreDirective();
|
|
243
|
+
const { directive: handleLabelDirective, elements$: currentLabelDoms$ } = createBrowserStoreArrayDirective();
|
|
244
|
+
const { directive: resizeDirective, dimensions$ } = createResizeObserver();
|
|
245
|
+
const { directive: resizeLabelsDirective, dimensionsMap$: handleDimensions$ } = createResizeObserverMap();
|
|
246
|
+
const { directive: resizeCombineLabelDirective, dimensions$: combinedDimensions$ } = createResizeObserver();
|
|
247
|
+
const updateSliderSize$ = writable({});
|
|
248
|
+
const sliderDomRect$ = computed(
|
|
249
|
+
() => {
|
|
250
|
+
dimensions$();
|
|
251
|
+
updateSliderSize$();
|
|
252
|
+
return sliderDom$()?.getBoundingClientRect() ?? {};
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
equal: Object.is
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
const minLabelDomRect$ = computed(
|
|
259
|
+
() => {
|
|
260
|
+
dimensions$();
|
|
261
|
+
updateSliderSize$();
|
|
262
|
+
return minLabelDom$()?.getBoundingClientRect() ?? {};
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
equal: (a, b) => Object.is(a, b)
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
const maxLabelDomRect$ = computed(
|
|
269
|
+
() => {
|
|
270
|
+
dimensions$();
|
|
271
|
+
updateSliderSize$();
|
|
272
|
+
return maxLabelDom$()?.getBoundingClientRect() ?? {};
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
equal: (a, b) => Object.is(a, b)
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
const sliderDomRectOffset$ = computed(() => sliderDomRect$()[vertical$() ? "top" : "left"]);
|
|
279
|
+
const sliderDomRectSize$ = computed(() => sliderDomRect$()[vertical$() ? "height" : "width"]);
|
|
280
|
+
const sortedValues$ = computed(() => [...values$()].sort((a, b) => a - b));
|
|
281
|
+
const _sortedHandlesValues$ = computed(() => {
|
|
282
|
+
return values$().map((val, index) => {
|
|
283
|
+
return { id: index, value: val };
|
|
284
|
+
}).sort((a, b) => a.value - b.value);
|
|
285
|
+
});
|
|
286
|
+
const sortedHandles$ = computed(() => {
|
|
287
|
+
const ariaLabelHandle = ariaLabel$(), ariaValueText = ariaValueText$(), ariaLabelledBy = ariaLabelledBy$();
|
|
288
|
+
return _sortedHandlesValues$().map((sortedValue, index) => {
|
|
289
|
+
return {
|
|
290
|
+
...sortedValue,
|
|
291
|
+
ariaLabel: ariaLabelledBy(index) ? void 0 : ariaLabelHandle(index),
|
|
292
|
+
ariaLabelledBy: ariaLabelledBy(index) || void 0,
|
|
293
|
+
ariaValueText: ariaValueText(sortedValue.value, index) || void 0
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
const valuesPercent$ = computed(() => values$().map((val) => percentCompute(val)));
|
|
298
|
+
const sortedValuesPercent$ = computed(() => [...valuesPercent$()].sort((a, b) => a - b));
|
|
299
|
+
const activeDimension$ = computed(() => vertical$() ? "height" : "width");
|
|
300
|
+
const activePosition$ = computed(() => vertical$() ? "top" : "left");
|
|
301
|
+
const minLabelSize$ = computed(() => pixelToPercent(minLabelDomRect$()[activeDimension$()]));
|
|
302
|
+
const maxLabelSize$ = computed(() => pixelToPercent(maxLabelDomRect$()[activeDimension$()]));
|
|
303
|
+
const adjustedShowValueLabels$ = computed(() => showValueLabels$() && (!showTicks$() || !showTickValues$()));
|
|
304
|
+
const pixelToPercent = (pixels) => pixels ? pixels / sliderDomRectSize$() * 100 : 0;
|
|
305
|
+
const combinedLabelSize$ = computed(() => pixelToPercent(combinedDimensions$()?.contentRect[activeDimension$()]));
|
|
306
|
+
const combinedLabelPosition$ = computed(
|
|
307
|
+
() => vertical$() ? combinedLabelPositionTop$() : combinedLabelPositionLeft$()
|
|
308
|
+
);
|
|
309
|
+
const currentLabelSizeByIndex = (index) => pixelToPercent(handleDimensions$().get(currentLabelDoms$()[index])?.contentRect[activeDimension$()]);
|
|
310
|
+
const minValueLabelDisplay$ = computed(() => {
|
|
311
|
+
if (!showMinMaxLabels$() || showTicks$() && showTickValues$()) {
|
|
312
|
+
return false;
|
|
313
|
+
} else if (!showValueLabels$()) {
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
const minLabelSize = minLabelSize$();
|
|
317
|
+
const vertical = vertical$();
|
|
318
|
+
const rtl = rtl$();
|
|
319
|
+
if (combinedLabelDisplay$()) {
|
|
320
|
+
const combinedLabelSize = combinedLabelSize$();
|
|
321
|
+
const combinedLabelPosition = combinedLabelPosition$();
|
|
322
|
+
return rtl && !vertical || vertical && !rtl ? combinedLabelPosition + combinedLabelSize / 2 < 100 - minLabelSize - 1 : combinedLabelPosition - combinedLabelSize / 2 > minLabelSize + 1;
|
|
323
|
+
}
|
|
324
|
+
const sortedValuesPercent = sortedValuesPercent$();
|
|
325
|
+
return rtl ? sortedValuesPercent[0] - currentLabelSizeByIndex(sortedValuesPercent.length - 1) / 2 > minLabelSize + 1 : sortedValuesPercent[0] - currentLabelSizeByIndex(0) / 2 > minLabelSize + 1;
|
|
326
|
+
});
|
|
327
|
+
const maxValueLabelDisplay$ = computed(() => {
|
|
328
|
+
if (!showMinMaxLabels$() || showTicks$() && showTickValues$()) {
|
|
329
|
+
return false;
|
|
330
|
+
} else if (!showValueLabels$()) {
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
const maxLabelSize = maxLabelSize$();
|
|
334
|
+
const vertical = vertical$();
|
|
335
|
+
const rtl = rtl$();
|
|
336
|
+
if (combinedLabelDisplay$()) {
|
|
337
|
+
const combinedLabelSize = combinedLabelSize$();
|
|
338
|
+
const combinedLabelPosition = combinedLabelPosition$();
|
|
339
|
+
return rtl && !vertical || vertical && !rtl ? combinedLabelPosition - combinedLabelSize / 2 > maxLabelSize + 1 : combinedLabelPosition + combinedLabelSize / 2 < 100 - maxLabelSize - 1;
|
|
340
|
+
}
|
|
341
|
+
const sortedValuesPercent = sortedValuesPercent$();
|
|
342
|
+
return rtl ? 100 - sortedValuesPercent[sortedValuesPercent.length - 1] - currentLabelSizeByIndex(0) / 2 > maxLabelSize + 1 : sortedValuesPercent[sortedValuesPercent.length - 1] + currentLabelSizeByIndex(sortedValuesPercent.length - 1) / 2 < 100 - maxLabelSize - 1;
|
|
343
|
+
});
|
|
344
|
+
const combinedLabelDisplay$ = computed(() => {
|
|
345
|
+
if (currentLabelDoms$().length == 2) {
|
|
346
|
+
return doLabelsIntersect();
|
|
347
|
+
}
|
|
348
|
+
return false;
|
|
349
|
+
});
|
|
350
|
+
function doLabelsIntersect() {
|
|
351
|
+
const handleOptions = handleDisplayOptions$();
|
|
352
|
+
const activePosition = activePosition$();
|
|
353
|
+
const labelPosition1 = labelPosition(handleOptions[0][activePosition], currentLabelSizeByIndex(0));
|
|
354
|
+
const labelPosition2 = labelPosition(handleOptions[1][activePosition], currentLabelSizeByIndex(1));
|
|
355
|
+
const labelSize1 = currentLabelSizeByIndex(0);
|
|
356
|
+
const labelSize2 = currentLabelSizeByIndex(1);
|
|
357
|
+
if (labelSize1 === 100 || labelSize2 === 100) {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
const labelStart1 = labelPosition1 - labelSize1;
|
|
361
|
+
const labelEnd1 = labelPosition1 + labelSize1;
|
|
362
|
+
const labelStart2 = labelPosition2 - labelSize2;
|
|
363
|
+
const labelEnd2 = labelPosition2 + labelSize2;
|
|
364
|
+
return !(labelEnd1 < labelStart2 || labelStart1 > labelEnd2);
|
|
365
|
+
}
|
|
366
|
+
const interactive$ = computed(() => !disabled$() && !readonly$());
|
|
367
|
+
const combinedLabelPositionLeft$ = computed(() => {
|
|
368
|
+
const sortedValuesPercent = sortedValuesPercent$();
|
|
369
|
+
const combinedLabelSize = combinedLabelSize$();
|
|
370
|
+
let combinedPosition = (sortedValuesPercent[0] + sortedValuesPercent[1]) / 2;
|
|
371
|
+
combinedPosition = labelPosition(combinedPosition, combinedLabelSize);
|
|
372
|
+
return vertical$() || sortedValuesPercent.length != 2 ? 0 : rtl$() ? 100 - combinedPosition : combinedPosition;
|
|
373
|
+
});
|
|
374
|
+
const combinedLabelPositionTop$ = computed(() => {
|
|
375
|
+
const sortedValuesPercent = sortedValuesPercent$();
|
|
376
|
+
const combinedPosition = 100 - (sortedValuesPercent[0] + sortedValuesPercent[1]) / 2;
|
|
377
|
+
return vertical$() && sortedValuesPercent.length == 2 ? rtl$() ? 100 - combinedPosition : combinedPosition : 0;
|
|
378
|
+
});
|
|
379
|
+
const handleDisplayOptions$ = computed(() => {
|
|
380
|
+
const vertical = vertical$(), rtl = rtl$();
|
|
381
|
+
return valuesPercent$().map((vp) => {
|
|
382
|
+
return {
|
|
383
|
+
left: rtl ? vertical ? null : 100 - vp : vertical ? null : vp,
|
|
384
|
+
top: rtl ? vertical ? vp : null : vertical ? 100 - vp : null
|
|
385
|
+
};
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
const labelPosition = (initialPosition, labelSize) => clamp(initialPosition, 100 - labelSize / 2, labelSize / 2);
|
|
389
|
+
const progressDisplayOptions$ = computed(() => {
|
|
390
|
+
const vertical = vertical$(), sortedValuesPercent = sortedValuesPercent$(), rtl = rtl$();
|
|
391
|
+
if (sortedValuesPercent.length === 1) {
|
|
392
|
+
return [
|
|
393
|
+
{
|
|
394
|
+
left: vertical ? null : rtl ? null : 0,
|
|
395
|
+
right: vertical ? null : rtl ? 0 : null,
|
|
396
|
+
bottom: vertical ? rtl ? null : 0 : null,
|
|
397
|
+
top: vertical ? rtl ? 0 : null : null,
|
|
398
|
+
width: vertical ? 100 : sortedValuesPercent[0],
|
|
399
|
+
height: vertical ? sortedValuesPercent[0] : 100,
|
|
400
|
+
id: 0
|
|
401
|
+
}
|
|
402
|
+
];
|
|
403
|
+
} else {
|
|
404
|
+
return sortedValuesPercent.map((svp, index, array) => {
|
|
405
|
+
return {
|
|
406
|
+
left: vertical ? null : rtl ? null : svp,
|
|
407
|
+
right: vertical ? null : rtl ? array[index] : null,
|
|
408
|
+
bottom: vertical ? rtl ? null : svp : null,
|
|
409
|
+
top: vertical ? rtl ? array[index] : null : null,
|
|
410
|
+
width: vertical ? 100 : index === array.length - 1 ? svp : array[index + 1] - svp,
|
|
411
|
+
height: vertical ? index === array.length - 1 ? svp : array[index + 1] - svp : 100,
|
|
412
|
+
id: index
|
|
413
|
+
};
|
|
414
|
+
}).slice(0, sortedValuesPercent.length - 1);
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
const computeTicks$ = computed(() => {
|
|
418
|
+
if (!showTicks$()) {
|
|
419
|
+
return [];
|
|
420
|
+
}
|
|
421
|
+
const vertical = vertical$();
|
|
422
|
+
const min = min$();
|
|
423
|
+
const max = max$();
|
|
424
|
+
const rtl = rtl$();
|
|
425
|
+
const showTickValues = showTickValues$();
|
|
426
|
+
const tickInterval = tickInterval$() || stepSize$();
|
|
427
|
+
const tickArray = [];
|
|
428
|
+
const intStepSize = _intStepSize$();
|
|
429
|
+
const decimalPrecision = _decimalPrecision$();
|
|
430
|
+
const positionCompute = (position) => {
|
|
431
|
+
return !!rtl !== !!vertical ? 100 - position : position;
|
|
432
|
+
};
|
|
433
|
+
for (let step = min; step < max; step += tickInterval) {
|
|
434
|
+
const cleanValue = computeCleanValue(step, min, max, intStepSize, decimalPrecision);
|
|
435
|
+
const stepPercent = percentCompute(cleanValue);
|
|
436
|
+
tickArray.push({
|
|
437
|
+
position: positionCompute(stepPercent),
|
|
438
|
+
selected: false,
|
|
439
|
+
value: cleanValue,
|
|
440
|
+
displayLabel: showTickValues
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
tickArray.push({ position: positionCompute(100), selected: false, value: max, displayLabel: showTickValues });
|
|
444
|
+
return tickArray;
|
|
445
|
+
});
|
|
446
|
+
const ticks$ = computed(() => {
|
|
447
|
+
const sortedValues = sortedValues$();
|
|
448
|
+
const isTickSelected = (value) => {
|
|
449
|
+
const isMultiHandle = sortedValues.length > 1;
|
|
450
|
+
const currentMax = isMultiHandle ? sortedValues[sortedValues.length - 1] : sortedValues[0];
|
|
451
|
+
const currentMin = isMultiHandle ? sortedValues[0] : 0;
|
|
452
|
+
return value <= currentMax && value >= currentMin;
|
|
453
|
+
};
|
|
454
|
+
return computeTicks$().map((tick) => {
|
|
455
|
+
return {
|
|
456
|
+
...tick,
|
|
457
|
+
selected: isTickSelected(tick.value)
|
|
458
|
+
};
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
const percentCompute = (value) => {
|
|
462
|
+
const min = min$(), max = max$();
|
|
463
|
+
return (value - min) * 100 / (max - min);
|
|
464
|
+
};
|
|
465
|
+
const getClosestSliderHandle = (clickedPercent) => {
|
|
466
|
+
const values = values$();
|
|
467
|
+
if (values.length === 1) {
|
|
468
|
+
return 0;
|
|
469
|
+
}
|
|
470
|
+
const sortedValues = sortedValues$();
|
|
471
|
+
const closestBigger = sortedValues.find((sv) => percentCompute(sv) > clickedPercent * 100);
|
|
472
|
+
const closestBiggerIndex = closestBigger ? sortedValues.indexOf(closestBigger) : sortedValues.length - 1;
|
|
473
|
+
const midPoint = percentCompute(
|
|
474
|
+
sortedValues[closestBiggerIndex - 1] + (sortedValues[closestBiggerIndex] - sortedValues[closestBiggerIndex - 1]) / 2
|
|
475
|
+
);
|
|
476
|
+
const closestValue = sortedValues[clickedPercent * 100 <= midPoint ? closestBiggerIndex - 1 : closestBiggerIndex];
|
|
477
|
+
return values.indexOf(closestValue);
|
|
478
|
+
};
|
|
479
|
+
const getClickedPercent = (clickedCoordinate) => {
|
|
480
|
+
const sliderDomRectSize = sliderDomRectSize$(), sliderDomRectOffset = sliderDomRectOffset$();
|
|
481
|
+
let clickedPercent = vertical$() ? (sliderDomRectSize - clickedCoordinate + sliderDomRectOffset) / sliderDomRectSize : (clickedCoordinate - sliderDomRectOffset) / sliderDomRectSize;
|
|
482
|
+
clickedPercent = rtl$() ? 1 - clickedPercent : clickedPercent;
|
|
483
|
+
return clickedPercent;
|
|
484
|
+
};
|
|
485
|
+
const adjustCoordinate = (clickedCoordinate, handleNumber) => {
|
|
486
|
+
if (interactive$()) {
|
|
487
|
+
const clickedPercent = getClickedPercent(clickedCoordinate);
|
|
488
|
+
const derivedHandleIndex = handleNumber ?? getClosestSliderHandle(clickedPercent);
|
|
489
|
+
const newValue = clickedPercent * (max$() - min$()) + min$();
|
|
490
|
+
values$.update((dh) => {
|
|
491
|
+
dh = [...dh];
|
|
492
|
+
dh[derivedHandleIndex] = newValue;
|
|
493
|
+
return dh;
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
const horizontal$ = computed(() => !vertical$());
|
|
498
|
+
const containerDirective = createAttributesDirective(() => ({
|
|
499
|
+
classNames: {
|
|
500
|
+
"au-slider": true$,
|
|
501
|
+
"au-slider-vertical": vertical$,
|
|
502
|
+
"au-slider-horizontal": horizontal$
|
|
503
|
+
},
|
|
504
|
+
attributes: {
|
|
505
|
+
class: stateProps.className$
|
|
506
|
+
}
|
|
507
|
+
}));
|
|
508
|
+
const contentDirective = createAttributesDirective(() => ({
|
|
509
|
+
attributes: {
|
|
510
|
+
"aria-disabled": computed(() => disabled$() ? "true" : void 0),
|
|
511
|
+
class: stateProps.className$
|
|
512
|
+
},
|
|
513
|
+
classNames: {
|
|
514
|
+
"au-slider-content": true$,
|
|
515
|
+
"au-slider-vertical": vertical$,
|
|
516
|
+
"au-slider-horizontal": horizontal$,
|
|
517
|
+
"au-slider-with-labels": computed(
|
|
518
|
+
() => showValueLabels$() || showMinMaxLabels$() || showTickValues$() && showTicks$()
|
|
519
|
+
),
|
|
520
|
+
disabled: disabled$
|
|
521
|
+
}
|
|
522
|
+
}));
|
|
523
|
+
const minLabelDirective = createAttributesDirective(() => ({
|
|
524
|
+
classNames: {
|
|
525
|
+
"au-slider-label-vertical": vertical$,
|
|
526
|
+
"au-slider-label-vertical-min": vertical$,
|
|
527
|
+
"au-slider-label": horizontal$,
|
|
528
|
+
"au-slider-label-min": horizontal$,
|
|
529
|
+
"au-slider-rtl": rtl$,
|
|
530
|
+
invisible: computed(() => !minValueLabelDisplay$())
|
|
531
|
+
},
|
|
532
|
+
attributes: {
|
|
533
|
+
"aria-hidden": readable("true")
|
|
534
|
+
}
|
|
535
|
+
}));
|
|
536
|
+
const maxLabelDirective = createAttributesDirective(() => ({
|
|
537
|
+
classNames: {
|
|
538
|
+
"au-slider-label-vertical": vertical$,
|
|
539
|
+
"au-slider-label-vertical-max": vertical$,
|
|
540
|
+
"au-slider-label": horizontal$,
|
|
541
|
+
"au-slider-label-max": horizontal$,
|
|
542
|
+
"au-slider-rtl": rtl$,
|
|
543
|
+
invisible: computed(() => !maxValueLabelDisplay$())
|
|
544
|
+
},
|
|
545
|
+
attributes: {
|
|
546
|
+
"aria-hidden": readable("true")
|
|
547
|
+
}
|
|
548
|
+
}));
|
|
549
|
+
const handleElementDirective = browserDirective(
|
|
550
|
+
(handleItem, args) => {
|
|
551
|
+
const destroy = () => {
|
|
552
|
+
_handleElements.delete(args.item.id);
|
|
553
|
+
};
|
|
554
|
+
const update = (args2) => {
|
|
555
|
+
_handleElements.set(args2.item.id, handleItem);
|
|
556
|
+
};
|
|
557
|
+
update(args);
|
|
558
|
+
return {
|
|
559
|
+
update,
|
|
560
|
+
destroy
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
);
|
|
564
|
+
const pointerMoveStart = (event, handleId) => {
|
|
565
|
+
const currentTarget = handleId !== void 0 ? _handleElements.get(handleId) : event.target;
|
|
566
|
+
if (interactive$()) {
|
|
567
|
+
const vertical = vertical$();
|
|
568
|
+
const clientXorY = vertical ? "clientY" : "clientX";
|
|
569
|
+
let _prevCoordinate = event[clientXorY];
|
|
570
|
+
updateSliderSize$.set({});
|
|
571
|
+
currentTarget?.focus();
|
|
572
|
+
return {
|
|
573
|
+
onMove: (event2) => {
|
|
574
|
+
currentTarget?.focus();
|
|
575
|
+
const newCoord = event2[clientXorY];
|
|
576
|
+
if (_prevCoordinate !== newCoord) {
|
|
577
|
+
_prevCoordinate = newCoord;
|
|
578
|
+
adjustCoordinate(newCoord, handleId);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
return void 0;
|
|
584
|
+
};
|
|
585
|
+
const handleEventsDirective = mergeDirectives(
|
|
586
|
+
createAttributesDirective((handleContext$) => ({
|
|
587
|
+
events: {
|
|
588
|
+
keydown: (event) => {
|
|
589
|
+
const handleIndex = handleContext$().item.id;
|
|
590
|
+
const { key } = event;
|
|
591
|
+
const rtl = rtl$(), stepSize = stepSize$(), min = min$(), max = max$(), vertical = vertical$();
|
|
592
|
+
if (interactive$()) {
|
|
593
|
+
switch (key) {
|
|
594
|
+
case "ArrowDown":
|
|
595
|
+
updateValue(handleIndex, values$, stepSize, getUpdateDirection(vertical, rtl, true));
|
|
596
|
+
break;
|
|
597
|
+
case "ArrowLeft":
|
|
598
|
+
updateValue(handleIndex, values$, stepSize, getUpdateDirection(vertical, rtl, false));
|
|
599
|
+
break;
|
|
600
|
+
case "ArrowUp":
|
|
601
|
+
updateValue(handleIndex, values$, stepSize, -1 * getUpdateDirection(vertical, rtl, true));
|
|
602
|
+
break;
|
|
603
|
+
case "ArrowRight":
|
|
604
|
+
updateValue(handleIndex, values$, stepSize, -1 * getUpdateDirection(vertical, rtl, false));
|
|
605
|
+
break;
|
|
606
|
+
case "Home":
|
|
607
|
+
values$.update((value) => {
|
|
608
|
+
value = [...value];
|
|
609
|
+
value[handleIndex] = min;
|
|
610
|
+
return value;
|
|
611
|
+
});
|
|
612
|
+
break;
|
|
613
|
+
case "End":
|
|
614
|
+
values$.update((value) => {
|
|
615
|
+
value = [...value];
|
|
616
|
+
value[handleIndex] = max;
|
|
617
|
+
return value;
|
|
618
|
+
});
|
|
619
|
+
break;
|
|
620
|
+
case "PageUp":
|
|
621
|
+
break;
|
|
622
|
+
case "PageDown":
|
|
623
|
+
break;
|
|
624
|
+
default:
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
event.preventDefault();
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
})),
|
|
632
|
+
createPointerdownPositionDirective(
|
|
633
|
+
(position, { item: { id } }) => pointerMoveStart(position, id)
|
|
634
|
+
)
|
|
635
|
+
);
|
|
636
|
+
const widget = {
|
|
637
|
+
...stateStores({
|
|
638
|
+
min$,
|
|
639
|
+
max$,
|
|
640
|
+
stepSize$,
|
|
641
|
+
values$,
|
|
642
|
+
sortedValues$,
|
|
643
|
+
sortedHandles$,
|
|
644
|
+
minValueLabelDisplay$,
|
|
645
|
+
maxValueLabelDisplay$,
|
|
646
|
+
combinedLabelDisplay$,
|
|
647
|
+
interactive$,
|
|
648
|
+
combinedLabelPositionLeft$,
|
|
649
|
+
combinedLabelPositionTop$,
|
|
650
|
+
progressDisplayOptions$,
|
|
651
|
+
handleDisplayOptions$,
|
|
652
|
+
showValueLabels$: adjustedShowValueLabels$,
|
|
653
|
+
showMinMaxLabels$,
|
|
654
|
+
showTicks$,
|
|
655
|
+
rtl$,
|
|
656
|
+
ticks$,
|
|
657
|
+
...stateProps
|
|
658
|
+
}),
|
|
659
|
+
patch,
|
|
660
|
+
api: {},
|
|
661
|
+
directives: {
|
|
662
|
+
sliderDirective: mergeDirectives(sliderDirective, resizeDirective, contentDirective),
|
|
663
|
+
containerDirective,
|
|
664
|
+
progressDisplayDirective: createAttributesDirective(
|
|
665
|
+
(progressContext$) => ({
|
|
666
|
+
styles: {
|
|
667
|
+
left: computed(() => percent(progressContext$().option.left)),
|
|
668
|
+
right: computed(() => percent(progressContext$().option.right)),
|
|
669
|
+
top: computed(() => percent(progressContext$().option.top)),
|
|
670
|
+
bottom: computed(() => percent(progressContext$().option.bottom)),
|
|
671
|
+
width: computed(() => percent(progressContext$().option.width)),
|
|
672
|
+
height: computed(() => percent(progressContext$().option.height))
|
|
673
|
+
},
|
|
674
|
+
classNames: {
|
|
675
|
+
"au-slider-progress": true$
|
|
676
|
+
}
|
|
677
|
+
})
|
|
678
|
+
),
|
|
679
|
+
clickableAreaDirective: mergeDirectives(
|
|
680
|
+
createAttributesDirective(() => ({
|
|
681
|
+
classNames: {
|
|
682
|
+
"au-slider-clickable-area": horizontal$,
|
|
683
|
+
"au-slider-clickable-area-vertical": vertical$,
|
|
684
|
+
"au-slider-clickable-area-with-ticks": computed(() => showTicks$() && tickInterval$() === 0)
|
|
685
|
+
}
|
|
686
|
+
})),
|
|
687
|
+
createPointerdownPositionDirective((position) => {
|
|
688
|
+
const clickedCoordinate = vertical$() ? position.clientY : position.clientX;
|
|
689
|
+
const closestHandle = getClosestSliderHandle(getClickedPercent(clickedCoordinate));
|
|
690
|
+
adjustCoordinate(clickedCoordinate, closestHandle);
|
|
691
|
+
return pointerMoveStart(position, closestHandle);
|
|
692
|
+
})
|
|
693
|
+
),
|
|
694
|
+
handleEventsDirective,
|
|
695
|
+
handleDirective: mergeDirectives(
|
|
696
|
+
handleElementDirective,
|
|
697
|
+
handleEventsDirective,
|
|
698
|
+
createAttributesDirective((handleContext$) => ({
|
|
699
|
+
attributes: {
|
|
700
|
+
role: readable("slider"),
|
|
701
|
+
"aria-valuemin": min$,
|
|
702
|
+
"aria-valuemax": max$,
|
|
703
|
+
"aria-valuenow": computed(() => handleContext$().item.value),
|
|
704
|
+
"aria-valuetext": computed(() => handleContext$().item.ariaValueText),
|
|
705
|
+
"aria-label": computed(() => handleContext$().item.ariaLabel),
|
|
706
|
+
"aria-labelledBy": computed(() => handleContext$().item.ariaLabelledBy),
|
|
707
|
+
"aria-orientation": computed(() => vertical$() ? "vertical" : void 0),
|
|
708
|
+
"aria-disabled": computed(() => disabled$() ? "true" : void 0),
|
|
709
|
+
disabled: disabled$,
|
|
710
|
+
"aria-readonly": computed(() => readonly$() ? "true" : void 0)
|
|
711
|
+
},
|
|
712
|
+
styles: {
|
|
713
|
+
left: computed(() => percent(handleDisplayOptions$()[handleContext$().item.id].left)),
|
|
714
|
+
top: computed(() => percent(handleDisplayOptions$()[handleContext$().item.id].top))
|
|
715
|
+
},
|
|
716
|
+
classNames: {
|
|
717
|
+
"au-slider-handle": true$,
|
|
718
|
+
"au-slider-handle-vertical": vertical$,
|
|
719
|
+
"au-slider-handle-horizontal": horizontal$
|
|
720
|
+
}
|
|
721
|
+
}))
|
|
722
|
+
),
|
|
723
|
+
minLabelDirective: mergeDirectives(minLabelDomDirective, minLabelDirective),
|
|
724
|
+
maxLabelDirective: mergeDirectives(maxLabelDomDirective, maxLabelDirective),
|
|
725
|
+
combinedHandleLabelDisplayDirective: mergeDirectives(
|
|
726
|
+
resizeCombineLabelDirective,
|
|
727
|
+
createAttributesDirective(() => ({
|
|
728
|
+
classNames: {
|
|
729
|
+
"au-slider-label-vertical": vertical$,
|
|
730
|
+
"au-slider-label-vertical-now": vertical$,
|
|
731
|
+
"au-slider-label": horizontal$,
|
|
732
|
+
"au-slider-label-now": horizontal$
|
|
733
|
+
},
|
|
734
|
+
styles: {
|
|
735
|
+
left: computed(() => percent(combinedLabelPositionLeft$())),
|
|
736
|
+
top: computed(() => percent(combinedLabelPositionTop$()))
|
|
737
|
+
},
|
|
738
|
+
attributes: {
|
|
739
|
+
"aria-hidden": readable("true")
|
|
740
|
+
}
|
|
741
|
+
}))
|
|
742
|
+
),
|
|
743
|
+
handleLabelDisplayDirective: mergeDirectives(
|
|
744
|
+
handleLabelDirective,
|
|
745
|
+
resizeLabelsDirective,
|
|
746
|
+
createAttributesDirective((labelDisplayContext$) => ({
|
|
747
|
+
classNames: {
|
|
748
|
+
"au-slider-label-vertical": vertical$,
|
|
749
|
+
"au-slider-label-vertical-now": vertical$,
|
|
750
|
+
"au-slider-label": horizontal$,
|
|
751
|
+
"au-slider-label-now": horizontal$
|
|
752
|
+
},
|
|
753
|
+
styles: {
|
|
754
|
+
left: computed(() => {
|
|
755
|
+
const handleIndex = labelDisplayContext$().index;
|
|
756
|
+
const leftPosition = handleDisplayOptions$()[handleIndex].left;
|
|
757
|
+
return leftPosition === null ? "" : percent(labelPosition(leftPosition, currentLabelSizeByIndex(handleIndex)));
|
|
758
|
+
}),
|
|
759
|
+
top: computed(() => percent(handleDisplayOptions$()[labelDisplayContext$().index].top)),
|
|
760
|
+
opacity: computed(() => combinedLabelDisplay$() ? "0" : "1")
|
|
761
|
+
},
|
|
762
|
+
attributes: {
|
|
763
|
+
"aria-hidden": readable("true")
|
|
764
|
+
}
|
|
765
|
+
}))
|
|
766
|
+
),
|
|
767
|
+
tickDirective: createAttributesDirective((tickContext$) => ({
|
|
768
|
+
classNames: {
|
|
769
|
+
"au-slider-tick": true$,
|
|
770
|
+
"au-slider-tick-horizontal": horizontal$,
|
|
771
|
+
"au-slider-tick-vertical": vertical$
|
|
772
|
+
},
|
|
773
|
+
styles: {
|
|
774
|
+
left: computed(() => vertical$() ? null : percent(tickContext$().tick.position)),
|
|
775
|
+
top: computed(() => vertical$() ? percent(tickContext$().tick.position) : null)
|
|
776
|
+
},
|
|
777
|
+
events: {
|
|
778
|
+
click: (event) => {
|
|
779
|
+
adjustCoordinate(vertical$() ? event.clientY : event.clientX);
|
|
780
|
+
}
|
|
781
|
+
},
|
|
782
|
+
attributes: {
|
|
783
|
+
"aria-hidden": readable("true")
|
|
784
|
+
}
|
|
785
|
+
})),
|
|
786
|
+
tickLabelDirective: createAttributesDirective((tickContext$) => ({
|
|
787
|
+
classNames: {
|
|
788
|
+
"au-slider-tick-label": true$,
|
|
789
|
+
"au-slider-tick-label-vertical": vertical$,
|
|
790
|
+
"au-slider-tick-label-now": computed(() => sortedValues$().some((sv) => sv === tickContext$().tick.value))
|
|
791
|
+
},
|
|
792
|
+
styles: {
|
|
793
|
+
left: computed(() => vertical$() ? null : percent(tickContext$().tick.position)),
|
|
794
|
+
top: computed(() => vertical$() ? percent(tickContext$().tick.position) : null)
|
|
795
|
+
},
|
|
796
|
+
attributes: {
|
|
797
|
+
"aria-hidden": readable("true")
|
|
798
|
+
}
|
|
799
|
+
}))
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
return widget;
|
|
803
|
+
}
|
|
804
|
+
);
|
|
805
|
+
export {
|
|
806
|
+
createSlider as c,
|
|
807
|
+
getSliderDefaultConfig as g
|
|
808
|
+
};
|