@pipelex/mthds-form 0.10.1 → 0.12.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.
@@ -1,5 +1,5 @@
1
- export { collectStuffFiles } from '../chunk-4JQAJT7C.js';
2
- import '../chunk-TID7ZN63.js';
1
+ export { collectStuffFiles, readStuffFile } from '../chunk-VS5JMFUV.js';
2
+ import '../chunk-CM4KVG53.js';
3
3
  import '../chunk-V3OV2XQT.js';
4
4
  //# sourceMappingURL=stuff-files.js.map
5
5
  //# sourceMappingURL=stuff-files.js.map
@@ -0,0 +1,65 @@
1
+ import * as react from 'react';
2
+ import { RunField } from './core/descriptor.js';
3
+
4
+ /**
5
+ * Ambient state that any field in the tree may need, threaded unchanged through
6
+ * the recursion so containers don't have to re-plumb it for every child.
7
+ */
8
+ interface FieldEnv {
9
+ disabled?: boolean;
10
+ /**
11
+ * A file field asks its parent to upload; the parent sets the value later.
12
+ *
13
+ * Its presence is the capability. A host that supplies it gets a dropzone on
14
+ * every file field; a host that does not gets no dropzone and no file picker,
15
+ * because a file taken with nowhere to go used to be dropped without a word.
16
+ * See docs/upload-seam.md, "Which ways into a file value a host offers".
17
+ */
18
+ onDropFile?: (id: string, file: File) => void;
19
+ /**
20
+ * Whether a file field offers a link input, the way in that needs no upload.
21
+ * `true` when absent; `false` hides the "paste a URL instead" toggle and the
22
+ * input behind it on every file field.
23
+ *
24
+ * It governs that input and nothing else. A file value is a URL whichever way
25
+ * it arrived, so this says nothing about which values are valid: a web link
26
+ * the host writes is still shown on the field's card and can still be
27
+ * cleared. Setting it to `false` with no `onDropFile` leaves a file field no
28
+ * way in at all, and the field throws, naming its path, when it renders.
29
+ */
30
+ allowUrl?: boolean;
31
+ /** Ids currently mid-upload. */
32
+ uploadingIds?: ReadonlySet<string>;
33
+ /**
34
+ * Why an upload failed, keyed by the same id `onDropFile` was handed, so the
35
+ * message shows on the field that took the file rather than under the whole
36
+ * form, where only its wording could say which input failed.
37
+ *
38
+ * The map is the host's truth about each upload attempt: a host removes an
39
+ * entry when the next file is dropped at that id, and sets it again if that
40
+ * upload fails too. A clear or a typed link on the field hides the message
41
+ * until the host sends a different one or removes it, and a list holds back
42
+ * the entries a row removal left at a renumbered position.
43
+ */
44
+ uploadErrors?: ReadonlyMap<string, string>;
45
+ /** Resolve a `pipelex-storage://` URI to a browser-viewable URL (for previews
46
+ * of already-stored files). */
47
+ resolveUrl?: (uri: string) => Promise<string | null>;
48
+ }
49
+ interface FieldRendererProps {
50
+ field: RunField;
51
+ value: unknown;
52
+ onChange: (value: unknown) => void;
53
+ /** Unique, stable id used for label linkage and upload tracking. */
54
+ id: string;
55
+ error?: string;
56
+ env?: FieldEnv;
57
+ }
58
+ /**
59
+ * The single dispatch point: a normalized `RunField` → the matching control.
60
+ * Object and list fields recurse back through here, so the whole form is one
61
+ * data-driven tree with no per-type branching anywhere else.
62
+ */
63
+ declare function FieldRenderer({ field, value, onChange, id, error, env }: FieldRendererProps): react.JSX.Element;
64
+
65
+ export { type FieldEnv as F, FieldRenderer as a, type FieldRendererProps as b };
@@ -7,7 +7,7 @@ import * as react from 'react';
7
7
  import * as _json_render_react from '@json-render/react';
8
8
  import { Components, Renderer } from '@json-render/react';
9
9
  import * as zod_v4_core from 'zod/v4/core';
10
- import { F as FieldEnv } from '../field-renderer-BSU2hMf6.js';
10
+ import { F as FieldEnv } from '../field-renderer-C5Onx6qB.js';
11
11
  import '../core/contracts.js';
12
12
  import 'mthds/protocol';
13
13
  import '../core/file-formats.js';
@@ -1,7 +1,8 @@
1
1
  "use client";
2
- import { cn, fieldControlClass, ResultField, FieldRenderer, ToggleGroup, ToggleGroupItem, Switch, Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '../chunk-W56WIIVC.js';
3
- import '../chunk-4JQAJT7C.js';
4
- import { isNativeValueNode, readDateContent, formatDateContent, isNativeHtmlNode, isNativeDateNode, isNativeCompositeNode } from '../chunk-TID7ZN63.js';
2
+ import { cn, fieldControlClass, ResultRoot, ResultField, FieldRenderer, ToggleGroup, ToggleGroupItem, Switch, Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '../chunk-4KX6YTLW.js';
3
+ import '../chunk-V7T4DM63.js';
4
+ import '../chunk-VS5JMFUV.js';
5
+ import { isNativeValueNode, readDateContent, formatDateContent, isNativeHtmlNode, isNativeDateNode, isNativeCompositeNode } from '../chunk-CM4KVG53.js';
5
6
  import '../chunk-FABY3DEY.js';
6
7
  import '../chunk-XCO6GTEC.js';
7
8
  import '../chunk-PM55AHRO.js';
@@ -2292,8 +2293,9 @@ function MthdsResult({ props }) {
2292
2293
  const path = useAbsolutePath(props.path) ?? "";
2293
2294
  const field = scope.result && path ? resultFieldAtPath(scope.result, path) : void 0;
2294
2295
  const value = useStateValue(path);
2295
- if (!field) return /* @__PURE__ */ jsx(Unresolved, { path: props.path, side: "result" });
2296
- return /* @__PURE__ */ jsx(ResultField, { field, value, hideLabel: props.hideLabel ?? false });
2296
+ if (!field || !scope.result) return /* @__PURE__ */ jsx(Unresolved, { path: props.path, side: "result" });
2297
+ const place = [scope.result.name, ...segmentsUnder(RESULT_ROOT, path) ?? []];
2298
+ return /* @__PURE__ */ jsx(ResultRoot, { baseName: scope.result.name, path: place, children: /* @__PURE__ */ jsx(ResultField, { field, value, hideLabel: props.hideLabel ?? false }) });
2297
2299
  }
2298
2300
  function AccessibleSelect({ props, bindings, emit }) {
2299
2301
  const [boundValue, setBoundValue] = useBoundProp(