@tremolo-ui/react 0.1.6 → 0.2.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/dist/index.cjs +166 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +109 -71
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +158 -152
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +160 -154
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +167 -145
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Knob/index.css +20 -26
- package/src/components/Knob/index.tsx +7 -7
- package/src/components/NumberInput/index.css +31 -15
- package/src/components/NumberInput/index.tsx +19 -10
- package/src/components/Piano/index.css +7 -14
- package/src/components/Piano/index.tsx +10 -7
- package/src/components/Slider/Thumb.tsx +1 -1
- package/src/components/Slider/Track.tsx +1 -1
- package/src/components/Slider/index.css +33 -8
- package/src/components/Slider/index.tsx +23 -23
- package/src/components/XYPad/Area.tsx +4 -3
- package/src/components/XYPad/Thumb.tsx +8 -4
- package/src/components/XYPad/index.css +18 -4
- package/src/components/XYPad/index.tsx +23 -17
- package/src/index.ts +14 -26
- package/src/styles/global.css +0 -4
package/dist/index.cjs
CHANGED
|
@@ -586,13 +586,6 @@ const Knob = (0, react.forwardRef)(({ value, min, max, step = 1, skew = 1, defau
|
|
|
586
586
|
stroke: inactiveLine || "currentColor",
|
|
587
587
|
strokeWidth: lineWeight
|
|
588
588
|
}),
|
|
589
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
590
|
-
className: (0, clsx.default)("tremolo-knob-active-line", classes?.activeLine),
|
|
591
|
-
d: `M ${x2} ${y2} A ${center} ${center} -135 ${r3 - r2 > 180 ? 1 : 0} 1 ${x3}, ${y3}`,
|
|
592
|
-
fill: "none",
|
|
593
|
-
stroke: activeLine || "currentColor",
|
|
594
|
-
strokeWidth: lineWeight
|
|
595
|
-
}),
|
|
596
589
|
startValue < max && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
597
590
|
className: (0, clsx.default)("tremolo-knob-inactive-line", classes?.inactiveLine),
|
|
598
591
|
d: `M ${x3} ${y3} A ${center} ${center} -135 ${r4 - r3 > 180 ? 1 : 0} 1 ${x4}, ${y4}`,
|
|
@@ -600,6 +593,13 @@ const Knob = (0, react.forwardRef)(({ value, min, max, step = 1, skew = 1, defau
|
|
|
600
593
|
stroke: inactiveLine || "currentColor",
|
|
601
594
|
strokeWidth: lineWeight
|
|
602
595
|
}),
|
|
596
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
597
|
+
className: (0, clsx.default)("tremolo-knob-active-line", classes?.activeLine),
|
|
598
|
+
d: `M ${x2} ${y2} A ${center} ${center} -135 ${r3 - r2 > 180 ? 1 : 0} 1 ${x3}, ${y3}`,
|
|
599
|
+
fill: "none",
|
|
600
|
+
stroke: activeLine || "currentColor",
|
|
601
|
+
strokeWidth: lineWeight
|
|
602
|
+
}),
|
|
603
603
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
604
604
|
className: (0, clsx.default)("tremolo-knob-thumb", classes?.thumb),
|
|
605
605
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
@@ -745,6 +745,111 @@ function useNumberInputContext(selector) {
|
|
|
745
745
|
return (0, zustand.useStore)(store, selector);
|
|
746
746
|
}
|
|
747
747
|
|
|
748
|
+
//#endregion
|
|
749
|
+
//#region src/hooks/useInterval.ts
|
|
750
|
+
/**
|
|
751
|
+
* @category hooks
|
|
752
|
+
*/
|
|
753
|
+
function useInterval(callback, delay) {
|
|
754
|
+
const savedCallback = (0, react.useRef)(callback);
|
|
755
|
+
(0, react.useEffect)(() => {
|
|
756
|
+
savedCallback.current = callback;
|
|
757
|
+
}, [callback]);
|
|
758
|
+
(0, react.useEffect)(() => {
|
|
759
|
+
if (delay === null) return;
|
|
760
|
+
const id = setInterval(() => {
|
|
761
|
+
savedCallback.current();
|
|
762
|
+
}, delay);
|
|
763
|
+
return () => {
|
|
764
|
+
clearInterval(id);
|
|
765
|
+
};
|
|
766
|
+
}, [delay]);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
//#endregion
|
|
770
|
+
//#region src/hooks/useLongPress.ts
|
|
771
|
+
/**
|
|
772
|
+
* @category hooks
|
|
773
|
+
*/
|
|
774
|
+
function useLongPress(callback, initialDelay = 500, interval = 40) {
|
|
775
|
+
const [pressed, setPressed] = (0, react.useState)(false);
|
|
776
|
+
const [delay, setDelay] = (0, react.useState)(initialDelay);
|
|
777
|
+
useInterval(() => {
|
|
778
|
+
callback();
|
|
779
|
+
setDelay(interval);
|
|
780
|
+
}, pressed ? delay : null);
|
|
781
|
+
useEventListener(globalThis.window, "pointerup", () => {
|
|
782
|
+
setPressed(false);
|
|
783
|
+
setDelay(initialDelay);
|
|
784
|
+
});
|
|
785
|
+
return (0, react.useCallback)(() => {
|
|
786
|
+
callback();
|
|
787
|
+
setPressed(true);
|
|
788
|
+
}, [callback]);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
//#endregion
|
|
792
|
+
//#region src/components/NumberInput/DecrementStepper.tsx
|
|
793
|
+
/** @category NumberInput */
|
|
794
|
+
function DecrementStepper({ size = 12, children, className,...props }) {
|
|
795
|
+
const min = useNumberInputContext((s) => s.min);
|
|
796
|
+
const valueAsNumber = useNumberInputContext((s) => s.valueAsNumber);
|
|
797
|
+
const readonly = useNumberInputContext((s) => s.readonly);
|
|
798
|
+
const keepWithinRange = useNumberInputContext((s) => s.keepWithinRange);
|
|
799
|
+
const press = useLongPress(useNumberInputContext((s) => s.decrement));
|
|
800
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
801
|
+
className: (0, clsx.default)("tremolo-number-input-decrement-stepper", className),
|
|
802
|
+
role: "button",
|
|
803
|
+
tabIndex: -1,
|
|
804
|
+
"aria-disabled": keepWithinRange && valueAsNumber <= (min ?? Number.MIN_SAFE_INTEGER),
|
|
805
|
+
"aria-readonly": readonly,
|
|
806
|
+
onPointerDown: press,
|
|
807
|
+
...props,
|
|
808
|
+
children: children || /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
809
|
+
width: size,
|
|
810
|
+
height: size,
|
|
811
|
+
viewBox: "0 0 24 24",
|
|
812
|
+
fill: "none",
|
|
813
|
+
stroke: "currentColor",
|
|
814
|
+
strokeWidth: "2",
|
|
815
|
+
strokeLinecap: "round",
|
|
816
|
+
strokeLinejoin: "round",
|
|
817
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("polyline", { points: "6 9 12 15 18 9" })
|
|
818
|
+
})
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
//#endregion
|
|
823
|
+
//#region src/components/NumberInput/IncrementStepper.tsx
|
|
824
|
+
/** @category NumberInput */
|
|
825
|
+
function IncrementStepper({ size = 12, children, className,...props }) {
|
|
826
|
+
const max = useNumberInputContext((s) => s.max);
|
|
827
|
+
const valueAsNumber = useNumberInputContext((s) => s.valueAsNumber);
|
|
828
|
+
const readonly = useNumberInputContext((s) => s.readonly);
|
|
829
|
+
const keepWithinRange = useNumberInputContext((s) => s.keepWithinRange);
|
|
830
|
+
const press = useLongPress(useNumberInputContext((s) => s.increment));
|
|
831
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
832
|
+
className: (0, clsx.default)("tremolo-number-input-increment-stepper", className),
|
|
833
|
+
role: "button",
|
|
834
|
+
tabIndex: -1,
|
|
835
|
+
"aria-disabled": keepWithinRange && valueAsNumber >= (max ?? Number.MAX_SAFE_INTEGER),
|
|
836
|
+
"aria-readonly": readonly,
|
|
837
|
+
onPointerDown: press,
|
|
838
|
+
...props,
|
|
839
|
+
children: children || /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
840
|
+
width: size,
|
|
841
|
+
height: size,
|
|
842
|
+
viewBox: "0 0 24 24",
|
|
843
|
+
fill: "none",
|
|
844
|
+
stroke: "currentColor",
|
|
845
|
+
strokeWidth: "2",
|
|
846
|
+
strokeLinecap: "round",
|
|
847
|
+
strokeLinejoin: "round",
|
|
848
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("polyline", { points: "18 15 12 9 6 15" })
|
|
849
|
+
})
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
|
|
748
853
|
//#endregion
|
|
749
854
|
//#region src/components/NumberInput/InternalInput.tsx
|
|
750
855
|
const InternalInput = (0, react.forwardRef)(({ disabled, readonly, selectWithFocus, blurOnEnter, clampValueOnBlur, wheel, keyboard, className, onChange, onFocus, onBlur, onKeyDown, children: _children,...props }, ref) => {
|
|
@@ -886,118 +991,9 @@ function Stepper({ dynamic = true, children, className,...props }) {
|
|
|
886
991
|
});
|
|
887
992
|
}
|
|
888
993
|
|
|
889
|
-
//#endregion
|
|
890
|
-
//#region src/hooks/useInterval.ts
|
|
891
|
-
/**
|
|
892
|
-
* @category hooks
|
|
893
|
-
*/
|
|
894
|
-
function useInterval(callback, delay) {
|
|
895
|
-
const savedCallback = (0, react.useRef)(callback);
|
|
896
|
-
(0, react.useEffect)(() => {
|
|
897
|
-
savedCallback.current = callback;
|
|
898
|
-
}, [callback]);
|
|
899
|
-
(0, react.useEffect)(() => {
|
|
900
|
-
if (delay === null) return;
|
|
901
|
-
const id = setInterval(() => {
|
|
902
|
-
savedCallback.current();
|
|
903
|
-
}, delay);
|
|
904
|
-
return () => {
|
|
905
|
-
clearInterval(id);
|
|
906
|
-
};
|
|
907
|
-
}, [delay]);
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
//#endregion
|
|
911
|
-
//#region src/hooks/useLongPress.ts
|
|
912
|
-
/**
|
|
913
|
-
* @category hooks
|
|
914
|
-
*/
|
|
915
|
-
function useLongPress(callback, initialDelay = 500, interval = 40) {
|
|
916
|
-
const [pressed, setPressed] = (0, react.useState)(false);
|
|
917
|
-
const [delay, setDelay] = (0, react.useState)(initialDelay);
|
|
918
|
-
useInterval(() => {
|
|
919
|
-
callback();
|
|
920
|
-
setDelay(interval);
|
|
921
|
-
}, pressed ? delay : null);
|
|
922
|
-
useEventListener(globalThis.window, "pointerup", () => {
|
|
923
|
-
setPressed(false);
|
|
924
|
-
setDelay(initialDelay);
|
|
925
|
-
});
|
|
926
|
-
return (0, react.useCallback)(() => {
|
|
927
|
-
callback();
|
|
928
|
-
setPressed(true);
|
|
929
|
-
}, [callback]);
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
//#endregion
|
|
933
|
-
//#region src/components/NumberInput/IncrementStepper.tsx
|
|
934
|
-
/** @category NumberInput */
|
|
935
|
-
function IncrementStepper({ size = 12, children, className,...props }) {
|
|
936
|
-
const max = useNumberInputContext((s) => s.max);
|
|
937
|
-
const valueAsNumber = useNumberInputContext((s) => s.valueAsNumber);
|
|
938
|
-
const readonly = useNumberInputContext((s) => s.readonly);
|
|
939
|
-
const keepWithinRange = useNumberInputContext((s) => s.keepWithinRange);
|
|
940
|
-
const press = useLongPress(useNumberInputContext((s) => s.increment));
|
|
941
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
942
|
-
className: (0, clsx.default)("tremolo-number-input-increment-stepper", className),
|
|
943
|
-
role: "button",
|
|
944
|
-
tabIndex: -1,
|
|
945
|
-
"aria-disabled": keepWithinRange && valueAsNumber >= (max ?? Number.MAX_SAFE_INTEGER),
|
|
946
|
-
"aria-readonly": readonly,
|
|
947
|
-
onPointerDown: press,
|
|
948
|
-
...props,
|
|
949
|
-
children: children || /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
950
|
-
width: size,
|
|
951
|
-
height: size,
|
|
952
|
-
viewBox: "0 0 24 24",
|
|
953
|
-
fill: "none",
|
|
954
|
-
stroke: "currentColor",
|
|
955
|
-
strokeWidth: "2",
|
|
956
|
-
strokeLinecap: "round",
|
|
957
|
-
strokeLinejoin: "round",
|
|
958
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("polyline", { points: "18 15 12 9 6 15" })
|
|
959
|
-
})
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
//#endregion
|
|
964
|
-
//#region src/components/NumberInput/DecrementStepper.tsx
|
|
965
|
-
/** @category NumberInput */
|
|
966
|
-
function DecrementStepper({ size = 12, children, className,...props }) {
|
|
967
|
-
const min = useNumberInputContext((s) => s.min);
|
|
968
|
-
const valueAsNumber = useNumberInputContext((s) => s.valueAsNumber);
|
|
969
|
-
const readonly = useNumberInputContext((s) => s.readonly);
|
|
970
|
-
const keepWithinRange = useNumberInputContext((s) => s.keepWithinRange);
|
|
971
|
-
const press = useLongPress(useNumberInputContext((s) => s.decrement));
|
|
972
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
973
|
-
className: (0, clsx.default)("tremolo-number-input-decrement-stepper", className),
|
|
974
|
-
role: "button",
|
|
975
|
-
tabIndex: -1,
|
|
976
|
-
"aria-disabled": keepWithinRange && valueAsNumber <= (min ?? Number.MIN_SAFE_INTEGER),
|
|
977
|
-
"aria-readonly": readonly,
|
|
978
|
-
onPointerDown: press,
|
|
979
|
-
...props,
|
|
980
|
-
children: children || /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
981
|
-
width: size,
|
|
982
|
-
height: size,
|
|
983
|
-
viewBox: "0 0 24 24",
|
|
984
|
-
fill: "none",
|
|
985
|
-
stroke: "currentColor",
|
|
986
|
-
strokeWidth: "2",
|
|
987
|
-
strokeLinecap: "round",
|
|
988
|
-
strokeLinejoin: "round",
|
|
989
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("polyline", { points: "6 9 12 15 18 9" })
|
|
990
|
-
})
|
|
991
|
-
});
|
|
992
|
-
}
|
|
993
|
-
|
|
994
994
|
//#endregion
|
|
995
995
|
//#region src/components/NumberInput/index.tsx
|
|
996
|
-
|
|
997
|
-
* Input with some useful functions for entering numerical values.
|
|
998
|
-
* @category NumberInput
|
|
999
|
-
*/
|
|
1000
|
-
const NumberInput = (0, react.forwardRef)(({ value, min, max, step = 1, units, readonly = false, disabled = false, digit, variant = "outline", selectWithFocus = "none", blurOnEnter = true, keepWithinRange = true, clampValueOnBlur = true, wheel = ["raw", 1], keyboard = ["raw", 1], activeColor, wrapperClassName, className, onChange, onFocus, onBlur, children,...props }, forwardedRef) => {
|
|
996
|
+
const NumberInputImpl = (0, react.forwardRef)(({ value, min, max, step = 1, units, readonly = false, disabled = false, digit, variant = "outline", selectWithFocus = "none", blurOnEnter = true, keepWithinRange = true, clampValueOnBlur = true, wheel = ["raw", 1], keyboard = ["raw", 1], activeColor, wrapperClassName, className, onChange, onFocus, onBlur, children,...props }, forwardedRef) => {
|
|
1001
997
|
const colors = { "--active-color": activeColor };
|
|
1002
998
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NumberInputProvider, {
|
|
1003
999
|
value: String(value),
|
|
@@ -1033,6 +1029,15 @@ const NumberInput = (0, react.forwardRef)(({ value, min, max, step = 1, units, r
|
|
|
1033
1029
|
})
|
|
1034
1030
|
});
|
|
1035
1031
|
});
|
|
1032
|
+
/**
|
|
1033
|
+
* Input with some useful functions for entering numerical values.
|
|
1034
|
+
* @category NumberInput
|
|
1035
|
+
*/
|
|
1036
|
+
const NumberInput = Object.assign(NumberInputImpl, {
|
|
1037
|
+
Stepper,
|
|
1038
|
+
IncrementStepper,
|
|
1039
|
+
DecrementStepper
|
|
1040
|
+
});
|
|
1036
1041
|
|
|
1037
1042
|
//#endregion
|
|
1038
1043
|
//#region src/hooks/useDragWithElement.ts
|
|
@@ -1254,11 +1259,7 @@ function getNoteRangeArray(noteRange) {
|
|
|
1254
1259
|
return Array.from({ length: noteRange.last - noteRange.first + 1 }, (_, i) => i + noteRange.first);
|
|
1255
1260
|
}
|
|
1256
1261
|
const blackPerWhiteWidth = defaultBlackKeyWidth / defaultWhiteKeyWidth;
|
|
1257
|
-
|
|
1258
|
-
* Customizable piano component.
|
|
1259
|
-
* @category Piano
|
|
1260
|
-
*/
|
|
1261
|
-
const Piano = (0, react.forwardRef)(({ noteRange, glissando = true, midiMax = 127, keyboardShortcuts, fill = false, height = fill ? "100%" : 160, whiteNoteWidth: _whiteNoteWidth = defaultWhiteKeyWidth, style, className, onPlayNote, onStopNote, label, children, onPointerDown,...props }, forwardedRef) => {
|
|
1262
|
+
const PianoImpl = (0, react.forwardRef)(({ noteRange, glissando = true, midiMax = 127, keyboardShortcuts, fill = false, height = fill ? "100%" : 160, whiteNoteWidth: _whiteNoteWidth = defaultWhiteKeyWidth, style, className, onPlayNote, onStopNote, label, children, onPointerDown,...props }, forwardedRef) => {
|
|
1262
1263
|
const [whiteNoteWidth, setWhiteNoteWidth] = (0, react.useState)(_whiteNoteWidth);
|
|
1263
1264
|
const keyRefs = (0, react.useRef)([]);
|
|
1264
1265
|
for (let i = 0; i < noteRange.last - noteRange.first + 1; i++) keyRefs.current[i] = (0, react.createRef)();
|
|
@@ -1439,6 +1440,15 @@ const Piano = (0, react.forwardRef)(({ noteRange, glissando = true, midiMax = 12
|
|
|
1439
1440
|
})
|
|
1440
1441
|
});
|
|
1441
1442
|
});
|
|
1443
|
+
/**
|
|
1444
|
+
* Customizable piano component.
|
|
1445
|
+
* @category Piano
|
|
1446
|
+
*/
|
|
1447
|
+
const Piano = Object.assign(PianoImpl, {
|
|
1448
|
+
WhiteKey,
|
|
1449
|
+
BlackKey,
|
|
1450
|
+
KeyLabel
|
|
1451
|
+
});
|
|
1442
1452
|
|
|
1443
1453
|
//#endregion
|
|
1444
1454
|
//#region src/components/Slider/context.tsx
|
|
@@ -1575,7 +1585,7 @@ function Scale({ gap = 6, options, children, className, style,...props }) {
|
|
|
1575
1585
|
/** @category Slider */
|
|
1576
1586
|
const defaultThumbSize = 22;
|
|
1577
1587
|
/** @category Slider */
|
|
1578
|
-
const
|
|
1588
|
+
const Thumb$1 = (0, react.forwardRef)(({ size, width = defaultThumbSize, height = defaultThumbSize, color, children, className, style, __percent }, ref) => {
|
|
1579
1589
|
const wrapperRef = (0, react.useRef)(null);
|
|
1580
1590
|
const vertical = useSliderContext((s) => s.vertical);
|
|
1581
1591
|
const disabled = useSliderContext((s) => s.disabled);
|
|
@@ -1617,7 +1627,7 @@ const SliderThumb = (0, react.forwardRef)(({ size, width = defaultThumbSize, hei
|
|
|
1617
1627
|
const defaultLength = 140;
|
|
1618
1628
|
const defaultThickness = 10;
|
|
1619
1629
|
/** @category Slider */
|
|
1620
|
-
function
|
|
1630
|
+
function Track({ length = defaultLength, thickness = defaultThickness, active, inactive, children, className, style, defaultStyle = true, __thumb, __percent = 0,...props }) {
|
|
1621
1631
|
const vertical = useSliderContext((s) => s.vertical);
|
|
1622
1632
|
const reverse = useSliderContext((s) => s.reverse);
|
|
1623
1633
|
const disabled = useSliderContext((s) => s.disabled);
|
|
@@ -1645,11 +1655,7 @@ function SliderTrack({ length = defaultLength, thickness = defaultThickness, act
|
|
|
1645
1655
|
|
|
1646
1656
|
//#endregion
|
|
1647
1657
|
//#region src/components/Slider/index.tsx
|
|
1648
|
-
|
|
1649
|
-
* Customizable slider
|
|
1650
|
-
* @category Slider
|
|
1651
|
-
*/
|
|
1652
|
-
const Slider = (0, react.forwardRef)(({ value, min, max, step = 1, skew = 1, vertical = false, reverse = false, bodyNoSelect = true, wheel = ["raw", 1], keyboard = ["raw", 1], disabled = false, readonly = false, onChange, onDragStart, onDragEnd, className, style, children, onFocus, onBlur, onPointerDown, onKeyDown,...props }, forwardedRef) => {
|
|
1658
|
+
const SliderImpl = (0, react.forwardRef)(({ value, min, max, step = 1, skew = 1, vertical = false, reverse = false, bodyNoSelect = true, wheel = ["raw", 1], keyboard = ["raw", 1], disabled = false, readonly = false, onChange, onDragStart, onDragEnd, className, style, children, onFocus, onBlur, onPointerDown, onKeyDown,...props }, forwardedRef) => {
|
|
1653
1659
|
const trackElementRef = (0, react.useRef)(null);
|
|
1654
1660
|
const thumbRef = (0, react.useRef)(null);
|
|
1655
1661
|
const p = (0, __tremolo_ui_functions.toFixed)((0, __tremolo_ui_functions.normalizeValue)(value, min, max, skew) * 100);
|
|
@@ -1660,8 +1666,8 @@ const Slider = (0, react.forwardRef)(({ value, min, max, step = 1, skew = 1, ver
|
|
|
1660
1666
|
let thumbProps = {};
|
|
1661
1667
|
let scaleComponent = void 0;
|
|
1662
1668
|
if (children != void 0) react.default.Children.forEach(children, (child) => {
|
|
1663
|
-
if (react.default.isValidElement(child)) if (child.type ==
|
|
1664
|
-
else if (child.type ==
|
|
1669
|
+
if (react.default.isValidElement(child)) if (child.type == Thumb$1) thumbProps = child.props;
|
|
1670
|
+
else if (child.type == Track) trackProps = child.props;
|
|
1665
1671
|
else if (child.type == Scale) scaleComponent = child;
|
|
1666
1672
|
else throw new Error("only <SliderThumb> or <SliderTrack>");
|
|
1667
1673
|
else throw new Error("children is an invalid element.");
|
|
@@ -1810,9 +1816,9 @@ const Slider = (0, react.forwardRef)(({ value, min, max, step = 1, skew = 1, ver
|
|
|
1810
1816
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1811
1817
|
className: "tremolo-slider-track-wrapper",
|
|
1812
1818
|
ref: trackElementRef,
|
|
1813
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1819
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Track, {
|
|
1814
1820
|
__percent: percent,
|
|
1815
|
-
__thumb: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1821
|
+
__thumb: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Thumb$1, {
|
|
1816
1822
|
ref: thumbRef,
|
|
1817
1823
|
__percent: percent,
|
|
1818
1824
|
...thumbProps
|
|
@@ -1824,6 +1830,16 @@ const Slider = (0, react.forwardRef)(({ value, min, max, step = 1, skew = 1, ver
|
|
|
1824
1830
|
})
|
|
1825
1831
|
});
|
|
1826
1832
|
});
|
|
1833
|
+
/**
|
|
1834
|
+
* Customizable slider
|
|
1835
|
+
* @category Slider
|
|
1836
|
+
*/
|
|
1837
|
+
const Slider = Object.assign(SliderImpl, {
|
|
1838
|
+
Thumb: Thumb$1,
|
|
1839
|
+
Track,
|
|
1840
|
+
Scale,
|
|
1841
|
+
ScaleOption
|
|
1842
|
+
});
|
|
1827
1843
|
|
|
1828
1844
|
//#endregion
|
|
1829
1845
|
//#region src/components/WheelObserver/index.tsx
|
|
@@ -1842,7 +1858,7 @@ function WheelObserver(props) {
|
|
|
1842
1858
|
//#endregion
|
|
1843
1859
|
//#region src/components/XYPad/Area.tsx
|
|
1844
1860
|
/** @category XYPad */
|
|
1845
|
-
function
|
|
1861
|
+
function Area({ width = 120, height = 120, color, children, className, style, __thumb,...props }) {
|
|
1846
1862
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1847
1863
|
className: (0, clsx.default)("tremolo-xy-pad-area", className),
|
|
1848
1864
|
style: {
|
|
@@ -1859,7 +1875,7 @@ function XYPadArea({ width = 120, height = 120, color, children, className, styl
|
|
|
1859
1875
|
//#endregion
|
|
1860
1876
|
//#region src/components/XYPad/Thumb.tsx
|
|
1861
1877
|
/** @category XYPad */
|
|
1862
|
-
const
|
|
1878
|
+
const Thumb = (0, react.forwardRef)(({ size, width = 22, height = 22, color, children, wrapperClassName, wrapperStyle, className, style, __disabled, __readonly, __css,...props }, ref) => {
|
|
1863
1879
|
const wrapperRef = (0, react.useRef)(null);
|
|
1864
1880
|
(0, react.useImperativeHandle)(ref, () => {
|
|
1865
1881
|
return {
|
|
@@ -1883,6 +1899,7 @@ const XYPadThumb = (0, react.forwardRef)(({ size, width = 22, height = 22, color
|
|
|
1883
1899
|
className: (0, clsx.default)("tremolo-xy-pad-thumb", className),
|
|
1884
1900
|
tabIndex: 0,
|
|
1885
1901
|
"aria-disabled": __disabled,
|
|
1902
|
+
"aria-readonly": __readonly,
|
|
1886
1903
|
style: {
|
|
1887
1904
|
"--color": color,
|
|
1888
1905
|
width: size ?? width,
|
|
@@ -1902,11 +1919,7 @@ const defaultValueOptions = {
|
|
|
1902
1919
|
wheel: ["raw", 1],
|
|
1903
1920
|
keyboard: ["raw", 1]
|
|
1904
1921
|
};
|
|
1905
|
-
|
|
1906
|
-
* Simple XYPad
|
|
1907
|
-
* @category XYPad
|
|
1908
|
-
*/
|
|
1909
|
-
const XYPad = (0, react.forwardRef)(({ x: _x, y: _y, className, style, bodyNoSelect = true, disabled = false, readonly = false, onChange, onDragStart, onDragEnd, onPointerDown, onKeyDown, onFocus, onBlur, children,...props }, forwardedRef) => {
|
|
1922
|
+
const XYPadImpl = (0, react.forwardRef)(({ x: _x, y: _y, className, style, bodyNoSelect = true, disabled = false, readonly = false, onChange, onDragStart, onDragEnd, onPointerDown, onKeyDown, onFocus, onBlur, children,...props }, forwardedRef) => {
|
|
1910
1923
|
const x = (0, react.useMemo)(() => {
|
|
1911
1924
|
return {
|
|
1912
1925
|
...defaultValueOptions,
|
|
@@ -1928,8 +1941,8 @@ const XYPad = (0, react.forwardRef)(({ x: _x, y: _y, className, style, bodyNoSel
|
|
|
1928
1941
|
let areaProps = {};
|
|
1929
1942
|
let thumbProps = {};
|
|
1930
1943
|
if (children != void 0) react.default.Children.forEach(children, (child) => {
|
|
1931
|
-
if (react.default.isValidElement(child)) if (child.type ==
|
|
1932
|
-
else if (child.type ==
|
|
1944
|
+
if (react.default.isValidElement(child)) if (child.type == Thumb) thumbProps = child.props;
|
|
1945
|
+
else if (child.type == Area) areaProps = child.props;
|
|
1933
1946
|
else throw new Error("only <XYPadThumb> or <XYPadArea>");
|
|
1934
1947
|
else throw new Error("children is an invalid element.");
|
|
1935
1948
|
});
|
|
@@ -2067,10 +2080,11 @@ const XYPad = (0, react.forwardRef)(({ x: _x, y: _y, className, style, bodyNoSel
|
|
|
2067
2080
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2068
2081
|
className: "tremolo-xy-pad-area-wrapper",
|
|
2069
2082
|
ref: areaElementRef,
|
|
2070
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2071
|
-
__thumb: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2083
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Area, {
|
|
2084
|
+
__thumb: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Thumb, {
|
|
2072
2085
|
ref: thumbRef,
|
|
2073
2086
|
__disabled: disabled,
|
|
2087
|
+
__readonly: readonly,
|
|
2074
2088
|
__css: {
|
|
2075
2089
|
top: `${percentY}%`,
|
|
2076
2090
|
left: `${percentX}%`
|
|
@@ -2082,6 +2096,14 @@ const XYPad = (0, react.forwardRef)(({ x: _x, y: _y, className, style, bodyNoSel
|
|
|
2082
2096
|
})
|
|
2083
2097
|
});
|
|
2084
2098
|
});
|
|
2099
|
+
/**
|
|
2100
|
+
* Simple XYPad
|
|
2101
|
+
* @category XYPad
|
|
2102
|
+
*/
|
|
2103
|
+
const XYPad = Object.assign(XYPadImpl, {
|
|
2104
|
+
Thumb,
|
|
2105
|
+
Area
|
|
2106
|
+
});
|
|
2085
2107
|
|
|
2086
2108
|
//#endregion
|
|
2087
2109
|
//#region src/hooks/useAnimationFrame.ts
|
|
@@ -2176,28 +2198,16 @@ function useMIDIInput(midiAccess, onNoteOnEvent, onNoteOffEvent, onPitchBendEven
|
|
|
2176
2198
|
//#endregion
|
|
2177
2199
|
exports.AnimationCanvas = AnimationCanvas;
|
|
2178
2200
|
exports.AnimationKnob = AnimationKnob;
|
|
2179
|
-
exports.BlackKey = BlackKey;
|
|
2180
|
-
exports.DecrementStepper = DecrementStepper;
|
|
2181
2201
|
exports.DragObserver = DragObserver;
|
|
2182
|
-
exports.IncrementStepper = IncrementStepper;
|
|
2183
|
-
exports.KeyLabel = KeyLabel;
|
|
2184
2202
|
exports.Knob = Knob;
|
|
2185
2203
|
exports.NOT_SUPPORTED = NOT_SUPPORTED;
|
|
2186
2204
|
exports.NumberInput = NumberInput;
|
|
2187
2205
|
exports.PERMISSION_DENIED = PERMISSION_DENIED;
|
|
2188
2206
|
exports.Piano = Piano;
|
|
2189
2207
|
exports.SHORTCUTS = SHORTCUTS;
|
|
2190
|
-
exports.Scale = Scale;
|
|
2191
|
-
exports.ScaleOption = ScaleOption;
|
|
2192
2208
|
exports.Slider = Slider;
|
|
2193
|
-
exports.SliderThumb = SliderThumb;
|
|
2194
|
-
exports.SliderTrack = SliderTrack;
|
|
2195
|
-
exports.Stepper = Stepper;
|
|
2196
2209
|
exports.WheelObserver = WheelObserver;
|
|
2197
|
-
exports.WhiteKey = WhiteKey;
|
|
2198
2210
|
exports.XYPad = XYPad;
|
|
2199
|
-
exports.XYPadArea = XYPadArea;
|
|
2200
|
-
exports.XYPadThumb = XYPadThumb;
|
|
2201
2211
|
exports.getNoteRangeArray = getNoteRangeArray;
|
|
2202
2212
|
exports.useAnimationFrame = useAnimationFrame;
|
|
2203
2213
|
exports.useDrag = useDrag;
|