@particle-academy/fancy-flow 0.52.0 → 0.53.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.
Files changed (39) hide show
  1. package/dist/{chunk-JOXMAWAI.js → chunk-CIBW5ATA.js} +148 -5
  2. package/dist/chunk-CIBW5ATA.js.map +1 -0
  3. package/dist/{chunk-PEX3ZGCO.js → chunk-FG3C7LIG.js} +3 -3
  4. package/dist/{chunk-PEX3ZGCO.js.map → chunk-FG3C7LIG.js.map} +1 -1
  5. package/dist/{chunk-PU3CLTAG.js → chunk-FH6MWLKD.js} +3 -3
  6. package/dist/{chunk-PU3CLTAG.js.map → chunk-FH6MWLKD.js.map} +1 -1
  7. package/dist/{chunk-PWIHOR57.js → chunk-FTGVVKWX.js} +4 -4
  8. package/dist/{chunk-PWIHOR57.js.map → chunk-FTGVVKWX.js.map} +1 -1
  9. package/dist/{chunk-I7ZDPY7C.js → chunk-VWANLNL5.js} +3 -3
  10. package/dist/{chunk-I7ZDPY7C.js.map → chunk-VWANLNL5.js.map} +1 -1
  11. package/dist/{chunk-RR7A6IUW.js → chunk-WCFRKXH5.js} +3 -3
  12. package/dist/{chunk-RR7A6IUW.js.map → chunk-WCFRKXH5.js.map} +1 -1
  13. package/dist/durable.cjs +103 -2
  14. package/dist/durable.cjs.map +1 -1
  15. package/dist/durable.js +1 -1
  16. package/dist/engine.cjs +103 -2
  17. package/dist/engine.cjs.map +1 -1
  18. package/dist/engine.js +3 -3
  19. package/dist/index.cjs +218 -37
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.js +84 -46
  22. package/dist/index.js.map +1 -1
  23. package/dist/registry.cjs +103 -2
  24. package/dist/registry.cjs.map +1 -1
  25. package/dist/registry.js +2 -2
  26. package/dist/runtime.cjs +103 -2
  27. package/dist/runtime.cjs.map +1 -1
  28. package/dist/runtime.js +3 -3
  29. package/dist/schema.cjs +103 -2
  30. package/dist/schema.cjs.map +1 -1
  31. package/dist/schema.js +2 -2
  32. package/dist/screens.cjs +103 -2
  33. package/dist/screens.cjs.map +1 -1
  34. package/dist/screens.js +4 -4
  35. package/dist/ux.cjs +103 -2
  36. package/dist/ux.cjs.map +1 -1
  37. package/dist/ux.js +1 -1
  38. package/package.json +1 -1
  39. package/dist/chunk-JOXMAWAI.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- import { removeNodes, removeEdges, cloneSubgraph, alignNodes, distributeNodes, reconnectEdge, assignToLane, removeFromLane, duplicateNode, setEdgeLabel, FlowCanvas } from './chunk-PWIHOR57.js';
2
- export { ActionNode, DecisionNode, FlowCanvas, FlowViewer, NodeShell, OutputNode, SubgraphNode, TriggerNode, alignNodes, cloneSubgraph, defaultNodeTypes, distributeNodes, reconnectEdge } from './chunk-PWIHOR57.js';
3
- import { useFlowState, useFlowRun, useFlowHistory, applyOutputsToNodes, applyStatusesToNodes } from './chunk-PEX3ZGCO.js';
4
- export { applyOutputsToNodes, applyStatusesToNodes, createHistory, useFlowHistory, useFlowRun, useFlowState } from './chunk-PEX3ZGCO.js';
5
- export { runCohort } from './chunk-RR7A6IUW.js';
1
+ import { removeNodes, removeEdges, cloneSubgraph, alignNodes, distributeNodes, reconnectEdge, assignToLane, removeFromLane, duplicateNode, setEdgeLabel, FlowCanvas } from './chunk-FTGVVKWX.js';
2
+ export { ActionNode, DecisionNode, FlowCanvas, FlowViewer, NodeShell, OutputNode, SubgraphNode, TriggerNode, alignNodes, cloneSubgraph, defaultNodeTypes, distributeNodes, reconnectEdge } from './chunk-FTGVVKWX.js';
3
+ import { useFlowState, useFlowRun, useFlowHistory, applyOutputsToNodes, applyStatusesToNodes } from './chunk-FG3C7LIG.js';
4
+ export { applyOutputsToNodes, applyStatusesToNodes, createHistory, useFlowHistory, useFlowRun, useFlowState } from './chunk-FG3C7LIG.js';
5
+ export { runCohort } from './chunk-WCFRKXH5.js';
6
6
  export { evaluateConfig, evaluateExpression, resolvePath, text, truthy } from './chunk-BHM5HGXH.js';
