diff --git a/flow-editor/src/visual-node-editor/MacroInstanceEditor/ConfigurableInputEditor.tsx b/flow-editor/src/visual-node-editor/MacroInstanceEditor/ConfigurableInputEditor.tsx index 0f27524ff..87585f2f4 100644 --- a/flow-editor/src/visual-node-editor/MacroInstanceEditor/ConfigurableInputEditor.tsx +++ b/flow-editor/src/visual-node-editor/MacroInstanceEditor/ConfigurableInputEditor.tsx @@ -1,9 +1,13 @@ import { Radio, RadioGroup } from "@blueprintjs/core"; import React from "react"; -import { ValueCompProps } from "./ValueCompProps"; import { ConfigurableInput } from "@flyde/core"; -export interface ConfigurableInputEditorProps> { +export interface ValueCompProps { + value: T; + onChange: (value: T) => void; +} + +export interface ConfigurableInputEditorProps { value: ConfigurableInput; onChange: (value: ConfigurableInput) => void; valueRenderer: React.FC>; @@ -11,13 +15,13 @@ export interface ConfigurableInputEditorProps> { defaultStaticValue: T; } -export const ConfigurableInputEditor = >({ +export const ConfigurableInputEditor = function ({ value, onChange, valueRenderer: ValueRenderer, defaultStaticValue, modeLabel, -}: ConfigurableInputEditorProps) => { +}: ConfigurableInputEditorProps) { const handleModeChange = (e: React.FormEvent) => { onChange({ mode: e.currentTarget.value as "static" | "dynamic", diff --git a/flow-editor/src/visual-node-editor/MacroInstanceEditor/ValueCompProps.ts b/flow-editor/src/visual-node-editor/MacroInstanceEditor/ValueCompProps.ts deleted file mode 100644 index b869da6d3..000000000 --- a/flow-editor/src/visual-node-editor/MacroInstanceEditor/ValueCompProps.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ValueCompProps { - value: T; - onChange: (value: T) => void; -} diff --git a/flow-editor/src/visual-node-editor/MacroInstanceEditor/buildStructuredMacroEditor.tsx b/flow-editor/src/visual-node-editor/MacroInstanceEditor/buildStructuredMacroEditor.tsx index 7fa884b39..f3ca26003 100644 --- a/flow-editor/src/visual-node-editor/MacroInstanceEditor/buildStructuredMacroEditor.tsx +++ b/flow-editor/src/visual-node-editor/MacroInstanceEditor/buildStructuredMacroEditor.tsx @@ -11,10 +11,14 @@ import { MacroEditorFieldDefinition, MacroEditorFieldDefinitionType, } from "@flyde/core"; -import { ValueCompProps } from "./ValueCompProps"; import { SimpleJsonEditor } from "./SimpleJsonEditor"; import { ConfigurableInputEditor } from "./ConfigurableInputEditor"; +export interface ValueCompProps { + value: T; + onChange: (value: T) => void; +} + export function MacroEditorBaseValueComp( props: ValueCompProps & { config: MacroEditorFieldDefinitionType } ) { @@ -120,79 +124,3 @@ export function buildStructuredMacroEditorComp( ); }; } - -// export const TimedNodeEditor: MacroEditorComp = -// function TimedNodeEditor(props) { -// const { value, onChange } = props; - -// return ( -// <> -// -// -// onChange({ -// ...value, -// mode: e.target.value as any, -// }) -// } -// > -// -// -// -// -// {value.mode === "static" ? ( -// -// onChange({ ...value, timeMs: e })} -// /> -// -// ) : null} -// -// ); -// }; - -// const IntervalEditor: MacroEditorComp = -// function IntervalEditor({ value, onChange }) { -// return ( -// <> -// onChange({ ...value, time })} -// valueRenderer={(rendererProps) => ( -// -// -// rendererProps.onChange({ timeMs: number }) -// } -// /> -// -// )} -// modeLabel="Interval mode:" -// defaultStaticValue={{ timeMs: 2000 }} -// /> - -// onChange({ ...value, value: _value })} -// valueRenderer={(rendererProps) => ( -// -// rendererProps.onChange({ jsonValue })} -// label="" -// /> -// -// )} -// modeLabel="Value mode:" -// defaultStaticValue={{ jsonValue: "" }} -// /> -// -// ); -// }; diff --git a/stdlib/src/Lists/Collect/Collect.flyde.ts b/stdlib/src/Lists/Collect/Collect.flyde.ts index 3b7acbd98..be316e80d 100644 --- a/stdlib/src/Lists/Collect/Collect.flyde.ts +++ b/stdlib/src/Lists/Collect/Collect.flyde.ts @@ -1,15 +1,15 @@ import { InputPinMap, MacroNode, isDefined } from "@flyde/core"; -import { ConfigurableInput } from "../../lib/ConfigurableInput"; import { timeToString } from "../../Timing/common"; +import { ConfigurableInput } from "@flyde/core"; export type CollectConfigTime = { strategy: "time"; - time: ConfigurableInput<{ timeMs?: number }>; + time: ConfigurableInput; }; export type CollectConfigCount = { strategy: "count"; - count: ConfigurableInput<{ count?: number }>; + count: ConfigurableInput; }; export type CollectConfigTrigger = { @@ -26,7 +26,7 @@ export const Collect: MacroNode = { displayName: "Collect", description: "Collects values into a list. Over time, count, or trigger.", namespace: "Lists", - defaultData: { strategy: "count", count: { mode: "static", count: 3 } }, + defaultData: { strategy: "count", count: { mode: "static", value: 3 } }, definitionBuilder: (config) => { const inputs = { value: { description: "Value to collect" }, @@ -47,13 +47,13 @@ export const Collect: MacroNode = { const displayName = (() => { if (config.strategy === "time") { if (config.time.mode === "static") { - return `Collect over ${timeToString(config.time.timeMs)}`; + return `Collect over ${timeToString(config.time.value)}`; } else { return "Collect over time"; } } else if (config.strategy === "count") { if (config.count.mode === "static") { - return `Collect ${config.count.count} values`; + return `Collect ${config.count.value} values`; } else { return "Collect values"; } @@ -66,14 +66,14 @@ export const Collect: MacroNode = { if (config.strategy === "time") { if (config.time.mode === "static") { return `Emits a list of all values received, from the first value and until ${timeToString( - config.time.timeMs + config.time.value )} pass.`; } else { return "Emits a list of all values received, from the first value and until the specified amount of time passes."; } } else if (config.strategy === "count") { if (config.count.mode === "static") { - return `Collect ${config.count.count} values and emit a list of them.`; + return `Collect ${config.count.value} values and emit a list of them.`; } else { return "Collect a specified amount of values and emit a list of them."; } @@ -107,7 +107,7 @@ export const Collect: MacroNode = { if (config.strategy === "time") { const timeValue = - config.time.mode === "dynamic" ? time : config.time.timeMs; + config.time.mode === "dynamic" ? time : config.time.value; const timer = adv.state.get("timer"); if (!timer) { @@ -120,7 +120,7 @@ export const Collect: MacroNode = { } } else if (config.strategy === "count") { const countValue = - config.count.mode === "dynamic" ? count : config.count.count; + config.count.mode === "dynamic" ? count : config.count.value; if (list.length >= countValue) { outputs.list.next(list); adv.state.set("list", []); diff --git a/stdlib/src/Lists/Collect/Collect.tsx b/stdlib/src/Lists/Collect/Collect.tsx index fc6128660..a9ab1360b 100644 --- a/stdlib/src/Lists/Collect/Collect.tsx +++ b/stdlib/src/Lists/Collect/Collect.tsx @@ -11,11 +11,11 @@ const defaultValuePerStrategy: Record< > = { count: { strategy: "count", - count: { mode: "static", count: 2 }, + count: { mode: "static", value: 2 }, }, time: { strategy: "time", - time: { mode: "static", timeMs: 2000 }, + time: { mode: "static", value: 2000 }, }, trigger: { strategy: "trigger", @@ -45,18 +45,18 @@ const CollectEditor: MacroEditorComp = function CollectEditor({ valueRenderer={(props) => ( onChange({ ...value, - count: { mode: "static", count: e }, + count: { mode: "static", value: e }, }) } /> )} modeLabel="Count mode:" - defaultStaticValue={{ count: 2 }} + defaultStaticValue={2} /> ); case "time": @@ -67,18 +67,18 @@ const CollectEditor: MacroEditorComp = function CollectEditor({ valueRenderer={(props) => ( onChange({ ...value, - time: { mode: "static", timeMs: e }, + time: { mode: "static", value: e }, }) } /> )} modeLabel="Time mode:" - defaultStaticValue={{ timeMs: 2000 }} + defaultStaticValue={2000} /> ); } diff --git a/stdlib/src/Timing/Delay/Delay.tsx b/stdlib/src/Timing/Delay/Delay.tsx deleted file mode 100644 index a0849867d..000000000 --- a/stdlib/src/Timing/Delay/Delay.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { MacroEditorComp } from "@flyde/core"; - -import { TimedNodeEditor } from "../TimedNodeEditor"; -import { DelayConfig } from "./Delay.flyde"; - -const DelayEditor: MacroEditorComp = TimedNodeEditor; - -export default DelayEditor; diff --git a/stdlib/src/lib/ConfigurableInputEditor.tsx b/stdlib/src/lib/ConfigurableInputEditor.tsx index 1ee633147..87585f2f4 100644 --- a/stdlib/src/lib/ConfigurableInputEditor.tsx +++ b/stdlib/src/lib/ConfigurableInputEditor.tsx @@ -7,7 +7,7 @@ export interface ValueCompProps { onChange: (value: T) => void; } -export interface ConfigurableInputEditorProps> { +export interface ConfigurableInputEditorProps { value: ConfigurableInput; onChange: (value: ConfigurableInput) => void; valueRenderer: React.FC>; @@ -15,13 +15,13 @@ export interface ConfigurableInputEditorProps> { defaultStaticValue: T; } -export const ConfigurableInputEditor = >({ +export const ConfigurableInputEditor = function ({ value, onChange, valueRenderer: ValueRenderer, defaultStaticValue, modeLabel, -}: ConfigurableInputEditorProps) => { +}: ConfigurableInputEditorProps) { const handleModeChange = (e: React.FormEvent) => { onChange({ mode: e.currentTarget.value as "static" | "dynamic", diff --git a/website/src/pages/_hero-example/ExampleDebounceThrottle.flyde b/website/src/pages/_hero-example/ExampleDebounceThrottle.flyde index 525c48c30..3a8a3ab22 100644 --- a/website/src/pages/_hero-example/ExampleDebounceThrottle.flyde +++ b/website/src/pages/_hero-example/ExampleDebounceThrottle.flyde @@ -79,7 +79,7 @@ node: strategy: count count: mode: static - count: 3 + value: 3 style: size: small - pos: diff --git a/website/src/pages/_hero-example/ExampleReactivity.flyde b/website/src/pages/_hero-example/ExampleReactivity.flyde index 6d2234f99..d613e0c72 100644 --- a/website/src/pages/_hero-example/ExampleReactivity.flyde +++ b/website/src/pages/_hero-example/ExampleReactivity.flyde @@ -59,7 +59,7 @@ node: strategy: count count: mode: static - count: 3 + value: 3 - pos: x: -630.6297778320313 y: -425.5123219069296