@design-factory/core 21.1.0 → 22.0.0-next.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/{accordion-D9ba0XYq.js → accordion-DUFLBQkV.js} +90 -28
- package/alert-Db6cG6JE.js +125 -0
- package/{collapse-Bn8iHKrd.js → collapse-D8Jo56k9.js} +2 -2
- package/{common-DFyZvkII.js → common-CP4amR0Z.js} +2 -2
- package/components/accordion/accordion.d.ts +80 -22
- package/components/accordion/index.js +1 -1
- package/components/alert/alert.d.ts +77 -8
- package/components/alert/common.d.ts +9 -9
- package/components/alert/index.js +2 -3
- package/components/carousel/index.js +2 -2
- package/components/collapse/index.js +1 -1
- package/components/drawer/drawer.d.ts +13 -0
- package/components/drawer/index.js +1 -1
- package/components/dropdown/dropdown.d.ts +110 -0
- package/components/dropdown/index.d.ts +1 -0
- package/components/dropdown/index.js +5 -0
- package/components/modal/index.js +1 -1
- package/components/pagination/index.js +1 -1
- package/components/progressbar/index.js +1 -1
- package/components/rating/index.js +1 -1
- package/components/slider/index.js +1 -1
- package/components/slider/slider.d.ts +23 -4
- package/components/toast/index.js +1 -1
- package/components/tooltip/index.d.ts +1 -0
- package/components/tooltip/index.js +174 -0
- package/components/tooltip/tooltip.d.ts +63 -0
- package/components/tree/index.js +1 -1
- package/{directive-CNNSo5Yn.js → directive-CMT2vEDg.js} +7 -4
- package/{drawer-CoBXUPyv.js → drawer-D4xSbhcT.js} +19 -5
- package/dropdown-Bjj2ql6d.js +246 -0
- package/index.d.ts +3 -1
- package/index.js +45 -39
- package/isFocusable-C2iRr0zh.js +72 -0
- package/{modal-BH9nrwVz.js → modal-CQWh2Sm5.js} +3 -3
- package/package.json +1 -1
- package/{pagination-BQWusWXN.js → pagination-DIRcpdRE.js} +2 -2
- package/{progressbar-S1pNn5rM.js → progressbar-Bth8r3Qu.js} +2 -2
- package/{promise-D-RZVPuv.js → promise-CkIc0KKt.js} +3 -3
- package/{rating-DWgGgwk3.js → rating-DLsgFSyB.js} +2 -2
- package/services/extendWidget.d.ts +1 -1
- package/services/focusElement.js +2 -2
- package/services/focustrack.js +2 -2
- package/services/matchMedia.js +1 -1
- package/services/mousetrack.d.ts +34 -0
- package/services/mousetrack.js +41 -0
- package/services/navManager.js +2 -2
- package/services/pointerdownPosition.js +1 -1
- package/services/portal.js +1 -1
- package/services/positioning.d.ts +101 -0
- package/services/positioning.js +104 -0
- package/services/resizeObserver.js +1 -1
- package/services/siblingsInert.js +1 -1
- package/services/transitions/baseTransitions.js +8 -8
- package/services/transitions/collapse.d.ts +4 -0
- package/services/transitions/collapse.js +23 -19
- package/services/transitions/cssTransitions.js +2 -2
- package/services/transitions/simpleClassTransition.js +1 -1
- package/{slider-Br_Qiopx.js → slider-tH5g55yQ.js} +132 -97
- package/{toaster-BUBzFeJM.js → toaster-BS9qeRLF.js} +3 -3
- package/{tree-vD7ZkV8Z.js → tree-DW6iLxdw.js} +2 -2
- package/types.d.ts +8 -1
- package/utils/debounceSignal.d.ts +11 -0
- package/utils/debounceSignal.js +18 -0
- package/utils/directive.js +1 -1
- package/utils/edgeState.d.ts +23 -0
- package/utils/edgeState.js +43 -0
- package/utils/internal/isFocusable.d.ts +40 -0
- package/utils/stores.d.ts +2 -16
- package/utils/stores.js +5 -24
- package/utils/writables.d.ts +27 -13
- package/utils/writables.js +12 -11
- package/{writables-DYGjj5T3.js → writables-_7BriMb2.js} +37 -12
- package/accordion-B0vs8JWM.cjs +0 -314
- package/alert-AhaliJ17.cjs +0 -9
- package/alert-Cb9FhbFQ.js +0 -10
- package/collapse-BnWw4Hnc.cjs +0 -94
- package/common-B5jS-Ih_.cjs +0 -73
- package/components/accordion/index.cjs +0 -7
- package/components/alert/index.cjs +0 -5
- package/components/carousel/index.cjs +0 -292
- package/components/collapse/index.cjs +0 -5
- package/components/drawer/index.cjs +0 -5
- package/components/modal/index.cjs +0 -8
- package/components/pagination/index.cjs +0 -5
- package/components/progressbar/index.cjs +0 -5
- package/components/rating/index.cjs +0 -5
- package/components/slider/index.cjs +0 -5
- package/components/toast/index.cjs +0 -7
- package/components/tree/index.cjs +0 -5
- package/config.cjs +0 -36
- package/directive-DyTodNPd.cjs +0 -523
- package/drawer-Ca_ktkEs.cjs +0 -328
- package/index.cjs +0 -134
- package/isFocusable-Ckwus82R.js +0 -32
- package/isFocusable-DfzDLeAN.cjs +0 -31
- package/modal-Dxdw2Pkv.cjs +0 -252
- package/pagination-BLVa1UsZ.cjs +0 -254
- package/progressbar-RopgvVeA.cjs +0 -86
- package/promise-CxCD3NYv.cjs +0 -118
- package/rating-DZ3OQgtt.cjs +0 -183
- package/scrollbars-f651ntzz.cjs +0 -33
- package/services/extendWidget.cjs +0 -41
- package/services/floatingUI.cjs +0 -111
- package/services/floatingUI.d.ts +0 -76
- package/services/floatingUI.js +0 -111
- package/services/focusElement.cjs +0 -46
- package/services/focustrack.cjs +0 -47
- package/services/hash.cjs +0 -15
- package/services/intersection.cjs +0 -53
- package/services/matchMedia.cjs +0 -14
- package/services/navManager.cjs +0 -166
- package/services/pointerdownPosition.cjs +0 -60
- package/services/portal.cjs +0 -42
- package/services/resizeObserver.cjs +0 -54
- package/services/siblingsInert.cjs +0 -44
- package/services/transitions/baseTransitions.cjs +0 -186
- package/services/transitions/collapse.cjs +0 -40
- package/services/transitions/cssTransitions.cjs +0 -32
- package/services/transitions/simpleClassTransition.cjs +0 -37
- package/slider-pgDq1V5r.cjs +0 -807
- package/textDirection-zqcZ5-eK.cjs +0 -3
- package/toaster-Dlube4Ya.cjs +0 -161
- package/tree-Chcy4ulJ.cjs +0 -228
- package/types.cjs +0 -6
- package/utils/directive.cjs +0 -28
- package/utils/func.cjs +0 -7
- package/utils/id.cjs +0 -5
- package/utils/stores.cjs +0 -172
- package/utils/widget.cjs +0 -8
- package/utils/writables.cjs +0 -16
- package/writables-Dt68gADJ.cjs +0 -102
|
@@ -1,11 +1,12 @@
|
|
|
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-
|
|
1
|
+
import { computed, derived, writable, readable } from "@amadeus-it-group/tansu";
|
|
2
|
+
import { i as createBrowserStoreDirective, h as createBrowserStoreArrayDirective, s as mergeDirectives, g as createAttributesDirective, o as directiveSubscribe, d as browserDirective } from "./directive-CMT2vEDg.js";
|
|
3
3
|
import { noop } from "./utils/func.js";
|
|
4
4
|
import { writablesForProps, bindableProp, true$, stateStores } from "./utils/stores.js";
|
|
5
|
-
import {
|
|
5
|
+
import { i as typeNumberInRangeFactory, d as typeBoolean, k as typeString, b as typeArray, f as typeFunction, h as typeNumber, m as clamp } from "./writables-_7BriMb2.js";
|
|
6
6
|
import { createResizeObserver, createResizeObserverMap } from "./services/resizeObserver.js";
|
|
7
7
|
import { createPointerdownPositionDirective } from "./services/pointerdownPosition.js";
|
|
8
8
|
import { createWidgetFactory } from "./utils/widget.js";
|
|
9
|
+
import { g as getTextDirection } from "./textDirection-cNgt24LJ.js";
|
|
9
10
|
const decimalRegExp = /(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/;
|
|
10
11
|
function getDecimalPrecision(number) {
|
|
11
12
|
const matches = ("" + number).match(decimalRegExp);
|
|
@@ -90,7 +91,8 @@ const defaultSliderConfig = {
|
|
|
90
91
|
minRange: 0,
|
|
91
92
|
maxRange: 0,
|
|
92
93
|
pushRange: false,
|
|
93
|
-
|
|
94
|
+
flip: false,
|
|
95
|
+
rtl: void 0
|
|
94
96
|
};
|
|
95
97
|
function getSliderDefaultConfig() {
|
|
96
98
|
return { ...defaultSliderConfig };
|
|
@@ -112,6 +114,7 @@ const configValidator = {
|
|
|
112
114
|
showTicks: typeBoolean,
|
|
113
115
|
showTickValues: typeBoolean,
|
|
114
116
|
tickInterval: typeNumberInRangeFactory(0, Infinity, { strict: true }),
|
|
117
|
+
flip: typeBoolean,
|
|
115
118
|
rtl: typeBoolean,
|
|
116
119
|
className: typeString,
|
|
117
120
|
minRange: typeNumberInRangeFactory(0, Infinity),
|
|
@@ -128,13 +131,6 @@ const computeCleanValue = (value, min, max, intStepSize, decimalPrecision) => {
|
|
|
128
131
|
const indexMin = Math.floor((value - min) * magnitude / intStepSize);
|
|
129
132
|
return +(((value - min) * magnitude % intStepSize < intStepSize / 2 ? indexMin : indexMin + 1) * intStepSize / magnitude + min).toFixed(decimalPrecision);
|
|
130
133
|
};
|
|
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
134
|
const getUpdateDirection = (vertical, rtl, keysVertical) => {
|
|
139
135
|
if (vertical && rtl) {
|
|
140
136
|
return keysVertical ? 1 : -1;
|
|
@@ -160,6 +156,7 @@ const createSlider = createWidgetFactory(
|
|
|
160
156
|
maxRange$: _dirtyMaximumRange$,
|
|
161
157
|
pushRange$,
|
|
162
158
|
stepSize$,
|
|
159
|
+
flip$,
|
|
163
160
|
rtl$,
|
|
164
161
|
values$: _dirtyValues$,
|
|
165
162
|
ariaLabel$,
|
|
@@ -211,7 +208,6 @@ const createSlider = createWidgetFactory(
|
|
|
211
208
|
() => Math.max(getDecimalPrecision(stepSize$()), getDecimalPrecision(min$()), getDecimalPrecision(max$()))
|
|
212
209
|
);
|
|
213
210
|
const _intStepSize$ = computed(() => stepSize$() * Math.pow(10, _decimalPrecision$()));
|
|
214
|
-
let previousValues = _dirtyValues$();
|
|
215
211
|
const values$ = bindableProp(
|
|
216
212
|
_dirtyValues$,
|
|
217
213
|
onValuesChange$,
|
|
@@ -220,23 +216,28 @@ const createSlider = createWidgetFactory(
|
|
|
220
216
|
const max = max$();
|
|
221
217
|
const intStepSize = _intStepSize$();
|
|
222
218
|
const decimalPrecision = _decimalPrecision$();
|
|
223
|
-
|
|
224
|
-
|
|
219
|
+
return dirtyValues.map((dv) => computeCleanValue(dv, min, max, intStepSize, decimalPrecision));
|
|
220
|
+
},
|
|
221
|
+
typeArray.equal
|
|
222
|
+
);
|
|
223
|
+
const updateValueAtIndex = (index, newValue) => {
|
|
224
|
+
values$.update((vals) => {
|
|
225
|
+
const min = min$();
|
|
226
|
+
const max = max$();
|
|
227
|
+
const intStepSize = _intStepSize$();
|
|
228
|
+
const decimalPrecision = _decimalPrecision$();
|
|
229
|
+
const newVals = [...vals];
|
|
230
|
+
newVals[index] = computeCleanValue(newValue, min, max, intStepSize, decimalPrecision);
|
|
231
|
+
if (newVals.length > 1) {
|
|
225
232
|
const minRange = minRange$();
|
|
226
233
|
const maxRange = maxRange$();
|
|
227
234
|
if (minRange || maxRange) {
|
|
228
|
-
|
|
229
|
-
const changedIndex = newValues.findIndex((dv, index) => dv !== previousValues[index]);
|
|
230
|
-
if (changedIndex !== -1) {
|
|
231
|
-
manageMinMaxRange(newValues, changedIndex, minRange, maxRange, min, max, pushRange);
|
|
232
|
-
}
|
|
235
|
+
manageMinMaxRange(newVals, index, minRange, maxRange, min, max, pushRange$());
|
|
233
236
|
}
|
|
234
237
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
typeArray.equal
|
|
239
|
-
);
|
|
238
|
+
return newVals;
|
|
239
|
+
});
|
|
240
|
+
};
|
|
240
241
|
const { directive: sliderDirective, element$: sliderDom$ } = createBrowserStoreDirective();
|
|
241
242
|
const { directive: minLabelDomDirective, element$: minLabelDom$ } = createBrowserStoreDirective();
|
|
242
243
|
const { directive: maxLabelDomDirective, element$: maxLabelDom$ } = createBrowserStoreDirective();
|
|
@@ -244,6 +245,31 @@ const createSlider = createWidgetFactory(
|
|
|
244
245
|
const { directive: resizeDirective, dimensions$ } = createResizeObserver();
|
|
245
246
|
const { directive: resizeLabelsDirective, dimensionsMap$: handleDimensions$ } = createResizeObserverMap();
|
|
246
247
|
const { directive: resizeCombineLabelDirective, dimensions$: combinedDimensions$ } = createResizeObserver();
|
|
248
|
+
const autoDetectedRtl$ = derived(
|
|
249
|
+
sliderDom$,
|
|
250
|
+
(el, set) => {
|
|
251
|
+
if (!el) {
|
|
252
|
+
set(false);
|
|
253
|
+
return noop;
|
|
254
|
+
}
|
|
255
|
+
set(getTextDirection(el) === "rtl");
|
|
256
|
+
const observer = new MutationObserver(() => {
|
|
257
|
+
set(getTextDirection(el) === "rtl");
|
|
258
|
+
});
|
|
259
|
+
let current = el;
|
|
260
|
+
while (current) {
|
|
261
|
+
observer.observe(current, { attributes: true, attributeFilter: ["dir"] });
|
|
262
|
+
current = current.parentElement;
|
|
263
|
+
}
|
|
264
|
+
return () => observer.disconnect();
|
|
265
|
+
},
|
|
266
|
+
false
|
|
267
|
+
);
|
|
268
|
+
const resolvedRtl$ = computed(() => {
|
|
269
|
+
const explicit = rtl$();
|
|
270
|
+
return explicit !== void 0 ? explicit : autoDetectedRtl$();
|
|
271
|
+
});
|
|
272
|
+
const effectiveRtl$ = computed(() => resolvedRtl$() !== flip$());
|
|
247
273
|
const updateSliderSize$ = writable({});
|
|
248
274
|
const sliderDomRect$ = computed(
|
|
249
275
|
() => {
|
|
@@ -315,7 +341,7 @@ const createSlider = createWidgetFactory(
|
|
|
315
341
|
}
|
|
316
342
|
const minLabelSize = minLabelSize$();
|
|
317
343
|
const vertical = vertical$();
|
|
318
|
-
const rtl =
|
|
344
|
+
const rtl = effectiveRtl$();
|
|
319
345
|
if (combinedLabelDisplay$()) {
|
|
320
346
|
const combinedLabelSize = combinedLabelSize$();
|
|
321
347
|
const combinedLabelPosition = combinedLabelPosition$();
|
|
@@ -332,7 +358,7 @@ const createSlider = createWidgetFactory(
|
|
|
332
358
|
}
|
|
333
359
|
const maxLabelSize = maxLabelSize$();
|
|
334
360
|
const vertical = vertical$();
|
|
335
|
-
const rtl =
|
|
361
|
+
const rtl = effectiveRtl$();
|
|
336
362
|
if (combinedLabelDisplay$()) {
|
|
337
363
|
const combinedLabelSize = combinedLabelSize$();
|
|
338
364
|
const combinedLabelPosition = combinedLabelPosition$();
|
|
@@ -369,15 +395,15 @@ const createSlider = createWidgetFactory(
|
|
|
369
395
|
const combinedLabelSize = combinedLabelSize$();
|
|
370
396
|
let combinedPosition = (sortedValuesPercent[0] + sortedValuesPercent[1]) / 2;
|
|
371
397
|
combinedPosition = labelPosition(combinedPosition, combinedLabelSize);
|
|
372
|
-
return vertical$() || sortedValuesPercent.length != 2 ? 0 :
|
|
398
|
+
return vertical$() || sortedValuesPercent.length != 2 ? 0 : effectiveRtl$() ? 100 - combinedPosition : combinedPosition;
|
|
373
399
|
});
|
|
374
400
|
const combinedLabelPositionTop$ = computed(() => {
|
|
375
401
|
const sortedValuesPercent = sortedValuesPercent$();
|
|
376
402
|
const combinedPosition = 100 - (sortedValuesPercent[0] + sortedValuesPercent[1]) / 2;
|
|
377
|
-
return vertical$() && sortedValuesPercent.length == 2 ?
|
|
403
|
+
return vertical$() && sortedValuesPercent.length == 2 ? effectiveRtl$() ? 100 - combinedPosition : combinedPosition : 0;
|
|
378
404
|
});
|
|
379
405
|
const handleDisplayOptions$ = computed(() => {
|
|
380
|
-
const vertical = vertical$(), rtl =
|
|
406
|
+
const vertical = vertical$(), rtl = effectiveRtl$();
|
|
381
407
|
return valuesPercent$().map((vp) => {
|
|
382
408
|
return {
|
|
383
409
|
left: rtl ? vertical ? null : 100 - vp : vertical ? null : vp,
|
|
@@ -387,7 +413,7 @@ const createSlider = createWidgetFactory(
|
|
|
387
413
|
});
|
|
388
414
|
const labelPosition = (initialPosition, labelSize) => clamp(initialPosition, 100 - labelSize / 2, labelSize / 2);
|
|
389
415
|
const progressDisplayOptions$ = computed(() => {
|
|
390
|
-
const vertical = vertical$(), sortedValuesPercent = sortedValuesPercent$(), rtl =
|
|
416
|
+
const vertical = vertical$(), sortedValuesPercent = sortedValuesPercent$(), rtl = effectiveRtl$();
|
|
391
417
|
if (sortedValuesPercent.length === 1) {
|
|
392
418
|
return [
|
|
393
419
|
{
|
|
@@ -421,7 +447,7 @@ const createSlider = createWidgetFactory(
|
|
|
421
447
|
const vertical = vertical$();
|
|
422
448
|
const min = min$();
|
|
423
449
|
const max = max$();
|
|
424
|
-
const rtl =
|
|
450
|
+
const rtl = effectiveRtl$();
|
|
425
451
|
const showTickValues = showTickValues$();
|
|
426
452
|
const tickInterval = tickInterval$() || stepSize$();
|
|
427
453
|
const tickArray = [];
|
|
@@ -479,7 +505,7 @@ const createSlider = createWidgetFactory(
|
|
|
479
505
|
const getClickedPercent = (clickedCoordinate) => {
|
|
480
506
|
const sliderDomRectSize = sliderDomRectSize$(), sliderDomRectOffset = sliderDomRectOffset$();
|
|
481
507
|
let clickedPercent = vertical$() ? (sliderDomRectSize - clickedCoordinate + sliderDomRectOffset) / sliderDomRectSize : (clickedCoordinate - sliderDomRectOffset) / sliderDomRectSize;
|
|
482
|
-
clickedPercent =
|
|
508
|
+
clickedPercent = effectiveRtl$() ? 1 - clickedPercent : clickedPercent;
|
|
483
509
|
return clickedPercent;
|
|
484
510
|
};
|
|
485
511
|
const adjustCoordinate = (clickedCoordinate, handleNumber) => {
|
|
@@ -487,19 +513,15 @@ const createSlider = createWidgetFactory(
|
|
|
487
513
|
const clickedPercent = getClickedPercent(clickedCoordinate);
|
|
488
514
|
const derivedHandleIndex = handleNumber ?? getClosestSliderHandle(clickedPercent);
|
|
489
515
|
const newValue = clickedPercent * (max$() - min$()) + min$();
|
|
490
|
-
|
|
491
|
-
dh = [...dh];
|
|
492
|
-
dh[derivedHandleIndex] = newValue;
|
|
493
|
-
return dh;
|
|
494
|
-
});
|
|
516
|
+
updateValueAtIndex(derivedHandleIndex, newValue);
|
|
495
517
|
}
|
|
496
518
|
};
|
|
497
519
|
const horizontal$ = computed(() => !vertical$());
|
|
498
520
|
const containerDirective = createAttributesDirective(() => ({
|
|
499
521
|
classNames: {
|
|
500
|
-
"
|
|
501
|
-
"
|
|
502
|
-
"
|
|
522
|
+
"df-slider": true$,
|
|
523
|
+
"df-slider-vertical": vertical$,
|
|
524
|
+
"df-slider-horizontal": horizontal$
|
|
503
525
|
},
|
|
504
526
|
attributes: {
|
|
505
527
|
class: stateProps.className$
|
|
@@ -511,23 +533,23 @@ const createSlider = createWidgetFactory(
|
|
|
511
533
|
class: stateProps.className$
|
|
512
534
|
},
|
|
513
535
|
classNames: {
|
|
514
|
-
"
|
|
515
|
-
"
|
|
516
|
-
"
|
|
517
|
-
"
|
|
536
|
+
"df-slider-content": true$,
|
|
537
|
+
"df-slider-vertical": vertical$,
|
|
538
|
+
"df-slider-horizontal": horizontal$,
|
|
539
|
+
"df-slider-with-labels": computed(
|
|
518
540
|
() => showValueLabels$() || showMinMaxLabels$() || showTickValues$() && showTicks$()
|
|
519
541
|
),
|
|
520
|
-
disabled: disabled$
|
|
542
|
+
"df-slider-disabled": disabled$
|
|
521
543
|
}
|
|
522
544
|
}));
|
|
523
545
|
const minLabelDirective = createAttributesDirective(() => ({
|
|
524
546
|
classNames: {
|
|
525
|
-
"
|
|
526
|
-
"
|
|
527
|
-
"
|
|
528
|
-
"
|
|
529
|
-
"
|
|
530
|
-
invisible: computed(() => !minValueLabelDisplay$())
|
|
547
|
+
"df-slider-label-vertical": vertical$,
|
|
548
|
+
"df-slider-label-vertical-min": vertical$,
|
|
549
|
+
"df-slider-label": horizontal$,
|
|
550
|
+
"df-slider-label-min": horizontal$,
|
|
551
|
+
"df-slider-rtl": effectiveRtl$,
|
|
552
|
+
"df-slider-invisible": computed(() => !minValueLabelDisplay$())
|
|
531
553
|
},
|
|
532
554
|
attributes: {
|
|
533
555
|
"aria-hidden": readable("true")
|
|
@@ -535,12 +557,12 @@ const createSlider = createWidgetFactory(
|
|
|
535
557
|
}));
|
|
536
558
|
const maxLabelDirective = createAttributesDirective(() => ({
|
|
537
559
|
classNames: {
|
|
538
|
-
"
|
|
539
|
-
"
|
|
540
|
-
"
|
|
541
|
-
"
|
|
542
|
-
"
|
|
543
|
-
invisible: computed(() => !maxValueLabelDisplay$())
|
|
560
|
+
"df-slider-label-vertical": vertical$,
|
|
561
|
+
"df-slider-label-vertical-max": vertical$,
|
|
562
|
+
"df-slider-label": horizontal$,
|
|
563
|
+
"df-slider-label-max": horizontal$,
|
|
564
|
+
"df-slider-rtl": effectiveRtl$,
|
|
565
|
+
"df-slider-invisible": computed(() => !maxValueLabelDisplay$())
|
|
544
566
|
},
|
|
545
567
|
attributes: {
|
|
546
568
|
"aria-hidden": readable("true")
|
|
@@ -588,34 +610,38 @@ const createSlider = createWidgetFactory(
|
|
|
588
610
|
keydown: (event) => {
|
|
589
611
|
const handleIndex = handleContext$().item.id;
|
|
590
612
|
const { key } = event;
|
|
591
|
-
const rtl =
|
|
613
|
+
const rtl = effectiveRtl$(), stepSize = stepSize$(), min = min$(), max = max$(), vertical = vertical$();
|
|
592
614
|
if (interactive$()) {
|
|
593
615
|
switch (key) {
|
|
594
616
|
case "ArrowDown":
|
|
595
|
-
|
|
617
|
+
updateValueAtIndex(
|
|
618
|
+
handleIndex,
|
|
619
|
+
values$()[handleIndex] + stepSize * getUpdateDirection(vertical, rtl, true)
|
|
620
|
+
);
|
|
596
621
|
break;
|
|
597
622
|
case "ArrowLeft":
|
|
598
|
-
|
|
623
|
+
updateValueAtIndex(
|
|
624
|
+
handleIndex,
|
|
625
|
+
values$()[handleIndex] + stepSize * getUpdateDirection(vertical, rtl, false)
|
|
626
|
+
);
|
|
599
627
|
break;
|
|
600
628
|
case "ArrowUp":
|
|
601
|
-
|
|
629
|
+
updateValueAtIndex(
|
|
630
|
+
handleIndex,
|
|
631
|
+
values$()[handleIndex] + stepSize * -1 * getUpdateDirection(vertical, rtl, true)
|
|
632
|
+
);
|
|
602
633
|
break;
|
|
603
634
|
case "ArrowRight":
|
|
604
|
-
|
|
635
|
+
updateValueAtIndex(
|
|
636
|
+
handleIndex,
|
|
637
|
+
values$()[handleIndex] + stepSize * -1 * getUpdateDirection(vertical, rtl, false)
|
|
638
|
+
);
|
|
605
639
|
break;
|
|
606
640
|
case "Home":
|
|
607
|
-
|
|
608
|
-
value = [...value];
|
|
609
|
-
value[handleIndex] = min;
|
|
610
|
-
return value;
|
|
611
|
-
});
|
|
641
|
+
updateValueAtIndex(handleIndex, min);
|
|
612
642
|
break;
|
|
613
643
|
case "End":
|
|
614
|
-
|
|
615
|
-
value = [...value];
|
|
616
|
-
value[handleIndex] = max;
|
|
617
|
-
return value;
|
|
618
|
-
});
|
|
644
|
+
updateValueAtIndex(handleIndex, max);
|
|
619
645
|
break;
|
|
620
646
|
case "PageUp":
|
|
621
647
|
break;
|
|
@@ -652,14 +678,23 @@ const createSlider = createWidgetFactory(
|
|
|
652
678
|
showValueLabels$: adjustedShowValueLabels$,
|
|
653
679
|
showMinMaxLabels$,
|
|
654
680
|
showTicks$,
|
|
655
|
-
|
|
681
|
+
flip$,
|
|
682
|
+
rtl$: resolvedRtl$,
|
|
656
683
|
ticks$,
|
|
657
684
|
...stateProps
|
|
658
685
|
}),
|
|
659
686
|
patch,
|
|
660
687
|
api: {},
|
|
661
688
|
directives: {
|
|
662
|
-
|
|
689
|
+
// Eagerly subscribe to dimensions$ so the slider-content ResizeObserver is active before the
|
|
690
|
+
// value-label ResizeObserver callback runs. This prevents the "ResizeObserver loop completed
|
|
691
|
+
// with undelivered notifications" error caused by label layout changes triggered mid-callback.
|
|
692
|
+
sliderDirective: mergeDirectives(
|
|
693
|
+
sliderDirective,
|
|
694
|
+
resizeDirective,
|
|
695
|
+
directiveSubscribe(dimensions$),
|
|
696
|
+
contentDirective
|
|
697
|
+
),
|
|
663
698
|
containerDirective,
|
|
664
699
|
progressDisplayDirective: createAttributesDirective(
|
|
665
700
|
(progressContext$) => ({
|
|
@@ -672,16 +707,16 @@ const createSlider = createWidgetFactory(
|
|
|
672
707
|
height: computed(() => percent(progressContext$().option.height))
|
|
673
708
|
},
|
|
674
709
|
classNames: {
|
|
675
|
-
"
|
|
710
|
+
"df-slider-progress": true$
|
|
676
711
|
}
|
|
677
712
|
})
|
|
678
713
|
),
|
|
679
714
|
clickableAreaDirective: mergeDirectives(
|
|
680
715
|
createAttributesDirective(() => ({
|
|
681
716
|
classNames: {
|
|
682
|
-
"
|
|
683
|
-
"
|
|
684
|
-
"
|
|
717
|
+
"df-slider-clickable-area": horizontal$,
|
|
718
|
+
"df-slider-clickable-area-vertical": vertical$,
|
|
719
|
+
"df-slider-clickable-area-with-ticks": computed(() => showTicks$() && tickInterval$() === 0)
|
|
685
720
|
}
|
|
686
721
|
})),
|
|
687
722
|
createPointerdownPositionDirective((position) => {
|
|
@@ -714,9 +749,9 @@ const createSlider = createWidgetFactory(
|
|
|
714
749
|
top: computed(() => percent(handleDisplayOptions$()[handleContext$().item.id].top))
|
|
715
750
|
},
|
|
716
751
|
classNames: {
|
|
717
|
-
"
|
|
718
|
-
"
|
|
719
|
-
"
|
|
752
|
+
"df-slider-handle": true$,
|
|
753
|
+
"df-slider-handle-vertical": vertical$,
|
|
754
|
+
"df-slider-handle-horizontal": horizontal$
|
|
720
755
|
}
|
|
721
756
|
}))
|
|
722
757
|
),
|
|
@@ -726,14 +761,14 @@ const createSlider = createWidgetFactory(
|
|
|
726
761
|
resizeCombineLabelDirective,
|
|
727
762
|
createAttributesDirective(() => ({
|
|
728
763
|
classNames: {
|
|
729
|
-
"
|
|
730
|
-
"
|
|
731
|
-
"
|
|
732
|
-
"
|
|
764
|
+
"df-slider-label-vertical": vertical$,
|
|
765
|
+
"df-slider-label-vertical-now": vertical$,
|
|
766
|
+
"df-slider-label": horizontal$,
|
|
767
|
+
"df-slider-label-now": horizontal$
|
|
733
768
|
},
|
|
734
769
|
styles: {
|
|
735
|
-
left: computed(() => percent(combinedLabelPositionLeft$())),
|
|
736
|
-
top: computed(() => percent(combinedLabelPositionTop$()))
|
|
770
|
+
left: computed(() => vertical$() ? "" : percent(combinedLabelPositionLeft$())),
|
|
771
|
+
top: computed(() => vertical$() ? percent(combinedLabelPositionTop$()) : "")
|
|
737
772
|
},
|
|
738
773
|
attributes: {
|
|
739
774
|
"aria-hidden": readable("true")
|
|
@@ -745,10 +780,10 @@ const createSlider = createWidgetFactory(
|
|
|
745
780
|
resizeLabelsDirective,
|
|
746
781
|
createAttributesDirective((labelDisplayContext$) => ({
|
|
747
782
|
classNames: {
|
|
748
|
-
"
|
|
749
|
-
"
|
|
750
|
-
"
|
|
751
|
-
"
|
|
783
|
+
"df-slider-label-vertical": vertical$,
|
|
784
|
+
"df-slider-label-vertical-now": vertical$,
|
|
785
|
+
"df-slider-label": horizontal$,
|
|
786
|
+
"df-slider-label-now": horizontal$
|
|
752
787
|
},
|
|
753
788
|
styles: {
|
|
754
789
|
left: computed(() => {
|
|
@@ -766,9 +801,9 @@ const createSlider = createWidgetFactory(
|
|
|
766
801
|
),
|
|
767
802
|
tickDirective: createAttributesDirective((tickContext$) => ({
|
|
768
803
|
classNames: {
|
|
769
|
-
"
|
|
770
|
-
"
|
|
771
|
-
"
|
|
804
|
+
"df-slider-tick": true$,
|
|
805
|
+
"df-slider-tick-horizontal": horizontal$,
|
|
806
|
+
"df-slider-tick-vertical": vertical$
|
|
772
807
|
},
|
|
773
808
|
styles: {
|
|
774
809
|
left: computed(() => vertical$() ? null : percent(tickContext$().tick.position)),
|
|
@@ -785,9 +820,9 @@ const createSlider = createWidgetFactory(
|
|
|
785
820
|
})),
|
|
786
821
|
tickLabelDirective: createAttributesDirective((tickContext$) => ({
|
|
787
822
|
classNames: {
|
|
788
|
-
"
|
|
789
|
-
"
|
|
790
|
-
"
|
|
823
|
+
"df-slider-tick-label": true$,
|
|
824
|
+
"df-slider-tick-label-vertical": vertical$,
|
|
825
|
+
"df-slider-tick-label-now": computed(() => sortedValues$().some((sv) => sv === tickContext$().tick.value))
|
|
791
826
|
},
|
|
792
827
|
styles: {
|
|
793
828
|
left: computed(() => vertical$() ? null : percent(tickContext$().tick.position)),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { computed, readable, writable } from "@amadeus-it-group/tansu";
|
|
2
2
|
import { extendWidgetProps } from "./services/extendWidget.js";
|
|
3
|
-
import { o as directiveSubscribe, g as createAttributesDirective } from "./directive-
|
|
3
|
+
import { o as directiveSubscribe, g as createAttributesDirective } from "./directive-CMT2vEDg.js";
|
|
4
4
|
import { true$ } from "./utils/stores.js";
|
|
5
|
-
import {
|
|
6
|
-
import { g as getCommonAlertDefaultConfig, c as createCommonAlert } from "./common-
|
|
5
|
+
import { i as typeNumberInRangeFactory, d as typeBoolean } from "./writables-_7BriMb2.js";
|
|
6
|
+
import { g as getCommonAlertDefaultConfig, c as createCommonAlert } from "./common-CP4amR0Z.js";
|
|
7
7
|
import { createWidgetFactory } from "./utils/widget.js";
|
|
8
8
|
const toastDefaultConfig = {
|
|
9
9
|
autoHide: true,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { writable, computed, readable } from "@amadeus-it-group/tansu";
|
|
2
2
|
import { createNavManager } from "./services/navManager.js";
|
|
3
|
-
import { s as mergeDirectives, d as browserDirective, g as createAttributesDirective, b as bindDirective } from "./directive-
|
|
3
|
+
import { s as mergeDirectives, d as browserDirective, g as createAttributesDirective, b as bindDirective } from "./directive-CMT2vEDg.js";
|
|
4
4
|
import { noop } from "./utils/func.js";
|
|
5
5
|
import { writablesForProps, stateStores, true$ } from "./utils/stores.js";
|
|
6
|
-
import {
|
|
6
|
+
import { f as typeFunction, b as typeArray, k as typeString } from "./writables-_7BriMb2.js";
|
|
7
7
|
import { createWidgetFactory } from "./utils/widget.js";
|
|
8
8
|
function getTreeDefaultConfig() {
|
|
9
9
|
return {
|
package/types.d.ts
CHANGED
|
@@ -173,7 +173,14 @@ export declare const INVALID_VALUE: unique symbol;
|
|
|
173
173
|
* @param value - The value to be normalized.
|
|
174
174
|
* @returns The normalized value of type `T` or `INVALID_VALUE` if the value is invalid.
|
|
175
175
|
*/
|
|
176
|
-
export type NormalizeValue<T> = (value:
|
|
176
|
+
export type NormalizeValue<T> = (value: unknown) => T | typeof INVALID_VALUE;
|
|
177
|
+
/**
|
|
178
|
+
* Makes the specified keys of a type required while keeping the rest unchanged.
|
|
179
|
+
*
|
|
180
|
+
* @template T - The original type.
|
|
181
|
+
* @template K - The keys to make required.
|
|
182
|
+
*/
|
|
183
|
+
export type PickRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
177
184
|
/**
|
|
178
185
|
* Interface representing options for a writable store with default values.
|
|
179
186
|
*
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReadableSignal } from '@amadeus-it-group/tansu';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a debounced readable signal from a source signal.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of the signal value
|
|
6
|
+
* @param source$ - The source readable signal to debounce
|
|
7
|
+
* @param delay - The debounce delay in milliseconds, or a function that returns the delay based on the value. If the delay is negative, the value is emitted immediately without debouncing.
|
|
8
|
+
* @param initialValue - The initial value of the debounced signal (defaults to the source signal's current value)
|
|
9
|
+
* @returns A readable signal that emits values from the source signal after the specified delay
|
|
10
|
+
*/
|
|
11
|
+
export declare const debounceSignal: <T>(source$: ReadableSignal<T>, delay: number | ((value: T) => number), initialValue?: T) => ReadableSignal<T>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { derived } from "@amadeus-it-group/tansu";
|
|
2
|
+
const debounceSignal = (source$, delay, initialValue = source$()) => derived(
|
|
3
|
+
source$,
|
|
4
|
+
(value, set) => {
|
|
5
|
+
const delayValue = typeof delay === "function" ? delay(value) : delay;
|
|
6
|
+
if (delayValue >= 0) {
|
|
7
|
+
const timeout = setTimeout(() => set(value), delayValue);
|
|
8
|
+
return () => clearTimeout(timeout);
|
|
9
|
+
} else {
|
|
10
|
+
set(value);
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
initialValue
|
|
15
|
+
);
|
|
16
|
+
export {
|
|
17
|
+
debounceSignal
|
|
18
|
+
};
|
package/utils/directive.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@amadeus-it-group/tansu";
|
|
2
2
|
import "esm-env";
|
|
3
|
-
import { a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v } from "../directive-
|
|
3
|
+
import { a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v } from "../directive-CMT2vEDg.js";
|
|
4
4
|
import "./func.js";
|
|
5
5
|
export {
|
|
6
6
|
a as attributesData,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReadableSignal, WritableSignal } from '@amadeus-it-group/tansu';
|
|
2
|
+
export interface EdgeState<Source extends string = string> extends WritableSignal<boolean> {
|
|
3
|
+
/**
|
|
4
|
+
* Skips the next update from a source when it matches the provided value.
|
|
5
|
+
*
|
|
6
|
+
* @param source - The source signal to skip the next matching update from.
|
|
7
|
+
* @param value - The value to skip.
|
|
8
|
+
*/
|
|
9
|
+
skipNextSourceValue: (source: Source, value: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates an edge-triggered boolean state from multiple input signals.
|
|
13
|
+
*
|
|
14
|
+
* Unlike a simple `computed(() => a() || b())`, this tracks which input signal
|
|
15
|
+
* last changed and adopts its value. This enables a "dismissed" state: an imperative
|
|
16
|
+
* `set(false)` hides the output even while some inputs remain `true`, and the next
|
|
17
|
+
* edge (any input changing) overrides the imperative value.
|
|
18
|
+
*
|
|
19
|
+
* @param sources - Boolean signals to track. The output follows whichever one last changed.
|
|
20
|
+
* @param guard - Optional signal that forces the output to `false` while truthy (e.g. `disabled$`).
|
|
21
|
+
* @return A writable signal that can be set imperatively, but also updates on edges of the input signals.
|
|
22
|
+
*/
|
|
23
|
+
export declare const createEdgeState: <const Sources extends Record<string, ReadableSignal<boolean>>>(sources: Sources, guard?: ReadableSignal<boolean>) => EdgeState<keyof Sources & string>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { writable, computed, asWritable } from "@amadeus-it-group/tansu";
|
|
2
|
+
const createEdgeState = (sources, guard) => {
|
|
3
|
+
const sourceList = Object.entries(sources).map(([name, signal]) => ({
|
|
4
|
+
name,
|
|
5
|
+
signal,
|
|
6
|
+
current: false,
|
|
7
|
+
previous: false
|
|
8
|
+
}));
|
|
9
|
+
const sourceByName = new Map(sourceList.map((source) => [source.name, source]));
|
|
10
|
+
let prevTrigger = { value: false };
|
|
11
|
+
const trigger$ = writable(prevTrigger);
|
|
12
|
+
let state = false;
|
|
13
|
+
const state$ = computed(() => {
|
|
14
|
+
for (const source of sourceList) {
|
|
15
|
+
source.current = source.signal();
|
|
16
|
+
}
|
|
17
|
+
const t = trigger$();
|
|
18
|
+
if (guard?.()) {
|
|
19
|
+
state = false;
|
|
20
|
+
} else {
|
|
21
|
+
const changed = sourceList.find((source) => source.current !== source.previous);
|
|
22
|
+
if (changed !== void 0) {
|
|
23
|
+
state = changed.current;
|
|
24
|
+
} else if (t !== prevTrigger) {
|
|
25
|
+
state = t.value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (const source of sourceList) {
|
|
29
|
+
source.previous = source.current;
|
|
30
|
+
}
|
|
31
|
+
prevTrigger = t;
|
|
32
|
+
return state;
|
|
33
|
+
});
|
|
34
|
+
return asWritable(state$, {
|
|
35
|
+
set: (v) => trigger$.set({ value: v }),
|
|
36
|
+
skipNextSourceValue: (source, value) => {
|
|
37
|
+
sourceByName.get(source).previous = value;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
createEdgeState
|
|
43
|
+
};
|
|
@@ -7,3 +7,43 @@
|
|
|
7
7
|
* @returns true if the element is programmatically focusable.
|
|
8
8
|
*/
|
|
9
9
|
export declare const isFocusable: (element: HTMLElement) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the next element in depth-first order after the given element's subtree
|
|
12
|
+
* (i.e. without descending into its descendants), or null if there is none.
|
|
13
|
+
*
|
|
14
|
+
* @param element - element whose subtree should be skipped
|
|
15
|
+
* @returns the next element after the subtree, or null.
|
|
16
|
+
*/
|
|
17
|
+
export declare const findNextElementSkippingSubtree: (element: HTMLElement) => HTMLElement | null;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the next element after the given one in depth-first (pre-order) document order,
|
|
20
|
+
* or null if the given element is the last one in the document.
|
|
21
|
+
*
|
|
22
|
+
* @param element - element to start from
|
|
23
|
+
* @returns the next element in depth-first order, or null.
|
|
24
|
+
*/
|
|
25
|
+
export declare const findNextElement: (element: HTMLElement) => HTMLElement | null;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the previous element before the given one in depth-first (pre-order) document order,
|
|
28
|
+
* or null if the given element is the first one in the document.
|
|
29
|
+
*
|
|
30
|
+
* @param element - element to start from
|
|
31
|
+
* @returns the previous element in depth-first order, or null.
|
|
32
|
+
*/
|
|
33
|
+
export declare const findPreviousElement: (element: HTMLElement) => HTMLElement | null;
|
|
34
|
+
/**
|
|
35
|
+
* Finds the next focusable element after the given one in document order.
|
|
36
|
+
*
|
|
37
|
+
* @param element - element to start from
|
|
38
|
+
* @param findNextElementFn - optional function to customize element traversal order (defaults to depth-first pre-order)
|
|
39
|
+
* @returns the next focusable element, or null if none found.
|
|
40
|
+
*/
|
|
41
|
+
export declare const findNextFocusableElement: (element: HTMLElement, findNextElementFn?: (element: HTMLElement) => HTMLElement | null) => HTMLElement | null;
|
|
42
|
+
/**
|
|
43
|
+
* Finds the previous focusable element before the given one in document order.
|
|
44
|
+
*
|
|
45
|
+
* @param element - element to start from
|
|
46
|
+
* @param findPreviousElementFn - optional function to customize element traversal order (defaults to depth-first pre-order)
|
|
47
|
+
* @returns the previous focusable element, or null if none found.
|
|
48
|
+
*/
|
|
49
|
+
export declare const findPreviousFocusableElement: (element: HTMLElement, findPreviousElementFn?: (element: HTMLElement) => HTMLElement | null) => HTMLElement | null;
|