@modelform/react-native 0.11.0 → 0.13.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.
@@ -8,6 +8,7 @@ import {
8
8
  ConfigLoader,
9
9
  DASHBOARD_DS,
10
10
  DEFAULT_GAZETTEER,
11
+ DICTATION_TYPES,
11
12
  DOCUMENT_GUIDE,
12
13
  EDITABLE_VARIABLE_TYPES,
13
14
  EXAMPLE_TEMPLATE,
@@ -62,6 +63,7 @@ import {
62
63
  dashboardSourceIds,
63
64
  defaultFetchJson,
64
65
  describeRange,
66
+ dictationHints,
65
67
  diffJson,
66
68
  documentChanges,
67
69
  documentIdFor,
@@ -127,6 +129,7 @@ import {
127
129
  mappingProblem,
128
130
  mappingRow,
129
131
  mappingRows,
132
+ matchChoices,
130
133
  metricChanges,
131
134
  movePanel,
132
135
  newDocument,
@@ -154,6 +157,9 @@ import {
154
157
  parseLocalDateTime,
155
158
  parseRange,
156
159
  parseSnippet,
160
+ parseSpokenDuration,
161
+ parseSpokenNumber,
162
+ parseSpokenYesNo,
157
163
  parseTemplate,
158
164
  parseTime,
159
165
  pasteSnippet,
@@ -178,6 +184,7 @@ import {
178
184
  renameVariableInPanels,
179
185
  repack,
180
186
  repeatOptions,
187
+ requiredManifestVersion,
181
188
  resizePanel,
182
189
  resolveColor,
183
190
  resolveFieldConfig,
@@ -201,9 +208,11 @@ import {
201
208
  settleLayout,
202
209
  snapToGrid,
203
210
  splitPath,
211
+ spokenValue,
204
212
  startOf,
205
213
  stringifyCompact,
206
214
  tabIdFor,
215
+ takesDictation,
207
216
  templateNeeds,
208
217
  templatePrompt,
209
218
  textSuggestions,
@@ -233,7 +242,7 @@ import {
233
242
  variableWithType,
234
243
  visibleVariables,
235
244
  zoomRange
236
- } from "../chunk-AJEPW5KG.mjs";
245
+ } from "../chunk-OFXIKI2L.mjs";
237
246
  export {
238
247
  ALL,
239
248
  AUTHORING_GUIDE,
@@ -244,6 +253,7 @@ export {
244
253
  ConfigLoader,
245
254
  DASHBOARD_DS,
246
255
  DEFAULT_GAZETTEER,
256
+ DICTATION_TYPES,
247
257
  DOCUMENT_GUIDE,
248
258
  EDITABLE_VARIABLE_TYPES,
249
259
  EXAMPLE_TEMPLATE,
@@ -298,6 +308,7 @@ export {
298
308
  dashboardSourceIds,
299
309
  defaultFetchJson,
300
310
  describeRange,
311
+ dictationHints,
301
312
  diffJson,
302
313
  documentChanges,
303
314
  documentIdFor,
@@ -363,6 +374,7 @@ export {
363
374
  mappingProblem,
364
375
  mappingRow,
365
376
  mappingRows,
377
+ matchChoices,
366
378
  metricChanges,
367
379
  movePanel,
368
380
  newDocument,
@@ -390,6 +402,9 @@ export {
390
402
  parseLocalDateTime,
391
403
  parseRange,
392
404
  parseSnippet,
405
+ parseSpokenDuration,
406
+ parseSpokenNumber,
407
+ parseSpokenYesNo,
393
408
  parseTemplate,
394
409
  parseTime,
395
410
  pasteSnippet,
@@ -414,6 +429,7 @@ export {
414
429
  renameVariableInPanels,
415
430
  repack,
416
431
  repeatOptions,
432
+ requiredManifestVersion,
417
433
  resizePanel,
418
434
  resolveColor,
419
435
  resolveFieldConfig,
@@ -437,9 +453,11 @@ export {
437
453
  settleLayout,
438
454
  snapToGrid,
439
455
  splitPath,
456
+ spokenValue,
440
457
  startOf,
441
458
  stringifyCompact,
442
459
  tabIdFor,
460
+ takesDictation,
443
461
  templateNeeds,
444
462
  templatePrompt,
445
463
  textSuggestions,
@@ -1,8 +1,23 @@
1
1
  import type { Dashboard } from './schema';
2
+ /**
3
+ * The newest config format this build can show. A manifest's `version` is the oldest format that
4
+ * can show it, so an app older than the config says to update rather than show it wrong.
5
+ *
6
+ * When a change means older apps would show a config wrong (a new panel or screen type, an
7
+ * option whose absence changes what's recorded), bump this and add a FORMAT_CHANGES entry that
8
+ * spots configs using it. Configs that don't use it keep working in older apps.
9
+ */
2
10
  export declare const MANIFEST_VERSION = 1;
11
+ /** The version a config should declare: the newest format change it uses, or 1. Editors set it when saving. */
12
+ export declare function requiredManifestVersion(bundle: ConfigBundle): number;
3
13
  /** The root of an app config: navigation, plus the documents it shows. Annotations here feed schema/app.schema.json. */
4
14
  export interface AppManifest {
5
- /** Format version. Always 1 for now. */
15
+ /**
16
+ * The oldest config format that can show this config: 1 unless it uses something newer (see
17
+ * MANIFEST_VERSION). An app that reads only older formats asks to be updated instead.
18
+ * @minimum 1
19
+ * @asType integer
20
+ */
6
21
  version: number;
7
22
  /**
8
23
  * The app's name.
@@ -66,6 +81,8 @@ export interface ConfigBundle {
66
81
  }
67
82
  export interface ConfigIssue {
68
83
  severity: 'error' | 'warning';
84
+ /** Set on the error for a config newer than this build can show, so an app can ask to be updated. */
85
+ code?: 'newer-version';
69
86
  /** Where in the config, e.g. `app.json: tabs[1].screen.dashboard` or `forms/daily.json: panels[3]`. */
70
87
  path: string;
71
88
  message: string;
@@ -196,6 +213,8 @@ export interface ConfigState {
196
213
  error?: string;
197
214
  /** True when the last fetch failed because the config couldn't be fetched at all, not because it has errors. */
198
215
  unreachable?: boolean;
216
+ /** True when the last fetch got a config newer than this app can show: the app should ask to be updated. */
217
+ needsUpdate?: boolean;
199
218
  /** From the last fetch, good or bad. */
200
219
  issues: ConfigIssue[];
201
220
  }
@@ -0,0 +1,36 @@
1
+ import { type InputChoice, type InputPanel, type InputValue } from './inputs';
2
+ /**
3
+ * The first number in what was said: "72.5", "seventy two point five", "minus three",
4
+ * "one twenty-five" (125), "two and a half", "a hundred and ten". Words around it
5
+ * ("about 80 kilos") are ignored. Null when there's no number.
6
+ */
7
+ export declare function parseSpokenNumber(text: string): number | null;
8
+ /** A duration in seconds: "1:32.45", "one minute thirty two point four five", "92 seconds", "an hour and ten minutes". */
9
+ export declare function parseSpokenDuration(text: string): number | null;
10
+ /**
11
+ * The choices mentioned in what was said, in the order they were said. Labels are matched
12
+ * as whole words, ignoring case, accents and plurals; the longest label wins where two
13
+ * overlap ("Very good" over "Good"). A spoken number also matches a choice whose label or
14
+ * value is that number.
15
+ */
16
+ export declare function matchChoices(text: string, choices: InputChoice[]): (string | number)[];
17
+ /** Yes or no from what was said, or null when it's neither. "No" wins when both are there ("not done"). */
18
+ export declare function parseSpokenYesNo(text: string): boolean | null;
19
+ /** What dictation into an input made of what was said: the new value, or why there isn't one. */
20
+ export type SpokenResult = {
21
+ value: InputValue;
22
+ } | {
23
+ problem: string;
24
+ };
25
+ /**
26
+ * The value an input takes from what was said. Text inputs take the words (added after
27
+ * what's there, for multi-line text); numbers, durations, choices and yes/no are read out
28
+ * of them. The value isn't checked against min, max or required: the form does that.
29
+ */
30
+ export declare function spokenValue(panel: InputPanel, said: string, current?: InputValue, choices?: InputChoice[]): SpokenResult;
31
+ /** Input types that show a dictation button. Sliders, ratings and toggles are a single tap already; counters record on tap. */
32
+ export declare const DICTATION_TYPES: InputPanel['type'][];
33
+ /** Whether an input offers dictation. */
34
+ export declare const takesDictation: (panel: InputPanel) => boolean;
35
+ /** Words a recognizer should expect for an input (its choice labels and unit), for recognizers that take hints. */
36
+ export declare function dictationHints(panel: InputPanel, choices?: InputChoice[]): string[];
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { DashboardView, PanelCard, type DashboardViewProps } from './ui/Dashboar
5
5
  export { RenderBoundary } from './ui/RenderBoundary';
6
6
  export { DashboardToolbar, Chip } from './ui/Toolbar';
7
7
  export { InputForm, type InputFormProps } from './ui/inputs/InputForm';
8
+ export { webSpeechRecognizer, type DictationOptions, type DictationSession, type SpeechRecognizer } from './ui/speech';
8
9
  export { Calendar } from './ui/TimeRangeSheet';
9
10
  export { groupKey, InputFormContext, useInputForm, type FormGroup, type InputFormState } from './ui/inputs/formContext';
10
11
  export { registerPanel } from './ui/panels/registry';