@fieldia/core 0.27.0 → 0.29.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 (267) hide show
  1. package/README.md +148 -5
  2. package/package.json +1 -1
  3. package/schema/page.schema.json +266 -7
  4. package/src/index.d.mts +10 -2
  5. package/src/index.d.ts +10 -2
  6. package/src/index.js +33 -2
  7. package/src/index.js.map +1 -1
  8. package/src/index.mjs +13 -2
  9. package/src/index.mjs.map +1 -1
  10. package/src/lib/format/approval-checks.d.mts +8 -0
  11. package/src/lib/format/approval-checks.d.ts +8 -0
  12. package/src/lib/format/approval-checks.js +29 -0
  13. package/src/lib/format/approval-checks.js.map +1 -0
  14. package/src/lib/format/approval-checks.mjs +26 -0
  15. package/src/lib/format/approval-checks.mjs.map +1 -0
  16. package/src/lib/format/approval.d.mts +20 -0
  17. package/src/lib/format/approval.d.ts +20 -0
  18. package/src/lib/format/approval.js +25 -0
  19. package/src/lib/format/approval.js.map +1 -0
  20. package/src/lib/format/approval.mjs +22 -0
  21. package/src/lib/format/approval.mjs.map +1 -0
  22. package/src/lib/format/assist-checks.d.mts +14 -0
  23. package/src/lib/format/assist-checks.d.ts +14 -0
  24. package/src/lib/format/assist-checks.js +68 -0
  25. package/src/lib/format/assist-checks.js.map +1 -0
  26. package/src/lib/format/assist-checks.mjs +64 -0
  27. package/src/lib/format/assist-checks.mjs.map +1 -0
  28. package/src/lib/format/assist.d.mts +41 -0
  29. package/src/lib/format/assist.d.ts +41 -0
  30. package/src/lib/format/assist.js +29 -0
  31. package/src/lib/format/assist.js.map +1 -0
  32. package/src/lib/format/assist.mjs +26 -0
  33. package/src/lib/format/assist.mjs.map +1 -0
  34. package/src/lib/format/editable-checks.d.mts +8 -0
  35. package/src/lib/format/editable-checks.d.ts +8 -0
  36. package/src/lib/format/editable-checks.js +38 -0
  37. package/src/lib/format/editable-checks.js.map +1 -0
  38. package/src/lib/format/editable-checks.mjs +35 -0
  39. package/src/lib/format/editable-checks.mjs.map +1 -0
  40. package/src/lib/format/field.d.mts +86 -0
  41. package/src/lib/format/field.d.ts +86 -0
  42. package/src/lib/format/field.js +56 -10
  43. package/src/lib/format/field.js.map +1 -1
  44. package/src/lib/format/field.mjs +55 -9
  45. package/src/lib/format/field.mjs.map +1 -1
  46. package/src/lib/format/languages-checks.d.mts +8 -0
  47. package/src/lib/format/languages-checks.d.ts +8 -0
  48. package/src/lib/format/languages-checks.js +40 -0
  49. package/src/lib/format/languages-checks.js.map +1 -0
  50. package/src/lib/format/languages-checks.mjs +37 -0
  51. package/src/lib/format/languages-checks.mjs.map +1 -0
  52. package/src/lib/format/later-checks.d.mts +4 -3
  53. package/src/lib/format/later-checks.d.ts +4 -3
  54. package/src/lib/format/later-checks.js +4 -3
  55. package/src/lib/format/later-checks.js.map +1 -1
  56. package/src/lib/format/later-checks.mjs +4 -3
  57. package/src/lib/format/later-checks.mjs.map +1 -1
  58. package/src/lib/format/layout.d.mts +123 -28
  59. package/src/lib/format/layout.d.ts +123 -28
  60. package/src/lib/format/layout.js +20 -4
  61. package/src/lib/format/layout.js.map +1 -1
  62. package/src/lib/format/layout.mjs +18 -2
  63. package/src/lib/format/layout.mjs.map +1 -1
  64. package/src/lib/format/layout.types.d.mts +2 -1
  65. package/src/lib/format/layout.types.d.ts +2 -1
  66. package/src/lib/format/list-editable.d.mts +20 -0
  67. package/src/lib/format/list-editable.d.ts +20 -0
  68. package/src/lib/format/list-editable.js +33 -0
  69. package/src/lib/format/list-editable.js.map +1 -0
  70. package/src/lib/format/list-editable.mjs +28 -0
  71. package/src/lib/format/list-editable.mjs.map +1 -0
  72. package/src/lib/format/page.d.mts +91 -9
  73. package/src/lib/format/page.d.ts +91 -9
  74. package/src/lib/format/page.js +4 -0
  75. package/src/lib/format/page.js.map +1 -1
  76. package/src/lib/format/page.mjs +4 -0
  77. package/src/lib/format/page.mjs.map +1 -1
  78. package/src/lib/format/photos-options.d.mts +29 -0
  79. package/src/lib/format/photos-options.d.ts +29 -0
  80. package/src/lib/format/photos-options.js +49 -0
  81. package/src/lib/format/photos-options.js.map +1 -0
  82. package/src/lib/format/photos-options.mjs +45 -0
  83. package/src/lib/format/photos-options.mjs.map +1 -0
  84. package/src/lib/format/references.js +31 -1
  85. package/src/lib/format/references.js.map +1 -1
  86. package/src/lib/format/references.mjs +31 -1
  87. package/src/lib/format/references.mjs.map +1 -1
  88. package/src/lib/format/scan-checks.d.mts +12 -0
  89. package/src/lib/format/scan-checks.d.ts +12 -0
  90. package/src/lib/format/scan-checks.js +89 -0
  91. package/src/lib/format/scan-checks.js.map +1 -0
  92. package/src/lib/format/scan-checks.mjs +86 -0
  93. package/src/lib/format/scan-checks.mjs.map +1 -0
  94. package/src/lib/format/scan-options.d.mts +84 -0
  95. package/src/lib/format/scan-options.d.ts +84 -0
  96. package/src/lib/format/scan-options.js +58 -0
  97. package/src/lib/format/scan-options.js.map +1 -0
  98. package/src/lib/format/scan-options.mjs +54 -0
  99. package/src/lib/format/scan-options.mjs.map +1 -0
  100. package/src/lib/format/upgrade.d.mts +4 -1
  101. package/src/lib/format/upgrade.d.ts +4 -1
  102. package/src/lib/format/upgrade.js +4 -1
  103. package/src/lib/format/upgrade.js.map +1 -1
  104. package/src/lib/format/upgrade.mjs +4 -1
  105. package/src/lib/format/upgrade.mjs.map +1 -1
  106. package/src/lib/format/version.d.mts +2 -2
  107. package/src/lib/format/version.d.ts +2 -2
  108. package/src/lib/format/version.js +2 -2
  109. package/src/lib/format/version.js.map +1 -1
  110. package/src/lib/format/version.mjs +2 -2
  111. package/src/lib/format/version.mjs.map +1 -1
  112. package/src/lib/record/approvals-part.d.mts +6 -0
  113. package/src/lib/record/approvals-part.d.ts +6 -0
  114. package/src/lib/record/approvals-part.js +14 -0
  115. package/src/lib/record/approvals-part.js.map +1 -0
  116. package/src/lib/record/approvals-part.mjs +7 -0
  117. package/src/lib/record/approvals-part.mjs.map +1 -0
  118. package/src/lib/record/approving.d.mts +45 -0
  119. package/src/lib/record/approving.d.ts +45 -0
  120. package/src/lib/record/approving.js +10 -0
  121. package/src/lib/record/approving.js.map +1 -0
  122. package/src/lib/record/approving.mjs +7 -0
  123. package/src/lib/record/approving.mjs.map +1 -0
  124. package/src/lib/record/check.js +7 -1
  125. package/src/lib/record/check.js.map +1 -1
  126. package/src/lib/record/check.mjs +7 -1
  127. package/src/lib/record/check.mjs.map +1 -1
  128. package/src/lib/record/data-source.d.mts +270 -0
  129. package/src/lib/record/data-source.d.ts +270 -0
  130. package/src/lib/record/data-source.js.map +1 -1
  131. package/src/lib/record/data-source.mjs.map +1 -1
  132. package/src/lib/record/day-words.d.mts +10 -0
  133. package/src/lib/record/day-words.d.ts +10 -0
  134. package/src/lib/record/day-words.js +23 -0
  135. package/src/lib/record/day-words.js.map +1 -0
  136. package/src/lib/record/day-words.mjs +20 -0
  137. package/src/lib/record/day-words.mjs.map +1 -0
  138. package/src/lib/record/files-part.d.mts +7 -0
  139. package/src/lib/record/files-part.d.ts +7 -0
  140. package/src/lib/record/files-part.js +167 -0
  141. package/src/lib/record/files-part.js.map +1 -0
  142. package/src/lib/record/files-part.mjs +163 -0
  143. package/src/lib/record/files-part.mjs.map +1 -0
  144. package/src/lib/record/filter.d.mts +5 -0
  145. package/src/lib/record/filter.d.ts +5 -0
  146. package/src/lib/record/filter.js +1 -0
  147. package/src/lib/record/filter.js.map +1 -1
  148. package/src/lib/record/filter.mjs +1 -1
  149. package/src/lib/record/filter.mjs.map +1 -1
  150. package/src/lib/record/form-approvals.d.mts +47 -0
  151. package/src/lib/record/form-approvals.d.ts +47 -0
  152. package/src/lib/record/form-approvals.js +186 -0
  153. package/src/lib/record/form-approvals.js.map +1 -0
  154. package/src/lib/record/form-approvals.mjs +180 -0
  155. package/src/lib/record/form-approvals.mjs.map +1 -0
  156. package/src/lib/record/form-limits.d.mts +5 -8
  157. package/src/lib/record/form-limits.d.ts +5 -8
  158. package/src/lib/record/form-limits.js +20 -21
  159. package/src/lib/record/form-limits.js.map +1 -1
  160. package/src/lib/record/form-limits.mjs +21 -22
  161. package/src/lib/record/form-limits.mjs.map +1 -1
  162. package/src/lib/record/form.d.mts +41 -8
  163. package/src/lib/record/form.d.ts +41 -8
  164. package/src/lib/record/form.js +119 -11
  165. package/src/lib/record/form.js.map +1 -1
  166. package/src/lib/record/form.mjs +119 -11
  167. package/src/lib/record/form.mjs.map +1 -1
  168. package/src/lib/record/languages-part.d.mts +32 -0
  169. package/src/lib/record/languages-part.d.ts +32 -0
  170. package/src/lib/record/languages-part.js +104 -0
  171. package/src/lib/record/languages-part.js.map +1 -0
  172. package/src/lib/record/languages-part.mjs +96 -0
  173. package/src/lib/record/languages-part.mjs.map +1 -0
  174. package/src/lib/record/languages.d.mts +26 -0
  175. package/src/lib/record/languages.d.ts +26 -0
  176. package/src/lib/record/languages.js +20 -0
  177. package/src/lib/record/languages.js.map +1 -0
  178. package/src/lib/record/languages.mjs +15 -0
  179. package/src/lib/record/languages.mjs.map +1 -0
  180. package/src/lib/record/limits.js +4 -2
  181. package/src/lib/record/limits.js.map +1 -1
  182. package/src/lib/record/limits.mjs +4 -2
  183. package/src/lib/record/limits.mjs.map +1 -1
  184. package/src/lib/record/locales/ar.js +6 -0
  185. package/src/lib/record/locales/ar.js.map +1 -1
  186. package/src/lib/record/locales/ar.mjs +6 -0
  187. package/src/lib/record/locales/ar.mjs.map +1 -1
  188. package/src/lib/record/locales/de.js +6 -0
  189. package/src/lib/record/locales/de.js.map +1 -1
  190. package/src/lib/record/locales/de.mjs +6 -0
  191. package/src/lib/record/locales/de.mjs.map +1 -1
  192. package/src/lib/record/locales/fr.js +6 -0
  193. package/src/lib/record/locales/fr.js.map +1 -1
  194. package/src/lib/record/locales/fr.mjs +6 -0
  195. package/src/lib/record/locales/fr.mjs.map +1 -1
  196. package/src/lib/record/memory-approvals.d.mts +47 -0
  197. package/src/lib/record/memory-approvals.d.ts +47 -0
  198. package/src/lib/record/memory-approvals.js +78 -0
  199. package/src/lib/record/memory-approvals.js.map +1 -0
  200. package/src/lib/record/memory-approvals.mjs +75 -0
  201. package/src/lib/record/memory-approvals.mjs.map +1 -0
  202. package/src/lib/record/memory-assist.d.mts +53 -0
  203. package/src/lib/record/memory-assist.d.ts +53 -0
  204. package/src/lib/record/memory-assist.js +519 -0
  205. package/src/lib/record/memory-assist.js.map +1 -0
  206. package/src/lib/record/memory-assist.mjs +513 -0
  207. package/src/lib/record/memory-assist.mjs.map +1 -0
  208. package/src/lib/record/memory-clusters.d.mts +18 -0
  209. package/src/lib/record/memory-clusters.d.ts +18 -0
  210. package/src/lib/record/memory-clusters.js +83 -0
  211. package/src/lib/record/memory-clusters.js.map +1 -0
  212. package/src/lib/record/memory-clusters.mjs +80 -0
  213. package/src/lib/record/memory-clusters.mjs.map +1 -0
  214. package/src/lib/record/memory-data-source.d.mts +43 -3
  215. package/src/lib/record/memory-data-source.d.ts +43 -3
  216. package/src/lib/record/memory-data-source.js +105 -19
  217. package/src/lib/record/memory-data-source.js.map +1 -1
  218. package/src/lib/record/memory-data-source.mjs +105 -19
  219. package/src/lib/record/memory-data-source.mjs.map +1 -1
  220. package/src/lib/record/memory-later.d.mts +1 -1
  221. package/src/lib/record/memory-later.d.ts +1 -1
  222. package/src/lib/record/memory-later.js +4 -1
  223. package/src/lib/record/memory-later.js.map +1 -1
  224. package/src/lib/record/memory-later.mjs +4 -1
  225. package/src/lib/record/memory-later.mjs.map +1 -1
  226. package/src/lib/record/messages.d.mts +24 -2
  227. package/src/lib/record/messages.d.ts +24 -2
  228. package/src/lib/record/messages.js +8 -4
  229. package/src/lib/record/messages.js.map +1 -1
  230. package/src/lib/record/messages.mjs +8 -4
  231. package/src/lib/record/messages.mjs.map +1 -1
  232. package/src/lib/record/option-rules.d.mts +7 -1
  233. package/src/lib/record/option-rules.d.ts +7 -1
  234. package/src/lib/record/option-rules.js +9 -3
  235. package/src/lib/record/option-rules.js.map +1 -1
  236. package/src/lib/record/option-rules.mjs +9 -3
  237. package/src/lib/record/option-rules.mjs.map +1 -1
  238. package/src/lib/record/record-words.d.mts +13 -1
  239. package/src/lib/record/record-words.d.ts +13 -1
  240. package/src/lib/record/record-words.js +29 -1
  241. package/src/lib/record/record-words.js.map +1 -1
  242. package/src/lib/record/record-words.mjs +27 -1
  243. package/src/lib/record/record-words.mjs.map +1 -1
  244. package/src/lib/record/uploads.d.mts +35 -9
  245. package/src/lib/record/uploads.d.ts +35 -9
  246. package/src/lib/record/uploads.js +49 -169
  247. package/src/lib/record/uploads.js.map +1 -1
  248. package/src/lib/record/uploads.mjs +42 -164
  249. package/src/lib/record/uploads.mjs.map +1 -1
  250. package/src/lib/record/values.d.mts +23 -0
  251. package/src/lib/record/values.d.ts +23 -0
  252. package/src/lib/record/values.js +4 -0
  253. package/src/lib/record/values.js.map +1 -1
  254. package/src/lib/record/values.mjs +4 -0
  255. package/src/lib/record/values.mjs.map +1 -1
  256. package/src/lib/record/waits.d.mts +7 -5
  257. package/src/lib/record/waits.d.ts +7 -5
  258. package/src/lib/record/waits.js +7 -10
  259. package/src/lib/record/waits.js.map +1 -1
  260. package/src/lib/record/waits.mjs +7 -10
  261. package/src/lib/record/waits.mjs.map +1 -1
  262. package/src/runtime.d.mts +13 -6
  263. package/src/runtime.d.ts +13 -6
  264. package/src/runtime.js +22 -3
  265. package/src/runtime.js.map +1 -1
  266. package/src/runtime.mjs +11 -2
  267. package/src/runtime.mjs.map +1 -1
