@tremolo-ui/react 0.5.0 → 0.6.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.
Files changed (76) hide show
  1. package/dist/compose-refs.cjs +72 -0
  2. package/dist/compose-refs.cjs.map +1 -0
  3. package/dist/compose-refs.d.cts +43 -0
  4. package/dist/compose-refs.d.cts.map +1 -0
  5. package/dist/compose-refs.d.ts +43 -0
  6. package/dist/compose-refs.d.ts.map +1 -0
  7. package/dist/compose-refs.js +70 -0
  8. package/dist/compose-refs.js.map +1 -0
  9. package/dist/index.cjs +1468 -534
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +1103 -435
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.ts +1103 -435
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1457 -534
  16. package/dist/index.js.map +1 -1
  17. package/package.json +28 -26
  18. package/src/components/AnimationCanvas/index.tsx +115 -76
  19. package/src/components/Knob/ActiveLine.tsx +7 -6
  20. package/src/components/Knob/InactiveLine.tsx +9 -10
  21. package/src/components/Knob/SVGRoot.tsx +5 -3
  22. package/src/components/Knob/Thumb.tsx +33 -11
  23. package/src/components/Knob/context.tsx +17 -1
  24. package/src/components/Knob/index.tsx +148 -55
  25. package/src/components/NumberInput/DecrementStepper.tsx +8 -4
  26. package/src/components/NumberInput/IncrementStepper.tsx +9 -4
  27. package/src/components/NumberInput/InputField.tsx +188 -105
  28. package/src/components/NumberInput/Stepper.tsx +123 -72
  29. package/src/components/NumberInput/{stepperButton.tsx → StepperButton.tsx} +27 -22
  30. package/src/components/NumberInput/context.tsx +35 -8
  31. package/src/components/NumberInput/index.tsx +272 -75
  32. package/src/components/Piano/index.tsx +354 -188
  33. package/src/components/PointsEditor/Background.tsx +11 -2
  34. package/src/components/PointsEditor/Container.tsx +87 -27
  35. package/src/components/PointsEditor/Point.tsx +239 -79
  36. package/src/components/PointsEditor/SelectionBox.tsx +54 -0
  37. package/src/components/PointsEditor/context.tsx +78 -10
  38. package/src/components/PointsEditor/index.tsx +440 -39
  39. package/src/components/Slider/Marks.tsx +48 -16
  40. package/src/components/Slider/MarksOption.tsx +57 -43
  41. package/src/components/Slider/Thumb.tsx +108 -50
  42. package/src/components/Slider/Track.tsx +69 -58
  43. package/src/components/Slider/context.tsx +4 -2
  44. package/src/components/Slider/index.tsx +131 -65
  45. package/src/components/Slider/type.ts +26 -8
  46. package/src/components/XYPad/Area.tsx +45 -35
  47. package/src/components/XYPad/Thumb.tsx +135 -62
  48. package/src/components/XYPad/context.tsx +4 -1
  49. package/src/components/XYPad/index.tsx +180 -48
  50. package/src/components/_util/Placement.tsx +68 -0
  51. package/src/components/_util/VisuallyHiddenRangeInput.tsx +24 -0
  52. package/src/components/_util/css-length.ts +13 -0
  53. package/src/{components/_util/composeRefs.tsx → compose-refs/index.tsx} +33 -5
  54. package/src/hooks/_internal/useCallbackRef.ts +3 -1
  55. package/src/hooks/_internal/useCheckSteps.ts +170 -0
  56. package/src/hooks/useAnimationFrame.ts +17 -7
  57. package/src/hooks/useDrag.ts +38 -8
  58. package/src/hooks/useDragValue.ts +54 -9
  59. package/src/hooks/useEventListener.ts +10 -6
  60. package/src/hooks/useLongPress.ts +42 -8
  61. package/src/hooks/useMIDIAccess.ts +82 -11
  62. package/src/hooks/useMIDIInput.ts +45 -13
  63. package/src/hooks/useMIDIMessage.ts +23 -5
  64. package/src/index.ts +38 -21
  65. package/src/input-event.ts +32 -0
  66. package/dist/index.css +0 -501
  67. package/src/Globals.d.ts +0 -3
  68. package/src/components/Knob/index.css +0 -81
  69. package/src/components/NumberInput/index.css +0 -121
  70. package/src/components/Piano/index.css +0 -90
  71. package/src/components/PointsEditor/index.css +0 -35
  72. package/src/components/Slider/index.css +0 -125
  73. package/src/components/XYPad/index.css +0 -60
  74. package/src/components/_util/index.ts +0 -28
  75. package/src/styles/global.css +0 -19
  76. /package/src/components/Piano/{keyboardShortcuts.ts → keyboard-shortcuts.ts} +0 -0