7
- import { buildNodeTypes } from './chunk-I7ZDPY7C.js';
8
- export { ANY_PORT_TYPE, RegistryNode, buildNodeTypes, createConnectionValidator, defaultPortCompatibility } from './chunk-I7ZDPY7C.js';
7
+ import { buildNodeTypes } from './chunk-VWANLNL5.js';
8
+ export { ANY_PORT_TYPE, RegistryNode, buildNodeTypes, createConnectionValidator, defaultPortCompatibility } from './chunk-VWANLNL5.js';
9
9
  export { LEGACY_PAUSE_PREFIXES, PAUSE_PREFIX, decodePause, encodePause, isPause, pauseForHuman } from './chunk-UEOE6B52.js';
10
- import { workflowToBlob, importWorkflow, exportWorkflow } from './chunk-PU3CLTAG.js';
11
- export { WORKFLOW_SCHEMA_URL, WORKFLOW_SCHEMA_VERSION, exportWorkflow, importWorkflow, migrateSchema, workflowToBlob } from './chunk-PU3CLTAG.js';
12
- import { ReactFlowProvider, useReactFlow, onNodeKindsChanged, listNodeKinds, getNodeKind, defaultConfigFor, FlowEditorProvider, addEdge, applyEdgeChanges, applyNodeChanges, Position, ensureBuiltinKinds, validateConfig, categoryAccent, Handle } from './chunk-JOXMAWAI.js';
13
- export { BUILTIN_KINDS, LaneNode, NoteNode, categoryAccent, clearNodeKindOverrides, defaultConfigFor, ensureBuiltinKinds, getNodeKind, listNodeKinds, onNodeKindsChanged, overrideNodeKind, registerBuiltinKinds, registerNodeKind, resolveNodePorts, resolvePortSpec, runFlow, useFlowEditor, useFlowEditorOptional, validateConfig } from './chunk-JOXMAWAI.js';
10
+ import { workflowToBlob, importWorkflow, exportWorkflow } from './chunk-FH6MWLKD.js';
11
+ export { WORKFLOW_SCHEMA_URL, WORKFLOW_SCHEMA_VERSION, exportWorkflow, importWorkflow, migrateSchema, workflowToBlob } from './chunk-FH6MWLKD.js';
12
+ import { ReactFlowProvider, useReactFlow, humanInputFields, onNodeKindsChanged, listNodeKinds, getNodeKind, defaultConfigFor, FlowEditorProvider, addEdge, applyEdgeChanges, applyNodeChanges, Position, ensureBuiltinKinds, validateConfig, categoryAccent, Handle } from './chunk-CIBW5ATA.js';
13
+ export { BUILTIN_KINDS, LaneNode, NoteNode, categoryAccent, clearNodeKindOverrides, defaultConfigFor, ensureBuiltinKinds, getNodeKind, listNodeKinds, onNodeKindsChanged, overrideNodeKind, registerBuiltinKinds, registerNodeKind, resolveNodePorts, resolvePortSpec, runFlow, useFlowEditor, useFlowEditorOptional, validateConfig } from './chunk-CIBW5ATA.js';
14
14
  import { getRichInputAdapter } from './chunk-F5RPRB7A.js';
15
15
  export { RichInputPreview, getRichInputAdapter, isRichInputEnabled, onRichInputAdapterChanged, registerRichInputAdapter } from './chunk-F5RPRB7A.js';
