@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
package/src/cli.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import yargs from "yargs/yargs";
|
|
3
3
|
import { addCollection } from "./add-collection.js";
|
|
4
|
-
import { addCRUD } from "./add-crud.js";
|
|
5
4
|
import { addJDDComponent } from "./add-jdd-component.js";
|
|
6
5
|
import { addRoute } from "./add-route.js";
|
|
7
|
-
import {
|
|
6
|
+
import { addCRUD } from "./add-crud.js";
|
|
8
7
|
import { buildProject } from "./build.js";
|
|
9
8
|
import { generateCollections } from "./generate-collections.js";
|
|
10
9
|
import { generateComponents } from "./generate-components.js";
|
|
11
10
|
import { generateRoutes } from "./generate-routes.js";
|
|
12
11
|
import { getFonts } from "./get-fonts.js";
|
|
13
12
|
import { makeEnv } from "./make-env.js";
|
|
14
|
-
|
|
13
|
+
|
|
15
14
|
import {
|
|
16
15
|
registerExternalControllers,
|
|
17
16
|
registerExternalStyles,
|
|
@@ -23,15 +22,14 @@ const actions: Record<
|
|
|
23
22
|
> = {
|
|
24
23
|
"add-collection": addCollection,
|
|
25
24
|
"add-route": addRoute,
|
|
26
|
-
"add-verbose-crud": addVerboseCRUD,
|
|
27
25
|
"add-crud": addCRUD,
|
|
28
26
|
"generate-collections": generateCollections,
|
|
29
27
|
"generate-components": generateComponents,
|
|
30
28
|
"generate-routes": generateRoutes,
|
|
31
29
|
build: buildProject,
|
|
32
30
|
default: async function () {
|
|
33
|
-
console.
|
|
34
|
-
console.
|
|
31
|
+
console.info("Usage: `npx sealgen <action>`");
|
|
32
|
+
console.info(
|
|
35
33
|
`Available actions: ${Object.keys(actions)
|
|
36
34
|
.filter((e) => e != "default")
|
|
37
35
|
.join(", ")}`
|
|
@@ -40,7 +38,7 @@ const actions: Record<
|
|
|
40
38
|
"make-env": makeEnv,
|
|
41
39
|
"add-component": addJDDComponent,
|
|
42
40
|
"get-fonts": getFonts,
|
|
43
|
-
"crud-field-snippets": crudFieldSnippets,
|
|
41
|
+
// "crud-field-snippets": crudFieldSnippets,
|
|
44
42
|
"register-external-controllers": registerExternalControllers,
|
|
45
43
|
"register-external-styles": registerExternalStyles,
|
|
46
44
|
};
|
package/src/components/tabs.ts
CHANGED
|
@@ -4,52 +4,53 @@ function name_to_id(str: string) {
|
|
|
4
4
|
return str.replace(/\W/g, "-");
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
const style = (hide_tabs_width: number) =>
|
|
8
|
-
|
|
9
|
-
height: 45px;
|
|
10
|
-
line-height: 45px;
|
|
11
|
-
padding: 0 45px;
|
|
12
|
-
display: block;
|
|
13
|
-
float: left;
|
|
14
|
-
box-sizing: border-box;
|
|
15
|
-
border-bottom: 3px solid transparent;
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
font-size: 18px;
|
|
18
|
-
-webkit-user-select: none;
|
|
19
|
-
user-select: none;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@media screen and (max-width: ${hide_tabs_width}px) {
|
|
7
|
+
const style = (hide_tabs_width: number) =>
|
|
8
|
+
/* HTML */ `<style>
|
|
23
9
|
.tab-label {
|
|
24
|
-
|
|
10
|
+
height: 45px;
|
|
11
|
+
line-height: 45px;
|
|
12
|
+
padding: 0 45px;
|
|
13
|
+
display: block;
|
|
14
|
+
float: left;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
border-bottom: 3px solid transparent;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
font-size: 18px;
|
|
19
|
+
-webkit-user-select: none;
|
|
20
|
+
user-select: none;
|
|
25
21
|
}
|
|
26
|
-
}
|
|
27
22
|
|
|
28
|
-
.tab-label--mobile {
|
|
29
|
-
line-height: unset;
|
|
30
|
-
padding-top: 30px;
|
|
31
|
-
padding-left: 0;
|
|
32
|
-
pointer-events: none;
|
|
33
|
-
padding-bottom: 30px;
|
|
34
|
-
color: $font-graphite;
|
|
35
|
-
border-bottom: 2px solid $font-primary;
|
|
36
|
-
display: none;
|
|
37
23
|
@media screen and (max-width: ${hide_tabs_width}px) {
|
|
38
|
-
|
|
24
|
+
.tab-label {
|
|
25
|
+
display: none;
|
|
26
|
+
}
|
|
39
27
|
}
|
|
40
|
-
}
|
|
41
28
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
.tab-label--mobile {
|
|
30
|
+
line-height: unset;
|
|
31
|
+
padding-top: 30px;
|
|
32
|
+
padding-left: 0;
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
padding-bottom: 30px;
|
|
35
|
+
color: $font-graphite;
|
|
36
|
+
border-bottom: 2px solid $font-primary;
|
|
37
|
+
display: none;
|
|
38
|
+
@media screen and (max-width: ${hide_tabs_width}px) {
|
|
39
|
+
display: block;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
46
42
|
|
|
47
|
-
@media screen and (max-width: ${hide_tabs_width}px) {
|
|
48
43
|
.tab-content {
|
|
49
|
-
|
|
44
|
+
padding-top: 30px;
|
|
45
|
+
clear: both;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@media screen and (max-width: ${hide_tabs_width}px) {
|
|
49
|
+
.tab-content {
|
|
50
|
+
display: block !important;
|
|
51
|
+
}
|
|
50
52
|
}
|
|
51
|
-
|
|
52
|
-
</style>`;
|
|
53
|
+
</style>`;
|
|
53
54
|
|
|
54
55
|
export function tabs(
|
|
55
56
|
tabs: Record<string, FlatTemplatable>,
|
|
@@ -10,7 +10,7 @@ export function toggleModal(options: {
|
|
|
10
10
|
}) {
|
|
11
11
|
const { contentWrapped, contentUnwrapped, name } = options;
|
|
12
12
|
const id = makeSlug(name);
|
|
13
|
-
return tempstream/* HTML */ `<style>
|
|
13
|
+
return tempstream /* HTML */ `<style>
|
|
14
14
|
.toggle-modal__wrapped {
|
|
15
15
|
display: none;
|
|
16
16
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference lib="dom" />
|
|
2
|
+
import { Controller } from "stimulus";
|
|
3
|
+
|
|
4
|
+
export default class extends Controller {
|
|
5
|
+
static targets = ["textarea"];
|
|
6
|
+
defaultRowsNumber = 20;
|
|
7
|
+
|
|
8
|
+
addRow() {
|
|
9
|
+
const template = this.element
|
|
10
|
+
.closest("turbo-frame")
|
|
11
|
+
?.querySelector("template");
|
|
12
|
+
if (!template) {
|
|
13
|
+
throw new Error("Couldn't find template");
|
|
14
|
+
}
|
|
15
|
+
const tbody = this.element
|
|
16
|
+
.closest("turbo-frame")
|
|
17
|
+
?.querySelector("tbody");
|
|
18
|
+
if (!tbody) {
|
|
19
|
+
throw new Error("tbody not found");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const orig_template = template.innerHTML;
|
|
23
|
+
const placeholder = this.element.getAttribute("data-table-placeholder");
|
|
24
|
+
if (!placeholder) {
|
|
25
|
+
throw new Error("Could find placeholder attribute");
|
|
26
|
+
}
|
|
27
|
+
template.innerHTML = orig_template.replaceAll(
|
|
28
|
+
placeholder,
|
|
29
|
+
String(tbody.querySelectorAll("tr").length)
|
|
30
|
+
);
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
32
|
+
tbody.appendChild((template.cloneNode(true) as any).content);
|
|
33
|
+
template.innerHTML = orig_template;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -22,16 +22,13 @@ export const rewrite_asset_imports_plugin = (project_dir: string) => ({
|
|
|
22
22
|
`^import ([^ ]+, )?(\\w+|{[^}]+}) from "([^"]+)";`,
|
|
23
23
|
"gm"
|
|
24
24
|
);
|
|
25
|
-
contents = contents.replaceAll(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return replaced;
|
|
33
|
-
}
|
|
34
|
-
);
|
|
25
|
+
contents = contents.replaceAll(regex_import, (line) => {
|
|
26
|
+
const replaced = line.replace(
|
|
27
|
+
`"src/`,
|
|
28
|
+
`"` + resolve(project_dir, "./dist") + "/"
|
|
29
|
+
);
|
|
30
|
+
return replaced;
|
|
31
|
+
});
|
|
35
32
|
|
|
36
33
|
return {
|
|
37
34
|
contents,
|
|
@@ -6,8 +6,8 @@ import qs from "qs";
|
|
|
6
6
|
import { Field, FieldsetOutput } from "sealious";
|
|
7
7
|
import { tempstream } from "tempstream";
|
|
8
8
|
import { FormField } from "../fields/field.js";
|
|
9
|
-
import {
|
|
10
|
-
import { StructuredArrayField } from "../fields/structured-array.js";
|
|
9
|
+
import { TextBasedSimpleField } from "../fields/simple-form-field.js";
|
|
10
|
+
import { StructuredArray as StructuredArrayField } from "../fields/structured-array.js";
|
|
11
11
|
import { FormDataValue } from "../form-types.js";
|
|
12
12
|
import { Derived } from "./derived.js";
|
|
13
13
|
import { FormControl, FormControlContext } from "./form-control.js";
|
|
@@ -16,11 +16,11 @@ import { FormFieldControl } from "./form-field-control.js";
|
|
|
16
16
|
export type UnboundControlStorage<
|
|
17
17
|
F extends { new (...args: any): FormFieldControl } = {
|
|
18
18
|
new (...args: any): FormFieldControl;
|
|
19
|
-
}
|
|
19
|
+
},
|
|
20
20
|
> = [F, string, ConstructorParameters<F>];
|
|
21
21
|
|
|
22
22
|
export function UnboundControl<
|
|
23
|
-
F extends { new (...args: any): FormFieldControl }
|
|
23
|
+
F extends { new (...args: any): FormFieldControl },
|
|
24
24
|
>(
|
|
25
25
|
controlClass: F,
|
|
26
26
|
arbitrary_field_name: string,
|
|
@@ -30,7 +30,7 @@ export function UnboundControl<
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export class StructuredArray<
|
|
33
|
-
Subfields extends Record<string, Field<any
|
|
33
|
+
Subfields extends Record<string, Field<any>>,
|
|
34
34
|
> extends FormFieldControl {
|
|
35
35
|
constructor(
|
|
36
36
|
public field: StructuredArrayField<Subfields>,
|
|
@@ -58,7 +58,7 @@ export class StructuredArray<
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
makeSubfield(_field_name: string): FormField {
|
|
61
|
-
return new
|
|
61
|
+
return new TextBasedSimpleField(false);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
async renderItemControl(
|
|
@@ -70,14 +70,13 @@ export class StructuredArray<
|
|
|
70
70
|
) {
|
|
71
71
|
const fctx = {
|
|
72
72
|
ctx,
|
|
73
|
-
data: {},
|
|
73
|
+
data: { raw_values: {}, messages: [], field_messages: {} },
|
|
74
74
|
messages: [],
|
|
75
75
|
field_name_prefix: "",
|
|
76
76
|
form_id,
|
|
77
77
|
validate: false,
|
|
78
|
-
};
|
|
78
|
+
} as FormControlContext;
|
|
79
79
|
if (Array.isArray(control)) {
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
81
80
|
const [constructor, field_name, params] = control;
|
|
82
81
|
const field = this.makeSubfield(field_name);
|
|
83
82
|
if (!field) {
|
|
@@ -86,20 +85,16 @@ export class StructuredArray<
|
|
|
86
85
|
);
|
|
87
86
|
return "";
|
|
88
87
|
}
|
|
89
|
-
|
|
90
|
-
`${this.field.name}[data][${index}][${field_name}]`
|
|
91
|
-
);
|
|
88
|
+
field.setName(`${this.field.name}[data][${index}][${field_name}]`);
|
|
92
89
|
const hidden_shadow = new Derived(
|
|
93
90
|
[field],
|
|
94
|
-
async (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
form="${inner_form_id}"
|
|
102
|
-
/>`,
|
|
91
|
+
async (values, { inner_form_id, field_name }) =>
|
|
92
|
+
/* HTML */ `<input
|
|
93
|
+
name="${field_name}"
|
|
94
|
+
type="hidden"
|
|
95
|
+
value="${values[field_name] || ""}"
|
|
96
|
+
form="${inner_form_id}"
|
|
97
|
+
/>`,
|
|
103
98
|
async () => ({
|
|
104
99
|
inner_form_id: this.getInnerFormID(),
|
|
105
100
|
field_name: field.name,
|
|
@@ -107,10 +102,22 @@ export class StructuredArray<
|
|
|
107
102
|
);
|
|
108
103
|
return tempstream`${new constructor(field, params).render({
|
|
109
104
|
...fctx,
|
|
110
|
-
data: {
|
|
105
|
+
data: {
|
|
106
|
+
raw_values: {
|
|
107
|
+
[field.name]: item[field_name] as FormDataValue,
|
|
108
|
+
},
|
|
109
|
+
messages: [],
|
|
110
|
+
field_messages: {},
|
|
111
|
+
},
|
|
111
112
|
})}${hidden_shadow.render({
|
|
112
113
|
...fctx,
|
|
113
|
-
data: {
|
|
114
|
+
data: {
|
|
115
|
+
raw_values: {
|
|
116
|
+
[field.name]: item[field_name] as FormDataValue,
|
|
117
|
+
},
|
|
118
|
+
messages: [],
|
|
119
|
+
field_messages: {},
|
|
120
|
+
},
|
|
114
121
|
form_id: this.getInnerFormID(),
|
|
115
122
|
})}`;
|
|
116
123
|
} else {
|
|
@@ -124,7 +131,7 @@ export class StructuredArray<
|
|
|
124
131
|
item: FieldsetOutput<Subfields>,
|
|
125
132
|
index: number
|
|
126
133
|
) {
|
|
127
|
-
return tempstream/* HTML */ `<div>
|
|
134
|
+
return tempstream /* HTML */ `<div>
|
|
128
135
|
${this.item_controls.map((control) =>
|
|
129
136
|
this.renderItemControl(ctx, form_id, control, item, index)
|
|
130
137
|
)}
|
|
@@ -140,9 +147,8 @@ export class StructuredArray<
|
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
async getItems(ctx: Context, raw_values: Record<string, FormDataValue>) {
|
|
143
|
-
return (await this.field.
|
|
144
|
-
FieldsetOutput<Subfields>[]
|
|
145
|
-
>;
|
|
150
|
+
return (await this.field.getParsedValue(ctx, raw_values))
|
|
151
|
+
.parsed as FieldsetOutput<Subfields>[];
|
|
146
152
|
}
|
|
147
153
|
|
|
148
154
|
async _render(
|
|
@@ -152,7 +158,7 @@ export class StructuredArray<
|
|
|
152
158
|
) {
|
|
153
159
|
const items = await this.getItems(ctx, raw_values);
|
|
154
160
|
|
|
155
|
-
return tempstream/* HTML */ `<turbo-frame id="${this.getFrameID()}">
|
|
161
|
+
return tempstream /* HTML */ `<turbo-frame id="${this.getFrameID()}">
|
|
156
162
|
Reverse Single Reference
|
|
157
163
|
${items.map((item, index) =>
|
|
158
164
|
this.renderItem(ctx, form_id, item, index)
|
|
@@ -170,7 +176,7 @@ export class StructuredArray<
|
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
render(fctx: FormControlContext) {
|
|
173
|
-
return this._render(fctx.ctx, fctx.form_id, fctx.data);
|
|
179
|
+
return this._render(fctx.ctx, fctx.form_id, fctx.data.raw_values);
|
|
174
180
|
}
|
|
175
181
|
|
|
176
182
|
async getTargetItemID(ctx: Context): Promise<string> {
|
|
@@ -179,7 +185,6 @@ export class StructuredArray<
|
|
|
179
185
|
}
|
|
180
186
|
|
|
181
187
|
mount(router: Router) {
|
|
182
|
-
console.log("mounting!", this.getActionURL());
|
|
183
188
|
router.post(this.getActionURL(), async (ctx) => {
|
|
184
189
|
const form_id = ctx.query.form_id;
|
|
185
190
|
if (typeof form_id != "string") {
|
|
@@ -198,7 +203,6 @@ export class StructuredArray<
|
|
|
198
203
|
const field_data = (ctx.$body as Record<string, unknown>)[
|
|
199
204
|
this.field.name
|
|
200
205
|
] || { data: [] };
|
|
201
|
-
console.log({ action: field_data });
|
|
202
206
|
if (
|
|
203
207
|
!hasShape(
|
|
204
208
|
{
|
|
@@ -215,12 +219,7 @@ export class StructuredArray<
|
|
|
215
219
|
...ctx.$body.action,
|
|
216
220
|
data: field_data.data || [],
|
|
217
221
|
});
|
|
218
|
-
console.log("ACTION", {
|
|
219
|
-
...ctx.$body.action,
|
|
220
|
-
data: field_data.data || [],
|
|
221
|
-
});
|
|
222
222
|
await item.save(ctx.$context);
|
|
223
|
-
console.log(await item.getDecodedBody(ctx.$context, {}));
|
|
224
223
|
ctx.body = this._render(
|
|
225
224
|
ctx,
|
|
226
225
|
form_id,
|
|
@@ -4,7 +4,7 @@ import { PickFromListField } from "../fields/pick-from-list.js";
|
|
|
4
4
|
import { FormControlContext } from "./form-control.js";
|
|
5
5
|
import { SimpleInput } from "./simple-input.js";
|
|
6
6
|
|
|
7
|
-
export class Autocomplete extends SimpleInput
|
|
7
|
+
export class Autocomplete extends SimpleInput {
|
|
8
8
|
constructor(
|
|
9
9
|
public field: PickFromListField<boolean>,
|
|
10
10
|
public options: { id?: string; label?: string; placeholder?: string }
|
|
@@ -24,7 +24,7 @@ export class Autocomplete extends SimpleInput<string | null> {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async postInput(ctx: Context) {
|
|
27
|
-
return tempstream/* HTML */ `<datalist id="${this.getListID()}">
|
|
27
|
+
return tempstream /* HTML */ `<datalist id="${this.getListID()}">
|
|
28
28
|
${(await this.field.generateOptions(ctx)).map(
|
|
29
29
|
({ value }) => /* HTML */ `<option>${value}</option>`
|
|
30
30
|
)}
|
|
@@ -19,14 +19,14 @@ export class BigRadioGroup extends FormFieldControl {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
async render(fctx: FormControlContext): Promise<FlatTemplatable> {
|
|
22
|
-
const { raw: current_value } = await this.field.
|
|
22
|
+
const { raw: current_value } = await this.field.getParsedValue(
|
|
23
23
|
fctx.ctx,
|
|
24
|
-
fctx.data
|
|
24
|
+
fctx.data.raw_values
|
|
25
25
|
);
|
|
26
|
-
return tempstream/* HTML */ `<div class="bigradios">
|
|
26
|
+
return tempstream /* HTML */ `<div class="bigradios">
|
|
27
27
|
${Object.entries(this.options).map(([key, { description }]) => {
|
|
28
28
|
const id = `${this.field.name}-radio-${key}`;
|
|
29
|
-
return tempstream/* HTML */ `<input
|
|
29
|
+
return tempstream /* HTML */ `<input
|
|
30
30
|
type="radio"
|
|
31
31
|
name="${this.field.name}"
|
|
32
32
|
value="${key}"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FlatTemplatable } from "tempstream";
|
|
2
|
-
import { EnumMultipleField } from "../fields/enum-multiple.js";
|
|
3
2
|
import { ProxyFormField } from "../fields/proxy-field.js";
|
|
4
3
|
import { CheckboxWithValue } from "./checkbox.js";
|
|
5
4
|
import { FieldGroup } from "./field-group.js";
|
|
6
5
|
import { FormControlContext } from "./form-control.js";
|
|
7
6
|
import { FormFieldControl } from "./form-field-control.js";
|
|
7
|
+
import { CheckboxedListField } from "../fields/checkboxed-list.js";
|
|
8
8
|
|
|
9
9
|
export type DefaultCheckboxOptions = {
|
|
10
10
|
id?: string;
|
|
@@ -17,10 +17,10 @@ export type DefaultCheckboxOptions = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export class CheckboxGroup<
|
|
20
|
-
Options extends DefaultCheckboxOptions = DefaultCheckboxOptions
|
|
20
|
+
Options extends DefaultCheckboxOptions = DefaultCheckboxOptions,
|
|
21
21
|
> extends FormFieldControl {
|
|
22
22
|
constructor(
|
|
23
|
-
public field:
|
|
23
|
+
public field: CheckboxedListField<boolean, string>,
|
|
24
24
|
public options: Options = {} as Options
|
|
25
25
|
) {
|
|
26
26
|
super([field]);
|
|
@@ -40,28 +40,28 @@ export class CheckboxGroup<
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
async render(fctx: FormControlContext): Promise<FlatTemplatable> {
|
|
43
|
-
const { parsed: values } = await this.field.
|
|
43
|
+
const { parsed: values } = await this.field.getParsedValue(
|
|
44
44
|
fctx.ctx,
|
|
45
|
-
fctx.data
|
|
45
|
+
fctx.data.raw_values
|
|
46
46
|
);
|
|
47
|
-
const checkboxes = this.field.
|
|
47
|
+
const checkboxes = (await this.field.generateOptions(fctx.ctx)).map(
|
|
48
48
|
(option) =>
|
|
49
49
|
new CheckboxWithValue(
|
|
50
50
|
new ProxyFormField(
|
|
51
51
|
false,
|
|
52
52
|
this.field.name,
|
|
53
53
|
false,
|
|
54
|
-
(values ||
|
|
54
|
+
Object.keys(values || {}).includes(option.value)
|
|
55
55
|
),
|
|
56
56
|
{
|
|
57
|
-
id: this.field.name + "__" + option,
|
|
57
|
+
id: this.field.name + "__" + option.value,
|
|
58
58
|
label: (
|
|
59
59
|
this.options.checkboxNameToLabel ||
|
|
60
60
|
((s: string) => s)
|
|
61
|
-
)(option),
|
|
61
|
+
)(option.value),
|
|
62
62
|
default_value: false,
|
|
63
63
|
},
|
|
64
|
-
option
|
|
64
|
+
option.value
|
|
65
65
|
)
|
|
66
66
|
);
|
|
67
67
|
return this.wrapGroup(fctx, checkboxes);
|
|
@@ -23,7 +23,7 @@ describe("checkboxed-list", () => {
|
|
|
23
23
|
|
|
24
24
|
it("sends the values", async () => {
|
|
25
25
|
const port = await getPort();
|
|
26
|
-
console.
|
|
26
|
+
console.info(`Using port ${port} form checkboxed-list-input.test.ts`);
|
|
27
27
|
const app = new Koa();
|
|
28
28
|
const router = new Router();
|
|
29
29
|
|
|
@@ -71,7 +71,7 @@ describe("checkboxed-list", () => {
|
|
|
71
71
|
describe("behavior with (non)required", () => {
|
|
72
72
|
it("allows to send a form when no value is selected and fiels is not required", async () => {
|
|
73
73
|
const port = await getPort();
|
|
74
|
-
console.
|
|
74
|
+
console.info(`Using port ${port} form checkboxed-list-input.test.ts`);
|
|
75
75
|
const app = new Koa();
|
|
76
76
|
const router = new Router();
|
|
77
77
|
|
|
@@ -118,7 +118,7 @@ describe("checkboxed-list", () => {
|
|
|
118
118
|
|
|
119
119
|
it("does not allow to send a form when no value is selected and field IS required", async () => {
|
|
120
120
|
const port = await getPort();
|
|
121
|
-
console.
|
|
121
|
+
console.info(`Using port ${port} form checkboxed-list-input.test.ts`);
|
|
122
122
|
const app = new Koa();
|
|
123
123
|
const router = new Router();
|
|
124
124
|
|
|
@@ -166,7 +166,7 @@ describe("checkboxed-list", () => {
|
|
|
166
166
|
|
|
167
167
|
it("allows to send a form when no value is selected and field IS required", async () => {
|
|
168
168
|
const port = await getPort();
|
|
169
|
-
console.
|
|
169
|
+
console.info(`Using port ${port} form checkboxed-list-input.test.ts`);
|
|
170
170
|
const app = new Koa();
|
|
171
171
|
const router = new Router();
|
|
172
172
|
|
|
@@ -215,7 +215,7 @@ describe("checkboxed-list", () => {
|
|
|
215
215
|
|
|
216
216
|
it("renders the label", async () => {
|
|
217
217
|
const port = await getPort();
|
|
218
|
-
console.
|
|
218
|
+
console.info(`Using port ${port} form checkboxed-list-input.test.ts`);
|
|
219
219
|
const app = new Koa();
|
|
220
220
|
const router = new Router();
|
|
221
221
|
|
|
@@ -258,7 +258,7 @@ describe("checkboxed-list", () => {
|
|
|
258
258
|
|
|
259
259
|
it("groups checkboxes based on the value of the 'group' attribute", async () => {
|
|
260
260
|
const port = await getPort();
|
|
261
|
-
console.
|
|
261
|
+
console.info(`Using port ${port} form checkboxed-list-input.test.ts`);
|
|
262
262
|
const app = new Koa();
|
|
263
263
|
const router = new Router();
|
|
264
264
|
|
|
@@ -7,9 +7,11 @@ import {
|
|
|
7
7
|
import { FormControlContext } from "./form-control.js";
|
|
8
8
|
import { FormFieldControl } from "./form-field-control.js";
|
|
9
9
|
|
|
10
|
-
export class CheckboxedListInput
|
|
10
|
+
export class CheckboxedListInput<
|
|
11
|
+
Values extends string,
|
|
12
|
+
> extends FormFieldControl {
|
|
11
13
|
constructor(
|
|
12
|
-
public field: CheckboxedListField<boolean>,
|
|
14
|
+
public field: CheckboxedListField<boolean, Values>,
|
|
13
15
|
public options: { label: string } = { label: field.name }
|
|
14
16
|
) {
|
|
15
17
|
super([field]);
|
|
@@ -30,7 +32,11 @@ export class CheckboxedListInput extends FormFieldControl {
|
|
|
30
32
|
valid,
|
|
31
33
|
message,
|
|
32
34
|
parsed: currentValue,
|
|
33
|
-
} = await this.field.
|
|
35
|
+
} = await this.field.getParsedValue(
|
|
36
|
+
fctx.ctx,
|
|
37
|
+
fctx.data.raw_values,
|
|
38
|
+
true
|
|
39
|
+
);
|
|
34
40
|
const pickedValues = Object.entries(currentValue || {})
|
|
35
41
|
.filter(([, is_on]) => is_on)
|
|
36
42
|
.map(([key]) => key);
|
|
@@ -60,7 +66,7 @@ export class CheckboxedListInput extends FormFieldControl {
|
|
|
60
66
|
getRequiredClass(required),
|
|
61
67
|
...this.generateCountBasedClasses(options.length),
|
|
62
68
|
],
|
|
63
|
-
tempstream/* HTML */ `<label
|
|
69
|
+
tempstream /* HTML */ `<label
|
|
64
70
|
>${this.options.label || this.field.name}</label
|
|
65
71
|
>
|
|
66
72
|
${~valid && fctx.validate
|
|
@@ -70,9 +76,10 @@ export class CheckboxedListInput extends FormFieldControl {
|
|
|
70
76
|
${isVisible
|
|
71
77
|
? Object.entries(groups).map(
|
|
72
78
|
([group_label, options]) =>
|
|
73
|
-
tempstream/* HTML */ ` <h3>
|
|
79
|
+
tempstream /* HTML */ ` <h3>
|
|
74
80
|
${group_label}
|
|
75
81
|
</h3>
|
|
82
|
+
|
|
76
83
|
${options!.map(({ value, label }) =>
|
|
77
84
|
this.renderOption({
|
|
78
85
|
name,
|
|
@@ -85,7 +92,7 @@ export class CheckboxedListInput extends FormFieldControl {
|
|
|
85
92
|
),
|
|
86
93
|
})
|
|
87
94
|
)}`
|
|
88
|
-
|
|
95
|
+
)
|
|
89
96
|
: ""}
|
|
90
97
|
${isVisible
|
|
91
98
|
? ungroupped.map(({ value, label }) =>
|
|
@@ -96,7 +103,7 @@ export class CheckboxedListInput extends FormFieldControl {
|
|
|
96
103
|
form_id: fctx.form_id,
|
|
97
104
|
checked: pickedValues.includes(value),
|
|
98
105
|
})
|
|
99
|
-
|
|
106
|
+
)
|
|
100
107
|
: ""}
|
|
101
108
|
</ul>`
|
|
102
109
|
);
|
|
@@ -115,7 +122,7 @@ export class CheckboxedListInput extends FormFieldControl {
|
|
|
115
122
|
label?: string;
|
|
116
123
|
checked: boolean;
|
|
117
124
|
}) {
|
|
118
|
-
return tempstream/* HTML */ `<li>
|
|
125
|
+
return tempstream /* HTML */ `<li>
|
|
119
126
|
${inputWrapper(
|
|
120
127
|
"checkbox",
|
|
121
128
|
[name],
|
|
@@ -126,6 +133,7 @@ export class CheckboxedListInput extends FormFieldControl {
|
|
|
126
133
|
name="${name}.${value}"
|
|
127
134
|
${checked ? "checked" : ""}
|
|
128
135
|
form=${form_id}
|
|
136
|
+
autocomplete="off"
|
|
129
137
|
/>
|
|
130
138
|
<label for="${name}.${value}">${label || value}</label>
|
|
131
139
|
`
|
|
@@ -23,10 +23,10 @@ export * from "./collapsible-field-group.js";
|
|
|
23
23
|
export * from "./collapsible-checkbox-group.js";
|
|
24
24
|
export * from "./autocomplete.js";
|
|
25
25
|
export * from "./file.js";
|
|
26
|
-
export * from "./
|
|
26
|
+
export * from "./image.js";
|
|
27
27
|
export * from "./multiple-files.js";
|
|
28
28
|
export * from "./number.js";
|
|
29
|
-
export * from "./multiple-
|
|
29
|
+
export * from "./multiple-images.js";
|
|
30
30
|
// export * from "./reverse-single-reference";
|
|
31
31
|
export * from "./array.js";
|
|
32
32
|
export * from "./table.js";
|