@@ -1,90 +0,0 @@
1
- .tremolo-piano {
2
- display: inline-block;
3
- box-sizing: border-box;
4
- user-select: none;
5
- touch-action: none;
6
- position: relative;
7
- }
8
-
9
- .tremolo-piano-white-key {
10
- --bg: oklch(100% 0 0);
11
- --color: oklch(0% 0 0);
12
- --active-bg: oklch(92% 0 0);
13
- --active-color: oklch(0% 0 0);
14
-
15
- box-sizing: border-box;
16
- position: absolute;
17
- background-color: var(--bg);
18
- -webkit-tap-highlight-color: transparent;
19
- color: var(--color);
20
- border: 1px solid #555;
21
- border-radius: 0px 0px 8px 8px;
22
- cursor: pointer;
23
- z-index: 1;
24
-
25
- &[data-active='true'] {
26
- background-color: var(--active-bg);
27
- color: var(--active-color);
28
- }
29
-
30
- &[aria-disabled='true'] {
31
- cursor: not-allowed;
32
- }
33
- }
34
-
35
- .tremolo-piano-black-key {
36
- --color: oklch(100% 0 0);
37
- --bg: oklch(32% 0 0);
38
- --active-color: oklch(100% 0 0);
39
- --active-bg: oklch(44% 0 0);
40
-
41
- box-sizing: border-box;
42
- position: absolute;
43
- background-color: var(--bg);
44
- -webkit-tap-highlight-color: transparent;
45
- color: var(--color);
46
- border: 1px solid #555;
47
- border-radius: 0px 0px 8px 8px;
48
- cursor: pointer;
49
- z-index: 2;
50
-
51
- &[data-active='true'] {
52
- background-color: var(--active-bg);
53
- color: var(--active-color);
54
- }
55
-
56
- &[aria-disabled='true'] {
57
- cursor: not-allowed;
58
- }
59
- }
60
-
61
- .tremolo-piano-key-label-wrapper {
62
- display: flex;
63
- justify-content: center;
64
- align-items: end;
65
- height: 100%;
66
- }
67
-
68
- .tremolo-piano-key-label {
69
- box-sizing: content-box;
70
- display: flex;
71
- justify-content: center;
72
- align-items: center;
73
- font-size: 0.6rem;
74
- height: 10px;
75
- margin-bottom: 10px;
76
- padding: 4px;
77
- border-radius: 4px;
78
- border: 1px solid #888;
79
- aspect-ratio: 1;
80
- max-width: calc(100% - 16px);
81
- }
82
-
83
- :where(.dark, [data-theme='dark']) {
84
- .tremolo-piano-white-key {
85
- --bg: oklch(80% 0 0);
86
- --color: oklch(0% 0 0);
87
- --active-bg: oklch(72% 0 0);
88
- --active-color: oklch(0% 0 0);
89
- }
90
- }
@@ -1,35 +0,0 @@
1
- .tremolo-points-editor {
2
- position: relative;
3
- }
4
-
5
- .tremolo-points-editor-background {
6
- position: absolute;
7
- inset: 0;
8
- z-index: 0;
9
- }
10
-
11
- .tremolo-points-editor-container {
12
- position: absolute;
13
- inset: 0;
14
- z-index: 10;
15
- }
16
-
17
- .tremolo-points-editor-point {
18
- --color: oklch(59.5% 0.17548 266.373);
19
-
20
- position: absolute;
21
- border-radius: 50%;
22
- outline: none;
23
- cursor: grab;
24
- background-color: var(--color);
25
- translate: -50% -50%;
26
-
27
- &[data-dragging='true'] {
28
- cursor: inherit;
29
- }
30
-
31
- /* Dragging does nothing while readonly, so do not offer to. */
32
- &[aria-readonly='true'] {
33
- cursor: default;
34
- }
35
- }
@@ -1,125 +0,0 @@
1
- .tremolo-slider {
2
- /* Half the thumb size. The thumb overhangs the ends of the track, so the
3
- slider reserves room for it. Override this when using a different size. */
4
- --thumb-size: 22px;
5
-
6
- display: inline-flex;
7
- flex-direction: column;
8
- margin: calc(var(--thumb-size) / 2);
9
- cursor: pointer;
10
- outline: 0;
11
- -webkit-tap-highlight-color: transparent;
12
-
13
- &[data-vertical='true'] {
14
- flex-direction: row;
15
- }
16
-
17
- &[aria-readonly='true'] {
18
- cursor: not-allowed;
19
- }
20
- }
21
-
22
- .tremolo-slider-thumb-wrapper {
23
- position: absolute;
24
- translate: -50% -50%;
25
- z-index: 100;
26
- }
27
-
28
- .tremolo-slider-thumb {
29
- --color: oklch(59.5% 0.17548 266.373);
30
-
31
- width: var(--thumb-size);
32
- height: var(--thumb-size);
33
-
34
- background: var(--color);
35
- border-radius: 50%;
36
- outline: none;
37
-
38
- &[aria-disabled='true'] {
39
- background: oklch(50.462% 0.03307 270.021);
40
- }
41
-
42
- &[aria-readonly='false']:focus {
43
- box-shadow: 0px 0px 0px 3px
44
- color-mix(in srgb, var(--color) 20%, transparent);
45
- }
46
- }
47
-
48
- .tremolo-slider-track {
49
- --active: oklch(69.212% 0.12903 267.633);
50
- --inactive: oklch(95% 0 0);
51
-
52
- position: relative;
53
-
54
- &[data-vertical='false'] {
55
- min-width: 50px;
56
- }
57
-
58
- &[data-vertical='true'] {
59
- min-height: 50px;
60
- }
61
-
62
- &:hover {
63
- --active: oklch(64.276% 0.15244 266.932);
64
- --inactive: #e0e0e0;
65
- }
66
-
67
- &[aria-disabled='true'] {
68
- --active: oklch(75.327% 0.01237 264.547);
69
- --inactive: oklch(89.755% 0.0001 271.152);
70
- }
71
- }
72
-
73
- .tremolo-slider-marks {
74
- display: block;
75
- position: relative;
76
- }
77
-
78
- .tremolo-slider-marks-option {
79
- display: flex;
80
- color: oklch(25.197% 0.00003 271.152);
81
- flex-direction: column;
82
- justify-content: center;
83
- align-items: center;
84
- position: absolute;
85
- translate: -50% 0;
86
- z-index: 10;
87
-
88
- &[data-vertical='true'] {
89
- flex-direction: row;
90
- translate: 0 -50%;
91
- }
92
- }
93
-
94
- .tremolo-slider-marks-option-mark {
95
- background-color: currentColor;
96
- }
97
-
98
- .tremolo-slider-marks-option-label {
99
- text-align: right;
100
- }
101
-
102
- :where(.dark, [data-theme='dark']) {
103
- .tremolo-slider-thumb {
104
- --color: oklch(64.5% 0.17548 266.373);
105
-
106
- &:hover {
107
- --color: oklch(67.5% 0.17548 266.373);
108
- }
109
- }
110
-
111
- .tremolo-slider-track {
112
- --active: oklch(59.5% 0.17548 266.373);
113
- --inactive: oklch(41.7% 0 0);
114
-
115
- &:hover {
116
- --active: oklch(62.5% 0.17548 266.373);
117
- --inactive: oklch(44.7% 0 0);
118
- }
119
-
120
- &[aria-disabled='true'] {
121
- --active: oklch(75.327% 0.01237 264.547);
122
- --inactive: oklch(89.755% 0.0001 271.152);
123
- }
124
- }
125
- }
@@ -1,60 +0,0 @@
1
- .tremolo-xy-pad {
2
- /* Half the thumb size. The thumb overhangs the edges of the area, so the
3
- pad reserves room for it. Override this when using a different size. */
4
- --thumb-size: 22px;
5
-
6
- display: inline-block;
7
- margin: calc(var(--thumb-size) / 2);
8
- cursor: pointer;
9
- -webkit-tap-highlight-color: transparent;
10
-
11
- &[aria-readonly='true'] {
12
- cursor: not-allowed;
13
- }
14
- }
15
-
16
- .tremolo-xy-pad-area {
17
- --color: oklch(95% 0 0);
18
-
19
- position: relative;
20
- background-color: var(--color);
21
- }
22
-
23
- .tremolo-xy-pad-thumb-wrapper {
24
- position: absolute;
25
- translate: -50% -50%;
26
- z-index: 100;
27
- }
28
-
29
- .tremolo-xy-pad-thumb {
30
- --color: oklch(59.5% 0.17548 266.373);
31
-
32
- width: var(--thumb-size);
33
- height: var(--thumb-size);
34
- border-radius: 50%;
35
- outline: none;
36
- background-color: var(--color);
37
-
38
- &[aria-disabled='true'] {
39
- background-color: oklch(50.462% 0.03307 270.021);
40
- }
41
-
42
- &[aria-readonly='false']:focus {
43
- box-shadow: 0px 0px 0px 3px
44
- color-mix(in srgb, var(--color) 20%, transparent);
45
- }
46
- }
47
-
48
- :where(.dark, [data-theme='dark']) {
49
- .tremolo-xy-pad-area {
50
- --color: oklch(41.7% 0 0);
51
- }
52
-
53
- .tremolo-xy-pad-thumb {
54
- --color: oklch(64.5% 0.17548 266.373);
55
-
56
- &:hover {
57
- --color: oklch(67.5% 0.17548 266.373);
58
- }
59
- }
60
- }
@@ -1,28 +0,0 @@
1
- export function addUserSelectNone() {
2
- window.document.body.classList.add('tremolo-user-select-none')
3
- }
4
-
5
- export function removeUserSelectNone() {
6
- window.document.body.classList.remove('tremolo-user-select-none')
7
- }
8
-
9
- const cursorStyles = {
10
- grabbing: 'tremolo-cursor-grabbing',
11
- grab: 'tremolo-cursor-grab',
12
- pointer: 'tremolo-cursor-pointer',
13
- move: 'tremolo-cursor-move',
14
- none: 'tremolo-cursor-none',
15
- }
16
-
17
- export type Cursor = keyof typeof cursorStyles
18
-
19
- export function setCursorStyle(type: Cursor) {
20
- resetCursorStyle()
21
- window.document.body.classList.add(cursorStyles[type])
22
- }
23
-
24
- export function resetCursorStyle() {
25
- Object.values(cursorStyles).forEach((s) => {
26
- window.document.body.classList.remove(s)
27
- })
28
- }
@@ -1,19 +0,0 @@
1
- .tremolo-user-select-none {
2
- user-select: none;
3
- }
4
-
5
- .tremolo-cursor-pointer {
6
- cursor: pointer;
7
- }
8
-
9
- .tremolo-cursor-move {
10
- cursor: move;
11
- }
12
-
13
- .tremolo-cursor-grabbing {
14
- cursor: grabbing;
15
- }
16
-
17
- .tremolo-cursor-none {
18
- cursor: none;
19
- }