16
16
  import './chunk-USL4FMFU.js';
@@ -974,24 +974,28 @@ function formatTime(at) {
974
974
  const d = new Date(at);
975
975
  return `${d.getMinutes().toString().padStart(2, "0")}:${d.getSeconds().toString().padStart(2, "0")}.${Math.floor(d.getMilliseconds() / 100)}`;
976
976
  }
977
- function humanInputFields(config) {
978
- const raw = Array.isArray(config?.fields) ? config.fields : [];
979
- const fields = raw.filter((f) => f && typeof f === "object" && typeof f.key === "string" && f.key).map((f) => ({
980
- key: f.key,
981
- label: typeof f.label === "string" && f.label ? f.label : f.key,
982
- type: ["text", "textarea", "number", "select", "switch"].includes(f.type) ? f.type : "text",
983
- required: !!f.required,
984
- placeholder: typeof f.placeholder === "string" ? f.placeholder : void 0,
985
- options: Array.isArray(f.options) ? f.options : void 0,
986
- default: f.default
987
- }));
988
- if (fields.length) return fields;
989
- const title = typeof config?.title === "string" && config.title ? config.title : "Your answer";
990
- return [{ key: "value", label: title, type: "textarea", required: true }];
991
- }
977
+ var INPUT_TYPE = {
978
+ text: "text",
979
+ number: "number",
980
+ date: "date",
981
+ datetime: "datetime-local",
982
+ time: "time",
983
+ email: "email",
984
+ url: "url",
985
+ tel: "tel",
986
+ password: "password"
987
+ };
992
988
  function initialValues(fields) {
993
989
  const v = {};
994
- for (const f of fields) v[f.key] = f.type === "switch" ? !!f.default : f.default ?? "";
990
+ for (const f of fields) {
991
+ if (f.type === "switch") {
992
+ v[f.key] = !!f.default;
993
+ } else if (f.type === "number") {
994
+ v[f.key] = typeof f.default === "number" ? f.default : f.default === void 0 || f.default === "" ? "" : Number(f.default);
995
+ } else {
996
+ v[f.key] = f.default ?? "";
997
+ }
998
+ }
995
999
  return v;
996
1000
  }
