@mistriwork/kit 1.0.0-rc.43 → 1.0.0-rc.44

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.
@@ -54,7 +54,7 @@ import { defaultCurrency } from '../locale.js';
54
54
  import { wordFor } from './valueModel.js';
55
55
  import { rowCurrency } from '@mistriwork/engine/shared/money.js';
56
56
  import { MinorMoneyInput, minorProblem } from './MinorMoneyInput.js';
57
- import { clockDefault, fieldInput, inferredNarrowing, flagStart, formColumns, formFrame, formGroups, hasFormChanges, insertValues, isFormFieldVisible, missingFields, narrowingCondition, presetValue, SEGMENTED_WORDS, } from './newRecordModel.js';
57
+ import { clockDefault, fieldInput, inferredNarrowing, flagStart, formColumns, formFrame, formGroups, hasFormChanges, insertValues, isFormFieldVisible, missingFields, narrowingCondition, presetValue, SEGMENTED_WORDS, withDisplayChoices, } from './newRecordModel.js';
58
58
  import { derivedValue, formWords, resolvedForm, useMeDefaults } from './formDefaults.js';
59
59
  import { useRecordInsert } from './useRecordInsert.js';
60
60
  import { say } from '../copy/forms/components/NewRecord.js';
@@ -105,8 +105,10 @@ function NewRecordFormBody({ table, form, app, label: columnLabel, target, inser
105
105
  useMessageLanguage();
106
106
  const assigned = autoKey(table);
107
107
  const written = app ? newFormWritten(table) : undefined;
108
- const columns = formColumns(table, form, app, written);
109
- const groups = formGroups(table, form, app, written);
108
+ /* A display-only vocabulary is chosen from in an App's form (withDisplayChoices). */
109
+ const choosing = (column) => app ? withDisplayChoices(column, display?.(column), [form?.defaults?.[column.name], literalDefault(column.default)]) : column;
110
+ const columns = formColumns(table, form, app, written).map(choosing);
111
+ const groups = formGroups(table, form, app, written).map((group) => ({ ...group, columns: group.columns.map(choosing) }));
110
112
  /* A switch is on or off, never "leave it": a flag it draws starts where the
111
113
  form, else the database, says — off for one that must be answered — and
112
114
  that start is sent like any default. */
@@ -157,6 +157,8 @@ export interface DashboardDef {
157
157
  actions?: string[];
158
158
  params: string[];
159
159
  loader?: string;
160
+ /** More loaders the page runs by name (`useLoader`), beside `loader`. */
161
+ loaders?: string[];
160
162
  public?: true;
161
163
  /** A record's tab (pages/<list view>/[id]/<tab>.page.tsx): drawn in that record's tab strip, never as a room. */
162
164
  record?: ServedRecordTab;
@@ -24,6 +24,18 @@ export declare function isFormFieldVisible(form: FormCuration | undefined, colum
24
24
  * form names one itself (in `show`, a step or a group), since a declared field is the author's to ask.
25
25
  */
26
26
  export declare function formColumns(table: TableMeta, form: FormCuration | undefined, app: boolean, written?: ReadonlySet<string>): ColumnMeta[];
27
+ /**
28
+ * A text column the database does not constrain (no CHECK, no enum) whose `display.values` names its words is chosen
29
+ * from them in an App's New form, as a column the database does constrain is: the words are the author's vocabulary
30
+ * for it, and a box to type one in would let a reader spell "To pick" where the stored word is `to_pick`. The words
31
+ * are display-only, so the database still takes any other; a value the form starts with that is none of them (an
32
+ * off-list default) stays in the list so it is not lost. A column with a format of its own, a reference, a rule of
33
+ * one word or one of more than thirty is left to be typed.
34
+ */
35
+ export declare function withDisplayChoices(column: ColumnMeta, rule: {
36
+ values?: Record<string, string>;
37
+ format?: string;
38
+ } | null | undefined, starts: readonly unknown[]): ColumnMeta;
27
39
  /** Grouped fields retain authored order; ungrouped fields follow in form order. */
28
40
  export declare function formGroups(table: TableMeta, form: FormCuration | undefined, app: boolean, written?: ReadonlySet<string>): FormGroup[];
29
41
  export declare function presetValue(column: ColumnMeta, defaults: Record<string, unknown>): string;
@@ -59,6 +59,27 @@ export function formColumns(table, form, app, written) {
59
59
  const editable = new Set(editableColumns(table, app));
60
60
  return columns.filter((c) => editable.has(c));
61
61
  }
62
+ /** The most words a display-only vocabulary may hold and still be a listbox: past it a person types. */
63
+ const DISPLAY_CHOICES = 30;
64
+ /**
65
+ * A text column the database does not constrain (no CHECK, no enum) whose `display.values` names its words is chosen
66
+ * from them in an App's New form, as a column the database does constrain is: the words are the author's vocabulary
67
+ * for it, and a box to type one in would let a reader spell "To pick" where the stored word is `to_pick`. The words
68
+ * are display-only, so the database still takes any other; a value the form starts with that is none of them (an
69
+ * off-list default) stays in the list so it is not lost. A column with a format of its own, a reference, a rule of
70
+ * one word or one of more than thirty is left to be typed.
71
+ */
72
+ export function withDisplayChoices(column, rule, starts) {
73
+ if (column.allowed?.length || column.references || columnKind(column.type) !== 'text' || isFlagColumn(column))
74
+ return column;
75
+ if (!rule?.values || rule.format !== undefined)
76
+ return column;
77
+ const words = Object.keys(rule.values);
78
+ if (words.length < 2 || words.length > DISPLAY_CHOICES)
79
+ return column;
80
+ const off = starts.filter((start) => typeof start === 'string' && start !== '' && !words.includes(start));
81
+ return { ...column, allowed: [...words, ...new Set(off)] };
82
+ }
62
83
  /** Grouped fields retain authored order; ungrouped fields follow in form order. */
63
84
  export function formGroups(table, form, app, written) {
64
85
  const columns = formColumns(table, form, app, written);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/kit",
3
- "version": "1.0.0-rc.43",
3
+ "version": "1.0.0-rc.44",
4
4
  "description": "The shared React client both shells are drawn with: the walk and the address, Grid, Value, the record page, lists, filters and charts.",
5
5
  "homepage": "https://mistriwork.dev",
6
6
  "bugs": {
@@ -83,8 +83,8 @@
83
83
  "./package.json": "./package.json"
84
84
  },
85
85
  "dependencies": {
86
- "@mistriwork/engine": "1.0.0-rc.43",
87
- "@mistriwork/ui": "1.0.0-rc.43",
86
+ "@mistriwork/engine": "1.0.0-rc.44",
87
+ "@mistriwork/ui": "1.0.0-rc.44",
88
88
  "intl-messageformat": "12.1.2",
89
89
  "qrcode-generator": "^2.0.4"
90
90
  },