@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.js
CHANGED
|
@@ -561,13 +561,6 @@ const Knob = forwardRef(({ value, min, max, step = 1, skew = 1, defaultValue = m
|
|
|
561
561
|
stroke: inactiveLine || "currentColor",
|
|
562
562
|
strokeWidth: lineWeight
|
|
563
563
|
}),
|
|
564
|
-
/* @__PURE__ */ jsx("path", {
|
|
565
|
-
className: clsx("tremolo-knob-active-line", classes?.activeLine),
|
|
566
|
-
d: `M ${x2} ${y2} A ${center} ${center} -135 ${r3 - r2 > 180 ? 1 : 0} 1 ${x3}, ${y3}`,
|
|
567
|
-
fill: "none",
|
|
568
|
-
stroke: activeLine || "currentColor",
|
|
569
|
-
strokeWidth: lineWeight
|
|
570
|
-
}),
|
|
571
564
|
startValue < max && /* @__PURE__ */ jsx("path", {
|
|
572
565
|
className: clsx("tremolo-knob-inactive-line", classes?.inactiveLine),
|
|
573
566
|
d: `M ${x3} ${y3} A ${center} ${center} -135 ${r4 - r3 > 180 ? 1 : 0} 1 ${x4}, ${y4}`,
|
|
@@ -575,6 +568,13 @@ const Knob = forwardRef(({ value, min, max, step = 1, skew = 1, defaultValue = m
|
|
|
575
568
|
stroke: inactiveLine || "currentColor",
|
|
576
569
|
strokeWidth: lineWeight
|
|
577
570
|
}),
|
|
571
|
+
/* @__PURE__ */ jsx("path", {
|
|
572
|
+
className: clsx("tremolo-knob-active-line", classes?.activeLine),
|
|
573
|
+
d: `M ${x2} ${y2} A ${center} ${center} -135 ${r3 - r2 > 180 ? 1 : 0} 1 ${x3}, ${y3}`,
|
|
574
|
+
fill: "none",
|
|
575
|
+
stroke: activeLine || "currentColor",
|
|
576
|
+
strokeWidth: lineWeight
|
|
577
|
+
}),
|
|
578
578
|
/* @__PURE__ */ jsxs("svg", {
|
|
579
579
|
className: clsx("tremolo-knob-thumb", classes?.thumb),
|
|
580
580
|
children: [/* @__PURE__ */ jsx("circle", {
|
|
@@ -720,6 +720,111 @@ function useNumberInputContext(selector) {
|
|
|
720
720
|
return useStore(store, selector);
|
|
721
721
|
}
|
|
722
722
|
|
|
723
|
+
//#endregion
|
|
724
|
+
//#region src/hooks/useInterval.ts
|
|
725
|
+
/**
|
|
726
|
+
* @category hooks
|
|
727
|
+
*/
|
|
728
|
+
function useInterval(callback, delay) {
|
|
729
|
+
const savedCallback = useRef(callback);
|
|
730
|
+
useEffect(() => {
|
|
731
|
+
savedCallback.current = callback;
|
|
732
|
+
}, [callback]);
|
|
733
|
+
useEffect(() => {
|
|
734
|
+
if (delay === null) return;
|
|
735
|
+
const id = setInterval(() => {
|
|
736
|
+
savedCallback.current();
|
|
737
|
+
}, delay);
|
|
738
|
+
return () => {
|
|
739
|
+
clearInterval(id);
|
|
740
|
+
};
|
|
741
|
+
}, [delay]);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
//#endregion
|
|
745
|
+
//#region src/hooks/useLongPress.ts
|
|
746
|
+
/**
|
|
747
|
+
* @category hooks
|
|
748
|
+
*/
|
|
749
|
+
function useLongPress(callback, initialDelay = 500, interval = 40) {
|
|
750
|
+
const [pressed, setPressed] = useState(false);
|
|
751
|
+
const [delay, setDelay] = useState(initialDelay);
|
|
752
|
+
useInterval(() => {
|
|
753
|
+
callback();
|
|
754
|
+
setDelay(interval);
|
|
755
|
+
}, pressed ? delay : null);
|
|
756
|
+
useEventListener(globalThis.window, "pointerup", () => {
|
|
757
|
+
setPressed(false);
|
|
758
|
+
setDelay(initialDelay);
|
|
759
|
+
});
|
|
760
|
+
return useCallback(() => {
|
|
761
|
+
callback();
|
|
762
|
+
setPressed(true);
|
|
763
|
+
}, [callback]);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
//#endregion
|
|
767
|
+
//#region src/components/NumberInput/DecrementStepper.tsx
|
|
768
|
+
/** @category NumberInput */
|
|
769
|
+
function DecrementStepper({ size = 12, children, className,...props }) {
|
|
770
|
+
const min = useNumberInputContext((s) => s.min);
|
|
771
|
+
const valueAsNumber = useNumberInputContext((s) => s.valueAsNumber);
|
|
772
|
+
const readonly = useNumberInputContext((s) => s.readonly);
|
|
773
|
+
const keepWithinRange = useNumberInputContext((s) => s.keepWithinRange);
|
|
774
|
+
const press = useLongPress(useNumberInputContext((s) => s.decrement));
|
|
775
|
+
return /* @__PURE__ */ jsx("div", {
|
|
776
|
+
className: clsx("tremolo-number-input-decrement-stepper", className),
|
|
777
|
+
role: "button",
|
|
778
|
+
tabIndex: -1,
|
|
779
|
+
"aria-disabled": keepWithinRange && valueAsNumber <= (min ?? Number.MIN_SAFE_INTEGER),
|
|
780
|
+
"aria-readonly": readonly,
|
|
781
|
+
onPointerDown: press,
|
|
782
|
+
...props,
|
|
783
|
+
children: children || /* @__PURE__ */ jsx("svg", {
|
|
784
|
+
width: size,
|
|
785
|
+
height: size,
|
|
786
|
+
viewBox: "0 0 24 24",
|
|
787
|
+
fill: "none",
|
|
788
|
+
stroke: "currentColor",
|
|
789
|
+
strokeWidth: "2",
|
|
790
|
+
strokeLinecap: "round",
|
|
791
|
+
strokeLinejoin: "round",
|
|
792
|
+
children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
|
|
793
|
+
})
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
//#endregion
|
|
798
|
+
//#region src/components/NumberInput/IncrementStepper.tsx
|
|
799
|
+
/** @category NumberInput */
|
|
800
|
+
function IncrementStepper({ size = 12, children, className,...props }) {
|
|
801
|
+
const max = useNumberInputContext((s) => s.max);
|
|
802
|
+
const valueAsNumber = useNumberInputContext((s) => s.valueAsNumber);
|
|
803
|
+
const readonly = useNumberInputContext((s) => s.readonly);
|
|
804
|
+
const keepWithinRange = useNumberInputContext((s) => s.keepWithinRange);
|
|
805
|
+
const press = useLongPress(useNumberInputContext((s) => s.increment));
|
|
806
|
+
return /* @__PURE__ */ jsx("div", {
|
|
807
|
+
className: clsx("tremolo-number-input-increment-stepper", className),
|
|
808
|
+
role: "button",
|
|
809
|
+
tabIndex: -1,
|
|
810
|
+
"aria-disabled": keepWithinRange && valueAsNumber >= (max ?? Number.MAX_SAFE_INTEGER),
|
|
811
|
+
"aria-readonly": readonly,
|
|
812
|
+
onPointerDown: press,
|
|
813
|
+
...props,
|
|
814
|
+
children: children || /* @__PURE__ */ jsx("svg", {
|
|
815
|
+
width: size,
|
|
816
|
+
height: size,
|
|
817
|
+
viewBox: "0 0 24 24",
|
|
818
|
+
fill: "none",
|
|
819
|
+
stroke: "currentColor",
|
|
820
|
+
strokeWidth: "2",
|
|
821
|
+
strokeLinecap: "round",
|
|
822
|
+
strokeLinejoin: "round",
|
|
823
|
+
children: /* @__PURE__ */ jsx("polyline", { points: "18 15 12 9 6 15" })
|
|
824
|
+
})
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
|
|
723
828
|
//#endregion
|
|
724
829
|
//#region src/components/NumberInput/InternalInput.tsx
|
|
725
830
|
const InternalInput = forwardRef(({ disabled, readonly, selectWithFocus, blurOnEnter, clampValueOnBlur, wheel, keyboard, className, onChange, onFocus, onBlur, onKeyDown, children: _children,...props }, ref) => {
|
|
@@ -861,118 +966,9 @@ function Stepper({ dynamic = true, children, className,...props }) {
|
|
|
861
966
|
});
|
|
862
967
|
}
|
|
863
968
|
|
|
864
|
-
//#endregion
|
|
865
|
-
//#region src/hooks/useInterval.ts
|
|
866
|
-
/**
|
|
867
|
-
* @category hooks
|
|
868
|
-
*/
|
|
869
|
-
function useInterval(callback, delay) {
|
|
870
|
-
const savedCallback = useRef(callback);
|
|
871
|
-
useEffect(() => {
|
|
872
|
-
savedCallback.current = callback;
|
|
873
|
-
}, [callback]);
|
|
874
|
-
useEffect(() => {
|
|
875
|
-
if (delay === null) return;
|
|
876
|
-
const id = setInterval(() => {
|
|
877
|
-
savedCallback.current();
|
|
878
|
-
}, delay);
|
|
879
|
-
return () => {
|
|
880
|
-
clearInterval(id);
|
|
881
|
-
};
|
|
882
|
-
}, [delay]);
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
//#endregion
|
|
886
|
-
//#region src/hooks/useLongPress.ts
|
|
887
|
-
/**
|
|
888
|
-
* @category hooks
|
|
889
|
-
*/
|
|
890
|
-
function useLongPress(callback, initialDelay = 500, interval = 40) {
|
|
891
|
-
const [pressed, setPressed] = useState(false);
|
|
892
|
-
const [delay, setDelay] = useState(initialDelay);
|
|
893
|
-
useInterval(() => {
|
|
894
|
-
callback();
|
|
895
|
-
setDelay(interval);
|
|
896
|
-
}, pressed ? delay : null);
|
|
897
|
-
useEventListener(globalThis.window, "pointerup", () => {
|
|
898
|
-
setPressed(false);
|
|
899
|
-
setDelay(initialDelay);
|
|
900
|
-
});
|
|
901
|
-
return useCallback(() => {
|
|
902
|
-
callback();
|
|
903
|
-
setPressed(true);
|
|
904
|
-
}, [callback]);
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
//#endregion
|
|
908
|
-
//#region src/components/NumberInput/IncrementStepper.tsx
|
|
909
|
-
/** @category NumberInput */
|
|
910
|
-
function IncrementStepper({ size = 12, children, className,...props }) {
|
|
911
|
-
const max = useNumberInputContext((s) => s.max);
|
|
912
|
-
const valueAsNumber = useNumberInputContext((s) => s.valueAsNumber);
|
|
913
|
-
const readonly = useNumberInputContext((s) => s.readonly);
|
|
914
|
-
const keepWithinRange = useNumberInputContext((s) => s.keepWithinRange);
|
|
915
|
-
const press = useLongPress(useNumberInputContext((s) => s.increment));
|
|
916
|
-
return /* @__PURE__ */ jsx("div", {
|
|
917
|
-
className: clsx("tremolo-number-input-increment-stepper", className),
|
|
918
|
-
role: "button",
|
|
919
|
-
tabIndex: -1,
|
|
920
|
-
"aria-disabled": keepWithinRange && valueAsNumber >= (max ?? Number.MAX_SAFE_INTEGER),
|
|
921
|
-
"aria-readonly": readonly,
|
|
922
|
-
onPointerDown: press,
|
|
923
|
-
...props,
|
|
924
|
-
children: children || /* @__PURE__ */ jsx("svg", {
|
|
925
|
-
width: size,
|
|
926
|
-
height: size,
|
|
927
|
-
viewBox: "0 0 24 24",
|
|
928
|
-
fill: "none",
|
|
929
|
-
stroke: "currentColor",
|
|
930
|
-
strokeWidth: "2",
|
|
931
|
-
strokeLinecap: "round",
|
|
932
|
-
strokeLinejoin: "round",
|
|
933
|
-
children: /* @__PURE__ */ jsx("polyline", { points: "18 15 12 9 6 15" })
|
|
934
|
-
})
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
//#endregion
|
|
939
|
-
//#region src/components/NumberInput/DecrementStepper.tsx
|
|
940
|
-
/** @category NumberInput */
|
|
941
|
-
function DecrementStepper({ size = 12, children, className,...props }) {
|
|
942
|
-
const min = useNumberInputContext((s) => s.min);
|
|
943
|
-
const valueAsNumber = useNumberInputContext((s) => s.valueAsNumber);
|
|
944
|
-
const readonly = useNumberInputContext((s) => s.readonly);
|
|
945
|
-
const keepWithinRange = useNumberInputContext((s) => s.keepWithinRange);
|
|
946
|
-
const press = useLongPress(useNumberInputContext((s) => s.decrement));
|
|
947
|
-
return /* @__PURE__ */ jsx("div", {
|
|
948
|
-
className: clsx("tremolo-number-input-decrement-stepper", className),
|
|
949
|
-
role: "button",
|
|
950
|
-
tabIndex: -1,
|
|
951
|
-
"aria-disabled": keepWithinRange && valueAsNumber <= (min ?? Number.MIN_SAFE_INTEGER),
|
|
952
|
-
"aria-readonly": readonly,
|
|
953
|
-
onPointerDown: press,
|
|
954
|
-
...props,
|
|
955
|
-
children: children || /* @__PURE__ */ jsx("svg", {
|
|
956
|
-
width: size,
|
|
957
|
-
height: size,
|
|
958
|
-
viewBox: "0 0 24 24",
|
|
959
|
-
fill: "none",
|
|
960
|
-
stroke: "currentColor",
|
|
961
|
-
strokeWidth: "2",
|
|
962
|
-
strokeLinecap: "round",
|
|
963
|
-
strokeLinejoin: "round",
|
|
964
|
-
children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
|
|
965
|
-
})
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
|
|
969
969
|
//#endregion
|
|
970
970
|
//#region src/components/NumberInput/index.tsx
|
|
971
|
-
|
|
972
|
-
* Input with some useful functions for entering numerical values.
|
|
973
|
-
* @category NumberInput
|
|
974
|
-
*/
|
|
975
|
-
const NumberInput = 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) => {
|
|
971
|
+
const NumberInputImpl = 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) => {
|
|
976
972
|
const colors = { "--active-color": activeColor };
|
|
977
973
|
return /* @__PURE__ */ jsx(NumberInputProvider, {
|
|
978
974
|
value: String(value),
|
|
@@ -1008,6 +1004,15 @@ const NumberInput = forwardRef(({ value, min, max, step = 1, units, readonly = f
|
|
|
1008
1004
|
})
|
|
1009
1005
|
});
|
|
1010
1006
|
});
|
|
1007
|
+
/**
|
|
1008
|
+
* Input with some useful functions for entering numerical values.
|
|
1009
|
+
* @category NumberInput
|
|
1010
|
+
*/
|
|
1011
|
+
const NumberInput = Object.assign(NumberInputImpl, {
|
|
1012
|
+
Stepper,
|
|
1013
|
+
IncrementStepper,
|
|
1014
|
+
DecrementStepper
|
|
1015
|
+
});
|
|
1011
1016
|
|
|
1012
1017
|
//#endregion
|
|
1013
1018
|
//#region src/hooks/useDragWithElement.ts
|
|
@@ -1229,11 +1234,7 @@ function getNoteRangeArray(noteRange) {
|
|
|
1229
1234
|
return Array.from({ length: noteRange.last - noteRange.first + 1 }, (_, i) => i + noteRange.first);
|
|
1230
1235
|
}
|
|
1231
1236
|
const blackPerWhiteWidth = defaultBlackKeyWidth / defaultWhiteKeyWidth;
|
|
1232
|
-
|
|
1233
|
-
* Customizable piano component.
|
|
1234
|
-
* @category Piano
|
|
1235
|
-
*/
|
|
1236
|
-
const Piano = 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) => {
|
|
1237
|
+
const PianoImpl = 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) => {
|
|
1237
1238
|
const [whiteNoteWidth, setWhiteNoteWidth] = useState(_whiteNoteWidth);
|
|
1238
1239
|
const keyRefs = useRef([]);
|
|
1239
1240
|
for (let i = 0; i < noteRange.last - noteRange.first + 1; i++) keyRefs.current[i] = createRef();
|
|
@@ -1414,6 +1415,15 @@ const Piano = forwardRef(({ noteRange, glissando = true, midiMax = 127, keyboard
|
|
|
1414
1415
|
})
|
|
1415
1416
|
});
|
|
1416
1417
|
});
|
|
1418
|
+
/**
|
|
1419
|
+
* Customizable piano component.
|
|
1420
|
+
* @category Piano
|
|
1421
|
+
*/
|
|
1422
|
+
const Piano = Object.assign(PianoImpl, {
|
|
1423
|
+
WhiteKey,
|
|
1424
|
+
BlackKey,
|
|
1425
|
+
KeyLabel
|
|
1426
|
+
});
|
|
1417
1427
|
|
|
1418
1428
|
//#endregion
|
|
1419
1429
|
//#region src/components/Slider/context.tsx
|
|
@@ -1550,7 +1560,7 @@ function Scale({ gap = 6, options, children, className, style,...props }) {
|
|
|
1550
1560
|
/** @category Slider */
|
|
1551
1561
|
const defaultThumbSize = 22;
|
|
1552
1562
|
/** @category Slider */
|
|
1553
|
-
const
|
|
1563
|
+
const Thumb$1 = forwardRef(({ size, width = defaultThumbSize, height = defaultThumbSize, color, children, className, style, __percent }, ref) => {
|
|
1554
1564
|
const wrapperRef = useRef(null);
|
|
1555
1565
|
const vertical = useSliderContext((s) => s.vertical);
|
|
1556
1566
|
const disabled = useSliderContext((s) => s.disabled);
|
|
@@ -1592,7 +1602,7 @@ const SliderThumb = forwardRef(({ size, width = defaultThumbSize, height = defau
|
|
|
1592
1602
|
const defaultLength = 140;
|
|
1593
1603
|
const defaultThickness = 10;
|
|
1594
1604
|
/** @category Slider */
|
|
1595
|
-
function
|
|
1605
|
+
function Track({ length = defaultLength, thickness = defaultThickness, active, inactive, children, className, style, defaultStyle = true, __thumb, __percent = 0,...props }) {
|
|
1596
1606
|
const vertical = useSliderContext((s) => s.vertical);
|
|
1597
1607
|
const reverse = useSliderContext((s) => s.reverse);
|
|
1598
1608
|
const disabled = useSliderContext((s) => s.disabled);
|
|
@@ -1620,11 +1630,7 @@ function SliderTrack({ length = defaultLength, thickness = defaultThickness, act
|
|
|
1620
1630
|
|
|
1621
1631
|
//#endregion
|
|
1622
1632
|
//#region src/components/Slider/index.tsx
|
|
1623
|
-
|
|
1624
|
-
* Customizable slider
|
|
1625
|
-
* @category Slider
|
|
1626
|
-
*/
|
|
1627
|
-
const Slider = 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) => {
|
|
1633
|
+
const SliderImpl = 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) => {
|
|
1628
1634
|
const trackElementRef = useRef(null);
|
|
1629
1635
|
const thumbRef = useRef(null);
|
|
1630
1636
|
const p = toFixed(normalizeValue(value, min, max, skew) * 100);
|
|
@@ -1635,8 +1641,8 @@ const Slider = forwardRef(({ value, min, max, step = 1, skew = 1, vertical = fal
|
|
|
1635
1641
|
let thumbProps = {};
|
|
1636
1642
|
let scaleComponent = void 0;
|
|
1637
1643
|
if (children != void 0) React.Children.forEach(children, (child) => {
|
|
1638
|
-
if (React.isValidElement(child)) if (child.type ==
|
|
1639
|
-
else if (child.type ==
|
|
1644
|
+
if (React.isValidElement(child)) if (child.type == Thumb$1) thumbProps = child.props;
|
|
1645
|
+
else if (child.type == Track) trackProps = child.props;
|
|
1640
1646
|
else if (child.type == Scale) scaleComponent = child;
|
|
1641
1647
|
else throw new Error("only <SliderThumb> or <SliderTrack>");
|
|
1642
1648
|
else throw new Error("children is an invalid element.");
|
|
@@ -1785,9 +1791,9 @@ const Slider = forwardRef(({ value, min, max, step = 1, skew = 1, vertical = fal
|
|
|
1785
1791
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1786
1792
|
className: "tremolo-slider-track-wrapper",
|
|
1787
1793
|
ref: trackElementRef,
|
|
1788
|
-
children: /* @__PURE__ */ jsx(
|
|
1794
|
+
children: /* @__PURE__ */ jsx(Track, {
|
|
1789
1795
|
__percent: percent,
|
|
1790
|
-
__thumb: /* @__PURE__ */ jsx(
|
|
1796
|
+
__thumb: /* @__PURE__ */ jsx(Thumb$1, {
|
|
1791
1797
|
ref: thumbRef,
|
|
1792
1798
|
__percent: percent,
|
|
1793
1799
|
...thumbProps
|
|
@@ -1799,6 +1805,16 @@ const Slider = forwardRef(({ value, min, max, step = 1, skew = 1, vertical = fal
|
|
|
1799
1805
|
})
|
|
1800
1806
|
});
|
|
1801
1807
|
});
|
|
1808
|
+
/**
|
|
1809
|
+
* Customizable slider
|
|
1810
|
+
* @category Slider
|
|
1811
|
+
*/
|
|
1812
|
+
const Slider = Object.assign(SliderImpl, {
|
|
1813
|
+
Thumb: Thumb$1,
|
|
1814
|
+
Track,
|
|
1815
|
+
Scale,
|
|
1816
|
+
ScaleOption
|
|
1817
|
+
});
|
|
1802
1818
|
|
|
1803
1819
|
//#endregion
|
|
1804
1820
|
//#region src/components/WheelObserver/index.tsx
|
|
@@ -1817,7 +1833,7 @@ function WheelObserver(props) {
|
|
|
1817
1833
|
//#endregion
|
|
1818
1834
|
//#region src/components/XYPad/Area.tsx
|
|
1819
1835
|
/** @category XYPad */
|
|
1820
|
-
function
|
|
1836
|
+
function Area({ width = 120, height = 120, color, children, className, style, __thumb,...props }) {
|
|
1821
1837
|
return /* @__PURE__ */ jsxs("div", {
|
|
1822
1838
|
className: clsx("tremolo-xy-pad-area", className),
|
|
1823
1839
|
style: {
|
|
@@ -1834,7 +1850,7 @@ function XYPadArea({ width = 120, height = 120, color, children, className, styl
|
|
|
1834
1850
|
//#endregion
|
|
1835
1851
|
//#region src/components/XYPad/Thumb.tsx
|
|
1836
1852
|
/** @category XYPad */
|
|
1837
|
-
const
|
|
1853
|
+
const Thumb = forwardRef(({ size, width = 22, height = 22, color, children, wrapperClassName, wrapperStyle, className, style, __disabled, __readonly, __css,...props }, ref) => {
|
|
1838
1854
|
const wrapperRef = useRef(null);
|
|
1839
1855
|
useImperativeHandle(ref, () => {
|
|
1840
1856
|
return {
|
|
@@ -1858,6 +1874,7 @@ const XYPadThumb = forwardRef(({ size, width = 22, height = 22, color, children,
|
|
|
1858
1874
|
className: clsx("tremolo-xy-pad-thumb", className),
|
|
1859
1875
|
tabIndex: 0,
|
|
1860
1876
|
"aria-disabled": __disabled,
|
|
1877
|
+
"aria-readonly": __readonly,
|
|
1861
1878
|
style: {
|
|
1862
1879
|
"--color": color,
|
|
1863
1880
|
width: size ?? width,
|
|
@@ -1877,11 +1894,7 @@ const defaultValueOptions = {
|
|
|
1877
1894
|
wheel: ["raw", 1],
|
|
1878
1895
|
keyboard: ["raw", 1]
|
|
1879
1896
|
};
|
|
1880
|
-
|
|
1881
|
-
* Simple XYPad
|
|
1882
|
-
* @category XYPad
|
|
1883
|
-
*/
|
|
1884
|
-
const XYPad = forwardRef(({ x: _x, y: _y, className, style, bodyNoSelect = true, disabled = false, readonly = false, onChange, onDragStart, onDragEnd, onPointerDown, onKeyDown, onFocus, onBlur, children,...props }, forwardedRef) => {
|
|
1897
|
+
const XYPadImpl = forwardRef(({ x: _x, y: _y, className, style, bodyNoSelect = true, disabled = false, readonly = false, onChange, onDragStart, onDragEnd, onPointerDown, onKeyDown, onFocus, onBlur, children,...props }, forwardedRef) => {
|
|
1885
1898
|
const x = useMemo(() => {
|
|
1886
1899
|
return {
|
|
1887
1900
|
...defaultValueOptions,
|
|
@@ -1903,8 +1916,8 @@ const XYPad = forwardRef(({ x: _x, y: _y, className, style, bodyNoSelect = true,
|
|
|
1903
1916
|
let areaProps = {};
|
|
1904
1917
|
let thumbProps = {};
|
|
1905
1918
|
if (children != void 0) React.Children.forEach(children, (child) => {
|
|
1906
|
-
if (React.isValidElement(child)) if (child.type ==
|
|
1907
|
-
else if (child.type ==
|
|
1919
|
+
if (React.isValidElement(child)) if (child.type == Thumb) thumbProps = child.props;
|
|
1920
|
+
else if (child.type == Area) areaProps = child.props;
|
|
1908
1921
|
else throw new Error("only <XYPadThumb> or <XYPadArea>");
|
|
1909
1922
|
else throw new Error("children is an invalid element.");
|
|
1910
1923
|
});
|
|
@@ -2042,10 +2055,11 @@ const XYPad = forwardRef(({ x: _x, y: _y, className, style, bodyNoSelect = true,
|
|
|
2042
2055
|
children: /* @__PURE__ */ jsx("div", {
|
|
2043
2056
|
className: "tremolo-xy-pad-area-wrapper",
|
|
2044
2057
|
ref: areaElementRef,
|
|
2045
|
-
children: /* @__PURE__ */ jsx(
|
|
2046
|
-
__thumb: /* @__PURE__ */ jsx(
|
|
2058
|
+
children: /* @__PURE__ */ jsx(Area, {
|
|
2059
|
+
__thumb: /* @__PURE__ */ jsx(Thumb, {
|
|
2047
2060
|
ref: thumbRef,
|
|
2048
2061
|
__disabled: disabled,
|
|
2062
|
+
__readonly: readonly,
|
|
2049
2063
|
__css: {
|
|
2050
2064
|
top: `${percentY}%`,
|
|
2051
2065
|
left: `${percentX}%`
|
|
@@ -2057,6 +2071,14 @@ const XYPad = forwardRef(({ x: _x, y: _y, className, style, bodyNoSelect = true,
|
|
|
2057
2071
|
})
|
|
2058
2072
|
});
|
|
2059
2073
|
});
|
|
2074
|
+
/**
|
|
2075
|
+
* Simple XYPad
|
|
2076
|
+
* @category XYPad
|
|
2077
|
+
*/
|
|
2078
|
+
const XYPad = Object.assign(XYPadImpl, {
|
|
2079
|
+
Thumb,
|
|
2080
|
+
Area
|
|
2081
|
+
});
|
|
2060
2082
|
|
|
2061
2083
|
//#endregion
|
|
2062
2084
|
//#region src/hooks/useAnimationFrame.ts
|
|
@@ -2149,5 +2171,5 @@ function useMIDIInput(midiAccess, onNoteOnEvent, onNoteOffEvent, onPitchBendEven
|
|
|
2149
2171
|
}
|
|
2150
2172
|
|
|
2151
2173
|
//#endregion
|
|
2152
|
-
export { AnimationCanvas, AnimationKnob,
|
|
2174
|
+
export { AnimationCanvas, AnimationKnob, DragObserver, Knob, NOT_SUPPORTED, NumberInput, PERMISSION_DENIED, Piano, SHORTCUTS, Slider, WheelObserver, XYPad, getNoteRangeArray, useAnimationFrame, useDrag, useDragWithElement, useEventListener, useInterval, useLongPress, useMIDIAccess, useMIDIInput, useMIDIMessage, useSliderContext };
|
|
2153
2175
|
//# sourceMappingURL=index.js.map
|