package/README.md CHANGED
@@ -28,7 +28,7 @@ list of records — that your app implements;
28
28
  The page format is also a JSON Schema, for editors and other languages:
29
29
  `@fieldia/core/page.schema.json`.
30
30
 
31
- A page says which format it is written in (`"fieldia": "0.6"`, `FORMAT_VERSION`; a page in 0.1, 0.2, 0.3, 0.4 or 0.5 is read as it is).
31
+ A page says which format it is written in (`"fieldia": "0.8"`, `FORMAT_VERSION`; a page in 0.1, 0.2, 0.3, 0.4, 0.5, 0.6 or 0.7 is read as it is).
32
32
  One in an older format is brought up to date as it is read — by `checkPage`,
33
33
  `validatePage` and `createForm`, so by the viewer and the designer too — and
34
34
  `upgradePage` does it for the pages your app keeps. One newer than this Fieldia
@@ -78,6 +78,15 @@ and null when it shows its value; the viewer draws it as a dash, said in words
78
78
  ("Fix line 1 of Order lines to see Untaxed amount"). An answer your onchange
79
79
  gives meanwhile is kept, and shown once the line reads.
80
80
 
81
+ It waits the same for an answer the form refuses: one shown that holds a value
82
+ its checks do not take — an area of −50 under its `min` of 0, a day past its
83
+ `max` of `today`, a pattern not met, an answer rule's error — on the record or
84
+ in a line's cell, whether the value is the page's own formula, one of
85
+ Fieldia's functions (`years(built_on, today())`) or your app's: "Fix Area (m²)
86
+ to see Price per m²", never −120,000.00. An empty answer is none, required or
87
+ not, and one no one is shown is never refused. What waits for an answer is told
88
+ before what is asked of your app's server for it.
89
+
81
90
  ## Functions, and your app's own
82
91
 
83
92
  A value worked out (`compute`), a value set by a condition (`setWhen`) and every
@@ -177,8 +186,11 @@ app's list gave, or those picked where they are carried from (`picked: false`: t
177
186
  left unpicked; a "None of these" is never carried) — less those whose condition hides
178
187
  them. A chosen option a change no longer offers is taken out of the answer, never
179
188
  silently kept: `form.getState().takenOut` says so by path ("Garden is no longer
180
- offered, so it was taken out"), until that value is written again — the same words
181
- for a choice its app's list no longer offers, a page's or a line's. One a record held
189
+ offered, so it was taken out"), while it is true: it goes once the value is written
190
+ again, or once what it names is offered again (Villa picked again, the treatment
191
+ ticked again above, the list asked again offering it); one of several offered again
192
+ leaves it naming the rest. The same words for a choice its app's list no longer
193
+ offers, a page's or a line's. One a record held
182
194
  as it was opened stays chosen, and the choice says it is no longer offered. The
183
195
  page's checks read each option's condition and refuse a choice carried from itself,
184
196
  from a field that is no choice, or round a circle.
@@ -192,6 +204,33 @@ carries no options from a question: its own, or one of the app's lists — the s
192
204
  `optionsFrom` as a page's own choice (`{ list, dependsOn }`, its `dependsOn` naming
193
205
  the line's columns or `parent.` and a field).
194
206
 
207
+ ## One text in several languages
208
+
209
+ A line, a paragraph or formatted text may keep its text in several languages, each
210
+ typed by a person — Fieldia never translates it (`translate`), and `requiredIn` says
211
+ which a required answer is typed in (every one when left out):
212
+
213
+ ```json
214
+ "title": { "type": "char", "label": "Title", "translate": ["ar", "en"], "required": true, "size": 80 },
215
+ "description": { "type": "text", "label": "Description", "translate": ["ar", "en"], "required": true, "requiredIn": ["en"] }
216
+ ```
217
+
218
+ Its value is an object of each language's text by its tag — `{ "ar": "شقة…", "en":
219
+ "Nile-view flat" }` — a language not typed yet left out, none typed `null`; a plain
220
+ text loaded for it is read as its first language's. The form checks it in each
221
+ language: "Title is required in Arabic" while it is typed in some (`languagesNeeded`,
222
+ or `languagesNeededQuestion` for a label that asks), "Title is required" in none;
223
+ each language held to the field's `size` and `pattern`, named in the problem ("Title
224
+ (English) is 4 characters too long: shorten it to 80"). `textIn(value, reader,
225
+ languages)` reads it as a reader of a language does — theirs where typed, else the
226
+ field's first typed, said to be another's — `languageName(tag, locale)` names a
227
+ language, `checkTranslated` and `languagesAtFault` check it. They come in the
228
+ languages part (`formLanguagesPart`), which a form with such a field asks for as it
229
+ is made and a save waits for; `languagesOf(field)` and `hasLanguages(page)` say
230
+ whether a page has one. A table's line keeps one language. The memory source finds
231
+ such a text by a search in any of its languages, and reads one text — a link's
232
+ name, a list's order — in its `language` option's.
233
+
195
234
  ## A public form's bot check
196
235
 
197
236
  A page of responses anyone may send — a sign-up, a contact form — can check that
@@ -258,7 +297,10 @@ form.endingWords('Your booking is {id}.'); // "Your booking is B-1043."
258
297
  help, each choice's words, a step's title and words, a wizard's and a button's
259
298
  words — as in a text's and an alert's: `form.words('How was your visit to
260
299
  {branch}?')` is "How was your visit to Zamalek?", and the form's messages name
261
- the field so ("How was your visit to Zamalek? is required"). How a value reads
300
+ the field so ("Please answer “How was your visit to Zamalek?”": a label that is
301
+ a question — ending with a question mark, or an ellipsis the answer completes —
302
+ is quoted in the language's marks wherever a sentence names it, `isQuestion` and
303
+ `quotedLabel`, and its required message is `requiredQuestion`). How a value reads
262
304
  there is the viewer's (`valueWords` in `createForm`'s options: a choice by its
263
305
  label, money with its currency, a day in the page's order); without one, a
264
306
  choice's label, a link's name, Yes or No, anything else as held. After a bar,
@@ -285,6 +327,10 @@ record (`model` and `recordId` are the record's, `field` is where it sits:
285
327
  `consent.deed`), and the record's save waits for them. A file picked while a save
286
328
  is on its way stays a change, to save next. A draft never keeps a file's bytes
287
329
  where the source has `upload`; without it, a draft keeps them, as before.
330
+ The sending itself — each file made ready and sent, its link put in its field —
331
+ is a part of its own (`formUploadsPart`), which comes with @fieldia/widgets'
332
+ files part, or the first time a form sends a file: `form.upload` gives its ids
333
+ at once, each file waiting its turn until the part is in.
288
334
 
289
335
  ```ts
290
336
  import { uploadTo } from '@fieldia/core';
@@ -302,6 +348,16 @@ your words and offers no Retry; any other error offers Retry. Stop with an
302
348
  one. Without `upload`, files travel inside the record as base64, as before.
303
349
  See [files stored as they are picked](https://fieldia.dev/data/#upload).
304
350
 
351
+ A photo set (`"widget": "photos"`, @fieldia/widgets' README) keeps everything in
352
+ the field's value, so any source that keeps a file value keeps it: the photos in
353
+ the order a person put them (the first the cover), a photo's `caption`, and for a
354
+ photo cropped or turned the photo as it was (`original`, a file value of its
355
+ own) and what was done to it (`edit`: `{ turn: 90, crop: { x, y, width, height }
356
+ }`, fractions of the turned original). A photo cropped is stored at once —
357
+ `form.upload(field, [file], { replaces })`: its link takes the place of the
358
+ bytes the field holds for it, with whatever stands beside them by then (a
359
+ caption typed meanwhile).
360
+
305
361
  ## Lists that add up, and filter by time
306
362
 
307
363
  A list asks its source's optional `totals({ model, filter, totals, groupBy?,
@@ -318,6 +374,20 @@ the span a value falls in as the list counts it, and `dayIn` and `dayStarts`
318
374
  a day in a time zone; `createMemoryDataSource` does it all. See
319
375
  [lists that add up](https://fieldia.dev/lists/#totals).
320
376
 
377
+ ## A map's records counted where they crowd
378
+
379
+ A list's map (@fieldia/map) asks its source's optional `clusters({ model,
380
+ filter, field, longitude?, bbox, zoom, radius, fields, weight?, signal })` for
381
+ the view's bubbles — `{ clusters: [{ lat, lng, count, bbox?, weight? }],
382
+ points?: [{ id, values }], unplaced? }` — instead of loading at most 500 records
383
+ and gathering them itself: every record a search finds, however many, a record
384
+ standing alone with its values for its pin and its card. Answer `false` to let
385
+ the map load the search's records, as it does without the member. The memory
386
+ source has it where its `clusters` option says how it answers:
387
+ `createMemoryDataSource({ records, clusters: gridClusters({ models: ['home'] }) })`
388
+ gathers its records by a grid of squares fixed to the world, as a server does.
389
+ See [lists on a map](https://fieldia.dev/lists/#map).
390
+
321
391
  ## Time zones and booking slots
322
392
 
323
393
  A page may name the time zone its dates and times are in, by its IANA name —
@@ -527,7 +597,11 @@ send, as it starts again, and just before its answers go. `state.limits` tells
527
597
  whether it takes answers now (`open`, `soon`, `closed`, `full`, `sent`), when it
528
598
  opens and closes, the responses it takes still, and each choice's places
529
599
  (`seats[field][value]`: `{ seats, taken, left }`); `takingWords(page, limits,
530
- messages)` says why it takes none. A full option the person picks is refused,
600
+ messages)` says why it takes none ("This form closed on 20 Nov 2026."). Every
601
+ message that names a day writes it as the page's date boxes do — its
602
+ `look.dateOrder` (the form puts it on its messages, `messages.dateOrder`), its
603
+ language, a time on its clock: "can’t be after 20 Oct 2026", "Oct 20, 2026"
604
+ month first; `dayWords(day, messages, order?)` is that rule (a time after it: `whenWords`). A full option the person picks is refused,
531
605
  said under its field ("Afternoon workshop is full"); one that filled up while
532
606
  held, or a page closed since it was opened, stops the send. The app's own
533
607
  `setValues` is never refused: the check says it. Without `limits` in the
@@ -558,6 +632,60 @@ const form = createForm({ page, dataSource, resume: new URLSearchParams(location
558
632
  form.on('draft', ({ key, later, saved }) => later && console.log('Continue from', saved.link));
559
633
  ```
560
634
 
635
+ ## Approvals on a record
636
+
637
+ A record's page may say its records wait for approval:
638
+
639
+ ```json
640
+ { "approval": { "open": ["notes"] } }
641
+ ```
642
+
643
+ The data source tells where a record stands, `approvals({ model, recordId,
644
+ user })` answering `{ levels, history, mine, together, why }` — each level its
645
+ `id`, `name`, `approvers` (each `{ id, name, decision, at }` in the round asked
646
+ now), `needs` (`any`, the default, or `all`) and `state` (`waiting`, `later`,
647
+ `approved`, `rejected`, `skipped`); `history` oldest first (`{ decision:
648
+ 'requested' | 'approved' | 'rejected', level, by, at, reason }`); `mine` the
649
+ levels this person may decide now — and takes the decisions, `decide({ model,
650
+ recordId, level, decision, reason, user })`, a rejection always with why. Who is
651
+ asked, and in what order, is the app's, or its approval engine's: Fieldia never
652
+ works it out. The form asks as a saved record is shown, after each save and each
653
+ decision, keeping what it told in `state.approval` (`status`: `none`, `needed`,
654
+ `waiting`, `approved`, `rejected`); an answer for a record no longer shown is
655
+ laid on none. While it waits, every field is read-only but those `open` names
656
+ (`form.node(id).readonly`, `form.fieldReadonly`), `form.approvalLock(name)`
657
+ saying why; `"lock": false` locks none. `form.decide(level, decision, reason?)`
658
+ reads and saves what is typed first, then decides, then loads the record again;
659
+ it refuses a level not this person's and a rejection with no reason, in words.
660
+ The memory source's `approvals` option routes records as an engine would (in
661
+ turn or together, any or all, a rejection ending the round), keeping each
662
+ decision; `approvalHistory` is what it starts from.
663
+
664
+ ```ts
665
+ await form.decide('finance', 'rejected', 'Over the quarter’s budget');
666
+ form.getState().approval?.status; // 'rejected'
667
+ ```
668
+
669
+ ## AI help: values proposed, words written, a search read
670
+
671
+ Three optional members answer with the app's own model — Fieldia ships no model
672
+ and no keys. `suggest({ page, values, fields, from: { text?, files? } })` gives
673
+ values for a form (a page's `suggest`: `fields`, `label`, `from`, `fromField`),
674
+ a table's lines to add among them; `rewrite({ field, how, text, values })` a
675
+ text field's words (its node's `options.rewrite`: `"draft"`, `"polish"`, or
676
+ `{ "how", "label" }`); `searchToFilter({ text, fields })` a list's conditions
677
+ (its `searchToFilter`). The viewer shows each value on its field to accept or
678
+ reject first, and Undo after; `checkPage` and `validatePage` check the settings.
679
+ The memory source has each member only where its `assist` option answers it;
680
+ `assistStandIn({ drafts })` is a stand-in for demos and tests — no model, words
681
+ read by their patterns, every answer saying so ("Stand-in AI, no model: …"):
682
+
683
+ ```ts
684
+ import { assistStandIn, createMemoryDataSource } from '@fieldia/core';
685
+
686
+ const dataSource = createMemoryDataSource({ records, assist: assistStandIn({ drafts: { 'enquiry.reply': (values) => `Dear ${values.partner_name},` } }) });
687
+ ```
688
+
561
689
  ## What a page's records are called
562
690
 
563
691
  A page may say what its records are, so Fieldia's own sentences name them as
@@ -725,6 +853,21 @@ fields); `importFields(page, list)` says which fields a file's columns may fill.
725
853
  `createMemoryDataSource` gives `createMany`. See [many records made at
726
854
  once](https://fieldia.dev/data/#import).
727
855
 
856
+ ## A record found by a code a scanner read
857
+
858
+ A link scanned into with the camera (`options.scan` on a many2one or a table's
859
+ link column, drawn by @fieldia/widgets' scan part) finds the record a code names
860
+ through the data source's `search`, with no member of its own:
861
+ `form.search(field, code, 2, { field: 'barcode' })` asks for the records whose
862
+ `barcode` holds the code exactly — the field's own filter kept, the condition
863
+ added to it, the query empty — and `form.searchLine(…)` the same for a line's
864
+ link. Without a field named, the code is searched as a name, the exact name
865
+ first. The page check holds `options.scan` to a kind a code is written into —
866
+ a char, a text, a many2one, or a one2many counted by a column (`field`) and a
867
+ number (`count`) — and the fields a GS1 code fills (`fills`) to fields of the
868
+ page, or of the line, that take a code's part; `ScanOptionSchema`
869
+ gives its shape. See [scanning a code](https://fieldia.dev/fields/#scan).
870
+
728
871
  ## A saved form placed in another
729
872
 
730
873
  A block made once — an address, a contact person, a consent — is a page of its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fieldia/core",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "Headless form model for Fieldia: the page format, modifiers, validation and record state. No DOM.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://fieldia.dev",
@@ -10,7 +10,9 @@
10
10
  "0.3",
11
11
  "0.4",
12
12
  "0.5",
13
- "0.6"
13
+ "0.6",
14
+ "0.7",
15
+ "0.8"
14
16
  ]
15
17
  },
16
18
  "id": {
@@ -388,6 +390,12 @@
388
390
  },
389
391
  "continueLater": {
390
392
  "type": "boolean"
393
+ },
394
+ "approval": {
395
+ "$ref": "#/$defs/PageApproval"
396
+ },
397
+ "suggest": {
398
+ "$ref": "#/$defs/PageSuggest"
391
399
  }
392
400
  },
393
401
  "required": [
@@ -451,13 +459,36 @@
451
459
  "patternHint": {
452
460
  "type": "string",
453
461
  "minLength": 1
462
+ },
463
+ "translate": {
464
+ "minItems": 2,
465
+ "type": "array",
466
+ "items": {
467
+ "$ref": "#/$defs/LanguageTag"
468
+ },
469
+ "uniqueItems": true
470
+ },
471
+ "requiredIn": {
472
+ "minItems": 1,
473
+ "type": "array",
474
+ "items": {
475
+ "$ref": "#/$defs/LanguageTag"
476
+ },
477
+ "uniqueItems": true
454
478
  }
455
479
  },
456
480
  "required": [
457
481
  "type",
458
482
  "label"
459
483
  ],
460
- "additionalProperties": false
484
+ "additionalProperties": false,
485
+ "dependentSchemas": {
486
+ "requiredIn": {
487
+ "required": [
488
+ "translate"
489
+ ]
490
+ }
491
+ }
461
492
  },
462
493
  {
463
494
  "type": "object",
@@ -500,13 +531,36 @@
500
531
  "type": "integer",
501
532
  "exclusiveMinimum": 0,
502
533
  "maximum": 9007199254740991
534
+ },
535
+ "translate": {
536
+ "minItems": 2,
537
+ "type": "array",
538
+ "items": {
539
+ "$ref": "#/$defs/LanguageTag"
540
+ },
541
+ "uniqueItems": true
542
+ },
543
+ "requiredIn": {
544
+ "minItems": 1,
545
+ "type": "array",
546
+ "items": {
547
+ "$ref": "#/$defs/LanguageTag"
548
+ },
549
+ "uniqueItems": true
503
550
  }
504
551
  },
505
552
  "required": [
506
553
  "type",
507
554
  "label"
508
555
  ],
509
- "additionalProperties": false
556
+ "additionalProperties": false,
557
+ "dependentSchemas": {
558
+ "requiredIn": {
559
+ "required": [
560
+ "translate"
561
+ ]
562
+ }
563
+ }
510
564
  },
511
565
  {
512
566
  "type": "object",
@@ -544,13 +598,36 @@
544
598
  "items": {
545
599
  "$ref": "#/$defs/SetWhen"
546
600
  }
601
+ },
602
+ "translate": {
603
+ "minItems": 2,
604
+ "type": "array",
605
+ "items": {
606
+ "$ref": "#/$defs/LanguageTag"
607
+ },
608
+ "uniqueItems": true
609
+ },
610
+ "requiredIn": {
611
+ "minItems": 1,
612
+ "type": "array",
613
+ "items": {
614
+ "$ref": "#/$defs/LanguageTag"
615
+ },
616
+ "uniqueItems": true
547
617
  }
548
618
  },
549
619
  "required": [
550
620
  "type",
551
621
  "label"
552
622
  ],
553
- "additionalProperties": false
623
+ "additionalProperties": false,
624
+ "dependentSchemas": {
625
+ "requiredIn": {
626
+ "required": [
627
+ "translate"
628
+ ]
629
+ }
630
+ }
554
631
  },
555
632
  {
556
633
  "type": "object",
@@ -1683,6 +1760,17 @@
1683
1760
  }
1684
1761
  ]
1685
1762
  },
1763
+ "LanguageTag": {
1764
+ "type": "string",
1765
+ "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$",
1766
+ "description": "A language by its BCP 47 tag.",
1767
+ "examples": [
1768
+ "ar",
1769
+ "en",
1770
+ "fr",
1771
+ "pt-BR"
1772
+ ]
1773
+ },
1686
1774
  "MoneyLook": {
1687
1775
  "type": "object",
1688
1776
  "properties": {
@@ -2013,13 +2101,36 @@
2013
2101
  "patternHint": {
2014
2102
  "type": "string",
2015
2103
  "minLength": 1
2104
+ },
2105
+ "translate": {
2106
+ "minItems": 2,
2107
+ "type": "array",
2108
+ "items": {
2109
+ "$ref": "#/$defs/LanguageTag"
2110
+ },
2111
+ "uniqueItems": true
2112
+ },
2113
+ "requiredIn": {
2114
+ "minItems": 1,
2115
+ "type": "array",
2116
+ "items": {
2117
+ "$ref": "#/$defs/LanguageTag"
2118
+ },
2119
+ "uniqueItems": true
2016
2120
  }
2017
2121
  },
2018
2122
  "required": [
2019
2123
  "type",
2020
2124
  "label"
2021
2125
  ],
2022
- "additionalProperties": false
2126
+ "additionalProperties": false,
2127
+ "dependentSchemas": {
2128
+ "requiredIn": {
2129
+ "required": [
2130
+ "translate"
2131
+ ]
2132
+ }
2133
+ }
2023
2134
  },
2024
2135
  {
2025
2136
  "type": "object",
@@ -2062,13 +2173,36 @@
2062
2173
  "type": "integer",
2063
2174
  "exclusiveMinimum": 0,
2064
2175
  "maximum": 9007199254740991
2176
+ },
2177
+ "translate": {
2178
+ "minItems": 2,
2179
+ "type": "array",
2180
+ "items": {
2181
+ "$ref": "#/$defs/LanguageTag"
2182
+ },
2183
+ "uniqueItems": true
2184
+ },
2185
+ "requiredIn": {
2186
+ "minItems": 1,
2187
+ "type": "array",
2188
+ "items": {
2189
+ "$ref": "#/$defs/LanguageTag"
2190
+ },
2191
+ "uniqueItems": true
2065
2192
  }
2066
2193
  },
2067
2194
  "required": [
2068
2195
  "type",
2069
2196
  "label"
2070
2197
  ],
2071
- "additionalProperties": false
2198
+ "additionalProperties": false,
2199
+ "dependentSchemas": {
2200
+ "requiredIn": {
2201
+ "required": [
2202
+ "translate"
2203
+ ]
2204
+ }
2205
+ }
2072
2206
  },
2073
2207
  {
2074
2208
  "type": "object",
@@ -2658,6 +2792,12 @@
2658
2792
  "patternHint": {
2659
2793
  "type": "string",
2660
2794
  "minLength": 1
2795
+ },
2796
+ "translate": {
2797
+ "not": {}
2798
+ },
2799
+ "requiredIn": {
2800
+ "not": {}
2661
2801
  }
2662
2802
  },
2663
2803
  "required": [
@@ -2707,6 +2847,12 @@
2707
2847
  "type": "integer",
2708
2848
  "exclusiveMinimum": 0,
2709
2849
  "maximum": 9007199254740991
2850
+ },
2851
+ "translate": {
2852
+ "not": {}
2853
+ },
2854
+ "requiredIn": {
2855
+ "not": {}
2710
2856
  }
2711
2857
  },
2712
2858
  "required": [
@@ -2751,6 +2897,12 @@
2751
2897
  "items": {
2752
2898
  "$ref": "#/$defs/SetWhen"
2753
2899
  }
2900
+ },
2901
+ "translate": {
2902
+ "not": {}
2903
+ },
2904
+ "requiredIn": {
2905
+ "not": {}
2754
2906
  }
2755
2907
  },
2756
2908
  "required": [
@@ -3858,6 +4010,12 @@
3858
4010
  "patternHint": {
3859
4011
  "type": "string",
3860
4012
  "minLength": 1
4013
+ },
4014
+ "translate": {
4015
+ "not": {}
4016
+ },
4017
+ "requiredIn": {
4018
+ "not": {}
3861
4019
  }
3862
4020
  },
3863
4021
  "required": [
@@ -3907,6 +4065,12 @@
3907
4065
  "type": "integer",
3908
4066
  "exclusiveMinimum": 0,
3909
4067
  "maximum": 9007199254740991
4068
+ },
4069
+ "translate": {
4070
+ "not": {}
4071
+ },
4072
+ "requiredIn": {
4073
+ "not": {}
3910
4074
  }
3911
4075
  },
3912
4076
  "required": [
@@ -3951,6 +4115,12 @@
3951
4115
  "items": {
3952
4116
  "$ref": "#/$defs/SetWhen"
3953
4117
  }
4118
+ },
4119
+ "translate": {
4120
+ "not": {}
4121
+ },
4122
+ "requiredIn": {
4123
+ "not": {}
3954
4124
  }
3955
4125
  },
3956
4126
  "required": [
@@ -6368,7 +6538,8 @@
6368
6538
  "type": "string",
6369
6539
  "enum": [
6370
6540
  "narrow",
6371
- "always"
6541
+ "always",
6542
+ "never"
6372
6543
  ]
6373
6544
  },
6374
6545
  "fit": {
@@ -9539,6 +9710,9 @@
9539
9710
  "filterSheet": {
9540
9711
  "type": "boolean"
9541
9712
  },
9713
+ "searchToFilter": {
9714
+ "type": "boolean"
9715
+ },
9542
9716
  "parentField": {
9543
9717
  "type": "string",
9544
9718
  "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
@@ -9721,6 +9895,16 @@
9721
9895
  ],
9722
9896
  "additionalProperties": false
9723
9897
  }
9898
+ },
9899
+ "editable": {
9900
+ "anyOf": [
9901
+ {
9902
+ "type": "boolean"
9903
+ },
9904
+ {
9905
+ "$ref": "#/$defs/ListEditable"
9906
+ }
9907
+ ]
9724
9908
  }
9725
9909
  },
9726
9910
  "required": [
@@ -10023,6 +10207,26 @@
10023
10207
  },
10024
10208
  "additionalProperties": false
10025
10209
  },
10210
+ "ListEditable": {
10211
+ "type": "object",
10212
+ "properties": {
10213
+ "fields": {
10214
+ "minItems": 1,
10215
+ "type": "array",
10216
+ "items": {
10217
+ "type": "string",
10218
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
10219
+ }
10220
+ },
10221
+ "add": {
10222
+ "type": "boolean"
10223
+ },
10224
+ "open": {
10225
+ "type": "boolean"
10226
+ }
10227
+ },
10228
+ "additionalProperties": false
10229
+ },
10026
10230
  "PageEvents": {
10027
10231
  "type": "object",
10028
10232
  "properties": {
@@ -10240,6 +10444,61 @@
10240
10444
  }
10241
10445
  },
10242
10446
  "additionalProperties": false
10447
+ },
10448
+ "PageApproval": {
10449
+ "type": "object",
10450
+ "properties": {
10451
+ "open": {
10452
+ "type": "array",
10453
+ "items": {
10454
+ "type": "string",
10455
+ "minLength": 1
10456
+ }
10457
+ },
10458
+ "lock": {
10459
+ "type": "boolean"
10460
+ }
10461
+ },
10462
+ "additionalProperties": false
10463
+ },
10464
+ "PageSuggest": {
10465
+ "type": "object",
10466
+ "properties": {
10467
+ "fields": {
10468
+ "minItems": 1,
10469
+ "type": "array",
10470
+ "items": {
10471
+ "type": "string",
10472
+ "minLength": 1
10473
+ }
10474
+ },
10475
+ "from": {
10476
+ "minItems": 1,
10477
+ "type": "array",
10478
+ "items": {
10479
+ "type": "string",
10480
+ "enum": [
10481
+ "text",
10482
+ "files"
10483
+ ]
10484
+ }
10485
+ },
10486
+ "label": {
10487
+ "type": "string",
10488
+ "minLength": 1,
10489
+ "maxLength": 60
10490
+ },
10491
+ "placeholder": {
10492
+ "type": "string",
10493
+ "minLength": 1,
10494
+ "maxLength": 200
10495
+ },
10496
+ "fromField": {
10497
+ "type": "string",
10498
+ "minLength": 1
10499
+ }
10500
+ },
10501
+ "additionalProperties": false
10243
10502
  }
10244
10503
  }
10245
10504
  }