@fieldia/core 0.26.1 → 0.28.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 +326 -3
- package/package.json +1 -1
- package/schema/page.schema.json +230 -24
- package/src/index.d.mts +10 -2
- package/src/index.d.ts +10 -2
- package/src/index.js +26 -1
- package/src/index.js.map +1 -1
- package/src/index.mjs +11 -2
- package/src/index.mjs.map +1 -1
- package/src/lib/expression/app-functions.d.mts +47 -0
- package/src/lib/expression/app-functions.d.ts +47 -0
- package/src/lib/expression/app-functions.js +64 -0
- package/src/lib/expression/app-functions.js.map +1 -0
- package/src/lib/expression/app-functions.mjs +58 -0
- package/src/lib/expression/app-functions.mjs.map +1 -0
- package/src/lib/expression/dates.d.mts +21 -0
- package/src/lib/expression/dates.d.ts +21 -0
- package/src/lib/expression/dates.js +73 -0
- package/src/lib/expression/dates.js.map +1 -0
- package/src/lib/expression/dates.mjs +67 -0
- package/src/lib/expression/dates.mjs.map +1 -0
- package/src/lib/expression/evaluator.js +12 -6
- package/src/lib/expression/evaluator.js.map +1 -1
- package/src/lib/expression/evaluator.mjs +12 -6
- package/src/lib/expression/evaluator.mjs.map +1 -1
- package/src/lib/expression/expression.d.mts +7 -3
- package/src/lib/expression/expression.d.ts +7 -3
- package/src/lib/expression/expression.js +8 -2
- package/src/lib/expression/expression.js.map +1 -1
- package/src/lib/expression/expression.mjs +7 -2
- package/src/lib/expression/expression.mjs.map +1 -1
- package/src/lib/expression/functions-part.d.mts +7 -0
- package/src/lib/expression/functions-part.d.ts +7 -0
- package/src/lib/expression/functions-part.js +13 -0
- package/src/lib/expression/functions-part.js.map +1 -0
- package/src/lib/expression/functions-part.mjs +8 -0
- package/src/lib/expression/functions-part.mjs.map +1 -0
- package/src/lib/expression/functions.d.mts +60 -3
- package/src/lib/expression/functions.d.ts +60 -3
- package/src/lib/expression/functions.js +109 -15
- package/src/lib/expression/functions.js.map +1 -1
- package/src/lib/expression/functions.mjs +103 -16
- package/src/lib/expression/functions.mjs.map +1 -1
- package/src/lib/expression/kinds.d.mts +31 -0
- package/src/lib/expression/kinds.d.ts +31 -0
- package/src/lib/expression/kinds.js +159 -0
- package/src/lib/expression/kinds.js.map +1 -0
- package/src/lib/expression/kinds.mjs +151 -0
- package/src/lib/expression/kinds.mjs.map +1 -0
- package/src/lib/expression/modifier.d.mts +4 -3
- package/src/lib/expression/modifier.d.ts +4 -3
- package/src/lib/expression/modifier.js +4 -3
- package/src/lib/expression/modifier.js.map +1 -1
- package/src/lib/expression/modifier.mjs +4 -3
- package/src/lib/expression/modifier.mjs.map +1 -1
- package/src/lib/expression/more-functions.d.mts +8 -0
- package/src/lib/expression/more-functions.d.ts +8 -0
- package/src/lib/expression/more-functions.js +235 -0
- package/src/lib/expression/more-functions.js.map +1 -0
- package/src/lib/expression/more-functions.mjs +230 -0
- package/src/lib/expression/more-functions.mjs.map +1 -0
- package/src/lib/expression/parser.d.mts +4 -1
- package/src/lib/expression/parser.d.ts +4 -1
- package/src/lib/expression/parser.js +6 -3
- package/src/lib/expression/parser.js.map +1 -1
- package/src/lib/expression/parser.mjs +6 -3
- package/src/lib/expression/parser.mjs.map +1 -1
- package/src/lib/expression/reads.d.mts +2 -2
- package/src/lib/expression/reads.d.ts +2 -2
- package/src/lib/expression/reads.js +6 -4
- package/src/lib/expression/reads.js.map +1 -1
- package/src/lib/expression/reads.mjs +6 -4
- package/src/lib/expression/reads.mjs.map +1 -1
- package/src/lib/format/actions.d.mts +16 -16
- package/src/lib/format/actions.d.ts +16 -16
- package/src/lib/format/check-page.d.mts +7 -2
- package/src/lib/format/check-page.d.ts +7 -2
- package/src/lib/format/check-page.js +10 -4
- package/src/lib/format/check-page.js.map +1 -1
- package/src/lib/format/check-page.mjs +10 -4
- package/src/lib/format/check-page.mjs.map +1 -1
- package/src/lib/format/choice-options.d.mts +34 -0
- package/src/lib/format/choice-options.d.ts +34 -0
- package/src/lib/format/choice-options.js +60 -0
- package/src/lib/format/choice-options.js.map +1 -0
- package/src/lib/format/choice-options.mjs +51 -0
- package/src/lib/format/choice-options.mjs.map +1 -0
- package/src/lib/format/endings-checks.d.mts +8 -0
- package/src/lib/format/endings-checks.d.ts +8 -0
- package/src/lib/format/endings-checks.js +23 -0
- package/src/lib/format/endings-checks.js.map +1 -0
- package/src/lib/format/endings-checks.mjs +20 -0
- package/src/lib/format/endings-checks.mjs.map +1 -0
- package/src/lib/format/endings.d.mts +40 -0
- package/src/lib/format/endings.d.ts +40 -0
- package/src/lib/format/endings.js +15 -0
- package/src/lib/format/endings.js.map +1 -0
- package/src/lib/format/endings.mjs +12 -0
- package/src/lib/format/endings.mjs.map +1 -0
- package/src/lib/format/field.d.mts +151 -16
- package/src/lib/format/field.d.ts +151 -16
- package/src/lib/format/field.js +64 -11
- package/src/lib/format/field.js.map +1 -1
- package/src/lib/format/field.mjs +63 -10
- package/src/lib/format/field.mjs.map +1 -1
- package/src/lib/format/head-checks.d.mts +2 -0
- package/src/lib/format/head-checks.d.ts +2 -0
- package/src/lib/format/head-checks.js +2 -59
- package/src/lib/format/head-checks.js.map +1 -1
- package/src/lib/format/head-checks.mjs +1 -58
- package/src/lib/format/head-checks.mjs.map +1 -1
- package/src/lib/format/later-checks.d.mts +17 -0
- package/src/lib/format/later-checks.d.ts +17 -0
- package/src/lib/format/later-checks.js +20 -0
- package/src/lib/format/later-checks.js.map +1 -0
- package/src/lib/format/later-checks.mjs +17 -0
- package/src/lib/format/later-checks.mjs.map +1 -0
- package/src/lib/format/layout.d.mts +264 -190
- package/src/lib/format/layout.d.ts +264 -190
- package/src/lib/format/layout.js +34 -29
- package/src/lib/format/layout.js.map +1 -1
- package/src/lib/format/layout.mjs +14 -4
- package/src/lib/format/layout.mjs.map +1 -1
- package/src/lib/format/layout.types.d.mts +2 -1
- package/src/lib/format/layout.types.d.ts +2 -1
- package/src/lib/format/limits-checks.d.mts +14 -0
- package/src/lib/format/limits-checks.d.ts +14 -0
- package/src/lib/format/limits-checks.js +36 -0
- package/src/lib/format/limits-checks.js.map +1 -0
- package/src/lib/format/limits-checks.mjs +33 -0
- package/src/lib/format/limits-checks.mjs.map +1 -0
- package/src/lib/format/limits.d.mts +24 -0
- package/src/lib/format/limits.d.ts +24 -0
- package/src/lib/format/limits.js +35 -0
- package/src/lib/format/limits.js.map +1 -0
- package/src/lib/format/limits.mjs +32 -0
- package/src/lib/format/limits.mjs.map +1 -0
- package/src/lib/format/list-checks.d.mts +44 -0
- package/src/lib/format/list-checks.d.ts +44 -0
- package/src/lib/format/list-checks.js +340 -0
- package/src/lib/format/list-checks.js.map +1 -0
- package/src/lib/format/list-checks.mjs +336 -0
- package/src/lib/format/list-checks.mjs.map +1 -0
- package/src/lib/format/map-checks.d.mts +33 -0
- package/src/lib/format/map-checks.d.ts +33 -0
- package/src/lib/format/map-checks.js +180 -0
- package/src/lib/format/map-checks.js.map +1 -0
- package/src/lib/format/map-checks.mjs +175 -0
- package/src/lib/format/map-checks.mjs.map +1 -0
- package/src/lib/format/mapchecks-part.d.mts +5 -0
- package/src/lib/format/mapchecks-part.d.ts +5 -0
- package/src/lib/format/mapchecks-part.js +11 -0
- package/src/lib/format/mapchecks-part.js.map +1 -0
- package/src/lib/format/mapchecks-part.mjs +6 -0
- package/src/lib/format/mapchecks-part.mjs.map +1 -0
- package/src/lib/format/option-checks.d.mts +16 -0
- package/src/lib/format/option-checks.d.ts +16 -0
- package/src/lib/format/option-checks.js +39 -0
- package/src/lib/format/option-checks.js.map +1 -0
- package/src/lib/format/option-checks.mjs +36 -0
- package/src/lib/format/option-checks.mjs.map +1 -0
- package/src/lib/format/options-part.d.mts +6 -0
- package/src/lib/format/options-part.d.ts +6 -0
- package/src/lib/format/options-part.js +11 -0
- package/src/lib/format/options-part.js.map +1 -0
- package/src/lib/format/options-part.mjs +7 -0
- package/src/lib/format/options-part.mjs.map +1 -0
- package/src/lib/format/page.d.mts +154 -71
- package/src/lib/format/page.d.ts +154 -71
- package/src/lib/format/page.js +5 -0
- package/src/lib/format/page.js.map +1 -1
- package/src/lib/format/page.mjs +5 -0
- package/src/lib/format/page.mjs.map +1 -1
- package/src/lib/format/part-checks.d.mts +20 -0
- package/src/lib/format/part-checks.d.ts +20 -0
- package/src/lib/format/part-checks.js +3 -0
- package/src/lib/format/part-checks.js.map +1 -0
- package/src/lib/format/part-checks.mjs +2 -0
- package/src/lib/format/part-checks.mjs.map +1 -0
- package/src/lib/format/references.d.mts +71 -65
- package/src/lib/format/references.d.ts +71 -65
- package/src/lib/format/references.js +194 -631
- package/src/lib/format/references.js.map +1 -1
- package/src/lib/format/references.mjs +194 -631
- package/src/lib/format/references.mjs.map +1 -1
- package/src/lib/format/seats-checks.d.mts +3 -0
- package/src/lib/format/seats-checks.d.ts +3 -0
- package/src/lib/format/seats-checks.js +13 -0
- package/src/lib/format/seats-checks.js.map +1 -0
- package/src/lib/format/seats-checks.mjs +10 -0
- package/src/lib/format/seats-checks.mjs.map +1 -0
- package/src/lib/format/sheet-head-checks.d.mts +4 -0
- package/src/lib/format/sheet-head-checks.d.ts +4 -0
- package/src/lib/format/sheet-head-checks.js +68 -0
- package/src/lib/format/sheet-head-checks.js.map +1 -0
- package/src/lib/format/sheet-head-checks.mjs +65 -0
- package/src/lib/format/sheet-head-checks.mjs.map +1 -0
- package/src/lib/format/signature-checks.d.mts +7 -0
- package/src/lib/format/signature-checks.d.ts +7 -0
- package/src/lib/format/signature-checks.js +32 -0
- package/src/lib/format/signature-checks.js.map +1 -0
- package/src/lib/format/signature-checks.mjs +29 -0
- package/src/lib/format/signature-checks.mjs.map +1 -0
- package/src/lib/format/signature-options.d.mts +24 -0
- package/src/lib/format/signature-options.d.ts +24 -0
- package/src/lib/format/signature-options.js +30 -0
- package/src/lib/format/signature-options.js.map +1 -0
- package/src/lib/format/signature-options.mjs +26 -0
- package/src/lib/format/signature-options.mjs.map +1 -0
- package/src/lib/format/slots-checks.d.mts +4 -0
- package/src/lib/format/slots-checks.d.ts +4 -0
- package/src/lib/format/slots-checks.js +21 -0
- package/src/lib/format/slots-checks.js.map +1 -0
- package/src/lib/format/slots-checks.mjs +18 -0
- package/src/lib/format/slots-checks.mjs.map +1 -0
- package/src/lib/format/statusbar-checks.d.mts +8 -0
- package/src/lib/format/statusbar-checks.d.ts +8 -0
- package/src/lib/format/statusbar-checks.js +35 -0
- package/src/lib/format/statusbar-checks.js.map +1 -0
- package/src/lib/format/statusbar-checks.mjs +32 -0
- package/src/lib/format/statusbar-checks.mjs.map +1 -0
- package/src/lib/format/table-checks.d.mts +21 -0
- package/src/lib/format/table-checks.d.ts +21 -0
- package/src/lib/format/table-checks.js +86 -0
- package/src/lib/format/table-checks.js.map +1 -0
- package/src/lib/format/table-checks.mjs +82 -0
- package/src/lib/format/table-checks.mjs.map +1 -0
- package/src/lib/format/translate.js +2 -2
- package/src/lib/format/translate.js.map +1 -1
- package/src/lib/format/translate.mjs +2 -2
- package/src/lib/format/translate.mjs.map +1 -1
- package/src/lib/format/upgrade.d.mts +7 -3
- package/src/lib/format/upgrade.d.ts +7 -3
- package/src/lib/format/upgrade.js +7 -3
- package/src/lib/format/upgrade.js.map +1 -1
- package/src/lib/format/upgrade.mjs +7 -3
- package/src/lib/format/upgrade.mjs.map +1 -1
- package/src/lib/format/validate.d.mts +18 -2
- package/src/lib/format/validate.d.ts +18 -2
- package/src/lib/format/validate.js +36 -3
- package/src/lib/format/validate.js.map +1 -1
- package/src/lib/format/validate.mjs +35 -3
- package/src/lib/format/validate.mjs.map +1 -1
- package/src/lib/format/version.d.mts +2 -2
- package/src/lib/format/version.d.ts +2 -2
- package/src/lib/format/version.js +2 -2
- package/src/lib/format/version.js.map +1 -1
- package/src/lib/format/version.mjs +2 -2
- package/src/lib/format/version.mjs.map +1 -1
- package/src/lib/format/words.d.mts +6 -2
- package/src/lib/format/words.d.ts +6 -2
- package/src/lib/format/words.js +13 -7
- package/src/lib/format/words.js.map +1 -1
- package/src/lib/format/words.mjs +13 -7
- package/src/lib/format/words.mjs.map +1 -1
- package/src/lib/parts.d.mts +45 -0
- package/src/lib/parts.d.ts +45 -0
- package/src/lib/parts.js +60 -0
- package/src/lib/parts.js.map +1 -0
- package/src/lib/parts.mjs +53 -0
- package/src/lib/parts.mjs.map +1 -0
- package/src/lib/record/cells.d.mts +3 -3
- package/src/lib/record/cells.d.ts +3 -3
- package/src/lib/record/cells.js +16 -15
- package/src/lib/record/cells.js.map +1 -1
- package/src/lib/record/cells.mjs +16 -15
- package/src/lib/record/cells.mjs.map +1 -1
- package/src/lib/record/check.js +3 -1
- package/src/lib/record/check.js.map +1 -1
- package/src/lib/record/check.mjs +3 -1
- package/src/lib/record/check.mjs.map +1 -1
- package/src/lib/record/compute.d.mts +16 -5
- package/src/lib/record/compute.d.ts +16 -5
- package/src/lib/record/compute.js +57 -16
- package/src/lib/record/compute.js.map +1 -1
- package/src/lib/record/compute.mjs +57 -16
- package/src/lib/record/compute.mjs.map +1 -1
- package/src/lib/record/data-source.d.mts +140 -3
- package/src/lib/record/data-source.d.ts +140 -3
- package/src/lib/record/data-source.js.map +1 -1
- package/src/lib/record/data-source.mjs.map +1 -1
- package/src/lib/record/day-words.d.mts +10 -0
- package/src/lib/record/day-words.d.ts +10 -0
- package/src/lib/record/day-words.js +23 -0
- package/src/lib/record/day-words.js.map +1 -0
- package/src/lib/record/day-words.mjs +20 -0
- package/src/lib/record/day-words.mjs.map +1 -0
- package/src/lib/record/drafts.d.mts +19 -0
- package/src/lib/record/drafts.d.ts +19 -0
- package/src/lib/record/drafts.js +35 -0
- package/src/lib/record/drafts.js.map +1 -0
- package/src/lib/record/drafts.mjs +31 -0
- package/src/lib/record/drafts.mjs.map +1 -0
- package/src/lib/record/env.d.mts +5 -1
- package/src/lib/record/env.d.ts +5 -1
- package/src/lib/record/env.js +9 -1
- package/src/lib/record/env.js.map +1 -1
- package/src/lib/record/env.mjs +8 -1
- package/src/lib/record/env.mjs.map +1 -1
- package/src/lib/record/form-limits.d.mts +78 -0
- package/src/lib/record/form-limits.d.ts +78 -0
- package/src/lib/record/form-limits.js +230 -0
- package/src/lib/record/form-limits.js.map +1 -0
- package/src/lib/record/form-limits.mjs +223 -0
- package/src/lib/record/form-limits.mjs.map +1 -0
- package/src/lib/record/form.d.mts +180 -9
- package/src/lib/record/form.d.ts +180 -9
- package/src/lib/record/form.js +858 -90
- package/src/lib/record/form.js.map +1 -1
- package/src/lib/record/form.mjs +858 -90
- package/src/lib/record/form.mjs.map +1 -1
- package/src/lib/record/limits-part.d.mts +6 -0
- package/src/lib/record/limits-part.d.ts +6 -0
- package/src/lib/record/limits-part.js +12 -0
- package/src/lib/record/limits-part.js.map +1 -0
- package/src/lib/record/limits-part.mjs +7 -0
- package/src/lib/record/limits-part.mjs.map +1 -0
- package/src/lib/record/limits.js +4 -2
- package/src/lib/record/limits.js.map +1 -1
- package/src/lib/record/limits.mjs +4 -2
- package/src/lib/record/limits.mjs.map +1 -1
- package/src/lib/record/line-choices.d.mts +30 -0
- package/src/lib/record/line-choices.d.ts +30 -0
- package/src/lib/record/line-choices.js +42 -0
- package/src/lib/record/line-choices.js.map +1 -0
- package/src/lib/record/line-choices.mjs +36 -0
- package/src/lib/record/line-choices.mjs.map +1 -0
- package/src/lib/record/locales/ar.js +11 -0
- package/src/lib/record/locales/ar.js.map +1 -1
- package/src/lib/record/locales/ar.mjs +11 -0
- package/src/lib/record/locales/ar.mjs.map +1 -1
- package/src/lib/record/locales/de.js +11 -0
- package/src/lib/record/locales/de.js.map +1 -1
- package/src/lib/record/locales/de.mjs +11 -0
- package/src/lib/record/locales/de.mjs.map +1 -1
- package/src/lib/record/locales/fr.js +11 -0
- package/src/lib/record/locales/fr.js.map +1 -1
- package/src/lib/record/locales/fr.mjs +11 -0
- package/src/lib/record/locales/fr.mjs.map +1 -1
- package/src/lib/record/memory-data-source.d.mts +44 -3
- package/src/lib/record/memory-data-source.d.ts +44 -3
- package/src/lib/record/memory-data-source.js +102 -40
- package/src/lib/record/memory-data-source.js.map +1 -1
- package/src/lib/record/memory-data-source.mjs +101 -40
- package/src/lib/record/memory-data-source.mjs.map +1 -1
- package/src/lib/record/memory-kept.d.mts +20 -0
- package/src/lib/record/memory-kept.d.ts +20 -0
- package/src/lib/record/memory-kept.js +46 -0
- package/src/lib/record/memory-kept.js.map +1 -0
- package/src/lib/record/memory-kept.mjs +43 -0
- package/src/lib/record/memory-kept.mjs.map +1 -0
- package/src/lib/record/memory-later.d.mts +19 -0
- package/src/lib/record/memory-later.d.ts +19 -0
- package/src/lib/record/memory-later.js +39 -0
- package/src/lib/record/memory-later.js.map +1 -0
- package/src/lib/record/memory-later.mjs +35 -0
- package/src/lib/record/memory-later.mjs.map +1 -0
- package/src/lib/record/memory-part.d.mts +7 -0
- package/src/lib/record/memory-part.d.ts +7 -0
- package/src/lib/record/memory-part.js +13 -0
- package/src/lib/record/memory-part.js.map +1 -0
- package/src/lib/record/memory-part.mjs +8 -0
- package/src/lib/record/memory-part.mjs.map +1 -0
- package/src/lib/record/messages.d.mts +27 -2
- package/src/lib/record/messages.d.ts +27 -2
- package/src/lib/record/messages.js +13 -4
- package/src/lib/record/messages.js.map +1 -1
- package/src/lib/record/messages.mjs +13 -4
- package/src/lib/record/messages.mjs.map +1 -1
- package/src/lib/record/option-rules.d.mts +56 -0
- package/src/lib/record/option-rules.d.ts +56 -0
- package/src/lib/record/option-rules.js +143 -0
- package/src/lib/record/option-rules.js.map +1 -0
- package/src/lib/record/option-rules.mjs +140 -0
- package/src/lib/record/option-rules.mjs.map +1 -0
- package/src/lib/record/record-words.d.mts +13 -1
- package/src/lib/record/record-words.d.ts +13 -1
- package/src/lib/record/record-words.js +29 -1
- package/src/lib/record/record-words.js.map +1 -1
- package/src/lib/record/record-words.mjs +27 -1
- package/src/lib/record/record-words.mjs.map +1 -1
- package/src/lib/record/rules.d.mts +2 -2
- package/src/lib/record/rules.d.ts +2 -2
- package/src/lib/record/rules.js +3 -3
- package/src/lib/record/rules.js.map +1 -1
- package/src/lib/record/rules.mjs +3 -3
- package/src/lib/record/rules.mjs.map +1 -1
- package/src/lib/record/run.js +9 -7
- package/src/lib/record/run.js.map +1 -1
- package/src/lib/record/run.mjs +9 -7
- package/src/lib/record/run.mjs.map +1 -1
- package/src/lib/record/search.d.mts +12 -2
- package/src/lib/record/search.d.ts +12 -2
- package/src/lib/record/search.js +29 -4
- package/src/lib/record/search.js.map +1 -1
- package/src/lib/record/search.mjs +29 -4
- package/src/lib/record/search.mjs.map +1 -1
- package/src/lib/record/set-when.d.mts +3 -3
- package/src/lib/record/set-when.d.ts +3 -3
- package/src/lib/record/set-when.js +9 -9
- package/src/lib/record/set-when.js.map +1 -1
- package/src/lib/record/set-when.mjs +9 -9
- package/src/lib/record/set-when.mjs.map +1 -1
- package/src/lib/record/signed.d.mts +21 -0
- package/src/lib/record/signed.d.ts +21 -0
- package/src/lib/record/signed.js +62 -0
- package/src/lib/record/signed.js.map +1 -0
- package/src/lib/record/signed.mjs +57 -0
- package/src/lib/record/signed.mjs.map +1 -0
- package/src/lib/record/taking.d.mts +60 -0
- package/src/lib/record/taking.d.ts +60 -0
- package/src/lib/record/taking.js +58 -0
- package/src/lib/record/taking.js.map +1 -0
- package/src/lib/record/taking.mjs +50 -0
- package/src/lib/record/taking.mjs.map +1 -0
- package/src/lib/record/value-map.js +11 -4
- package/src/lib/record/value-map.js.map +1 -1
- package/src/lib/record/value-map.mjs +11 -4
- package/src/lib/record/value-map.mjs.map +1 -1
- package/src/lib/record/values.d.mts +20 -0
- package/src/lib/record/values.d.ts +20 -0
- package/src/lib/record/values.js.map +1 -1
- package/src/lib/record/values.mjs.map +1 -1
- package/src/lib/record/waits.d.mts +13 -6
- package/src/lib/record/waits.d.ts +13 -6
- package/src/lib/record/waits.js +9 -12
- package/src/lib/record/waits.js.map +1 -1
- package/src/lib/record/waits.mjs +9 -12
- package/src/lib/record/waits.mjs.map +1 -1
- package/src/runtime.d.mts +17 -6
- package/src/runtime.d.ts +17 -6
- package/src/runtime.js +45 -3
- package/src/runtime.js.map +1 -1
- package/src/runtime.mjs +17 -1
- package/src/runtime.mjs.map +1 -1
package/src/lib/record/form.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { changesOptions, hasOptionRules, optionRulesPart, optionsField, optionsList } from '../format/choice-options.mjs';
|
|
2
|
+
import { fillValues } from '../format/words.mjs';
|
|
1
3
|
import { upgradePage } from '../format/upgrade.mjs';
|
|
2
4
|
import { zonedPage } from '../format/zoned.mjs';
|
|
3
5
|
import { compileModifier } from '../expression/modifier.mjs';
|
|
6
|
+
import { callsPartFunctions, functionsPart } from '../expression/functions.mjs';
|
|
7
|
+
import { functionTable } from '../expression/app-functions.mjs';
|
|
4
8
|
import { dayIn, ownZone } from './zones.mjs';
|
|
5
9
|
import { checkProperties, checkValue } from './check.mjs';
|
|
6
10
|
import { checkInput } from './inputs.mjs';
|
|
@@ -14,10 +18,14 @@ import { rolesAllow } from './roles.mjs';
|
|
|
14
18
|
import { compileFieldTone, compileTable } from './cells.mjs';
|
|
15
19
|
import { fillMessage, MESSAGES } from './messages.mjs';
|
|
16
20
|
import { recordSentence } from './record-words.mjs';
|
|
21
|
+
import { askKey, cellOf, listedColumns, notOffered } from './line-choices.mjs';
|
|
17
22
|
import { loadedRecordOf, saveProblemOf, } from './data-source.mjs';
|
|
23
|
+
import { formLimitsPart, hasLimits } from './taking.mjs';
|
|
24
|
+
import { draftRead, resumeStep } from './drafts.mjs';
|
|
18
25
|
import { waitingOn, workedOutFrom } from './waits.mjs';
|
|
19
26
|
import { createUploads, fileBytesIn, uploadGoing, withoutFileBytes } from './uploads.mjs';
|
|
20
27
|
import { hostScheduler } from './scheduler.mjs';
|
|
28
|
+
import { signedBy } from './signed.mjs';
|
|
21
29
|
import { createMoments, createRunner } from './run.mjs';
|
|
22
30
|
import { emptyValue, initialValues, isEmpty, lineKind, structuredCopy, } from './values.mjs';
|
|
23
31
|
/**
|
|
@@ -77,16 +85,53 @@ function innerForm(options, within, place, outer) {
|
|
|
77
85
|
const page = zonedPage(options.page);
|
|
78
86
|
const scheduler = options.scheduler ?? hostScheduler;
|
|
79
87
|
// A field's label small inside a message's sentence where the page asks (`lowerLabels`).
|
|
80
|
-
|
|
88
|
+
// …and a day written in the page's order where it says one (`look.dateOrder`): "can't be after Oct 20, 2026".
|
|
89
|
+
const dateOrder = page.look?.dateOrder;
|
|
90
|
+
const messages = page.lowerLabels || dateOrder ? { ...(options.messages ?? MESSAGES.en), lowerLabels: page.lowerLabels, dateOrder } : (options.messages ?? MESSAGES.en);
|
|
81
91
|
/** One of the form's sentences in the words the page names its records by (`records`), else as the language says it plainly. */
|
|
82
92
|
const named = (noun, plain) => recordSentence(page.records, noun, plain, messages.locale);
|
|
83
|
-
|
|
93
|
+
/** The app's functions the page's expressions call: a name none may call is refused now. */
|
|
94
|
+
const table = functionTable(options.functions);
|
|
95
|
+
/**
|
|
96
|
+
* The answers of the app's functions that ask, for the record shown (`ExpressionEnv.answer`), by function and
|
|
97
|
+
* values: each asked once, `asking` until it comes. Another record shown, they start again: an answer for the last
|
|
98
|
+
* one is laid on none.
|
|
99
|
+
*/
|
|
100
|
+
let answers = new Map();
|
|
101
|
+
/** Those on their way: a save waits for them. */
|
|
102
|
+
const asking = new Set();
|
|
103
|
+
/** Everything the form waits on (`track`): there before the form's first values are worked out, which may ask. */
|
|
104
|
+
const pending = new Set();
|
|
105
|
+
function answer(key, asked) {
|
|
106
|
+
const kept = answers.get(key);
|
|
107
|
+
if (kept !== undefined || !asked)
|
|
108
|
+
return kept;
|
|
109
|
+
const map = answers;
|
|
110
|
+
map.set(key, 'asking');
|
|
111
|
+
const land = (found) => {
|
|
112
|
+
asking.delete(going);
|
|
113
|
+
if (map !== answers || disposed)
|
|
114
|
+
return;
|
|
115
|
+
map.set(key, found);
|
|
116
|
+
answered();
|
|
117
|
+
};
|
|
118
|
+
const going = Promise.resolve(asked).then((value) => land({ value: value === undefined ? null : value }), (error) => land({ value: null, failed: error instanceof Error ? error.message : String(error) }));
|
|
119
|
+
asking.add(going);
|
|
120
|
+
track(going);
|
|
121
|
+
return 'asking';
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* What every expression of the form is handed of the app's — and, on a page calling Fieldia's functions whose bodies
|
|
125
|
+
* come in the functions part before it has come, the answers they wait for it with, as an app's function that asks.
|
|
126
|
+
*/
|
|
127
|
+
const app = table ? { functions: table, answer } : !functionsPart.loaded && callsPartFunctions(page) ? { answer } : {};
|
|
128
|
+
const index = indexLayout(page.layout, table);
|
|
84
129
|
/** Each field node's answer rules, read once. */
|
|
85
130
|
const nodeRules = new Map();
|
|
86
131
|
for (const node of index.values()) {
|
|
87
132
|
const rules = node.source.validate;
|
|
88
133
|
if (node.kind === 'field' && rules)
|
|
89
|
-
nodeRules.set(node.id, compileRules(rules));
|
|
134
|
+
nodeRules.set(node.id, compileRules(rules, table));
|
|
90
135
|
}
|
|
91
136
|
/** Tables of lines with rules of their own, by their field node: each read once. */
|
|
92
137
|
const tables = new Map();
|
|
@@ -95,14 +140,14 @@ function innerForm(options, within, place, outer) {
|
|
|
95
140
|
if (node.kind !== 'field' || page.fields[source.field]?.type !== 'one2many')
|
|
96
141
|
continue;
|
|
97
142
|
if (source.cells || source.rowTones || source.rowBold !== undefined || source.rowButtons || source.lineDelete !== undefined)
|
|
98
|
-
tables.set(node.id, { field: source.field, compiled: compileTable(source) });
|
|
143
|
+
tables.set(node.id, { field: source.field, compiled: compileTable(source, table) });
|
|
99
144
|
}
|
|
100
145
|
/** Field nodes whose value takes a tone or bold, by id: each read once. */
|
|
101
146
|
const fieldTones = new Map();
|
|
102
147
|
for (const node of index.values()) {
|
|
103
148
|
const source = node.source;
|
|
104
149
|
if (node.kind === 'field' && (source.tones || source.bold !== undefined))
|
|
105
|
-
fieldTones.set(node.id, compileFieldTone(source));
|
|
150
|
+
fieldTones.set(node.id, compileFieldTone(source, table));
|
|
106
151
|
}
|
|
107
152
|
/** The tables whose lines load in an order of their own fields, by the field: the first node to give one. */
|
|
108
153
|
const lineOrders = new Map();
|
|
@@ -130,7 +175,7 @@ function innerForm(options, within, place, outer) {
|
|
|
130
175
|
const placeholders = new Map();
|
|
131
176
|
const placeholderOf = (id, own) => {
|
|
132
177
|
if (own.placeholderWhen?.length)
|
|
133
|
-
placeholders.set(id, { fixed: own.placeholder, when: own.placeholderWhen.map((item) => ({ text: item.text, holds: compileModifier(item.when) })) });
|
|
178
|
+
placeholders.set(id, { fixed: own.placeholder, when: own.placeholderWhen.map((item) => ({ text: item.text, holds: compileModifier(item.when, table) })) });
|
|
134
179
|
};
|
|
135
180
|
for (const node of index.values())
|
|
136
181
|
if (node.kind === 'field' && 'type' in node.source)
|
|
@@ -140,9 +185,11 @@ function innerForm(options, within, place, outer) {
|
|
|
140
185
|
/** Whether any rule only warns: without one, there are never warnings to look for. */
|
|
141
186
|
const warns = [...nodeRules.values()].some((rules) => rules.some((compiled) => compiled.rule.level === 'warning'));
|
|
142
187
|
const steps = page.layout.type === 'wizard' ? page.layout.children.map((step) => step.id) : [];
|
|
143
|
-
const
|
|
188
|
+
const storeKey = () => `fieldia:draft:${page.id}:${state.recordId ?? 'new'}`;
|
|
144
189
|
/** Today, on the clock of the page's time zone (the browser's own when it names none). */
|
|
145
190
|
const today = () => dayIn(options.now?.() ?? new Date(), page.timeZone);
|
|
191
|
+
/** Whether a field's own words — a label, a choice's — show a value: found once, so a page with none checks as before. */
|
|
192
|
+
const worded = /\{[A-Za-z_]\w*(\|[^{}]*)?\}/.test(JSON.stringify(page.fields));
|
|
146
193
|
const clock = () => (options.now?.() ?? new Date()).getTime();
|
|
147
194
|
/** What a page's bot check saw — its hidden box filled, the captcha's token — and when the page was shown or started again. */
|
|
148
195
|
let bot = { honeypot: false, captcha: null, since: clock() };
|
|
@@ -162,10 +209,10 @@ function innerForm(options, within, place, outer) {
|
|
|
162
209
|
/** Whether the record is being edited now: not while a view locks it, nor when its source lets the person only read it. */
|
|
163
210
|
const editingNow = () => editing && !(started && state.can?.edit === false);
|
|
164
211
|
const about = () => ({ recordId: started ? state.recordId : (options.recordId ?? null), user: options.user, editing: editingNow(), context: options.context, parent: parentContext });
|
|
165
|
-
const computed = compileComputed(page, today, about);
|
|
212
|
+
const computed = compileComputed(page, today, about, app);
|
|
166
213
|
/** Each value worked out from others — by the page, or by the app as the lines change — and what it waits for. */
|
|
167
|
-
const workedOut = workedOutFrom(page, !!options.dataSource?.onchange && page.data.kind === 'record', !!options.parent);
|
|
168
|
-
const setWhen = compileSetWhen(page, today, about);
|
|
214
|
+
const workedOut = workedOutFrom(page, !!options.dataSource?.onchange && page.data.kind === 'record', !!options.parent, table);
|
|
215
|
+
const setWhen = compileSetWhen(page, today, about, app);
|
|
169
216
|
/** The saved forms placed on the page, by the part's id: each one's answers sit under its name, as JSON. */
|
|
170
217
|
const parts = new Map();
|
|
171
218
|
for (const node of index.values())
|
|
@@ -217,7 +264,7 @@ function innerForm(options, within, place, outer) {
|
|
|
217
264
|
const values = initialValues(fields, today());
|
|
218
265
|
if (isNew) {
|
|
219
266
|
const about = { recordId: null, user: options.user, context: options.context, parent: parentContext };
|
|
220
|
-
Object.assign(values, firstValues(page.fields, mapScope(values, page.fields, recordContext(values, page.fields, about), expressionEnv(values, page.fields, today))));
|
|
267
|
+
Object.assign(values, firstValues(page.fields, mapScope(values, page.fields, recordContext(values, page.fields, about), expressionEnv(values, page.fields, today, app))));
|
|
221
268
|
}
|
|
222
269
|
return given ? ordered({ ...values, ...structuredCopy(options.values ?? {}) }) : values;
|
|
223
270
|
}
|
|
@@ -246,7 +293,7 @@ function innerForm(options, within, place, outer) {
|
|
|
246
293
|
function lineScope(field, values) {
|
|
247
294
|
const def = lineField(field);
|
|
248
295
|
const lineFields = def.fields;
|
|
249
|
-
return mapScope(values, lineFields, lineContext(values, lineFields, reading().context), { today }, { values: state.values, fields: page.fields });
|
|
296
|
+
return mapScope(values, lineFields, lineContext(values, lineFields, reading().context), { ...app, today }, { values: state.values, fields: page.fields });
|
|
250
297
|
}
|
|
251
298
|
function tableOf(nodeId) {
|
|
252
299
|
const table = tables.get(nodeId);
|
|
@@ -266,7 +313,7 @@ function innerForm(options, within, place, outer) {
|
|
|
266
313
|
if (!line)
|
|
267
314
|
throw new Error(`"${table.field}" has no line "${key}"`);
|
|
268
315
|
const def = lineField(table.field);
|
|
269
|
-
return table.compiled.line(lineContext(line.values, def.fields, reading().context, line.id ?? null), { today }, userRoles);
|
|
316
|
+
return table.compiled.line(lineContext(line.values, def.fields, reading().context, line.id ?? null), { ...app, today }, userRoles);
|
|
270
317
|
}
|
|
271
318
|
function createValuesOf(field, line) {
|
|
272
319
|
if (!line) {
|
|
@@ -279,7 +326,9 @@ function innerForm(options, within, place, outer) {
|
|
|
279
326
|
return {};
|
|
280
327
|
return readLooseMap(sub.createValues, lineScope(line.lines, found.values));
|
|
281
328
|
}
|
|
282
|
-
|
|
329
|
+
/** The values worked out from an app's function that asks with no answer yet, as the values shown last settled. */
|
|
330
|
+
let askedNow = new Map();
|
|
331
|
+
let baseline = computed.apply(startingValues(), askedNow);
|
|
283
332
|
/** The setWhen conditions holding for the values as they last settled: one starts to hold only against these. */
|
|
284
333
|
let holding = setWhen.holding(baseline);
|
|
285
334
|
let state = {
|
|
@@ -306,6 +355,12 @@ function innerForm(options, within, place, outer) {
|
|
|
306
355
|
unsent: [],
|
|
307
356
|
leaving: false,
|
|
308
357
|
unread: {},
|
|
358
|
+
sent: null,
|
|
359
|
+
asked: Object.fromEntries(askedNow),
|
|
360
|
+
takenOut: {},
|
|
361
|
+
// Worked out once the form has its state, as the limits part comes (`limitsCode`).
|
|
362
|
+
limits: null,
|
|
363
|
+
resume: null,
|
|
309
364
|
};
|
|
310
365
|
started = true;
|
|
311
366
|
/**
|
|
@@ -478,7 +533,6 @@ function innerForm(options, within, place, outer) {
|
|
|
478
533
|
let onchangeSeq = 0;
|
|
479
534
|
let draftTimer = null;
|
|
480
535
|
let autosaveTimer = null;
|
|
481
|
-
const pending = new Set();
|
|
482
536
|
const listeners = new Set();
|
|
483
537
|
/** The app's listeners, by event. */
|
|
484
538
|
const events = new Map();
|
|
@@ -492,10 +546,30 @@ function innerForm(options, within, place, outer) {
|
|
|
492
546
|
const userRoles = [...(options.user?.roles ?? [])];
|
|
493
547
|
/** The latest load of each field's choices: an answer to an older one is let go. */
|
|
494
548
|
const choiceLoads = {};
|
|
549
|
+
/** The tables' columns whose choices are the app's: none on most pages, and then nothing below is followed. */
|
|
550
|
+
const listed = listedColumns(page.fields);
|
|
551
|
+
/** Whether the values set now are a change someone made (`writeValues`), after which a line's choice no longer offered is cleared. */
|
|
552
|
+
let edit = false;
|
|
495
553
|
function set(patch) {
|
|
496
554
|
const was = state.values;
|
|
555
|
+
const choicesWas = state.choices;
|
|
497
556
|
const shown = state.errors;
|
|
557
|
+
const edited = edit;
|
|
558
|
+
edit = false;
|
|
559
|
+
const stepWas = state.step;
|
|
498
560
|
state = { ...state, ...patch };
|
|
561
|
+
// A line's choices go with their line.
|
|
562
|
+
if (state.values !== was)
|
|
563
|
+
state = { ...state, choices: choicesNow(state.choices) };
|
|
564
|
+
// What was said taken out is said while it is true: an option offered again, or picked again, is said no more.
|
|
565
|
+
if ((state.values !== was || state.choices !== choicesWas) && Object.keys(state.takenOut).length) {
|
|
566
|
+
const takenOut = takenOutTrue();
|
|
567
|
+
if (takenOut !== state.takenOut)
|
|
568
|
+
state = { ...state, takenOut };
|
|
569
|
+
}
|
|
570
|
+
// What waits for an app's answer, as the values shown last settled.
|
|
571
|
+
if (patch.values !== undefined && patch.asked === undefined && !sameAsked(state.asked, askedNow))
|
|
572
|
+
state = { ...state, asked: Object.fromEntries(askedNow) };
|
|
499
573
|
// The person's changes the last save did not send, worked out again from the values as they are now, and from the
|
|
500
574
|
// text they left that does not read.
|
|
501
575
|
if (patch.unsent === undefined && (patch.values !== undefined || patch.unread !== undefined)) {
|
|
@@ -511,15 +585,21 @@ function innerForm(options, within, place, outer) {
|
|
|
511
585
|
listener(state);
|
|
512
586
|
// Choices that change with a value that just changed are asked for again.
|
|
513
587
|
if (state.values !== was) {
|
|
588
|
+
// After someone's change, a choice its new choices do not offer is taken out and said, as a line's is.
|
|
514
589
|
for (const name in state.choices)
|
|
515
|
-
if (fromList(name)
|
|
516
|
-
loadChoices(name);
|
|
590
|
+
if (!name.includes('.') && fromList(name)?.dependsOn?.some((other) => was[other] !== state.values[other]))
|
|
591
|
+
loadChoices(name, edited);
|
|
517
592
|
for (const name in state.definitions)
|
|
518
593
|
if (fromRecord(name).dependsOn?.some((other) => was[other] !== state.values[other]))
|
|
519
594
|
loadDefinitions(name);
|
|
595
|
+
if (listed.length)
|
|
596
|
+
followLines(was, edited);
|
|
520
597
|
}
|
|
521
598
|
if (showing && state.step !== told)
|
|
522
599
|
tellStep(entering);
|
|
600
|
+
// A wizard's step entered with answers typed is kept in the draft, so it opens there again.
|
|
601
|
+
if (state.step !== stepWas && showing && state.dirty.length)
|
|
602
|
+
scheduleDraft();
|
|
523
603
|
}
|
|
524
604
|
function emit(event, payload) {
|
|
525
605
|
const heard = events.get(event);
|
|
@@ -542,6 +622,9 @@ function innerForm(options, within, place, outer) {
|
|
|
542
622
|
/** Another record is shown: nothing of the last one's is the person's work any more, and its files on their way stop. */
|
|
543
623
|
function newGeneration() {
|
|
544
624
|
generation++;
|
|
625
|
+
// Another record's lines ask the source anew.
|
|
626
|
+
lineAsks = new Map();
|
|
627
|
+
answers = new Map();
|
|
545
628
|
personal.clear();
|
|
546
629
|
personalLines.clear();
|
|
547
630
|
filed.clear();
|
|
@@ -666,16 +749,129 @@ function innerForm(options, within, place, outer) {
|
|
|
666
749
|
entering = was;
|
|
667
750
|
}
|
|
668
751
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
752
|
+
/** The app's list a choice's options come from; none for one whose options are its own or carried. */
|
|
753
|
+
const fromList = (name) => optionsList(page.fields[name]?.optionsFrom);
|
|
754
|
+
// ---- a table line's choices from the app's lists (line-choices.ts) ----------------------------------------------
|
|
755
|
+
/** A line's choices asked of the source, by what they are asked by (`askKey`), for the record shown: lines alike share one. */
|
|
756
|
+
let lineAsks = new Map();
|
|
757
|
+
/** What each line cell's choices were last asked by. */
|
|
758
|
+
const askedBy = new Map();
|
|
759
|
+
const listedAt = (table, column) => listed.find((one) => one.table === table && one.column === column);
|
|
760
|
+
const lineAt = (table, key) => (state.values[table] ?? []).find((line) => line.key === key);
|
|
761
|
+
/** A line's choices from the source: asked once for every line whose columns they change with hold the same values. */
|
|
762
|
+
function askLine(one, values) {
|
|
763
|
+
const key = askKey(one, values, state.values);
|
|
764
|
+
const asks = lineAsks;
|
|
765
|
+
let ask = asks.get(key);
|
|
766
|
+
if (ask)
|
|
767
|
+
return ask;
|
|
768
|
+
const source = options.dataSource;
|
|
769
|
+
const request = { list: one.list, values: structuredCopy(values), parent: structuredCopy(state.values) };
|
|
770
|
+
ask = source?.options ? source.options(request) : Promise.reject(new Error(`No list "${one.list}"`));
|
|
771
|
+
asks.set(key, ask);
|
|
772
|
+
// One that failed is asked again next time.
|
|
773
|
+
ask.catch(() => asks.get(key) === ask && asks.delete(key));
|
|
774
|
+
return ask;
|
|
775
|
+
}
|
|
776
|
+
/** The choices as the values are now: a line's go with their line. */
|
|
777
|
+
function choicesNow(choices) {
|
|
778
|
+
let kept = null;
|
|
779
|
+
for (const path of Object.keys(choices)) {
|
|
780
|
+
if (valueAt(state.values, path) !== gone)
|
|
781
|
+
continue;
|
|
782
|
+
kept ??= { ...choices };
|
|
783
|
+
delete kept[path];
|
|
784
|
+
askedBy.delete(path);
|
|
785
|
+
}
|
|
786
|
+
return kept ?? choices;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Values changed: each line's choices loaded are asked again where what they change with changed on their line (a
|
|
790
|
+
* record shown with the same line, Discard, a draft); after a change someone made (`edited`), judged too — and so is a
|
|
791
|
+
* line holding a choice whose choices nobody asked for yet, so none is kept that its columns no longer offer.
|
|
792
|
+
*/
|
|
793
|
+
function followLines(was, edited) {
|
|
794
|
+
// Choices that change with nothing are asked once.
|
|
795
|
+
for (const one of listed.filter((column) => column.own.length || column.parent.length)) {
|
|
796
|
+
for (const line of state.values[one.table] ?? []) {
|
|
797
|
+
const path = `${one.table}.${line.key}.${one.column}`;
|
|
798
|
+
const by = askKey(one, line.values, state.values);
|
|
799
|
+
const old = !(path in state.choices) && edited && !isEmpty(one.def, line.values[one.column]) && (was[one.table] ?? []).find((l) => l.key === line.key);
|
|
800
|
+
if (path in state.choices ? by !== askedBy.get(path) : old && by !== askKey(one, old.values, was))
|
|
801
|
+
loadChoices(path, edited);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Load a field's choices, or a line cell's by its path (`table.key.column`). `judge`, after a change someone made of
|
|
807
|
+
* what they change with: a choice they no longer offer is taken out and said, on the record they were asked for,
|
|
808
|
+
* while a line still asks by the same.
|
|
809
|
+
*/
|
|
810
|
+
function loadChoices(name, judge = false) {
|
|
811
|
+
const cell = cellOf(name);
|
|
812
|
+
const one = cell && listedAt(cell.table, cell.column);
|
|
813
|
+
const line = cell && lineAt(cell.table, cell.key);
|
|
814
|
+
if (cell && (!one || !line))
|
|
815
|
+
throw new Error(`"${name}" is no line's choice from the app's lists`);
|
|
816
|
+
const from = one ?? fromList(name);
|
|
817
|
+
if (!from)
|
|
818
|
+
throw new Error(`"${name}" takes no choices from the app's lists`);
|
|
819
|
+
const { list } = from;
|
|
672
820
|
const load = (choiceLoads[name] = (choiceLoads[name] ?? 0) + 1);
|
|
673
|
-
const
|
|
821
|
+
const by = one && line ? askKey(one, line.values, state.values) : '';
|
|
822
|
+
if (cell)
|
|
823
|
+
askedBy.set(name, by);
|
|
824
|
+
// A line's answer lands while its line is there.
|
|
825
|
+
const put = (choices) => load === choiceLoads[name] && (!cell || name in state.choices) && set({ choices: { ...state.choices, [name]: choices } });
|
|
674
826
|
// What was shown stays while the next ones load, so the list does not flash empty.
|
|
675
827
|
const shown = state.choices[name]?.options ?? null;
|
|
676
|
-
|
|
828
|
+
const loading = { options: shown, loading: true };
|
|
829
|
+
// A line's cell asks first as it is drawn, inside its table's drawing: told with the next change, never drawn again
|
|
830
|
+
// inside it. Asked again, as a column they change with changes, it says it is loading at once.
|
|
831
|
+
if (cell && !(name in state.choices))
|
|
832
|
+
state = { ...state, choices: { ...state.choices, [name]: loading } };
|
|
833
|
+
else
|
|
834
|
+
set({ choices: { ...state.choices, [name]: loading } });
|
|
677
835
|
const source = options.dataSource;
|
|
678
|
-
|
|
836
|
+
const onRecord = shownNow();
|
|
837
|
+
const ask = one && line
|
|
838
|
+
? askLine(one, line.values)
|
|
839
|
+
: source?.options
|
|
840
|
+
? // A line's own form (a dialog) asks as its line does: the record it is on as parent.
|
|
841
|
+
source.options({ list, values: structuredCopy(state.values), ...(options.parent ? { parent: structuredCopy(options.parent.values) } : {}) })
|
|
842
|
+
: Promise.reject(new Error(`No list "${list}"`));
|
|
843
|
+
void track(ask.then((loaded) => {
|
|
844
|
+
if (load !== choiceLoads[name])
|
|
845
|
+
return;
|
|
846
|
+
const now = cell && lineAt(cell.table, cell.key);
|
|
847
|
+
const held = !cell ? state.values[name] : now && askKey(one, now.values, state.values) === by ? now.values[cell.column] : null;
|
|
848
|
+
const lost = judge && onRecord() ? notOffered(one?.def ?? page.fields[name], held, loaded) : [];
|
|
849
|
+
// Taken out and said: the words stay until its value changes again.
|
|
850
|
+
if (lost.length)
|
|
851
|
+
clearChoices(cell ? cell.table : name, cell, lost, namedChoices(lost, shown, loaded));
|
|
852
|
+
put({ options: loaded });
|
|
853
|
+
// Options of the app's list with places, never counted yet: how many took each is asked.
|
|
854
|
+
if (!cell && loaded.some((option) => option.seats !== undefined) && (!limitsKit || limitsKit.uncounted(name)))
|
|
855
|
+
void track(limitsCode().then((kit) => kit?.ask()));
|
|
856
|
+
}, (error) => put({ options: shown, error: error.message ?? String(error) })));
|
|
857
|
+
}
|
|
858
|
+
/** Choices by their labels, as the choices shown before or now name them. */
|
|
859
|
+
const namedChoices = (lost, shown, loaded) => lost.map((value) => [...(shown ?? []), ...loaded].find((option) => option.value === value)?.label ?? String(value));
|
|
860
|
+
/**
|
|
861
|
+
* A choice — a field's, or a line's (`key`) column — less what its choices no longer offer, worked out from someone's
|
|
862
|
+
* change, and said as every choice taken out is (`FormState.takenOut`): their claim stays.
|
|
863
|
+
*/
|
|
864
|
+
function clearChoices(field, line, lost, labels) {
|
|
865
|
+
const without = (value) => (Array.isArray(value) ? value.filter((v) => !lost.includes(v)) : null);
|
|
866
|
+
const values = state.values;
|
|
867
|
+
const written = line
|
|
868
|
+
? (values[field] ?? []).map((l) => (l.key === line.key ? { ...l, values: { ...l.values, [line.column]: without(l.values[line.column]) } } : l))
|
|
869
|
+
: without(values[field]);
|
|
870
|
+
const path = line ? `${field}.${line.key}.${line.column}` : field;
|
|
871
|
+
takenOutOf.set(path, lost.map((value, i) => ({ value, label: labels[i] })));
|
|
872
|
+
writeValues({ ...values, [field]: written }, {}, false, { [path]: takenOutWords(labels) });
|
|
873
|
+
afterEdit(field);
|
|
874
|
+
changed(field, 'step', { keep: true });
|
|
679
875
|
}
|
|
680
876
|
const fromRecord = (name) => page.fields[name].definitionsFrom;
|
|
681
877
|
const definitionLoads = {};
|
|
@@ -695,8 +891,23 @@ function innerForm(options, within, place, outer) {
|
|
|
695
891
|
set({ definitions: { ...state.definitions, [name]: { definitions } } });
|
|
696
892
|
await track(options.dataSource?.saveDefinitions?.({ list, values: structuredCopy(state.values), definitions }) ?? Promise.resolve());
|
|
697
893
|
}
|
|
698
|
-
/**
|
|
894
|
+
/**
|
|
895
|
+
* A field as its value is checked: a list's choices are those loaded, and until they are, any choice may be one; its
|
|
896
|
+
* label and its choices' words with their `{field}`s filled in, as the page shows them.
|
|
897
|
+
*/
|
|
699
898
|
function checked(name) {
|
|
899
|
+
const def = checkedAsLoaded(name);
|
|
900
|
+
return worded ? shownWords(def) : def;
|
|
901
|
+
}
|
|
902
|
+
/** A field whose words show values — its label, its choices' — with them filled in now, else as it is. */
|
|
903
|
+
function shownWords(def) {
|
|
904
|
+
const options = def.type === 'selection' && def.options.some((option) => option.label.includes('{')) ? def.options.map((option) => ({ ...option, label: wordsNow(option.label) })) : null;
|
|
905
|
+
if (!def.label.includes('{') && !options)
|
|
906
|
+
return def;
|
|
907
|
+
return { ...def, label: wordsNow(def.label), ...(options ? { options } : {}) };
|
|
908
|
+
}
|
|
909
|
+
/** A field as its value is checked, its choices those loaded from the app's list. */
|
|
910
|
+
function checkedAsLoaded(name) {
|
|
700
911
|
const def = page.fields[name];
|
|
701
912
|
const loaded = state.choices[name]?.options;
|
|
702
913
|
if (def.type === 'properties' && def.definitionsFrom) {
|
|
@@ -704,7 +915,105 @@ function innerForm(options, within, place, outer) {
|
|
|
704
915
|
const definitions = state.definitions[name]?.definitions;
|
|
705
916
|
return definitions ? { ...def, definitions } : def;
|
|
706
917
|
}
|
|
707
|
-
|
|
918
|
+
// Carried from an earlier question: any of its options, and its own after them, is one of this one's.
|
|
919
|
+
if (def.type === 'selection' && optionsField(def.optionsFrom))
|
|
920
|
+
return { ...def, options: everyOption(name), optionsFrom: undefined };
|
|
921
|
+
return def.type === 'selection' && optionsList(def.optionsFrom) && loaded ? { ...def, options: loaded, optionsFrom: undefined } : def;
|
|
922
|
+
}
|
|
923
|
+
/** Every option a choice may hold, whatever its conditions: its own, its list's once loaded, or those of the question it carries them from and its own. */
|
|
924
|
+
function everyOption(name, seen = []) {
|
|
925
|
+
const def = page.fields[name];
|
|
926
|
+
if (def?.type !== 'selection')
|
|
927
|
+
return [];
|
|
928
|
+
const carried = optionsField(def.optionsFrom);
|
|
929
|
+
if (carried && !seen.includes(carried.field))
|
|
930
|
+
return [...everyOption(carried.field, [...seen, name]).filter((o) => !o.exclusive), ...def.options];
|
|
931
|
+
return [...((fromList(name) && state.choices[name]?.options) || def.options)];
|
|
932
|
+
}
|
|
933
|
+
// ---- options by condition, and carried from an earlier question (the options part: option-rules.ts) -----------
|
|
934
|
+
/** The options' rules made for this form from the options part, once it came: none before, nor on a page with none. */
|
|
935
|
+
let optionKit = null;
|
|
936
|
+
/**
|
|
937
|
+
* The options' rules, made from their part as it comes — at once where it has come — or null on a page with none, or
|
|
938
|
+
* where the part could not come. Values written before they came are judged as they come: a chosen option the values
|
|
939
|
+
* no longer offer, since the form was made, is taken out and said.
|
|
940
|
+
*/
|
|
941
|
+
function optionsCode() {
|
|
942
|
+
if (optionKit || !hasOptionRules(page))
|
|
943
|
+
return Promise.resolve(optionKit);
|
|
944
|
+
if (optionRulesPart.loaded)
|
|
945
|
+
return Promise.resolve(optionsMade(optionRulesPart.loaded));
|
|
946
|
+
const from = state.values;
|
|
947
|
+
return optionRulesPart.load().then((part) => {
|
|
948
|
+
const kit = optionsMade(part);
|
|
949
|
+
if (kit && !disposed && state.values !== from)
|
|
950
|
+
writeValues(state.values, {}, false, {}, from);
|
|
951
|
+
return kit;
|
|
952
|
+
}, () => null);
|
|
953
|
+
}
|
|
954
|
+
function optionsMade(part) {
|
|
955
|
+
optionKit ??= part.optionRules({ page, table, app, state: () => state, today, about, reading, settle, words: (labels) => takenOutWords(labels) });
|
|
956
|
+
return optionKit;
|
|
957
|
+
}
|
|
958
|
+
if (hasOptionRules(page))
|
|
959
|
+
void track(optionsCode());
|
|
960
|
+
/** A table line's choice's options as they are offered on that line: its list's once loaded, or its own, by their conditions once they came. */
|
|
961
|
+
function lineOffered(lines, line, column, record) {
|
|
962
|
+
if (optionKit)
|
|
963
|
+
return optionKit.lineOffered(lines, line, column, record);
|
|
964
|
+
const sub = page.fields[lines].fields[column];
|
|
965
|
+
return [...((optionsList(sub.optionsFrom) && state.choices[`${lines}.${line.key}.${column}`]?.options) || sub.options)];
|
|
966
|
+
}
|
|
967
|
+
/** Options in words, as a sentence joins them: "Garden and Pool". */
|
|
968
|
+
function listedLabels(labels) {
|
|
969
|
+
try {
|
|
970
|
+
return new Intl.ListFormat(messages.locale, { type: 'conjunction' }).format(labels);
|
|
971
|
+
}
|
|
972
|
+
catch {
|
|
973
|
+
return labels.join(', ');
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* What is said of options taken out of an answer, by their labels — an answer they show (`{branch}`) as it reads now:
|
|
978
|
+
* "Garden is no longer offered, so it was taken out".
|
|
979
|
+
*/
|
|
980
|
+
const takenOutWords = (labels) => fillMessage(messages, labels.length > 1 ? messages.notOfferedNowMany : messages.notOfferedNow, { name: listedLabels(labels.map((label) => (label.includes('{') ? wordsNow(label) : label))) });
|
|
981
|
+
/** The options each note of `takenOut` names, by its path: a note goes once none of them is still out. */
|
|
982
|
+
const takenOutOf = new Map();
|
|
983
|
+
/**
|
|
984
|
+
* The notes of options taken out (`FormState.takenOut`) that are still true for the values and the choices now: one
|
|
985
|
+
* whose options are all offered again — the type that offers them picked again, the treatment ticked again above, the
|
|
986
|
+
* app's list asked again offering it — or picked again goes; one with some still out names those. A list being asked
|
|
987
|
+
* again says nothing yet. The same notes, when none changed.
|
|
988
|
+
*/
|
|
989
|
+
function takenOutTrue() {
|
|
990
|
+
let kept = null;
|
|
991
|
+
for (const path of Object.keys(state.takenOut)) {
|
|
992
|
+
const options = takenOutOf.get(path);
|
|
993
|
+
const held = valueAt(state.values, path);
|
|
994
|
+
if (!options || held === gone || state.choices[path]?.loading)
|
|
995
|
+
continue;
|
|
996
|
+
const offered = form.offered(path);
|
|
997
|
+
if (!offered)
|
|
998
|
+
continue;
|
|
999
|
+
const chosen = [held].flat();
|
|
1000
|
+
const left = options.filter((option) => !chosen.includes(option.value) && !offered.some((one) => one.value === option.value));
|
|
1001
|
+
if (left.length === options.length)
|
|
1002
|
+
continue;
|
|
1003
|
+
kept ??= { ...state.takenOut };
|
|
1004
|
+
if (left.length) {
|
|
1005
|
+
takenOutOf.set(path, left);
|
|
1006
|
+
kept[path] = takenOutWords(left.map((option) => option.label));
|
|
1007
|
+
}
|
|
1008
|
+
else
|
|
1009
|
+
delete kept[path];
|
|
1010
|
+
}
|
|
1011
|
+
return kept ?? state.takenOut;
|
|
1012
|
+
}
|
|
1013
|
+
/** A line's field as its value is checked: its choices from the app's list, those loaded for its line. */
|
|
1014
|
+
function checkedLine(path, def) {
|
|
1015
|
+
const loaded = def.type === 'selection' && optionsList(def.optionsFrom) ? state.choices[path]?.options : null;
|
|
1016
|
+
return loaded ? { ...def, options: loaded, optionsFrom: undefined } : def;
|
|
708
1017
|
}
|
|
709
1018
|
/** A properties field's problems, each at its property's path (`field.property`), as its row shows them. */
|
|
710
1019
|
function propertyProblems(name) {
|
|
@@ -723,12 +1032,57 @@ function innerForm(options, within, place, outer) {
|
|
|
723
1032
|
promise.then(done, done);
|
|
724
1033
|
return promise;
|
|
725
1034
|
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Words with each `{field}` showing the value `values` hold (the form's now, unless given), as the app's viewer
|
|
1037
|
+
* writes it (`valueWords`), else plainly; `other` answers a name first (an ending's `{id}`). A name that is no field
|
|
1038
|
+
* shows nothing.
|
|
1039
|
+
*/
|
|
1040
|
+
function wordsNow(text, values = state.values, other) {
|
|
1041
|
+
if (!text.includes('{'))
|
|
1042
|
+
return text;
|
|
1043
|
+
return fillValues(text, (name) => {
|
|
1044
|
+
const own = other?.(name);
|
|
1045
|
+
if (own !== undefined)
|
|
1046
|
+
return own;
|
|
1047
|
+
const def = page.fields[name];
|
|
1048
|
+
if (!def)
|
|
1049
|
+
return '';
|
|
1050
|
+
return options.valueWords ? options.valueWords(def, values[name], values) : wordsOfValue(def, values[name]);
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Each ending's condition, read once — with Fieldia's functions and the app's own, as every condition of the page —
|
|
1055
|
+
* null for the default (no `when`), and one that does not read never holds.
|
|
1056
|
+
*/
|
|
1057
|
+
const endingConditions = (page.endings ?? []).map((ending) => {
|
|
1058
|
+
if (ending.when === undefined)
|
|
1059
|
+
return null;
|
|
1060
|
+
try {
|
|
1061
|
+
return compileModifier(ending.when, table);
|
|
1062
|
+
}
|
|
1063
|
+
catch {
|
|
1064
|
+
return compileModifier(false);
|
|
1065
|
+
}
|
|
1066
|
+
});
|
|
1067
|
+
/** The ending for the response sent: the first whose condition holds on it — its answers, what the source added, its id — else the default. */
|
|
1068
|
+
function endingNow() {
|
|
1069
|
+
const sent = state.sent;
|
|
1070
|
+
const endings = page.endings;
|
|
1071
|
+
if (!sent || !endings?.length)
|
|
1072
|
+
return null;
|
|
1073
|
+
const values = sent.values;
|
|
1074
|
+
const context = recordContext(values, page.fields, { ...about(), recordId: sent.id });
|
|
1075
|
+
// An app's function that asks its server is asked as any condition asks it: it holds once answered.
|
|
1076
|
+
const env = expressionEnv(values, page.fields, today, app);
|
|
1077
|
+
const at = endingConditions.findIndex((condition) => !condition || condition.evaluate(context, env));
|
|
1078
|
+
return at === -1 ? null : endings[at];
|
|
1079
|
+
}
|
|
726
1080
|
/** The values as expressions read them, and what else they read: the record's id, the person, the lines' rows, today. */
|
|
727
1081
|
function reading() {
|
|
728
1082
|
if (contextCache?.values !== state.values || contextCache.recordId !== state.recordId || contextCache.editing !== editingNow()) {
|
|
729
1083
|
const values = state.values;
|
|
730
1084
|
const context = recordContext(values, page.fields, about());
|
|
731
|
-
contextCache = { values, recordId: state.recordId, editing: editingNow(), context, env: expressionEnv(values, page.fields, today) };
|
|
1085
|
+
contextCache = { values, recordId: state.recordId, editing: editingNow(), context, env: expressionEnv(values, page.fields, today, app) };
|
|
732
1086
|
}
|
|
733
1087
|
return contextCache;
|
|
734
1088
|
}
|
|
@@ -766,6 +1120,10 @@ function innerForm(options, within, place, outer) {
|
|
|
766
1120
|
if ((node.kind === 'field' || node.kind === 'form') && (can.edit === false || (node.field !== undefined && can.readonlyFields?.includes(node.field) === true)))
|
|
767
1121
|
readonly = true;
|
|
768
1122
|
}
|
|
1123
|
+
// An answer a signature kept signed: locked until the signature is taken away and signed again.
|
|
1124
|
+
const answer = answerOf(node);
|
|
1125
|
+
if (answer !== undefined && signedNow().has(answer))
|
|
1126
|
+
readonly = true;
|
|
769
1127
|
return {
|
|
770
1128
|
invisible,
|
|
771
1129
|
readonly: readonly || (def !== undefined && lockedField(def)),
|
|
@@ -773,6 +1131,17 @@ function innerForm(options, within, place, outer) {
|
|
|
773
1131
|
...(node.pressed ? { pressed: node.pressed.evaluate(ctx, env) } : {}),
|
|
774
1132
|
};
|
|
775
1133
|
}
|
|
1134
|
+
/** The answer a field node shows, by its field — or a saved form placed on the page, by the name its answers are kept under. */
|
|
1135
|
+
function answerOf(node) {
|
|
1136
|
+
return node.kind === 'field' ? node.field : node.kind === 'form' ? node.source.name : undefined;
|
|
1137
|
+
}
|
|
1138
|
+
/** The answers signatures signed, as the values hold them now: worked out once for each change of the values. */
|
|
1139
|
+
let signedCache = null;
|
|
1140
|
+
function signedNow() {
|
|
1141
|
+
if (signedCache?.values !== state.values)
|
|
1142
|
+
signedCache = { values: state.values, answers: signedBy(page, state.values) };
|
|
1143
|
+
return signedCache.answers;
|
|
1144
|
+
}
|
|
776
1145
|
/** Field nodes — or saved forms placed on the page — inside `root` (or the whole page), visible right now; `field`'s alone, when named. */
|
|
777
1146
|
function visibleFieldNodes(root, kind = 'field', field) {
|
|
778
1147
|
const inside = (node) => {
|
|
@@ -801,7 +1170,7 @@ function innerForm(options, within, place, outer) {
|
|
|
801
1170
|
return {};
|
|
802
1171
|
const name = node.field;
|
|
803
1172
|
const def = page.fields[name];
|
|
804
|
-
const label = node.source.label ?? def.label;
|
|
1173
|
+
const label = wordsNow(node.source.label ?? def.label);
|
|
805
1174
|
const { context: ctx, env } = reading();
|
|
806
1175
|
return checkRules(def, label, state.values[name], rules, { context: ctx, env, now: options.now?.() ?? new Date(), messages });
|
|
807
1176
|
}
|
|
@@ -814,10 +1183,35 @@ function innerForm(options, within, place, outer) {
|
|
|
814
1183
|
/** The widget a field is shown with where it keeps its value its own way (a per cent): the first of its nodes'. */
|
|
815
1184
|
const shownWidget = (shown) => shown.map((node) => node.source.widget).find((widget) => widget === 'percentage');
|
|
816
1185
|
/** A field node's error now: its field's own rules first, then its answer rules. */
|
|
1186
|
+
/** A path's field's label: a field's, or a line's cell's (`field.lineKey.subfield`). */
|
|
1187
|
+
function labelOfPath(path) {
|
|
1188
|
+
const parts = path.split('.');
|
|
1189
|
+
const def = page.fields[parts[0]];
|
|
1190
|
+
if (parts.length >= 3 && def?.type === 'one2many')
|
|
1191
|
+
return def.fields[parts[parts.length - 1]]?.label ?? path;
|
|
1192
|
+
return def?.label ?? path;
|
|
1193
|
+
}
|
|
817
1194
|
function nodeError(node) {
|
|
818
1195
|
const name = node.field;
|
|
819
1196
|
return unticked(node) ?? checkInput(page.fields[name], node.source, state.values[name], messages) ?? checkValue(checked(name), state.values[name], nodeState(node.id).required, messages, today(), node.source.widget) ?? ruleCheck(node).error;
|
|
820
1197
|
}
|
|
1198
|
+
/** What a check would refuse now (`collectErrors`), for the state it was found for. */
|
|
1199
|
+
let refusals = null;
|
|
1200
|
+
/**
|
|
1201
|
+
* Whether the form refuses the answer at a path — a field's, or a table line's cell (`field.lineKey.subfield`) — as a
|
|
1202
|
+
* check would now: one it shows that holds a value its rules do not take (under its least, past today, a pattern not
|
|
1203
|
+
* met, an answer rule's error). An empty answer is none, required or not: there is nothing worked out from it to wait.
|
|
1204
|
+
*/
|
|
1205
|
+
function refusedAt(path) {
|
|
1206
|
+
if (refusals?.state !== state)
|
|
1207
|
+
refusals = { state, errors: collectErrors() };
|
|
1208
|
+
if (!refusals.errors[path])
|
|
1209
|
+
return false;
|
|
1210
|
+
const parts = path.split('.');
|
|
1211
|
+
const def = page.fields[parts[0]];
|
|
1212
|
+
const held = valueAt(state.values, path);
|
|
1213
|
+
return held !== gone && !isEmpty((parts.length > 2 && def?.type === 'one2many' ? def.fields[parts[parts.length - 1]] : def), held);
|
|
1214
|
+
}
|
|
821
1215
|
/** Warnings for the visible fields of the page, without publishing them. */
|
|
822
1216
|
function collectWarnings() {
|
|
823
1217
|
const warnings = {};
|
|
@@ -862,7 +1256,7 @@ function innerForm(options, within, place, outer) {
|
|
|
862
1256
|
return undefined;
|
|
863
1257
|
const at = (v) => (def.type === 'datetime' ? Date.parse(v) : Date.parse(v.slice(0, 10)));
|
|
864
1258
|
if (at(value) < at(start))
|
|
865
|
-
return fillMessage(messages, messages.endBeforeStart, { end: def.label, start: page.fields[node.field].label });
|
|
1259
|
+
return fillMessage(messages, messages.endBeforeStart, { end: wordsNow(def.label), start: wordsNow(page.fields[node.field].label) });
|
|
866
1260
|
return undefined;
|
|
867
1261
|
}
|
|
868
1262
|
/** Errors for the visible fields under `root`, without publishing them. */
|
|
@@ -900,7 +1294,7 @@ function innerForm(options, within, place, outer) {
|
|
|
900
1294
|
const cell = ruled[sub];
|
|
901
1295
|
if (cell?.invisible || (tables.has(node.id) && tables.get(node.id).compiled.hidden(sub, reading().context, reading().env, userRoles)))
|
|
902
1296
|
continue;
|
|
903
|
-
const lineMessage = checkValue(subDef, line.values[sub], subDef.required === true || cell?.required === true, messages, today(), node.source.cells?.[sub]?.widget);
|
|
1297
|
+
const lineMessage = checkValue(checkedLine(`${name}.${line.key}.${sub}`, subDef), line.values[sub], subDef.required === true || cell?.required === true, messages, today(), node.source.cells?.[sub]?.widget);
|
|
904
1298
|
if (lineMessage)
|
|
905
1299
|
errors[`${name}.${line.key}.${sub}`] = lineMessage;
|
|
906
1300
|
}
|
|
@@ -911,6 +1305,16 @@ function innerForm(options, within, place, outer) {
|
|
|
911
1305
|
for (const [path, unread] of Object.entries(state.unread))
|
|
912
1306
|
if (seen.has(path.split('.')[0]))
|
|
913
1307
|
errors[path] = unread.message;
|
|
1308
|
+
// A value an app's function is asked for answers for its field: still asked, or why it did not come.
|
|
1309
|
+
for (const [path, found] of Object.entries(state.asked)) {
|
|
1310
|
+
if (!seen.has(path.split('.')[0]) || errors[path])
|
|
1311
|
+
continue;
|
|
1312
|
+
const label = labelOfPath(path);
|
|
1313
|
+
errors[path] = found.failed === undefined ? fillMessage(messages, messages.stillWorkedOut, { label }) : fillMessage(messages, messages.notWorkedOut, { label, problem: found.failed });
|
|
1314
|
+
}
|
|
1315
|
+
// A choice held whose places filled up since it was picked: never sent, said under it.
|
|
1316
|
+
if (limitsKit)
|
|
1317
|
+
Object.assign(errors, limitsKit.fullErrors(seen, errors));
|
|
914
1318
|
// A saved form placed here answers for its fields by its own page's rules.
|
|
915
1319
|
for (const node of visibleFieldNodes(root, 'form')) {
|
|
916
1320
|
const part = attached.get(node.id);
|
|
@@ -935,6 +1339,13 @@ function innerForm(options, within, place, outer) {
|
|
|
935
1339
|
const line = (values[field] ?? []).find((l) => l.key === key);
|
|
936
1340
|
return line ? line.values[sub] : gone;
|
|
937
1341
|
}
|
|
1342
|
+
/** A value — a field's, or a table line's by its cell's path — the same in both: a line that is gone, none. */
|
|
1343
|
+
function sameAt(a, b, path) {
|
|
1344
|
+
if (!path.includes('.'))
|
|
1345
|
+
return a[path] === b[path];
|
|
1346
|
+
const now = valueAt(a, path);
|
|
1347
|
+
return now !== gone && JSON.stringify(now ?? null) === JSON.stringify(valueAt(b, path) ?? null);
|
|
1348
|
+
}
|
|
938
1349
|
/** Unread text whose field has since been written another way — a value typed that reads, the app's — is let go. */
|
|
939
1350
|
function unreadKept(values) {
|
|
940
1351
|
let kept = null;
|
|
@@ -975,7 +1386,7 @@ function innerForm(options, within, place, outer) {
|
|
|
975
1386
|
const value = valueAt(state.values, path);
|
|
976
1387
|
if (!sub || value === gone || isEmpty(sub, value))
|
|
977
1388
|
return undefined;
|
|
978
|
-
return checkValue(sub, value, false, messages, today());
|
|
1389
|
+
return checkValue(checkedLine(path, sub), value, false, messages, today());
|
|
979
1390
|
}
|
|
980
1391
|
/**
|
|
981
1392
|
* Answers changed from outside a saved form — loaded, put back, set — handed
|
|
@@ -1004,25 +1415,77 @@ function innerForm(options, within, place, outer) {
|
|
|
1004
1415
|
* few rounds at most, so rules that set each other cannot run forever.
|
|
1005
1416
|
*/
|
|
1006
1417
|
function settle(written) {
|
|
1007
|
-
let
|
|
1418
|
+
let asked = new Map();
|
|
1419
|
+
let values = computed.apply(written, asked);
|
|
1008
1420
|
for (let round = 0; round < 8; round++) {
|
|
1009
1421
|
const result = setWhen.apply(values, holding);
|
|
1010
1422
|
holding = result.holding;
|
|
1011
1423
|
if (result.values === values)
|
|
1012
1424
|
break;
|
|
1013
|
-
|
|
1425
|
+
asked = new Map();
|
|
1426
|
+
values = computed.apply(result.values, asked);
|
|
1014
1427
|
}
|
|
1428
|
+
askedNow = asked;
|
|
1015
1429
|
return values;
|
|
1016
1430
|
}
|
|
1017
1431
|
/** Values to start again from, as loaded or restored: conditions holding in them hold already, and set nothing. */
|
|
1018
1432
|
function startFrom(values) {
|
|
1019
|
-
const
|
|
1433
|
+
const asked = new Map();
|
|
1434
|
+
const worked = computed.apply(values, asked);
|
|
1435
|
+
askedNow = asked;
|
|
1020
1436
|
holding = setWhen.holding(worked);
|
|
1021
1437
|
return worked;
|
|
1022
1438
|
}
|
|
1023
|
-
/**
|
|
1024
|
-
|
|
1025
|
-
|
|
1439
|
+
/**
|
|
1440
|
+
* An app's function answered: the values worked out again with its answer, and the record as loaded with them, so
|
|
1441
|
+
* an answer is never a change of the person's. Values no one has changed start again from it — no rule starts to
|
|
1442
|
+
* hold on what only came late — and changed ones settle as any change does.
|
|
1443
|
+
*/
|
|
1444
|
+
function answered() {
|
|
1445
|
+
baseline = computed.apply(baseline);
|
|
1446
|
+
if (state.dirty.length)
|
|
1447
|
+
return writeValues(state.values);
|
|
1448
|
+
const values = startFrom(state.values);
|
|
1449
|
+
set({ values, dirty: dirtyFields(values) });
|
|
1450
|
+
}
|
|
1451
|
+
/** Every answer on its way, and those that come of them, waited for: what a save does before it checks. */
|
|
1452
|
+
async function asksSettled() {
|
|
1453
|
+
while (asking.size)
|
|
1454
|
+
await Promise.all([...asking]);
|
|
1455
|
+
}
|
|
1456
|
+
/** Answers that failed asked again — a save's try — and waited for. */
|
|
1457
|
+
async function askAgain() {
|
|
1458
|
+
let failed = false;
|
|
1459
|
+
for (const [key, found] of answers) {
|
|
1460
|
+
if (found === 'asking' || found.failed === undefined)
|
|
1461
|
+
continue;
|
|
1462
|
+
answers.delete(key);
|
|
1463
|
+
failed = true;
|
|
1464
|
+
}
|
|
1465
|
+
if (failed)
|
|
1466
|
+
writeValues(state.values);
|
|
1467
|
+
await asksSettled();
|
|
1468
|
+
}
|
|
1469
|
+
/**
|
|
1470
|
+
* Write values someone or something changed. `fresh` values are a starting point instead (a restored draft). `said`:
|
|
1471
|
+
* options taken out of an answer by the write, by path, with their words (`FormState.takenOut`); `from`, the values
|
|
1472
|
+
* those the write no longer offers were offered in (the form's now, unless said).
|
|
1473
|
+
*/
|
|
1474
|
+
function writeValues(written, extra = {}, fresh = false, said = {}, from = state.values) {
|
|
1475
|
+
let settled = fresh ? startFrom(written) : settle(written);
|
|
1476
|
+
// A choice written again says no more what was taken out of it — a line's, nor once its line is gone; options a
|
|
1477
|
+
// change no longer offers are taken out now.
|
|
1478
|
+
let takenOut = fresh ? {} : { ...Object.fromEntries(Object.entries(state.takenOut).filter(([path]) => sameAt(written, state.values, path))), ...said };
|
|
1479
|
+
const out = fresh || !optionKit ? null : optionKit.takeOut(from, settled);
|
|
1480
|
+
if (out) {
|
|
1481
|
+
settled = out.values;
|
|
1482
|
+
takenOut = { ...takenOut, ...out.said };
|
|
1483
|
+
for (const [path, gone] of Object.entries(out.gone))
|
|
1484
|
+
takenOutOf.set(path, gone);
|
|
1485
|
+
}
|
|
1486
|
+
if (Object.keys(takenOut).length || Object.keys(state.takenOut).length)
|
|
1487
|
+
extra = { takenOut, ...extra };
|
|
1488
|
+
const values = syncParts(settled, fresh ? 'fresh' : 'edit');
|
|
1026
1489
|
// Text left unread in a box goes once its field is written another way, and its words with it.
|
|
1027
1490
|
const unread = unreadKept(values);
|
|
1028
1491
|
const before = state;
|
|
@@ -1048,6 +1511,8 @@ function innerForm(options, within, place, outer) {
|
|
|
1048
1511
|
}
|
|
1049
1512
|
if (Object.keys(words).length)
|
|
1050
1513
|
errors = { ...errors, ...words };
|
|
1514
|
+
// A change someone made: a line's choice its columns no longer offer is cleared (followLines); a draft restored is none.
|
|
1515
|
+
edit = !fresh;
|
|
1051
1516
|
set({ values, dirty: dirtyFields(values), errors, warnings: withValues(values, collectWarnings), unread, ...extra });
|
|
1052
1517
|
}
|
|
1053
1518
|
/** Once errors are on screen, keep them current as the person fixes things. */
|
|
@@ -1070,24 +1535,84 @@ function innerForm(options, within, place, outer) {
|
|
|
1070
1535
|
kept[key] ??= unstoredNow[key];
|
|
1071
1536
|
return kept;
|
|
1072
1537
|
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Whether drafts are kept on the app's server: its source keeps them, and the page offers "Continue later" (or the
|
|
1540
|
+
* form continues one by its key). A page without either keeps its drafts where it always did.
|
|
1541
|
+
*/
|
|
1542
|
+
const onServer = () => !!options.dataSource?.saveDraft && !!options.dataSource.loadDraft && (page.continueLater === true || !!options.resume);
|
|
1543
|
+
/** Whether drafts are kept: the app gave a store, or they are kept on the server. */
|
|
1544
|
+
const draftsOn = () => !!options.drafts || onServer();
|
|
1545
|
+
/** The key of the draft kept on the server for the record shown; null until the source gave one. */
|
|
1546
|
+
let serverKey = null;
|
|
1547
|
+
/** Counted each time the draft is let go (sent, discarded, another record shown): a keeping answered after is dropped. */
|
|
1548
|
+
let draftEpoch = 0;
|
|
1549
|
+
/** The draft kept on the server last asked to be kept: the next waits for it, so it carries the key it gave. */
|
|
1550
|
+
let draftGoing = Promise.resolve();
|
|
1551
|
+
/** How many drafts are on their way to the server. */
|
|
1552
|
+
let keeping = 0;
|
|
1553
|
+
/** The draft found as the form opened, offered to restore (`state.draft`). */
|
|
1554
|
+
let found = null;
|
|
1555
|
+
/** The key the form was given to continue from (`resume`), until it is opened. */
|
|
1556
|
+
let resumeKey = outer ? undefined : options.resume;
|
|
1073
1557
|
function scheduleDraft() {
|
|
1074
|
-
|
|
1075
|
-
if (!drafts)
|
|
1558
|
+
if (!draftsOn())
|
|
1076
1559
|
return;
|
|
1077
1560
|
if (draftTimer !== null)
|
|
1078
1561
|
scheduler.clearTimeout(draftTimer);
|
|
1079
1562
|
draftTimer = scheduler.setTimeout(() => {
|
|
1080
1563
|
draftTimer = null;
|
|
1081
|
-
//
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1564
|
+
// On the server, a failure is kept in the browser's store instead, where there is one: the form goes on.
|
|
1565
|
+
void track(keepDraft(false).catch(() => keepHere(draftNow())));
|
|
1566
|
+
}, options.drafts?.delayMs ?? (onServer() ? 1500 : 400));
|
|
1567
|
+
}
|
|
1568
|
+
/** The draft of what is typed now: the answers, the wizard's step and the steps passed over, text that does not read. */
|
|
1569
|
+
function draftNow() {
|
|
1570
|
+
// Where files are stored apart, never a file's bytes: they would fill the browser's store (uploads.ts). Without, kept as always.
|
|
1571
|
+
const values = options.dataSource?.upload ? draftOf(state.values) : structuredCopy(state.values);
|
|
1572
|
+
return {
|
|
1573
|
+
values,
|
|
1574
|
+
...(steps.length ? { step: state.step, skipped: [...state.skipped] } : {}),
|
|
1575
|
+
...(Object.keys(state.unread).length ? { unread: structuredCopy(state.unread) } : {}),
|
|
1576
|
+
answered: Object.keys(fields).filter((name) => state.dirty.includes(name)),
|
|
1577
|
+
savedAt: new Date(clock()).toISOString(),
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
/** A draft in the browser's store, where the app gave one: a store that is full keeps none. */
|
|
1581
|
+
function keepHere(kept) {
|
|
1582
|
+
try {
|
|
1583
|
+
options.drafts?.store.setItem(storeKey(), JSON.stringify(kept));
|
|
1584
|
+
}
|
|
1585
|
+
catch {
|
|
1586
|
+
// The draft is a convenience: the form goes on without it.
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* Keep what is typed now: on the server where the source keeps drafts — one at a time, each carrying the key the last
|
|
1591
|
+
* was given; its key in the browser's store — else in the browser's store. The server's answer, or null.
|
|
1592
|
+
*/
|
|
1593
|
+
function keepDraft(later) {
|
|
1594
|
+
const draft = draftNow();
|
|
1595
|
+
const source = options.dataSource;
|
|
1596
|
+
if (!onServer() || !source?.saveDraft) {
|
|
1597
|
+
keepHere(draft);
|
|
1598
|
+
return Promise.resolve(null);
|
|
1599
|
+
}
|
|
1600
|
+
const shown = shownNow();
|
|
1601
|
+
const epoch = draftEpoch;
|
|
1602
|
+
keeping++;
|
|
1603
|
+
const going = draftGoing.then(() => source.saveDraft({ pageId: page.id, model: page.data.kind === 'record' ? page.data.model : '', recordId: state.recordId, key: epoch === draftEpoch ? serverKey : null, draft, ...(later ? { later } : {}) }));
|
|
1604
|
+
draftGoing = going.then(() => void keeping--, () => void keeping--);
|
|
1605
|
+
return going.then((saved) => {
|
|
1606
|
+
// Kept for a record no longer shown, or for answers sent or let go meanwhile: the source has it; nothing is laid here.
|
|
1607
|
+
if (!shown() || epoch !== draftEpoch)
|
|
1608
|
+
return saved;
|
|
1609
|
+
serverKey = saved.key;
|
|
1610
|
+
if (state.resume?.key !== saved.key || state.resume.missing)
|
|
1611
|
+
set({ resume: { key: saved.key } });
|
|
1612
|
+
keepHere({ savedAt: draft.savedAt, key: saved.key });
|
|
1613
|
+
emit('draft', { key: saved.key, savedAt: draft.savedAt, later, saved });
|
|
1614
|
+
return saved;
|
|
1615
|
+
});
|
|
1091
1616
|
}
|
|
1092
1617
|
/** The values with a draft's over them: a field it left out — a file's bytes — as the record holds it, in a saved form placed here too. */
|
|
1093
1618
|
function withDraft(kept) {
|
|
@@ -1099,32 +1624,144 @@ function innerForm(options, within, place, outer) {
|
|
|
1099
1624
|
}
|
|
1100
1625
|
return values;
|
|
1101
1626
|
}
|
|
1627
|
+
/** A draft laid on the form: its answers as a starting point, its wizard step (or the nearest before it that applies), its text that does not read. */
|
|
1628
|
+
function applyDraft(draft) {
|
|
1629
|
+
found = null;
|
|
1630
|
+
writeValues(withDraft(draft.values ?? {}), { draft: null }, true);
|
|
1631
|
+
const known = (draft.skipped ?? []).filter((id) => steps.includes(id));
|
|
1632
|
+
// Text typed that did not read stays as typed, said as it was, where its field is still on the page.
|
|
1633
|
+
const unread = Object.fromEntries(Object.entries(draft.unread ?? {}).filter(([path]) => !!page.fields[path.split('.')[0]] && typeof draft.unread?.[path]?.text === 'string'));
|
|
1634
|
+
const patch = {
|
|
1635
|
+
...(steps.length ? { skipped: known, step: resumeStep(steps, form.steps(), draft.step) } : {}),
|
|
1636
|
+
...(Object.keys(unread).length ? { unread: { ...state.unread, ...unread } } : {}),
|
|
1637
|
+
// Its boxes were left with it: why each does not read is said at once, as it was where it was typed.
|
|
1638
|
+
...(Object.keys(unread).length ? { errors: { ...state.errors, ...Object.fromEntries(Object.entries(unread).map(([path, kept]) => [path, kept.message])) } } : {}),
|
|
1639
|
+
};
|
|
1640
|
+
if (Object.keys(patch).length)
|
|
1641
|
+
set(patch);
|
|
1642
|
+
}
|
|
1102
1643
|
function forgetDraft() {
|
|
1103
1644
|
if (draftTimer !== null)
|
|
1104
1645
|
scheduler.clearTimeout(draftTimer);
|
|
1105
1646
|
draftTimer = null;
|
|
1106
|
-
|
|
1647
|
+
found = null;
|
|
1648
|
+
draftEpoch++;
|
|
1649
|
+
serverKey = null;
|
|
1650
|
+
if (state.resume)
|
|
1651
|
+
set({ resume: null });
|
|
1652
|
+
options.drafts?.store.removeItem(storeKey());
|
|
1653
|
+
}
|
|
1654
|
+
/** A draft found: laid at once (`restore: "auto"`, or a draft continued from its key over nothing typed), else offered. */
|
|
1655
|
+
function offer(draft, auto = options.drafts?.restore === 'auto') {
|
|
1656
|
+
// What the person typed while it was asked for is theirs: the draft is offered, never laid over it.
|
|
1657
|
+
if (auto && !state.dirty.length && !Object.keys(state.unread).length)
|
|
1658
|
+
return applyDraft(draft);
|
|
1659
|
+
found = draft;
|
|
1660
|
+
set({ draft: { savedAt: draft.savedAt } });
|
|
1107
1661
|
}
|
|
1662
|
+
/**
|
|
1663
|
+
* The draft kept for the record shown, offered as it opens: the one the form was given to continue from (`resume`),
|
|
1664
|
+
* else the browser's store's — on the server by its key, or in the store. A draft asked of the server is laid only
|
|
1665
|
+
* on the record it was asked for.
|
|
1666
|
+
*/
|
|
1108
1667
|
function offerDraft() {
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1668
|
+
const source = options.dataSource;
|
|
1669
|
+
const given = resumeKey;
|
|
1670
|
+
resumeKey = undefined;
|
|
1671
|
+
const kept = given ? null : draftRead(options.drafts?.store.getItem(storeKey()) ?? null);
|
|
1672
|
+
if (!given && !kept)
|
|
1111
1673
|
return;
|
|
1112
|
-
|
|
1113
|
-
|
|
1674
|
+
if (kept && !('key' in kept))
|
|
1675
|
+
return offer(kept);
|
|
1676
|
+
const key = given ?? kept.key;
|
|
1677
|
+
if (!source?.loadDraft || !onServer())
|
|
1114
1678
|
return;
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1679
|
+
const shown = shownNow();
|
|
1680
|
+
if (given)
|
|
1681
|
+
set({ status: 'loading' });
|
|
1682
|
+
return track(source.loadDraft({ pageId: page.id, key }).then((draft) => {
|
|
1683
|
+
if (!shown())
|
|
1684
|
+
return;
|
|
1685
|
+
if (given)
|
|
1686
|
+
set({ status: 'ready' });
|
|
1687
|
+
if (!draft) {
|
|
1688
|
+
// Sent, or gone: the form starts empty, and says so where it was asked to continue it.
|
|
1689
|
+
options.drafts?.store.removeItem(storeKey());
|
|
1690
|
+
if (given)
|
|
1691
|
+
set({ resume: { key, missing: true } });
|
|
1692
|
+
return;
|
|
1693
|
+
}
|
|
1694
|
+
serverKey = key;
|
|
1695
|
+
set({ resume: { key } });
|
|
1696
|
+
offer(draft, given ? true : undefined);
|
|
1697
|
+
}, (error) => {
|
|
1698
|
+
if (shown() && given)
|
|
1699
|
+
set({ status: 'error', error: error?.message ?? String(error) });
|
|
1700
|
+
}));
|
|
1701
|
+
}
|
|
1702
|
+
// ---- when the page takes answers, and each choice's places (the limits part: form-limits.ts) --------------------
|
|
1703
|
+
/** The limits made for this form from the limits part, once it came: none before, nor on a page with neither limits nor places. */
|
|
1704
|
+
let limitsKit = null;
|
|
1705
|
+
/** Whether the record shown was loaded once: its counts are asked then, its own choices not counted against it. */
|
|
1706
|
+
let loadedOnce = false;
|
|
1707
|
+
/** Whether the form keeps limits: a page with them or with places of its own, or a list's choices that came with places. */
|
|
1708
|
+
const keepsLimits = () => !outer && (hasLimits(page) || Object.values(state.choices).some((choices) => choices.options?.some((option) => option.seats !== undefined)));
|
|
1709
|
+
/**
|
|
1710
|
+
* The limits, made from their part as it comes — at once where it has come — shown, and asked of the source as the
|
|
1711
|
+
* form opens (or once its record is loaded); null where the form keeps none, or the part could not come: the source's
|
|
1712
|
+
* submit decides then.
|
|
1713
|
+
*/
|
|
1714
|
+
function limitsCode() {
|
|
1715
|
+
if (limitsKit || !keepsLimits())
|
|
1716
|
+
return Promise.resolve(limitsKit);
|
|
1717
|
+
if (formLimitsPart.loaded)
|
|
1718
|
+
return Promise.resolve(limitsMade(formLimitsPart.loaded));
|
|
1719
|
+
return formLimitsPart.load().then(limitsMade, () => null);
|
|
1720
|
+
}
|
|
1721
|
+
function limitsMade(part) {
|
|
1722
|
+
if (limitsKit || disposed)
|
|
1723
|
+
return limitsKit;
|
|
1724
|
+
const kit = part.formLimits({
|
|
1725
|
+
page,
|
|
1726
|
+
dataSource: options.dataSource,
|
|
1727
|
+
user: options.user,
|
|
1728
|
+
messages,
|
|
1729
|
+
scheduler,
|
|
1730
|
+
state: () => state,
|
|
1731
|
+
set,
|
|
1732
|
+
clock,
|
|
1733
|
+
started: () => started,
|
|
1734
|
+
shownNow,
|
|
1735
|
+
generation: () => generation,
|
|
1736
|
+
replaced: () => named(messages.recordReplacedNoun, messages.recordReplaced),
|
|
1737
|
+
listened: () => listeners.size > 0,
|
|
1738
|
+
disposed: () => disposed,
|
|
1739
|
+
refuse(name, message) {
|
|
1740
|
+
// Said until the field changes from what it holds, as a refused save's words are.
|
|
1741
|
+
serverErrors[name] = { message, value: JSON.stringify(state.values[name] ?? null) };
|
|
1742
|
+
set({ errors: { ...state.errors, [name]: message } });
|
|
1743
|
+
},
|
|
1744
|
+
});
|
|
1745
|
+
limitsKit = kit;
|
|
1746
|
+
kit.show();
|
|
1747
|
+
if (kit.asks() && (state.recordId == null || loadedOnce))
|
|
1748
|
+
void track(kit.ask());
|
|
1749
|
+
return kit;
|
|
1750
|
+
}
|
|
1751
|
+
/** Ask the source's `limits` again and show what it tells; without the limits part, nothing to ask. */
|
|
1752
|
+
const askLimits = () => (limitsKit ? limitsKit.ask() : Promise.resolve());
|
|
1753
|
+
/** Whether the form asks the source for counts. */
|
|
1754
|
+
const asksLimits = () => !!limitsKit?.asks();
|
|
1755
|
+
/**
|
|
1756
|
+
* Whether the page takes these answers now, asked of the source again just before they go — the limits part waited
|
|
1757
|
+
* for where the form keeps limits: why not, as a save's problem, or null.
|
|
1758
|
+
*/
|
|
1759
|
+
async function stillTaking(asked) {
|
|
1760
|
+
const kit = await limitsCode();
|
|
1761
|
+
return kit ? kit.stillTaking(asked) : null;
|
|
1127
1762
|
}
|
|
1763
|
+
/** A choice of a full option, picked by the person, refused under its field: the field keeps what it held. */
|
|
1764
|
+
const refusedFull = (name, value) => !!limitsKit?.refusedFull(name, value);
|
|
1128
1765
|
function scheduleAutosave() {
|
|
1129
1766
|
const autosave = options.autosave;
|
|
1130
1767
|
// A record the person may not change is never saved unasked: it would only be refused.
|
|
@@ -1265,6 +1902,20 @@ function innerForm(options, within, place, outer) {
|
|
|
1265
1902
|
await waiting;
|
|
1266
1903
|
if (asked !== generation)
|
|
1267
1904
|
return elsewhere();
|
|
1905
|
+
// Options by condition waited for where they have not come: what is saved never holds one they would take out.
|
|
1906
|
+
if (!optionKit && hasOptionRules(page)) {
|
|
1907
|
+
await optionsCode();
|
|
1908
|
+
if (asked !== generation)
|
|
1909
|
+
return elsewhere();
|
|
1910
|
+
}
|
|
1911
|
+
// Values the app's functions are asked for are waited for — those that failed asked again — so what is saved is worked out.
|
|
1912
|
+
if (asking.size || Object.values(state.asked).some((found) => found.failed !== undefined)) {
|
|
1913
|
+
set({ status: 'saving', error: null, saveProblem: null });
|
|
1914
|
+
await askAgain();
|
|
1915
|
+
if (asked !== generation)
|
|
1916
|
+
return elsewhere();
|
|
1917
|
+
set({ status: 'ready' });
|
|
1918
|
+
}
|
|
1268
1919
|
// Files still on their way are waited for first — a saved form's placed here too: the state says how many, so the page can say why it waits.
|
|
1269
1920
|
if (filesGoing()) {
|
|
1270
1921
|
set({ status: 'saving', error: null, saveProblem: null });
|
|
@@ -1286,6 +1937,10 @@ function innerForm(options, within, place, outer) {
|
|
|
1286
1937
|
return { reason: 'save', ...(before.message !== undefined ? { message: before.message } : {}) };
|
|
1287
1938
|
}
|
|
1288
1939
|
}
|
|
1940
|
+
// Whether the page still takes answers — its dates, its counts asked again — and each choice held still has room.
|
|
1941
|
+
const refused = await stillTaking(asked);
|
|
1942
|
+
if (refused)
|
|
1943
|
+
return refused;
|
|
1289
1944
|
// A file that did not reach the store stops it, under its field, with the form's own checks.
|
|
1290
1945
|
const errors = { ...collectErrors(), ...fileProblems() };
|
|
1291
1946
|
if (Object.keys(errors).length) {
|
|
@@ -1295,6 +1950,13 @@ function innerForm(options, within, place, outer) {
|
|
|
1295
1950
|
const source = options.dataSource;
|
|
1296
1951
|
serverErrors = {};
|
|
1297
1952
|
set({ status: 'saving', errors: {}, error: null, saveProblem: null, conflict: null });
|
|
1953
|
+
// A draft being kept on the server goes first, so the send names the draft it ends; none is kept after it.
|
|
1954
|
+
if (draftTimer !== null)
|
|
1955
|
+
scheduler.clearTimeout(draftTimer);
|
|
1956
|
+
draftTimer = null;
|
|
1957
|
+
if (keeping)
|
|
1958
|
+
await draftGoing;
|
|
1959
|
+
const draft = serverKey ? { draft: serverKey } : {};
|
|
1298
1960
|
/** The generation the record was in when this save went to the source. */
|
|
1299
1961
|
let at = generation;
|
|
1300
1962
|
try {
|
|
@@ -1313,8 +1975,10 @@ function innerForm(options, within, place, outer) {
|
|
|
1313
1975
|
const sent = shownValues();
|
|
1314
1976
|
const before = state.values;
|
|
1315
1977
|
at = generation;
|
|
1978
|
+
const resetAt = resets;
|
|
1316
1979
|
const seen = botReport();
|
|
1317
|
-
|
|
1980
|
+
// What the source answered: the id it gave the response, and the values it added — what an ending reads.
|
|
1981
|
+
const answer = (await source.submit({ pageId: page.id, values: sent, ...(seen ? { bot: seen } : {}), ...draft })) ?? {};
|
|
1318
1982
|
// The captcha's token is spent once sent: the next send waits for a new one.
|
|
1319
1983
|
if (seen?.captcha)
|
|
1320
1984
|
bot.captcha = null;
|
|
@@ -1324,8 +1988,13 @@ function innerForm(options, within, place, outer) {
|
|
|
1324
1988
|
forgetDraft();
|
|
1325
1989
|
// What it sent is what an answer changed since is told against: still to send.
|
|
1326
1990
|
sentAs = before;
|
|
1327
|
-
|
|
1991
|
+
const added = answer.values && typeof answer.values === 'object' ? structuredCopy(answer.values) : {};
|
|
1992
|
+
// Started again meanwhile (`reset`): a new response is on screen, and no ending is the old one's.
|
|
1993
|
+
set({ status: 'saved', unsent: unsentNow(), ...(resets === resetAt ? { sent: { id: answer.id ?? null, values: { ...structuredCopy(sent), ...added } } } : {}) });
|
|
1328
1994
|
emit('send', { values: sent, ...(seen ? { bot: seen } : {}) });
|
|
1995
|
+
// Counted again: one response fewer to take, this person's sent.
|
|
1996
|
+
if (asksLimits())
|
|
1997
|
+
void track(askLimits());
|
|
1329
1998
|
void track(moment('on.afterSave', page.on?.afterSave, chain, false));
|
|
1330
1999
|
return null;
|
|
1331
2000
|
}
|
|
@@ -1343,6 +2012,7 @@ function innerForm(options, within, place, outer) {
|
|
|
1343
2012
|
values: sentValues(),
|
|
1344
2013
|
// The version it was opened at, for a source that refuses a save over someone else's.
|
|
1345
2014
|
...(state.recordId != null && state.version ? { version: state.version } : {}),
|
|
2015
|
+
...draft,
|
|
1346
2016
|
});
|
|
1347
2017
|
// Answered for a record no longer shown — another opened, or this one loaded again: the source has it, and the
|
|
1348
2018
|
// form lays nothing of it over the record it shows now.
|
|
@@ -1618,7 +2288,11 @@ function innerForm(options, within, place, outer) {
|
|
|
1618
2288
|
return;
|
|
1619
2289
|
// Lines load in their tables' orders; where a person moves them after, they stay.
|
|
1620
2290
|
baseline = syncParts(startFrom(ordered({ ...initialValues(fields, today()), ...loaded })), 'start');
|
|
1621
|
-
set({ status: 'ready', values: structuredCopy(baseline), dirty: [], errors: {}, warnings: withValues(baseline, collectWarnings), version: version ?? null, can: can ?? null, unread: {} });
|
|
2291
|
+
set({ status: 'ready', values: structuredCopy(baseline), dirty: [], errors: {}, warnings: withValues(baseline, collectWarnings), version: version ?? null, can: can ?? null, unread: {}, takenOut: {} });
|
|
2292
|
+
// Each choice's places, for this record: its own choices are its own.
|
|
2293
|
+
loadedOnce = true;
|
|
2294
|
+
if (asksLimits())
|
|
2295
|
+
void track(askLimits());
|
|
1622
2296
|
if (again)
|
|
1623
2297
|
return;
|
|
1624
2298
|
offerDraft();
|
|
@@ -1647,7 +2321,11 @@ function innerForm(options, within, place, outer) {
|
|
|
1647
2321
|
told = null;
|
|
1648
2322
|
showing = false;
|
|
1649
2323
|
clearFiles();
|
|
1650
|
-
|
|
2324
|
+
// The draft kept for the record shown before is that one's.
|
|
2325
|
+
found = null;
|
|
2326
|
+
serverKey = null;
|
|
2327
|
+
draftEpoch++;
|
|
2328
|
+
const fresh = { dirty: [], errors: {}, warning: null, warningField: null, error: null, draft: null, step: steps[0] ?? null, skipped: [], saveProblem: null, version: null, can: null, conflict: null, setAside: null, unsent: [], unread: {}, takenOut: {}, resume: null };
|
|
1651
2329
|
if (id != null) {
|
|
1652
2330
|
set({ ...fresh, recordId: id, status: 'idle' });
|
|
1653
2331
|
await load();
|
|
@@ -1657,6 +2335,8 @@ function innerForm(options, within, place, outer) {
|
|
|
1657
2335
|
baseline = startFrom(startingValues(true, false));
|
|
1658
2336
|
const values = syncParts(structuredCopy(baseline), 'start');
|
|
1659
2337
|
set({ ...fresh, recordId: null, status: 'ready', values, warnings: withValues(values, collectWarnings) });
|
|
2338
|
+
if (asksLimits())
|
|
2339
|
+
void track(askLimits());
|
|
1660
2340
|
offerDraft();
|
|
1661
2341
|
await opening();
|
|
1662
2342
|
return true;
|
|
@@ -2017,10 +2697,18 @@ function innerForm(options, within, place, outer) {
|
|
|
2017
2697
|
}
|
|
2018
2698
|
const form = {
|
|
2019
2699
|
page,
|
|
2700
|
+
...(table ? { functions: table } : {}),
|
|
2020
2701
|
getState: () => state,
|
|
2021
2702
|
subscribe(listener) {
|
|
2022
2703
|
listeners.add(listener);
|
|
2023
|
-
|
|
2704
|
+
// Listened to: the page opening or closing is said as it comes.
|
|
2705
|
+
if (listeners.size === 1)
|
|
2706
|
+
limitsKit?.heard(true);
|
|
2707
|
+
return () => {
|
|
2708
|
+
listeners.delete(listener);
|
|
2709
|
+
if (!listeners.size)
|
|
2710
|
+
limitsKit?.heard(false);
|
|
2711
|
+
};
|
|
2024
2712
|
},
|
|
2025
2713
|
load() {
|
|
2026
2714
|
const go = letGo();
|
|
@@ -2028,6 +2716,9 @@ function innerForm(options, within, place, outer) {
|
|
|
2028
2716
|
},
|
|
2029
2717
|
setValue(name, value, how) {
|
|
2030
2718
|
fieldDef(name);
|
|
2719
|
+
// A choice whose places are all taken is shown, and refused when the person picks it: said under its field.
|
|
2720
|
+
if ((how?.by ?? 'person') === 'person' && refusedFull(name, value))
|
|
2721
|
+
return;
|
|
2031
2722
|
writeValues({ ...state.values, [name]: structuredCopy(value) });
|
|
2032
2723
|
afterEdit(name);
|
|
2033
2724
|
changed(name, how?.by ?? 'person');
|
|
@@ -2053,13 +2744,38 @@ function innerForm(options, within, place, outer) {
|
|
|
2053
2744
|
// Nothing of the record changed; what shows of it may have.
|
|
2054
2745
|
set({});
|
|
2055
2746
|
},
|
|
2056
|
-
fieldReadonly: (name) => lockedField(fieldDef(name)) || state.can?.edit === false || state.can?.readonlyFields?.includes(name) === true,
|
|
2057
|
-
loadChoices,
|
|
2747
|
+
fieldReadonly: (name) => lockedField(fieldDef(name)) || state.can?.edit === false || state.can?.readonlyFields?.includes(name) === true || signedNow().has(name),
|
|
2748
|
+
loadChoices: (field) => loadChoices(field),
|
|
2058
2749
|
loadDefinitions,
|
|
2059
2750
|
addDefinition,
|
|
2751
|
+
lineChoices(field, key, subfield, values = {}) {
|
|
2752
|
+
const one = listedAt(field, subfield);
|
|
2753
|
+
const line = key === null ? one && { values: newLineValues(field) } : lineAt(field, key);
|
|
2754
|
+
if (!one || !line)
|
|
2755
|
+
throw new Error(`"${field}.${key}.${subfield}" is no line's choice from the app's lists`);
|
|
2756
|
+
return track(askLine(one, { ...line.values, ...values }));
|
|
2757
|
+
},
|
|
2758
|
+
offered(name) {
|
|
2759
|
+
const cell = cellOf(name);
|
|
2760
|
+
if (!cell)
|
|
2761
|
+
return page.fields[name]?.type === 'selection' ? (optionKit ? optionKit.offered(name, state.values, reading()) : everyOption(name)) : null;
|
|
2762
|
+
const lines = page.fields[cell.table];
|
|
2763
|
+
const line = lineAt(cell.table, cell.key);
|
|
2764
|
+
return lines?.type === 'one2many' && lines.fields[cell.column]?.type === 'selection' && line ? lineOffered(cell.table, line, cell.column, reading().context) : null;
|
|
2765
|
+
},
|
|
2766
|
+
offersChange(name) {
|
|
2767
|
+
const cell = cellOf(name);
|
|
2768
|
+
const lines = cell ? page.fields[cell.table] : undefined;
|
|
2769
|
+
return changesOptions(cell ? (lines?.type === 'one2many' ? lines.fields[cell.column] : undefined) : page.fields[name]);
|
|
2770
|
+
},
|
|
2060
2771
|
waitsFor(name) {
|
|
2772
|
+
// What it is worked out from first: an answer that does not read, or that the form refuses, is never asked about.
|
|
2061
2773
|
const from = workedOut.get(name);
|
|
2062
|
-
|
|
2774
|
+
const waits = from ? waitingOn(page, from, state.values, state.unread, refusedAt) : null;
|
|
2775
|
+
if (waits)
|
|
2776
|
+
return waits;
|
|
2777
|
+
const found = state.asked[name];
|
|
2778
|
+
return found ? { field: name, asking: true, ...(found.failed !== undefined ? { failed: found.failed } : {}) } : null;
|
|
2063
2779
|
},
|
|
2064
2780
|
problem(name) {
|
|
2065
2781
|
fieldDef(name);
|
|
@@ -2139,6 +2855,9 @@ function innerForm(options, within, place, outer) {
|
|
|
2139
2855
|
save: () => track(save()),
|
|
2140
2856
|
canUpload: () => typeof options.dataSource?.upload === 'function',
|
|
2141
2857
|
today,
|
|
2858
|
+
now: () => options.now?.() ?? new Date(),
|
|
2859
|
+
user: () => options.user ?? null,
|
|
2860
|
+
shownFields: () => [...new Set([...visibleFieldNodes(), ...visibleFieldNodes(undefined, 'form')].map((node) => answerOf(node)).filter((name) => !!name))],
|
|
2142
2861
|
recordReads: (id, values, fields) => recordContext(values, fields ?? page.fields, { recordId: id, user: options.user, editing: false, context: options.context }),
|
|
2143
2862
|
canFindSlots: () => typeof options.dataSource?.slots === 'function',
|
|
2144
2863
|
findSlots(field, ask) {
|
|
@@ -2173,6 +2892,22 @@ function innerForm(options, within, place, outer) {
|
|
|
2173
2892
|
const others = (matches ?? []).filter((match) => match && String(match.id) !== String(recordId));
|
|
2174
2893
|
return others.every((match) => typeof match.score === 'number') ? others.sort((a, b) => b.score - a.score) : others;
|
|
2175
2894
|
},
|
|
2895
|
+
keepsNotDuplicates: () => !!(page.data.kind === 'record' && options.dataSource?.notDuplicates && options.dataSource.markNotDuplicate),
|
|
2896
|
+
async notDuplicates() {
|
|
2897
|
+
const [source, model] = recordSource('notDuplicates');
|
|
2898
|
+
const recordId = state.recordId;
|
|
2899
|
+
if (recordId === null)
|
|
2900
|
+
return [];
|
|
2901
|
+
const ids = await source.notDuplicates({ model, recordId });
|
|
2902
|
+
return Array.isArray(ids) ? ids.filter((id) => (typeof id === 'string' || typeof id === 'number') && String(id) !== String(recordId)) : [];
|
|
2903
|
+
},
|
|
2904
|
+
async markNotDuplicate(matchId) {
|
|
2905
|
+
const [source, model] = recordSource('markNotDuplicate');
|
|
2906
|
+
const recordId = state.recordId;
|
|
2907
|
+
if (recordId === null)
|
|
2908
|
+
throw new Error('A new record has no id to keep it by');
|
|
2909
|
+
await source.markNotDuplicate({ model, recordId, matchId });
|
|
2910
|
+
},
|
|
2176
2911
|
canMerge: () => !!(page.data.kind === 'record' && options.dataSource?.merge && options.dataSource.load),
|
|
2177
2912
|
async readRecord(id) {
|
|
2178
2913
|
const [source, model] = recordSource('load');
|
|
@@ -2213,7 +2948,19 @@ function innerForm(options, within, place, outer) {
|
|
|
2213
2948
|
// Started again: a new response, timed from now.
|
|
2214
2949
|
bot = { ...bot, honeypot: false, since: clock() };
|
|
2215
2950
|
const values = syncParts(structuredCopy(baseline), 'start');
|
|
2216
|
-
set({ values, dirty: [], errors: {}, warnings: withValues(values, collectWarnings), warning: null, warningField: null, draft: null, step: steps[0] ?? null, skipped: [], saveProblem: null, conflict: null, unsent: [], unread: {} });
|
|
2951
|
+
set({ values, dirty: [], errors: {}, warnings: withValues(values, collectWarnings), warning: null, warningField: null, draft: null, step: steps[0] ?? null, skipped: [], saveProblem: null, conflict: null, unsent: [], unread: {}, takenOut: {}, sent: null });
|
|
2952
|
+
// Started again: whether the page takes another response, and each choice's places, asked again.
|
|
2953
|
+
if (asksLimits())
|
|
2954
|
+
void track(askLimits());
|
|
2955
|
+
},
|
|
2956
|
+
words: (text) => wordsNow(text),
|
|
2957
|
+
ending: endingNow,
|
|
2958
|
+
endingWords(text) {
|
|
2959
|
+
const sent = state.sent;
|
|
2960
|
+
if (!sent)
|
|
2961
|
+
return wordsNow(text);
|
|
2962
|
+
// The response's id where the page has no field of that name: "Your booking is {id}".
|
|
2963
|
+
return wordsNow(text, sent.values, (name) => (name === 'id' && !page.fields['id'] ? String(sent.id ?? '') : undefined));
|
|
2217
2964
|
},
|
|
2218
2965
|
changes,
|
|
2219
2966
|
addLine: (field, values = {}) => addLine(field, values, 'person'),
|
|
@@ -2474,16 +3221,27 @@ function innerForm(options, within, place, outer) {
|
|
|
2474
3221
|
return () => void heard.delete(listener);
|
|
2475
3222
|
},
|
|
2476
3223
|
restoreDraft() {
|
|
2477
|
-
const
|
|
2478
|
-
if (
|
|
2479
|
-
|
|
2480
|
-
const draft = JSON.parse(raw);
|
|
2481
|
-
writeValues(withDraft(draft.values), { draft: null }, true);
|
|
3224
|
+
const kept = found ?? draftRead(options.drafts?.store.getItem(storeKey()) ?? null);
|
|
3225
|
+
if (kept && 'values' in kept)
|
|
3226
|
+
applyDraft(kept);
|
|
2482
3227
|
},
|
|
2483
3228
|
discardDraft() {
|
|
2484
3229
|
forgetDraft();
|
|
2485
3230
|
set({ draft: null });
|
|
2486
3231
|
},
|
|
3232
|
+
canContinueLater: () => page.continueLater === true && onServer() && page.layout.type !== 'list',
|
|
3233
|
+
async continueLater() {
|
|
3234
|
+
if (!form.canContinueLater())
|
|
3235
|
+
throw new Error('No continueLater, or no saveDraft and loadDraft');
|
|
3236
|
+
// What is typed is read first, as a save reads it: text that does not read is kept as typed, said again as it opens.
|
|
3237
|
+
await (readTyped() ?? Promise.resolve());
|
|
3238
|
+
if (draftTimer !== null)
|
|
3239
|
+
scheduler.clearTimeout(draftTimer);
|
|
3240
|
+
draftTimer = null;
|
|
3241
|
+
const saved = await track(keepDraft(true));
|
|
3242
|
+
return saved;
|
|
3243
|
+
},
|
|
3244
|
+
refreshLimits: () => askLimits(),
|
|
2487
3245
|
async reloadTheirs() {
|
|
2488
3246
|
// A save on its way first: its answer is not dropped by the load.
|
|
2489
3247
|
const asked = shownNow();
|
|
@@ -2610,6 +3368,8 @@ function innerForm(options, within, place, outer) {
|
|
|
2610
3368
|
scheduler,
|
|
2611
3369
|
messages,
|
|
2612
3370
|
now: options.now,
|
|
3371
|
+
// Its words that show its answers read them as this form's do.
|
|
3372
|
+
...(options.valueWords ? { valueWords: options.valueWords } : {}),
|
|
2613
3373
|
}, chain,
|
|
2614
3374
|
// Its files are the record's: stored for it, under the part's name.
|
|
2615
3375
|
{ model: where.model, recordId: where.recordId, under: `${where.under}${part.name}.` },
|
|
@@ -2653,6 +3413,7 @@ function innerForm(options, within, place, outer) {
|
|
|
2653
3413
|
scheduler.clearTimeout(draftTimer);
|
|
2654
3414
|
if (autosaveTimer !== null)
|
|
2655
3415
|
scheduler.clearTimeout(autosaveTimer);
|
|
3416
|
+
limitsKit?.dispose();
|
|
2656
3417
|
listeners.clear();
|
|
2657
3418
|
events.clear();
|
|
2658
3419
|
for (const part of attached.values())
|
|
@@ -2661,11 +3422,16 @@ function innerForm(options, within, place, outer) {
|
|
|
2661
3422
|
};
|
|
2662
3423
|
// A record's starting values may already break a warning rule; nothing listens yet.
|
|
2663
3424
|
state = { ...state, warnings: collectWarnings() };
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
3425
|
+
// When the page takes answers — at once where the limits part has come, else as soon as it does — its counts and each
|
|
3426
|
+
// choice's places as the source tells them: a record's own once it is loaded, its own choices not counted against it.
|
|
3427
|
+
if (keepsLimits())
|
|
3428
|
+
void track(limitsCode());
|
|
3429
|
+
// A new form has its values now — a draft continued from its key once it is laid — and opens once whoever made it
|
|
3430
|
+
// has had the chance to listen.
|
|
3431
|
+
if (state.recordId == null) {
|
|
3432
|
+
const continued = offerDraft();
|
|
3433
|
+
void track(Promise.resolve(continued).then(opening));
|
|
3434
|
+
}
|
|
2669
3435
|
return {
|
|
2670
3436
|
form,
|
|
2671
3437
|
take(values, how) {
|
|
@@ -2675,7 +3441,7 @@ function innerForm(options, within, place, outer) {
|
|
|
2675
3441
|
filed.clear();
|
|
2676
3442
|
baseline = startFrom({ ...initialValues(page.fields, today()), ...structuredCopy(values) });
|
|
2677
3443
|
const start = syncParts(structuredCopy(baseline), 'start');
|
|
2678
|
-
set({ values: start, dirty: [], errors: {}, warnings: withValues(start, collectWarnings), warning: null, warningField: null, unread: {} });
|
|
3444
|
+
set({ values: start, dirty: [], errors: {}, warnings: withValues(start, collectWarnings), warning: null, warningField: null, unread: {}, takenOut: {} });
|
|
2679
3445
|
},
|
|
2680
3446
|
errorsNow: () => collectErrors(),
|
|
2681
3447
|
typing: typingNow,
|
|
@@ -2699,6 +3465,8 @@ function innerForm(options, within, place, outer) {
|
|
|
2699
3465
|
const sameHow = (a, b) => !!a.changes === !!b.changes && !!a.discard === !!b.discard;
|
|
2700
3466
|
/** Two lists of names the same, in the same order. */
|
|
2701
3467
|
const sameList = (a, b) => a.length === b.length && a.every((name, i) => name === b[i]);
|
|
3468
|
+
/** Whether what waits for an app's answer is the same as before: the same paths, each waiting or failed for the same reason. */
|
|
3469
|
+
const sameAsked = (shown, now) => Object.keys(shown).length === now.size && [...now].every(([path, found]) => shown[path] !== undefined && shown[path].failed === found.failed);
|
|
2702
3470
|
/** A file on its way in a saved form placed in another, as that one names it: its id and its field under the part's name. */
|
|
2703
3471
|
function underPart(name, upload) {
|
|
2704
3472
|
return { ...upload, id: `${name}/${upload.id}`, ...(upload.line ? { line: { ...upload.line, field: `${name}.${upload.line.field}` } } : { field: `${name}.${upload.field}` }) };
|
|
@@ -2809,7 +3577,7 @@ function linkOps(before, now) {
|
|
|
2809
3577
|
...before.filter((r) => !has.has(r.id)).map((r) => ({ op: 'unlink', id: r.id })),
|
|
2810
3578
|
];
|
|
2811
3579
|
}
|
|
2812
|
-
function indexLayout(root) {
|
|
3580
|
+
function indexLayout(root, functions) {
|
|
2813
3581
|
const index = new Map();
|
|
2814
3582
|
const add = (source, parent, kind, modifiers) => {
|
|
2815
3583
|
const roles = source.roles;
|
|
@@ -2821,10 +3589,10 @@ function indexLayout(root) {
|
|
|
2821
3589
|
kind,
|
|
2822
3590
|
field: modifiers.field,
|
|
2823
3591
|
...(roles?.length ? { roles } : {}),
|
|
2824
|
-
invisible: compileModifier(modifiers.invisible),
|
|
2825
|
-
readonly: compileModifier(modifiers.readonly),
|
|
2826
|
-
required: compileModifier(modifiers.required),
|
|
2827
|
-
...(pressed !== undefined ? { pressed: compileModifier(pressed) } : {}),
|
|
3592
|
+
invisible: compileModifier(modifiers.invisible, functions),
|
|
3593
|
+
readonly: compileModifier(modifiers.readonly, functions),
|
|
3594
|
+
required: compileModifier(modifiers.required, functions),
|
|
3595
|
+
...(pressed !== undefined ? { pressed: compileModifier(pressed, functions) } : {}),
|
|
2828
3596
|
...(does.length ? { does } : {}),
|
|
2829
3597
|
source,
|
|
2830
3598
|
});
|