@tremolo-ui/svelte 0.8.0 → 0.9.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/actions/drag-value.d.ts.map +1 -1
- package/dist/actions/drag-value.js +2 -1
- package/dist/actions/drag.d.ts.map +1 -1
- package/dist/actions/drag.js +2 -1
- package/dist/actions/drop-zone.d.ts.map +1 -1
- package/dist/actions/drop-zone.js +2 -1
- package/dist/actions/long-press.d.ts.map +1 -1
- package/dist/actions/long-press.js +2 -1
- package/dist/actions/wheel.d.ts +1 -4
- package/dist/actions/wheel.d.ts.map +1 -1
- package/dist/actions/wheel.js +3 -14
- package/dist/components/AnimationCanvas/types.d.ts +4 -11
- package/dist/components/AnimationCanvas/types.d.ts.map +1 -1
- package/dist/components/FileInput/Root.svelte +1 -1
- package/dist/components/Knob/Root.svelte +31 -10
- package/dist/components/Knob/Root.svelte.d.ts.map +1 -1
- package/dist/components/Knob/Thumb.svelte +11 -11
- package/dist/components/Knob/types.d.ts +30 -19
- package/dist/components/Knob/types.d.ts.map +1 -1
- package/dist/components/NumberInput/InputField.svelte +4 -2
- package/dist/components/NumberInput/InputField.svelte.d.ts.map +1 -1
- package/dist/components/NumberInput/Root.svelte +55 -5
- package/dist/components/NumberInput/Root.svelte.d.ts.map +1 -1
- package/dist/components/NumberInput/Stepper.svelte +27 -4
- package/dist/components/NumberInput/Stepper.svelte.d.ts.map +1 -1
- package/dist/components/NumberInput/StepperButton.svelte +9 -1
- package/dist/components/NumberInput/StepperButton.svelte.d.ts.map +1 -1
- package/dist/components/NumberInput/context.d.ts +10 -0
- package/dist/components/NumberInput/context.d.ts.map +1 -1
- package/dist/components/NumberInput/context.js +3 -0
- package/dist/components/NumberInput/types.d.ts +25 -1
- package/dist/components/NumberInput/types.d.ts.map +1 -1
- package/dist/components/Piano/Root.svelte +6 -4
- package/dist/components/Piano/Root.svelte.d.ts.map +1 -1
- package/dist/components/PointsEditor/Container.svelte +2 -6
- package/dist/components/PointsEditor/Container.svelte.d.ts.map +1 -1
- package/dist/components/PointsEditor/Point.svelte +24 -10
- package/dist/components/PointsEditor/Point.svelte.d.ts.map +1 -1
- package/dist/components/PointsEditor/Root.svelte +7 -5
- package/dist/components/PointsEditor/Root.svelte.d.ts.map +1 -1
- package/dist/components/PointsEditor/context.d.ts +1 -1
- package/dist/components/PointsEditor/context.d.ts.map +1 -1
- package/dist/components/PointsEditor/types.d.ts +21 -7
- package/dist/components/PointsEditor/types.d.ts.map +1 -1
- package/dist/components/Slider/Marks.svelte +5 -3
- package/dist/components/Slider/Marks.svelte.d.ts.map +1 -1
- package/dist/components/Slider/MarksOption.svelte +7 -6
- package/dist/components/Slider/MarksOption.svelte.d.ts.map +1 -1
- package/dist/components/Slider/Root.svelte +30 -17
- package/dist/components/Slider/Root.svelte.d.ts.map +1 -1
- package/dist/components/Slider/Thumb.svelte +3 -3
- package/dist/components/Slider/Track.svelte +9 -7
- package/dist/components/Slider/Track.svelte.d.ts.map +1 -1
- package/dist/components/Slider/context.d.ts +1 -1
- package/dist/components/Slider/context.d.ts.map +1 -1
- package/dist/components/Slider/types.d.ts +30 -17
- package/dist/components/Slider/types.d.ts.map +1 -1
- package/dist/components/XYPad/Root.svelte +30 -16
- package/dist/components/XYPad/Root.svelte.d.ts.map +1 -1
- package/dist/components/XYPad/Thumb.svelte +1 -1
- package/dist/components/XYPad/types.d.ts +21 -7
- package/dist/components/XYPad/types.d.ts.map +1 -1
- package/dist/components/_util/change-gesture.svelte.d.ts +18 -0
- package/dist/components/_util/change-gesture.svelte.d.ts.map +1 -0
- package/dist/components/_util/change-gesture.svelte.js +26 -0
- package/dist/components/_util/check-steps.svelte.d.ts +1 -1
- package/dist/components/_util/check-steps.svelte.d.ts.map +1 -1
- package/dist/components/_util/check-steps.svelte.js +1 -1
- package/dist/components/_util/style.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stepper.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/NumberInput/Stepper.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Stepper.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/NumberInput/Stepper.svelte.ts"],"names":[],"mappings":"AAeA,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;AAwEJ,QAAA,MAAM,OAAO,8CAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { longPress } from '../../actions/long-press.js'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
useNumberInputContext,
|
|
6
|
+
useNumberInputGesture,
|
|
7
|
+
useStepperContext,
|
|
8
|
+
} from './context.js'
|
|
5
9
|
|
|
6
10
|
import type { Snippet } from 'svelte'
|
|
7
11
|
import type { HTMLAttributes } from 'svelte/elements'
|
|
@@ -15,6 +19,7 @@
|
|
|
15
19
|
|
|
16
20
|
const field = useNumberInputContext()
|
|
17
21
|
const stepper = useStepperContext()
|
|
22
|
+
const gesture = useNumberInputGesture()
|
|
18
23
|
|
|
19
24
|
const blocked = $derived(
|
|
20
25
|
field.disabled || (direction > 0 ? field.atMax : field.atMin),
|
|
@@ -23,6 +28,9 @@
|
|
|
23
28
|
const pressOptions = {
|
|
24
29
|
onPress: () => {
|
|
25
30
|
if (field.disabled || field.readonly) return
|
|
31
|
+
// Here rather than on pointerdown: the press moves the value from the
|
|
32
|
+
// action's own listener, which runs before a delegated one would.
|
|
33
|
+
gesture?.press()
|
|
26
34
|
// Once the pointer has actually travelled, the drag on `Stepper` owns
|
|
27
35
|
// the value; repeating on top of it would move it twice.
|
|
28
36
|
if (stepper?.moved()) return
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepperButton.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/NumberInput/StepperButton.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StepperButton.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/NumberInput/StepperButton.svelte.ts"],"names":[],"mappings":"AAWA,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,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC;AA+CJ,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
|
|
@@ -12,6 +12,7 @@ export interface NumberInputContextValue {
|
|
|
12
12
|
readonly drag: number | null;
|
|
13
13
|
readonly dragSensitivity: ModifierValue<number>;
|
|
14
14
|
readonly pointerLock: boolean;
|
|
15
|
+
readonly dragCursor: string;
|
|
15
16
|
readonly selectOnFocus: 'all' | 'number' | 'none';
|
|
16
17
|
readonly unformatOnFocus: boolean;
|
|
17
18
|
readonly keepCaretOnStep: boolean;
|
|
@@ -39,6 +40,15 @@ export interface NumberInputContextValue {
|
|
|
39
40
|
/** The context of the enclosing `NumberInput.Root`, for a part of your own. */
|
|
40
41
|
export declare const useNumberInputContext: () => NumberInputContextValue;
|
|
41
42
|
export declare const setNumberInputContext: (context: NumberInputContextValue) => NumberInputContextValue;
|
|
43
|
+
/** @internal The change gesture of `Root`, for the parts that change the value. */
|
|
44
|
+
export interface NumberInputGestureValue {
|
|
45
|
+
/** A press on a stepper, held until the pointer is released anywhere. */
|
|
46
|
+
press: () => void;
|
|
47
|
+
/** An arrow key in `InputField`. */
|
|
48
|
+
key: () => void;
|
|
49
|
+
}
|
|
50
|
+
export declare const useNumberInputGesture: () => NumberInputGestureValue | null;
|
|
51
|
+
export declare const setNumberInputGesture: (context: NumberInputGestureValue) => NumberInputGestureValue;
|
|
42
52
|
/** @internal Whether the drag on `Stepper` has moved the value. */
|
|
43
53
|
export interface StepperContextValue {
|
|
44
54
|
moved: () => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/NumberInput/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,aAAa,EACd,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,8EAA8E;AAC9E,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAA;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC/C,QAAQ,C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AK,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAA;IAC7B,gEAAgE;IAChE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,qEAAqE;IACrE,WAAW,EAAE,MAAM,IAAI,CAAA;IACvB,yCAAyC;IACzC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,+CAA+C;IAC/C,KAAK,EAAE,CACL,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,aAAa,CAAC,gBAAgB,CAAC,EACvC,SAAS,CAAC,EAAE,aAAa,KACtB,IAAI,CAAA;IACT,qEAAqE;IACrE,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAA;CACnD;AAID,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,+BAAM,CAAA;AACxC,eAAO,MAAM,qBAAqB,+DAAM,CAAA;AAExC,mFAAmF;AACnF,MAAM,WAAW,uBAAuB;IACtC,yEAAyE;IACzE,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,oCAAoC;IACpC,GAAG,EAAE,MAAM,IAAI,CAAA;CAChB;AAKD,eAAO,MAAM,qBAAqB,sCAA6C,CAAA;AAC/E,eAAO,MAAM,qBAAqB,+DAAa,CAAA;AAE/C,mEAAmE;AACnE,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,OAAO,CAAA;CACrB;AAKD,eAAO,MAAM,iBAAiB,kCAA6C,CAAA;AAC3E,eAAO,MAAM,iBAAiB,uDAAa,CAAA"}
|
|
@@ -3,6 +3,9 @@ const [get, set] = createContext();
|
|
|
3
3
|
/** The context of the enclosing `NumberInput.Root`, for a part of your own. */
|
|
4
4
|
export const useNumberInputContext = get;
|
|
5
5
|
export const setNumberInputContext = set;
|
|
6
|
+
const [getGesture, setGesture, hasGesture] = createContext();
|
|
7
|
+
export const useNumberInputGesture = () => (hasGesture() ? getGesture() : null);
|
|
8
|
+
export const setNumberInputGesture = setGesture;
|
|
6
9
|
const [getStepper, setStepper, hasStepper] = createContext();
|
|
7
10
|
export const useStepperContext = () => (hasStepper() ? getStepper() : null);
|
|
8
11
|
export const setStepperContext = setStepper;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InputEventOption, ModifierValue } from '@tremolo-ui/dom';
|
|
1
|
+
import type { ChangeSource, InputEventOption, ModifierValue } from '@tremolo-ui/dom';
|
|
2
2
|
import type { Scale } from '@tremolo-ui/functions';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
export interface NumberInputProps {
|
|
@@ -65,6 +65,11 @@ export interface NumberInputProps {
|
|
|
65
65
|
* @default false
|
|
66
66
|
*/
|
|
67
67
|
pointerLock?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The cursor to show while dragging a `Stepper`.
|
|
70
|
+
* @default 'ns-resize'
|
|
71
|
+
*/
|
|
72
|
+
dragCursor?: string;
|
|
68
73
|
/**
|
|
69
74
|
* Select the text when `InputField` takes focus: all of it, only the
|
|
70
75
|
* number without its unit, or nothing.
|
|
@@ -96,6 +101,25 @@ export interface NumberInputProps {
|
|
|
96
101
|
* committed or stepped.
|
|
97
102
|
*/
|
|
98
103
|
onChange?: (value: number) => void;
|
|
104
|
+
/**
|
|
105
|
+
* Called when a change of the value starts — a press on a stepper, the
|
|
106
|
+
* first wheel notch, arrow key or typed character — with the value before
|
|
107
|
+
* it and what it is made with. A host recording automation can treat the
|
|
108
|
+
* input as touched from here until `onChangeEnd`.
|
|
109
|
+
*/
|
|
110
|
+
onChangeStart?: (value: number, source: ChangeSource) => void;
|
|
111
|
+
/**
|
|
112
|
+
* Called when the change ends, with the value it ended on: when the stepper
|
|
113
|
+
* is released, when typed text is committed, or `changeEndDelay` after the
|
|
114
|
+
* last wheel notch or arrow key.
|
|
115
|
+
*/
|
|
116
|
+
onChangeEnd?: (value: number, source: ChangeSource) => void;
|
|
117
|
+
/**
|
|
118
|
+
* How long after the last wheel notch, arrow key or typed character the
|
|
119
|
+
* change counts as over, in milliseconds.
|
|
120
|
+
* @default 500
|
|
121
|
+
*/
|
|
122
|
+
changeEndDelay?: number;
|
|
99
123
|
/** The root element, bound with `bind:ref`. */
|
|
100
124
|
ref?: HTMLDivElement | null;
|
|
101
125
|
/** The input renders exactly what you compose here. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/NumberInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/NumberInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACd,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAElD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,MAAM,WAAW,gBAAgB;IAC/B,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAClC;;;;OAIG;IACH,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IAChC;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC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put,
|
|
5
|
-
fitWhiteKeyWidth,
|
|
6
|
-
getNoteRangeArray,
|
|
7
4
|
notePosition,
|
|
8
|
-
pianoWidth,
|
|
9
5
|
type PianoInputInstance,
|
|
10
6
|
type PianoLayout,
|
|
11
7
|
} from '@tremolo-ui/dom'
|
|
8
|
+
import {
|
|
9
|
+
blackKeyWidth,
|
|
10
|
+
fitWhiteKeyWidth,
|
|
11
|
+
getNoteRangeArray,
|
|
12
|
+
pianoWidth,
|
|
13
|
+
} from '@tremolo-ui/dom/internal'
|
|
12
14
|
import { isWhiteKey, noteKey } from '@tremolo-ui/functions'
|
|
13
15
|
import { untrack } from 'svelte'
|
|
14
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Root.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Piano/Root.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Root.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Piano/Root.svelte.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAY,UAAU,EAAE,MAAM,YAAY,CAAA;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,KAAK,GAAG,UAAU,GACrB,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,MAAM,UAAU,CAAC,CAAC;AAuJ3D,QAAA,MAAM,IAAI;qBA9CiB,MAAM,aAAa,MAAM;qBAKzB,MAAM;SAyCiB,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
elementMapping,
|
|
5
|
-
POINT_AXIS,
|
|
6
|
-
wheelMove,
|
|
7
|
-
} from '@tremolo-ui/dom'
|
|
2
|
+
import { createDragValue, elementMapping } from '@tremolo-ui/dom'
|
|
3
|
+
import { POINT_AXIS, wheelMove } from '@tremolo-ui/dom/internal'
|
|
8
4
|
|
|
9
5
|
import { wheel as wheelAction } from '../../actions/wheel.js'
|
|
10
6
|
import { setPlacement } from '../_util/placement.js'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Container.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/PointsEditor/Container.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Container.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/PointsEditor/Container.svelte.ts"],"names":[],"mappings":"AAWA,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;AAwEJ,QAAA,MAAM,SAAS,8CAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
arrowKeyMove,
|
|
4
|
-
clampPoint,
|
|
5
3
|
createDragValue,
|
|
6
4
|
elementMapping,
|
|
7
|
-
POINT_AXIS,
|
|
8
|
-
selectModifier,
|
|
9
5
|
type PointPosition,
|
|
10
6
|
type PointsEditorPoint,
|
|
11
7
|
} from '@tremolo-ui/dom'
|
|
8
|
+
import {
|
|
9
|
+
arrowKeyMove,
|
|
10
|
+
clampPoint,
|
|
11
|
+
POINT_AXIS,
|
|
12
|
+
selectModifier,
|
|
13
|
+
} from '@tremolo-ui/dom/internal'
|
|
12
14
|
import { untrack } from 'svelte'
|
|
13
15
|
|
|
16
|
+
import { useChangeGesture } from '../_util/change-gesture.svelte.js'
|
|
14
17
|
import { checkPlacement } from '../_util/placement.js'
|
|
15
18
|
import VisuallyHiddenRangeInput from '../_util/VisuallyHiddenRangeInput.svelte'
|
|
16
19
|
|
|
@@ -35,8 +38,9 @@
|
|
|
35
38
|
'aria-label': ariaLabel,
|
|
36
39
|
'aria-valuetext': ariaValuetext,
|
|
37
40
|
onChange,
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
onChangeStart,
|
|
42
|
+
onChangeEnd,
|
|
43
|
+
changeEndDelay,
|
|
40
44
|
children,
|
|
41
45
|
style,
|
|
42
46
|
onfocus,
|
|
@@ -61,6 +65,14 @@
|
|
|
61
65
|
const selected = $derived(points.selection.includes(id))
|
|
62
66
|
const current = $derived(clampPoint(value, min, max))
|
|
63
67
|
|
|
68
|
+
const gesture = useChangeGesture(() => ({
|
|
69
|
+
value: current,
|
|
70
|
+
inactive,
|
|
71
|
+
onChangeStart,
|
|
72
|
+
onChangeEnd,
|
|
73
|
+
changeEndDelay,
|
|
74
|
+
}))
|
|
75
|
+
|
|
64
76
|
let element: HTMLDivElement | null = $state(null)
|
|
65
77
|
let xInput: HTMLInputElement | null = $state(null)
|
|
66
78
|
let dragging = $state(false)
|
|
@@ -75,6 +87,7 @@
|
|
|
75
87
|
onChange,
|
|
76
88
|
element,
|
|
77
89
|
wheel,
|
|
90
|
+
beforeWheel: () => gesture.pulse('wheel'),
|
|
78
91
|
})
|
|
79
92
|
|
|
80
93
|
$effect(() => points.editor.registerPoint(id, read))
|
|
@@ -92,7 +105,7 @@
|
|
|
92
105
|
sensitivity: (state) =>
|
|
93
106
|
selectModifier(points.dragSensitivity, state.event).value,
|
|
94
107
|
}),
|
|
95
|
-
cursor: untrack(() => (inactive ? undefined : points.
|
|
108
|
+
cursor: untrack(() => (inactive ? undefined : points.dragCursor)),
|
|
96
109
|
shouldStart: () => !disabled,
|
|
97
110
|
// The value is a move rather than a position: the point keeps the
|
|
98
111
|
// offset it was grabbed at, and everything else selected moves with it.
|
|
@@ -105,16 +118,16 @@
|
|
|
105
118
|
origin = { x, y }
|
|
106
119
|
dragging = true
|
|
107
120
|
xInput?.focus()
|
|
108
|
-
if (!inactive)
|
|
121
|
+
if (!inactive) gesture.hold('pointer')
|
|
109
122
|
},
|
|
110
123
|
onDragEnd: () => {
|
|
111
124
|
origin = null
|
|
112
125
|
dragging = false
|
|
113
|
-
|
|
126
|
+
gesture.end()
|
|
114
127
|
},
|
|
115
128
|
})
|
|
116
129
|
$effect(() => {
|
|
117
|
-
drag.update({ cursor: inactive ? undefined : points.
|
|
130
|
+
drag.update({ cursor: inactive ? undefined : points.dragCursor })
|
|
118
131
|
})
|
|
119
132
|
return () => drag.destroy()
|
|
120
133
|
})
|
|
@@ -170,6 +183,7 @@
|
|
|
170
183
|
if (move) {
|
|
171
184
|
event.preventDefault()
|
|
172
185
|
if (onChange && !inactive && keyboard) {
|
|
186
|
+
gesture.pulse('keyboard')
|
|
173
187
|
points.editor.nudgePoint(
|
|
174
188
|
id,
|
|
175
189
|
move.axis === 0 ? 'x' : 'y',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Point.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/PointsEditor/Point.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Point.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/PointsEditor/Point.svelte.ts"],"names":[],"mappings":"AAsBA,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;AAgLvE,QAAA,MAAM,KAAK,2CAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createPointsEditor,
|
|
4
4
|
DEFAULT_DRAG_SENSITIVITY,
|
|
5
|
-
POINTS_EDITOR_DEFAULT_KEYBOARD,
|
|
6
|
-
POINTS_EDITOR_DEFAULT_WHEEL,
|
|
7
5
|
type SelectionBoxRect,
|
|
8
6
|
} from '@tremolo-ui/dom'
|
|
7
|
+
import {
|
|
8
|
+
POINTS_EDITOR_DEFAULT_KEYBOARD,
|
|
9
|
+
POINTS_EDITOR_DEFAULT_WHEEL,
|
|
10
|
+
} from '@tremolo-ui/dom/internal'
|
|
9
11
|
|
|
10
12
|
import { setPointsEditorContext } from './context.js'
|
|
11
13
|
import type { PointsEditorProps } from './types.js'
|
|
@@ -18,7 +20,7 @@
|
|
|
18
20
|
let {
|
|
19
21
|
disabled = false,
|
|
20
22
|
readonly = false,
|
|
21
|
-
|
|
23
|
+
dragCursor = 'grabbing',
|
|
22
24
|
wheel = POINTS_EDITOR_DEFAULT_WHEEL,
|
|
23
25
|
keyboard = POINTS_EDITOR_DEFAULT_KEYBOARD,
|
|
24
26
|
dragSensitivity = DEFAULT_DRAG_SENSITIVITY,
|
|
@@ -73,8 +75,8 @@
|
|
|
73
75
|
get dragSensitivity() {
|
|
74
76
|
return dragSensitivity
|
|
75
77
|
},
|
|
76
|
-
get
|
|
77
|
-
return
|
|
78
|
+
get dragCursor() {
|
|
79
|
+
return dragCursor
|
|
78
80
|
},
|
|
79
81
|
get selectable() {
|
|
80
82
|
return selectable
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Root.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/PointsEditor/Root.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Root.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/PointsEditor/Root.svelte.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,KAAK,GAAG,iBAAiB,GAC5B,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,MAAM,iBAAiB,CAAC,CAAC;AAkGlE,QAAA,MAAM,IAAI,4DAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
|
|
@@ -6,7 +6,7 @@ export interface PointsEditorContextValue {
|
|
|
6
6
|
readonly wheel: ModifierValue<InputEventOption> | null;
|
|
7
7
|
readonly keyboard: ModifierValue<InputEventOption> | null;
|
|
8
8
|
readonly dragSensitivity: ModifierValue<number>;
|
|
9
|
-
readonly
|
|
9
|
+
readonly dragCursor: string;
|
|
10
10
|
readonly selectable: boolean;
|
|
11
11
|
/** Ids of the selected points. Always empty while `selectable` is off. */
|
|
12
12
|
readonly selection: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/PointsEditor/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,iBAAiB,CAAA;AAExB,+EAA+E;AAC/E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAA;IACtD,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAA;IACzD,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC/C,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/PointsEditor/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,iBAAiB,CAAA;AAExB,+EAA+E;AAC/E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAA;IACtD,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAA;IACzD,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC/C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;IACrC,qDAAqD;IACrD,QAAQ,CAAC,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAAA;IAC9C,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAA;IACtC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;IACrC,mDAAmD;IACnD,YAAY,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAA;CACpD;AAID,gFAAgF;AAChF,eAAO,MAAM,sBAAsB,gCAAM,CAAA;AACzC,eAAO,MAAM,sBAAsB,iEAAM,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InputEventOption, ModifierValue, PointPosition } from '@tremolo-ui/dom';
|
|
1
|
+
import type { ChangeSource, InputEventOption, ModifierValue, PointPosition } from '@tremolo-ui/dom';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
export interface PointsEditorProps {
|
|
4
4
|
/** Make the points unchangeable and remove them from the tab order. */
|
|
@@ -7,11 +7,9 @@ export interface PointsEditorProps {
|
|
|
7
7
|
readonly?: boolean;
|
|
8
8
|
/**
|
|
9
9
|
* The cursor to show while dragging a point.
|
|
10
|
-
* @default
|
|
10
|
+
* @default 'grabbing'
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
cursor?: string;
|
|
14
|
-
};
|
|
12
|
+
dragCursor?: string;
|
|
15
13
|
/**
|
|
16
14
|
* How much one notch of the wheel moves the focused `Point`. Scrolling
|
|
17
15
|
* sideways, or with shift held, moves x. A `Point` can override it.
|
|
@@ -77,8 +75,24 @@ export interface PointsEditorPointProps {
|
|
|
77
75
|
* moves along with a selection.
|
|
78
76
|
*/
|
|
79
77
|
onChange?: (value: PointPosition) => void;
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Called when a change of this point starts — a drag on it, the first wheel
|
|
80
|
+
* notch or arrow key while it has the focus — with where it is and what the
|
|
81
|
+
* change is made with. The points that move along with a selection report
|
|
82
|
+
* through `onChange` only.
|
|
83
|
+
*/
|
|
84
|
+
onChangeStart?: (value: PointPosition, source: ChangeSource) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Called when that change ends, with where the point is: on release, or
|
|
87
|
+
* `changeEndDelay` after the last wheel notch or arrow key.
|
|
88
|
+
*/
|
|
89
|
+
onChangeEnd?: (value: PointPosition, source: ChangeSource) => void;
|
|
90
|
+
/**
|
|
91
|
+
* How long after the last wheel notch or arrow key the change counts as
|
|
92
|
+
* over, in milliseconds.
|
|
93
|
+
* @default 500
|
|
94
|
+
*/
|
|
95
|
+
changeEndDelay?: number;
|
|
82
96
|
children?: Snippet;
|
|
83
97
|
}
|
|
84
98
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/PointsEditor/types.ts"],"names":[],"mappings":"A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
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { cssLength, sliderMarks } from '@tremolo-ui/dom'
|
|
2
|
+
import { cssLength, sliderMarks } from '@tremolo-ui/dom/internal'
|
|
3
3
|
|
|
4
4
|
import { setPlacement } from '../_util/placement.js'
|
|
5
5
|
|
|
@@ -21,13 +21,15 @@
|
|
|
21
21
|
if (!options) return []
|
|
22
22
|
const list = sliderMarks(options, slider.min, slider.max, slider.step)
|
|
23
23
|
// In the order they are on screen.
|
|
24
|
-
return slider.vertical !== slider.reverse
|
|
24
|
+
return (slider.orientation === 'vertical') !== slider.reverse
|
|
25
|
+
? list.reverse()
|
|
26
|
+
: list
|
|
25
27
|
})
|
|
26
28
|
</script>
|
|
27
29
|
|
|
28
30
|
<!-- Each option inside is placed against this box. -->
|
|
29
31
|
<div
|
|
30
|
-
data-orientation={slider.
|
|
32
|
+
data-orientation={slider.orientation}
|
|
31
33
|
style="position: relative; {style ?? ''}"
|
|
32
34
|
style:--gap={cssLength(gap)}
|
|
33
35
|
{...rest}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Marks.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/Marks.svelte.ts"],"names":[],"mappings":"AASA,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;
|
|
1
|
+
{"version":3,"file":"Marks.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/Marks.svelte.ts"],"names":[],"mappings":"AASA,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;AAyCjE,QAAA,MAAM,KAAK,2CAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { valuePercent } from '@tremolo-ui/dom'
|
|
3
|
+
import { cssLength } from '@tremolo-ui/dom/internal'
|
|
3
4
|
|
|
4
5
|
import { checkPlacement } from '../_util/placement.js'
|
|
5
6
|
|
|
@@ -32,23 +33,23 @@
|
|
|
32
33
|
valuePercent(
|
|
33
34
|
value,
|
|
34
35
|
{ min: slider.min, max: slider.max, scale: slider.scale },
|
|
35
|
-
slider.vertical !== slider.reverse,
|
|
36
|
+
(slider.orientation === 'vertical') !== slider.reverse,
|
|
36
37
|
),
|
|
37
38
|
)
|
|
38
|
-
const orientation = $derived(slider.
|
|
39
|
+
const orientation = $derived(slider.orientation)
|
|
39
40
|
</script>
|
|
40
41
|
|
|
41
42
|
<div
|
|
42
43
|
data-orientation={orientation}
|
|
43
44
|
{...rest}
|
|
44
|
-
style="position: absolute; translate: {slider.vertical
|
|
45
|
+
style="position: absolute; translate: {slider.orientation === 'vertical'
|
|
45
46
|
? 'var(--translate, 0 -50%)'
|
|
46
47
|
: 'var(--translate, -50% 0)'}; z-index: 10; {style ?? ''}"
|
|
47
48
|
style:--thickness={cssLength(thickness)}
|
|
48
49
|
style:--length={cssLength(length)}
|
|
49
50
|
style:--gap={cssLength(gap)}
|
|
50
|
-
style:left={slider.vertical ? undefined : `${percent}%`}
|
|
51
|
-
style:top={slider.vertical ? `${percent}%` : undefined}
|
|
51
|
+
style:left={slider.orientation === 'vertical' ? undefined : `${percent}%`}
|
|
52
|
+
style:top={slider.orientation === 'vertical' ? `${percent}%` : undefined}
|
|
52
53
|
>
|
|
53
54
|
{#if mark}
|
|
54
55
|
<div
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarksOption.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/MarksOption.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MarksOption.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/MarksOption.svelte.ts"],"names":[],"mappings":"AASA,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;AAqDvE,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
applyDelta,
|
|
4
|
-
arrowKeyDirection,
|
|
5
3
|
DEFAULT_DRAG_SENSITIVITY,
|
|
6
4
|
DEFAULT_KEYBOARD_OPTIONS,
|
|
7
5
|
DEFAULT_WHEEL_OPTIONS,
|
|
8
6
|
elementMapping,
|
|
9
|
-
selectModifier,
|
|
10
7
|
valuePercent,
|
|
11
|
-
wheelDirection,
|
|
12
8
|
type AxisOptions,
|
|
13
9
|
type XY,
|
|
14
10
|
} from '@tremolo-ui/dom'
|
|
11
|
+
import {
|
|
12
|
+
applyDelta,
|
|
13
|
+
arrowKeyDirection,
|
|
14
|
+
selectModifier,
|
|
15
|
+
wheelDirection,
|
|
16
|
+
} from '@tremolo-ui/dom/internal'
|
|
15
17
|
import { linearScale } from '@tremolo-ui/functions'
|
|
16
18
|
|
|
17
19
|
import { dragValue } from '../../actions/drag-value.js'
|
|
18
20
|
import { wheel as wheelAction } from '../../actions/wheel.js'
|
|
21
|
+
import { useChangeGesture } from '../_util/change-gesture.svelte.js'
|
|
19
22
|
import { useCheckSteps } from '../_util/check-steps.svelte.js'
|
|
20
23
|
|
|
21
24
|
import { setSliderContext } from './context.js'
|
|
@@ -32,17 +35,18 @@
|
|
|
32
35
|
max,
|
|
33
36
|
step = 1,
|
|
34
37
|
scale = linearScale,
|
|
35
|
-
|
|
38
|
+
orientation = 'horizontal',
|
|
36
39
|
reverse = false,
|
|
37
|
-
|
|
40
|
+
dragCursor = 'pointer',
|
|
38
41
|
wheel = DEFAULT_WHEEL_OPTIONS,
|
|
39
42
|
keyboard = DEFAULT_KEYBOARD_OPTIONS,
|
|
40
43
|
dragSensitivity = DEFAULT_DRAG_SENSITIVITY,
|
|
41
44
|
disabled = false,
|
|
42
45
|
readonly = false,
|
|
43
46
|
onChange,
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
onChangeStart,
|
|
48
|
+
onChangeEnd,
|
|
49
|
+
changeEndDelay,
|
|
46
50
|
ref = $bindable(null),
|
|
47
51
|
children,
|
|
48
52
|
onkeydown,
|
|
@@ -57,6 +61,7 @@
|
|
|
57
61
|
// vertical -> reversed (up)
|
|
58
62
|
// reverse -> reversed (left)
|
|
59
63
|
// vertical & reverse -> normal (down)
|
|
64
|
+
const vertical = $derived(orientation === 'vertical')
|
|
60
65
|
const displayReversed = $derived(vertical !== reverse)
|
|
61
66
|
const percent = $derived(
|
|
62
67
|
valuePercent(value, { min, max, scale }, displayReversed),
|
|
@@ -81,6 +86,14 @@
|
|
|
81
86
|
onChange?.(next)
|
|
82
87
|
}
|
|
83
88
|
|
|
89
|
+
const gesture = useChangeGesture(() => ({
|
|
90
|
+
value,
|
|
91
|
+
inactive,
|
|
92
|
+
onChangeStart,
|
|
93
|
+
onChangeEnd,
|
|
94
|
+
changeEndDelay,
|
|
95
|
+
}))
|
|
96
|
+
|
|
84
97
|
setSliderContext({
|
|
85
98
|
get value() {
|
|
86
99
|
return value
|
|
@@ -97,8 +110,8 @@
|
|
|
97
110
|
get scale() {
|
|
98
111
|
return scale
|
|
99
112
|
},
|
|
100
|
-
get
|
|
101
|
-
return
|
|
113
|
+
get orientation() {
|
|
114
|
+
return orientation
|
|
102
115
|
},
|
|
103
116
|
get reverse() {
|
|
104
117
|
return reverse
|
|
@@ -129,20 +142,18 @@
|
|
|
129
142
|
sensitivity: (state) =>
|
|
130
143
|
selectModifier(dragSensitivity, state.event).value,
|
|
131
144
|
}),
|
|
132
|
-
cursor: inactive ? undefined :
|
|
145
|
+
cursor: inactive ? undefined : dragCursor,
|
|
133
146
|
shouldStart: () => !inactive,
|
|
134
147
|
updateOnPointerDown: true,
|
|
135
148
|
onChange: (v: XY<number>) => {
|
|
136
149
|
if (!inactive) change(valueOf(v))
|
|
137
150
|
},
|
|
138
|
-
onDragStart: (
|
|
151
|
+
onDragStart: () => {
|
|
139
152
|
if (inactive) return
|
|
153
|
+
gesture.hold('pointer')
|
|
140
154
|
thumb?.focus()
|
|
141
|
-
onDragStart?.(valueOf(v))
|
|
142
|
-
},
|
|
143
|
-
onDragEnd: (v: XY<number>) => {
|
|
144
|
-
if (!inactive) onDragEnd?.(valueOf(v))
|
|
145
155
|
},
|
|
156
|
+
onDragEnd: () => gesture.end(),
|
|
146
157
|
})
|
|
147
158
|
|
|
148
159
|
const wheelOptions = $derived({
|
|
@@ -154,6 +165,7 @@
|
|
|
154
165
|
const direction = wheelDirection(event, { horizontal: !vertical })
|
|
155
166
|
if (direction === null) return
|
|
156
167
|
event.preventDefault()
|
|
168
|
+
gesture.pulse('wheel')
|
|
157
169
|
change(
|
|
158
170
|
applyDelta(value, reverse ? -direction : direction, wheel, axis, event),
|
|
159
171
|
)
|
|
@@ -180,7 +192,7 @@
|
|
|
180
192
|
bind:this={ref}
|
|
181
193
|
role="group"
|
|
182
194
|
tabindex="-1"
|
|
183
|
-
data-orientation={
|
|
195
|
+
data-orientation={orientation}
|
|
184
196
|
data-disabled={disabled ? '' : undefined}
|
|
185
197
|
data-readonly={readonly ? '' : undefined}
|
|
186
198
|
use:dragValue={dragOptions}
|
|
@@ -190,6 +202,7 @@
|
|
|
190
202
|
if (direction !== null) {
|
|
191
203
|
event.preventDefault()
|
|
192
204
|
if (keyboard && !inactive) {
|
|
205
|
+
gesture.pulse('keyboard')
|
|
193
206
|
change(
|
|
194
207
|
applyDelta(
|
|
195
208
|
value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Root.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/Root.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Root.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/Root.svelte.ts"],"names":[],"mappings":"AA0BA,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;AA0M5D,QAAA,MAAM,IAAI;;;mBAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
style="position: absolute; translate: var(--translate, -50% -50%); z-index: 100; {style ??
|
|
56
56
|
''}"
|
|
57
57
|
style:--color={color}
|
|
58
|
-
style:top={slider.vertical ? `${slider.percent}%` : '50%'}
|
|
59
|
-
style:left={slider.vertical ? '50%' : `${slider.percent}%`}
|
|
58
|
+
style:top={slider.orientation === 'vertical' ? `${slider.percent}%` : '50%'}
|
|
59
|
+
style:left={slider.orientation === 'vertical' ? '50%' : `${slider.percent}%`}
|
|
60
60
|
>
|
|
61
61
|
<VisuallyHiddenRangeInput
|
|
62
62
|
bind:ref={input}
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
step={slider.step}
|
|
67
67
|
disabled={slider.disabled}
|
|
68
68
|
aria-readonly={slider.readonly}
|
|
69
|
-
aria-orientation={slider.
|
|
69
|
+
aria-orientation={slider.orientation}
|
|
70
70
|
aria-label={ariaLabel}
|
|
71
71
|
aria-labelledby={ariaLabelledby}
|
|
72
72
|
aria-describedby={ariaDescribedby}
|