@sealcode/sealgen 0.18.8 → 0.19.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/.eslintrc.cjs +7 -2
- package/.xunit +75 -0
- package/@types/add-crud.d.sync-conflict-20250918-184311-TFDLWFG.ts +1 -0
- package/@types/builders/colors-builder.d.sync-conflict-20250918-184323-TFDLWFG.ts +10 -0
- package/@types/builders/colors-builder.d.ts +1 -1
- package/@types/builders/fonts-builder.d.sync-conflict-20250918-184322-TFDLWFG.ts +7 -0
- package/@types/builders/fonts-builder.d.ts +1 -1
- package/@types/controllers/table-add-button.d.ts +6 -0
- package/@types/controllers/table-add-button.stimulus.d.ts +6 -0
- package/@types/crud-field-snippets.d.sync-conflict-20250918-184323-TFDLWFG.ts +1 -0
- package/@types/crud-field-snippets.d.ts +1 -3
- package/@types/forms/controls/array.d.sync-conflict-20250918-184306-TFDLWFG.ts +33 -0
- package/@types/forms/controls/array.d.ts +1 -2
- package/@types/forms/controls/array.sync-conflict-20250918-222045-TFDLWFG.d.ts +33 -0
- package/@types/forms/controls/autocomplete.d.sync-conflict-20250918-222042-TFDLWFG.ts +22 -0
- package/@types/forms/controls/autocomplete.d.ts +1 -1
- package/@types/forms/controls/checkbox-group.d.sync-conflict-20250918-184319-TFDLWFG.ts +21 -0
- package/@types/forms/controls/checkbox-group.d.ts +3 -3
- package/@types/forms/controls/checkboxed-list-input.d.sync-conflict-20250918-184323-TFDLWFG.ts +21 -0
- package/@types/forms/controls/checkboxed-list-input.d.ts +3 -3
- package/@types/forms/controls/controls.d.ts +2 -2
- package/@types/forms/controls/derived-frame.d.sync-conflict-20250918-184314-TFDLWFG.ts +19 -0
- package/@types/forms/controls/derived-frame.d.ts +0 -1
- package/@types/forms/controls/dropdown.d.sync-conflict-20250918-222044-TFDLWFG.ts +30 -0
- package/@types/forms/controls/dropdown.d.ts +1 -1
- package/@types/forms/controls/file.d.sync-conflict-20250918-222045-TFDLWFG.ts +13 -0
- package/@types/forms/controls/file.d.ts +1 -2
- package/@types/forms/controls/form-control.d.sync-conflict-20250918-184322-TFDLWFG.ts +19 -0
- package/@types/forms/controls/form-control.d.sync-conflict-20250918-222046-TFDLWFG.ts +19 -0
- package/@types/forms/controls/form-control.d.ts +7 -3
- package/@types/forms/controls/image.d.ts +19 -0
- package/@types/forms/controls/image.test.d.ts +1 -0
- package/@types/forms/controls/multiple-files.d.sync-conflict-20250918-184318-TFDLWFG.ts +42 -0
- package/@types/forms/controls/multiple-files.d.ts +3 -0
- package/@types/forms/controls/multiple-images.d.ts +19 -0
- package/@types/forms/controls/number.d.sync-conflict-20250918-222046-TFDLWFG.ts +13 -0
- package/@types/forms/controls/number.d.ts +1 -1
- package/@types/forms/controls/photo.d.sync-conflict-20250918-184321-TFDLWFG.ts +19 -0
- package/@types/forms/controls/photo.d.ts +3 -5
- package/@types/forms/controls/simple-input.d.sync-conflict-20250918-184310-TFDLWFG.ts +33 -0
- package/@types/forms/controls/simple-input.d.sync-conflict-20250918-222042-TFDLWFG.ts +33 -0
- package/@types/forms/controls/simple-input.d.ts +5 -4
- package/@types/forms/controls/simple-input.sync-conflict-20250918-222045-TFDLWFG.d.ts +33 -0
- package/@types/forms/controls/single-reference.d.ts +3 -2
- package/@types/forms/controls/table.d.sync-conflict-20250918-184302-TFDLWFG.ts +39 -0
- package/@types/forms/controls/table.d.ts +8 -2
- package/@types/forms/controls/table.sync-conflict-20250918-222042-TFDLWFG.d.ts +39 -0
- package/@types/forms/controls/textarea.d.sync-conflict-20250918-222045-TFDLWFG.ts +25 -0
- package/@types/forms/controls/textarea.d.ts +3 -3
- package/@types/forms/fields/boolean.d.sync-conflict-20250918-184325-TFDLWFG.ts +22 -0
- package/@types/forms/fields/boolean.d.ts +6 -1
- package/@types/forms/fields/boolean.sync-conflict-20250918-222042-TFDLWFG.d.ts +22 -0
- package/@types/forms/fields/checkboxed-list.d.sync-conflict-20250918-184325-TFDLWFG.ts +23 -0
- package/@types/forms/fields/checkboxed-list.d.ts +3 -1
- package/@types/forms/fields/collection-field.d.sync-conflict-20250918-184319-TFDLWFG.ts +22 -0
- package/@types/forms/fields/collection-field.d.sync-conflict-20250918-222047-TFDLWFG.ts +22 -0
- package/@types/forms/fields/collection-field.d.ts +8 -1
- package/@types/forms/fields/color.d.ts +4 -0
- package/@types/forms/fields/coordinates.d.sync-conflict-20250918-222044-TFDLWFG.ts +14 -0
- package/@types/forms/fields/coordinates.d.ts +14 -0
- package/@types/forms/fields/date.d.ts +13 -0
- package/@types/forms/fields/datetime.d.sync-conflict-20250918-222050-TFDLWFG.ts +4 -0
- package/@types/forms/fields/datetime.d.ts +14 -0
- package/@types/forms/fields/deep-reverse-single-reference-list.d.ts +24 -0
- package/@types/forms/fields/deep-reverse-single-reference-table.d.ts +16 -0
- package/@types/forms/fields/email.d.sync-conflict-20250918-184303-TFDLWFG.ts +8 -0
- package/@types/forms/fields/email.d.ts +3 -0
- package/@types/forms/fields/enum-multiple-sealious.d.ts +16 -0
- package/@types/forms/fields/enum-multiple-sealious.sync-conflict-20250918-222047-TFDLWFG.d.ts +16 -0
- package/@types/forms/fields/field.d.sync-conflict-20250918-184306-TFDLWFG.ts +70 -0
- package/@types/forms/fields/field.d.ts +37 -5
- package/@types/forms/fields/fields.d.sync-conflict-20250918-184314-TFDLWFG.ts +29 -0
- package/@types/forms/fields/fields.d.ts +23 -8
- package/@types/forms/fields/file.d.sync-conflict-20250918-184310-TFDLWFG.ts +23 -0
- package/@types/forms/fields/file.d.sync-conflict-20250918-222046-TFDLWFG.ts +23 -0
- package/@types/forms/fields/file.d.ts +11 -5
- package/@types/forms/fields/file.sync-conflict-20250918-222049-TFDLWFG.d.ts +23 -0
- package/@types/forms/fields/float.d.ts +4 -0
- package/@types/forms/fields/get-field-for-sealious.d.sync-conflict-20250918-222046-TFDLWFG.ts +29 -0
- package/@types/forms/fields/get-field-for-sealious.d.ts +31 -0
- package/@types/forms/fields/get-field-for-sealious.sync-conflict-20250918-222042-TFDLWFG.d.ts +29 -0
- package/@types/forms/fields/html.d.ts +6 -0
- package/@types/forms/fields/image.d.sync-conflict-20250918-222042-TFDLWFG.ts +5 -0
- package/@types/forms/fields/image.d.ts +5 -0
- package/@types/forms/fields/int.d.ts +6 -0
- package/@types/forms/fields/json.d.ts +13 -0
- package/@types/forms/fields/markdown.d.ts +6 -0
- package/@types/forms/fields/multiple-files.d.sync-conflict-20250918-184304-TFDLWFG.ts +16 -0
- package/@types/forms/fields/multiple-files.d.ts +3 -1
- package/@types/forms/fields/number.d.sync-conflict-20250918-184317-TFDLWFG.ts +25 -0
- package/@types/forms/fields/number.d.sync-conflict-20250918-222047-TFDLWFG.ts +25 -0
- package/@types/forms/fields/number.d.ts +3 -1
- package/@types/forms/fields/password.d.ts +6 -0
- package/@types/forms/fields/pick-from-list-sealious.d.ts +11 -0
- package/@types/forms/fields/pick-from-list.d.sync-conflict-20250918-184322-TFDLWFG.ts +15 -0
- package/@types/forms/fields/pick-from-list.d.ts +4 -3
- package/@types/forms/fields/proxy-field.d.sync-conflict-20250918-184307-TFDLWFG.ts +15 -0
- package/@types/forms/fields/proxy-field.d.ts +3 -1
- package/@types/forms/fields/regexp.d.sync-conflict-20250918-184305-TFDLWFG.ts +21 -0
- package/@types/forms/fields/regexp.d.sync-conflict-20250918-222045-TFDLWFG.ts +21 -0
- package/@types/forms/fields/regexp.d.ts +6 -1
- package/@types/forms/fields/regexp.sync-conflict-20250918-222047-TFDLWFG.d.ts +21 -0
- package/@types/forms/fields/simple-form-field.d.sync-conflict-20250918-184309-TFDLWFG.ts +29 -0
- package/@types/forms/fields/simple-form-field.d.sync-conflict-20250918-222044-TFDLWFG.ts +29 -0
- package/@types/forms/fields/simple-form-field.d.ts +23 -3
- package/@types/forms/fields/simple-form-field.sync-conflict-20250918-222049-TFDLWFG.d.ts +29 -0
- package/@types/forms/fields/single-reference.d.ts +19 -0
- package/@types/forms/fields/single-reference.sync-conflict-20250918-222043-TFDLWFG.d.ts +10 -0
- package/@types/forms/fields/structured-array.d.sync-conflict-20250918-184302-TFDLWFG.ts +27 -0
- package/@types/forms/fields/structured-array.d.sync-conflict-20250918-222049-TFDLWFG.ts +27 -0
- package/@types/forms/fields/structured-array.d.ts +19 -10
- package/@types/forms/fields/structured-array.sync-conflict-20250918-222047-TFDLWFG.d.ts +27 -0
- package/@types/forms/fields/table.d.sync-conflict-20250918-184303-TFDLWFG.ts +16 -0
- package/@types/forms/fields/table.d.ts +3 -0
- package/@types/forms/fields/text.d.ts +6 -0
- package/@types/forms/fields/url.d.ts +6 -0
- package/@types/forms/form-types.d.sync-conflict-20250918-222045-TFDLWFG.ts +26 -0
- package/@types/forms/form-types.d.ts +2 -0
- package/@types/forms/form.d.sync-conflict-20250918-184315-TFDLWFG.ts +32 -0
- package/@types/forms/form.d.sync-conflict-20250918-222049-TFDLWFG.ts +32 -0
- package/@types/forms/form.d.ts +10 -7
- package/@types/forms/form.sync-conflict-20250918-222049-TFDLWFG.d.ts +33 -0
- package/@types/forms/form.test.d.sync-conflict-20250918-184318-TFDLWFG.ts +6 -0
- package/@types/forms/form.test.d.sync-conflict-20250918-222047-TFDLWFG.ts +6 -0
- package/@types/forms/form.test.d.ts +2 -2
- package/@types/forms/multiform.d.sync-conflict-20250918-184308-TFDLWFG.ts +23 -0
- package/@types/forms/multiform.d.ts +1 -1
- package/@types/forms/multiform.sync-conflict-20250918-222044-TFDLWFG.d.ts +23 -0
- package/@types/index.d.sync-conflict-20250918-184316-TFDLWFG.ts +46 -0
- package/@types/index.d.ts +2 -2
- package/@types/mount.d.sync-conflict-20250918-184320-TFDLWFG.ts +6 -0
- package/@types/page/list.d.sync-conflict-20250918-184318-TFDLWFG.ts +48 -0
- package/@types/page/list.d.sync-conflict-20250918-222046-TFDLWFG.ts +48 -0
- package/@types/page/list.d.ts +2 -2
- package/@types/page/list.sync-conflict-20250918-222048-TFDLWFG.d.ts +48 -0
- package/@types/page/mountable-with-fields.d.sync-conflict-20250918-184321-TFDLWFG.ts +42 -0
- package/@types/page/mountable-with-fields.d.sync-conflict-20250918-222046-TFDLWFG.ts +42 -0
- package/@types/page/mountable-with-fields.d.ts +3 -3
- package/@types/page/mountable-with-fields.sync-conflict-20250918-222044-TFDLWFG.d.ts +42 -0
- package/@types/page/mountable.d.sync-conflict-20250918-184306-TFDLWFG.ts +10 -0
- package/@types/page/page.d.sync-conflict-20250918-184320-TFDLWFG.ts +18 -0
- package/@types/page/props-parser.d.sync-conflict-20250918-184305-TFDLWFG.ts +15 -0
- package/@types/page/props-parser.d.ts +0 -1
- package/@types/page/stateful-page.d.sync-conflict-20250918-184326-TFDLWFG.ts +62 -0
- package/@types/templates/shared/shared-crud-form-fields.d.sync-conflict-20250918-184306-TFDLWFG.ts +1 -0
- package/@types/templates/shared/shared-crud-form-fields.d.ts +0 -67
- package/@types/test_utils/test-on-real-app.d.sync-conflict-20250918-184320-TFDLWFG.ts +26 -0
- package/@types/test_utils/test-on-real-app.d.ts +0 -1
- package/@types/utils/extract-fields-from-collection.d.sync-conflict-20250918-184312-TFDLWFG.ts +18 -0
- package/@types/utils/extract-fields-from-collection.d.ts +5 -1
- package/@types/utils/extract-fields-from-collection.sync-conflict-20250918-222045-TFDLWFG.d.ts +18 -0
- package/@types/utils/wrap-attributes.d.ts +3 -0
- package/README.md +5 -0
- package/assets/file-icon.svg +5 -0
- package/lib/add-crud.js +80 -89
- package/lib/add-list-route.test.js +1 -1
- package/lib/add-route.js +0 -7
- package/lib/build.js +3 -1
- package/lib/cli.js +2 -5
- package/lib/controllers/table-add-button.stimulus.js +35 -0
- package/lib/forms/controls/array.js +20 -16
- package/lib/forms/controls/big-radio-group.js +2 -2
- package/lib/forms/controls/checkbox-group.js +7 -7
- package/lib/forms/controls/checkboxed-list-input.js +9 -2
- package/lib/forms/controls/controls.js +2 -2
- package/lib/forms/controls/derived-frame.js +5 -1
- package/lib/forms/controls/derived.js +1 -1
- package/lib/forms/controls/dropdown.js +4 -1
- package/lib/forms/controls/editable-collection-subset.js +2 -2
- package/lib/forms/controls/file.js +26 -2
- package/lib/forms/controls/file.test.js +2 -2
- package/lib/forms/controls/hidden-input.js +4 -1
- package/lib/forms/controls/{photo.js → image.js} +6 -7
- package/lib/forms/controls/{photo.test.js → image.test.js} +6 -21
- package/lib/forms/controls/multiple-files.js +10 -1
- package/lib/forms/controls/{multiple-photos.js → multiple-images.js} +3 -3
- package/lib/forms/controls/simple-input.js +13 -12
- package/lib/forms/controls/single-reference.js +4 -0
- package/lib/forms/controls/table.js +66 -24
- package/lib/forms/controls/textarea.js +4 -2
- package/lib/forms/controls/tickable.js +13 -5
- package/lib/forms/fields/boolean.js +14 -0
- package/lib/forms/fields/checkboxed-list.js +4 -0
- package/lib/forms/fields/collection-field.js +9 -0
- package/lib/forms/fields/color.js +10 -0
- package/lib/forms/fields/coordinates.js +49 -0
- package/lib/forms/fields/date.js +34 -0
- package/lib/forms/fields/datetime.js +46 -0
- package/lib/forms/fields/deep-reverse-single-reference-list.js +81 -0
- package/lib/forms/fields/deep-reverse-single-reference-table.js +122 -0
- package/lib/forms/fields/email.js +7 -0
- package/lib/forms/fields/enum-multiple-sealious.js +32 -0
- package/lib/forms/fields/field.js +32 -4
- package/lib/forms/fields/field.test.js +5 -5
- package/lib/forms/fields/fields.js +23 -8
- package/lib/forms/fields/file.js +33 -9
- package/lib/forms/fields/file.test.js +4 -16
- package/lib/forms/fields/float.js +10 -0
- package/lib/forms/fields/get-field-for-sealious.js +213 -0
- package/lib/forms/fields/html.js +14 -0
- package/lib/forms/fields/image.js +13 -0
- package/lib/forms/fields/int.js +23 -0
- package/lib/forms/fields/json.js +31 -0
- package/lib/forms/fields/markdown.js +14 -0
- package/lib/forms/fields/multiple-files.js +4 -0
- package/lib/forms/fields/number.js +6 -0
- package/lib/forms/fields/password.js +13 -0
- package/lib/forms/fields/pick-from-list-sealious.js +17 -0
- package/lib/forms/fields/pick-from-list.js +6 -2
- package/lib/forms/fields/proxy-field.js +3 -0
- package/lib/forms/fields/regexp.js +14 -0
- package/lib/forms/fields/simple-form-field.js +60 -2
- package/lib/forms/fields/single-reference.js +44 -0
- package/lib/forms/fields/structured-array.js +63 -12
- package/lib/forms/fields/table.js +28 -1
- package/lib/forms/fields/text.js +17 -0
- package/lib/forms/fields/url.js +17 -0
- package/lib/forms/form.js +30 -13
- package/lib/forms/form.test.js +3 -4
- package/lib/forms/multiform.js +4 -2
- package/lib/forms/multiform.test.js +3 -3
- package/lib/generate-stimulus.js +1 -0
- package/lib/index.js +1 -0
- package/lib/make-hidden-inputs.js +1 -1
- package/lib/mount.js +11 -0
- package/lib/notifier.js +0 -1
- package/lib/page/list.js +15 -8
- package/lib/page/mountable-with-fields.js +14 -6
- package/lib/page/mountable-with-fields.test.js +1 -1
- package/lib/templates/form.js +8 -9
- package/lib/templates/multiform.js +4 -4
- package/lib/templates/page.js +0 -2
- package/lib/templates/shared/collection-create-form.js +28 -40
- package/lib/templates/shared/collection-edit-form.js +40 -77
- package/lib/templates/shared/collection-list.js +12 -20
- package/lib/templates/shared/shared-crud-form-fields.js +27 -95
- package/lib/test_utils/test-on-real-app.js +3 -3
- package/lib/utils/extract-fields-from-collection.js +60 -20
- package/lib/utils/make-slug.js +1 -1
- package/lib/utils/wrap-attributes.js +20 -0
- package/package.json +5 -4
- package/src/add-crud.ts +86 -97
- package/src/add-list-route.test.ts +1 -1
- package/src/add-route.ts +0 -7
- package/src/build.ts +3 -1
- package/src/cli.ts +3 -5
- package/src/controllers/table-add-button.stimulus.ts +35 -0
- package/src/forms/controls/array.ts +23 -20
- package/src/forms/controls/autocomplete.ts +1 -1
- package/src/forms/controls/big-radio-group.ts +2 -2
- package/src/forms/controls/checkbox-group.ts +9 -9
- package/src/forms/controls/checkboxed-list-input.ts +27 -15
- package/src/forms/controls/controls.ts +2 -2
- package/src/forms/controls/derived-frame.ts +5 -1
- package/src/forms/controls/derived.ts +1 -1
- package/src/forms/controls/dropdown.ts +5 -2
- package/src/forms/controls/editable-collection-subset.ts +2 -2
- package/src/forms/controls/file.test.ts +4 -2
- package/src/forms/controls/file.ts +31 -5
- package/src/forms/controls/form-control.ts +7 -2
- package/src/forms/controls/hidden-input.ts +4 -1
- package/src/forms/controls/{photo.test.ts → image.test.ts} +5 -22
- package/src/forms/controls/{photo.ts → image.ts} +3 -5
- package/src/forms/controls/multiple-files.ts +18 -1
- package/src/forms/controls/{multiple-photos.ts → multiple-images.ts} +1 -1
- package/src/forms/controls/number.ts +1 -1
- package/src/forms/controls/simple-input.ts +18 -34
- package/src/forms/controls/single-reference.ts +10 -2
- package/src/forms/controls/table.ts +90 -31
- package/src/forms/controls/textarea.ts +6 -4
- package/src/forms/controls/tickable.ts +13 -5
- package/src/forms/fields/boolean.ts +23 -1
- package/src/forms/fields/checkboxed-list.ts +11 -2
- package/src/forms/fields/collection-field.ts +16 -1
- package/src/forms/fields/color.ts +9 -0
- package/src/forms/fields/coordinates.ts +66 -0
- package/src/forms/fields/date.ts +50 -0
- package/src/forms/fields/datetime.ts +66 -0
- package/src/forms/fields/deep-reverse-single-reference-list.ts +136 -0
- package/src/forms/fields/deep-reverse-single-reference-table.ts +213 -0
- package/src/forms/fields/email.ts +9 -0
- package/src/forms/fields/enum-multiple-sealious.ts +48 -0
- package/src/forms/fields/field.test.ts +5 -5
- package/src/forms/fields/field.ts +94 -8
- package/src/forms/fields/fields.ts +23 -8
- package/src/forms/fields/file.test.ts +4 -16
- package/src/forms/fields/file.ts +43 -15
- package/src/forms/fields/float.ts +9 -0
- package/src/forms/fields/get-field-for-sealious.ts +304 -0
- package/src/forms/fields/html.ts +15 -0
- package/src/forms/fields/image.ts +12 -0
- package/src/forms/fields/int.ts +25 -0
- package/src/forms/fields/json.ts +48 -0
- package/src/forms/fields/markdown.ts +15 -0
- package/src/forms/fields/multiple-files.ts +10 -1
- package/src/forms/fields/number.ts +8 -1
- package/src/forms/fields/password.ts +17 -0
- package/src/forms/fields/pick-from-list-sealious.ts +22 -0
- package/src/forms/fields/pick-from-list.ts +7 -3
- package/src/forms/fields/proxy-field.ts +6 -1
- package/src/forms/fields/regexp.ts +27 -1
- package/src/forms/fields/simple-form-field.ts +95 -7
- package/src/forms/fields/single-reference.ts +62 -0
- package/src/forms/fields/structured-array.ts +115 -18
- package/src/forms/fields/table.ts +32 -1
- package/src/forms/fields/text.ts +18 -0
- package/src/forms/fields/url.ts +20 -0
- package/src/forms/form-types.ts +2 -0
- package/src/forms/form.test.ts +3 -4
- package/src/forms/form.ts +37 -16
- package/src/forms/forms.css +0 -85
- package/src/forms/multiform.test.ts +3 -3
- package/src/forms/multiform.ts +2 -0
- package/src/generate-stimulus.ts +1 -0
- package/src/index.ts +2 -1
- package/src/make-hidden-inputs.ts +1 -1
- package/src/mount.ts +14 -0
- package/src/notifier.ts +0 -1
- package/src/page/list.ts +15 -8
- package/src/page/mountable-with-fields.test.ts +1 -1
- package/src/page/mountable-with-fields.ts +18 -9
- package/src/register-external.ts +1 -1
- package/src/templates/form.ts +8 -9
- package/src/templates/multiform.ts +4 -4
- package/src/templates/page.ts +0 -2
- package/src/templates/shared/collection-create-form.ts +30 -66
- package/src/templates/shared/collection-edit-form.ts +41 -102
- package/src/templates/shared/collection-list.ts +12 -20
- package/src/templates/shared/item-delete.ts +0 -1
- package/src/templates/shared/shared-crud-form-fields.ts +37 -171
- package/src/test_utils/test-on-real-app.ts +4 -3
- package/src/utils/extract-fields-from-collection.ts +76 -25
- package/src/utils/make-slug.ts +1 -1
- package/src/utils/wrap-attributes.ts +17 -0
- package/lib/add-verbose-crud.js +0 -119
- package/lib/crud-field-snippets.js +0 -52
- package/lib/find-css-includes.js +0 -3
- package/lib/forms/controls/reverse-single-reference.js +0 -1
- package/lib/forms/fields/enum-multiple.js +0 -47
- package/lib/forms/fields/enum-multiple.test.js +0 -27
- package/lib/forms/fields/enum.js +0 -41
- package/lib/forms/fields/enum.test.js +0 -21
- package/lib/forms/fields/reverse-single-reference.js +0 -17
- package/lib/templates/shared/handlers/boolean.js +0 -14
- package/lib/templates/shared/handlers/date.js +0 -8
- package/lib/templates/shared/handlers/deep-reverse-single-reference.js +0 -209
- package/lib/templates/shared/handlers/default.js +0 -49
- package/lib/templates/shared/handlers/enum.js +0 -19
- package/lib/templates/shared/handlers/file.js +0 -23
- package/lib/templates/shared/handlers/image.js +0 -32
- package/lib/templates/shared/handlers/int.js +0 -11
- package/lib/templates/shared/handlers/jdd.js +0 -10
- package/lib/templates/shared/handlers/single-reference.js +0 -12
- package/lib/templates/shared/handlers/structured-array.js +0 -33
- package/src/add-verbose-crud.ts +0 -138
- package/src/crud-field-snippets.ts +0 -57
- package/src/find-css-includes.ts +0 -3
- package/src/forms/controls/reverse-single-reference.ts +0 -50
- package/src/forms/fields/enum-multiple.test.ts +0 -31
- package/src/forms/fields/enum-multiple.ts +0 -62
- package/src/forms/fields/enum.test.ts +0 -25
- package/src/forms/fields/enum.ts +0 -56
- package/src/forms/fields/reverse-single-reference.ts +0 -20
- package/src/templates/shared/handlers/boolean.ts +0 -18
- package/src/templates/shared/handlers/date.ts +0 -12
- package/src/templates/shared/handlers/deep-reverse-single-reference.ts +0 -244
- package/src/templates/shared/handlers/default.ts +0 -64
- package/src/templates/shared/handlers/enum.ts +0 -23
- package/src/templates/shared/handlers/file.ts +0 -27
- package/src/templates/shared/handlers/image.ts +0 -45
- package/src/templates/shared/handlers/int.ts +0 -15
- package/src/templates/shared/handlers/jdd.ts +0 -14
- package/src/templates/shared/handlers/single-reference.ts +0 -16
- package/src/templates/shared/handlers/structured-array.ts +0 -42
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { t } from "../../utils/translate.js";
|
|
3
|
+
import { wrapAttribute, wrapKeyName } from "../../utils/wrap-attributes.js";
|
|
3
4
|
function fieldsToShape(obj) {
|
|
4
5
|
return Object.fromEntries(
|
|
5
6
|
Object.entries(obj).map(([key, value]) => [key, value.predicate])
|
|
@@ -11,8 +12,11 @@ class FormField {
|
|
|
11
12
|
this.predicate = predicates.unknown;
|
|
12
13
|
this.mapToFilter = (value) => value;
|
|
13
14
|
}
|
|
14
|
-
async init(
|
|
15
|
-
|
|
15
|
+
async init() {
|
|
16
|
+
}
|
|
17
|
+
setName(name) {
|
|
18
|
+
this.name = name;
|
|
19
|
+
return this;
|
|
16
20
|
}
|
|
17
21
|
async _validate(ctx, value) {
|
|
18
22
|
if (value === "" || value === null || value === void 0) {
|
|
@@ -38,7 +42,7 @@ class FormField {
|
|
|
38
42
|
async isValueValid(_ctx, _value) {
|
|
39
43
|
return { valid: true, message: "" };
|
|
40
44
|
}
|
|
41
|
-
async
|
|
45
|
+
async getParsedValue(ctx, all_form_values, validate = false) {
|
|
42
46
|
const raw = all_form_values[this.name];
|
|
43
47
|
if (raw == void 0 || raw == null || raw == "") {
|
|
44
48
|
return {
|
|
@@ -79,9 +83,33 @@ class FormField {
|
|
|
79
83
|
}
|
|
80
84
|
//return undefined here to delete a value
|
|
81
85
|
async getDatabaseValue(ctx, data) {
|
|
82
|
-
const { parsed } = await this.
|
|
86
|
+
const { parsed } = await this.getParsedValue(ctx, data);
|
|
83
87
|
return parsed;
|
|
84
88
|
}
|
|
89
|
+
getSealiousCreateValue(fctx) {
|
|
90
|
+
throw new Error("This field does not have a default sealious mapping");
|
|
91
|
+
}
|
|
92
|
+
sealiousValueToForm(ctx, sealiousValue, item) {
|
|
93
|
+
throw new Error("This field does not have a default sealious mapping");
|
|
94
|
+
}
|
|
95
|
+
async postSealiousCreate(ctx, created_item, form_data) {
|
|
96
|
+
}
|
|
97
|
+
async postSealiousEdit(ctx, edited_item, form_data) {
|
|
98
|
+
}
|
|
99
|
+
generateFieldDeclaration(field_info, vars) {
|
|
100
|
+
return `new ${vars.form_field_types}.${this.constructor.name}(${String(
|
|
101
|
+
field_info.is_required
|
|
102
|
+
)})`;
|
|
103
|
+
}
|
|
104
|
+
generateCreateValueGetter(field_info, vars) {
|
|
105
|
+
return `${wrapKeyName(field_info.name)}: await ${vars.form_fields}${wrapAttribute(field_info.name)}.getSealiousCreateValue(fctx)`;
|
|
106
|
+
}
|
|
107
|
+
generateInitialValue(field_info, vars) {
|
|
108
|
+
return `${wrapKeyName(field_info.name)}: await ${vars.form_fields}${wrapAttribute(field_info.name)}.sealiousValueToForm(ctx, item.get("${field_info.name}"))`;
|
|
109
|
+
}
|
|
110
|
+
generateImportsForFieldList(field_info) {
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
85
113
|
}
|
|
86
114
|
export {
|
|
87
115
|
FormField,
|
|
@@ -5,7 +5,7 @@ import { mount } from "../../mount.js";
|
|
|
5
5
|
import { Form } from "../form.js";
|
|
6
6
|
import { getBrowser } from "../../utils/browser-creator.js";
|
|
7
7
|
import assert from "assert";
|
|
8
|
-
import {
|
|
8
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
9
9
|
import { SimpleInput } from "../controls/simple-input.js";
|
|
10
10
|
import { Boolean } from "./boolean.js";
|
|
11
11
|
import { Checkbox } from "../controls/checkbox.js";
|
|
@@ -23,7 +23,7 @@ describe("basic field", () => {
|
|
|
23
23
|
const app = new Koa();
|
|
24
24
|
const router = new Router();
|
|
25
25
|
const fields = {
|
|
26
|
-
text: new
|
|
26
|
+
text: new TextBasedSimpleField(true)
|
|
27
27
|
};
|
|
28
28
|
let received_values;
|
|
29
29
|
mount(
|
|
@@ -37,7 +37,7 @@ describe("basic field", () => {
|
|
|
37
37
|
}
|
|
38
38
|
async onSubmit(ctx, data) {
|
|
39
39
|
received_values = await this.getParsedValues(ctx);
|
|
40
|
-
const { parsed: email } = await this.fields.text.
|
|
40
|
+
const { parsed: email } = await this.fields.text.getParsedValue(
|
|
41
41
|
ctx,
|
|
42
42
|
data.raw_values
|
|
43
43
|
);
|
|
@@ -64,7 +64,7 @@ describe("basic field", () => {
|
|
|
64
64
|
let is_value_valid_called = false;
|
|
65
65
|
let parse_called = false;
|
|
66
66
|
const fields = {
|
|
67
|
-
text: new class MockField extends
|
|
67
|
+
text: new class MockField extends TextBasedSimpleField {
|
|
68
68
|
async isValueValid() {
|
|
69
69
|
is_value_valid_called = true;
|
|
70
70
|
return true;
|
|
@@ -109,7 +109,7 @@ describe("basic field", () => {
|
|
|
109
109
|
const router = new Router();
|
|
110
110
|
let submit_called = false;
|
|
111
111
|
const fields = {
|
|
112
|
-
text: new
|
|
112
|
+
text: new TextBasedSimpleField(false),
|
|
113
113
|
checkbox: new Boolean(false)
|
|
114
114
|
};
|
|
115
115
|
mount(
|
|
@@ -1,17 +1,32 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./boolean.js";
|
|
2
2
|
export * from "./checkboxed-list.js";
|
|
3
3
|
export * from "./collection-field.js";
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
4
|
+
export * from "./color.js";
|
|
5
|
+
export * from "./coordinates.js";
|
|
6
|
+
export * from "./date.js";
|
|
7
|
+
export * from "./datetime.js";
|
|
8
|
+
export * from "./deep-reverse-single-reference-list.js";
|
|
9
|
+
export * from "./deep-reverse-single-reference-table.js";
|
|
7
10
|
export * from "./email.js";
|
|
8
|
-
export * from "./enum.js";
|
|
9
|
-
export * from "./boolean.js";
|
|
10
|
-
export * from "./enum-multiple.js";
|
|
11
|
+
export * from "./enum-multiple-sealious.js";
|
|
11
12
|
export * from "./existing-sealious-value.js";
|
|
12
13
|
export * from "./file.js";
|
|
14
|
+
export * from "./float.js";
|
|
15
|
+
export * from "./html.js";
|
|
16
|
+
export * from "./image.js";
|
|
17
|
+
export * from "./int.js";
|
|
18
|
+
export * from "./json.js";
|
|
19
|
+
export * from "./markdown.js";
|
|
13
20
|
export * from "./multiple-files.js";
|
|
14
|
-
export * from "./
|
|
21
|
+
export * from "./number.js";
|
|
22
|
+
export * from "./password.js";
|
|
23
|
+
export * from "./pick-from-list-sealious.js";
|
|
24
|
+
export * from "./pick-from-list.js";
|
|
25
|
+
export * from "./regexp.js";
|
|
26
|
+
export * from "./simple-form-field.js";
|
|
27
|
+
export * from "./single-reference.js";
|
|
15
28
|
export * from "./structured-array.js";
|
|
16
29
|
export * from "./table.js";
|
|
30
|
+
export * from "./text.js";
|
|
31
|
+
export * from "./url.js";
|
|
17
32
|
//# sourceMappingURL=fields.js.map
|
package/lib/forms/fields/file.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { hasFieldOfType, is, predicates } from "@sealcode/ts-predicates";
|
|
2
|
-
import {
|
|
3
|
-
PathFilePointer
|
|
4
|
-
} from "@sealcode/file-manager";
|
|
2
|
+
import { PathFilePointer } from "@sealcode/file-manager";
|
|
5
3
|
import { FormField } from "./field.js";
|
|
4
|
+
import { File as FileControl } from "../controls/file.js";
|
|
6
5
|
class File extends FormField {
|
|
7
|
-
constructor(required
|
|
6
|
+
constructor(required) {
|
|
8
7
|
super(required);
|
|
9
8
|
this.required = required;
|
|
10
|
-
this.file_manager = file_manager;
|
|
11
9
|
}
|
|
12
|
-
async parse(
|
|
10
|
+
async parse(ctx, raw_value) {
|
|
13
11
|
let result;
|
|
14
12
|
if (is(raw_value, predicates.string)) {
|
|
15
|
-
const file = await
|
|
13
|
+
const file = await ctx.$app.fileManager.fromToken(raw_value);
|
|
16
14
|
result = {
|
|
17
15
|
parsed_value: { old: file, new: null },
|
|
18
16
|
error: null,
|
|
@@ -29,7 +27,7 @@ class File extends FormField {
|
|
|
29
27
|
raw_value,
|
|
30
28
|
"old",
|
|
31
29
|
predicates.instanceOf(PathFilePointer)
|
|
32
|
-
) ? await
|
|
30
|
+
) ? await ctx.$app.fileManager.toPointer(
|
|
33
31
|
raw_value.old
|
|
34
32
|
) : null;
|
|
35
33
|
const new_file = hasFieldOfType(
|
|
@@ -49,12 +47,38 @@ class File extends FormField {
|
|
|
49
47
|
return result;
|
|
50
48
|
}
|
|
51
49
|
async getDatabaseValue(ctx, data) {
|
|
52
|
-
const { parsed } = await this.
|
|
50
|
+
const { parsed } = await this.getParsedValue(ctx, data);
|
|
53
51
|
return parsed?.new || void 0;
|
|
54
52
|
}
|
|
55
53
|
getEmptyValue() {
|
|
56
54
|
return { old: null, new: null };
|
|
57
55
|
}
|
|
56
|
+
getControl(...args) {
|
|
57
|
+
return new FileControl(this, { label: this.name, autocomplete: false });
|
|
58
|
+
}
|
|
59
|
+
async getSealiousCreateValue(fctx) {
|
|
60
|
+
const { parsed: value } = await this.getParsedValue(
|
|
61
|
+
fctx.ctx,
|
|
62
|
+
fctx.data.raw_values
|
|
63
|
+
);
|
|
64
|
+
const pointer = value?.new || value?.old || void 0;
|
|
65
|
+
if (this.required && !pointer) {
|
|
66
|
+
throw new Error("File is required, but no value is provided");
|
|
67
|
+
}
|
|
68
|
+
return pointer;
|
|
69
|
+
}
|
|
70
|
+
async sealiousValueToForm(ctx, sealiousValue) {
|
|
71
|
+
if (!sealiousValue) {
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
74
|
+
if (typeof sealiousValue == "string") {
|
|
75
|
+
sealiousValue = await ctx.$app.fileManager.fromToken(sealiousValue);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
old: sealiousValue
|
|
79
|
+
// FilePointer
|
|
80
|
+
};
|
|
81
|
+
}
|
|
58
82
|
}
|
|
59
83
|
export {
|
|
60
84
|
File
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import Router from "@koa/router";
|
|
2
|
-
import {
|
|
2
|
+
import { FilePointer } from "@sealcode/file-manager";
|
|
3
3
|
import getPort from "get-port";
|
|
4
4
|
import Koa from "koa";
|
|
5
5
|
import fs from "node:fs/promises";
|
|
6
|
-
import { KoaResponsiveImageRouter } from "koa-responsive-image-router";
|
|
7
6
|
import { mount } from "../../mount.js";
|
|
8
|
-
import {
|
|
7
|
+
import { Image } from "../controls/image.js";
|
|
9
8
|
import { Form } from "../form.js";
|
|
10
9
|
import { File as FileField } from "./file.js";
|
|
11
10
|
import { getBrowser } from "../../utils/browser-creator.js";
|
|
@@ -26,7 +25,7 @@ describe("file field", () => {
|
|
|
26
25
|
const app = new Koa();
|
|
27
26
|
const router = new Router();
|
|
28
27
|
const fields = {
|
|
29
|
-
file: new FileField(true
|
|
28
|
+
file: new FileField(true)
|
|
30
29
|
};
|
|
31
30
|
let received_values;
|
|
32
31
|
mount(
|
|
@@ -36,18 +35,7 @@ describe("file field", () => {
|
|
|
36
35
|
constructor() {
|
|
37
36
|
super(...arguments);
|
|
38
37
|
this.fields = fields;
|
|
39
|
-
this.controls = [
|
|
40
|
-
new Photo(
|
|
41
|
-
fields.file,
|
|
42
|
-
new KoaResponsiveImageRouter({
|
|
43
|
-
staticPath: "/tmp",
|
|
44
|
-
thumbnailSize: 10,
|
|
45
|
-
cacheManagerResolutionThreshold: 10,
|
|
46
|
-
imageStoragePath: "/tmp",
|
|
47
|
-
smartCropStoragePath: "/tmp"
|
|
48
|
-
})
|
|
49
|
-
)
|
|
50
|
-
];
|
|
38
|
+
this.controls = [new Image(fields.file)];
|
|
51
39
|
}
|
|
52
40
|
async onSubmit(ctx) {
|
|
53
41
|
received_values = await this.getParsedValues(ctx);
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FieldTypes as SealiousFieldTypes
|
|
3
|
+
} from "sealious";
|
|
4
|
+
import { Boolean as BooleanField } from "./boolean.js";
|
|
5
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
6
|
+
import { File } from "./file.js";
|
|
7
|
+
import { StructuredArray as StructuredArrayField } from "./structured-array.js";
|
|
8
|
+
import { Color } from "./color.js";
|
|
9
|
+
import { DateField } from "./date.js";
|
|
10
|
+
import { DateTime } from "./datetime.js";
|
|
11
|
+
import { EmailField } from "./email.js";
|
|
12
|
+
import { Float } from "./float.js";
|
|
13
|
+
import { HTML } from "./html.js";
|
|
14
|
+
import { Int } from "./int.js";
|
|
15
|
+
import { JSONField } from "./json.js";
|
|
16
|
+
import { Password } from "./password.js";
|
|
17
|
+
import { Text } from "./text.js";
|
|
18
|
+
import { Markdown } from "./markdown.js";
|
|
19
|
+
import { DeepReverseSingleReferenceTable } from "./deep-reverse-single-reference-table.js";
|
|
20
|
+
import { DeepReverseSingleReferenceList } from "./deep-reverse-single-reference-list.js";
|
|
21
|
+
import { Coordinates } from "./coordinates.js";
|
|
22
|
+
import { PickFromListSealious } from "./pick-from-list-sealious.js";
|
|
23
|
+
import { SingleReference } from "./single-reference.js";
|
|
24
|
+
import extract_fields_from_collection from "../../utils/extract-fields-from-collection.js";
|
|
25
|
+
import { EnumMultipleSealious } from "./enum-multiple-sealious.js";
|
|
26
|
+
import { URLField } from "./url.js";
|
|
27
|
+
import { Image } from "./image.js";
|
|
28
|
+
function sealiousToFormField(sealious_field) {
|
|
29
|
+
if (sealious_field instanceof SealiousFieldTypes.Boolean) {
|
|
30
|
+
return new BooleanField(
|
|
31
|
+
sealious_field.required
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
if (sealious_field instanceof SealiousFieldTypes.Color) {
|
|
35
|
+
return new Color(sealious_field.required);
|
|
36
|
+
}
|
|
37
|
+
if (sealious_field instanceof SealiousFieldTypes.ControlAccess) {
|
|
38
|
+
const target_field = sealious_field.virtual_field;
|
|
39
|
+
return sealiousToFormField(target_field);
|
|
40
|
+
}
|
|
41
|
+
if (sealious_field instanceof SealiousFieldTypes.Date) {
|
|
42
|
+
return new DateField(
|
|
43
|
+
sealious_field.required
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (sealious_field instanceof SealiousFieldTypes.DateTime) {
|
|
47
|
+
return new DateTime(sealious_field.required);
|
|
48
|
+
}
|
|
49
|
+
if (sealious_field instanceof SealiousFieldTypes.DeepReverseSingleReference) {
|
|
50
|
+
const referencing_collection = sealious_field.collection.app.collections[sealious_field.referencing_collection];
|
|
51
|
+
if (!referencing_collection) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
"Unknown collection: " + sealious_field.referencing_collection
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (Object.keys(referencing_collection.fields).length == 2) {
|
|
57
|
+
return new DeepReverseSingleReferenceList(
|
|
58
|
+
sealious_field
|
|
59
|
+
);
|
|
60
|
+
} else {
|
|
61
|
+
return new DeepReverseSingleReferenceTable(
|
|
62
|
+
sealious_field
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (sealious_field instanceof SealiousFieldTypes.DisallowUpdate) {
|
|
67
|
+
return sealiousToFormField(
|
|
68
|
+
sealious_field.virtual_field
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
if (sealious_field instanceof SealiousFieldTypes.Email) {
|
|
72
|
+
return new EmailField(
|
|
73
|
+
sealious_field.required
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (sealious_field instanceof SealiousFieldTypes.Enum) {
|
|
77
|
+
return new PickFromListSealious(
|
|
78
|
+
sealious_field
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (sealious_field instanceof SealiousFieldTypes.EnumMultiple) {
|
|
82
|
+
return new EnumMultipleSealious(
|
|
83
|
+
sealious_field
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
if (sealious_field instanceof SealiousFieldTypes.File) {
|
|
87
|
+
return new File(sealious_field.required);
|
|
88
|
+
}
|
|
89
|
+
if (sealious_field instanceof SealiousFieldTypes.Float) {
|
|
90
|
+
return new Float(sealious_field.required);
|
|
91
|
+
}
|
|
92
|
+
if (sealious_field instanceof SealiousFieldTypes.HTML) {
|
|
93
|
+
return new HTML(sealious_field.required);
|
|
94
|
+
}
|
|
95
|
+
if (sealious_field instanceof SealiousFieldTypes.Image) {
|
|
96
|
+
return new Image(sealious_field.required);
|
|
97
|
+
}
|
|
98
|
+
if (sealious_field instanceof SealiousFieldTypes.Int) {
|
|
99
|
+
return new Int(sealious_field.required);
|
|
100
|
+
}
|
|
101
|
+
if (sealious_field instanceof SealiousFieldTypes.JsonObject) {
|
|
102
|
+
return new JSONField(
|
|
103
|
+
sealious_field.required
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (sealious_field instanceof SealiousFieldTypes.Password) {
|
|
107
|
+
return new Password(sealious_field.required);
|
|
108
|
+
}
|
|
109
|
+
if (sealious_field instanceof SealiousFieldTypes.SettableBy) {
|
|
110
|
+
return sealiousToFormField(
|
|
111
|
+
sealious_field.virtual_field
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
if (sealious_field instanceof SealiousFieldTypes.SingleReference) {
|
|
115
|
+
return new SingleReference(
|
|
116
|
+
false,
|
|
117
|
+
sealious_field
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
if (sealious_field instanceof SealiousFieldTypes.Text) {
|
|
121
|
+
return new Text(sealious_field.required);
|
|
122
|
+
}
|
|
123
|
+
if (sealious_field instanceof SealiousFieldTypes.Username) {
|
|
124
|
+
return new Text(sealious_field.required);
|
|
125
|
+
}
|
|
126
|
+
if (sealious_field instanceof SealiousFieldTypes.Url) {
|
|
127
|
+
return new URLField(sealious_field.required);
|
|
128
|
+
}
|
|
129
|
+
if (sealious_field instanceof SealiousFieldTypes.Money) {
|
|
130
|
+
return new Float(sealious_field.required);
|
|
131
|
+
}
|
|
132
|
+
if (sealious_field instanceof SealiousFieldTypes.Markdown) {
|
|
133
|
+
return new Markdown(sealious_field.required);
|
|
134
|
+
}
|
|
135
|
+
if (sealious_field instanceof SealiousFieldTypes.Coordinates) {
|
|
136
|
+
return new Coordinates(
|
|
137
|
+
sealious_field.required
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
if (sealious_field instanceof SealiousFieldTypes.StructuredArray) {
|
|
141
|
+
return new StructuredArrayField(
|
|
142
|
+
sealious_field
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
return new TextBasedSimpleField(false);
|
|
146
|
+
}
|
|
147
|
+
async function sealiousFieldInfoToFormField(field_info) {
|
|
148
|
+
switch (field_info.type) {
|
|
149
|
+
case "boolean":
|
|
150
|
+
return new BooleanField(field_info.is_required);
|
|
151
|
+
case "color":
|
|
152
|
+
return new Color(field_info.is_required);
|
|
153
|
+
case "date":
|
|
154
|
+
return new DateField(field_info.is_required);
|
|
155
|
+
case "datetime":
|
|
156
|
+
return new DateTime(field_info.is_required);
|
|
157
|
+
case "deep-reverse-single-reference": {
|
|
158
|
+
const referencing_fields = await extract_fields_from_collection(
|
|
159
|
+
field_info.referencing_collection
|
|
160
|
+
);
|
|
161
|
+
if (referencing_fields.length == 2) {
|
|
162
|
+
return new DeepReverseSingleReferenceList({});
|
|
163
|
+
} else {
|
|
164
|
+
return new DeepReverseSingleReferenceTable({});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
case "email":
|
|
168
|
+
return new EmailField(field_info.is_required);
|
|
169
|
+
case "enum":
|
|
170
|
+
return new PickFromListSealious({});
|
|
171
|
+
case "enum-multiple":
|
|
172
|
+
return new EnumMultipleSealious({});
|
|
173
|
+
case "file":
|
|
174
|
+
return new File(field_info.is_required);
|
|
175
|
+
case "float":
|
|
176
|
+
return new Float(field_info.is_required);
|
|
177
|
+
case "html":
|
|
178
|
+
return new HTML(field_info.is_required);
|
|
179
|
+
case "image":
|
|
180
|
+
return new Image(field_info.is_required);
|
|
181
|
+
case "int":
|
|
182
|
+
return new Int(field_info.is_required);
|
|
183
|
+
case "json-object":
|
|
184
|
+
return new JSONField(field_info.is_required);
|
|
185
|
+
case "password":
|
|
186
|
+
return new Password(field_info.is_required);
|
|
187
|
+
case "single-reference":
|
|
188
|
+
return new SingleReference(false, {});
|
|
189
|
+
case "text":
|
|
190
|
+
return new Text(field_info.is_required);
|
|
191
|
+
case "username":
|
|
192
|
+
return new Text(field_info.is_required);
|
|
193
|
+
case "url":
|
|
194
|
+
return new URLField(field_info.is_required);
|
|
195
|
+
case "money":
|
|
196
|
+
return new Float(field_info.is_required);
|
|
197
|
+
case "markdown":
|
|
198
|
+
return new Markdown(field_info.is_required);
|
|
199
|
+
case "coordinates":
|
|
200
|
+
return new Coordinates(field_info.is_required);
|
|
201
|
+
case "structured-array":
|
|
202
|
+
return new StructuredArrayField(
|
|
203
|
+
new SealiousFieldTypes.StructuredArray({})
|
|
204
|
+
);
|
|
205
|
+
default:
|
|
206
|
+
return new TextBasedSimpleField(false);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
export {
|
|
210
|
+
sealiousFieldInfoToFormField,
|
|
211
|
+
sealiousToFormField
|
|
212
|
+
};
|
|
213
|
+
//# sourceMappingURL=get-field-for-sealious.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Textarea } from "../controls/textarea.js";
|
|
2
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
3
|
+
class HTML extends TextBasedSimpleField {
|
|
4
|
+
constructor(required) {
|
|
5
|
+
super(required, "text");
|
|
6
|
+
}
|
|
7
|
+
getControl() {
|
|
8
|
+
return new Textarea(this);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
HTML
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Image as ImageControl } from "../controls/image.js";
|
|
2
|
+
import { File as FileField } from "./file.js";
|
|
3
|
+
class Image extends FileField {
|
|
4
|
+
getControl() {
|
|
5
|
+
return new ImageControl(
|
|
6
|
+
this
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
Image
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NumberBasedSimpleField } from "./simple-form-field.js";
|
|
2
|
+
class Int extends NumberBasedSimpleField {
|
|
3
|
+
constructor(required) {
|
|
4
|
+
super(required, "number");
|
|
5
|
+
}
|
|
6
|
+
async getSealiousCreateValue(fctx) {
|
|
7
|
+
const { parsed } = await this.getParsedValue(
|
|
8
|
+
fctx.ctx,
|
|
9
|
+
fctx.data.raw_values
|
|
10
|
+
);
|
|
11
|
+
if (parsed == null) {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
if (isNaN(parsed)) {
|
|
15
|
+
return void 0;
|
|
16
|
+
} else
|
|
17
|
+
return parsed;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
Int
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=int.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Textarea } from "../controls/textarea.js";
|
|
2
|
+
import { SimpleFormField } from "./simple-form-field.js";
|
|
3
|
+
class JSONField extends SimpleFormField {
|
|
4
|
+
constructor(required) {
|
|
5
|
+
super(required, "text");
|
|
6
|
+
}
|
|
7
|
+
getControl() {
|
|
8
|
+
return new Textarea(this);
|
|
9
|
+
}
|
|
10
|
+
getEmptyValue() {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
async parse(ctx, raw_value) {
|
|
14
|
+
return {
|
|
15
|
+
parsable: true,
|
|
16
|
+
error: null,
|
|
17
|
+
parsed_value: JSON.parse(raw_value)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async getSealiousCreateValue(fctx) {
|
|
21
|
+
const { parsed } = await this.getParsedValue(
|
|
22
|
+
fctx.ctx,
|
|
23
|
+
fctx.data.raw_values
|
|
24
|
+
);
|
|
25
|
+
return parsed;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
JSONField
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Textarea } from "../controls/textarea.js";
|
|
2
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
3
|
+
class Markdown extends TextBasedSimpleField {
|
|
4
|
+
constructor(required) {
|
|
5
|
+
super(required, "text");
|
|
6
|
+
}
|
|
7
|
+
getControl() {
|
|
8
|
+
return new Textarea(this);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
Markdown
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FormField } from "./field.js";
|
|
2
|
+
import { MultipleFiles as MultipleFilesControl } from "../controls/multiple-files.js";
|
|
2
3
|
class MultipleFiles extends FormField {
|
|
3
4
|
constructor(collection_field, getItemId) {
|
|
4
5
|
super(false);
|
|
@@ -11,6 +12,9 @@ class MultipleFiles extends FormField {
|
|
|
11
12
|
async parse() {
|
|
12
13
|
return { parsed_value: void 0, parsable: true, error: null };
|
|
13
14
|
}
|
|
15
|
+
getControl() {
|
|
16
|
+
return new MultipleFilesControl(this);
|
|
17
|
+
}
|
|
14
18
|
}
|
|
15
19
|
export {
|
|
16
20
|
MultipleFiles
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
|
+
import { SimpleInput } from "../controls/simple-input.js";
|
|
2
3
|
import { FormField } from "./field.js";
|
|
3
4
|
class NumberField extends FormField {
|
|
4
5
|
constructor(required, default_value, options = {}) {
|
|
@@ -35,6 +36,11 @@ class NumberField extends FormField {
|
|
|
35
36
|
getEmptyValue() {
|
|
36
37
|
return this.default_value;
|
|
37
38
|
}
|
|
39
|
+
getControl() {
|
|
40
|
+
return new SimpleInput(this, {
|
|
41
|
+
type: "number"
|
|
42
|
+
});
|
|
43
|
+
}
|
|
38
44
|
}
|
|
39
45
|
export {
|
|
40
46
|
NumberField
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
2
|
+
class Password extends TextBasedSimpleField {
|
|
3
|
+
constructor(required) {
|
|
4
|
+
super(required, "password");
|
|
5
|
+
}
|
|
6
|
+
async sealiousValueToForm(ctx, value) {
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
Password
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=password.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PickFromListField } from "./pick-from-list.js";
|
|
2
|
+
class PickFromListSealious extends PickFromListField {
|
|
3
|
+
constructor(sealious_field) {
|
|
4
|
+
super(
|
|
5
|
+
sealious_field.required,
|
|
6
|
+
async (ctx) => sealious_field.getAllowedValues(ctx.$app).map((value) => ({ value, label: value }))
|
|
7
|
+
);
|
|
8
|
+
this.sealious_field = sealious_field;
|
|
9
|
+
}
|
|
10
|
+
generateFieldDeclaration(field_info, vars) {
|
|
11
|
+
return `new ${vars.form_field_types}.${this.constructor.name}(${vars.sealious_field})`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
PickFromListSealious
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=pick-from-list-sealious.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { Dropdown } from "../controls/dropdown.js";
|
|
3
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
4
|
+
class PickFromListField extends TextBasedSimpleField {
|
|
4
5
|
constructor(required, generateOptions, customValidation = (ctx, value, instance) => instance.valueInList(ctx, value)) {
|
|
5
6
|
super(required);
|
|
6
7
|
this.required = required;
|
|
@@ -27,6 +28,9 @@ class PickFromListField extends SimpleFormField {
|
|
|
27
28
|
getEmptyValue() {
|
|
28
29
|
return "";
|
|
29
30
|
}
|
|
31
|
+
getControl() {
|
|
32
|
+
return new Dropdown(this);
|
|
33
|
+
}
|
|
30
34
|
}
|
|
31
35
|
export {
|
|
32
36
|
PickFromListField
|