@tremolo-ui/svelte 0.7.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/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/actions/drag-value.d.ts +22 -0
- package/dist/actions/drag-value.d.ts.map +1 -0
- package/dist/actions/drag-value.js +30 -0
- package/dist/actions/drag.d.ts +14 -0
- package/dist/actions/drag.d.ts.map +1 -0
- package/dist/actions/drag.js +22 -0
- package/dist/actions/drop-zone.d.ts +12 -0
- package/dist/actions/drop-zone.d.ts.map +1 -0
- package/dist/actions/drop-zone.js +20 -0
- package/dist/actions/long-press.d.ts +11 -0
- package/dist/actions/long-press.d.ts.map +1 -0
- package/dist/actions/long-press.js +24 -0
- package/dist/actions/wheel.d.ts +15 -0
- package/dist/actions/wheel.d.ts.map +1 -0
- package/dist/actions/wheel.js +32 -0
- package/dist/components/AnimationCanvas/AnimationCanvas.svelte +69 -0
- package/dist/components/AnimationCanvas/AnimationCanvas.svelte.d.ts +7 -0
- package/dist/components/AnimationCanvas/AnimationCanvas.svelte.d.ts.map +1 -0
- package/dist/components/AnimationCanvas/types.d.ts +46 -0
- package/dist/components/AnimationCanvas/types.d.ts.map +1 -0
- package/dist/components/AnimationCanvas/types.js +1 -0
- package/dist/components/DropZone/Root.svelte +47 -0
- package/dist/components/DropZone/Root.svelte.d.ts +7 -0
- package/dist/components/DropZone/Root.svelte.d.ts.map +1 -0
- package/dist/components/DropZone/index.d.ts +2 -0
- package/dist/components/DropZone/index.d.ts.map +1 -0
- package/dist/components/DropZone/index.js +1 -0
- package/dist/components/DropZone/types.d.ts +26 -0
- package/dist/components/DropZone/types.d.ts.map +1 -0
- package/dist/components/DropZone/types.js +1 -0
- package/dist/components/FileInput/Root.svelte +68 -0
- package/dist/components/FileInput/Root.svelte.d.ts +7 -0
- package/dist/components/FileInput/Root.svelte.d.ts.map +1 -0
- package/dist/components/FileInput/Trigger.svelte +28 -0
- package/dist/components/FileInput/Trigger.svelte.d.ts +11 -0
- package/dist/components/FileInput/Trigger.svelte.d.ts.map +1 -0
- package/dist/components/FileInput/context.d.ts +10 -0
- package/dist/components/FileInput/context.d.ts.map +1 -0
- package/dist/components/FileInput/context.js +5 -0
- package/dist/components/FileInput/index.d.ts +3 -0
- package/dist/components/FileInput/index.d.ts.map +1 -0
- package/dist/components/FileInput/index.js +2 -0
- package/dist/components/FileInput/types.d.ts +28 -0
- package/dist/components/FileInput/types.d.ts.map +1 -0
- package/dist/components/FileInput/types.js +1 -0
- package/dist/components/Knob/ActiveLine.svelte +29 -0
- package/dist/components/Knob/ActiveLine.svelte.d.ts +6 -0
- package/dist/components/Knob/ActiveLine.svelte.d.ts.map +1 -0
- package/dist/components/Knob/InactiveLine.svelte +41 -0
- package/dist/components/Knob/InactiveLine.svelte.d.ts +6 -0
- package/dist/components/Knob/InactiveLine.svelte.d.ts.map +1 -0
- package/dist/components/Knob/Root.svelte +189 -0
- package/dist/components/Knob/Root.svelte.d.ts +10 -0
- package/dist/components/Knob/Root.svelte.d.ts.map +1 -0
- package/dist/components/Knob/SVGRoot.svelte +28 -0
- package/dist/components/Knob/SVGRoot.svelte.d.ts +13 -0
- package/dist/components/Knob/SVGRoot.svelte.d.ts.map +1 -0
- package/dist/components/Knob/Thumb.svelte +43 -0
- package/dist/components/Knob/Thumb.svelte.d.ts +7 -0
- package/dist/components/Knob/Thumb.svelte.d.ts.map +1 -0
- package/dist/components/Knob/context.d.ts +22 -0
- package/dist/components/Knob/context.d.ts.map +1 -0
- package/dist/components/Knob/context.js +5 -0
- package/dist/components/Knob/index.d.ts +6 -0
- package/dist/components/Knob/index.d.ts.map +1 -0
- package/dist/components/Knob/index.js +5 -0
- package/dist/components/Knob/types.d.ts +139 -0
- package/dist/components/Knob/types.d.ts.map +1 -0
- package/dist/components/Knob/types.js +1 -0
- package/dist/components/NumberInput/DecrementStepper.svelte +11 -0
- package/dist/components/NumberInput/DecrementStepper.svelte.d.ts +9 -0
- package/dist/components/NumberInput/DecrementStepper.svelte.d.ts.map +1 -0
- package/dist/components/NumberInput/IncrementStepper.svelte +11 -0
- package/dist/components/NumberInput/IncrementStepper.svelte.d.ts +9 -0
- package/dist/components/NumberInput/IncrementStepper.svelte.d.ts.map +1 -0
- package/dist/components/NumberInput/InputField.svelte +134 -0
- package/dist/components/NumberInput/InputField.svelte.d.ts +8 -0
- package/dist/components/NumberInput/InputField.svelte.d.ts.map +1 -0
- package/dist/components/NumberInput/Root.svelte +209 -0
- package/dist/components/NumberInput/Root.svelte.d.ts +10 -0
- package/dist/components/NumberInput/Root.svelte.d.ts.map +1 -0
- package/dist/components/NumberInput/Stepper.svelte +61 -0
- package/dist/components/NumberInput/Stepper.svelte.d.ts +10 -0
- package/dist/components/NumberInput/Stepper.svelte.d.ts.map +1 -0
- package/dist/components/NumberInput/StepperButton.svelte +63 -0
- package/dist/components/NumberInput/StepperButton.svelte.d.ts +10 -0
- package/dist/components/NumberInput/StepperButton.svelte.d.ts.map +1 -0
- package/dist/components/NumberInput/context.d.ts +48 -0
- package/dist/components/NumberInput/context.d.ts.map +1 -0
- package/dist/components/NumberInput/context.js +8 -0
- package/dist/components/NumberInput/index.d.ts +6 -0
- package/dist/components/NumberInput/index.d.ts.map +1 -0
- package/dist/components/NumberInput/index.js +5 -0
- package/dist/components/NumberInput/types.d.ts +104 -0
- package/dist/components/NumberInput/types.d.ts.map +1 -0
- package/dist/components/NumberInput/types.js +1 -0
- package/dist/components/Piano/Root.svelte +177 -0
- package/dist/components/Piano/Root.svelte.d.ts +10 -0
- package/dist/components/Piano/Root.svelte.d.ts.map +1 -0
- package/dist/components/Piano/index.d.ts +2 -0
- package/dist/components/Piano/index.d.ts.map +1 -0
- package/dist/components/Piano/index.js +1 -0
- package/dist/components/Piano/types.d.ts +90 -0
- package/dist/components/Piano/types.d.ts.map +1 -0
- package/dist/components/Piano/types.js +1 -0
- package/dist/components/PointsEditor/Background.svelte +14 -0
- package/dist/components/PointsEditor/Background.svelte.d.ts +9 -0
- package/dist/components/PointsEditor/Background.svelte.d.ts.map +1 -0
- package/dist/components/PointsEditor/Container.svelte +82 -0
- package/dist/components/PointsEditor/Container.svelte.d.ts +10 -0
- package/dist/components/PointsEditor/Container.svelte.d.ts.map +1 -0
- package/dist/components/PointsEditor/Point.svelte +213 -0
- package/dist/components/PointsEditor/Point.svelte.d.ts +7 -0
- package/dist/components/PointsEditor/Point.svelte.d.ts.map +1 -0
- package/dist/components/PointsEditor/Root.svelte +107 -0
- package/dist/components/PointsEditor/Root.svelte.d.ts +7 -0
- package/dist/components/PointsEditor/Root.svelte.d.ts.map +1 -0
- package/dist/components/PointsEditor/SelectionBox.svelte +32 -0
- package/dist/components/PointsEditor/SelectionBox.svelte.d.ts +9 -0
- package/dist/components/PointsEditor/SelectionBox.svelte.d.ts.map +1 -0
- package/dist/components/PointsEditor/context.d.ts +28 -0
- package/dist/components/PointsEditor/context.d.ts.map +1 -0
- package/dist/components/PointsEditor/context.js +5 -0
- package/dist/components/PointsEditor/index.d.ts +6 -0
- package/dist/components/PointsEditor/index.d.ts.map +1 -0
- package/dist/components/PointsEditor/index.js +5 -0
- package/dist/components/PointsEditor/types.d.ts +84 -0
- package/dist/components/PointsEditor/types.d.ts.map +1 -0
- package/dist/components/PointsEditor/types.js +1 -0
- package/dist/components/Slider/Marks.svelte +42 -0
- package/dist/components/Slider/Marks.svelte.d.ts +7 -0
- package/dist/components/Slider/Marks.svelte.d.ts.map +1 -0
- package/dist/components/Slider/MarksOption.svelte +63 -0
- package/dist/components/Slider/MarksOption.svelte.d.ts +7 -0
- package/dist/components/Slider/MarksOption.svelte.d.ts.map +1 -0
- package/dist/components/Slider/Root.svelte +217 -0
- package/dist/components/Slider/Root.svelte.d.ts +10 -0
- package/dist/components/Slider/Root.svelte.d.ts.map +1 -0
- package/dist/components/Slider/Thumb.svelte +84 -0
- package/dist/components/Slider/Thumb.svelte.d.ts +10 -0
- package/dist/components/Slider/Thumb.svelte.d.ts.map +1 -0
- package/dist/components/Slider/Track.svelte +51 -0
- package/dist/components/Slider/Track.svelte.d.ts +7 -0
- package/dist/components/Slider/Track.svelte.d.ts.map +1 -0
- package/dist/components/Slider/context.d.ts +28 -0
- package/dist/components/Slider/context.d.ts.map +1 -0
- package/dist/components/Slider/context.js +5 -0
- package/dist/components/Slider/index.d.ts +6 -0
- package/dist/components/Slider/index.d.ts.map +1 -0
- package/dist/components/Slider/index.js +5 -0
- package/dist/components/Slider/types.d.ts +138 -0
- package/dist/components/Slider/types.d.ts.map +1 -0
- package/dist/components/Slider/types.js +1 -0
- package/dist/components/XYPad/Area.svelte +29 -0
- package/dist/components/XYPad/Area.svelte.d.ts +10 -0
- package/dist/components/XYPad/Area.svelte.d.ts.map +1 -0
- package/dist/components/XYPad/Root.svelte +238 -0
- package/dist/components/XYPad/Root.svelte.d.ts +10 -0
- package/dist/components/XYPad/Root.svelte.d.ts.map +1 -0
- package/dist/components/XYPad/Thumb.svelte +109 -0
- package/dist/components/XYPad/Thumb.svelte.d.ts +10 -0
- package/dist/components/XYPad/Thumb.svelte.d.ts.map +1 -0
- package/dist/components/XYPad/context.d.ts +25 -0
- package/dist/components/XYPad/context.d.ts.map +1 -0
- package/dist/components/XYPad/context.js +5 -0
- package/dist/components/XYPad/index.d.ts +4 -0
- package/dist/components/XYPad/index.d.ts.map +1 -0
- package/dist/components/XYPad/index.js +3 -0
- package/dist/components/XYPad/types.d.ts +80 -0
- package/dist/components/XYPad/types.d.ts.map +1 -0
- package/dist/components/XYPad/types.js +1 -0
- package/dist/components/_util/VisuallyHiddenRangeInput.svelte +17 -0
- package/dist/components/_util/VisuallyHiddenRangeInput.svelte.d.ts +8 -0
- package/dist/components/_util/VisuallyHiddenRangeInput.svelte.d.ts.map +1 -0
- package/dist/components/_util/check-steps.svelte.d.ts +10 -0
- package/dist/components/_util/check-steps.svelte.d.ts.map +1 -0
- package/dist/components/_util/check-steps.svelte.js +17 -0
- package/dist/components/_util/placement.d.ts +15 -0
- package/dist/components/_util/placement.d.ts.map +1 -0
- package/dist/components/_util/placement.js +30 -0
- package/dist/components/_util/style.d.ts +5 -0
- package/dist/components/_util/style.d.ts.map +1 -0
- package/dist/components/_util/style.js +9 -0
- package/dist/hooks/useMIDIAccess.svelte.d.ts +29 -0
- package/dist/hooks/useMIDIAccess.svelte.d.ts.map +1 -0
- package/dist/hooks/useMIDIAccess.svelte.js +62 -0
- package/dist/hooks/useMIDIInput.svelte.d.ts +18 -0
- package/dist/hooks/useMIDIInput.svelte.d.ts.map +1 -0
- package/dist/hooks/useMIDIInput.svelte.js +31 -0
- package/dist/hooks/useMIDIMessage.svelte.d.ts +9 -0
- package/dist/hooks/useMIDIMessage.svelte.d.ts.map +1 -0
- package/dist/hooks/useMIDIMessage.svelte.js +23 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/package.json +72 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarksOption.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/MarksOption.svelte.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,KAAK,GAAG,sBAAsB,GACjC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,MAAM,sBAAsB,CAAC,CAAC;AAoDvE,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
applyDelta,
|
|
4
|
+
arrowKeyDirection,
|
|
5
|
+
DEFAULT_DRAG_SENSITIVITY,
|
|
6
|
+
DEFAULT_KEYBOARD_OPTIONS,
|
|
7
|
+
DEFAULT_WHEEL_OPTIONS,
|
|
8
|
+
elementMapping,
|
|
9
|
+
selectModifier,
|
|
10
|
+
valuePercent,
|
|
11
|
+
wheelDirection,
|
|
12
|
+
type AxisOptions,
|
|
13
|
+
type XY,
|
|
14
|
+
} from '@tremolo-ui/dom'
|
|
15
|
+
import { linearScale } from '@tremolo-ui/functions'
|
|
16
|
+
|
|
17
|
+
import { dragValue } from '../../actions/drag-value.js'
|
|
18
|
+
import { wheel as wheelAction } from '../../actions/wheel.js'
|
|
19
|
+
import { useCheckSteps } from '../_util/check-steps.svelte.js'
|
|
20
|
+
|
|
21
|
+
import { setSliderContext } from './context.js'
|
|
22
|
+
import type { SliderProps } from './types.js'
|
|
23
|
+
|
|
24
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
25
|
+
|
|
26
|
+
type Props = SliderProps &
|
|
27
|
+
Omit<HTMLAttributes<HTMLDivElement>, keyof SliderProps>
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
value = $bindable(),
|
|
31
|
+
min,
|
|
32
|
+
max,
|
|
33
|
+
step = 1,
|
|
34
|
+
scale = linearScale,
|
|
35
|
+
vertical = false,
|
|
36
|
+
reverse = false,
|
|
37
|
+
externalStyles,
|
|
38
|
+
wheel = DEFAULT_WHEEL_OPTIONS,
|
|
39
|
+
keyboard = DEFAULT_KEYBOARD_OPTIONS,
|
|
40
|
+
dragSensitivity = DEFAULT_DRAG_SENSITIVITY,
|
|
41
|
+
disabled = false,
|
|
42
|
+
readonly = false,
|
|
43
|
+
onChange,
|
|
44
|
+
onDragStart,
|
|
45
|
+
onDragEnd,
|
|
46
|
+
ref = $bindable(null),
|
|
47
|
+
children,
|
|
48
|
+
onkeydown,
|
|
49
|
+
onfocus,
|
|
50
|
+
onblur,
|
|
51
|
+
...rest
|
|
52
|
+
}: Props = $props()
|
|
53
|
+
|
|
54
|
+
const inactive = $derived(disabled || readonly)
|
|
55
|
+
// Measured from the left or the top, as CSS places things:
|
|
56
|
+
// normal -> normal (right)
|
|
57
|
+
// vertical -> reversed (up)
|
|
58
|
+
// reverse -> reversed (left)
|
|
59
|
+
// vertical & reverse -> normal (down)
|
|
60
|
+
const displayReversed = $derived(vertical !== reverse)
|
|
61
|
+
const percent = $derived(
|
|
62
|
+
valuePercent(value, { min, max, scale }, displayReversed),
|
|
63
|
+
)
|
|
64
|
+
// The pointer is normalized against the track on both axes; only the one
|
|
65
|
+
// the slider runs along is read back.
|
|
66
|
+
const axis: AxisOptions = $derived({
|
|
67
|
+
min,
|
|
68
|
+
max,
|
|
69
|
+
step,
|
|
70
|
+
scale,
|
|
71
|
+
reverse: displayReversed,
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
let track: HTMLElement | null = null
|
|
75
|
+
let thumb: HTMLInputElement | null = null
|
|
76
|
+
|
|
77
|
+
useCheckSteps(() => ({ component: 'Slider', range: axis, keyboard, wheel }))
|
|
78
|
+
|
|
79
|
+
function change(next: number) {
|
|
80
|
+
value = next
|
|
81
|
+
onChange?.(next)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
setSliderContext({
|
|
85
|
+
get value() {
|
|
86
|
+
return value
|
|
87
|
+
},
|
|
88
|
+
get min() {
|
|
89
|
+
return min
|
|
90
|
+
},
|
|
91
|
+
get max() {
|
|
92
|
+
return max
|
|
93
|
+
},
|
|
94
|
+
get step() {
|
|
95
|
+
return step
|
|
96
|
+
},
|
|
97
|
+
get scale() {
|
|
98
|
+
return scale
|
|
99
|
+
},
|
|
100
|
+
get vertical() {
|
|
101
|
+
return vertical
|
|
102
|
+
},
|
|
103
|
+
get reverse() {
|
|
104
|
+
return reverse
|
|
105
|
+
},
|
|
106
|
+
get disabled() {
|
|
107
|
+
return disabled
|
|
108
|
+
},
|
|
109
|
+
get readonly() {
|
|
110
|
+
return readonly
|
|
111
|
+
},
|
|
112
|
+
get percent() {
|
|
113
|
+
return percent
|
|
114
|
+
},
|
|
115
|
+
change,
|
|
116
|
+
setTrack: (element) => {
|
|
117
|
+
track = element
|
|
118
|
+
},
|
|
119
|
+
setThumb: (input) => {
|
|
120
|
+
thumb = input
|
|
121
|
+
},
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
const valueOf = (v: XY<number>) => v[vertical ? 1 : 0]
|
|
125
|
+
|
|
126
|
+
const dragOptions = $derived({
|
|
127
|
+
axis,
|
|
128
|
+
mapping: elementMapping(() => track, {
|
|
129
|
+
sensitivity: (state) =>
|
|
130
|
+
selectModifier(dragSensitivity, state.event).value,
|
|
131
|
+
}),
|
|
132
|
+
cursor: inactive ? undefined : (externalStyles?.cursor ?? 'pointer'),
|
|
133
|
+
shouldStart: () => !inactive,
|
|
134
|
+
updateOnPointerDown: true,
|
|
135
|
+
onChange: (v: XY<number>) => {
|
|
136
|
+
if (!inactive) change(valueOf(v))
|
|
137
|
+
},
|
|
138
|
+
onDragStart: (v: XY<number>) => {
|
|
139
|
+
if (inactive) return
|
|
140
|
+
thumb?.focus()
|
|
141
|
+
onDragStart?.(valueOf(v))
|
|
142
|
+
},
|
|
143
|
+
onDragEnd: (v: XY<number>) => {
|
|
144
|
+
if (!inactive) onDragEnd?.(valueOf(v))
|
|
145
|
+
},
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
const wheelOptions = $derived({
|
|
149
|
+
requireFocus: true,
|
|
150
|
+
onWheel: (event: WheelEvent) => {
|
|
151
|
+
if (!wheel || inactive) return
|
|
152
|
+
// A notch the slider does not read — a sideways scroll on a vertical
|
|
153
|
+
// slider — is left to the page rather than swallowed.
|
|
154
|
+
const direction = wheelDirection(event, { horizontal: !vertical })
|
|
155
|
+
if (direction === null) return
|
|
156
|
+
event.preventDefault()
|
|
157
|
+
change(
|
|
158
|
+
applyDelta(value, reverse ? -direction : direction, wheel, axis, event),
|
|
159
|
+
)
|
|
160
|
+
},
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
/** Move the focus to the thumb. */
|
|
164
|
+
export function focus() {
|
|
165
|
+
if (!disabled) thumb?.focus()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Take the focus away from the thumb. */
|
|
169
|
+
export function blur() {
|
|
170
|
+
thumb?.blur()
|
|
171
|
+
}
|
|
172
|
+
</script>
|
|
173
|
+
|
|
174
|
+
<!-- The group is the pointer and keyboard event area; the range input inside
|
|
175
|
+
the thumb carries the control semantics. A press lands on the track or the
|
|
176
|
+
thumb, neither of which can hold focus, and the browser answers that by
|
|
177
|
+
clearing the focus — tabindex -1 keeps it inside, and onfocus passes it to
|
|
178
|
+
the input. -->
|
|
179
|
+
<div
|
|
180
|
+
bind:this={ref}
|
|
181
|
+
role="group"
|
|
182
|
+
tabindex="-1"
|
|
183
|
+
data-orientation={vertical ? 'vertical' : 'horizontal'}
|
|
184
|
+
data-disabled={disabled ? '' : undefined}
|
|
185
|
+
data-readonly={readonly ? '' : undefined}
|
|
186
|
+
use:dragValue={dragOptions}
|
|
187
|
+
use:wheelAction={wheelOptions}
|
|
188
|
+
onkeydown={(event) => {
|
|
189
|
+
const direction = arrowKeyDirection(event.key)
|
|
190
|
+
if (direction !== null) {
|
|
191
|
+
event.preventDefault()
|
|
192
|
+
if (keyboard && !inactive) {
|
|
193
|
+
change(
|
|
194
|
+
applyDelta(
|
|
195
|
+
value,
|
|
196
|
+
reverse ? -direction : direction,
|
|
197
|
+
keyboard,
|
|
198
|
+
axis,
|
|
199
|
+
event,
|
|
200
|
+
),
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
onkeydown?.(event)
|
|
205
|
+
}}
|
|
206
|
+
onfocus={(event) => {
|
|
207
|
+
if (!disabled) thumb?.focus()
|
|
208
|
+
onfocus?.(event)
|
|
209
|
+
}}
|
|
210
|
+
onblur={(event) => {
|
|
211
|
+
thumb?.blur()
|
|
212
|
+
onblur?.(event)
|
|
213
|
+
}}
|
|
214
|
+
{...rest}
|
|
215
|
+
>
|
|
216
|
+
{@render children()}
|
|
217
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SliderProps } from './types.js';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
type Props = SliderProps & Omit<HTMLAttributes<HTMLDivElement>, keyof SliderProps>;
|
|
4
|
+
declare const Root: import("svelte").Component<Props, {
|
|
5
|
+
focus: () => void;
|
|
6
|
+
blur: () => void;
|
|
7
|
+
}, "ref" | "value">;
|
|
8
|
+
type Root = ReturnType<typeof Root>;
|
|
9
|
+
export default Root;
|
|
10
|
+
//# sourceMappingURL=Root.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Root.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/Root.svelte.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,KAAK,GAAG,WAAW,GACtB,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,MAAM,WAAW,CAAC,CAAC;AA8L5D,QAAA,MAAM,IAAI;;;mBAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { checkPlacement } from '../_util/placement.js'
|
|
3
|
+
import VisuallyHiddenRangeInput from '../_util/VisuallyHiddenRangeInput.svelte'
|
|
4
|
+
|
|
5
|
+
import { useSliderContext } from './context.js'
|
|
6
|
+
import type { SliderThumbProps } from './types.js'
|
|
7
|
+
|
|
8
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
9
|
+
|
|
10
|
+
type Props = SliderThumbProps &
|
|
11
|
+
Omit<HTMLAttributes<HTMLDivElement>, keyof SliderThumbProps>
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
color,
|
|
15
|
+
children,
|
|
16
|
+
style,
|
|
17
|
+
// Pulled out so that they land on the range input: the input is the
|
|
18
|
+
// control and takes the focus, and a name on a plain div is ignored.
|
|
19
|
+
'aria-label': ariaLabel,
|
|
20
|
+
'aria-labelledby': ariaLabelledby,
|
|
21
|
+
'aria-describedby': ariaDescribedby,
|
|
22
|
+
'aria-valuetext': ariaValuetext,
|
|
23
|
+
...rest
|
|
24
|
+
}: Props = $props()
|
|
25
|
+
|
|
26
|
+
const slider = useSliderContext()
|
|
27
|
+
checkPlacement('Slider.Thumb', 'Slider.Track')
|
|
28
|
+
|
|
29
|
+
let input: HTMLInputElement | null = $state(null)
|
|
30
|
+
|
|
31
|
+
// Root focuses the thumb when a drag starts, wherever it was placed.
|
|
32
|
+
$effect(() => {
|
|
33
|
+
slider.setThumb(input)
|
|
34
|
+
return () => slider.setThumb(null)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
/** Move the focus to the thumb's input. */
|
|
38
|
+
export function focus() {
|
|
39
|
+
if (!slider.disabled) input?.focus()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Take the focus away from the thumb's input. */
|
|
43
|
+
export function blur() {
|
|
44
|
+
input?.blur()
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<!-- Placed by a percentage of the track, measured from its own centre;
|
|
49
|
+
`--translate` is there for a thumb that should hang off its edge. Where it
|
|
50
|
+
sits is the component's decision, so it comes after the caller's style. -->
|
|
51
|
+
<div
|
|
52
|
+
data-disabled={slider.disabled ? '' : undefined}
|
|
53
|
+
data-readonly={slider.readonly ? '' : undefined}
|
|
54
|
+
{...rest}
|
|
55
|
+
style="position: absolute; translate: var(--translate, -50% -50%); z-index: 100; {style ??
|
|
56
|
+
''}"
|
|
57
|
+
style:--color={color}
|
|
58
|
+
style:top={slider.vertical ? `${slider.percent}%` : '50%'}
|
|
59
|
+
style:left={slider.vertical ? '50%' : `${slider.percent}%`}
|
|
60
|
+
>
|
|
61
|
+
<VisuallyHiddenRangeInput
|
|
62
|
+
bind:ref={input}
|
|
63
|
+
value={slider.value}
|
|
64
|
+
min={slider.min}
|
|
65
|
+
max={slider.max}
|
|
66
|
+
step={slider.step}
|
|
67
|
+
disabled={slider.disabled}
|
|
68
|
+
aria-readonly={slider.readonly}
|
|
69
|
+
aria-orientation={slider.vertical ? 'vertical' : 'horizontal'}
|
|
70
|
+
aria-label={ariaLabel}
|
|
71
|
+
aria-labelledby={ariaLabelledby}
|
|
72
|
+
aria-describedby={ariaDescribedby}
|
|
73
|
+
aria-valuetext={ariaValuetext}
|
|
74
|
+
oninput={(event) => {
|
|
75
|
+
const target = event.currentTarget
|
|
76
|
+
if (slider.readonly) {
|
|
77
|
+
target.value = String(slider.value)
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
slider.change(target.valueAsNumber)
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
83
|
+
{@render children?.()}
|
|
84
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SliderThumbProps } from './types.js';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
type Props = SliderThumbProps & Omit<HTMLAttributes<HTMLDivElement>, keyof SliderThumbProps>;
|
|
4
|
+
declare const Thumb: import("svelte").Component<Props, {
|
|
5
|
+
focus: () => void;
|
|
6
|
+
blur: () => void;
|
|
7
|
+
}, "">;
|
|
8
|
+
type Thumb = ReturnType<typeof Thumb>;
|
|
9
|
+
export default Thumb;
|
|
10
|
+
//# sourceMappingURL=Thumb.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Thumb.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/Thumb.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,KAAK,GAAG,gBAAgB,GAC3B,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,MAAM,gBAAgB,CAAC,CAAC;AA8DjE,QAAA,MAAM,KAAK;;;MAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cssLength } from '@tremolo-ui/dom'
|
|
3
|
+
|
|
4
|
+
import { setPlacement } from '../_util/placement.js'
|
|
5
|
+
|
|
6
|
+
import { useSliderContext } from './context.js'
|
|
7
|
+
import type { SliderTrackProps } from './types.js'
|
|
8
|
+
|
|
9
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
10
|
+
|
|
11
|
+
type Props = SliderTrackProps &
|
|
12
|
+
Omit<HTMLAttributes<HTMLDivElement>, keyof SliderTrackProps>
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
length,
|
|
16
|
+
thickness,
|
|
17
|
+
active,
|
|
18
|
+
inactive,
|
|
19
|
+
ref = $bindable(null),
|
|
20
|
+
children,
|
|
21
|
+
style,
|
|
22
|
+
...rest
|
|
23
|
+
}: Props = $props()
|
|
24
|
+
|
|
25
|
+
const slider = useSliderContext()
|
|
26
|
+
setPlacement('Slider.Track')
|
|
27
|
+
|
|
28
|
+
// The track is what the pointer position is normalized against.
|
|
29
|
+
$effect(() => {
|
|
30
|
+
slider.setTrack(ref)
|
|
31
|
+
return () => slider.setTrack(null)
|
|
32
|
+
})
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<!-- `--percent` is where the value sits, for the theme to paint the fill
|
|
36
|
+
with: the one number CSS cannot work out on its own. -->
|
|
37
|
+
<div
|
|
38
|
+
bind:this={ref}
|
|
39
|
+
data-disabled={slider.disabled ? '' : undefined}
|
|
40
|
+
data-orientation={slider.vertical ? 'vertical' : 'horizontal'}
|
|
41
|
+
data-flipped={slider.vertical !== slider.reverse ? '' : undefined}
|
|
42
|
+
style="position: relative; {style ?? ''}"
|
|
43
|
+
style:--active={active}
|
|
44
|
+
style:--inactive={inactive}
|
|
45
|
+
style:--length={cssLength(length)}
|
|
46
|
+
style:--thickness={cssLength(thickness)}
|
|
47
|
+
style:--percent="{slider.percent}%"
|
|
48
|
+
{...rest}
|
|
49
|
+
>
|
|
50
|
+
{@render children?.()}
|
|
51
|
+
</div>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SliderTrackProps } from './types.js';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
type Props = SliderTrackProps & Omit<HTMLAttributes<HTMLDivElement>, keyof SliderTrackProps>;
|
|
4
|
+
declare const Track: import("svelte").Component<Props, {}, "ref">;
|
|
5
|
+
type Track = ReturnType<typeof Track>;
|
|
6
|
+
export default Track;
|
|
7
|
+
//# sourceMappingURL=Track.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Track.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/Track.svelte.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,KAAK,GAAG,gBAAgB,GAC3B,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,MAAM,gBAAgB,CAAC,CAAC;AAwCjE,QAAA,MAAM,KAAK,8CAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Scale } from '@tremolo-ui/functions';
|
|
2
|
+
/**
|
|
3
|
+
* What `Slider.Root` shares with its parts. Every field is a getter, so
|
|
4
|
+
* reading one follows the value as it changes.
|
|
5
|
+
*/
|
|
6
|
+
export interface SliderContextValue {
|
|
7
|
+
readonly value: number;
|
|
8
|
+
readonly min: number;
|
|
9
|
+
readonly max: number;
|
|
10
|
+
readonly step: number;
|
|
11
|
+
readonly scale: Scale;
|
|
12
|
+
readonly vertical: boolean;
|
|
13
|
+
readonly reverse: boolean;
|
|
14
|
+
readonly disabled: boolean;
|
|
15
|
+
readonly readonly: boolean;
|
|
16
|
+
/** Where the value sits along the track, as a percentage from the top or left. */
|
|
17
|
+
readonly percent: number;
|
|
18
|
+
/** Set the value, as an input on the slider would. */
|
|
19
|
+
change: (value: number) => void;
|
|
20
|
+
/** @internal `Slider.Track` registers the element the pointer is measured against. */
|
|
21
|
+
setTrack: (element: HTMLElement | null) => void;
|
|
22
|
+
/** @internal `Slider.Thumb` registers the input the focus goes to. */
|
|
23
|
+
setThumb: (input: HTMLInputElement | null) => void;
|
|
24
|
+
}
|
|
25
|
+
/** The context of the enclosing `Slider.Root`, for a part of your own. */
|
|
26
|
+
export declare const useSliderContext: () => SliderContextValue;
|
|
27
|
+
export declare const setSliderContext: (context: SliderContextValue) => SliderContextValue;
|
|
28
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAElD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,kFAAkF;IAClF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,sDAAsD;IACtD,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/B,sFAAsF;IACtF,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAA;IAC/C,sEAAsE;IACtE,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAA;CACnD;AAID,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,0BAAM,CAAA;AACnC,eAAO,MAAM,gBAAgB,qDAAM,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Marks } from './Marks.svelte';
|
|
2
|
+
export { default as MarksOption } from './MarksOption.svelte';
|
|
3
|
+
export { default as Root } from './Root.svelte';
|
|
4
|
+
export { default as Thumb } from './Thumb.svelte';
|
|
5
|
+
export { default as Track } from './Track.svelte';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Marks } from './Marks.svelte';
|
|
2
|
+
export { default as MarksOption } from './MarksOption.svelte';
|
|
3
|
+
export { default as Root } from './Root.svelte';
|
|
4
|
+
export { default as Thumb } from './Thumb.svelte';
|
|
5
|
+
export { default as Track } from './Track.svelte';
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { InputEventOption, MarksOptions, ModifierValue } from '@tremolo-ui/dom';
|
|
2
|
+
import type { Scale } from '@tremolo-ui/functions';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
export interface SliderProps {
|
|
5
|
+
/** The current value. Bind it (`bind:value`) or update it from `onChange`. */
|
|
6
|
+
value: number;
|
|
7
|
+
/** The value at the start of the travel. */
|
|
8
|
+
min: number;
|
|
9
|
+
/** The value at the end of the travel. */
|
|
10
|
+
max: number;
|
|
11
|
+
/**
|
|
12
|
+
* Granularity of the value. A drag, the wheel and the arrow keys snap it to
|
|
13
|
+
* multiples of `step`.
|
|
14
|
+
* @default 1
|
|
15
|
+
*/
|
|
16
|
+
step?: number;
|
|
17
|
+
/**
|
|
18
|
+
* How the value is distributed across the travel. Pick one of the scales
|
|
19
|
+
* from `@tremolo-ui/functions`.
|
|
20
|
+
* @default linearScale
|
|
21
|
+
*/
|
|
22
|
+
scale?: Scale;
|
|
23
|
+
/**
|
|
24
|
+
* Run the slider vertically, with the value growing upwards.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
vertical?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Grow the value the other way: leftwards, or downwards when `vertical`.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
reverse?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The cursor to show while dragging.
|
|
35
|
+
* @default { cursor: 'pointer' }
|
|
36
|
+
*/
|
|
37
|
+
externalStyles?: {
|
|
38
|
+
cursor?: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* How much one notch of the wheel moves the value, while the focus is
|
|
42
|
+
* inside. `null` turns the wheel off.
|
|
43
|
+
* @default ['raw', 1]
|
|
44
|
+
*/
|
|
45
|
+
wheel?: ModifierValue<InputEventOption> | null;
|
|
46
|
+
/**
|
|
47
|
+
* How much a drag moves the value, per modifier key. `1` follows the
|
|
48
|
+
* pointer; anything else turns the drag relative.
|
|
49
|
+
* @default { default: 1, shift: 0.1 }
|
|
50
|
+
*/
|
|
51
|
+
dragSensitivity?: ModifierValue<number>;
|
|
52
|
+
/**
|
|
53
|
+
* How much one arrow key press moves the value. `null` turns the arrow
|
|
54
|
+
* keys off.
|
|
55
|
+
* @default { default: ['raw', 1], shift: ['raw', 0.1] }
|
|
56
|
+
*/
|
|
57
|
+
keyboard?: ModifierValue<InputEventOption> | null;
|
|
58
|
+
/**
|
|
59
|
+
* Make the slider unchangeable and remove it from the tab order.
|
|
60
|
+
* The parts carry `data-disabled` while it is set.
|
|
61
|
+
*/
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Make the value unchangeable. The parts carry `data-readonly` while it is
|
|
65
|
+
* set.
|
|
66
|
+
*/
|
|
67
|
+
readonly?: boolean;
|
|
68
|
+
/** Called with the new value when a drag, the wheel or an arrow key moves it. */
|
|
69
|
+
onChange?: (value: number) => void;
|
|
70
|
+
/** Called when a drag starts, with the value where the track was pressed. */
|
|
71
|
+
onDragStart?: (value: number) => void;
|
|
72
|
+
/** Called when the drag ends, with the value it ended on. */
|
|
73
|
+
onDragEnd?: (value: number) => void;
|
|
74
|
+
/** The root element, bound with `bind:ref`. */
|
|
75
|
+
ref?: HTMLDivElement | null;
|
|
76
|
+
/** The slider renders exactly what you compose here. */
|
|
77
|
+
children: Snippet;
|
|
78
|
+
}
|
|
79
|
+
export interface SliderTrackProps {
|
|
80
|
+
/** How long the track is along the axis the slider runs. Sets `--length`. */
|
|
81
|
+
length?: number | string;
|
|
82
|
+
/** How thick the track is across that axis. Sets `--thickness`. */
|
|
83
|
+
thickness?: number | string;
|
|
84
|
+
/** Colour of the part from `min` to the value. Sets `--active`. */
|
|
85
|
+
active?: string;
|
|
86
|
+
/** Colour of the rest of the track. Sets `--inactive`. */
|
|
87
|
+
inactive?: string;
|
|
88
|
+
ref?: HTMLDivElement | null;
|
|
89
|
+
children?: Snippet;
|
|
90
|
+
}
|
|
91
|
+
export interface SliderThumbProps {
|
|
92
|
+
/** Sets `--color`, for the theme to colour the thumb with. */
|
|
93
|
+
color?: string;
|
|
94
|
+
children?: Snippet;
|
|
95
|
+
}
|
|
96
|
+
export interface SliderMarksProps {
|
|
97
|
+
/** Space between the marks and the track. Sets `--gap`. */
|
|
98
|
+
gap?: number | string;
|
|
99
|
+
/**
|
|
100
|
+
* Build the marks instead of writing `Slider.MarksOption` out: a number
|
|
101
|
+
* puts one every that many, `'step'` one every `step`, and
|
|
102
|
+
* `{ per, mark, label }` also turns the mark or the label off for all of
|
|
103
|
+
* them. `children` is ignored while it is set.
|
|
104
|
+
*/
|
|
105
|
+
options?: MarksOptions;
|
|
106
|
+
children?: Snippet;
|
|
107
|
+
}
|
|
108
|
+
export interface SliderMarksOptionProps {
|
|
109
|
+
/** Where the mark sits, on the same scale as the thumb. */
|
|
110
|
+
value: number;
|
|
111
|
+
/**
|
|
112
|
+
* Draw the mark itself.
|
|
113
|
+
* @default true
|
|
114
|
+
*/
|
|
115
|
+
mark?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Text shown next to the mark. Leave it out to show the value; `null`
|
|
118
|
+
* leaves the label out.
|
|
119
|
+
*/
|
|
120
|
+
label?: number | string | null;
|
|
121
|
+
/** Thickness of the mark. Sets `--thickness`. */
|
|
122
|
+
thickness?: number | string;
|
|
123
|
+
/** Length of the mark. Sets `--length`. */
|
|
124
|
+
length?: number | string;
|
|
125
|
+
/** Space between the mark and the label. Sets `--gap`. */
|
|
126
|
+
gap?: number | string;
|
|
127
|
+
/** Classes for the mark and the label inside the option. */
|
|
128
|
+
classes?: {
|
|
129
|
+
mark?: string;
|
|
130
|
+
label?: string;
|
|
131
|
+
};
|
|
132
|
+
/** Styles for the mark and the label inside the option. */
|
|
133
|
+
styles?: {
|
|
134
|
+
mark?: string;
|
|
135
|
+
label?: string;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { setPlacement } from '../_util/placement.js'
|
|
3
|
+
|
|
4
|
+
import { useXYPadContext } from './context.js'
|
|
5
|
+
|
|
6
|
+
import type { Snippet } from 'svelte'
|
|
7
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
8
|
+
|
|
9
|
+
type Props = HTMLAttributes<HTMLDivElement> & {
|
|
10
|
+
ref?: HTMLDivElement | null
|
|
11
|
+
children?: Snippet
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let { ref = $bindable(null), children, style, ...rest }: Props = $props()
|
|
15
|
+
|
|
16
|
+
const pad = useXYPadContext()
|
|
17
|
+
setPlacement('XYPad.Area')
|
|
18
|
+
|
|
19
|
+
// The area is what the pointer position is normalized against.
|
|
20
|
+
$effect(() => {
|
|
21
|
+
pad.setArea(ref)
|
|
22
|
+
return () => pad.setArea(null)
|
|
23
|
+
})
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<!-- The thumb inside is placed against this box. -->
|
|
27
|
+
<div bind:this={ref} style="position: relative; {style ?? ''}" {...rest}>
|
|
28
|
+
{@render children?.()}
|
|
29
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
type Props = HTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
ref?: HTMLDivElement | null;
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
};
|
|
7
|
+
declare const Area: import("svelte").Component<Props, {}, "ref">;
|
|
8
|
+
type Area = ReturnType<typeof Area>;
|
|
9
|
+
export default Area;
|
|
10
|
+
//# sourceMappingURL=Area.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Area.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/XYPad/Area.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,KAAK,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC5C,GAAG,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC;AA6BJ,QAAA,MAAM,IAAI,8CAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
|