@salt-ds/lab 1.0.0-alpha.61 → 1.0.0-alpha.63
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/CHANGELOG.md +102 -0
- package/css/salt-lab.css +623 -324
- package/dist-cjs/date-picker/DatePicker.js +4 -3
- package/dist-cjs/date-picker/DatePicker.js.map +1 -1
- package/dist-cjs/date-picker/DatePickerActions.js +1 -1
- package/dist-cjs/date-picker/DatePickerActions.js.map +1 -1
- package/dist-cjs/date-picker/DatePickerContext.js.map +1 -1
- package/dist-cjs/date-picker/DatePickerOverlay.js +0 -4
- package/dist-cjs/date-picker/DatePickerOverlay.js.map +1 -1
- package/dist-cjs/date-picker/DatePickerOverlayProvider.js +65 -43
- package/dist-cjs/date-picker/DatePickerOverlayProvider.js.map +1 -1
- package/dist-cjs/date-picker/DatePickerRangeInput.js +10 -26
- package/dist-cjs/date-picker/DatePickerRangeInput.js.map +1 -1
- package/dist-cjs/date-picker/DatePickerSingleInput.js +8 -14
- package/dist-cjs/date-picker/DatePickerSingleInput.js.map +1 -1
- package/dist-cjs/date-picker/useDatePicker.js +10 -7
- package/dist-cjs/date-picker/useDatePicker.js.map +1 -1
- package/dist-cjs/date-picker/useKeyboard.js +23 -0
- package/dist-cjs/date-picker/useKeyboard.js.map +1 -0
- package/dist-cjs/index.js +19 -8
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/number-input/NumberInput.css.js +6 -0
- package/dist-cjs/number-input/NumberInput.css.js.map +1 -0
- package/dist-cjs/{stepper-input/StepperInput.js → number-input/NumberInput.js} +15 -15
- package/dist-cjs/number-input/NumberInput.js.map +1 -0
- package/dist-cjs/number-input/internal/useActivateWhileMouseDown.js.map +1 -0
- package/dist-cjs/number-input/internal/useInterval.js.map +1 -0
- package/dist-cjs/number-input/internal/utils.js.map +1 -0
- package/dist-cjs/{stepper-input/useStepperInput.js → number-input/useNumberInput.js} +3 -3
- package/dist-cjs/number-input/useNumberInput.js.map +1 -0
- package/dist-cjs/slider/RangeSlider.js +161 -0
- package/dist-cjs/slider/RangeSlider.js.map +1 -0
- package/dist-cjs/slider/Slider.js +104 -70
- package/dist-cjs/slider/Slider.js.map +1 -1
- package/dist-cjs/slider/internal/SliderThumb.css.js +6 -0
- package/dist-cjs/slider/internal/SliderThumb.css.js.map +1 -0
- package/dist-cjs/slider/internal/SliderThumb.js +136 -70
- package/dist-cjs/slider/internal/SliderThumb.js.map +1 -1
- package/dist-cjs/slider/internal/SliderTooltip.css.js +6 -0
- package/dist-cjs/slider/internal/SliderTooltip.css.js.map +1 -0
- package/dist-cjs/slider/internal/SliderTooltip.js +43 -0
- package/dist-cjs/slider/internal/SliderTooltip.js.map +1 -0
- package/dist-cjs/slider/internal/SliderTrack.css.js +6 -0
- package/dist-cjs/slider/internal/SliderTrack.css.js.map +1 -0
- package/dist-cjs/slider/internal/SliderTrack.js +160 -80
- package/dist-cjs/slider/internal/SliderTrack.js.map +1 -1
- package/dist-cjs/slider/internal/useRangeSliderThumb.js +194 -0
- package/dist-cjs/slider/internal/useRangeSliderThumb.js.map +1 -0
- package/dist-cjs/slider/internal/useSliderThumb.js +123 -0
- package/dist-cjs/slider/internal/useSliderThumb.js.map +1 -0
- package/dist-cjs/slider/internal/utils.js +97 -72
- package/dist-cjs/slider/internal/utils.js.map +1 -1
- package/dist-cjs/splitter/SplitHandle.css.js +6 -0
- package/dist-cjs/splitter/SplitHandle.css.js.map +1 -0
- package/dist-cjs/splitter/SplitHandle.js +60 -0
- package/dist-cjs/splitter/SplitHandle.js.map +1 -0
- package/dist-cjs/splitter/SplitPanel.css.js +6 -0
- package/dist-cjs/splitter/SplitPanel.css.js.map +1 -0
- package/dist-cjs/splitter/SplitPanel.js +37 -0
- package/dist-cjs/splitter/SplitPanel.js.map +1 -0
- package/dist-cjs/splitter/Splitter.js +31 -0
- package/dist-cjs/splitter/Splitter.js.map +1 -0
- package/dist-cjs/splitter/utils.js +18 -0
- package/dist-cjs/splitter/utils.js.map +1 -0
- package/dist-cjs/stepped-tracker/stepReducer.js +127 -81
- package/dist-cjs/stepped-tracker/stepReducer.js.map +1 -1
- package/dist-cjs/stepped-tracker/useStepReducer.js +6 -4
- package/dist-cjs/stepped-tracker/useStepReducer.js.map +1 -1
- package/dist-cjs/stepped-tracker/utils.js +44 -9
- package/dist-cjs/stepped-tracker/utils.js.map +1 -1
- package/dist-cjs/tabs-next/TabListNext.css.js +1 -1
- package/dist-cjs/tabs-next/TabListNext.js +10 -16
- package/dist-cjs/tabs-next/TabListNext.js.map +1 -1
- package/dist-cjs/tabs-next/TabOverflowList.css.js +1 -1
- package/dist-cjs/tabs-next/TabOverflowList.js +3 -2
- package/dist-cjs/tabs-next/TabOverflowList.js.map +1 -1
- package/dist-cjs/tabs-next/TabsNext.js +4 -51
- package/dist-cjs/tabs-next/TabsNext.js.map +1 -1
- package/dist-cjs/tabs-next/TabsNextContext.js +1 -1
- package/dist-cjs/tabs-next/TabsNextContext.js.map +1 -1
- package/dist-cjs/tabs-next/hooks/useCollection.js.map +1 -1
- package/dist-cjs/tabs-next/hooks/useOverflow.js +48 -5
- package/dist-cjs/tabs-next/hooks/useOverflow.js.map +1 -1
- package/dist-cjs/tabs-next/hooks/useRestoreActiveTab.js +93 -0
- package/dist-cjs/tabs-next/hooks/useRestoreActiveTab.js.map +1 -0
- package/dist-es/date-picker/DatePicker.js +4 -3
- package/dist-es/date-picker/DatePicker.js.map +1 -1
- package/dist-es/date-picker/DatePickerActions.js +1 -1
- package/dist-es/date-picker/DatePickerActions.js.map +1 -1
- package/dist-es/date-picker/DatePickerContext.js.map +1 -1
- package/dist-es/date-picker/DatePickerOverlay.js +0 -4
- package/dist-es/date-picker/DatePickerOverlay.js.map +1 -1
- package/dist-es/date-picker/DatePickerOverlayProvider.js +67 -45
- package/dist-es/date-picker/DatePickerOverlayProvider.js.map +1 -1
- package/dist-es/date-picker/DatePickerRangeInput.js +10 -26
- package/dist-es/date-picker/DatePickerRangeInput.js.map +1 -1
- package/dist-es/date-picker/DatePickerSingleInput.js +8 -14
- package/dist-es/date-picker/DatePickerSingleInput.js.map +1 -1
- package/dist-es/date-picker/useDatePicker.js +10 -7
- package/dist-es/date-picker/useDatePicker.js.map +1 -1
- package/dist-es/date-picker/useKeyboard.js +21 -0
- package/dist-es/date-picker/useKeyboard.js.map +1 -0
- package/dist-es/index.js +9 -4
- package/dist-es/index.js.map +1 -1
- package/dist-es/number-input/NumberInput.css.js +4 -0
- package/dist-es/number-input/NumberInput.css.js.map +1 -0
- package/dist-es/{stepper-input/StepperInput.js → number-input/NumberInput.js} +14 -14
- package/dist-es/number-input/NumberInput.js.map +1 -0
- package/dist-es/number-input/internal/useActivateWhileMouseDown.js.map +1 -0
- package/dist-es/number-input/internal/useInterval.js.map +1 -0
- package/dist-es/number-input/internal/utils.js.map +1 -0
- package/dist-es/{stepper-input/useStepperInput.js → number-input/useNumberInput.js} +3 -3
- package/dist-es/number-input/useNumberInput.js.map +1 -0
- package/dist-es/slider/RangeSlider.js +159 -0
- package/dist-es/slider/RangeSlider.js.map +1 -0
- package/dist-es/slider/Slider.js +107 -73
- package/dist-es/slider/Slider.js.map +1 -1
- package/dist-es/slider/internal/SliderThumb.css.js +4 -0
- package/dist-es/slider/internal/SliderThumb.css.js.map +1 -0
- package/dist-es/slider/internal/SliderThumb.js +138 -72
- package/dist-es/slider/internal/SliderThumb.js.map +1 -1
- package/dist-es/slider/internal/SliderTooltip.css.js +4 -0
- package/dist-es/slider/internal/SliderTooltip.css.js.map +1 -0
- package/dist-es/slider/internal/SliderTooltip.js +41 -0
- package/dist-es/slider/internal/SliderTooltip.js.map +1 -0
- package/dist-es/slider/internal/SliderTrack.css.js +4 -0
- package/dist-es/slider/internal/SliderTrack.css.js.map +1 -0
- package/dist-es/slider/internal/SliderTrack.js +164 -84
- package/dist-es/slider/internal/SliderTrack.js.map +1 -1
- package/dist-es/slider/internal/useRangeSliderThumb.js +192 -0
- package/dist-es/slider/internal/useRangeSliderThumb.js.map +1 -0
- package/dist-es/slider/internal/useSliderThumb.js +121 -0
- package/dist-es/slider/internal/useSliderThumb.js.map +1 -0
- package/dist-es/slider/internal/utils.js +91 -63
- package/dist-es/slider/internal/utils.js.map +1 -1
- package/dist-es/splitter/SplitHandle.css.js +4 -0
- package/dist-es/splitter/SplitHandle.css.js.map +1 -0
- package/dist-es/splitter/SplitHandle.js +58 -0
- package/dist-es/splitter/SplitHandle.js.map +1 -0
- package/dist-es/splitter/SplitPanel.css.js +4 -0
- package/dist-es/splitter/SplitPanel.css.js.map +1 -0
- package/dist-es/splitter/SplitPanel.js +35 -0
- package/dist-es/splitter/SplitPanel.js.map +1 -0
- package/dist-es/splitter/Splitter.js +27 -0
- package/dist-es/splitter/Splitter.js.map +1 -0
- package/dist-es/splitter/utils.js +15 -0
- package/dist-es/splitter/utils.js.map +1 -0
- package/dist-es/stepped-tracker/stepReducer.js +128 -82
- package/dist-es/stepped-tracker/stepReducer.js.map +1 -1
- package/dist-es/stepped-tracker/useStepReducer.js +7 -5
- package/dist-es/stepped-tracker/useStepReducer.js.map +1 -1
- package/dist-es/stepped-tracker/utils.js +43 -9
- package/dist-es/stepped-tracker/utils.js.map +1 -1
- package/dist-es/tabs-next/TabListNext.css.js +1 -1
- package/dist-es/tabs-next/TabListNext.js +11 -17
- package/dist-es/tabs-next/TabListNext.js.map +1 -1
- package/dist-es/tabs-next/TabOverflowList.css.js +1 -1
- package/dist-es/tabs-next/TabOverflowList.js +4 -3
- package/dist-es/tabs-next/TabOverflowList.js.map +1 -1
- package/dist-es/tabs-next/TabsNext.js +5 -52
- package/dist-es/tabs-next/TabsNext.js.map +1 -1
- package/dist-es/tabs-next/TabsNextContext.js +1 -1
- package/dist-es/tabs-next/TabsNextContext.js.map +1 -1
- package/dist-es/tabs-next/hooks/useCollection.js.map +1 -1
- package/dist-es/tabs-next/hooks/useOverflow.js +49 -6
- package/dist-es/tabs-next/hooks/useOverflow.js.map +1 -1
- package/dist-es/tabs-next/hooks/useRestoreActiveTab.js +91 -0
- package/dist-es/tabs-next/hooks/useRestoreActiveTab.js.map +1 -0
- package/dist-types/date-picker/DatePicker.d.ts +6 -1
- package/dist-types/date-picker/DatePickerContext.d.ts +2 -1
- package/dist-types/date-picker/DatePickerOverlayProvider.d.ts +18 -4
- package/dist-types/date-picker/DatePickerRangeInput.d.ts +1 -1
- package/dist-types/date-picker/index.d.ts +1 -0
- package/dist-types/date-picker/useKeyboard.d.ts +14 -0
- package/dist-types/index.d.ts +5 -4
- package/dist-types/{stepper-input/StepperInput.d.ts → number-input/NumberInput.d.ts} +7 -7
- package/dist-types/number-input/index.d.ts +2 -0
- package/dist-types/{stepper-input/useStepperInput.d.ts → number-input/useNumberInput.d.ts} +2 -2
- package/dist-types/slider/RangeSlider.d.ts +91 -0
- package/dist-types/slider/Slider.d.ts +74 -15
- package/dist-types/slider/index.d.ts +1 -1
- package/dist-types/slider/internal/SliderThumb.d.ts +20 -7
- package/dist-types/slider/internal/SliderTooltip.d.ts +6 -0
- package/dist-types/slider/internal/SliderTrack.d.ts +23 -3
- package/dist-types/slider/internal/useRangeSliderThumb.d.ts +26 -0
- package/dist-types/slider/internal/useSliderThumb.d.ts +24 -0
- package/dist-types/slider/internal/utils.d.ts +17 -15
- package/dist-types/splitter/SplitHandle.d.ts +21 -0
- package/dist-types/splitter/SplitPanel.d.ts +10 -0
- package/dist-types/splitter/Splitter.d.ts +22 -0
- package/dist-types/splitter/index.d.ts +4 -0
- package/dist-types/splitter/utils.d.ts +4 -0
- package/dist-types/stepped-tracker/Step.types.d.ts +2 -4
- package/dist-types/stepped-tracker/stepReducer.types.d.ts +6 -4
- package/dist-types/stepped-tracker/utils.d.ts +6 -3
- package/dist-types/tabs/drag-drop/drag-utils.d.ts +6 -6
- package/dist-types/tabs-next/TabsNextContext.d.ts +1 -1
- package/dist-types/tabs-next/hooks/useOverflow.d.ts +1 -1
- package/dist-types/tabs-next/hooks/useRestoreActiveTab.d.ts +10 -0
- package/package.json +4 -3
- package/dist-cjs/slider/Slider.css.js +0 -6
- package/dist-cjs/slider/Slider.css.js.map +0 -1
- package/dist-cjs/slider/internal/SliderContext.js +0 -19
- package/dist-cjs/slider/internal/SliderContext.js.map +0 -1
- package/dist-cjs/slider/internal/SliderMarks.js +0 -29
- package/dist-cjs/slider/internal/SliderMarks.js.map +0 -1
- package/dist-cjs/slider/internal/SliderSelection.js +0 -33
- package/dist-cjs/slider/internal/SliderSelection.js.map +0 -1
- package/dist-cjs/slider/internal/useKeyDownThumb.js +0 -50
- package/dist-cjs/slider/internal/useKeyDownThumb.js.map +0 -1
- package/dist-cjs/stepper-input/StepperInput.css.js +0 -6
- package/dist-cjs/stepper-input/StepperInput.css.js.map +0 -1
- package/dist-cjs/stepper-input/StepperInput.js.map +0 -1
- package/dist-cjs/stepper-input/internal/useActivateWhileMouseDown.js.map +0 -1
- package/dist-cjs/stepper-input/internal/useInterval.js.map +0 -1
- package/dist-cjs/stepper-input/internal/utils.js.map +0 -1
- package/dist-cjs/stepper-input/useStepperInput.js.map +0 -1
- package/dist-es/slider/Slider.css.js +0 -4
- package/dist-es/slider/Slider.css.js.map +0 -1
- package/dist-es/slider/internal/SliderContext.js +0 -16
- package/dist-es/slider/internal/SliderContext.js.map +0 -1
- package/dist-es/slider/internal/SliderMarks.js +0 -27
- package/dist-es/slider/internal/SliderMarks.js.map +0 -1
- package/dist-es/slider/internal/SliderSelection.js +0 -31
- package/dist-es/slider/internal/SliderSelection.js.map +0 -1
- package/dist-es/slider/internal/useKeyDownThumb.js +0 -48
- package/dist-es/slider/internal/useKeyDownThumb.js.map +0 -1
- package/dist-es/stepper-input/StepperInput.css.js +0 -4
- package/dist-es/stepper-input/StepperInput.css.js.map +0 -1
- package/dist-es/stepper-input/StepperInput.js.map +0 -1
- package/dist-es/stepper-input/internal/useActivateWhileMouseDown.js.map +0 -1
- package/dist-es/stepper-input/internal/useInterval.js.map +0 -1
- package/dist-es/stepper-input/internal/utils.js.map +0 -1
- package/dist-es/stepper-input/useStepperInput.js.map +0 -1
- package/dist-types/slider/internal/SliderContext.d.ts +0 -11
- package/dist-types/slider/internal/SliderMarks.d.ts +0 -7
- package/dist-types/slider/internal/SliderSelection.d.ts +0 -4
- package/dist-types/slider/internal/index.d.ts +0 -3
- package/dist-types/slider/internal/useKeyDownThumb.d.ts +0 -2
- package/dist-types/slider/types.d.ts +0 -4
- package/dist-types/stepper-input/index.d.ts +0 -2
- /package/dist-cjs/{stepper-input → number-input}/internal/useActivateWhileMouseDown.js +0 -0
- /package/dist-cjs/{stepper-input → number-input}/internal/useInterval.js +0 -0
- /package/dist-cjs/{stepper-input → number-input}/internal/utils.js +0 -0
- /package/dist-es/{stepper-input → number-input}/internal/useActivateWhileMouseDown.js +0 -0
- /package/dist-es/{stepper-input → number-input}/internal/useInterval.js +0 -0
- /package/dist-es/{stepper-input → number-input}/internal/utils.js +0 -0
- /package/dist-types/{stepper-input → number-input}/internal/useActivateWhileMouseDown.d.ts +0 -0
- /package/dist-types/{stepper-input → number-input}/internal/useInterval.d.ts +0 -0
- /package/dist-types/{stepper-input → number-input}/internal/utils.d.ts +0 -0
|
@@ -1,75 +1,103 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const roundedToStep = roundToStep(normaliseBetweenValues, step);
|
|
6
|
-
const decimals = countDecimalPlaces(step);
|
|
7
|
-
const rounded = Number(roundedToStep.toFixed(decimals));
|
|
8
|
-
const value = clampValue(rounded, [min, max]);
|
|
9
|
-
return value;
|
|
10
|
-
};
|
|
11
|
-
const setValue = (value, newValue, index, onChange) => {
|
|
12
|
-
if (value.length === 2) {
|
|
13
|
-
const newValueArray = [...value];
|
|
14
|
-
newValueArray.splice(index, 1, newValue);
|
|
15
|
-
onChange(newValueArray);
|
|
16
|
-
return;
|
|
1
|
+
const toFloat = (value) => typeof value === "string" ? Number.parseFloat(value) : value;
|
|
2
|
+
const calculateMarkPosition = (value, max, min) => {
|
|
3
|
+
if (min === max) {
|
|
4
|
+
return 0;
|
|
17
5
|
}
|
|
18
|
-
|
|
6
|
+
const clampedValue = Number.isNaN(toFloat(value)) ? min : Math.min(Math.max(toFloat(value), min), max);
|
|
7
|
+
const markPosition = (clampedValue - min) / (max - min) * 100;
|
|
8
|
+
return Math.round(markPosition * 100) / 100;
|
|
19
9
|
};
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
if (value
|
|
23
|
-
return max;
|
|
24
|
-
}
|
|
25
|
-
if (value < min) {
|
|
10
|
+
const calculatePercentage = (value, max, min) => (value - min) / (max - min) * 100;
|
|
11
|
+
const clamp = (value, max, min, step, decimalPlaces, marks, restrictToMarks) => {
|
|
12
|
+
if (Number.isNaN(value)) {
|
|
26
13
|
return min;
|
|
27
14
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
const clampedValue = Math.min(Math.max(value, min), max);
|
|
16
|
+
if (restrictToMarks && marks) {
|
|
17
|
+
let closestMark = marks[0].value;
|
|
18
|
+
let smallestDifference = Math.abs(clampedValue - closestMark);
|
|
19
|
+
for (let i = 1; i < marks.length; i++) {
|
|
20
|
+
const currentDifference = Math.abs(clampedValue - marks[i].value);
|
|
21
|
+
if (currentDifference < smallestDifference) {
|
|
22
|
+
smallestDifference = currentDifference;
|
|
23
|
+
closestMark = marks[i].value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return closestMark;
|
|
27
|
+
}
|
|
28
|
+
let roundedValue = Math.round(clampedValue / step) * step;
|
|
29
|
+
if (roundedValue > max) {
|
|
30
|
+
roundedValue = max;
|
|
31
|
+
}
|
|
32
|
+
return Number.parseFloat(roundedValue.toFixed(decimalPlaces));
|
|
37
33
|
};
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
const clampRange = (range, max, min, step, decimalPlaces, marks, restrictToMarks) => {
|
|
35
|
+
let [start, end] = range;
|
|
36
|
+
if (Number.isNaN(start)) {
|
|
37
|
+
start = min;
|
|
38
|
+
}
|
|
39
|
+
if (Number.isNaN(end)) {
|
|
40
|
+
end = max;
|
|
41
|
+
}
|
|
42
|
+
if (start > end) {
|
|
43
|
+
[start, end] = [end, start];
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
start = clamp(start, max, min, step, decimalPlaces, marks, restrictToMarks);
|
|
46
|
+
end = clamp(end, max, min, step, decimalPlaces, marks, restrictToMarks);
|
|
47
|
+
return [start, end];
|
|
48
|
+
};
|
|
49
|
+
const getClickedPosition = (sliderRef, clientX, max, min, step, decimalPlaces, marks, restrictToMarks) => {
|
|
50
|
+
if (!sliderRef.current) return;
|
|
51
|
+
const sliderRect = sliderRef.current.getBoundingClientRect();
|
|
52
|
+
const rawValue = (clientX - sliderRect.left) / sliderRect.width * (max - min) + min;
|
|
53
|
+
const steppedValue = Math.round(rawValue / step) * step;
|
|
54
|
+
return clamp(
|
|
55
|
+
steppedValue,
|
|
56
|
+
max,
|
|
57
|
+
min,
|
|
58
|
+
step,
|
|
59
|
+
decimalPlaces,
|
|
60
|
+
marks,
|
|
61
|
+
restrictToMarks
|
|
47
62
|
);
|
|
48
|
-
return marks.map((mark) => ({
|
|
49
|
-
...mark,
|
|
50
|
-
label: mark.value.toFixed(decimals)
|
|
51
|
-
}));
|
|
52
63
|
};
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
const getKeyboardValue = (event, value, step, stepMultiplier, max, min, restrictToMarks, marks) => {
|
|
65
|
+
let newValue = value;
|
|
66
|
+
if (restrictToMarks && marks && marks.length >= 1) {
|
|
67
|
+
const currentIndex = marks.findIndex((mark) => mark.value === value);
|
|
68
|
+
switch (event.key) {
|
|
69
|
+
case "ArrowUp":
|
|
70
|
+
case "ArrowRight":
|
|
71
|
+
case "PageUp":
|
|
72
|
+
if (currentIndex < marks.length - 1) {
|
|
73
|
+
newValue = marks[currentIndex + 1].value;
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case "ArrowDown":
|
|
77
|
+
case "ArrowLeft":
|
|
78
|
+
case "PageDown":
|
|
79
|
+
if (currentIndex > 0) {
|
|
80
|
+
newValue = marks[currentIndex - 1].value;
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
default:
|
|
84
|
+
return newValue;
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
switch (event.key) {
|
|
88
|
+
case "PageUp":
|
|
89
|
+
newValue = Math.min(value + step * stepMultiplier, max);
|
|
90
|
+
break;
|
|
91
|
+
case "PageDown":
|
|
92
|
+
newValue = Math.max(value - step * stepMultiplier, min);
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
return newValue;
|
|
96
|
+
}
|
|
58
97
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const nearestIndex = distances.indexOf(minDistance);
|
|
62
|
-
return nearestIndex;
|
|
63
|
-
};
|
|
64
|
-
const preventOverlappingValues = (value, newValue, index) => value.length === 2 ? index === 0 ? Math.min(newValue, value[1]) : Math.max(newValue, value[0]) : newValue;
|
|
65
|
-
const parseValueProp = (value, min, max) => {
|
|
66
|
-
if (typeof value === "undefined" || value.length < 1) return;
|
|
67
|
-
const a = clampValue(value[0], [min, max]);
|
|
68
|
-
if (value.length === 1) return [a];
|
|
69
|
-
const b = clampValue(value[1], [min, max]);
|
|
70
|
-
if (a > b) return [a, a];
|
|
71
|
-
return [a, b];
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
return newValue;
|
|
72
100
|
};
|
|
73
101
|
|
|
74
|
-
export {
|
|
102
|
+
export { calculateMarkPosition, calculatePercentage, clamp, clampRange, getClickedPosition, getKeyboardValue, toFloat };
|
|
75
103
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../src/slider/internal/utils.ts"],"sourcesContent":["import type { RefObject } from \"react\";\
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/slider/internal/utils.ts"],"sourcesContent":["import type { RefObject } from \"react\";\n\nexport const toFloat = (value: number | string) =>\n typeof value === \"string\" ? Number.parseFloat(value) : value;\n\nexport const calculateMarkPosition = (\n value: number | string,\n max: number,\n min: number,\n) => {\n if (min === max) {\n return 0;\n }\n const clampedValue = Number.isNaN(toFloat(value))\n ? min\n : Math.min(Math.max(toFloat(value), min), max);\n const markPosition = ((clampedValue - min) / (max - min)) * 100;\n return Math.round(markPosition * 100) / 100;\n};\n\nexport const calculatePercentage = (value: number, max: number, min: number) =>\n ((value - min) / (max - min)) * 100;\n\nexport const clamp = (\n value: number,\n max: number,\n min: number,\n step: number,\n decimalPlaces: number,\n marks?: { value: number; label: string }[],\n restrictToMarks?: boolean,\n) => {\n if (Number.isNaN(value)) {\n return min;\n }\n // Clamp the value between min and max\n const clampedValue = Math.min(Math.max(value, min), max);\n if (restrictToMarks && marks) {\n // Find the closest mark value\n let closestMark = marks[0].value;\n let smallestDifference = Math.abs(clampedValue - closestMark);\n for (let i = 1; i < marks.length; i++) {\n const currentDifference = Math.abs(clampedValue - marks[i].value);\n if (currentDifference < smallestDifference) {\n smallestDifference = currentDifference;\n closestMark = marks[i].value;\n }\n }\n return closestMark;\n }\n // Round to the nearest multiple of the step\n let roundedValue = Math.round(clampedValue / step) * step;\n // Ensure the rounded value does not exceed max\n if (roundedValue > max) {\n roundedValue = max;\n }\n return Number.parseFloat(roundedValue.toFixed(decimalPlaces));\n};\n\nexport const clampRange = (\n range: [number, number],\n max: number,\n min: number,\n step: number,\n decimalPlaces: number,\n marks?: { value: number; label: string }[],\n restrictToMarks?: boolean,\n) => {\n let [start, end] = range;\n\n if (Number.isNaN(start)) {\n start = min;\n }\n if (Number.isNaN(end)) {\n end = max;\n }\n if (start > end) {\n [start, end] = [end, start];\n }\n start = clamp(start, max, min, step, decimalPlaces, marks, restrictToMarks);\n end = clamp(end, max, min, step, decimalPlaces, marks, restrictToMarks);\n return [start, end] as [number, number];\n};\n\nexport const getClickedPosition = (\n sliderRef: RefObject<HTMLDivElement>,\n clientX: number,\n max: number,\n min: number,\n step: number,\n decimalPlaces: number,\n marks?: { label: string; value: number }[],\n restrictToMarks?: boolean,\n) => {\n if (!sliderRef.current) return;\n\n const sliderRect = sliderRef.current.getBoundingClientRect();\n const rawValue =\n ((clientX - sliderRect.left) / sliderRect.width) * (max - min) + min;\n const steppedValue = Math.round(rawValue / step) * step;\n return clamp(\n steppedValue,\n max,\n min,\n step,\n decimalPlaces,\n marks,\n restrictToMarks,\n );\n};\n\nexport const getKeyboardValue = (\n event: React.KeyboardEvent,\n value: number,\n step: number,\n stepMultiplier: number,\n max: number,\n min: number,\n restrictToMarks?: boolean,\n marks?: { label: string; value: number }[],\n) => {\n let newValue = value;\n\n if (restrictToMarks && marks && marks.length >= 1) {\n const currentIndex = marks.findIndex((mark) => mark.value === value);\n\n switch (event.key) {\n case \"ArrowUp\":\n case \"ArrowRight\":\n case \"PageUp\":\n if (currentIndex < marks.length - 1) {\n newValue = marks[currentIndex + 1].value;\n }\n break;\n case \"ArrowDown\":\n case \"ArrowLeft\":\n case \"PageDown\":\n if (currentIndex > 0) {\n newValue = marks[currentIndex - 1].value;\n }\n break;\n default:\n return newValue;\n }\n } else {\n switch (event.key) {\n case \"PageUp\":\n newValue = Math.min(value + step * stepMultiplier, max);\n break;\n case \"PageDown\":\n newValue = Math.max(value - step * stepMultiplier, min);\n break;\n default:\n return newValue;\n }\n }\n\n event.preventDefault();\n return newValue;\n};\n"],"names":[],"mappings":"AAEa,MAAA,OAAA,GAAU,CAAC,KACtB,KAAA,OAAO,UAAU,QAAW,GAAA,MAAA,CAAO,UAAW,CAAA,KAAK,CAAI,GAAA;AAElD,MAAM,qBAAwB,GAAA,CACnC,KACA,EAAA,GAAA,EACA,GACG,KAAA;AACH,EAAA,IAAI,QAAQ,G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C,QAAA;AAAA,MACF;AACE,QAAO,OAAA,QAAA;AAAA;AACX,GACK,MAAA;AACL,IAAA,QAAQ,MAAM,GAAK;AAAA,MACjB,KAAK,QAAA;AACH,QAAA,QAAA,GAAW,IAAK,CAAA,GAAA,CAAI,KAAQ,GAAA,IAAA,GAAO,gBAAgB,GAAG,CAAA;AACtD,QAAA;AAAA,MACF,KAAK,UAAA;AACH,QAAA,QAAA,GAAW,IAAK,CAAA,GAAA,CAAI,KAAQ,GAAA,IAAA,GAAO,gBAAgB,GAAG,CAAA;AACtD,QAAA;AAAA,MACF;AACE,QAAO,OAAA,QAAA;AAAA;AACX;AAGF,EAAA,KAAA,CAAM,cAAe,EAAA;AACrB,EAAO,OAAA,QAAA;AACT;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var css_248z = ".saltSplitHandle {\n --splitHandle-size: var(--salt-size-thickness-400, calc(var(--salt-size-border) * 4));\n --splitHandle-borderWidth: var(--salt-size-thickness-100, var(--salt-size-border));\n --splitHandle-borderColor: var(--salt-separable-secondary-borderColor);\n --splitHandle-borderStyle: var(--salt-separable-borderStyle);\n --splitHandle-dot-background: var(--salt-separable-foreground);\n --splitHandle-dot-background-hover: var(--salt-separable-foreground-hover);\n --splitHandle-dot-background-active: var(--salt-separable-foreground-active);\n\n position: relative;\n\n display: inline-flex;\n justify-content: center;\n align-items: center;\n gap: 2px;\n\n box-sizing: content-box;\n\n background: var(--splitHandle-background);\n}\n\n.saltSplitHandle-bordered,\n.saltSplitHandle-variant-primary {\n --splitHandle-background: var(--salt-container-primary-background);\n --splitHandle-background-hover: var(--salt-separable-background-hover);\n --splitHandle-background-active: var(--salt-separable-background-active);\n}\n\n.saltSplitHandle-variant-secondary {\n --splitHandle-background: var(--salt-container-secondary-background);\n --splitHandle-background-hover: var(--salt-separable-background-hover);\n --splitHandle-background-active: var(--salt-separable-background-active);\n}\n\n.saltSplitHandle-variant-tertiary {\n --splitHandle-background: var(--salt-container-tertiary-background);\n --splitHandle-background-hover: var(--salt-separable-background-hover);\n --splitHandle-background-active: var(--salt-separable-background-active);\n}\n\n.saltSplitHandle-variant-transparent {\n --splitHandle-background: var(--salt-separable-background);\n --splitHandle-background-hover: var(--salt-separable-background-hover);\n --splitHandle-background-active: var(--salt-separable-background-active);\n}\n\n.saltSplitHandle[data-resize-handle-state=\"hover\"] {\n background: var(--splitHandle-background-hover);\n}\n\n.saltSplitHandle[data-resize-handle-state=\"drag\"] {\n --splitHandle-background: var(--splitHandle-background-active);\n}\n\n.saltSplitHandle[data-panel-group-direction=\"horizontal\"] {\n flex-direction: column;\n width: var(--splitHandle-size);\n}\n\n.saltSplitHandle[data-panel-group-direction=\"vertical\"] {\n flex-direction: row;\n height: var(--splitHandle-size);\n}\n\n.saltSplitHandle[data-panel-group-direction=\"horizontal\"]::after {\n content: \"\";\n position: absolute;\n left: -10px;\n right: -10px;\n top: 0;\n bottom: 0;\n}\n\n.saltSplitHandle[data-panel-group-direction=\"vertical\"]::after {\n content: \"\";\n position: absolute;\n left: 0;\n right: 0;\n top: -10px;\n bottom: -10px;\n}\n\n.saltSplitHandle:focus-visible {\n outline-style: var(--salt-focused-outlineStyle);\n outline-width: var(--salt-focused-outlineWidth);\n outline-color: var(--salt-focused-outlineColor);\n outline-offset: var(--salt-focused-outlineOffset);\n}\n\n.saltSplitHandle-border-top {\n border-top-width: var(--splitHandle-borderWidth);\n border-top-color: var(--splitHandle-borderColor);\n border-top-style: var(--splitHandle-borderStyle);\n\n border-bottom-width: var(--splitHandle-borderWidth);\n border-bottom-color: transparent;\n border-bottom-style: var(--splitHandle-borderStyle);\n}\n\n.saltSplitHandle-border-bottom {\n border-top-width: var(--splitHandle-borderWidth);\n border-top-color: transparent;\n border-top-style: var(--splitHandle-borderStyle);\n\n border-bottom-width: var(--splitHandle-borderWidth);\n border-bottom-color: var(--splitHandle-borderColor);\n border-bottom-style: var(--splitHandle-borderStyle);\n}\n\n.saltSplitHandle-border-top-bottom {\n border-top-width: var(--splitHandle-borderWidth);\n border-top-color: var(--splitHandle-borderColor);\n border-top-style: var(--splitHandle-borderStyle);\n\n border-bottom-width: var(--splitHandle-borderWidth);\n border-bottom-color: var(--splitHandle-borderColor);\n border-bottom-style: var(--splitHandle-borderStyle);\n}\n\n.saltSplitHandle-border-left {\n border-left-width: var(--splitHandle-borderWidth);\n border-left-color: var(--splitHandle-borderColor);\n border-left-style: var(--splitHandle-borderStyle);\n\n border-right-width: var(--splitHandle-borderWidth);\n border-right-color: transparent;\n border-right-style: var(--splitHandle-borderStyle);\n}\n\n.saltSplitHandle-border-right {\n border-left-width: var(--splitHandle-borderWidth);\n border-left-color: transparent;\n border-left-style: var(--splitHandle-borderStyle);\n\n border-right-width: var(--splitHandle-borderWidth);\n border-right-color: var(--splitHandle-borderColor);\n border-right-style: var(--splitHandle-borderStyle);\n}\n\n.saltSplitHandle-border-left-right {\n border-left-width: var(--splitHandle-borderWidth);\n border-left-color: var(--splitHandle-borderColor);\n border-left-style: var(--splitHandle-borderStyle);\n\n border-right-width: var(--splitHandle-borderWidth);\n border-right-color: var(--splitHandle-borderColor);\n border-right-style: var(--splitHandle-borderStyle);\n}\n\n/* two handles touching horizontally */\n.saltSplitHandle[data-panel-group-direction=\"horizontal\"] + div[data-panel-size=\"0.0\"] + .saltSplitHandle[data-panel-group-direction=\"horizontal\"] {\n margin-left: -1px;\n}\n\n/* two handles touching vertically */\n.saltSplitHandle[data-panel-group-direction=\"vertical\"] + div[data-panel-size=\"0.0\"] + .saltSplitHandle[data-panel-group-direction=\"vertical\"] {\n margin-top: -1px;\n}\n\n/* handle touching the side of a container */\n@supports selector(:has(*)) {\n .saltSplitPanel:first-of-type[data-panel-size=\"0.0\"] + .saltSplitHandle-bordered[data-panel-group-direction=\"horizontal\"] {\n margin-left: -1px;\n }\n\n .saltSplitPanel:first-of-type[data-panel-size=\"0.0\"] + .saltSplitHandle-bordered[data-panel-group-direction=\"vertical\"] {\n margin-top: -1px;\n }\n\n .saltSplitHandle-bordered[data-panel-group-direction=\"horizontal\"]:has(+ .saltSplitPanel:last-of-type[data-panel-size=\"0.0\"]) {\n margin-right: -1px;\n }\n\n .saltSplitHandle-bordered[data-panel-group-direction=\"vertical\"]:has(+ .saltSplitPanel:last-of-type[data-panel-size=\"0.0\"]) {\n margin-bottom: -1px;\n }\n}\n\n.saltSplitHandle-dot {\n background: var(--splitHandle-dot-background);\n}\n\n.saltSplitHandle[data-resize-handle-state=\"hover\"] > .saltSplitHandle-dot {\n background: var(--splitHandle-dot-background-hover);\n}\n\n.saltSplitHandle[data-resize-handle-state=\"drag\"] > .saltSplitHandle-dot {\n background: var(--splitHandle-dot-background-active);\n}\n\n.saltSplitHandle[data-panel-group-direction=\"horizontal\"] > .saltSplitHandle-dot {\n width: 2px;\n height: 1px;\n}\n\n.saltSplitHandle[data-panel-group-direction=\"vertical\"] > .saltSplitHandle-dot {\n height: 2px;\n width: 1px;\n}\n";
|
|
2
|
+
|
|
3
|
+
export { css_248z as default };
|
|
4
|
+
//# sourceMappingURL=SplitHandle.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitHandle.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { makePrefixer } from '@salt-ds/core';
|
|
3
|
+
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
4
|
+
import { useWindow } from '@salt-ds/window';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { useContext } from 'react';
|
|
7
|
+
import { PanelResizeHandle } from 'react-resizable-panels';
|
|
8
|
+
import css_248z from './SplitHandle.css.js';
|
|
9
|
+
import { AppearanceContext, OrientationContext } from './Splitter.js';
|
|
10
|
+
import { computeVariant, computeAccent } from './utils.js';
|
|
11
|
+
|
|
12
|
+
const withBaseName = makePrefixer("saltSplitHandle");
|
|
13
|
+
function SplitHandle({
|
|
14
|
+
variant: variantProp,
|
|
15
|
+
border: borderProp,
|
|
16
|
+
hitAreaMargins = {
|
|
17
|
+
coarse: 9,
|
|
18
|
+
fine: 9
|
|
19
|
+
},
|
|
20
|
+
className,
|
|
21
|
+
...props
|
|
22
|
+
}) {
|
|
23
|
+
const targetWindow = useWindow();
|
|
24
|
+
const appearance = useContext(AppearanceContext);
|
|
25
|
+
const orientation = useContext(OrientationContext);
|
|
26
|
+
const variant = variantProp ?? computeVariant(appearance);
|
|
27
|
+
const border = borderProp ?? computeAccent(appearance, orientation);
|
|
28
|
+
useComponentCssInjection({
|
|
29
|
+
testId: "salt-split-handle",
|
|
30
|
+
css: css_248z,
|
|
31
|
+
window: targetWindow
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ jsxs(
|
|
34
|
+
PanelResizeHandle,
|
|
35
|
+
{
|
|
36
|
+
hitAreaMargins,
|
|
37
|
+
"data-variant": variant,
|
|
38
|
+
"data-border": border,
|
|
39
|
+
className: clsx(
|
|
40
|
+
withBaseName(),
|
|
41
|
+
withBaseName(appearance),
|
|
42
|
+
withBaseName("border", border),
|
|
43
|
+
withBaseName("variant", variant),
|
|
44
|
+
className
|
|
45
|
+
),
|
|
46
|
+
...props,
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ jsx("span", { className: withBaseName("dot") }),
|
|
49
|
+
/* @__PURE__ */ jsx("span", { className: withBaseName("dot") }),
|
|
50
|
+
/* @__PURE__ */ jsx("span", { className: withBaseName("dot") }),
|
|
51
|
+
/* @__PURE__ */ jsx("span", { className: withBaseName("dot") })
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { SplitHandle };
|
|
58
|
+
//# sourceMappingURL=SplitHandle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitHandle.js","sources":["../src/splitter/SplitHandle.tsx"],"sourcesContent":["import { makePrefixer } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport clsx from \"clsx\";\nimport { useContext } from \"react\";\nimport {\n PanelResizeHandle,\n type PanelResizeHandleProps,\n} from \"react-resizable-panels\";\n\nimport splitHandleCSS from \"./SplitHandle.css\";\nimport { AppearanceContext, OrientationContext } from \"./Splitter\";\nimport { computeAccent, computeVariant } from \"./utils\";\n\nconst withBaseName = makePrefixer(\"saltSplitHandle\");\n\nexport type SplitHandleVariant =\n | \"primary\"\n | \"secondary\"\n | \"tertiary\"\n | \"transparent\";\n\nexport type SplitHandleBorder =\n | \"top\"\n | \"bottom\"\n | \"right\"\n | \"left\"\n | \"top-bottom\"\n | \"left-right\"\n | \"none\";\n\nexport interface SplitHandleProps extends PanelResizeHandleProps {\n /**\n * Styling variant\n * @default \"primary\"\n */\n variant?: SplitHandleVariant;\n /**\n * Change which sides get a border displayed\n *\n * Default is based on the orientation and appearance\n * set on the parent Stepper components, ex.\n * bordered + vertical = left-right\n * bordered + horizontal = top-bottom\n * transparent = none\n */\n border?: SplitHandleBorder;\n}\n\nexport function SplitHandle({\n variant: variantProp,\n border: borderProp,\n hitAreaMargins = {\n coarse: 9,\n fine: 9,\n },\n className,\n ...props\n}: SplitHandleProps) {\n const targetWindow = useWindow();\n const appearance = useContext(AppearanceContext);\n const orientation = useContext(OrientationContext);\n\n const variant = variantProp ?? computeVariant(appearance);\n const border = borderProp ?? computeAccent(appearance, orientation);\n\n useComponentCssInjection({\n testId: \"salt-split-handle\",\n css: splitHandleCSS,\n window: targetWindow,\n });\n\n return (\n <PanelResizeHandle\n hitAreaMargins={hitAreaMargins}\n data-variant={variant}\n data-border={border}\n className={clsx(\n withBaseName(),\n withBaseName(appearance),\n withBaseName(\"border\", border),\n withBaseName(\"variant\", variant),\n className,\n )}\n {...props}\n >\n <span className={withBaseName(\"dot\")} />\n <span className={withBaseName(\"dot\")} />\n <span className={withBaseName(\"dot\")} />\n <span className={withBaseName(\"dot\")} />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A,MAAA,EAAA,EAAK,SAAW,EAAA,YAAA,CAAa,KAAK,CAAG,EAAA,CAAA;AAAA,wBACrC,GAAA,CAAA,MAAA,EAAA,EAAK,SAAW,EAAA,YAAA,CAAa,KAAK,CAAG,EAAA,CAAA;AAAA,wBACrC,GAAA,CAAA,MAAA,EAAA,EAAK,SAAW,EAAA,YAAA,CAAa,KAAK,CAAG,EAAA;AAAA;AAAA;AAAA,GACxC;AAEJ;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var css_248z = ".saltSplitPanel {\n box-sizing: border-box;\n\n background: var(--splitPanel-background);\n}\n\n.saltSplitPanel[data-panel-size=\"0.0\"] {\n visibility: hidden;\n}\n\n.saltSplitPanel-primary {\n --splitPanel-background: var(--salt-container-primary-background);\n}\n\n.saltSplitPanel-secondary {\n --splitPanel-background: var(--salt-container-secondary-background);\n}\n\n.saltSplitPanel-tertiary {\n --splitPanel-background: var(--salt-container-tertiary-background);\n}\n\n@supports selector(:has(*)) {\n .saltSplitPanel:has(.saltSplitPanel) {\n background: unset;\n }\n}\n";
|
|
2
|
+
|
|
3
|
+
export { css_248z as default };
|
|
4
|
+
//# sourceMappingURL=SplitPanel.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitPanel.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { makePrefixer, useId } from '@salt-ds/core';
|
|
3
|
+
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
4
|
+
import { useWindow } from '@salt-ds/window';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { forwardRef } from 'react';
|
|
7
|
+
import { Panel } from 'react-resizable-panels';
|
|
8
|
+
import css_248z from './SplitPanel.css.js';
|
|
9
|
+
|
|
10
|
+
const withBaseName = makePrefixer("saltSplitPanel");
|
|
11
|
+
const SplitPanel = forwardRef(
|
|
12
|
+
function SplitPanel2({ id: idProp, variant = "primary", minSize = 10, className, ...props }, ref) {
|
|
13
|
+
const id = useId(idProp);
|
|
14
|
+
const targetWindow = useWindow();
|
|
15
|
+
useComponentCssInjection({
|
|
16
|
+
testId: "salt-split-panel",
|
|
17
|
+
css: css_248z,
|
|
18
|
+
window: targetWindow
|
|
19
|
+
});
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
Panel,
|
|
22
|
+
{
|
|
23
|
+
id,
|
|
24
|
+
minSize,
|
|
25
|
+
"data-variant": variant,
|
|
26
|
+
className: clsx(withBaseName(), withBaseName(variant), className),
|
|
27
|
+
ref,
|
|
28
|
+
...props
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export { SplitPanel };
|
|
35
|
+
//# sourceMappingURL=SplitPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitPanel.js","sources":["../src/splitter/SplitPanel.tsx"],"sourcesContent":["import { makePrefixer, useId } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport clsx from \"clsx\";\nimport { forwardRef } from \"react\";\nimport {\n type ImperativePanelHandle,\n Panel,\n type PanelProps,\n} from \"react-resizable-panels\";\n\nimport splitPanelCSS from \"./SplitPanel.css\";\n\nexport type SplitPanelVariant = \"primary\" | \"secondary\" | \"tertiary\";\n\nexport interface SplitPanelProps extends PanelProps {\n /**\n * Styling variant\n * @default \"primary\"\n */\n variant?: SplitPanelVariant;\n}\n\nconst withBaseName = makePrefixer(\"saltSplitPanel\");\n\nexport const SplitPanel = forwardRef<ImperativePanelHandle, SplitPanelProps>(\n function SplitPanel(\n { id: idProp, variant = \"primary\", minSize = 10, className, ...props },\n ref,\n ) {\n const id = useId(idProp);\n const targetWindow = useWindow();\n\n useComponentCssInjection({\n testId: \"salt-split-panel\",\n css: splitPanelCSS,\n window: targetWindow,\n });\n\n return (\n <Panel\n id={id}\n minSize={minSize}\n data-variant={variant}\n className={clsx(withBaseName(), withBaseName(variant), className)}\n ref={ref}\n {...props}\n />\n );\n },\n);\n"],"names":["SplitPanel","splitPanelCSS"],"mappings":";;;;;;;;;AAuBA,MAAM,YAAA,GAAe,aAAa,gBAAgB,CAAA;AAE3C,MAAM,UAAa,GAAA,UAAA;AAAA,EACxB,SAASA,WAAAA,CACP,EAAE,EAAA,EAAI,MAAQ,EAAA,OAAA,GAAU,SAAW,EAAA,OAAA,GAAU,EAAI,EAAA,SAAA,EAAW,GAAG,KAAA,IAC/D,GACA,EAAA;AACA,IAAM,MAAA,EAAA,GAAK,MAAM,MAAM,CAAA;AACvB,IAAA,MAAM,eAAe,SAAU,EAAA;AAE/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,kBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA;AAAA,KACT,CAAA;AAED,IACE,uBAAA,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,EAAA;AAAA,QACA,OAAA;AAAA,QACA,cAAc,EAAA,OAAA;AAAA,QACd,WAAW,IAAK,CAAA,YAAA,IAAgB,YAAa,CAAA,OAAO,GAAG,SAAS,CAAA;AAAA,QAChE,GAAA;AAAA,QACC,GAAG;AAAA;AAAA,KACN;AAAA;AAGN;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
import { PanelGroup } from 'react-resizable-panels';
|
|
4
|
+
|
|
5
|
+
const OrientationContext = createContext("vertical");
|
|
6
|
+
const AppearanceContext = createContext("bordered");
|
|
7
|
+
function Splitter({
|
|
8
|
+
orientation,
|
|
9
|
+
appearance: appearanceProp,
|
|
10
|
+
...props
|
|
11
|
+
}) {
|
|
12
|
+
const appearanceContext = useContext(AppearanceContext);
|
|
13
|
+
const appearance = appearanceProp ?? appearanceContext;
|
|
14
|
+
const direction = orientation === "horizontal" ? "vertical" : "horizontal";
|
|
15
|
+
return /* @__PURE__ */ jsx(OrientationContext.Provider, { value: orientation, children: /* @__PURE__ */ jsx(AppearanceContext.Provider, { value: appearance, children: /* @__PURE__ */ jsx(
|
|
16
|
+
PanelGroup,
|
|
17
|
+
{
|
|
18
|
+
"data-orientation": orientation,
|
|
19
|
+
"data-appearance": appearance,
|
|
20
|
+
direction,
|
|
21
|
+
...props
|
|
22
|
+
}
|
|
23
|
+
) }) });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { AppearanceContext, OrientationContext, Splitter };
|
|
27
|
+
//# sourceMappingURL=Splitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Splitter.js","sources":["../src/splitter/Splitter.tsx"],"sourcesContent":["import { type ReactNode, createContext, useContext } from \"react\";\nimport { PanelGroup, type PanelGroupProps } from \"react-resizable-panels\";\n\nexport type SplitterAppearance = \"bordered\" | \"transparent\";\nexport type SplitterOrientation = \"horizontal\" | \"vertical\";\n\nexport const OrientationContext =\n createContext<SplitterOrientation>(\"vertical\");\nexport const AppearanceContext = createContext<SplitterAppearance>(\"bordered\");\n\nexport interface SplitterProps extends Omit<PanelGroupProps, \"direction\"> {\n /**\n * The orientation of the splitter.\n * Replaces `PanelGroupProps[\"direction\"]`\n */\n orientation: SplitterOrientation;\n /**\n * The appearance of the splitter.\n * If set to \"transparent\", the splitter handle will\n * be transparent, hence the background will be visible.\n * @default \"bordered\"\n */\n appearance?: SplitterAppearance;\n children: ReactNode;\n}\n\nexport function Splitter({\n orientation,\n appearance: appearanceProp,\n ...props\n}: SplitterProps) {\n const appearanceContext = useContext(AppearanceContext);\n const appearance = appearanceProp ?? appearanceContext;\n\n const direction = orientation === \"horizontal\" ? \"vertical\" : \"horizontal\";\n\n return (\n <OrientationContext.Provider value={orientation}>\n <AppearanceContext.Provider value={appearance}>\n <PanelGroup\n data-orientation={orientation}\n data-appearance={appearance}\n direction={direction}\n {...props}\n />\n </AppearanceContext.Provider>\n </OrientationContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;AAMa,MAAA,kBAAA,GACX,cAAmC,UAAU;AAClC,MAAA,iBAAA,GAAoB,cAAkC,UAAU;AAkBtE,SAAS,QAAS,CAAA;AAAA,EACvB,WAAA;AAAA,EACA,UAAY,EAAA,cAAA;AAAA,EACZ,GAAG;AACL,CAAkB,EAAA;AAChB,EAAM,MAAA,iBAAA,GAAoB,WAAW,iBAAiB,CAAA;AACtD,EAAA,MAAM,aAAa,cAAkB,IAAA,iBAAA;AAErC,EAAM,MAAA,SAAA,GAAY,WAAgB,KAAA,YAAA,GAAe,UAAa,GAAA,YAAA;AAE9D,EACE,uBAAA,GAAA,CAAC,kBAAmB,CAAA,QAAA,EAAnB,EAA4B,KAAA,EAAO,WAClC,EAAA,QAAA,kBAAA,GAAA,CAAC,iBAAkB,CAAA,QAAA,EAAlB,EAA2B,KAAA,EAAO,UACjC,EAAA,QAAA,kBAAA,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,kBAAkB,EAAA,WAAA;AAAA,MAClB,iBAAiB,EAAA,UAAA;AAAA,MACjB,SAAA;AAAA,MACC,GAAG;AAAA;AAAA,KAER,CACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function computeAccent(appearance, orientation) {
|
|
2
|
+
if (appearance === "transparent") {
|
|
3
|
+
return "none";
|
|
4
|
+
}
|
|
5
|
+
if (orientation === "horizontal") {
|
|
6
|
+
return "top-bottom";
|
|
7
|
+
}
|
|
8
|
+
return "left-right";
|
|
9
|
+
}
|
|
10
|
+
function computeVariant(appearance) {
|
|
11
|
+
return appearance === "bordered" ? "primary" : "transparent";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { computeAccent, computeVariant };
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/splitter/utils.ts"],"sourcesContent":["import type { SplitHandleBorder } from \"./SplitHandle\";\nimport type { SplitterAppearance, SplitterOrientation } from \"./Splitter\";\n\nexport function computeAccent(\n appearance: SplitterAppearance,\n orientation: SplitterOrientation,\n): SplitHandleBorder {\n if (appearance === \"transparent\") {\n return \"none\";\n }\n\n if (orientation === \"horizontal\") {\n return \"top-bottom\";\n }\n\n return \"left-right\";\n}\n\nexport function computeVariant(\n appearance: SplitterAppearance,\n): \"primary\" | \"transparent\" {\n return appearance === \"bordered\" ? \"primary\" : \"transparent\";\n}\n"],"names":[],"mappings":"AAGgB,SAAA,aAAA,CACd,YACA,WACmB,EAAA;AACnB,EAAA,IAAI,eAAe,aAAe,EAAA;AAChC,IAAO,OAAA,MAAA;AAAA;AAGT,EAAA,IAAI,gBAAgB,YAAc,EAAA;AAChC,IAAO,OAAA,YAAA;AAAA;AAGT,EAAO,OAAA,YAAA;AACT;AAEO,SAAS,eACd,UAC2B,EAAA;AAC3B,EAAO,OAAA,UAAA,KAAe,aAAa,SAAY,GAAA,aAAA;AACjD;;;;"}
|