@pipelex/mthds-ui 0.60.1 → 0.62.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/dist/form/layout-design.mthds +61 -18
- package/dist/form/react/index.d.ts +3 -0
- package/dist/form/react/index.js +80 -37
- package/dist/form/react/index.js.map +1 -1
- package/dist/standalone/graph-standalone.html +139 -136
- package/dist/standalone/graph-viewer.css +1 -1
- package/dist/standalone/graph-viewer.js +138 -135
- package/package.json +2 -2
|
@@ -132,16 +132,9 @@ paths = { type = "list", item_type = "concept", item_concept_ref = "PathE
|
|
|
132
132
|
run_control = { type = "text", description = "On an input page, the catalog component that runs the method, by name; the page has exactly one of it." }
|
|
133
133
|
returns = { type = "list", item_type = "text", description = "On a composer, what one run gives back, one line per member of the result, read from the result's own titles and descriptions. Absent elsewhere." }
|
|
134
134
|
frame = { choices = ["page", "composer", "result"], description = "Where the page sits: `page`, a whole product page of its own; `composer`, the inputs of a host's compose-then-result app, before a run; `result`, the result page of that app, after one. Absent reads as `page`." }
|
|
135
|
-
|
|
135
|
+
shell = { type = "text", description = "The name of the page shell the host draws the app in, when the host has chosen one. The shell and the team's design system draw the look; the page decides only its composition. Absent when the host names none." }
|
|
136
136
|
sample_state = { type = "text", description = "On a result page, the state of one real run as the host loads it, as JSON - what `/result` held after one actual run, so magnitudes and lengths can be judged. Never copied into a page." }
|
|
137
137
|
|
|
138
|
-
[concept.Style]
|
|
139
|
-
description = "An app style: a named look the components draw - faces, weights, radii, panels and rhythm - and the one sentence that says what it is, which the composition follows."
|
|
140
|
-
|
|
141
|
-
[concept.Style.structure]
|
|
142
|
-
name = { type = "text", description = "The style's name, as a team picks it: `Quiet`, `Soft`, `Editorial`, `Bold`.", required = true }
|
|
143
|
-
direction = { type = "text", description = "The style's direction in one sentence, as a designer reads it.", required = true }
|
|
144
|
-
|
|
145
138
|
[concept.PathEntry]
|
|
146
139
|
description = "One path of the state, as the brief describes it: where it is, what it holds, what it is called, what constrains it, and whether the page lays it out or hands it back to the kernel's own control."
|
|
147
140
|
|
|
@@ -154,7 +147,13 @@ title = { type = "text", description = "The member's human title, whe
|
|
|
154
147
|
description = { type = "text", description = "What the member is for, as the method's author wrote it." }
|
|
155
148
|
required = { type = "boolean", description = "On an input page, whether the input must be filled before the run: true for a required input, false for an optional one." }
|
|
156
149
|
gating = { type = "boolean", description = "On an input page, true when the run waits for this input - a top-level fact only." }
|
|
157
|
-
notes = { type = "list", item_type = "text", description = "The constraints
|
|
150
|
+
notes = { type = "list", item_type = "text", description = "The constraints in words, each on its own: `min 1`, `more than 0`, `at most 80 characters`, `matches the pattern ...`, `default \"x\"`, `examples ...`, and any hint the vocabulary below does not name, as `hints key=value`." }
|
|
151
|
+
unit = { type = "text", description = "What a number counts, exactly as the method writes it: a currency code (`EUR`), `percent` (100 is the whole), or a unit of measure (`kg`, `ms`). Absent when the method states none." }
|
|
152
|
+
aggregate = { choices = ["sum", "average"], description = "On a number member of a list's item, how the column combines across the items, when the method declares it: their total or their average." }
|
|
153
|
+
intent = { type = "text", description = "The intent word the method states for the value (`rating`, `quantity`, `code`, `identifier`, `question`, `photo`, ...), when it states one the vocabulary knows." }
|
|
154
|
+
role = { choices = ["subject", "context", "guidance", "reference", "setting"], description = "On an input page, what a top-level input is to the job: as the method states it, or the standard's default for it once any input of the method states one. Absent when none does." }
|
|
155
|
+
part = { choices = ["title", "summary", "verdict", "metric", "body", "evidence", "detail"], description = "On a result page, what part of its record a member is, when the method states one that applies to its kind." }
|
|
156
|
+
options = { type = "list", item_type = "concept", item_concept_ref = "OptionEntry", description = "On a choice whose options carry words or a tone, every option in the order of the choices, with what the method says of it." }
|
|
158
157
|
default = { type = "text", description = "The authored default value, as JSON, when the method states one - the seed a `/state` patch sets." }
|
|
159
158
|
delegated = { type = "boolean", description = "True when the page hands the path back to the kernel's own control - MthdsField on an input page, MthdsResult on a result page - because the catalog cannot enter or show it. A delegated structure's members are not listed.", required = true }
|
|
160
159
|
relative = { type = "boolean", description = "True when the path is spelled relative to one item of the list above it, as a DataTable column or `$item` reads it, rather than from the page's root." }
|
|
@@ -162,6 +161,15 @@ item_kind = { type = "text", description = "On a list whose items the bri
|
|
|
162
161
|
item_description = { type = "text", description = "On a list whose items the brief describes: what one item is for, as the method's author wrote it." }
|
|
163
162
|
item_laid_out = { type = "boolean", description = "On a list whose items the brief describes: true when the item's members follow this entry, one each, spelled relative to one item." }
|
|
164
163
|
|
|
164
|
+
[concept.OptionEntry]
|
|
165
|
+
description = "One option of a choice: its value, and the words and the tone the method gives it. Only the value is ever written; the rest is how the option reads."
|
|
166
|
+
|
|
167
|
+
[concept.OptionEntry.structure]
|
|
168
|
+
value = { type = "text", description = "The option exactly as the choice lists it, the value a control writes.", required = true }
|
|
169
|
+
label = { type = "text", description = "The option's name for people, when the method gives one." }
|
|
170
|
+
description = { type = "text", description = "What choosing the option means, when the method says." }
|
|
171
|
+
tone = { choices = ["positive", "caution", "negative", "neutral"], description = "How the option reads to a person, when the method says: a component that reads tones colours it from this, and an option with none reads neutral." }
|
|
172
|
+
|
|
165
173
|
[concept.PagePlan]
|
|
166
174
|
description = "The designer's plan for one page, settled before any element is written: what the page is for, how it is composed - a decision the plan makes, with no shape given in advance - what each region shows or collects and with which components, what runs the method, and what is delegated."
|
|
167
175
|
|
|
@@ -207,6 +215,11 @@ template = """
|
|
|
207
215
|
{% set delegated = brief.paths | selectattr("delegated") | rejectattr("relative") | list %}
|
|
208
216
|
{% set defaults = brief.paths | selectattr("default") | list %}
|
|
209
217
|
{% set gating = brief.paths | selectattr("gating") | list %}
|
|
218
|
+
{% set roled = brief.paths | selectattr("role") | list %}
|
|
219
|
+
{% set parted = brief.paths | selectattr("part") | list %}
|
|
220
|
+
{% set worded = brief.paths | selectattr("options") | list %}
|
|
221
|
+
{% set counted = brief.paths | selectattr("unit") | list %}
|
|
222
|
+
{% set totalled = brief.paths | selectattr("aggregate") | list %}
|
|
210
223
|
# {{ "Input" if brief.side == "input" else "Result" }} page: {{ brief.pipe_ref }}
|
|
211
224
|
|
|
212
225
|
{% if brief.description %}
|
|
@@ -220,7 +233,7 @@ The result of a method, described below.
|
|
|
220
233
|
{% if brief.name %}
|
|
221
234
|
## Name
|
|
222
235
|
|
|
223
|
-
The method is called «{{ brief.name }}», as the host lists it. That is the app's name wherever the layout asks for one; invent no other.
|
|
236
|
+
The method is called «{{ brief.name }}», as the host lists it. That is the app's name wherever the layout asks for one; invent no other. The page states nothing the method does not: no promise about storage, privacy, speed, or what happens after the run.
|
|
224
237
|
|
|
225
238
|
{% endif %}
|
|
226
239
|
{% if brief.frame == "composer" %}
|
|
@@ -251,12 +264,10 @@ The page is the result across the full width. It opens on its header, which name
|
|
|
251
264
|
Show each value once: a figure a component already states, such as the total inside a ProportionBar, is not repeated beside it. When the result carries the request back - the same facts the person entered, such as the topic or the tone they chose - leave that part out: the host's bar already restates the request. Write a value as a person reads it: a date in words, an amount beside its currency when the result has one.
|
|
252
265
|
|
|
253
266
|
{% endif %}
|
|
254
|
-
{% if brief.
|
|
255
|
-
##
|
|
267
|
+
{% if brief.shell %}
|
|
268
|
+
## Shell
|
|
256
269
|
|
|
257
|
-
The
|
|
258
|
-
|
|
259
|
-
The components already draw its faces, weights, radii and panels, so the page sets none of them. What the page decides is its composition, and the composition should read as this style too: how much air there is between the groups, how large and how long the headline is, how many groups the inputs fall into and whether they are titled, how much the page says around them. A calm style asks for few groups and generous air, a literary one for a headline that reads like a title and a measured rhythm, a graphic one for a dense, firm page with short labels.
|
|
270
|
+
The host draws this app in its {{ brief.shell }} shell and dresses it in the team's own design system: the faces, the colours, the radii, the panels and everything around the page are the shell's and the components', never the page's. The page decides its composition inside the frame above, and nothing of the look.
|
|
260
271
|
|
|
261
272
|
{% endif %}
|
|
262
273
|
## State
|
|
@@ -268,11 +279,36 @@ The host loads the run's result under `/result` before the page renders. Read ev
|
|
|
268
279
|
{% endif %}
|
|
269
280
|
|
|
270
281
|
{% for entry in brief.paths %}
|
|
271
|
-
{{ " " * entry.depth }}- `{{ entry.path }}` — {{ entry.kind }}{% if brief.side == "input" %}, {{ "required" if entry.required else "optional" }}{% if entry.gating %}, gates the run{% endif %}{% endif %}{% if entry.name %} — {% if entry.title %}{{ entry.title }} (`{{ entry.name }}`){% else %}`{{ entry.name }}`{% endif %}{% endif %}{% if entry.description %}: {{ entry.description }}{% endif %}{% if entry.notes %} ({{ entry.notes | join("; ") }}){% endif %}{% if entry.delegated and entry.relative %} (a DataTable prints it as text; delegate the whole list to {{ hatch }} to render it properly){% elif entry.delegated %} **[delegate: {{ hatch }}]**{% endif +%}
|
|
282
|
+
{{ " " * entry.depth }}- `{{ entry.path }}` — {{ entry.kind }}{% if brief.side == "input" %}, {{ "required" if entry.required else "optional" }}{% if entry.gating %}, gates the run{% endif %}{% endif %}{% if entry.name %} — {% if entry.title %}{{ entry.title }} (`{{ entry.name }}`){% else %}`{{ entry.name }}`{% endif %}{% endif %}{% if entry.description %}: {{ entry.description }}{% endif %}{% if entry.role %} [role: {{ entry.role }}]{% endif %}{% if entry.part %} [part: {{ entry.part }}]{% endif %}{% if entry.intent %} [intent: {{ entry.intent }}]{% endif %}{% if entry.unit %} [unit: {{ entry.unit }}]{% endif %}{% if entry.aggregate %} [shows its column's {{ "total" if entry.aggregate == "sum" else "average" }}]{% endif %}{% if entry.notes %} ({{ entry.notes | join("; ") }}){% endif %}{% if entry.delegated and entry.relative %} (a DataTable prints it as text; delegate the whole list to {{ hatch }} to render it properly){% elif entry.delegated %} **[delegate: {{ hatch }}]**{% endif +%}
|
|
283
|
+
{% for option in entry.options or [] %}
|
|
284
|
+
{{ " " * (entry.depth + 1) }}- option `{{ option.value }}`{% if option.label %} «{{ option.label }}»{% endif %}{% if option.tone %}, tone {{ option.tone }}{% endif %}{% if option.description %}: {{ option.description }}{% endif +%}
|
|
285
|
+
{% endfor %}
|
|
272
286
|
{% if entry.item_kind %}
|
|
273
287
|
{{ " " * (entry.depth + 1) }}- each item is a {{ entry.item_kind }}{% if entry.item_description %} ({{ entry.item_description }}){% endif %}{% if entry.item_laid_out and entry.relative %}, with:{% elif entry.item_laid_out %}, with these members (paths relative to one item, for DataTable columns or $$item):{% endif +%}
|
|
274
288
|
{% endif %}
|
|
275
289
|
{% endfor %}
|
|
290
|
+
{% if roled or parted or worded or counted or totalled %}
|
|
291
|
+
|
|
292
|
+
## Meaning
|
|
293
|
+
|
|
294
|
+
The method states what its values mean, and the page shows it as stated: it restates no fact in its own words and guesses none the method leaves out.
|
|
295
|
+
|
|
296
|
+
{% if roled %}
|
|
297
|
+
- An input's role says what it is to the job. The subject is the material the run works on: the page opens on it, first and largest, and never folds it away. Context and guidance follow it. A reference, the yardstick the run applies and the same next time, and a setting, a knob with a sensible default, are set once and rarely changed: they are never the page's hero, nothing of theirs comes before the subject, and they sit together in a component made to fold settings away - except one the run waits for that has no default, which stays in view. A reference is entered with a component that offers the one used last, where the catalog has one.
|
|
298
|
+
{% endif %}
|
|
299
|
+
{% if parted %}
|
|
300
|
+
- A member's part says what it is to its record. The verdict is the answer the reader came for: the page leads with it, large and in its tone, and shows no other value before it but the record's title and summary. The title names the record, the summary says it in a line, a metric is the figure a reader looks for first, the body is the record's text, the evidence is what backs it, and a detail is read last.
|
|
301
|
+
{% endif %}
|
|
302
|
+
{% if worded %}
|
|
303
|
+
- A choice whose options carry words or a tone is shown as its option reads, never as its raw value: with a component that reads the option's label and tone from the method and colours it from the tone. An option with no tone reads neutral; never colour a value by guessing from its words.
|
|
304
|
+
{% endif %}
|
|
305
|
+
{% if counted %}
|
|
306
|
+
- A number with a unit is written in it - money in its currency, a percentage, a measure - by a component that reads the unit from the method; the page never writes a currency or a unit of its own beside it. A number the method bounds on both sides may be shown against its bounds.
|
|
307
|
+
{% endif %}
|
|
308
|
+
{% if totalled %}
|
|
309
|
+
- A column that declares a total or an average shows it under its table, and a column that declares none shows none.
|
|
310
|
+
{% endif %}
|
|
311
|
+
{% endif %}
|
|
276
312
|
|
|
277
313
|
## Delegated
|
|
278
314
|
|
|
@@ -354,7 +390,8 @@ DESIGN DIRECTION:
|
|
|
354
390
|
- Write copy a person would say: short labels, one helper sentence where a label is not enough and none where it is. The control that runs names the job ("Plan my trip"), never "Submit".
|
|
355
391
|
- Every value binds to a path the brief lists, and the page reads clearly in both a light and a dark theme.
|
|
356
392
|
- When the brief has a Frame section, the host has already drawn the rest of the screen: plan only the page that section describes, inside that frame - never a side panel, never a bar or a footer the host draws, never a second place the method is run from or a second copy of the request.
|
|
357
|
-
- When the brief has a
|
|
393
|
+
- When the brief has a Shell section, the host draws the page inside that shell, in the team's own design system: the look is decided, so the page decides its composition and nothing of the look - no face, radius, panel or colour.
|
|
394
|
+
- When the brief has a Meaning section, the method has said what its values mean, and the plan shows it: the subject leads an input page and the settings come after it, folded; a verdict leads a result page in its tone; a choice in its option's words and tone, a number in its unit, a bounded number against its bounds, a declared total under its column - each with the component whose description says it reads that fact from the method.
|
|
358
395
|
|
|
359
396
|
AVAILABLE COMPONENTS ({{ catalog.components | length }}):
|
|
360
397
|
|
|
@@ -374,6 +411,9 @@ PLANNING RULES:
|
|
|
374
411
|
6. Tabs and Steps hold exactly one panel per tab or step, in the same order, usually a Stack. Their own state - the active tab, the current step, an open Collapsible - is theirs, never the host's.
|
|
375
412
|
7. An input page has exactly ONE control that runs the method, wherever the composition puts it, and no other Button: a Button bound to nothing does nothing, and navigation is never built out of Buttons, since Steps and Tabs carry their own.
|
|
376
413
|
8. On an input page the only state the page sets is the defaults the brief lists under "Defaults"; on a result page it sets none.
|
|
414
|
+
9. Settings and references are never the page's hero: none of them sits before the subject, the subject is never folded away, and a setting or reference the run waits for with no default stays in view.
|
|
415
|
+
10. A result whose record states a verdict shows it first: no value of the result comes before it but the record's title and summary.
|
|
416
|
+
11. A value the method gives a meaning to is shown by a component that reads it: a toned choice never through a Badge whose colour is guessed, and a number with a unit never through a component that writes a unit of its own.
|
|
377
417
|
|
|
378
418
|
CREATIVE SEED:
|
|
379
419
|
When a creative seed follows the brief, it is your ONLY source of variety. Read it the way a designer reads a found object: its runs of letters, its rare characters, its numbers, its rhythm. Derive from it a creative direction - the composition, the density, the tone of the copy, which controls you favour, where the emphasis sits - and commit to it.
|
|
@@ -465,7 +505,7 @@ EXECUTION:
|
|
|
465
505
|
- Restraint reads premium. No label that restates the obvious, no card inside a card, no paragraph that explains the form, no more than two levels of heading. Every element must earn its place; when in doubt, remove it.
|
|
466
506
|
- Write copy a person would say: short labels, one helper sentence where a label is not enough and none where it is. The control that runs names the job ("Plan my trip"), never "Submit".
|
|
467
507
|
- Every value binds to a path the brief lists, and the page reads clearly in both a light and a dark theme.
|
|
468
|
-
- When the brief has a
|
|
508
|
+
- When the brief has a Shell section, the look is the shell's and the team's design system's: build the plan's composition and set nothing of the look.
|
|
469
509
|
|
|
470
510
|
AVAILABLE COMPONENTS ({{ catalog.components | length }}):
|
|
471
511
|
|
|
@@ -503,6 +543,9 @@ RULES:
|
|
|
503
543
|
12. One root element, and it is a container that accepts children.
|
|
504
544
|
13. The plan's title is on the page as its one h1 - a Heading at level h1, or the headline of a component whose description says it renders an h1 - and no other h1. Below it, heading levels increase by one and never skip: h2, then h3. A component whose description says it renders a heading counts at that level, so a Heading inside it starts one level down.
|
|
505
545
|
14. Never set a "className" prop. Colour, spacing and type come from the components as they are.
|
|
546
|
+
15. Settings and references are never the page's hero: none of them is placed before the subject, the subject is never inside a fold, and a setting or reference the run waits for with no default is not folded away.
|
|
547
|
+
16. A result whose record states a verdict shows it first: no element shows a value of the result before it but the record's title and summary.
|
|
548
|
+
17. A value the method gives a meaning to is shown by a component that reads it: a toned choice never through a Badge, whose colour would be guessed, and a number with a unit never through a component whose description does not say it reads the unit, since that one writes it without.
|
|
506
549
|
|
|
507
550
|
---
|
|
508
551
|
|
|
@@ -173,6 +173,9 @@ interface RunPanelProps {
|
|
|
173
173
|
* so a file the kernel's camera is still making holds Run as an upload in
|
|
174
174
|
* flight does, and calls yours beside it when you pass one: your report
|
|
175
175
|
* starts with the panel's, and the release the field calls ends both.
|
|
176
|
+
* `onUnwritableInput` joins the same way: an entry a control cannot write as
|
|
177
|
+
* a value (a date-time at a local time the clocks skip) holds Run while the
|
|
178
|
+
* control shows it, an optional input's included.
|
|
176
179
|
*
|
|
177
180
|
* A host owning the whole loop answers the field as the panel does: its
|
|
178
181
|
* `onDropFile` returns its upload, a promise of what it stored that resolves
|
package/dist/form/react/index.js
CHANGED
|
@@ -16,9 +16,9 @@ export * from "@pipelex/mthds-form/react";
|
|
|
16
16
|
// src/form/react/RunPanel.tsx
|
|
17
17
|
import * as React from "react";
|
|
18
18
|
import {
|
|
19
|
-
computeReadiness,
|
|
19
|
+
computeReadiness as computeReadiness2,
|
|
20
20
|
fieldsForContract,
|
|
21
|
-
isFilled,
|
|
21
|
+
isFilled as isFilled2,
|
|
22
22
|
sameRunValues,
|
|
23
23
|
setValueAtPath
|
|
24
24
|
} from "@pipelex/mthds-form";
|
|
@@ -31,8 +31,11 @@ import {
|
|
|
31
31
|
|
|
32
32
|
// src/form/runGate.ts
|
|
33
33
|
import {
|
|
34
|
+
computeReadiness,
|
|
34
35
|
describeValidationError,
|
|
35
36
|
gateRunInputs,
|
|
37
|
+
isFilled,
|
|
38
|
+
refusedValue,
|
|
36
39
|
rjsfDataFromRunValues
|
|
37
40
|
} from "@pipelex/mthds-form";
|
|
38
41
|
var MAX_QUOTED_ERRORS = 3;
|
|
@@ -72,6 +75,43 @@ function runSubmitGate(contract, fields, values, t = defaultValidationTranslate)
|
|
|
72
75
|
}
|
|
73
76
|
return { ok: true, apiInputs: verdict.inputs };
|
|
74
77
|
}
|
|
78
|
+
function readinessLine(fields, values, unwritable) {
|
|
79
|
+
const readiness = computeReadiness(fields, values);
|
|
80
|
+
if (readiness.missing.length === 0) {
|
|
81
|
+
return unwritable ? "An entry cannot be used as it is written \u2014 correct it to run." : null;
|
|
82
|
+
}
|
|
83
|
+
const refused = new Set(
|
|
84
|
+
fields.filter((field) => {
|
|
85
|
+
const value = values[field.name];
|
|
86
|
+
return isFilled(value) && refusedValue(field, value) !== void 0;
|
|
87
|
+
}).map((field) => field.name)
|
|
88
|
+
);
|
|
89
|
+
const needed = readiness.missing.filter((name) => !refused.has(name));
|
|
90
|
+
const toCorrect = readiness.missing.filter((name) => refused.has(name));
|
|
91
|
+
const parts = [`${readiness.ready} of ${readiness.total} ready`];
|
|
92
|
+
if (needed.length > 0) parts.push(`still needed: ${needed.join(", ")}`);
|
|
93
|
+
if (toCorrect.length > 0) parts.push(`to correct: ${toCorrect.join(", ")}`);
|
|
94
|
+
return parts.join(" \u2014 ");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// src/form/react/panelReports.ts
|
|
98
|
+
function panelReportSeam(reports, hostSeam) {
|
|
99
|
+
let counter = 0;
|
|
100
|
+
return (id) => {
|
|
101
|
+
var _a;
|
|
102
|
+
counter += 1;
|
|
103
|
+
const token = counter;
|
|
104
|
+
reports.open(token);
|
|
105
|
+
const releaseHost = (_a = hostSeam()) == null ? void 0 : _a(id);
|
|
106
|
+
let released = false;
|
|
107
|
+
return () => {
|
|
108
|
+
if (released) return;
|
|
109
|
+
released = true;
|
|
110
|
+
reports.close(token);
|
|
111
|
+
releaseHost == null ? void 0 : releaseHost();
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
}
|
|
75
115
|
|
|
76
116
|
// src/form/react/panelUpload.ts
|
|
77
117
|
function runPanelUpload({
|
|
@@ -113,6 +153,28 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
113
153
|
var EMPTY_IDS = /* @__PURE__ */ new Set();
|
|
114
154
|
var NO_REPORTS = /* @__PURE__ */ new Set();
|
|
115
155
|
var NOTHING_REVEALED = /* @__PURE__ */ new Set();
|
|
156
|
+
function usePanelReportSeam(hostSeam) {
|
|
157
|
+
const [reports, setReports] = React.useState(NO_REPORTS);
|
|
158
|
+
const hostRef = React.useRef(hostSeam);
|
|
159
|
+
React.useLayoutEffect(() => {
|
|
160
|
+
hostRef.current = hostSeam;
|
|
161
|
+
}, [hostSeam]);
|
|
162
|
+
const [seam] = React.useState(
|
|
163
|
+
() => panelReportSeam(
|
|
164
|
+
{
|
|
165
|
+
open: (token) => setReports((previous) => new Set(previous).add(token)),
|
|
166
|
+
close: (token) => setReports((previous) => {
|
|
167
|
+
if (!previous.has(token)) return previous;
|
|
168
|
+
const next = new Set(previous);
|
|
169
|
+
next.delete(token);
|
|
170
|
+
return next;
|
|
171
|
+
})
|
|
172
|
+
},
|
|
173
|
+
() => hostRef.current
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
return [reports.size, seam];
|
|
177
|
+
}
|
|
116
178
|
function RunPanel({
|
|
117
179
|
contract,
|
|
118
180
|
descriptor,
|
|
@@ -136,7 +198,6 @@ function RunPanel({
|
|
|
136
198
|
var _a, _b, _c;
|
|
137
199
|
const [showOptional, setShowOptional] = React.useState(false);
|
|
138
200
|
const [uploadingIds, setUploadingIds] = React.useState(EMPTY_IDS);
|
|
139
|
-
const [preparing, setPreparing] = React.useState(NO_REPORTS);
|
|
140
201
|
const [submitError, setSubmitError] = React.useState(null);
|
|
141
202
|
const [given, setGiven] = React.useState(null);
|
|
142
203
|
const [fills, setFills] = React.useState(0);
|
|
@@ -146,7 +207,7 @@ function RunPanel({
|
|
|
146
207
|
() => fieldsForContract(contract, descriptor),
|
|
147
208
|
[contract, descriptor]
|
|
148
209
|
);
|
|
149
|
-
const readiness = React.useMemo(() =>
|
|
210
|
+
const readiness = React.useMemo(() => computeReadiness2(fields, values), [fields, values]);
|
|
150
211
|
const commitValues = React.useCallback(
|
|
151
212
|
(next, before) => {
|
|
152
213
|
setSubmitError(null);
|
|
@@ -197,30 +258,8 @@ function RunPanel({
|
|
|
197
258
|
// at drop time, so this callback does not need rebuilding per pipe.
|
|
198
259
|
[uploadFile, commitValues]
|
|
199
260
|
);
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
hostPreparingRef.current = env == null ? void 0 : env.onPreparingFile;
|
|
203
|
-
}, [env == null ? void 0 : env.onPreparingFile]);
|
|
204
|
-
const reportCounter = React.useRef(0);
|
|
205
|
-
const handlePreparingFile = React.useCallback((id) => {
|
|
206
|
-
var _a2;
|
|
207
|
-
reportCounter.current += 1;
|
|
208
|
-
const token = reportCounter.current;
|
|
209
|
-
setPreparing((previous) => new Set(previous).add(token));
|
|
210
|
-
const releaseHost = (_a2 = hostPreparingRef.current) == null ? void 0 : _a2.call(hostPreparingRef, id);
|
|
211
|
-
let released = false;
|
|
212
|
-
return () => {
|
|
213
|
-
if (released) return;
|
|
214
|
-
released = true;
|
|
215
|
-
setPreparing((previous) => {
|
|
216
|
-
if (!previous.has(token)) return previous;
|
|
217
|
-
const next = new Set(previous);
|
|
218
|
-
next.delete(token);
|
|
219
|
-
return next;
|
|
220
|
-
});
|
|
221
|
-
releaseHost == null ? void 0 : releaseHost();
|
|
222
|
-
};
|
|
223
|
-
}, []);
|
|
261
|
+
const [preparing, handlePreparingFile] = usePanelReportSeam(env == null ? void 0 : env.onPreparingFile);
|
|
262
|
+
const [unwritable, handleUnwritableInput] = usePanelReportSeam(env == null ? void 0 : env.onUnwritableInput);
|
|
224
263
|
const fieldEnv = React.useMemo(
|
|
225
264
|
() => {
|
|
226
265
|
var _a2, _b2, _c2, _d, _e;
|
|
@@ -244,8 +283,9 @@ function RunPanel({
|
|
|
244
283
|
// supplies `onDropFile` too, so our set is empty and the union is exactly
|
|
245
284
|
// its set — "yours win" still holds where that clause applies.
|
|
246
285
|
uploadingIds: /* @__PURE__ */ new Set([...(_e = env == null ? void 0 : env.uploadingIds) != null ? _e : EMPTY_IDS, ...uploadingIds]),
|
|
247
|
-
// Always the panel's, which
|
|
248
|
-
onPreparingFile: handlePreparingFile
|
|
286
|
+
// Always the panel's, which call the host's beside them (above).
|
|
287
|
+
onPreparingFile: handlePreparingFile,
|
|
288
|
+
onUnwritableInput: handleUnwritableInput
|
|
249
289
|
});
|
|
250
290
|
},
|
|
251
291
|
[
|
|
@@ -256,12 +296,15 @@ function RunPanel({
|
|
|
256
296
|
fileSource,
|
|
257
297
|
loadText,
|
|
258
298
|
uploadingIds,
|
|
259
|
-
handlePreparingFile
|
|
299
|
+
handlePreparingFile,
|
|
300
|
+
handleUnwritableInput
|
|
260
301
|
]
|
|
261
302
|
);
|
|
262
|
-
const uploading = ((_b = (_a = fieldEnv.uploadingIds) == null ? void 0 : _a.size) != null ? _b : 0) > 0 || preparing
|
|
303
|
+
const uploading = ((_b = (_a = fieldEnv.uploadingIds) == null ? void 0 : _a.size) != null ? _b : 0) > 0 || preparing > 0;
|
|
263
304
|
const notReady = readiness.missing.length > 0;
|
|
264
|
-
const
|
|
305
|
+
const unwritableEntry = unwritable > 0;
|
|
306
|
+
const readinessText = readinessLine(fields, values, unwritableEntry);
|
|
307
|
+
const blocked = running || notReady || unwritableEntry || uploading || ((_c = env == null ? void 0 : env.disabled) != null ? _c : false);
|
|
265
308
|
const [revealed, setRevealed] = React.useState(NOTHING_REVEALED);
|
|
266
309
|
const [latchedFor, setLatchedFor] = React.useState(contract);
|
|
267
310
|
const [contractTurns, setContractTurns] = React.useState(0);
|
|
@@ -275,7 +318,7 @@ function RunPanel({
|
|
|
275
318
|
setContractTurns(contractTurnsNow);
|
|
276
319
|
}
|
|
277
320
|
const newlyRevealed = fields.filter(
|
|
278
|
-
(field) => !field.required &&
|
|
321
|
+
(field) => !field.required && isFilled2(values[field.name]) && !revealedNow.has(field.name)
|
|
279
322
|
);
|
|
280
323
|
if (newlyRevealed.length > 0) {
|
|
281
324
|
revealedNow = /* @__PURE__ */ new Set([...revealedNow, ...newlyRevealed.map((field) => field.name)]);
|
|
@@ -286,7 +329,7 @@ function RunPanel({
|
|
|
286
329
|
[revealedNow]
|
|
287
330
|
);
|
|
288
331
|
const foldableCount = fields.filter(
|
|
289
|
-
(field) => !field.required && !
|
|
332
|
+
(field) => !field.required && !isFilled2(values[field.name])
|
|
290
333
|
).length;
|
|
291
334
|
const visibleFields = showOptional ? fields : fields.filter((field) => !isFolded(field));
|
|
292
335
|
const hasExampleSource = exampleSource !== void 0;
|
|
@@ -389,11 +432,11 @@ function RunPanel({
|
|
|
389
432
|
type: "submit",
|
|
390
433
|
className: "mthds-run-panel-run",
|
|
391
434
|
disabled: blocked,
|
|
392
|
-
"aria-describedby":
|
|
435
|
+
"aria-describedby": readinessText ? readinessHintId : void 0,
|
|
393
436
|
children: running ? "Running\u2026" : "Run"
|
|
394
437
|
}
|
|
395
438
|
),
|
|
396
|
-
|
|
439
|
+
readinessText && /* @__PURE__ */ jsx("span", { id: readinessHintId, className: "mthds-run-panel-readiness", children: readinessText })
|
|
397
440
|
] })
|
|
398
441
|
]
|
|
399
442
|
}
|