fragment-tools 0.1.20 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +2 -2
- package/package.json +5 -6
- package/src/cli/build.js +1 -1
- package/src/cli/run.js +1 -1
- package/src/cli/templates/three-fragment/index.js +6 -6
- package/src/cli/templates/three-orthographic/index.js +3 -3
- package/src/cli/templates/three-perspective/index.js +3 -3
- package/src/client/app/actions/resize.js +14 -0
- package/src/client/app/components/HintLoading.svelte +94 -0
- package/src/client/app/components/HintPaused.svelte +88 -0
- package/src/client/app/components/HintRecord.svelte +62 -0
- package/src/client/app/components/IconLocked.svelte +51 -0
- package/src/client/app/components/IconTriggers.svelte +48 -0
- package/src/client/app/components/Init.svelte +14 -27
- package/src/client/app/components/KeyBinding.svelte +3 -6
- package/src/client/app/helpers.js +4 -40
- package/src/client/app/hooks.js +41 -17
- package/src/client/app/inputs/MIDI.js +2 -1
- package/src/client/app/lib/canvas-recorder/CanvasRecorder.js +6 -1
- package/src/client/app/lib/gl/Renderer.js +1 -0
- package/src/client/app/lib/svelte-json-tree/ErrorNode.svelte +28 -0
- package/src/client/app/lib/svelte-json-tree/ErrorStack.svelte +31 -0
- package/src/client/app/lib/svelte-json-tree/Expandable.svelte +25 -0
- package/src/client/app/lib/svelte-json-tree/JSONArrayNode.svelte +38 -0
- package/src/client/app/lib/svelte-json-tree/JSONArrow.svelte +47 -0
- package/src/client/app/lib/svelte-json-tree/JSONFunctionNode.svelte +114 -0
- package/src/client/app/lib/svelte-json-tree/JSONIterableArrayNode.svelte +60 -0
- package/src/client/app/lib/svelte-json-tree/JSONIterableMapNode.svelte +87 -0
- package/src/client/app/lib/svelte-json-tree/JSONNested.svelte +94 -0
- package/src/client/app/lib/svelte-json-tree/JSONNode.svelte +91 -0
- package/src/client/app/lib/svelte-json-tree/JSONObjectNode.svelte +40 -0
- package/src/client/app/lib/svelte-json-tree/JSONStringNode.svelte +31 -0
- package/src/client/app/lib/svelte-json-tree/JSONValueNode.svelte +31 -0
- package/src/client/app/lib/svelte-json-tree/PreviewList.svelte +38 -0
- package/src/client/app/lib/svelte-json-tree/RegExpNode.svelte +42 -0
- package/src/client/app/lib/svelte-json-tree/Root.svelte +75 -0
- package/src/client/app/lib/svelte-json-tree/Summary.svelte +9 -0
- package/src/client/app/lib/svelte-json-tree/TypedArrayNode.svelte +56 -0
- package/src/client/app/lib/svelte-json-tree/index.js +1 -0
- package/src/client/app/lib/svelte-json-tree/utils.js +57 -0
- package/src/client/app/modules/Console/ConsoleLine.svelte +12 -11
- package/src/client/app/modules/Console.svelte +82 -17
- package/src/client/app/modules/Exports.svelte +48 -48
- package/src/client/app/modules/MidiPanel.svelte +12 -19
- package/src/client/app/modules/Monitor.svelte +147 -55
- package/src/client/app/modules/Params.svelte +127 -80
- package/src/client/app/renderers/2DRenderer.js +1 -0
- package/src/client/app/renderers/FragmentRenderer.js +1 -1
- package/src/client/app/renderers/P5GLRenderer.js +11 -5
- package/src/client/app/renderers/P5Renderer.js +7 -3
- package/src/client/app/renderers/THREERenderer.js +42 -79
- package/src/client/app/state/Sketch.svelte.js +538 -0
- package/src/client/app/state/errors.svelte.js +17 -0
- package/src/client/app/state/exports.svelte.js +152 -0
- package/src/client/app/state/layout.svelte.js +205 -0
- package/src/client/app/state/monitors.svelte.js +36 -0
- package/src/client/app/state/renderers.svelte.js +77 -0
- package/src/client/app/state/rendering.svelte.js +697 -0
- package/src/client/app/state/sketches.svelte.js +73 -0
- package/src/client/app/state/utils.svelte.js +65 -0
- package/src/client/app/ui/Build.svelte +53 -60
- package/src/client/app/ui/ErrorOverlay.svelte +2 -2
- package/src/client/app/ui/Field.svelte +63 -189
- package/src/client/app/ui/FieldGroup.svelte +4 -5
- package/src/client/app/ui/FieldSection.svelte +14 -9
- package/src/client/app/ui/FieldSpace.svelte +1 -1
- package/src/client/app/ui/FieldTrigger.svelte +86 -84
- package/src/client/app/ui/FieldTriggers.svelte +25 -24
- package/src/client/app/ui/FloatingParams.svelte +50 -12
- package/src/client/app/ui/Layout.svelte +24 -13
- package/src/client/app/ui/LayoutColumn.svelte +2 -2
- package/src/client/app/ui/LayoutComponent.svelte +86 -195
- package/src/client/app/ui/LayoutResizer.svelte +25 -37
- package/src/client/app/ui/LayoutRoot.svelte +3 -5
- package/src/client/app/ui/LayoutRow.svelte +2 -2
- package/src/client/app/ui/LayoutToolbar.svelte +17 -76
- package/src/client/app/ui/Module.svelte +31 -35
- package/src/client/app/ui/ModuleHeaderAction.svelte +23 -16
- package/src/client/app/ui/ModuleHeaderButton.svelte +3 -3
- package/src/client/app/ui/ModuleHeaderSelect.svelte +4 -12
- package/src/client/app/ui/ModuleRenderer.svelte +84 -22
- package/src/client/app/ui/ParamsOutput.svelte +61 -77
- package/src/client/app/ui/Preview.svelte +15 -4
- package/src/client/app/ui/SelectChevrons.svelte +1 -2
- package/src/client/app/ui/SketchRenderer.svelte +89 -701
- package/src/client/app/ui/SketchSelect.svelte +14 -49
- package/src/client/app/ui/fields/ButtonInput.svelte +14 -11
- package/src/client/app/ui/fields/CheckboxInput.svelte +5 -12
- package/src/client/app/ui/fields/ColorInput.svelte +46 -121
- package/src/client/app/ui/fields/FieldInputRow.svelte +5 -1
- package/src/client/app/ui/fields/ImageInput.svelte +14 -14
- package/src/client/app/ui/fields/Input.svelte +19 -25
- package/src/client/app/ui/fields/IntervalInput.svelte +22 -22
- package/src/client/app/ui/fields/NumberInput.svelte +32 -38
- package/src/client/app/ui/fields/ProgressInput.svelte +14 -13
- package/src/client/app/ui/fields/Select.svelte +34 -45
- package/src/client/app/ui/fields/TextInput.svelte +10 -6
- package/src/client/app/ui/fields/VectorInput.svelte +25 -30
- package/src/client/app/utils/canvas.utils.js +8 -8
- package/src/client/app/utils/color.utils.js +46 -13
- package/src/client/app/utils/fields.utils.js +1 -1
- package/src/client/app/utils/glsl.utils.js +1 -1
- package/src/client/app/utils/glslErrors.js +1 -1
- package/src/client/main.js +2 -2
|
@@ -1,55 +1,20 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import ModuleHeaderAction from './ModuleHeaderAction.svelte';
|
|
3
|
-
import {
|
|
4
|
-
sketches,
|
|
5
|
-
sketchesKeys,
|
|
6
|
-
sketchesCount,
|
|
7
|
-
} from '../stores/sketches.js';
|
|
8
|
-
import { monitors } from '../stores/rendering';
|
|
3
|
+
import { sketchesManager } from '../state/sketches.svelte';
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
export let selected;
|
|
5
|
+
let { sketchKey = sketchesManager.keys[0], onchange } = $props();
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
$sketchesCount > 1 &&
|
|
26
|
-
!options.some((opt) => opt.value === 'output')
|
|
27
|
-
) {
|
|
28
|
-
options = [...options, { value: 'output', label: 'output' }];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (options.length > 0 && selected === undefined) {
|
|
32
|
-
selected = options[0].value;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
$: {
|
|
37
|
-
monitors.update((all) => {
|
|
38
|
-
return all.map((monitor) => {
|
|
39
|
-
if (monitor.id === monitorID) {
|
|
40
|
-
monitor.selected = selected;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return monitor;
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
7
|
+
let options = $derived(
|
|
8
|
+
[
|
|
9
|
+
...sketchesManager.keys.map((key) => {
|
|
10
|
+
const name = sketchesManager.sketches[key].name ?? key;
|
|
11
|
+
return { value: key, label: name };
|
|
12
|
+
}),
|
|
13
|
+
sketchesManager.count > 1
|
|
14
|
+
? { value: 'output', label: 'output' }
|
|
15
|
+
: undefined,
|
|
16
|
+
].filter((opt) => opt !== undefined),
|
|
17
|
+
);
|
|
47
18
|
</script>
|
|
48
19
|
|
|
49
|
-
<ModuleHeaderAction
|
|
50
|
-
value={selected}
|
|
51
|
-
permanent
|
|
52
|
-
border
|
|
53
|
-
on:change={(event) => (selected = event.detail)}
|
|
54
|
-
{options}
|
|
55
|
-
/>
|
|
20
|
+
<ModuleHeaderAction value={sketchKey} permanent border {onchange} {options} />
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
let {
|
|
3
|
+
label = 'run',
|
|
4
|
+
disabled = false,
|
|
5
|
+
showLabel = true,
|
|
6
|
+
title = '',
|
|
7
|
+
onclick,
|
|
8
|
+
onmouseenter,
|
|
9
|
+
onmouseleave,
|
|
10
|
+
children,
|
|
11
|
+
} = $props();
|
|
9
12
|
</script>
|
|
10
13
|
|
|
11
14
|
<div class="button-container" class:disabled>
|
|
12
15
|
<button
|
|
13
16
|
class="button"
|
|
14
17
|
{disabled}
|
|
15
|
-
|
|
18
|
+
{onclick}
|
|
19
|
+
{onmouseenter}
|
|
20
|
+
{onmouseleave}
|
|
16
21
|
{title}
|
|
17
|
-
on:mouseenter
|
|
18
|
-
on:mouseleave
|
|
19
22
|
>
|
|
20
23
|
<span class="label" class:visually-hidden={!showLabel}>{label}</span>
|
|
21
|
-
|
|
24
|
+
{@render children?.()}
|
|
22
25
|
</button>
|
|
23
26
|
</div>
|
|
24
27
|
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
2
|
+
let { value = $bindable(), context, key = '', disabled = false, onchange } = $props();
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export let disabled = false;
|
|
8
|
-
|
|
9
|
-
const dispatch = createEventDispatcher();
|
|
10
|
-
|
|
11
|
-
function handleChange() {
|
|
12
|
-
dispatch('change', value);
|
|
13
|
-
}
|
|
4
|
+
const handleChange = (event) => {
|
|
5
|
+
onchange(value);
|
|
6
|
+
};
|
|
14
7
|
</script>
|
|
15
8
|
|
|
16
9
|
<div class="checkbox">
|
|
@@ -18,7 +11,7 @@
|
|
|
18
11
|
class="input"
|
|
19
12
|
bind:checked={value}
|
|
20
13
|
type="checkbox"
|
|
21
|
-
|
|
14
|
+
onchange={handleChange}
|
|
22
15
|
disabled={disabled ? 'disabled' : null}
|
|
23
16
|
/>
|
|
24
17
|
<div class="checked" />
|
|
@@ -1,147 +1,73 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { createEventDispatcher } from 'svelte';
|
|
3
2
|
import * as color from '../../utils/color.utils.js';
|
|
4
3
|
import TextInput from './TextInput.svelte';
|
|
5
4
|
import Field from '../Field.svelte';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
export let context = null;
|
|
9
|
-
export let key = '';
|
|
10
|
-
export let disabled = false;
|
|
6
|
+
let { value, context = null, key = '', disabled = false, onchange } = $props();
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
$: alpha = 1;
|
|
18
|
-
$: hasAlpha = [
|
|
8
|
+
let format = $derived(color.getColorFormat(value));
|
|
9
|
+
let hexValue = $derived(color.toHex(value, format));
|
|
10
|
+
let textValue = $state();
|
|
11
|
+
let alpha = $state(1);
|
|
12
|
+
let hasAlpha = $derived([
|
|
19
13
|
color.FORMATS.RGBA_STRING,
|
|
20
14
|
color.FORMATS.VEC4_STRING,
|
|
21
15
|
color.FORMATS.VEC4_ARRAY,
|
|
22
16
|
color.FORMATS.RGBA_OBJECT,
|
|
23
17
|
color.FORMATS.HSLA_STRING,
|
|
24
|
-
].includes(format);
|
|
25
|
-
|
|
18
|
+
].includes(format));
|
|
19
|
+
|
|
20
|
+
$effect(() => {
|
|
26
21
|
if (hasAlpha) {
|
|
27
22
|
const [r, g, b, a = 1] = color.toComponents(value);
|
|
28
23
|
alpha = a;
|
|
29
24
|
} else {
|
|
30
25
|
alpha = 1;
|
|
31
26
|
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function dispatchChange() {
|
|
35
|
-
const [r, g, b] = color.hexToComponents(hexValue);
|
|
27
|
+
})
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
value[0] = r;
|
|
41
|
-
value[1] = g;
|
|
42
|
-
value[2] = b;
|
|
43
|
-
dispatch('change', value);
|
|
44
|
-
break;
|
|
45
|
-
case color.FORMATS.VEC4_ARRAY:
|
|
46
|
-
value[0] = r;
|
|
47
|
-
value[1] = g;
|
|
48
|
-
value[2] = b;
|
|
49
|
-
value[3] = alpha;
|
|
50
|
-
dispatch('change', value);
|
|
51
|
-
break;
|
|
52
|
-
case color.FORMATS.THREE:
|
|
53
|
-
case color.FORMATS.RGB_OBJECT:
|
|
54
|
-
value.r = r;
|
|
55
|
-
value.g = g;
|
|
56
|
-
value.b = b;
|
|
29
|
+
$effect(() => {
|
|
30
|
+
textValue = color.toString(value, format)?.toLowerCase();
|
|
31
|
+
});
|
|
57
32
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
case color.FORMATS.RGBA_OBJECT:
|
|
61
|
-
value.r = r;
|
|
62
|
-
value.g = g;
|
|
63
|
-
value.b = b;
|
|
64
|
-
value.a = alpha;
|
|
33
|
+
function dispatchChange(newColor) {
|
|
34
|
+
const newFormat = color.getColorFormat(newColor);
|
|
65
35
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
36
|
+
if (format === newFormat) {
|
|
37
|
+
onchange(newColor);
|
|
38
|
+
} else {
|
|
39
|
+
const components = color.toComponents(newColor);
|
|
40
|
+
const [r, g, b] = components;
|
|
41
|
+
|
|
42
|
+
switch(format) {
|
|
43
|
+
case color.FORMATS.RGB_OBJECT:
|
|
44
|
+
onchange({ r, g, b });
|
|
45
|
+
break;
|
|
46
|
+
case color.FORMATS.RGBA_OBJECT:
|
|
47
|
+
onchange({ r, g, b, a: alpha });
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
onchange(color.componentsToFormat([r, g, b, alpha], format));
|
|
51
|
+
}
|
|
70
52
|
}
|
|
71
53
|
}
|
|
72
54
|
|
|
73
|
-
function handleBlur() {
|
|
74
|
-
dispatchChange();
|
|
55
|
+
function handleBlur(event) {
|
|
56
|
+
dispatchChange(event.currentTarget.value);
|
|
75
57
|
}
|
|
76
58
|
|
|
77
59
|
function onChangeText(event) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (color.isColor(newColor)) {
|
|
81
|
-
textValue = newColor;
|
|
82
|
-
} else {
|
|
83
|
-
// newColor is not a color, reset value
|
|
84
|
-
textValue = color.toString(value, format);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
hexValue = color.toHex(textValue);
|
|
88
|
-
dispatchChange();
|
|
60
|
+
dispatchChange(event.currentTarget.value);
|
|
89
61
|
}
|
|
90
62
|
|
|
91
|
-
function onChangeAlpha(
|
|
92
|
-
alpha =
|
|
93
|
-
|
|
94
|
-
const [r, g, b] = color.hexToComponents(hexValue);
|
|
95
|
-
|
|
96
|
-
switch (format) {
|
|
97
|
-
case color.FORMATS.RGBA_STRING:
|
|
98
|
-
case color.FORMATS.RGBA_OBJECT:
|
|
99
|
-
textValue = color.componentsToRGBAString([r, g, b, alpha]);
|
|
100
|
-
break;
|
|
101
|
-
case color.FORMATS.VEC4_STRING:
|
|
102
|
-
textValue = color.componentsToVec4String([r, g, b, alpha]);
|
|
103
|
-
break;
|
|
104
|
-
case color.FORMATS.HSLA_STRING:
|
|
105
|
-
const [h, s, l] = color.hslToHSLComponents(textValue);
|
|
106
|
-
textValue = color.hslaToHSLAString([h, s, l, alpha]);
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
63
|
+
function onChangeAlpha(newAlpha) {
|
|
64
|
+
alpha = newAlpha;
|
|
109
65
|
|
|
110
|
-
dispatchChange();
|
|
66
|
+
dispatchChange(color.toHex(value));
|
|
111
67
|
}
|
|
112
68
|
|
|
113
69
|
function onInput(event) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const [r, g, b] = color.hexToComponents(hexValue);
|
|
117
|
-
|
|
118
|
-
switch (format) {
|
|
119
|
-
case color.FORMATS.RGBA_STRING:
|
|
120
|
-
case color.FORMATS.RGBA_OBJECT:
|
|
121
|
-
textValue = color.toRGBAString({ r, g, b, a: alpha });
|
|
122
|
-
break;
|
|
123
|
-
case color.FORMATS.VEC3_STRING:
|
|
124
|
-
textValue = color.componentsToVec3String([r, g, b]);
|
|
125
|
-
break;
|
|
126
|
-
case color.FORMATS.VEC4_STRING:
|
|
127
|
-
textValue = color.componentsToVec4String([r, g, b, alpha]);
|
|
128
|
-
break;
|
|
129
|
-
case color.FORMATS.RGB_STRING:
|
|
130
|
-
case color.FORMATS.RGB_OBJECT:
|
|
131
|
-
textValue = color.toRGBString(hexValue);
|
|
132
|
-
break;
|
|
133
|
-
case color.FORMATS.HSL_STRING:
|
|
134
|
-
textValue = color.componentsToHSLString([r, g, b]);
|
|
135
|
-
break;
|
|
136
|
-
case color.FORMATS.HSLA_STRING:
|
|
137
|
-
textValue = color.componentsToHSLAString([r, g, b, alpha]);
|
|
138
|
-
break;
|
|
139
|
-
default:
|
|
140
|
-
textValue = color.toString(hexValue);
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
dispatchChange();
|
|
70
|
+
dispatchChange(event.currentTarget.value);
|
|
145
71
|
}
|
|
146
72
|
</script>
|
|
147
73
|
|
|
@@ -204,31 +130,30 @@
|
|
|
204
130
|
/>
|
|
205
131
|
</svg>
|
|
206
132
|
{/if}
|
|
207
|
-
<!-- svelte-ignore -->
|
|
208
133
|
<input
|
|
209
134
|
class="input"
|
|
210
135
|
type="color"
|
|
211
136
|
disabled={disabled ? 'disabled' : null}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
137
|
+
value={hexValue}
|
|
138
|
+
onblur={handleBlur}
|
|
139
|
+
oninput={onInput}
|
|
215
140
|
/>
|
|
216
141
|
</div>
|
|
217
142
|
<TextInput
|
|
218
143
|
{context}
|
|
219
144
|
{key}
|
|
220
145
|
{disabled}
|
|
221
|
-
|
|
222
|
-
|
|
146
|
+
value={textValue}
|
|
147
|
+
onchange={onChangeText}
|
|
223
148
|
/>
|
|
224
149
|
</div>
|
|
225
150
|
{#if hasAlpha}
|
|
226
151
|
<Field
|
|
227
|
-
key=
|
|
152
|
+
key="alpha"
|
|
228
153
|
value={alpha}
|
|
229
|
-
params={{
|
|
154
|
+
params={{ min: 0, max: 1, step: 0.01 }}
|
|
230
155
|
{context}
|
|
231
|
-
|
|
156
|
+
onchange={onChangeAlpha}
|
|
232
157
|
/>
|
|
233
158
|
{/if}
|
|
234
159
|
</div>
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { onMount } from 'svelte';
|
|
3
2
|
import { loadImage } from '../../lib/loader/loadImage';
|
|
4
3
|
import ButtonInput from './ButtonInput.svelte';
|
|
5
4
|
import FieldInputRow from './FieldInputRow.svelte';
|
|
6
5
|
import TextInput from './TextInput.svelte';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
let { value, context = null, key = '', disabled = false } = $props();
|
|
8
|
+
|
|
9
|
+
/** @type {HTMLImageElement} */
|
|
10
|
+
let img;
|
|
11
|
+
/** @type {HTMLInputElement} */
|
|
12
|
+
let input;
|
|
13
|
+
|
|
14
|
+
let name = $state('');
|
|
15
|
+
let url = $derived(typeof value === HTMLImageElement ? value.src : value);
|
|
16
|
+
let displayUrl = $derived(name ? name : url.replace(`/@fs${__CWD__}`, ''));
|
|
17
|
+
|
|
18
|
+
$effect(async () => {
|
|
19
|
+
await loadImage(url, { img });
|
|
20
|
+
});
|
|
21
21
|
|
|
22
22
|
function handleClick() {
|
|
23
23
|
input.click();
|
|
@@ -1,45 +1,39 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
let {
|
|
3
|
+
label,
|
|
4
|
+
value = $bindable(),
|
|
5
|
+
disabled = false,
|
|
6
|
+
oninput,
|
|
7
|
+
onchange,
|
|
8
|
+
onkeydown,
|
|
9
|
+
onfocus,
|
|
10
|
+
onblur,
|
|
11
|
+
} = $props();
|
|
12
|
+
|
|
13
|
+
/** @type {HTMLInputElement} */
|
|
10
14
|
let node;
|
|
11
15
|
|
|
12
|
-
const dispatch = createEventDispatcher();
|
|
13
|
-
|
|
14
16
|
function onKeyPress(event) {
|
|
15
17
|
if (event.key === 'Enter') {
|
|
16
18
|
node.blur();
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
function handleInput(event) {
|
|
21
|
-
dispatch('input', event.currentTarget.value);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function handleChange(event) {
|
|
25
|
-
dispatch('change', event.currentTarget.value);
|
|
26
|
-
}
|
|
27
21
|
</script>
|
|
28
22
|
|
|
29
23
|
<div class="input-container" class:disabled>
|
|
30
|
-
{#if label}
|
|
24
|
+
{#if label !== undefined}
|
|
31
25
|
<span class="label">{label}</span>
|
|
32
26
|
{/if}
|
|
33
27
|
<input
|
|
34
28
|
class="input"
|
|
35
29
|
bind:this={node}
|
|
36
30
|
bind:value
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
{oninput}
|
|
32
|
+
{onchange}
|
|
33
|
+
{onkeydown}
|
|
34
|
+
{onfocus}
|
|
35
|
+
{onblur}
|
|
36
|
+
onkeypress={onKeyPress}
|
|
43
37
|
disabled={disabled ? 'disabled' : null}
|
|
44
38
|
autocomplete="off"
|
|
45
39
|
spellcheck="false"
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
import FieldInputRow from './FieldInputRow.svelte';
|
|
3
3
|
import NumberInput from './NumberInput.svelte';
|
|
4
4
|
import { map, clamp, roundToStep } from '../../utils/math.utils';
|
|
5
|
-
import { createEventDispatcher } from 'svelte';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
let {
|
|
7
|
+
value = null,
|
|
8
|
+
label,
|
|
9
|
+
step = 1,
|
|
10
|
+
suffix = '',
|
|
11
|
+
min = -Infinity,
|
|
12
|
+
max = Infinity,
|
|
13
|
+
disabled = false,
|
|
14
|
+
context,
|
|
15
|
+
key,
|
|
16
|
+
onchange,
|
|
17
|
+
} = $props();
|
|
18
18
|
|
|
19
19
|
/** @type {HTMLElement} */
|
|
20
20
|
let node;
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
|
|
41
41
|
let dragValue = computeDrag(event);
|
|
42
42
|
|
|
43
|
-
let abs0 = Math.abs(dragValue -
|
|
44
|
-
let abs1 = Math.abs(dragValue -
|
|
43
|
+
let abs0 = Math.abs(dragValue - value[0]);
|
|
44
|
+
let abs1 = Math.abs(dragValue - value[1]);
|
|
45
45
|
|
|
46
46
|
proximityIndex = abs0 < abs1 ? 0 : 1;
|
|
47
47
|
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
value[0] = newValues[0];
|
|
81
81
|
value[1] = newValues[1];
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
onchange(value);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -95,10 +95,10 @@
|
|
|
95
95
|
function handleValueChange(index, newValue) {
|
|
96
96
|
value[index] = newValue;
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
onchange(value);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
$effect(() => {
|
|
102
102
|
if (value[0] > value[1]) {
|
|
103
103
|
console.warn(`Values provided for ${key} are in the wrong order. `);
|
|
104
104
|
}
|
|
@@ -110,10 +110,10 @@
|
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
|
-
}
|
|
113
|
+
});
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
let p1 = $derived(map(clamp(value[0], min, max), min, max, 0, 1));
|
|
116
|
+
let p2 = $derived(map(clamp(value[1], min, max), min, max, 0, 1));
|
|
117
117
|
</script>
|
|
118
118
|
|
|
119
119
|
<div class="interval-input" class:disabled>
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
{min}
|
|
139
139
|
{max}
|
|
140
140
|
progress={false}
|
|
141
|
-
|
|
141
|
+
value={value[0]}
|
|
142
142
|
on:change={(event) => handleValueChange(0, event.detail)}
|
|
143
143
|
/>
|
|
144
144
|
<NumberInput
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
{min}
|
|
152
152
|
{max}
|
|
153
153
|
progress={false}
|
|
154
|
-
|
|
154
|
+
value={value[1]}
|
|
155
155
|
on:change={(event) => handleValueChange(1, event.detail)}
|
|
156
156
|
/>
|
|
157
157
|
</div>
|