mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 05:18:19 +00:00
Phase 4: removes svelte/legacy compat APIs
This commit is contained in:
parent
8c4340d6ed
commit
fc5d59bb2e
6 changed files with 49 additions and 48 deletions
|
@ -1,7 +1,4 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createBubbler, stopPropagation, passive } from 'svelte/legacy';
|
|
||||||
|
|
||||||
const bubble = createBubbler();
|
|
||||||
import { getContext, onMount } from "svelte";
|
import { getContext, onMount } from "svelte";
|
||||||
|
|
||||||
import type { FrontendNodeType } from "@graphite/messages";
|
import type { FrontendNodeType } from "@graphite/messages";
|
||||||
|
@ -10,6 +7,7 @@
|
||||||
import TextButton from "@graphite/components/widgets/buttons/TextButton.svelte";
|
import TextButton from "@graphite/components/widgets/buttons/TextButton.svelte";
|
||||||
import TextInput from "@graphite/components/widgets/inputs/TextInput.svelte";
|
import TextInput from "@graphite/components/widgets/inputs/TextInput.svelte";
|
||||||
import TextLabel from "@graphite/components/widgets/labels/TextLabel.svelte";
|
import TextLabel from "@graphite/components/widgets/labels/TextLabel.svelte";
|
||||||
|
import type { WheelEventHandler } from 'svelte/elements';
|
||||||
|
|
||||||
const nodeGraph = getContext<NodeGraphState>("nodeGraph");
|
const nodeGraph = getContext<NodeGraphState>("nodeGraph");
|
||||||
|
|
||||||
|
@ -17,9 +15,10 @@
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
initialSearchTerm?: string;
|
initialSearchTerm?: string;
|
||||||
onselectNodeType?: (selectNodeType: string) => void;
|
onselectNodeType?: (selectNodeType: string) => void;
|
||||||
|
onwheel?: WheelEventHandler<HTMLDivElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { disabled = false, initialSearchTerm = "", onselectNodeType }: Props = $props();
|
let { disabled = false, initialSearchTerm = "", onselectNodeType, onwheel }: Props = $props();
|
||||||
|
|
||||||
let nodeSearchInput: TextInput | undefined = $state(undefined);
|
let nodeSearchInput: TextInput | undefined = $state(undefined);
|
||||||
let searchTerm = $state(initialSearchTerm);
|
let searchTerm = $state(initialSearchTerm);
|
||||||
|
@ -118,7 +117,12 @@
|
||||||
|
|
||||||
<div class="node-catalog">
|
<div class="node-catalog">
|
||||||
<TextInput placeholder="Search Nodes..." bind:value={searchTerm} bind:this={nodeSearchInput} />
|
<TextInput placeholder="Search Nodes..." bind:value={searchTerm} bind:this={nodeSearchInput} />
|
||||||
<div class="list-results" use:passive={['wheel', () => stopPropagation(bubble('wheel'))]}>
|
<div class="list-results" onwheel={(event) => {
|
||||||
|
// onwheel events are passive by default
|
||||||
|
// https://svelte.dev/docs/svelte/v5-migration-guide#Breaking-changes-in-runes-mode-Touch-and-wheel-events-are-passive
|
||||||
|
event.stopPropagation();
|
||||||
|
onwheel?.(event);
|
||||||
|
}}>
|
||||||
{#each nodeCategories as nodeCategory}
|
{#each nodeCategories as nodeCategory}
|
||||||
<details open={nodeCategory[1].open}>
|
<details open={nodeCategory[1].open}>
|
||||||
<summary>
|
<summary>
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { SvelteHTMLElements } from 'svelte/elements';
|
import type { SvelteHTMLElements } from 'svelte/elements';
|
||||||
import { createBubbler } from 'svelte/legacy';
|
|
||||||
|
|
||||||
const bubble = createBubbler();
|
|
||||||
|
|
||||||
type DivHTMLElementProps = SvelteHTMLElements["div"];
|
type DivHTMLElementProps = SvelteHTMLElements["div"];
|
||||||
|
|
||||||
|
@ -54,26 +51,26 @@
|
||||||
style={`${styleName} ${extraStyles}`.trim() || undefined}
|
style={`${styleName} ${extraStyles}`.trim() || undefined}
|
||||||
title={tooltip}
|
title={tooltip}
|
||||||
bind:this={self}
|
bind:this={self}
|
||||||
onauxclick={bubble('auxclick')}
|
|
||||||
onblur={bubble('blur')}
|
|
||||||
onclick={bubble('click')}
|
|
||||||
ondblclick={bubble('dblclick')}
|
|
||||||
ondragend={bubble('dragend')}
|
|
||||||
ondragleave={bubble('dragleave')}
|
|
||||||
ondragover={bubble('dragover')}
|
|
||||||
ondragstart={bubble('dragstart')}
|
|
||||||
ondrop={bubble('drop')}
|
|
||||||
onmouseup={bubble('mouseup')}
|
|
||||||
onpointerdown={bubble('pointerdown')}
|
|
||||||
onpointerenter={bubble('pointerenter')}
|
|
||||||
onpointerleave={bubble('pointerleave')}
|
|
||||||
onscroll={bubble('scroll')}
|
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Unused (each impacts performance, see <https://github.com/GraphiteEditor/Graphite/issues/1877>):
|
<!-- Unused (each impacts performance, see <https://github.com/GraphiteEditor/Graphite/issues/1877>):
|
||||||
|
onauxclick={bubble('auxclick')}
|
||||||
|
onblur={bubble('blur')}
|
||||||
|
onclick={bubble('click')}
|
||||||
|
ondblclick={bubble('dblclick')}
|
||||||
|
ondragend={bubble('dragend')}
|
||||||
|
ondragleave={bubble('dragleave')}
|
||||||
|
ondragover={bubble('dragover')}
|
||||||
|
ondragstart={bubble('dragstart')}
|
||||||
|
ondrop={bubble('drop')}
|
||||||
|
onmouseup={bubble('mouseup')}
|
||||||
|
onpointerdown={bubble('pointerdown')}
|
||||||
|
onpointerenter={bubble('pointerenter')}
|
||||||
|
onpointerleave={bubble('pointerleave')}
|
||||||
|
onscroll={bubble('scroll')}
|
||||||
on:contextmenu
|
on:contextmenu
|
||||||
on:copy
|
on:copy
|
||||||
on:cut
|
on:cut
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { SvelteHTMLElements } from 'svelte/elements';
|
import type { SvelteHTMLElements } from 'svelte/elements';
|
||||||
import { createBubbler } from 'svelte/legacy';
|
|
||||||
|
|
||||||
const bubble = createBubbler();
|
|
||||||
|
|
||||||
type DivHTMLElementProps = SvelteHTMLElements["div"];
|
type DivHTMLElementProps = SvelteHTMLElements["div"];
|
||||||
|
|
||||||
|
@ -55,26 +52,26 @@
|
||||||
style={`${styleName} ${extraStyles}`.trim() || undefined}
|
style={`${styleName} ${extraStyles}`.trim() || undefined}
|
||||||
title={tooltip}
|
title={tooltip}
|
||||||
bind:this={self}
|
bind:this={self}
|
||||||
onauxclick={bubble('auxclick')}
|
|
||||||
onblur={bubble('blur')}
|
|
||||||
onclick={bubble('click')}
|
|
||||||
ondblclick={bubble('dblclick')}
|
|
||||||
ondragend={bubble('dragend')}
|
|
||||||
ondragleave={bubble('dragleave')}
|
|
||||||
ondragover={bubble('dragover')}
|
|
||||||
ondragstart={bubble('dragstart')}
|
|
||||||
ondrop={bubble('drop')}
|
|
||||||
onmouseup={bubble('mouseup')}
|
|
||||||
onpointerdown={bubble('pointerdown')}
|
|
||||||
onpointerenter={bubble('pointerenter')}
|
|
||||||
onpointerleave={bubble('pointerleave')}
|
|
||||||
onscroll={bubble('scroll')}
|
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Unused (each impacts performance, see <https://github.com/GraphiteEditor/Graphite/issues/1877>):
|
<!-- Unused (each impacts performance, see <https://github.com/GraphiteEditor/Graphite/issues/1877>):
|
||||||
|
onauxclick={bubble('auxclick')}
|
||||||
|
onblur={bubble('blur')}
|
||||||
|
onclick={bubble('click')}
|
||||||
|
ondblclick={bubble('dblclick')}
|
||||||
|
ondragend={bubble('dragend')}
|
||||||
|
ondragleave={bubble('dragleave')}
|
||||||
|
ondragover={bubble('dragover')}
|
||||||
|
ondragstart={bubble('dragstart')}
|
||||||
|
ondrop={bubble('drop')}
|
||||||
|
onmouseup={bubble('mouseup')}
|
||||||
|
onpointerdown={bubble('pointerdown')}
|
||||||
|
onpointerenter={bubble('pointerenter')}
|
||||||
|
onpointerleave={bubble('pointerleave')}
|
||||||
|
onscroll={bubble('scroll')}
|
||||||
on:contextmenu
|
on:contextmenu
|
||||||
on:copy
|
on:copy
|
||||||
on:cut
|
on:cut
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { handlers } from 'svelte/legacy';
|
|
||||||
|
|
||||||
import { getContext, onMount, onDestroy, tick } from "svelte";
|
import { getContext, onMount, onDestroy, tick } from "svelte";
|
||||||
|
|
||||||
import type { Editor } from "@graphite/editor";
|
import type { Editor } from "@graphite/editor";
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import WidgetSection from './WidgetSection.svelte';
|
import WidgetSection from './WidgetSection.svelte';
|
||||||
import { stopPropagation } from 'svelte/legacy';
|
|
||||||
|
|
||||||
import { getContext } from "svelte";
|
import { getContext } from "svelte";
|
||||||
|
|
||||||
|
@ -37,7 +36,10 @@
|
||||||
|
|
||||||
<!-- TODO: Implement collapsable sections with properties system -->
|
<!-- TODO: Implement collapsable sections with properties system -->
|
||||||
<LayoutCol class={`widget-section ${className}`.trim()} {classes}>
|
<LayoutCol class={`widget-section ${className}`.trim()} {classes}>
|
||||||
<button class="header" class:expanded onclick={stopPropagation(() => (expanded = !expanded))} tabindex="0">
|
<button class="header" class:expanded onclick={(event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
expanded = !expanded;
|
||||||
|
}} tabindex="0">
|
||||||
<div class="expand-arrow"></div>
|
<div class="expand-arrow"></div>
|
||||||
<TextLabel tooltip={widgetData.description} bold={true}>{widgetData.name}</TextLabel>
|
<TextLabel tooltip={widgetData.description} bold={true}>{widgetData.name}</TextLabel>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createBubbler, preventDefault } from 'svelte/legacy';
|
|
||||||
|
|
||||||
const bubble = createBubbler();
|
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
|
|
||||||
import { PRESS_REPEAT_DELAY_MS, PRESS_REPEAT_INTERVAL_MS } from "@graphite/io-managers/input";
|
import { PRESS_REPEAT_DELAY_MS, PRESS_REPEAT_INTERVAL_MS } from "@graphite/io-managers/input";
|
||||||
|
@ -10,6 +7,7 @@
|
||||||
|
|
||||||
import { preventEscapeClosingParentFloatingMenu } from "@graphite/components/layout/FloatingMenu.svelte";
|
import { preventEscapeClosingParentFloatingMenu } from "@graphite/components/layout/FloatingMenu.svelte";
|
||||||
import FieldInput from "@graphite/components/widgets/inputs/FieldInput.svelte";
|
import FieldInput from "@graphite/components/widgets/inputs/FieldInput.svelte";
|
||||||
|
import type { MouseEventHandler } from 'svelte/elements';
|
||||||
|
|
||||||
const BUTTONS_LEFT = 0b0000_0001;
|
const BUTTONS_LEFT = 0b0000_0001;
|
||||||
const BUTTONS_RIGHT = 0b0000_0010;
|
const BUTTONS_RIGHT = 0b0000_0010;
|
||||||
|
@ -56,6 +54,7 @@
|
||||||
incrementCallbackDecrease?: (() => void) | undefined;
|
incrementCallbackDecrease?: (() => void) | undefined;
|
||||||
onvalue?: (value: number | undefined) => void;
|
onvalue?: (value: number | undefined) => void;
|
||||||
onstartHistoryTransaction?: () => void;
|
onstartHistoryTransaction?: () => void;
|
||||||
|
oncontextmenu?: MouseEventHandler<HTMLInputElement>
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
@ -80,6 +79,7 @@
|
||||||
incrementCallbackDecrease = undefined,
|
incrementCallbackDecrease = undefined,
|
||||||
onvalue,
|
onvalue,
|
||||||
onstartHistoryTransaction,
|
onstartHistoryTransaction,
|
||||||
|
oncontextmenu,
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
let self: FieldInput | undefined = $state();
|
let self: FieldInput | undefined = $state();
|
||||||
|
@ -708,13 +708,16 @@
|
||||||
class="slider"
|
class="slider"
|
||||||
class:hidden={rangeSliderClickDragState === "Deciding"}
|
class:hidden={rangeSliderClickDragState === "Deciding"}
|
||||||
{disabled}
|
{disabled}
|
||||||
min={rangeMin}
|
min={rangeMin}
|
||||||
max={rangeMax}
|
max={rangeMax}
|
||||||
step={sliderStepValue}
|
step={sliderStepValue}
|
||||||
bind:value={rangeSliderValue}
|
bind:value={rangeSliderValue}
|
||||||
oninput={onSliderInput}
|
oninput={onSliderInput}
|
||||||
onpointerup={onSliderPointerUp}
|
onpointerup={onSliderPointerUp}
|
||||||
oncontextmenu={preventDefault(bubble('contextmenu'))}
|
oncontextmenu={(event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
oncontextmenu?.(event);
|
||||||
|
}}
|
||||||
onwheel={(e) => /* Stops slider eating the scroll event in Firefox */ e.target instanceof HTMLInputElement && e.target.blur()}
|
onwheel={(e) => /* Stops slider eating the scroll event in Firefox */ e.target instanceof HTMLInputElement && e.target.blur()}
|
||||||
bind:this={inputRangeElement}
|
bind:this={inputRangeElement}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue