@sealcode/sealgen 0.18.10 → 0.19.2
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/.xunit +74 -69
- 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 -3
- 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 -2
- 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 -4
- 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 -1
- 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 -3
- 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 +20 -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 +5 -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 -8
- 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 -2
- 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/mount.d.ts +0 -1
- 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/mountable.d.ts +0 -1
- package/@types/page/page.d.sync-conflict-20250918-184320-TFDLWFG.ts +18 -0
- package/@types/page/page.d.ts +0 -1
- 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/page/stateful-page.d.ts +0 -1
- package/@types/register-external.d.ts +2 -2
- package/@types/templates/form.d.ts +1 -3
- package/@types/templates/jdd-component.d.ts +1 -1
- package/@types/templates/page.d.ts +1 -1
- 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 +1 -68
- package/@types/templates/templates.d.ts +1 -21
- 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/eslint.config.mjs +56 -0
- package/lib/add-crud.js +77 -89
- package/lib/add-jdd-component.js +3 -3
- package/lib/add-list-route.test.js +1 -1
- package/lib/add-route.js +2 -9
- package/lib/build.js +6 -4
- package/lib/builders/backend-ts-builder.js +0 -1
- package/lib/builders/colors-builder.js +11 -8
- package/lib/builders/fonts-builder.js +0 -1
- package/lib/builders/frontend-ts-builder.js +0 -1
- package/lib/cli.js +4 -7
- package/lib/components/tabs.js +36 -36
- package/lib/controllers/table-add-button.stimulus.js +35 -0
- package/lib/esbuild-plugins/rewrite-asset-imports.js +7 -10
- package/lib/forms/controls/array.js +25 -22
- 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 +7 -1
- package/lib/forms/controls/checkboxed-list-input.test.js +6 -6
- package/lib/forms/controls/controls.js +2 -2
- package/lib/forms/controls/derived-frame.js +8 -4
- package/lib/forms/controls/derived.js +1 -1
- package/lib/forms/controls/dropdown.js +5 -3
- 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/form-control.js +1 -1
- 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} +8 -23
- 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/single-reference.test.js +1 -1
- package/lib/forms/controls/table.js +62 -25
- package/lib/forms/controls/textarea.js +5 -3
- 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 +8 -8
- package/lib/forms/fields/fields.js +23 -8
- package/lib/forms/fields/file.js +33 -9
- package/lib/forms/fields/file.test.js +5 -17
- 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 +61 -2
- package/lib/forms/fields/single-reference.js +44 -0
- package/lib/forms/fields/structured-array.js +61 -12
- package/lib/forms/fields/table.js +29 -2
- package/lib/forms/fields/text.js +17 -0
- package/lib/forms/fields/url.js +17 -0
- package/lib/forms/form.js +30 -14
- package/lib/forms/form.test.js +5 -7
- package/lib/forms/multiform.js +10 -9
- package/lib/forms/multiform.test.js +5 -5
- package/lib/generate-collections.js +2 -3
- package/lib/generate-components.js +2 -3
- package/lib/generate-routes.js +3 -5
- package/lib/generate-routes.test.js +7 -16
- package/lib/generate-stimulus.js +4 -4
- package/lib/get-fonts.js +29 -27
- package/lib/index.js +1 -0
- package/lib/make-env.js +1 -1
- package/lib/make-hidden-inputs.js +4 -4
- package/lib/mount.js +11 -1
- package/lib/notifier.js +3 -4
- package/lib/page/list.js +20 -15
- package/lib/page/mountable-with-fields.js +14 -6
- package/lib/page/mountable-with-fields.test.js +1 -1
- package/lib/page/mountable.js +0 -1
- package/lib/page/page.js +0 -1
- package/lib/register-external.js +4 -4
- package/lib/templates/form.js +9 -10
- package/lib/templates/jdd-component.js +1 -1
- package/lib/templates/jdd-editor.js +1 -1
- package/lib/templates/multiform.js +4 -4
- package/lib/templates/page.js +1 -3
- package/lib/templates/shared/collection-create-form.js +31 -44
- package/lib/templates/shared/collection-edit-form.js +43 -81
- package/lib/templates/shared/collection-list.js +13 -21
- package/lib/templates/shared/shared-crud-form-fields.js +28 -98
- package/lib/test_utils/exec_async.js +3 -3
- package/lib/test_utils/test-on-real-app.js +12 -14
- 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/lib/utils/write-file.js +1 -1
- package/package.json +11 -9
- package/src/add-collection.ts +1 -3
- package/src/add-crud.ts +84 -100
- package/src/add-jdd-component.ts +4 -5
- package/src/add-list-route.test.ts +1 -1
- package/src/add-route.ts +3 -13
- package/src/build.ts +6 -4
- package/src/builders/backend-ts-builder.ts +0 -1
- package/src/builders/builder.ts +4 -1
- package/src/builders/colors-builder.ts +11 -9
- package/src/builders/css-builder.ts +4 -1
- package/src/builders/fonts-builder.ts +0 -1
- package/src/builders/frontend-ts-builder.ts +0 -1
- package/src/cli.ts +5 -7
- package/src/components/tabs.ts +38 -37
- package/src/components/toggle-modal.ts +1 -1
- package/src/controllers/table-add-button.stimulus.ts +35 -0
- package/src/esbuild-plugins/rewrite-asset-imports.ts +7 -10
- package/src/forms/controls/array.ts +35 -36
- package/src/forms/controls/autocomplete.ts +2 -2
- package/src/forms/controls/big-radio-group.ts +4 -4
- package/src/forms/controls/checkbox-group.ts +10 -10
- package/src/forms/controls/checkboxed-list-input.test.ts +6 -6
- package/src/forms/controls/checkboxed-list-input.ts +16 -8
- package/src/forms/controls/controls.ts +2 -2
- package/src/forms/controls/derived-frame.ts +16 -11
- package/src/forms/controls/derived.ts +7 -6
- package/src/forms/controls/dropdown.ts +13 -13
- package/src/forms/controls/editable-collection-subset.ts +4 -3
- package/src/forms/controls/field-group.ts +1 -1
- package/src/forms/controls/file.test.ts +4 -2
- package/src/forms/controls/file.ts +30 -7
- package/src/forms/controls/form-control.ts +8 -3
- package/src/forms/controls/hidden-input.ts +5 -1
- package/src/forms/controls/html.ts +1 -0
- package/src/forms/controls/{photo.test.ts → image.test.ts} +7 -24
- package/src/forms/controls/{photo.ts → image.ts} +4 -6
- package/src/forms/controls/multiple-files.ts +23 -8
- package/src/forms/controls/{multiple-photos.ts → multiple-images.ts} +2 -2
- package/src/forms/controls/number.ts +1 -1
- package/src/forms/controls/simple-input.ts +21 -33
- package/src/forms/controls/single-reference.test.ts +1 -1
- package/src/forms/controls/single-reference.ts +11 -3
- package/src/forms/controls/table.ts +87 -33
- package/src/forms/controls/textarea.ts +7 -5
- package/src/forms/controls/tickable.ts +13 -7
- package/src/forms/fields/boolean.ts +27 -2
- package/src/forms/fields/checkboxed-list.ts +11 -2
- package/src/forms/fields/collection-field.ts +21 -3
- 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 +130 -0
- package/src/forms/fields/deep-reverse-single-reference-table.ts +213 -0
- package/src/forms/fields/email.ts +10 -1
- package/src/forms/fields/enum-multiple-sealious.ts +48 -0
- package/src/forms/fields/existing-sealious-value.ts +1 -1
- package/src/forms/fields/field.test.ts +8 -8
- package/src/forms/fields/field.ts +98 -11
- package/src/forms/fields/fields.ts +23 -8
- package/src/forms/fields/file.test.ts +5 -17
- package/src/forms/fields/file.ts +44 -16
- package/src/forms/fields/float.ts +9 -0
- package/src/forms/fields/get-field-for-sealious.ts +337 -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 +10 -3
- package/src/forms/fields/password.ts +13 -0
- package/src/forms/fields/pick-from-list-sealious.ts +22 -0
- package/src/forms/fields/pick-from-list.ts +8 -4
- package/src/forms/fields/proxy-field.ts +7 -1
- package/src/forms/fields/regexp.ts +27 -1
- package/src/forms/fields/simple-form-field.ts +103 -7
- package/src/forms/fields/single-reference.ts +62 -0
- package/src/forms/fields/structured-array.ts +111 -18
- package/src/forms/fields/table.ts +39 -16
- package/src/forms/fields/text.ts +18 -0
- package/src/forms/fields/url.ts +20 -0
- package/src/forms/form-types.ts +5 -4
- package/src/forms/form.test.ts +5 -7
- package/src/forms/form.ts +42 -23
- package/src/forms/forms.css +0 -85
- package/src/forms/multiform.test.ts +9 -9
- package/src/forms/multiform.ts +12 -10
- package/src/generate-collections.ts +2 -3
- package/src/generate-components.ts +2 -3
- package/src/generate-routes.test.ts +7 -16
- package/src/generate-routes.ts +6 -10
- package/src/generate-stimulus.ts +4 -5
- package/src/get-fonts.ts +32 -30
- package/src/index.ts +2 -1
- package/src/make-env.ts +1 -1
- package/src/make-hidden-inputs.ts +8 -7
- package/src/mount.ts +16 -7
- package/src/notifier.ts +4 -7
- package/src/page/default-list-filters.ts +1 -0
- package/src/page/list.ts +33 -28
- package/src/page/mountable-with-fields.test.ts +1 -1
- package/src/page/mountable-with-fields.ts +21 -12
- package/src/page/mountable.ts +0 -1
- package/src/page/page.ts +2 -3
- package/src/page/props-parser.ts +1 -1
- package/src/page/sealious-list.ts +1 -1
- package/src/page/stateful-page.ts +6 -10
- package/src/register-external.ts +5 -5
- package/src/templates/form.ts +9 -11
- package/src/templates/jdd-component.ts +1 -1
- package/src/templates/jdd-editor.ts +2 -4
- package/src/templates/list.ts +0 -1
- package/src/templates/multiform.ts +4 -4
- package/src/templates/page.ts +1 -6
- package/src/templates/shared/collection-create-form.ts +34 -71
- package/src/templates/shared/collection-edit-form.ts +46 -108
- package/src/templates/shared/collection-list.ts +13 -21
- package/src/templates/shared/item-delete.ts +0 -1
- package/src/templates/shared/shared-crud-form-fields.ts +38 -177
- package/src/templates/templates.ts +5 -1
- package/src/test_utils/exec_async.ts +3 -4
- package/src/test_utils/test-on-real-app.ts +13 -14
- package/src/utils/browser-creator.js +0 -1
- package/src/utils/exec.ts +0 -1
- package/src/utils/extract-fields-from-collection.ts +76 -25
- package/src/utils/input-wrapper.ts +1 -1
- package/src/utils/make-slug.ts +1 -1
- package/src/utils/wrap-attributes.ts +17 -0
- package/src/utils/write-file.ts +1 -1
- package/.eslintrc.cjs +0 -39
- 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,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
|
|
@@ -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 RegExpField extends FormField {
|
|
4
5
|
constructor(required, regexp, error_message, default_value = "") {
|
|
@@ -35,6 +36,19 @@ class RegExpField extends FormField {
|
|
|
35
36
|
getEmptyValue() {
|
|
36
37
|
return this.default_value || "";
|
|
37
38
|
}
|
|
39
|
+
getControl() {
|
|
40
|
+
return new SimpleInput(this, { label: this.name });
|
|
41
|
+
}
|
|
42
|
+
async getSealiousCreateValue(fctx) {
|
|
43
|
+
const { parsed } = await this.getParsedValue(
|
|
44
|
+
fctx.ctx,
|
|
45
|
+
fctx.data.raw_values
|
|
46
|
+
);
|
|
47
|
+
return parsed || "";
|
|
48
|
+
}
|
|
49
|
+
async sealiousValueToForm(ctx, sealious_value) {
|
|
50
|
+
return sealious_value || "";
|
|
51
|
+
}
|
|
38
52
|
}
|
|
39
53
|
export {
|
|
40
54
|
RegExpField
|
|
@@ -1,22 +1,81 @@
|
|
|
1
1
|
import { predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { FormField } from "./field.js";
|
|
3
|
+
import { SimpleInput } from "../controls/simple-input.js";
|
|
3
4
|
class SimpleFormField extends FormField {
|
|
4
|
-
constructor(required) {
|
|
5
|
+
constructor(required, type = "text") {
|
|
5
6
|
super(required);
|
|
7
|
+
this.type = type;
|
|
6
8
|
this.predicate = predicates.string;
|
|
7
9
|
}
|
|
10
|
+
async sealiousValueToForm(_ctx, value) {
|
|
11
|
+
if (value === null) {
|
|
12
|
+
return "";
|
|
13
|
+
}
|
|
14
|
+
return String(value);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
class TextBasedSimpleField extends SimpleFormField {
|
|
8
18
|
async parse(_, raw_value) {
|
|
9
19
|
return {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
10
21
|
parsed_value: (raw_value || "").toString(),
|
|
11
22
|
parsable: true,
|
|
12
23
|
error: null
|
|
13
24
|
};
|
|
14
25
|
}
|
|
26
|
+
async getSealiousCreateValue(fctx) {
|
|
27
|
+
const { parsed } = await this.getParsedValue(
|
|
28
|
+
fctx.ctx,
|
|
29
|
+
fctx.data.raw_values
|
|
30
|
+
);
|
|
31
|
+
return parsed || "";
|
|
32
|
+
}
|
|
33
|
+
async postSealiousCreate(ctx, created_item) {
|
|
34
|
+
}
|
|
35
|
+
async postSealiousEdit(ctx, edited_item) {
|
|
36
|
+
}
|
|
37
|
+
getControl() {
|
|
38
|
+
return new SimpleInput(this, {
|
|
39
|
+
label: this.name,
|
|
40
|
+
type: this.type
|
|
41
|
+
});
|
|
42
|
+
}
|
|
15
43
|
getEmptyValue() {
|
|
16
44
|
return "";
|
|
17
45
|
}
|
|
18
46
|
}
|
|
47
|
+
class NumberBasedSimpleField extends SimpleFormField {
|
|
48
|
+
async parse(_, raw_value) {
|
|
49
|
+
return {
|
|
50
|
+
parsed_value: parseFloat(raw_value) || 0,
|
|
51
|
+
parsable: true,
|
|
52
|
+
error: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async getSealiousCreateValue(fctx) {
|
|
56
|
+
const { parsed } = await this.getParsedValue(
|
|
57
|
+
fctx.ctx,
|
|
58
|
+
fctx.data.raw_values
|
|
59
|
+
);
|
|
60
|
+
return parsed || 0;
|
|
61
|
+
}
|
|
62
|
+
async postSealiousCreate() {
|
|
63
|
+
}
|
|
64
|
+
async postSealiousEdit() {
|
|
65
|
+
}
|
|
66
|
+
getControl() {
|
|
67
|
+
return new SimpleInput(this, {
|
|
68
|
+
label: this.name,
|
|
69
|
+
type: this.type
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
getEmptyValue() {
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
19
76
|
export {
|
|
20
|
-
|
|
77
|
+
NumberBasedSimpleField,
|
|
78
|
+
SimpleFormField,
|
|
79
|
+
TextBasedSimpleField
|
|
21
80
|
};
|
|
22
81
|
//# sourceMappingURL=simple-form-field.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CollectionField } from "./collection-field.js";
|
|
2
|
+
import { SingleReferenceDropdown } from "../controls/single-reference.js";
|
|
3
|
+
import { toPascalCase } from "js-convert-case";
|
|
4
|
+
class SingleReference extends CollectionField {
|
|
5
|
+
getControl() {
|
|
6
|
+
return new SingleReferenceDropdown(this, {
|
|
7
|
+
label: this.name,
|
|
8
|
+
getLabel: (item) => item.id
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
async getSealiousCreateValue(fctx) {
|
|
12
|
+
const { parsed } = await this.getParsedValue(
|
|
13
|
+
fctx.ctx,
|
|
14
|
+
fctx.data.raw_values
|
|
15
|
+
);
|
|
16
|
+
return parsed || void 0;
|
|
17
|
+
}
|
|
18
|
+
async sealiousValueToForm(_ctx, value) {
|
|
19
|
+
return value || void 0;
|
|
20
|
+
}
|
|
21
|
+
generateImportsForFieldList(field_info) {
|
|
22
|
+
if (!field_info.target) {
|
|
23
|
+
throw new Error("Expected 'target' attribute in field info");
|
|
24
|
+
}
|
|
25
|
+
return [
|
|
26
|
+
{
|
|
27
|
+
what: toPascalCase(field_info.target),
|
|
28
|
+
from: "src/back/collections/collections.js"
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
generateFieldDeclaration(field_info, vars) {
|
|
33
|
+
if (!field_info.target) {
|
|
34
|
+
throw new Error("Expected 'target' attribute in field info");
|
|
35
|
+
}
|
|
36
|
+
return `new ${vars.form_field_types}.${this.constructor.name}<typeof ${toPascalCase(field_info.target)}, ${String(
|
|
37
|
+
field_info.is_required
|
|
38
|
+
)}, typeof ${vars.sealious_field}>(${String(field_info.is_required)}, ${vars.sealious_field})`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
SingleReference
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=single-reference.js.map
|
|
@@ -1,21 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Table as TableControl } from "../controls/table.js";
|
|
2
|
+
import {
|
|
3
|
+
sealiousToFormField
|
|
4
|
+
} from "./get-field-for-sealious.js";
|
|
5
|
+
import { Table } from "./table.js";
|
|
6
|
+
class StructuredArray extends Table {
|
|
3
7
|
constructor(sealious_field) {
|
|
4
|
-
|
|
8
|
+
const columns = Object.fromEntries(
|
|
9
|
+
Object.entries(sealious_field.subfields).map(
|
|
10
|
+
([key, sealious_field2]) => [
|
|
11
|
+
key,
|
|
12
|
+
sealiousToFormField(sealious_field2)
|
|
13
|
+
]
|
|
14
|
+
)
|
|
15
|
+
);
|
|
16
|
+
super(columns);
|
|
5
17
|
this.sealious_field = sealious_field;
|
|
6
18
|
}
|
|
7
|
-
|
|
8
|
-
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
getControl() {
|
|
20
|
+
return new TableControl(this, {
|
|
21
|
+
label: this.name,
|
|
22
|
+
subfield_controls: Object.fromEntries(
|
|
23
|
+
Object.entries(this.columns).map(([column_name, subfield]) => [
|
|
24
|
+
column_name,
|
|
25
|
+
subfield.getControl()
|
|
26
|
+
])
|
|
27
|
+
),
|
|
28
|
+
allow_adding: true,
|
|
29
|
+
make_new_row: () => ({})
|
|
30
|
+
});
|
|
13
31
|
}
|
|
14
|
-
|
|
15
|
-
return
|
|
32
|
+
generateFieldDeclaration(_field_info, vars) {
|
|
33
|
+
return `new ${vars.form_field_types}.${this.constructor.name}(${vars.sealious_field})`;
|
|
34
|
+
}
|
|
35
|
+
async getSealiousCreateValue(fctx) {
|
|
36
|
+
const { parsed } = await this.getParsedValue(
|
|
37
|
+
fctx.ctx,
|
|
38
|
+
fctx.data.raw_values
|
|
39
|
+
);
|
|
40
|
+
return parsed || this.getEmptyValue();
|
|
41
|
+
}
|
|
42
|
+
async sealiousValueToForm(ctx, sealiousValue) {
|
|
43
|
+
return Promise.all(
|
|
44
|
+
(sealiousValue || []).map(
|
|
45
|
+
async (element) => Object.fromEntries(
|
|
46
|
+
await Promise.all(
|
|
47
|
+
Object.entries(element).map(async ([key, value]) => {
|
|
48
|
+
const form_subfield = this.columns[key];
|
|
49
|
+
if (!form_subfield) {
|
|
50
|
+
return [key, ""];
|
|
51
|
+
}
|
|
52
|
+
return [
|
|
53
|
+
key,
|
|
54
|
+
await form_subfield.sealiousValueToForm(
|
|
55
|
+
ctx,
|
|
56
|
+
value,
|
|
57
|
+
{}
|
|
58
|
+
)
|
|
59
|
+
];
|
|
60
|
+
})
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
)
|
|
64
|
+
);
|
|
16
65
|
}
|
|
17
66
|
}
|
|
18
67
|
export {
|
|
19
|
-
|
|
68
|
+
StructuredArray
|
|
20
69
|
};
|
|
21
70
|
//# sourceMappingURL=structured-array.js.map
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { FormField } from "./field.js";
|
|
3
|
+
import {
|
|
4
|
+
Table as TableControl,
|
|
5
|
+
TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER
|
|
6
|
+
} from "../controls/table.js";
|
|
3
7
|
class Table extends FormField {
|
|
4
8
|
constructor(columns) {
|
|
5
9
|
super(false);
|
|
@@ -8,6 +12,15 @@ class Table extends FormField {
|
|
|
8
12
|
getEmptyValue() {
|
|
9
13
|
return [];
|
|
10
14
|
}
|
|
15
|
+
setName(name) {
|
|
16
|
+
super.setName(name);
|
|
17
|
+
for (const [column_name, field] of Object.entries(this.columns)) {
|
|
18
|
+
field.setName(
|
|
19
|
+
`${this.name}[${TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER}][${column_name}]`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
11
24
|
async parse(ctx, raw_value) {
|
|
12
25
|
if (!is(raw_value, predicates.object)) {
|
|
13
26
|
return {
|
|
@@ -21,10 +34,9 @@ class Table extends FormField {
|
|
|
21
34
|
const row_data = raw_value[row_number];
|
|
22
35
|
const parsed_row = {};
|
|
23
36
|
if (!is(row_data, predicates.object)) {
|
|
24
|
-
console.log("table.ts<fields>:55", this.name);
|
|
25
37
|
throw new Error(`Expected object, got ${String(row_data)}`);
|
|
26
38
|
}
|
|
27
|
-
for (const key
|
|
39
|
+
for (const key of Object.keys(row_data)) {
|
|
28
40
|
const field = this.columns[key];
|
|
29
41
|
if (field == void 0) {
|
|
30
42
|
return {
|
|
@@ -56,6 +68,21 @@ class Table extends FormField {
|
|
|
56
68
|
const ret = { parsed_value: result, parsable: true, error: null };
|
|
57
69
|
return ret;
|
|
58
70
|
}
|
|
71
|
+
getControl() {
|
|
72
|
+
return new TableControl(this, {
|
|
73
|
+
label: this.name,
|
|
74
|
+
subfield_controls: Object.fromEntries(
|
|
75
|
+
Object.entries(this.columns).map(([column_name, field]) => [
|
|
76
|
+
column_name,
|
|
77
|
+
field.getControl()
|
|
78
|
+
])
|
|
79
|
+
),
|
|
80
|
+
allow_adding: true,
|
|
81
|
+
make_new_row: async () => Object.fromEntries(
|
|
82
|
+
Object.keys(this.columns).map((key) => [key, ""])
|
|
83
|
+
)
|
|
84
|
+
});
|
|
85
|
+
}
|
|
59
86
|
}
|
|
60
87
|
export {
|
|
61
88
|
Table
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
2
|
+
class Text extends TextBasedSimpleField {
|
|
3
|
+
constructor(required) {
|
|
4
|
+
super(required, "text");
|
|
5
|
+
}
|
|
6
|
+
async getSealiousCreateValue(fctx) {
|
|
7
|
+
const { parsed } = await this.getParsedValue(
|
|
8
|
+
fctx.ctx,
|
|
9
|
+
fctx.data.raw_values
|
|
10
|
+
);
|
|
11
|
+
return parsed || this.getEmptyValue();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
Text
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TextBasedSimpleField } from "./simple-form-field.js";
|
|
2
|
+
class URLField extends TextBasedSimpleField {
|
|
3
|
+
constructor(required) {
|
|
4
|
+
super(required, "text");
|
|
5
|
+
}
|
|
6
|
+
async getSealiousCreateValue(fctx) {
|
|
7
|
+
const { parsed } = await this.getParsedValue(
|
|
8
|
+
fctx.ctx,
|
|
9
|
+
fctx.data.raw_values
|
|
10
|
+
);
|
|
11
|
+
return parsed || null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
URLField
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=url.js.map
|
package/lib/forms/form.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
MountableWithFields
|
|
12
12
|
} from "../page/mountable-with-fields.js";
|
|
13
|
+
import { Errors as SealiousErrors } from "sealious";
|
|
13
14
|
class Form extends MountableWithFields {
|
|
14
15
|
constructor() {
|
|
15
16
|
super(...arguments);
|
|
@@ -47,7 +48,6 @@ class Form extends MountableWithFields {
|
|
|
47
48
|
${this.makeCloseFormTag()}
|
|
48
49
|
</div>`;
|
|
49
50
|
}
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51
51
|
async makeFormClasses(_ctx) {
|
|
52
52
|
return [];
|
|
53
53
|
}
|
|
@@ -59,7 +59,7 @@ class Form extends MountableWithFields {
|
|
|
59
59
|
makeCloseFormTag() {
|
|
60
60
|
return `</div>`;
|
|
61
61
|
}
|
|
62
|
-
async onValuesInvalid(ctx, form_messages,
|
|
62
|
+
async onValuesInvalid(ctx, form_messages, field_errors) {
|
|
63
63
|
const messages = form_messages.length ? form_messages : [{ type: "error", text: "Some fields are invalid" }];
|
|
64
64
|
return {
|
|
65
65
|
action: "stay",
|
|
@@ -67,7 +67,8 @@ class Form extends MountableWithFields {
|
|
|
67
67
|
ctx,
|
|
68
68
|
{
|
|
69
69
|
raw_values: await this.extractRawValues(ctx),
|
|
70
|
-
messages
|
|
70
|
+
messages,
|
|
71
|
+
field_messages: field_errors
|
|
71
72
|
},
|
|
72
73
|
true
|
|
73
74
|
),
|
|
@@ -76,9 +77,18 @@ class Form extends MountableWithFields {
|
|
|
76
77
|
}
|
|
77
78
|
async onError(ctx, data, error) {
|
|
78
79
|
let error_message = "Unknown error has occured";
|
|
80
|
+
let field_messages = {};
|
|
79
81
|
if (is(error, predicates.object) && hasShape({ message: predicates.string }, error)) {
|
|
80
82
|
error_message = error.message;
|
|
81
83
|
}
|
|
84
|
+
if (error instanceof SealiousErrors.FieldsError) {
|
|
85
|
+
field_messages = Object.fromEntries(
|
|
86
|
+
Object.entries(error.field_messages).map(([key, value]) => {
|
|
87
|
+
const message = value?.message || "";
|
|
88
|
+
return [key, { type: "error", message }];
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
}
|
|
82
92
|
const messages = [{ type: "error", text: error_message }];
|
|
83
93
|
return {
|
|
84
94
|
action: "stay",
|
|
@@ -86,7 +96,8 @@ class Form extends MountableWithFields {
|
|
|
86
96
|
ctx,
|
|
87
97
|
{
|
|
88
98
|
raw_values: data.raw_values,
|
|
89
|
-
messages
|
|
99
|
+
messages,
|
|
100
|
+
field_messages
|
|
90
101
|
},
|
|
91
102
|
true
|
|
92
103
|
)
|
|
@@ -102,7 +113,8 @@ class Form extends MountableWithFields {
|
|
|
102
113
|
ctx,
|
|
103
114
|
{
|
|
104
115
|
raw_values: await this.getInitialValues(ctx),
|
|
105
|
-
messages
|
|
116
|
+
messages,
|
|
117
|
+
field_messages: {}
|
|
106
118
|
},
|
|
107
119
|
false
|
|
108
120
|
),
|
|
@@ -119,23 +131,21 @@ class Form extends MountableWithFields {
|
|
|
119
131
|
raw_values
|
|
120
132
|
);
|
|
121
133
|
if (!valid) {
|
|
122
|
-
console.debug("Form values invalid: ", {
|
|
123
|
-
form_messages,
|
|
124
|
-
field_errors
|
|
125
|
-
});
|
|
126
134
|
return this.onValuesInvalid(ctx, form_messages, field_errors);
|
|
127
135
|
}
|
|
128
136
|
try {
|
|
129
137
|
ctx.status = 303;
|
|
130
138
|
const result = await this.onSubmit(ctx, {
|
|
131
139
|
raw_values,
|
|
132
|
-
messages: []
|
|
140
|
+
messages: [],
|
|
141
|
+
field_messages: {}
|
|
133
142
|
});
|
|
134
143
|
return this.onSuccess(
|
|
135
144
|
ctx,
|
|
136
145
|
{
|
|
137
146
|
raw_values: await this.getRawValuesOnSuccess(ctx),
|
|
138
|
-
messages: []
|
|
147
|
+
messages: [],
|
|
148
|
+
field_messages: {}
|
|
139
149
|
},
|
|
140
150
|
result
|
|
141
151
|
);
|
|
@@ -151,7 +161,8 @@ class Form extends MountableWithFields {
|
|
|
151
161
|
type: "error",
|
|
152
162
|
text: message
|
|
153
163
|
}
|
|
154
|
-
]
|
|
164
|
+
],
|
|
165
|
+
field_messages: {}
|
|
155
166
|
},
|
|
156
167
|
e
|
|
157
168
|
);
|
|
@@ -181,13 +192,13 @@ class Form extends MountableWithFields {
|
|
|
181
192
|
ctx,
|
|
182
193
|
{
|
|
183
194
|
raw_values: await this.extractRawValues(ctx),
|
|
184
|
-
messages: []
|
|
195
|
+
messages: [],
|
|
196
|
+
field_messages: {}
|
|
185
197
|
},
|
|
186
198
|
false
|
|
187
199
|
);
|
|
188
200
|
});
|
|
189
201
|
router.post(path, async (ctx) => {
|
|
190
|
-
console.log("REGULAR FORM HANDLE");
|
|
191
202
|
const reaction = ctx.override_reaction || await this.handlePost(ctx);
|
|
192
203
|
if (reaction.action == "stay") {
|
|
193
204
|
ctx.status = 422;
|
|
@@ -201,6 +212,11 @@ class Form extends MountableWithFields {
|
|
|
201
212
|
async extractRawValues(ctx) {
|
|
202
213
|
return Object.keys(ctx.$body).length ? ctx.$body : this.getInitialValues(ctx);
|
|
203
214
|
}
|
|
215
|
+
static initFieldNames(fields) {
|
|
216
|
+
for (const [field_name, field] of Object.entries(fields)) {
|
|
217
|
+
field.setName(field_name);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
204
220
|
}
|
|
205
221
|
export {
|
|
206
222
|
Form
|
package/lib/forms/form.test.js
CHANGED
|
@@ -7,10 +7,10 @@ import { locator_is_visible } from "../test_utils/locator_is_visible.js";
|
|
|
7
7
|
import { getBrowser } from "../utils/browser-creator.js";
|
|
8
8
|
import { assertThrowsAsync } from "../utils/utils.js";
|
|
9
9
|
import getPort from "get-port";
|
|
10
|
-
import {
|
|
10
|
+
import { TextBasedSimpleField } from "./fields/simple-form-field.js";
|
|
11
11
|
import { expect as PlaywritghtExpect } from "@playwright/test";
|
|
12
12
|
const fields = {
|
|
13
|
-
text: new Fields.
|
|
13
|
+
text: new Fields.TextBasedSimpleField(true)
|
|
14
14
|
};
|
|
15
15
|
function form_factory(canAccessFun) {
|
|
16
16
|
const result = new class extends Form {
|
|
@@ -34,7 +34,7 @@ function form_factory(canAccessFun) {
|
|
|
34
34
|
return result;
|
|
35
35
|
}
|
|
36
36
|
const port = await getPort();
|
|
37
|
-
console.
|
|
37
|
+
console.info("Using port " + port + " for form.test.ts");
|
|
38
38
|
describe("form test", () => {
|
|
39
39
|
let page;
|
|
40
40
|
before(async () => {
|
|
@@ -81,7 +81,6 @@ describe("form test", () => {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
);
|
|
84
|
-
console.log(res_axios.data);
|
|
85
84
|
if (!res_axios.data.includes("Some fields are invalid")) {
|
|
86
85
|
throw new Error("when sending a empty request with axios, the error didnt appear");
|
|
87
86
|
}
|
|
@@ -121,7 +120,6 @@ describe("form test", () => {
|
|
|
121
120
|
"/",
|
|
122
121
|
form_factory(
|
|
123
122
|
async (ctx) => {
|
|
124
|
-
console.log("CAN ACCESS? FALSE");
|
|
125
123
|
return { canAccess: false, message: "" };
|
|
126
124
|
}
|
|
127
125
|
),
|
|
@@ -307,7 +305,7 @@ describe("form test", () => {
|
|
|
307
305
|
await page.getByPlaceholder("text").click();
|
|
308
306
|
await page.getByPlaceholder("text").fill("yes@an.email");
|
|
309
307
|
await page.getByRole("button", { name: "Submit" }).click();
|
|
310
|
-
assertThrowsAsync(async () => {
|
|
308
|
+
await assertThrowsAsync(async () => {
|
|
311
309
|
return page.getByText("Please enter a proper email address").click({ timeout: 500 });
|
|
312
310
|
});
|
|
313
311
|
});
|
|
@@ -322,7 +320,7 @@ describe("form test", () => {
|
|
|
322
320
|
const app = new Koa();
|
|
323
321
|
const router = new Router();
|
|
324
322
|
const fields2 = {
|
|
325
|
-
title: new
|
|
323
|
+
title: new TextBasedSimpleField(true)
|
|
326
324
|
};
|
|
327
325
|
mount(
|
|
328
326
|
router,
|
package/lib/forms/multiform.js
CHANGED
|
@@ -29,12 +29,12 @@ class Multiform extends MountableWithFields {
|
|
|
29
29
|
form.makeSubmitButton = () => (
|
|
30
30
|
/* HTML */
|
|
31
31
|
`<input
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
type="submit"
|
|
33
|
+
value="${form.submitButtonText}"
|
|
34
|
+
formaction="${form.action}"
|
|
35
|
+
id="${submit_button_id}"
|
|
36
|
+
${form.form_id ? `form="${form.form_id}"` : ""}
|
|
37
|
+
/> `
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
for (const form of Object.values(this.forms)) {
|
|
@@ -56,7 +56,6 @@ class Multiform extends MountableWithFields {
|
|
|
56
56
|
message: "this view includes multiple forms and each of them have their unique access rules"
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
59
|
getSubformsToRender(ctx) {
|
|
61
60
|
const requested_frame = ctx.headers["turbo-frame"];
|
|
62
61
|
if (!is(
|
|
@@ -78,7 +77,8 @@ class Multiform extends MountableWithFields {
|
|
|
78
77
|
ctx,
|
|
79
78
|
{
|
|
80
79
|
raw_values: await this.getSubformRawValues(ctx, sub_form_name),
|
|
81
|
-
messages: []
|
|
80
|
+
messages: [],
|
|
81
|
+
field_messages: {}
|
|
82
82
|
},
|
|
83
83
|
show_field_errors
|
|
84
84
|
);
|
|
@@ -97,7 +97,8 @@ class Multiform extends MountableWithFields {
|
|
|
97
97
|
async render(ctx, messages, prerenderedForms = {}, show_field_errors) {
|
|
98
98
|
return tempstream`${this.renderMessages(ctx, {
|
|
99
99
|
raw_values: {},
|
|
100
|
-
messages
|
|
100
|
+
messages,
|
|
101
|
+
field_messages: {}
|
|
101
102
|
})}
|
|
102
103
|
<div class="forms">
|
|
103
104
|
<form
|
|
@@ -8,16 +8,16 @@ import { Multiform } from "./multiform.js";
|
|
|
8
8
|
import { assertThrowsAsync } from "../utils/utils.js";
|
|
9
9
|
import { form_factory } from "./form.test.js";
|
|
10
10
|
import { getBrowser } from "../utils/browser-creator.js";
|
|
11
|
-
import {
|
|
11
|
+
import { TextBasedSimpleField } from "./fields/simple-form-field.js";
|
|
12
12
|
import { Form } from "./form.js";
|
|
13
13
|
import { FormHeader } from "./controls/form-header.js";
|
|
14
14
|
import { SimpleInput } from "./controls/simple-input.js";
|
|
15
15
|
import { EmailField } from "./fields/email.js";
|
|
16
16
|
import getPort from "get-port";
|
|
17
17
|
const port = await getPort();
|
|
18
|
-
console.
|
|
18
|
+
console.info(`Using port ${port} form multiform.test.ts`);
|
|
19
19
|
const fields1 = {
|
|
20
|
-
email: new
|
|
20
|
+
email: new TextBasedSimpleField(true)
|
|
21
21
|
};
|
|
22
22
|
const form1 = new class extends Form {
|
|
23
23
|
constructor() {
|
|
@@ -31,7 +31,7 @@ const form1 = new class extends Form {
|
|
|
31
31
|
}
|
|
32
32
|
}();
|
|
33
33
|
const fields2 = {
|
|
34
|
-
name: new
|
|
34
|
+
name: new TextBasedSimpleField(true)
|
|
35
35
|
};
|
|
36
36
|
const form2 = new class extends Form {
|
|
37
37
|
constructor() {
|
|
@@ -134,7 +134,7 @@ async function individual_field_validation_e2e_tests(javaScriptEnabled) {
|
|
|
134
134
|
await page.getByPlaceholder("text").click();
|
|
135
135
|
await page.getByPlaceholder("text").fill("yes@an.email");
|
|
136
136
|
await page.locator("#multiform_test_form1_submit").click();
|
|
137
|
-
assertThrowsAsync(async () => {
|
|
137
|
+
await assertThrowsAsync(async () => {
|
|
138
138
|
return page.getByText("Please enter a proper email address").click({ timeout: 500 });
|
|
139
139
|
});
|
|
140
140
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _locreq from "locreq";
|
|
2
|
-
import * as prettier from "prettier";
|
|
3
2
|
import { promises as fs } from "fs";
|
|
4
3
|
import { assertType, predicates } from "@sealcode/ts-predicates";
|
|
5
|
-
import {
|
|
4
|
+
import { formatWithPrettier } from "./utils/prettier.js";
|
|
6
5
|
const target_locreq = _locreq(process.cwd());
|
|
7
6
|
async function extractCollectionClassname(full_file_path) {
|
|
8
7
|
const file_content = await fs.readFile(full_file_path, "utf-8");
|
|
@@ -52,7 +51,7 @@ ${file_data.map(({ class_name, urlname }) => ` "${urlname}": ${class_name},`).jo
|
|
|
52
51
|
};`;
|
|
53
52
|
await fs.writeFile(
|
|
54
53
|
target_locreq.resolve("src/back/collections/collections.ts"),
|
|
55
|
-
|
|
54
|
+
await formatWithPrettier(content)
|
|
56
55
|
);
|
|
57
56
|
console.log(
|
|
58
57
|
"Successfuly generated new src/back/collections/collections.ts file"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _locreq from "locreq";
|
|
2
|
-
import * as prettier from "prettier";
|
|
3
2
|
import { promises as fs } from "fs";
|
|
4
|
-
import {
|
|
3
|
+
import { formatWithPrettier } from "./utils/prettier.js";
|
|
5
4
|
import recursive from "recursive-readdir";
|
|
6
5
|
import path from "path";
|
|
7
6
|
import { toKebabCase, toPascalCase } from "js-convert-case";
|
|
@@ -29,7 +28,7 @@ ${component_data.map(
|
|
|
29
28
|
const target = "src/back/jdd-components/components.ts";
|
|
30
29
|
await fs.writeFile(
|
|
31
30
|
target_locreq.resolve(target),
|
|
32
|
-
|
|
31
|
+
await formatWithPrettier(content)
|
|
33
32
|
);
|
|
34
33
|
console.log(`Successfuly generated new ${target} file`);
|
|
35
34
|
}
|