997
1001
  function HumanPrompt({ request, onCancel }) {
@@ -1026,6 +1030,8 @@ function InputBody({
1026
1030
  }) {
1027
1031
  const [values, setValues] = useState(() => initialValues(request.fields));
1028
1032
  const set = (k, v) => setValues((prev) => ({ ...prev, [k]: v }));
1033
+ const uid = useId();
1034
+ const fieldId = (key) => `${uid}-${key}`;
1029
1035
  const missing = request.fields.filter((f) => f.required && (values[f.key] === void 0 || values[f.key] === ""));
1030
1036
  const submit = () => {
1031
1037
  if (missing.length === 0) request.resolve(values);
@@ -1044,12 +1050,21 @@ function InputBody({
1044
1050
  }
1045
1051
  },
1046
1052
  children: [
1047
- /* @__PURE__ */ jsx("div", { className: "ff-prompt__fields", children: request.fields.map((f, i) => /* @__PURE__ */ jsxs("label", { className: "ff-prompt__field", children: [
1048
- /* @__PURE__ */ jsxs("span", { className: "ff-prompt__label", children: [
1053
+ /* @__PURE__ */ jsx("div", { className: "ff-prompt__fields", children: request.fields.map((f, i) => /* @__PURE__ */ jsxs("div", { className: "ff-prompt__field", children: [
1054
+ /* @__PURE__ */ jsxs("label", { className: "ff-prompt__label", htmlFor: fieldId(f.key), children: [
1049
1055
  f.label ?? f.key,
1050
- f.required && /* @__PURE__ */ jsx("span", { className: "ff-prompt__req", children: " *" })
1056
+ f.required && /* @__PURE__ */ jsx("span", { className: "ff-prompt__req", "aria-hidden": "true", children: " *" })
1051
1057
  ] }),
1052
- renderControl(f, values[f.key], (v) => set(f.key, v), i === 0 ? firstRef : void 0)
1058
+ /* @__PURE__ */ jsx(
1059
+ FieldControl,
1060
+ {
1061
+ field: f,
1062
+ id: fieldId(f.key),
1063
+ value: values[f.key],
1064
+ onChange: (v) => set(f.key, v),
1065
+ autoFocusRef: i === 0 ? firstRef : void 0
1066
+ }
1067
+ )
1053
1068
  ] }, f.key)) }),
1054
1069
  /* @__PURE__ */ jsxs("div", { className: "ff-prompt__actions", children: [
1055
1070
  /* @__PURE__ */ jsx("button", { type: "button", className: "ff-prompt__btn ff-prompt__btn--ghost", onClick: onCancel, children: "Cancel" }),
@@ -1059,45 +1074,68 @@ function InputBody({
1059
1074
  }
1060
1075
  );
1061
1076
  }
1062
- function renderControl(f, value, onChange, ref) {
1063
- const common = { className: "ff-prompt__input", placeholder: f.placeholder };
1064
- if (f.type === "textarea") {
1077
+ function FieldControl({
1078
+ field,
1079
+ id,
1080
+ value,
1081
+ onChange,
1082
+ autoFocusRef
1083
+ }) {
1084
+ const handle = { id, "data-ff-field": field.key };
1085
+ if (field.type === "textarea") {
1065
1086
  return /* @__PURE__ */ jsx(
1066
1087
  "textarea",
1067
1088
  {
1068
- ...common,
1069
- ref,
1089
+ ...handle,
1090
+ className: "ff-prompt__input",
1091
+ placeholder: field.placeholder,
1092
+ ref: autoFocusRef,
1070
1093
  rows: 3,
1071
1094
  value: String(value ?? ""),
1072
1095
  onChange: (e) => onChange(e.target.value)
1073
1096
  }
1074
1097
  );
1075
1098
  }
1076
- if (f.type === "switch") {
1099
+ if (field.type === "switch") {
1077
1100
  return /* @__PURE__ */ jsx(
1078
1101
  "input",
1079
1102
  {
1103
+ ...handle,
1080
1104
  type: "checkbox",
1081
1105
  className: "ff-prompt__switch",
1106
+ ref: autoFocusRef,
1082
1107
  checked: !!value,
1083
1108
  onChange: (e) => onChange(e.target.checked)
1084
1109
  }
1085
1110
  );
1086
1111
  }
1087
- if (f.type === "select" && f.options && f.options.length) {
1088
- return /* @__PURE__ */ jsxs("select", { className: "ff-prompt__input", value: String(value ?? ""), onChange: (e) => onChange(e.target.value), children: [
1089
- /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Choose\u2026" }),
1090
- f.options.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value))
1091
- ] });
1112
+ if (field.type === "select") {
1113
+ const options = field.options ?? [];
1114
+ return /* @__PURE__ */ jsxs(
1115
+ "select",
1116
+ {
1117
+ ...handle,
1118
+ className: "ff-prompt__input",
1119
+ ref: autoFocusRef,
1120
+ value: String(value ?? ""),
1121
+ onChange: (e) => onChange(e.target.value),
1122
+ children: [
1123
+ /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: options.length ? "Choose\u2026" : "No choices configured" }),
1124
+ options.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value))
1125
+ ]
1126
+ }
1127
+ );
1092
1128
  }
1093
1129
  return /* @__PURE__ */ jsx(
1094
1130
  "input",
1095
1131
  {
1096
- ...common,
1097
- ref,
1098
- type: f.type === "number" ? "number" : "text",
1132
+ ...handle,
1133
+ className: "ff-prompt__input",
1134
+ placeholder: field.placeholder,
1135
+ ref: autoFocusRef,
1136
+ type: INPUT_TYPE[field.type ?? "text"] ?? "text",
1099
1137
  value: String(value ?? ""),
1100
- onChange: (e) => onChange(f.type === "number" ? e.target.value === "" ? "" : Number(e.target.value) : e.target.value)
1138
+ onChange: (e) => onChange(field.type === "number" ? e.target.value === "" ? "" : Number(e.target.value) : e.target.value)
1101
1139
  }
1102
1140
  );
1103
1141
  }