@valbuild/next 0.110.1 → 0.111.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/README.md +82 -11
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
- [keyOf](#keyof)
|
|
58
58
|
- [Route](#route)
|
|
59
59
|
- [Color](#color)
|
|
60
|
+
- [Code](#code)
|
|
60
61
|
- [Date](#date)
|
|
61
62
|
- [DateTime](#datetime)
|
|
62
63
|
|
|
@@ -353,6 +354,8 @@ To configure your project for monorepos, you can use the `root` parameter descri
|
|
|
353
354
|
import { s } from "./val.config";
|
|
354
355
|
|
|
355
356
|
s.string(); // <- Schema<string>
|
|
357
|
+
|
|
358
|
+
s.string().multiline(); // edited in a growing text box, not a single-line input
|
|
356
359
|
```
|
|
357
360
|
|
|
358
361
|
## Number
|
|
@@ -562,27 +565,52 @@ for it to read into the value's content.
|
|
|
562
565
|
> closure no longer receives `key` — derive the title from `val`. And
|
|
563
566
|
> `.jsonValues()` must come before `.preview(...)`, like `.validate(...)`.
|
|
564
567
|
|
|
565
|
-
###
|
|
568
|
+
### Multi-line strings and code
|
|
566
569
|
|
|
567
|
-
A
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
how the value shows where it is navigable to. A schema can carry both, and a
|
|
571
|
-
second `.render(...)` replaces the first rather than merging with it.
|
|
570
|
+
A string that holds more than one line says so with `.multiline()`: the editor
|
|
571
|
+
gives it a growing text box instead of a single-line input. Nothing else changes —
|
|
572
|
+
the value is a plain string.
|
|
572
573
|
|
|
573
574
|
```ts
|
|
574
575
|
const articleSchema = s.object({
|
|
575
576
|
title: s.string(),
|
|
576
577
|
// A multi-line box instead of a single-line input
|
|
577
|
-
summary: s.string().
|
|
578
|
+
summary: s.string().multiline(),
|
|
578
579
|
// A syntax-highlighted code editor
|
|
579
|
-
snippet: s.
|
|
580
|
+
snippet: s.code({ language: "typescript" }),
|
|
580
581
|
});
|
|
581
582
|
```
|
|
582
583
|
|
|
583
|
-
`
|
|
584
|
-
`
|
|
585
|
-
`@valbuild/core` for the full
|
|
584
|
+
`s.code()` is its own schema type, edited in a code editor. Its `language`
|
|
585
|
+
option — `typescript`, `javascript`, `json`, `html`, `css`, `markdown`,
|
|
586
|
+
`python`, `sql` and others; see `CodeLanguage` in `@valbuild/core` for the full
|
|
587
|
+
list — decides the syntax highlighting. Leave it out for a plain monospaced
|
|
588
|
+
editor with no highlighting.
|
|
589
|
+
|
|
590
|
+
The value is a string like any other, with one difference: a code value is
|
|
591
|
+
never stega encoded, so what reaches your app is exactly
|
|
592
|
+
what was written. Invisible characters are an edit tag in prose and corruption
|
|
593
|
+
in source code.
|
|
594
|
+
|
|
595
|
+
> **Breaking.** `s.string().render({ as: "textarea" })` and
|
|
596
|
+
> `s.string().render({ as: "code", language })` have been removed. Neither was
|
|
597
|
+
> about layout: whether a string may hold line breaks is a fact about the
|
|
598
|
+
> content, and a language is part of what the value is.
|
|
599
|
+
>
|
|
600
|
+
> ```ts
|
|
601
|
+
> s.string().multiline(); // was .render({ as: "textarea" })
|
|
602
|
+
> s.code({ language: "typescript" }); // was .render({ as: "code", language })
|
|
603
|
+
> ```
|
|
604
|
+
>
|
|
605
|
+
> `.render(...)` now takes only `{ as: "inline" }`, on every field alike.
|
|
606
|
+
|
|
607
|
+
### Field rendering
|
|
608
|
+
|
|
609
|
+
A **render** is how ONE field is laid out in the editor when you are LOOKING at
|
|
610
|
+
that field. It is static configuration rather than a function, and it is a
|
|
611
|
+
different thing from a preview: a render is the field's own layout, a preview is
|
|
612
|
+
how the value shows where it is navigable to. A schema can carry both, and a
|
|
613
|
+
second `.render(...)` replaces the first rather than merging with it.
|
|
586
614
|
|
|
587
615
|
#### Editing list items in place
|
|
588
616
|
|
|
@@ -1099,6 +1127,49 @@ To hand a color to a stylesheet instead, set it as a CSS custom property:
|
|
|
1099
1127
|
|
|
1100
1128
|
**NOTE**: colors are not steganographically tagged, since the value ends up in CSS where the invisible characters would break the declaration. Colors therefore do not participate in click-then-edit visual editing (the same is true of dates) - edit them from the studio instead.
|
|
1101
1129
|
|
|
1130
|
+
## Code
|
|
1131
|
+
|
|
1132
|
+
The `code` schema is a string edited in a code editor. It is a schema type of
|
|
1133
|
+
its own rather than a layout on `s.string()`, because the language is part of
|
|
1134
|
+
what the value is — and because a code value is never stega encoded, so what
|
|
1135
|
+
reaches your app is exactly what was written.
|
|
1136
|
+
|
|
1137
|
+
### Code Schema
|
|
1138
|
+
|
|
1139
|
+
```ts
|
|
1140
|
+
s.code(); // <- Schema<string>, a monospaced editor with no highlighting
|
|
1141
|
+
s.code({ language: "typescript" }); // syntax highlighted
|
|
1142
|
+
```
|
|
1143
|
+
|
|
1144
|
+
### Languages
|
|
1145
|
+
|
|
1146
|
+
`language` is one of `typescript`, `javascript`, `typescriptreact`,
|
|
1147
|
+
`javascriptreact`, `json`, `java`, `html`, `css`, `xml`, `markdown`, `sql`,
|
|
1148
|
+
`python`, `rust`, `php`, `go`, `cpp`, `sass`, `vue` or `angular` — the
|
|
1149
|
+
`CodeLanguage` type exported from `@valbuild/core`. Leave it out for a plain
|
|
1150
|
+
monospaced editor.
|
|
1151
|
+
|
|
1152
|
+
The language decides the highlighting only: the content is never checked against
|
|
1153
|
+
it, since a half-written snippet is a normal thing to save an editor in. Use
|
|
1154
|
+
`.validate()` if you need more than that.
|
|
1155
|
+
|
|
1156
|
+
### Initializing code content
|
|
1157
|
+
|
|
1158
|
+
```ts
|
|
1159
|
+
import { s, c, type t } from "../val.config";
|
|
1160
|
+
|
|
1161
|
+
export const schema = s.object({
|
|
1162
|
+
snippet: s.code({ language: "typescript" }).describe("Example usage"),
|
|
1163
|
+
styles: s.code({ language: "css" }).nullable(),
|
|
1164
|
+
});
|
|
1165
|
+
|
|
1166
|
+
export type Example = t.inferSchema<typeof schema>;
|
|
1167
|
+
export default c.define("/content/example.val.ts", schema, {
|
|
1168
|
+
snippet: "const val = initVal();",
|
|
1169
|
+
styles: null,
|
|
1170
|
+
});
|
|
1171
|
+
```
|
|
1172
|
+
|
|
1102
1173
|
## Date
|
|
1103
1174
|
|
|
1104
1175
|
The `date` schema represents a calendar day, with no time and no timezone. It is stored as a `YYYY-MM-DD` string.
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"next",
|
|
13
13
|
"react"
|
|
14
14
|
],
|
|
15
|
-
"version": "0.
|
|
15
|
+
"version": "0.111.0",
|
|
16
16
|
"main": "dist/valbuild-next.cjs.js",
|
|
17
17
|
"module": "dist/valbuild-next.esm.js",
|
|
18
18
|
"exports": {
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"client-only": "^0.0.1",
|
|
49
49
|
"server-only": "^0.0.1",
|
|
50
|
-
"@valbuild/core": "0.
|
|
51
|
-
"@valbuild/
|
|
52
|
-
"@valbuild/
|
|
53
|
-
"@valbuild/
|
|
54
|
-
"@valbuild/
|
|
55
|
-
"@valbuild/
|
|
50
|
+
"@valbuild/core": "0.111.0",
|
|
51
|
+
"@valbuild/react": "0.111.0",
|
|
52
|
+
"@valbuild/shared": "0.111.0",
|
|
53
|
+
"@valbuild/server": "0.111.0",
|
|
54
|
+
"@valbuild/language-server": "0.111.0",
|
|
55
|
+
"@valbuild/ui": "0.111.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@testing-library/react": "^16.3.3",
|