@nodii/dev 0.6.146 → 0.6.147
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/core.js +1 -1
- package/dist/surface.js +22 -2
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.147";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/surface.js
CHANGED
|
@@ -906,7 +906,7 @@ const literalText = (lit) => JSON.parse(lit.startsWith("{") ? lit.slice(1, -1) :
|
|
|
906
906
|
function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
|
|
907
907
|
const lifted = [];
|
|
908
908
|
const lift = (at, name) => (lifted.push(name), mark(ctx, at, name));
|
|
909
|
-
let out = liftFieldControls(code, node, ctx, lift);
|
|
909
|
+
let out = liftFieldControls(code, node, ctx, lift, scope);
|
|
910
910
|
// An Alert's title or description that names a record's value: a date, an amount, a code,
|
|
911
911
|
// or any figure ("running at 4.2% this period", "3 lines still carry a flag"; hub-468).
|
|
912
912
|
out = out.replace(/<(Alert(Title|Description))>(\{"(?:[^"\\\n]|\\.)*"\})<\/\1>/g, (all, tag, part, lit) =>
|
|
@@ -1356,6 +1356,9 @@ function textNextTo(node, ctx) {
|
|
|
1356
1356
|
/** The form controls the page owns: a value it passes and a change it hears (NODII-DEV-CLI-82, -83). */
|
|
1357
1357
|
const FIELD_CONTROLS = { Input: "onChange", Textarea: "onChange", SelectField: "onValueChange", RadioGroup: "onValueChange" };
|
|
1358
1358
|
|
|
1359
|
+
/** The form controls whose template may wire them with generic names, and the change each hears (hub-481). */
|
|
1360
|
+
const NAMED_CHANGE = { ...FIELD_CONTROLS, MultiSelect: "onValueChange", DateTimePicker: "onChange", DatePicker: "onValueChange", DateRangePicker: "onChange" };
|
|
1361
|
+
|
|
1359
1362
|
/**
|
|
1360
1363
|
* A control the template half-controls (`defaultValue="chart"` beside
|
|
1361
1364
|
* `onValueChange={setView}`, a Segmented Control's view switch), or that
|
|
@@ -1406,8 +1409,25 @@ function fieldScope(node, ctx, code) {
|
|
|
1406
1409
|
* and a change calls back. A SelectField's id is its own, not the template's
|
|
1407
1410
|
* shared `id="select"`. The scope also names the template's own identifiers
|
|
1408
1411
|
* (a select's options), so two filters never share one.
|
|
1412
|
+
*
|
|
1413
|
+
* A template that wires the control itself with generic names (an Input's
|
|
1414
|
+
* `value={value} onChange={onChange}`, a Date Time Picker's
|
|
1415
|
+
* `onChange={setValue}`, a Date Picker's `onValueChange={setDate}`) has them
|
|
1416
|
+
* named from its field, `<field>Value` and `on<Field>Change`, as a
|
|
1417
|
+
* SelectField's are; a date picker's sample or empty value (`value=""`) is the
|
|
1418
|
+
* page's too, in every view. Two fields of one label in one view are told
|
|
1419
|
+
* apart by their place (resolveScopes) (hub-481).
|
|
1409
1420
|
*/
|
|
1410
|
-
function liftFieldControls(code, node, ctx, lift) {
|
|
1421
|
+
function liftFieldControls(code, node, ctx, lift, scope) {
|
|
1422
|
+
code = rewriteTags(code, Object.keys(NAMED_CHANGE).join("|"), (attrs, tag) => {
|
|
1423
|
+
const handler = NAMED_CHANGE[tag];
|
|
1424
|
+
const change = new RegExp(String.raw`(^|\s)${handler}=\{(?:onChange|onValueChange|set(?:Value|Date|Range))\}`).exec(attrs);
|
|
1425
|
+
if (!change) return attrs;
|
|
1426
|
+
const named = attrs.replace(change[0], `${change[1]}${handler}={${lift(scope, `on${cap(scope)}Change`)}}`);
|
|
1427
|
+
const sample = String.raw`|"(?:[^"\\\n]|\\.)*"|\{\{[^{}]*\}\}|\{new Date\([^()]*\)\}`;
|
|
1428
|
+
const value = new RegExp(String.raw`(^|\s)value=(?:\{(?:value|date|range)\}${/^Date/.test(tag) ? sample : ""})`).exec(named);
|
|
1429
|
+
return value ? named.replace(value[0], `${value[1]}value={${lift(scope, `${scope}Value`)}}`) : named;
|
|
1430
|
+
});
|
|
1411
1431
|
// A field's placeholder is the page's too: in a Surface it is the value the frame shows
|
|
1412
1432
|
// ("Last 30 days", "K*** M***", "Sep 2026"), and a search box's copy names the list
|
|
1413
1433
|
// the page searches (hub-468). Named by the field, as its value is.
|