@mirror-physics/fractal-ui 0.2.0-next.72 → 0.2.0-next.73

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/dist/index.js CHANGED
@@ -835,6 +835,21 @@ function Slider(props) {
835
835
  clamp(nextUpper, nextLower, max)
836
836
  ]);
837
837
  };
838
+ const getKeyboardValue = (event, value) => {
839
+ const pageStep = step * 10;
840
+ const adjustments = {
841
+ ArrowDown: -step,
842
+ ArrowLeft: -step,
843
+ ArrowRight: step,
844
+ ArrowUp: step,
845
+ PageDown: -pageStep,
846
+ PageUp: pageStep
847
+ };
848
+ if (event.key === "Home") return min;
849
+ if (event.key === "End") return max;
850
+ if (!(event.key in adjustments)) return null;
851
+ return value + adjustments[event.key];
852
+ };
838
853
  return /* @__PURE__ */ jsxs8(
839
854
  "div",
840
855
  {
@@ -869,6 +884,13 @@ function Slider(props) {
869
884
  if (knobs === 2) changeRangeValue(Math.min(nextValue, secondValue), secondValue);
870
885
  else changeSingleValue(nextValue);
871
886
  },
887
+ onKeyDown: (event) => {
888
+ const nextValue = getKeyboardValue(event, firstValue);
889
+ if (nextValue === null) return;
890
+ event.preventDefault();
891
+ if (knobs === 2) changeRangeValue(Math.min(nextValue, secondValue), secondValue);
892
+ else changeSingleValue(nextValue);
893
+ },
872
894
  step,
873
895
  type: "range",
874
896
  value: firstValue
@@ -885,6 +907,12 @@ function Slider(props) {
885
907
  const nextValue = event.currentTarget.valueAsNumber;
886
908
  changeRangeValue(firstValue, Math.max(nextValue, firstValue));
887
909
  },
910
+ onKeyDown: (event) => {
911
+ const nextValue = getKeyboardValue(event, secondValue);
912
+ if (nextValue === null) return;
913
+ event.preventDefault();
914
+ changeRangeValue(firstValue, Math.max(nextValue, firstValue));
915
+ },
888
916
  step,
889
917
  type: "range",
890
918
  value: secondValue