@moises.ai/design-system 4.20.7 → 4.20.9
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/{AssistSectionsIcon-CJLASvcE.js → ScrollIcon-CdaQMO93.js} +657 -631
- package/dist/icons.js +206 -205
- package/dist/index.js +2724 -2724
- package/package.json +1 -1
- package/src/components/PanControl/PanControl.jsx +120 -31
- package/src/icons/MaximizeIcon.jsx +3 -3
- package/src/icons/ScrollIcon.jsx +23 -0
- package/src/icons.jsx +1 -0
package/package.json
CHANGED
|
@@ -27,10 +27,12 @@ export const PanControl = ({
|
|
|
27
27
|
tooltipCloseDelay = 500,
|
|
28
28
|
}) => {
|
|
29
29
|
const containerRef = useRef(null)
|
|
30
|
+
const knobRef = useRef(null)
|
|
30
31
|
const [isDragging, setIsDragging] = useState(false)
|
|
31
32
|
const styleRef = useRef(null)
|
|
32
33
|
|
|
33
34
|
const startYRef = useRef(0)
|
|
35
|
+
const activePointerIdRef = useRef(null)
|
|
34
36
|
const pendingNormRef = useRef(value)
|
|
35
37
|
const rafRef = useRef(0)
|
|
36
38
|
const openTimeoutRef = useRef(null)
|
|
@@ -44,12 +46,43 @@ export const PanControl = ({
|
|
|
44
46
|
const [knobFocused, setKnobFocused] = useState(false)
|
|
45
47
|
const [isHovering, setIsHovering] = useState(false)
|
|
46
48
|
|
|
49
|
+
const clearOpenTimeout = useCallback(() => {
|
|
50
|
+
if (openTimeoutRef.current != null) {
|
|
51
|
+
clearTimeout(openTimeoutRef.current)
|
|
52
|
+
openTimeoutRef.current = null
|
|
53
|
+
}
|
|
54
|
+
}, [])
|
|
55
|
+
|
|
56
|
+
const clearCloseTimeout = useCallback(() => {
|
|
57
|
+
if (closeTimeoutRef.current != null) {
|
|
58
|
+
clearTimeout(closeTimeoutRef.current)
|
|
59
|
+
closeTimeoutRef.current = null
|
|
60
|
+
}
|
|
61
|
+
}, [])
|
|
62
|
+
|
|
63
|
+
const endDrag = useCallback(() => {
|
|
64
|
+
const pointerId = activePointerIdRef.current
|
|
65
|
+
const knob = knobRef.current
|
|
66
|
+
if (pointerId != null && knob?.hasPointerCapture?.(pointerId)) {
|
|
67
|
+
try {
|
|
68
|
+
knob.releasePointerCapture(pointerId)
|
|
69
|
+
} catch {
|
|
70
|
+
// Capture may already be gone (lostpointercapture / interrupt).
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
activePointerIdRef.current = null
|
|
74
|
+
setIsDragging(false)
|
|
75
|
+
}, [])
|
|
76
|
+
|
|
47
77
|
useEffect(() => {
|
|
48
78
|
if (disabled) {
|
|
79
|
+
endDrag()
|
|
80
|
+
clearOpenTimeout()
|
|
81
|
+
clearCloseTimeout()
|
|
49
82
|
setIsHovering(false)
|
|
50
83
|
setKnobFocused(false)
|
|
51
84
|
}
|
|
52
|
-
}, [disabled])
|
|
85
|
+
}, [disabled, endDrag, clearOpenTimeout, clearCloseTimeout])
|
|
53
86
|
|
|
54
87
|
useEffect(() => {
|
|
55
88
|
return () => {
|
|
@@ -59,17 +92,13 @@ export const PanControl = ({
|
|
|
59
92
|
}, [])
|
|
60
93
|
|
|
61
94
|
useEffect(() => {
|
|
62
|
-
if (isDragging)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
document.head.removeChild(styleRef.current)
|
|
70
|
-
styleRef.current = null
|
|
71
|
-
}
|
|
72
|
-
}
|
|
95
|
+
if (!isDragging) return undefined
|
|
96
|
+
|
|
97
|
+
const style = document.createElement('style')
|
|
98
|
+
style.textContent = '* { cursor: ns-resize !important; }'
|
|
99
|
+
document.head.appendChild(style)
|
|
100
|
+
styleRef.current = style
|
|
101
|
+
|
|
73
102
|
return () => {
|
|
74
103
|
if (styleRef.current) {
|
|
75
104
|
document.head.removeChild(styleRef.current)
|
|
@@ -82,6 +111,47 @@ export const PanControl = ({
|
|
|
82
111
|
}
|
|
83
112
|
}, [isDragging])
|
|
84
113
|
|
|
114
|
+
// Window-level end handlers: releasing outside the element, context menu,
|
|
115
|
+
// tab blur, visibility changes, and Escape must all clear the global ns-resize cursor.
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (!isDragging) return undefined
|
|
118
|
+
|
|
119
|
+
const isActivePointer = (e) =>
|
|
120
|
+
activePointerIdRef.current == null ||
|
|
121
|
+
e.pointerId === activePointerIdRef.current
|
|
122
|
+
|
|
123
|
+
const onPointerEnd = (e) => {
|
|
124
|
+
if (!isActivePointer(e)) return
|
|
125
|
+
endDrag()
|
|
126
|
+
}
|
|
127
|
+
const onInterrupt = () => endDrag()
|
|
128
|
+
const onKeyDown = (e) => {
|
|
129
|
+
if (e.key === 'Escape') {
|
|
130
|
+
e.preventDefault()
|
|
131
|
+
endDrag()
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const onVisibilityChange = () => {
|
|
135
|
+
if (document.visibilityState !== 'visible') endDrag()
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
window.addEventListener('pointerup', onPointerEnd)
|
|
139
|
+
window.addEventListener('pointercancel', onPointerEnd)
|
|
140
|
+
window.addEventListener('blur', onInterrupt)
|
|
141
|
+
window.addEventListener('contextmenu', onInterrupt)
|
|
142
|
+
window.addEventListener('keydown', onKeyDown)
|
|
143
|
+
document.addEventListener('visibilitychange', onVisibilityChange)
|
|
144
|
+
|
|
145
|
+
return () => {
|
|
146
|
+
window.removeEventListener('pointerup', onPointerEnd)
|
|
147
|
+
window.removeEventListener('pointercancel', onPointerEnd)
|
|
148
|
+
window.removeEventListener('blur', onInterrupt)
|
|
149
|
+
window.removeEventListener('contextmenu', onInterrupt)
|
|
150
|
+
window.removeEventListener('keydown', onKeyDown)
|
|
151
|
+
document.removeEventListener('visibilitychange', onVisibilityChange)
|
|
152
|
+
}
|
|
153
|
+
}, [isDragging, endDrag])
|
|
154
|
+
|
|
85
155
|
const scheduleEmit = useCallback(
|
|
86
156
|
(nextNormalized) => {
|
|
87
157
|
pendingNormRef.current = clampNorm(nextNormalized)
|
|
@@ -110,18 +180,29 @@ export const PanControl = ({
|
|
|
110
180
|
const onPointerDown = useCallback(
|
|
111
181
|
(e) => {
|
|
112
182
|
if (disabled) return
|
|
183
|
+
// Ignore secondary/auxiliary buttons (e.g. Mac trackpad two-finger click).
|
|
184
|
+
// Those can start drag without a reliable pointerup and leave cursor stuck.
|
|
185
|
+
if (e.button !== 0) return
|
|
113
186
|
e.preventDefault()
|
|
114
187
|
const target = e.currentTarget
|
|
188
|
+
activePointerIdRef.current = e.pointerId
|
|
115
189
|
target.setPointerCapture?.(e.pointerId)
|
|
190
|
+
clearCloseTimeout()
|
|
116
191
|
setIsDragging(true)
|
|
117
192
|
startYRef.current = e.clientY
|
|
118
193
|
},
|
|
119
|
-
[disabled],
|
|
194
|
+
[disabled, clearCloseTimeout],
|
|
120
195
|
)
|
|
121
196
|
|
|
122
197
|
const onPointerMove = useCallback(
|
|
123
198
|
(e) => {
|
|
124
199
|
if (!isDragging) return
|
|
200
|
+
if (
|
|
201
|
+
activePointerIdRef.current != null &&
|
|
202
|
+
e.pointerId !== activePointerIdRef.current
|
|
203
|
+
) {
|
|
204
|
+
return
|
|
205
|
+
}
|
|
125
206
|
const deltaY = startYRef.current - e.clientY
|
|
126
207
|
const next = value + deltaY * STEP_SIZE
|
|
127
208
|
scheduleEmit(next)
|
|
@@ -130,10 +211,26 @@ export const PanControl = ({
|
|
|
130
211
|
[isDragging, value, scheduleEmit],
|
|
131
212
|
)
|
|
132
213
|
|
|
133
|
-
const onPointerUp = useCallback(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
214
|
+
const onPointerUp = useCallback(
|
|
215
|
+
(e) => {
|
|
216
|
+
if (
|
|
217
|
+
activePointerIdRef.current != null &&
|
|
218
|
+
e.pointerId !== activePointerIdRef.current
|
|
219
|
+
) {
|
|
220
|
+
return
|
|
221
|
+
}
|
|
222
|
+
endDrag()
|
|
223
|
+
},
|
|
224
|
+
[endDrag],
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
const onContextMenu = useCallback(
|
|
228
|
+
(e) => {
|
|
229
|
+
e.preventDefault()
|
|
230
|
+
endDrag()
|
|
231
|
+
},
|
|
232
|
+
[endDrag],
|
|
233
|
+
)
|
|
137
234
|
|
|
138
235
|
const handleClick = useCallback(
|
|
139
236
|
(e) => {
|
|
@@ -204,20 +301,6 @@ export const PanControl = ({
|
|
|
204
301
|
const displayNorm = clampNorm(denormalize(value, minValue, maxValue))
|
|
205
302
|
const ariaPanPct = Math.round(displayNorm * 100)
|
|
206
303
|
|
|
207
|
-
const clearOpenTimeout = () => {
|
|
208
|
-
if (openTimeoutRef.current != null) {
|
|
209
|
-
clearTimeout(openTimeoutRef.current)
|
|
210
|
-
openTimeoutRef.current = null
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const clearCloseTimeout = () => {
|
|
215
|
-
if (closeTimeoutRef.current != null) {
|
|
216
|
-
clearTimeout(closeTimeoutRef.current)
|
|
217
|
-
closeTimeoutRef.current = null
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
304
|
const handlePointerEnter = () => {
|
|
222
305
|
if (disabled) return
|
|
223
306
|
clearCloseTimeout()
|
|
@@ -234,6 +317,9 @@ export const PanControl = ({
|
|
|
234
317
|
}
|
|
235
318
|
|
|
236
319
|
const handlePointerLeave = () => {
|
|
320
|
+
// Keep tooltip visible while actively dragging, even if the pointer
|
|
321
|
+
// leaves the knob (common when adjusting vertically).
|
|
322
|
+
if (isDragging) return
|
|
237
323
|
clearOpenTimeout()
|
|
238
324
|
const { tooltipCloseDelay: delay } = tooltipTimingRef.current
|
|
239
325
|
if (delay <= 0) {
|
|
@@ -251,6 +337,7 @@ export const PanControl = ({
|
|
|
251
337
|
|
|
252
338
|
const pan = (
|
|
253
339
|
<div
|
|
340
|
+
ref={knobRef}
|
|
254
341
|
role="slider"
|
|
255
342
|
tabIndex={disabled ? -1 : 0}
|
|
256
343
|
aria-label="Pan"
|
|
@@ -268,8 +355,10 @@ export const PanControl = ({
|
|
|
268
355
|
onPointerMove={onPointerMove}
|
|
269
356
|
onPointerUp={onPointerUp}
|
|
270
357
|
onPointerCancel={onPointerUp}
|
|
358
|
+
onLostPointerCapture={onPointerUp}
|
|
271
359
|
onPointerEnter={handlePointerEnter}
|
|
272
360
|
onPointerLeave={handlePointerLeave}
|
|
361
|
+
onContextMenu={onContextMenu}
|
|
273
362
|
onFocus={() => setKnobFocused(true)}
|
|
274
363
|
onBlur={() => setKnobFocused(false)}
|
|
275
364
|
onKeyDown={handleKnobKeyDown}
|
|
@@ -4,9 +4,9 @@ export const MaximizeIcon = ({
|
|
|
4
4
|
className,
|
|
5
5
|
...props
|
|
6
6
|
}) => (
|
|
7
|
-
<svg xmlns="http://www.w3.org/2000/svg" width={width} height={height} viewBox="0 0
|
|
8
|
-
|
|
9
|
-
</svg>
|
|
7
|
+
<svg xmlns="http://www.w3.org/2000/svg" width={width} height={height} viewBox="0 0 16 16" fill="none" className={className} {...props} aria-label="Maximize">
|
|
8
|
+
<path d="M14 7V2H9M14 2L9.33333 6.66667M2 9V14H7M2 14L6.66667 9.33333" stroke="currentColor" strokeOpacity="0.75" strokeLinecap="round" strokeLinejoin="round"/>
|
|
9
|
+
</svg>
|
|
10
10
|
)
|
|
11
11
|
|
|
12
12
|
MaximizeIcon.displayName = 'MaximizeIcon'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const ScrollIcon = ({ width = 16, height = 16, className, ...props }) => (
|
|
2
|
+
<svg
|
|
3
|
+
width={width}
|
|
4
|
+
height={height}
|
|
5
|
+
viewBox="0 0 24 24"
|
|
6
|
+
fill="none"
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
className={className}
|
|
9
|
+
{...props}
|
|
10
|
+
aria-label="Scroll"
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
d="M12 6V16.5M9 8.5L12 6L15 8.5M9 14L12 16.5L15 14M12 22C7.58172 22 4 18.4183 4 14V10C4 5.58172 7.58172 2 12 2C16.4183 2 20 5.58172 20 10V14C20 18.4183 16.4183 22 12 22Z"
|
|
14
|
+
stroke="currentColor"
|
|
15
|
+
strokeWidth="1.8"
|
|
16
|
+
strokeMiterlimit="10"
|
|
17
|
+
strokeLinecap="round"
|
|
18
|
+
strokeLinejoin="round"
|
|
19
|
+
/>
|
|
20
|
+
</svg>
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
ScrollIcon.displayName = 'ScrollIcon'
|
package/src/icons.jsx
CHANGED
|
@@ -483,4 +483,5 @@ export { Lyrics2Icon } from './icons/Lyrics2Icon'
|
|
|
483
483
|
export { AssistLyricsIcon } from './icons/AssistLyricsIcon'
|
|
484
484
|
export { AssistChordsIcon } from './icons/AssistChordsIcon'
|
|
485
485
|
export { AssistSectionsIcon } from './icons/AssistSectionsIcon'
|
|
486
|
+
export { ScrollIcon } from './icons/ScrollIcon'
|
|
486
487
|
|