@sealcode/sealgen 0.11.8 → 0.12.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/@types/components/components.d.ts +2 -2
- package/@types/components/toggle-modal.d.ts +1 -1
- package/@types/example.test.d.ts +1 -0
- package/@types/forms/controls/array.d.ts +7 -7
- package/@types/forms/controls/autocomplete.d.ts +3 -3
- package/@types/forms/controls/big-radio-group.d.ts +3 -3
- package/@types/forms/controls/checkbox-group.d.ts +4 -4
- package/@types/forms/controls/checkbox.d.ts +3 -3
- package/@types/forms/controls/checkboxed-list-input.d.ts +4 -4
- package/@types/forms/controls/collapsible-checkbox-group.d.ts +3 -3
- package/@types/forms/controls/collapsible-field-group.d.ts +2 -2
- package/@types/forms/controls/controls.d.ts +29 -29
- package/@types/forms/controls/derived-frame.d.ts +6 -6
- package/@types/forms/controls/derived.d.ts +3 -3
- package/@types/forms/controls/dropdown.d.ts +4 -4
- package/@types/forms/controls/editable-collection-subset.d.ts +3 -3
- package/@types/forms/controls/field-group.d.ts +2 -2
- package/@types/forms/controls/file.d.ts +5 -5
- package/@types/forms/controls/form-control.d.ts +2 -2
- package/@types/forms/controls/form-field-control.d.ts +3 -3
- package/@types/forms/controls/form-header.d.ts +2 -2
- package/@types/forms/controls/form-paragraph.d.ts +1 -1
- package/@types/forms/controls/frame.d.ts +1 -1
- package/@types/forms/controls/hidden-input.d.ts +3 -3
- package/@types/forms/controls/html.d.ts +2 -2
- package/@types/forms/controls/multiple-files.d.ts +5 -5
- package/@types/forms/controls/multiple-photos.d.ts +5 -5
- package/@types/forms/controls/number.d.ts +3 -3
- package/@types/forms/controls/photo.d.ts +7 -7
- package/@types/forms/controls/radio.d.ts +3 -3
- package/@types/forms/controls/reverse-single-reference.d.ts +1 -0
- package/@types/forms/controls/simple-input.d.ts +4 -4
- package/@types/forms/controls/textarea.d.ts +4 -4
- package/@types/forms/controls/tickable.d.ts +4 -4
- package/@types/forms/fields/boolean.d.ts +2 -2
- package/@types/forms/fields/checkboxed-list.d.ts +2 -2
- package/@types/forms/fields/collection-field.d.ts +2 -2
- package/@types/forms/fields/email.d.ts +1 -1
- package/@types/forms/fields/enum-multiple.d.ts +2 -2
- package/@types/forms/fields/enum.d.ts +2 -2
- package/@types/forms/fields/existing-sealious-value.d.ts +1 -1
- package/@types/forms/fields/field.d.ts +16 -16
- package/@types/forms/fields/file.d.ts +2 -2
- package/@types/forms/fields/multiple-files.d.ts +1 -1
- package/@types/forms/fields/number.d.ts +2 -2
- package/@types/forms/fields/pick-from-list.d.ts +3 -3
- package/@types/forms/fields/proxy-field.d.ts +1 -1
- package/@types/forms/fields/regexp.d.ts +2 -2
- package/@types/forms/fields/reverse-single-reference.d.ts +1 -1
- package/@types/forms/fields/simple-form-field.d.ts +2 -2
- package/@types/forms/fields/structured-array.d.ts +2 -2
- package/@types/forms/form.d.ts +3 -3
- package/@types/forms/form.test.d.ts +1 -1
- package/@types/forms/multiform.d.ts +4 -4
- package/@types/index.d.ts +17 -17
- package/@types/make-hidden-inputs.d.ts +2 -2
- package/@types/mount.d.ts +2 -2
- package/@types/page/list.d.ts +4 -4
- package/@types/page/mountable-with-fields.d.ts +4 -4
- package/@types/page/mountable.d.ts +1 -1
- package/@types/page/page.d.ts +4 -4
- package/@types/page/props-parser.d.ts +2 -2
- package/@types/page/sealious-list.d.ts +1 -1
- package/@types/page/stateful-page.d.ts +3 -3
- package/@types/remove-named-imports.d.ts +4 -0
- package/@types/run.d.ts +1 -0
- package/@types/src/add-collection.d.ts +1 -0
- package/@types/src/add-jdd-component.d.ts +1 -0
- package/@types/src/add-route.d.ts +3 -0
- package/@types/src/add-route.test.d.ts +1 -0
- package/@types/src/build.d.ts +3 -0
- package/@types/src/cli.d.ts +2 -0
- package/@types/src/components/components.d.ts +2 -0
- package/@types/src/components/tabs.d.ts +2 -0
- package/@types/src/components/toggle-modal.d.ts +7 -0
- package/@types/src/example.test.d.ts +1 -0
- package/@types/src/find-css-includes.d.ts +1 -0
- package/@types/src/forms/controls/array.d.ts +35 -0
- package/@types/src/forms/controls/autocomplete.d.ts +22 -0
- package/@types/src/forms/controls/big-radio-group.d.ts +14 -0
- package/@types/src/forms/controls/checkbox-group.d.ts +22 -0
- package/@types/src/forms/controls/checkbox.d.ts +15 -0
- package/@types/src/forms/controls/checkboxed-list-input.d.ts +14 -0
- package/@types/src/forms/controls/collapsible-checkbox-group.d.ts +11 -0
- package/@types/src/forms/controls/collapsible-field-group.d.ts +21 -0
- package/@types/src/forms/controls/controls.d.ts +29 -0
- package/@types/src/forms/controls/derived-frame.d.ts +22 -0
- package/@types/src/forms/controls/derived.d.ts +13 -0
- package/@types/src/forms/controls/dropdown.d.ts +30 -0
- package/@types/src/forms/controls/editable-collection-subset.d.ts +20 -0
- package/@types/src/forms/controls/field-group.d.ts +23 -0
- package/@types/src/forms/controls/file.d.ts +16 -0
- package/@types/src/forms/controls/form-control.d.ts +19 -0
- package/@types/src/forms/controls/form-field-control.d.ts +13 -0
- package/@types/src/forms/controls/form-header.d.ts +8 -0
- package/@types/src/forms/controls/form-paragraph.d.ts +7 -0
- package/@types/src/forms/controls/frame.d.ts +17 -0
- package/@types/src/forms/controls/hidden-input.d.ts +9 -0
- package/@types/src/forms/controls/html.d.ts +11 -0
- package/@types/src/forms/controls/multiple-files.d.ts +40 -0
- package/@types/src/forms/controls/multiple-photos.d.ts +18 -0
- package/@types/src/forms/controls/number.d.ts +13 -0
- package/@types/src/forms/controls/photo.d.ts +22 -0
- package/@types/src/forms/controls/radio.d.ts +16 -0
- package/@types/src/forms/controls/reverse-single-reference.d.ts +1 -0
- package/@types/src/forms/controls/simple-input.d.ts +32 -0
- package/@types/src/forms/controls/textarea.d.ts +25 -0
- package/@types/src/forms/controls/tickable.d.ts +24 -0
- package/@types/src/forms/fields/boolean.d.ts +17 -0
- package/@types/src/forms/fields/boolean.test.d.ts +1 -0
- package/@types/src/forms/fields/checkboxed-list.d.ts +20 -0
- package/@types/src/forms/fields/collection-field.d.ts +15 -0
- package/@types/src/forms/fields/email.d.ts +7 -0
- package/@types/src/forms/fields/email.test.d.ts +1 -0
- package/@types/src/forms/fields/enum-multiple.d.ts +18 -0
- package/@types/src/forms/fields/enum-multiple.test.d.ts +1 -0
- package/@types/src/forms/fields/enum.d.ts +18 -0
- package/@types/src/forms/fields/enum.test.d.ts +1 -0
- package/@types/src/forms/fields/existing-sealious-value.d.ts +6 -0
- package/@types/src/forms/fields/field.d.ts +43 -0
- package/@types/src/forms/fields/fields.d.ts +15 -0
- package/@types/src/forms/fields/file.d.ts +16 -0
- package/@types/src/forms/fields/multiple-files.d.ts +14 -0
- package/@types/src/forms/fields/number.d.ts +23 -0
- package/@types/src/forms/fields/number.test.d.ts +1 -0
- package/@types/src/forms/fields/pick-from-list.d.ts +14 -0
- package/@types/src/forms/fields/pick-from-list.test.d.ts +1 -0
- package/@types/src/forms/fields/proxy-field.d.ts +13 -0
- package/@types/src/forms/fields/regexp.d.ts +16 -0
- package/@types/src/forms/fields/regexp.test.d.ts +1 -0
- package/@types/src/forms/fields/reverse-single-reference.d.ts +13 -0
- package/@types/src/forms/fields/simple-form-field.d.ts +9 -0
- package/@types/src/forms/fields/structured-array.d.ts +14 -0
- package/@types/src/forms/form-types.d.ts +26 -0
- package/@types/src/forms/form.d.ts +31 -0
- package/@types/src/forms/form.test.d.ts +6 -0
- package/@types/src/forms/multiform.d.ts +24 -0
- package/@types/src/forms/multiform.test.d.ts +1 -0
- package/@types/src/generate-collections.d.ts +2 -0
- package/@types/src/generate-components.d.ts +1 -0
- package/@types/src/generate-routes.d.ts +1 -0
- package/@types/src/hehe.test.d.ts +1 -0
- package/@types/src/index.d.ts +27 -0
- package/@types/src/make-env.d.ts +1 -0
- package/@types/src/make-hidden-inputs.d.ts +5 -0
- package/@types/src/mount.d.ts +6 -0
- package/@types/src/notifier.d.ts +1 -0
- package/@types/src/page/access-control.d.ts +6 -0
- package/@types/src/page/default-list-filters.d.ts +6 -0
- package/@types/src/page/list.d.ts +47 -0
- package/@types/src/page/mountable-with-fields.d.ts +36 -0
- package/@types/src/page/mountable.d.ts +11 -0
- package/@types/src/page/page.d.ts +19 -0
- package/@types/src/page/props-parser.d.ts +16 -0
- package/@types/src/page/sealious-list.d.ts +19 -0
- package/@types/src/page/stateful-page.d.ts +34 -0
- package/@types/src/run.d.ts +1 -0
- package/@types/src/sample-index.d.ts +1 -0
- package/@types/src/sample-lib.d.ts +3 -0
- package/@types/src/sanitize.d.ts +1 -0
- package/@types/src/templates/collection.d.ts +1 -0
- package/@types/src/templates/form.d.ts +1 -0
- package/@types/src/templates/jdd-component.d.ts +1 -0
- package/@types/src/templates/list.d.ts +1 -0
- package/@types/src/templates/long-running-process.d.ts +1 -0
- package/@types/src/templates/multiform.d.ts +1 -0
- package/@types/src/templates/page.d.ts +1 -0
- package/@types/src/templates/post.d.ts +1 -0
- package/@types/src/templates/redirect.d.ts +1 -0
- package/@types/src/templates/route-test.d.ts +1 -0
- package/@types/src/templates/stateful-page.d.ts +1 -0
- package/@types/src/templates/templates.d.ts +19 -0
- package/@types/src/test_utils/locator_is_visible.d.ts +2 -0
- package/@types/src/utils/assert-throws.d.ts +1 -0
- package/@types/src/utils/base64.d.ts +2 -0
- package/@types/src/utils/browser-creator.d.ts +1 -0
- package/@types/src/utils/escape-url-params.d.ts +2 -0
- package/@types/src/utils/exec.d.ts +5 -0
- package/@types/src/utils/extract-fields-from-collection.d.ts +4 -0
- package/@types/src/utils/format-external-url.d.ts +1 -0
- package/@types/src/utils/import-path.d.ts +2 -0
- package/@types/src/utils/input-wrapper.d.ts +5 -0
- package/@types/src/utils/list-collections.d.ts +1 -0
- package/@types/src/utils/make-slug.d.ts +1 -0
- package/@types/src/utils/natural-numbers.d.ts +1 -0
- package/@types/src/utils/prettier.d.ts +2 -0
- package/@types/src/utils/question.d.ts +1 -0
- package/@types/src/utils/render-attributes.d.ts +1 -0
- package/@types/src/utils/sleep.d.ts +1 -0
- package/@types/src/utils/translate.d.ts +3 -0
- package/@types/src/utils/url-with-new-params.d.ts +2 -0
- package/@types/src/utils/utils.d.ts +16 -0
- package/@types/src/utils/walk.d.ts +1 -0
- package/@types/src/vitest.config.d.ts +2 -0
- package/@types/templates/templates.d.ts +8 -8
- package/@types/utils/input-wrapper.d.ts +1 -1
- package/@types/utils/utils.d.ts +12 -12
- package/@types/vitest.config.d.ts +2 -0
- package/build.js +18 -0
- package/dist/add-collection.js +31 -0
- package/dist/add-jdd-component.js +42 -0
- package/dist/add-route.js +67 -0
- package/dist/add-route.test.js +90 -0
- package/dist/back/routes/sample.page.js +17 -0
- package/dist/back/routes/sample.test.js +39 -0
- package/dist/build.js +149 -0
- package/dist/cli.js +35 -0
- package/dist/components/components.js +3 -0
- package/{lib → dist}/components/tabs.js +32 -23
- package/{lib → dist}/components/toggle-modal.js +9 -10
- package/dist/example.test.js +5 -0
- package/dist/find-css-includes.js +27 -0
- package/dist/forms/controls/array.js +171 -0
- package/dist/forms/controls/autocomplete.js +34 -0
- package/dist/forms/controls/big-radio-group.js +38 -0
- package/dist/forms/controls/checkbox-group.js +46 -0
- package/dist/forms/controls/checkbox.js +28 -0
- package/dist/forms/controls/checkboxed-list-input.js +44 -0
- package/dist/forms/controls/collapsible-checkbox-group.js +16 -0
- package/{lib → dist}/forms/controls/collapsible-field-group.js +32 -27
- package/dist/forms/controls/controls.js +44 -0
- package/dist/forms/controls/derived-frame.js +77 -0
- package/dist/forms/controls/derived.js +81 -0
- package/dist/forms/controls/dropdown.js +62 -0
- package/dist/forms/controls/editable-collection-subset.js +82 -0
- package/dist/forms/controls/field-group.js +52 -0
- package/dist/forms/controls/file.js +38 -0
- package/dist/forms/controls/form-control.js +19 -0
- package/dist/forms/controls/form-field-control.js +12 -0
- package/dist/forms/controls/form-header.js +17 -0
- package/dist/forms/controls/form-paragraph.js +15 -0
- package/dist/forms/controls/frame.js +22 -0
- package/dist/forms/controls/hidden-input.js +17 -0
- package/dist/forms/controls/html.js +23 -0
- package/dist/forms/controls/multiple-files.js +190 -0
- package/dist/forms/controls/multiple-photos.js +36 -0
- package/dist/forms/controls/number.js +24 -0
- package/dist/forms/controls/photo.js +56 -0
- package/dist/forms/controls/radio.js +28 -0
- package/dist/forms/controls/reverse-single-reference.js +1 -0
- package/dist/forms/controls/simple-input.js +85 -0
- package/dist/forms/controls/textarea.js +40 -0
- package/dist/forms/controls/tickable.js +72 -0
- package/dist/forms/fields/boolean.js +49 -0
- package/dist/forms/fields/boolean.test.js +33 -0
- package/dist/forms/fields/checkboxed-list.js +49 -0
- package/dist/forms/fields/collection-field.js +47 -0
- package/dist/forms/fields/email.js +19 -0
- package/dist/forms/fields/email.test.js +20 -0
- package/dist/forms/fields/enum-multiple.js +47 -0
- package/dist/forms/fields/enum-multiple.test.js +27 -0
- package/dist/forms/fields/enum.js +41 -0
- package/dist/forms/fields/enum.test.js +21 -0
- package/dist/forms/fields/existing-sealious-value.js +21 -0
- package/dist/forms/fields/field.js +82 -0
- package/dist/forms/fields/fields.js +16 -0
- package/dist/forms/fields/file.js +63 -0
- package/dist/forms/fields/multiple-files.js +18 -0
- package/dist/forms/fields/number.js +42 -0
- package/dist/forms/fields/number.test.js +31 -0
- package/dist/forms/fields/pick-from-list.js +34 -0
- package/dist/forms/fields/pick-from-list.test.js +17 -0
- package/dist/forms/fields/proxy-field.js +23 -0
- package/dist/forms/fields/regexp.js +42 -0
- package/dist/forms/fields/regexp.test.js +21 -0
- package/dist/forms/fields/reverse-single-reference.js +17 -0
- package/dist/forms/fields/simple-form-field.js +22 -0
- package/dist/forms/fields/structured-array.js +21 -0
- package/dist/forms/form-types.js +1 -0
- package/dist/forms/form.js +203 -0
- package/dist/forms/form.test.js +316 -0
- package/dist/forms/multiform.js +200 -0
- package/dist/forms/multiform.test.js +486 -0
- package/dist/generate-collections.js +65 -0
- package/dist/generate-components.js +41 -0
- package/dist/generate-routes.js +90 -0
- package/dist/hehe.test.js +7 -0
- package/dist/index.js +26 -0
- package/dist/make-env.js +17 -0
- package/dist/make-hidden-inputs.js +15 -0
- package/dist/mount.js +66 -0
- package/dist/notifier.js +21 -0
- package/dist/page/access-control.js +19 -0
- package/dist/page/default-list-filters.js +46 -0
- package/dist/page/list.js +199 -0
- package/dist/page/mountable-with-fields.js +106 -0
- package/dist/page/mountable.js +9 -0
- package/dist/page/page.js +31 -0
- package/dist/page/props-parser.js +24 -0
- package/dist/page/sealious-list.js +61 -0
- package/dist/page/stateful-page.js +123 -0
- package/dist/run.js +1 -0
- package/dist/sample-index.js +3 -0
- package/dist/sample-lib.js +9 -0
- package/dist/sanitize.js +10 -0
- package/dist/templates/collection.js +15 -0
- package/{lib → dist}/templates/form.js +8 -9
- package/dist/templates/jdd-component.js +44 -0
- package/{lib → dist}/templates/list.js +47 -49
- package/{lib → dist}/templates/long-running-process.js +7 -8
- package/{lib → dist}/templates/multiform.js +7 -8
- package/{lib → dist}/templates/page.js +7 -8
- package/{lib → dist}/templates/post.js +5 -6
- package/{lib → dist}/templates/redirect.js +5 -6
- package/{lib → dist}/templates/route-test.js +12 -9
- package/{lib → dist}/templates/stateful-page.js +7 -8
- package/dist/templates/templates.js +24 -0
- package/dist/test_utils/locator_is_visible.js +14 -0
- package/dist/utils/assert-throws.js +18 -0
- package/dist/utils/base64.js +11 -0
- package/dist/utils/browser-creator.js +11 -0
- package/dist/utils/escape-url-params.js +11 -0
- package/dist/utils/exec.js +29 -0
- package/dist/utils/extract-fields-from-collection.js +33 -0
- package/dist/utils/format-external-url.js +11 -0
- package/dist/utils/import-path.js +23 -0
- package/dist/utils/input-wrapper.js +19 -0
- package/dist/utils/list-collections.js +13 -0
- package/dist/utils/make-slug.js +7 -0
- package/dist/utils/natural-numbers.js +9 -0
- package/dist/utils/prettier.js +15 -0
- package/dist/utils/question.js +20 -0
- package/dist/utils/render-attributes.js +18 -0
- package/dist/utils/sleep.js +7 -0
- package/dist/utils/translate.js +12 -0
- package/dist/utils/url-with-new-params.js +8 -0
- package/dist/utils/utils.js +28 -0
- package/dist/utils/walk.js +23 -0
- package/dist/vitest.config.js +23 -0
- package/package.json +22 -21
- package/remove-named-imports.js +65 -0
- package/src/add-collection.ts +3 -3
- package/src/add-jdd-component.ts +3 -3
- package/src/add-route.test.ts +38 -10
- package/src/add-route.ts +5 -5
- package/src/build.ts +16 -90
- package/src/cli.ts +14 -13
- package/src/components/components.ts +2 -2
- package/src/components/toggle-modal.ts +1 -1
- package/src/find-css-includes.ts +1 -1
- package/src/forms/controls/array.ts +9 -8
- package/src/forms/controls/autocomplete.ts +4 -4
- package/src/forms/controls/big-radio-group.ts +3 -3
- package/src/forms/controls/checkbox-group.ts +7 -6
- package/src/forms/controls/checkbox.ts +3 -3
- package/src/forms/controls/checkboxed-list-input.ts +4 -6
- package/src/forms/controls/collapsible-checkbox-group.ts +4 -7
- package/src/forms/controls/collapsible-field-group.ts +2 -2
- package/src/forms/controls/controls.ts +29 -29
- package/src/forms/controls/derived-frame.ts +4 -4
- package/src/forms/controls/derived.ts +3 -3
- package/src/forms/controls/dropdown.ts +6 -5
- package/src/forms/controls/editable-collection-subset.ts +4 -4
- package/src/forms/controls/field-group.ts +2 -4
- package/src/forms/controls/file.ts +4 -4
- package/src/forms/controls/form-control.ts +1 -1
- package/src/forms/controls/form-field-control.ts +3 -4
- package/src/forms/controls/form-header.ts +1 -3
- package/src/forms/controls/form-paragraph.ts +1 -1
- package/src/forms/controls/frame.ts +2 -2
- package/src/forms/controls/hidden-input.ts +5 -5
- package/src/forms/controls/html.ts +1 -4
- package/src/forms/controls/multiple-files.ts +24 -26
- package/src/forms/controls/multiple-photos.ts +4 -4
- package/src/forms/controls/number.ts +3 -6
- package/src/forms/controls/photo.ts +9 -8
- package/src/forms/controls/radio.ts +3 -3
- package/src/forms/controls/simple-input.ts +6 -6
- package/src/forms/controls/textarea.ts +4 -4
- package/src/forms/controls/tickable.ts +6 -6
- package/src/forms/fields/boolean.test.ts +2 -1
- package/src/forms/fields/boolean.ts +2 -2
- package/src/forms/fields/checkboxed-list.ts +2 -2
- package/src/forms/fields/collection-field.ts +2 -2
- package/src/forms/fields/email.test.ts +1 -1
- package/src/forms/fields/email.ts +1 -1
- package/src/forms/fields/enum-multiple.test.ts +1 -1
- package/src/forms/fields/enum-multiple.ts +2 -2
- package/src/forms/fields/enum.test.ts +1 -1
- package/src/forms/fields/enum.ts +2 -2
- package/src/forms/fields/existing-sealious-value.ts +1 -1
- package/src/forms/fields/field.ts +2 -18
- package/src/forms/fields/fields.ts +15 -0
- package/src/forms/fields/file.ts +8 -9
- package/src/forms/fields/multiple-files.ts +1 -1
- package/src/forms/fields/number.test.ts +2 -1
- package/src/forms/fields/number.ts +2 -2
- package/src/forms/fields/pick-from-list.test.ts +1 -1
- package/src/forms/fields/pick-from-list.ts +3 -3
- package/src/forms/fields/proxy-field.ts +1 -1
- package/src/forms/fields/regexp.test.ts +1 -1
- package/src/forms/fields/regexp.ts +2 -2
- package/src/forms/fields/reverse-single-reference.ts +1 -1
- package/src/forms/fields/simple-form-field.ts +2 -2
- package/src/forms/fields/structured-array.ts +2 -2
- package/src/forms/form-types.ts +30 -0
- package/src/forms/form.test.ts +16 -13
- package/src/forms/form.ts +11 -31
- package/src/forms/multiform.test.ts +33 -28
- package/src/forms/multiform.ts +4 -3
- package/src/generate-collections.ts +1 -1
- package/src/generate-components.ts +3 -1
- package/src/generate-routes.ts +5 -5
- package/src/index.ts +19 -17
- package/src/make-hidden-inputs.ts +3 -3
- package/src/mount.ts +5 -5
- package/src/page/list.ts +8 -6
- package/src/page/mountable-with-fields.ts +8 -4
- package/src/page/page.ts +3 -4
- package/src/page/props-parser.ts +2 -2
- package/src/page/sealious-list.ts +2 -2
- package/src/page/stateful-page.ts +3 -3
- package/src/templates/form.ts +1 -1
- package/src/templates/list.ts +6 -6
- package/src/templates/long-running-process.ts +1 -1
- package/src/templates/multiform.ts +1 -1
- package/src/templates/page.ts +1 -1
- package/src/templates/route-test.ts +1 -1
- package/src/templates/stateful-page.ts +1 -1
- package/src/templates/templates.ts +9 -9
- package/src/test_utils/locator_is_visible.ts +1 -1
- package/src/utils/extract-fields-from-collection.ts +1 -1
- package/src/utils/list-collections.ts +1 -1
- package/src/utils/prettier.ts +2 -2
- package/src/utils/render-attributes.ts +1 -1
- package/src/utils/utils.ts +12 -12
- package/src/vitest.config.ts +21 -0
- package/tsconfig.json +12 -5
- package/lib/add-collection.js +0 -31
- package/lib/add-jdd-component.js +0 -34
- package/lib/add-route.js +0 -72
- package/lib/add-route.test.js +0 -66
- package/lib/build.js +0 -217
- package/lib/cli.js +0 -36
- package/lib/components/components.js +0 -19
- package/lib/example.test.js +0 -4
- package/lib/find-css-includes.js +0 -30
- package/lib/find-scss-includes.js +0 -30
- package/lib/forms/controls/array.js +0 -148
- package/lib/forms/controls/autocomplete.js +0 -27
- package/lib/forms/controls/big-radio-group.js +0 -38
- package/lib/forms/controls/checkbox-group.js +0 -33
- package/lib/forms/controls/checkbox.js +0 -29
- package/lib/forms/controls/checkboxed-list-input.js +0 -39
- package/lib/forms/controls/collapsible-checkbox-group.js +0 -17
- package/lib/forms/controls/controls.js +0 -60
- package/lib/forms/controls/derived-frame.js +0 -56
- package/lib/forms/controls/derived.js +0 -81
- package/lib/forms/controls/dropdown.js +0 -60
- package/lib/forms/controls/editable-collection-subset.js +0 -72
- package/lib/forms/controls/field-group.js +0 -57
- package/lib/forms/controls/file.js +0 -39
- package/lib/forms/controls/form-control.js +0 -19
- package/lib/forms/controls/form-field-control.js +0 -13
- package/lib/forms/controls/form-header.js +0 -18
- package/lib/forms/controls/form-paragraph.js +0 -16
- package/lib/forms/controls/frame.js +0 -29
- package/lib/forms/controls/hidden-input.js +0 -18
- package/lib/forms/controls/html.js +0 -27
- package/lib/forms/controls/multiple-files.js +0 -164
- package/lib/forms/controls/multiple-photos.js +0 -37
- package/lib/forms/controls/number.js +0 -29
- package/lib/forms/controls/photo.js +0 -61
- package/lib/forms/controls/radio.js +0 -29
- package/lib/forms/controls/reverse-single-reference.js +0 -46
- package/lib/forms/controls/simple-input.js +0 -82
- package/lib/forms/controls/textarea.js +0 -37
- package/lib/forms/controls/tickable.js +0 -79
- package/lib/forms/fields/boolean.js +0 -55
- package/lib/forms/fields/boolean.test.js +0 -37
- package/lib/forms/fields/checkboxed-list.js +0 -44
- package/lib/forms/fields/collection-field.js +0 -33
- package/lib/forms/fields/email.js +0 -15
- package/lib/forms/fields/email.test.js +0 -25
- package/lib/forms/fields/enum-multiple.js +0 -51
- package/lib/forms/fields/enum-multiple.test.js +0 -32
- package/lib/forms/fields/enum.js +0 -43
- package/lib/forms/fields/enum.test.js +0 -26
- package/lib/forms/fields/existing-sealious-value.js +0 -20
- package/lib/forms/fields/field.js +0 -100
- package/lib/forms/fields/file.js +0 -57
- package/lib/forms/fields/multiple-files.js +0 -19
- package/lib/forms/fields/number.js +0 -49
- package/lib/forms/fields/number.test.js +0 -35
- package/lib/forms/fields/pick-from-list.js +0 -35
- package/lib/forms/fields/pick-from-list.test.js +0 -22
- package/lib/forms/fields/proxy-field.js +0 -24
- package/lib/forms/fields/regexp.js +0 -44
- package/lib/forms/fields/regexp.test.js +0 -26
- package/lib/forms/fields/reverse-single-reference.js +0 -18
- package/lib/forms/fields/simple-form-field.js +0 -23
- package/lib/forms/fields/structured-array.js +0 -22
- package/lib/forms/form.js +0 -183
- package/lib/forms/form.test.js +0 -275
- package/lib/forms/multiform.js +0 -178
- package/lib/forms/multiform.test.js +0 -431
- package/lib/generate-collections.js +0 -83
- package/lib/generate-components.js +0 -63
- package/lib/generate-routes.js +0 -105
- package/lib/index.js +0 -46
- package/lib/make-env.js +0 -21
- package/lib/make-hidden-inputs.js +0 -18
- package/lib/mount.js +0 -74
- package/lib/notifier.js +0 -26
- package/lib/page/access-control.js +0 -20
- package/lib/page/default-list-filters.js +0 -45
- package/lib/page/list.js +0 -190
- package/lib/page/mountable-with-fields.js +0 -89
- package/lib/page/mountable.js +0 -9
- package/lib/page/page.js +0 -30
- package/lib/page/props-parser.js +0 -31
- package/lib/page/sealious-list.js +0 -66
- package/lib/page/stateful-page.js +0 -104
- package/lib/run.js +0 -1
- package/lib/sanitize.js +0 -14
- package/lib/templates/collection.js +0 -16
- package/lib/templates/jdd-component.js +0 -43
- package/lib/templates/templates.js +0 -24
- package/lib/test_utils/locator_is_visible.js +0 -15
- package/lib/utils/assert-throws.js +0 -24
- package/lib/utils/base64.js +0 -12
- package/lib/utils/browser-creator.js +0 -14
- package/lib/utils/escape-url-params.js +0 -19
- package/lib/utils/exec.js +0 -26
- package/lib/utils/extract-fields-from-collection.js +0 -32
- package/lib/utils/format-external-url.js +0 -15
- package/lib/utils/import-path.js +0 -24
- package/lib/utils/input-wrapper.js +0 -20
- package/lib/utils/list-collections.js +0 -20
- package/lib/utils/make-slug.js +0 -10
- package/lib/utils/natural-numbers.js +0 -10
- package/lib/utils/prettier.js +0 -40
- package/lib/utils/question.js +0 -23
- package/lib/utils/render-attributes.js +0 -23
- package/lib/utils/sleep.js +0 -8
- package/lib/utils/translate.js +0 -10
- package/lib/utils/url-with-new-params.js +0 -12
- package/lib/utils/utils.js +0 -43
- package/lib/utils/walk.js +0 -27
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
import Router from "@koa/router";
|
|
2
|
-
import
|
|
3
|
-
Collection,
|
|
4
|
-
CollectionItem,
|
|
5
|
-
File as SealiousFile,
|
|
6
|
-
Field as SealiousField,
|
|
7
|
-
} from "sealious";
|
|
2
|
+
import Sealious from "sealious";
|
|
8
3
|
import { Context } from "koa";
|
|
9
|
-
import { inputWrapper } from "../../utils/input-wrapper";
|
|
4
|
+
import { inputWrapper } from "../../utils/input-wrapper.js";
|
|
10
5
|
import { FlatTemplatable, tempstream } from "tempstream";
|
|
11
|
-
import { MultipleFiles as MultipleFilesField } from "../fields/multiple-files";
|
|
12
|
-
import { FormFieldControl } from "./form-field-control";
|
|
6
|
+
import { MultipleFiles as MultipleFilesField } from "../fields/multiple-files.js";
|
|
7
|
+
import { FormFieldControl } from "./form-field-control.js";
|
|
13
8
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
14
|
-
import { renderAttributes } from "../../utils/render-attributes";
|
|
15
|
-
import { FormControlContext } from "./form-control";
|
|
9
|
+
import { renderAttributes } from "../../utils/render-attributes.js";
|
|
10
|
+
import { FormControlContext } from "./form-control.js";
|
|
16
11
|
|
|
17
12
|
export type MultipleFilesOptions = {
|
|
18
13
|
label?: string;
|
|
19
14
|
uploadLabel?: string;
|
|
20
15
|
getAdditionalFields: (
|
|
21
16
|
ctx: Context,
|
|
22
|
-
file:
|
|
17
|
+
file: Sealious.File
|
|
23
18
|
) => Promise<Record<string, unknown>>;
|
|
24
19
|
};
|
|
25
20
|
|
|
@@ -57,7 +52,7 @@ export class MultipleFiles extends FormFieldControl {
|
|
|
57
52
|
);
|
|
58
53
|
|
|
59
54
|
router.post(this.getFrameRelativeURL() + "/add", async (ctx) => {
|
|
60
|
-
let files = ctx.$body.files as
|
|
55
|
+
let files = ctx.$body.files as Sealious.File | Sealious.File[];
|
|
61
56
|
if (!files || !is(files, predicates.object)) {
|
|
62
57
|
ctx.body = "Missing files";
|
|
63
58
|
return;
|
|
@@ -69,7 +64,7 @@ export class MultipleFiles extends FormFieldControl {
|
|
|
69
64
|
files.map((file) =>
|
|
70
65
|
this.addFileAssociation(
|
|
71
66
|
ctx,
|
|
72
|
-
file as unknown as
|
|
67
|
+
file as unknown as Sealious.File
|
|
73
68
|
)
|
|
74
69
|
)
|
|
75
70
|
);
|
|
@@ -86,7 +81,7 @@ export class MultipleFiles extends FormFieldControl {
|
|
|
86
81
|
].removeByID(ctx.$context, file_item_id);
|
|
87
82
|
}
|
|
88
83
|
|
|
89
|
-
async addFileAssociation(ctx: Context, file:
|
|
84
|
+
async addFileAssociation(ctx: Context, file: Sealious.File) {
|
|
90
85
|
const file_field = this.getFileField();
|
|
91
86
|
if (!file_field) {
|
|
92
87
|
throw new Error("No file field in referencing collection");
|
|
@@ -135,7 +130,7 @@ export class MultipleFiles extends FormFieldControl {
|
|
|
135
130
|
return result;
|
|
136
131
|
}
|
|
137
132
|
|
|
138
|
-
getFileField():
|
|
133
|
+
getFileField(): Sealious.Field | null {
|
|
139
134
|
for (const [_, field] of Object.entries(
|
|
140
135
|
this.getReferencingCollection().fields
|
|
141
136
|
)) {
|
|
@@ -147,28 +142,28 @@ export class MultipleFiles extends FormFieldControl {
|
|
|
147
142
|
}
|
|
148
143
|
|
|
149
144
|
async extractFileFromItem(
|
|
150
|
-
item: CollectionItem
|
|
151
|
-
): Promise<
|
|
145
|
+
item: Sealious.CollectionItem
|
|
146
|
+
): Promise<Sealious.File | null> {
|
|
152
147
|
const sealious_field = this.getFileField();
|
|
153
148
|
if (!sealious_field) {
|
|
154
149
|
return null;
|
|
155
150
|
}
|
|
156
|
-
return await
|
|
157
|
-
(item.collection as Collection).app,
|
|
151
|
+
return await Sealious.File.fromID(
|
|
152
|
+
(item.collection as Sealious.Collection).app,
|
|
158
153
|
item.get(sealious_field.name).id
|
|
159
154
|
);
|
|
160
155
|
}
|
|
161
156
|
|
|
162
157
|
async renderFileItemPreview(
|
|
163
|
-
_fileItem: CollectionItem,
|
|
164
|
-
file:
|
|
158
|
+
_fileItem: Sealious.CollectionItem,
|
|
159
|
+
file: Sealious.File
|
|
165
160
|
): Promise<FlatTemplatable> {
|
|
166
161
|
return file.filename || "no filename";
|
|
167
162
|
}
|
|
168
163
|
|
|
169
164
|
async renderFileItem(
|
|
170
|
-
fileItem: CollectionItem,
|
|
171
|
-
file:
|
|
165
|
+
fileItem: Sealious.CollectionItem,
|
|
166
|
+
file: Sealious.File
|
|
172
167
|
): Promise<FlatTemplatable> {
|
|
173
168
|
return tempstream/* HTML */ `<li class="file-list-item">
|
|
174
169
|
<a
|
|
@@ -182,7 +177,7 @@ export class MultipleFiles extends FormFieldControl {
|
|
|
182
177
|
</li>`;
|
|
183
178
|
}
|
|
184
179
|
|
|
185
|
-
renderFileRemoveButton(fileItem: CollectionItem): FlatTemplatable {
|
|
180
|
+
renderFileRemoveButton(fileItem: Sealious.CollectionItem): FlatTemplatable {
|
|
186
181
|
return /* HTML */ ` <form
|
|
187
182
|
data-turbo-frame="${this.getFrameID()}"
|
|
188
183
|
action="${this.getFrameRelativeURL()}/delete/${fileItem.id}"
|
|
@@ -226,7 +221,10 @@ export class MultipleFiles extends FormFieldControl {
|
|
|
226
221
|
await this.extractFileFromItem(item),
|
|
227
222
|
])
|
|
228
223
|
)
|
|
229
|
-
).filter(([_, f]) => f !== null) as [
|
|
224
|
+
).filter(([_, f]) => f !== null) as [
|
|
225
|
+
Sealious.CollectionItem,
|
|
226
|
+
Sealious.File
|
|
227
|
+
][];
|
|
230
228
|
|
|
231
229
|
return inputWrapper(
|
|
232
230
|
["multiple-files", this.field.name, ...this.getClassModifiers()],
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { File as SealiousFile, CollectionItem } from "sealious";
|
|
2
2
|
import { FlatTemplatable, tempstream } from "tempstream";
|
|
3
|
-
import { MultipleFiles, MultipleFilesOptions } from "./multiple-files";
|
|
4
|
-
import { MultipleFiles as MultipleFilesField } from "../fields/multiple-files";
|
|
5
|
-
import KoaResponsiveImageRouter from "koa-responsive-image-router";
|
|
3
|
+
import { MultipleFiles, MultipleFilesOptions } from "./multiple-files.js";
|
|
4
|
+
import { MultipleFiles as MultipleFilesField } from "../fields/multiple-files.js";
|
|
5
|
+
import * as KoaResponsiveImageRouter from "koa-responsive-image-router";
|
|
6
6
|
|
|
7
7
|
export class MultiplePhotos extends MultipleFiles {
|
|
8
8
|
constructor(
|
|
9
9
|
public field: MultipleFilesField,
|
|
10
|
-
public imageRouter: KoaResponsiveImageRouter,
|
|
10
|
+
public imageRouter: KoaResponsiveImageRouter.default,
|
|
11
11
|
options?: Partial<MultipleFilesOptions>
|
|
12
12
|
) {
|
|
13
13
|
super(field, options);
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { FormDataValue } from "../form";
|
|
5
|
-
import { FormControlContext } from "./form-control";
|
|
6
|
-
import { SimpleInput, SimpleInputOptions } from "./simple-input";
|
|
1
|
+
import { NumberField } from "../fields/number.js";
|
|
2
|
+
import { FormControlContext } from "./form-control.js";
|
|
3
|
+
import { SimpleInput, SimpleInputOptions } from "./simple-input.js";
|
|
7
4
|
|
|
8
5
|
export type NumberOptions = SimpleInputOptions & Partial<{ step: number }>;
|
|
9
6
|
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Context } from "koa";
|
|
2
2
|
import { FlatTemplatable, tempstream } from "tempstream";
|
|
3
|
-
import { File } from "./file";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { SimpleInputOptions } from "./simple-input";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
3
|
+
import { File } from "./file.js";
|
|
4
|
+
import Sealious from "sealious";
|
|
5
|
+
import { FormField } from "../fields/field.js";
|
|
6
|
+
import { SimpleInputOptions } from "./simple-input.js";
|
|
7
|
+
import { FormControlContext } from "./form-control.js";
|
|
8
|
+
import * as KoaResponsiveImageRouter from "koa-responsive-image-router";
|
|
9
|
+
import { FileContainer } from "../fields/file.js";
|
|
9
10
|
|
|
10
11
|
export class Photo extends File {
|
|
11
12
|
constructor(
|
|
12
13
|
public field: FormField<boolean, FileContainer>,
|
|
13
|
-
public imageRouter: KoaResponsiveImageRouter,
|
|
14
|
+
public imageRouter: KoaResponsiveImageRouter.default,
|
|
14
15
|
options?: SimpleInputOptions
|
|
15
16
|
) {
|
|
16
17
|
super(field, options);
|
|
@@ -33,7 +34,7 @@ export class Photo extends File {
|
|
|
33
34
|
if (!id) {
|
|
34
35
|
return empty_container;
|
|
35
36
|
}
|
|
36
|
-
const file = await
|
|
37
|
+
const file = await Sealious.File.fromID(ctx.$app, id);
|
|
37
38
|
return tempstream/* HTML */ `<div class="${class_name}">
|
|
38
39
|
${this.imageRouter.image({
|
|
39
40
|
resolutions: [100],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from "koa";
|
|
2
|
-
import { FormField } from "../fields/field";
|
|
3
|
-
import { FormDataValue } from "../form";
|
|
4
|
-
import { Tickable } from "./tickable";
|
|
2
|
+
import { FormField } from "../fields/field.js";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { Tickable } from "./tickable.js";
|
|
5
5
|
|
|
6
6
|
export class Radio extends Tickable<string> {
|
|
7
7
|
type = <const>"radio";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Context } from "koa";
|
|
2
2
|
import { FlatTemplatable, tempstream } from "tempstream";
|
|
3
|
-
import { getRequiredClass, inputWrapper } from "../../utils/input-wrapper";
|
|
4
|
-
import { renderAttributes } from "../../utils/render-attributes";
|
|
5
|
-
import { FormField } from "../fields/field";
|
|
6
|
-
import { FormDataValue } from "../form";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { getRequiredClass, inputWrapper } from "../../utils/input-wrapper.js";
|
|
4
|
+
import { renderAttributes } from "../../utils/render-attributes.js";
|
|
5
|
+
import { FormField } from "../fields/field.js";
|
|
6
|
+
import { FormDataValue } from "../form-types.js";
|
|
7
|
+
import { FormControlContext } from "./form-control.js";
|
|
8
|
+
import { FormFieldControl } from "./form-field-control.js";
|
|
9
9
|
|
|
10
10
|
export type SimpleInputOptions = {
|
|
11
11
|
id?: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context } from "koa";
|
|
2
|
-
import { FormField } from "../fields/field";
|
|
3
|
-
import { FormDataValue } from "../form";
|
|
4
|
-
import { FormControlContext } from "./form-control";
|
|
5
|
-
import { SimpleInput, SimpleInputOptions } from "./simple-input";
|
|
2
|
+
import { FormField } from "../fields/field.js";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { FormControlContext } from "./form-control.js";
|
|
5
|
+
import { SimpleInput, SimpleInputOptions } from "./simple-input.js";
|
|
6
6
|
|
|
7
7
|
export class Textarea<Required extends boolean> extends SimpleInput<
|
|
8
8
|
string | null
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Context } from "koa";
|
|
2
2
|
import { FlatTemplatable } from "tempstream";
|
|
3
|
-
import { attribute } from "../../sanitize";
|
|
4
|
-
import { getRequiredClass, inputWrapper } from "../../utils/input-wrapper";
|
|
5
|
-
import { FormField } from "../fields/field";
|
|
6
|
-
import { FormDataValue } from "../form";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { attribute } from "../../sanitize.js";
|
|
4
|
+
import { getRequiredClass, inputWrapper } from "../../utils/input-wrapper.js";
|
|
5
|
+
import { FormField } from "../fields/field.js";
|
|
6
|
+
import { FormDataValue } from "../form-types.js";
|
|
7
|
+
import { FormControlContext } from "./form-control.js";
|
|
8
|
+
import { FormFieldControl } from "./form-field-control.js";
|
|
9
9
|
|
|
10
10
|
export type TickableOptions = {
|
|
11
11
|
id?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { Context } from "koa";
|
|
3
|
-
import { FormDataValue } from "../form";
|
|
4
|
-
import { FieldParseResult, FormField } from "./field";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
5
5
|
|
|
6
6
|
const truthy = ["true", "on", "yes", "1"];
|
|
7
7
|
const falsy = ["false", "off", "no", "0"];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { Context } from "koa";
|
|
3
|
-
import { FormDataValue } from "../form";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
4
|
import {
|
|
5
5
|
FieldParseResult,
|
|
6
6
|
FormField,
|
|
7
7
|
FormFieldValidationResponse,
|
|
8
|
-
} from "./field";
|
|
8
|
+
} from "./field.js";
|
|
9
9
|
|
|
10
10
|
export class ChekboxedListField<Required extends boolean> extends FormField<
|
|
11
11
|
Required,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { Context } from "koa";
|
|
3
3
|
import { Depromisify, Field, FieldOutput } from "sealious";
|
|
4
|
-
import { FormDataValue } from "../form";
|
|
4
|
+
import { FormDataValue } from "../form-types.js";
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
FieldParseResult,
|
|
8
8
|
FormField,
|
|
9
9
|
FormFieldValidationResponse,
|
|
10
|
-
} from "./field";
|
|
10
|
+
} from "./field.js";
|
|
11
11
|
|
|
12
12
|
export class CollectionField<
|
|
13
13
|
F extends Field,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { Context } from "koa";
|
|
3
|
-
import { FormDataValue } from "../form";
|
|
4
|
-
import { FieldParseResult, FormField } from "./field";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
5
5
|
|
|
6
6
|
export class EnumMultipleField<
|
|
7
7
|
Options extends readonly string[],
|
package/src/forms/fields/enum.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { Context } from "koa";
|
|
3
|
-
import { FormDataValue } from "../form";
|
|
4
|
-
import { FieldParseResult, FormField } from "./field";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
5
5
|
|
|
6
6
|
export class EnumField<
|
|
7
7
|
Options extends readonly string[],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Predicate, predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { Context } from "koa";
|
|
3
|
-
import { t } from "../../utils/translate";
|
|
4
|
-
import { FormDataValue } from "../form";
|
|
3
|
+
import { t } from "../../utils/translate.js";
|
|
4
|
+
import { FormDataValue } from "../form-types.js";
|
|
5
5
|
|
|
6
6
|
export type FormFieldValidationResponse = { valid: boolean; message: string };
|
|
7
7
|
|
|
@@ -154,19 +154,3 @@ export abstract class FormField<
|
|
|
154
154
|
return parsed;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
|
|
158
|
-
export * from "./simple-form-field";
|
|
159
|
-
export * from "./checkboxed-list";
|
|
160
|
-
export * from "./collection-field";
|
|
161
|
-
export * from "./number";
|
|
162
|
-
export * from "./pick-from-list";
|
|
163
|
-
export * from "./regexp";
|
|
164
|
-
export * from "./email";
|
|
165
|
-
export * from "./enum";
|
|
166
|
-
export * from "./boolean";
|
|
167
|
-
export * from "./enum-multiple";
|
|
168
|
-
export * from "./existing-sealious-value";
|
|
169
|
-
export * from "./file";
|
|
170
|
-
export * from "./multiple-files";
|
|
171
|
-
export * from "./reverse-single-reference";
|
|
172
|
-
export * from "./structured-array";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./simple-form-field.js";
|
|
2
|
+
export * from "./checkboxed-list.js";
|
|
3
|
+
export * from "./collection-field.js";
|
|
4
|
+
export * from "./number.js";
|
|
5
|
+
export * from "./pick-from-list.js";
|
|
6
|
+
export * from "./regexp.js";
|
|
7
|
+
export * from "./email.js";
|
|
8
|
+
export * from "./enum.js";
|
|
9
|
+
export * from "./boolean.js";
|
|
10
|
+
export * from "./enum-multiple.js";
|
|
11
|
+
export * from "./existing-sealious-value.js";
|
|
12
|
+
export * from "./file.js";
|
|
13
|
+
export * from "./multiple-files.js";
|
|
14
|
+
export * from "./reverse-single-reference.js";
|
|
15
|
+
export * from "./structured-array.js";
|
package/src/forms/fields/file.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
hasField,
|
|
3
2
|
hasFieldOfType,
|
|
4
3
|
hasShape,
|
|
5
4
|
is,
|
|
6
5
|
predicates,
|
|
7
6
|
} from "@sealcode/ts-predicates";
|
|
8
7
|
import { Context } from "koa";
|
|
9
|
-
import
|
|
10
|
-
import { FormDataValue } from "../form";
|
|
11
|
-
import { FieldParseResult, FormField } from "./field";
|
|
8
|
+
import Sealious from "sealious";
|
|
9
|
+
import { FormDataValue } from "../form-types.js";
|
|
10
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
12
11
|
|
|
13
12
|
export type FileContainer = {
|
|
14
|
-
old:
|
|
15
|
-
new:
|
|
13
|
+
old: Sealious.File | null;
|
|
14
|
+
new: Sealious.File | null;
|
|
16
15
|
};
|
|
17
16
|
|
|
18
17
|
export class File<Required extends boolean> extends FormField<
|
|
@@ -25,7 +24,7 @@ export class File<Required extends boolean> extends FormField<
|
|
|
25
24
|
): Promise<FieldParseResult<FileContainer>> {
|
|
26
25
|
let result;
|
|
27
26
|
if (
|
|
28
|
-
raw_value instanceof
|
|
27
|
+
raw_value instanceof Sealious.File ||
|
|
29
28
|
(is(raw_value, predicates.object) &&
|
|
30
29
|
hasShape(
|
|
31
30
|
{
|
|
@@ -36,7 +35,7 @@ export class File<Required extends boolean> extends FormField<
|
|
|
36
35
|
) &&
|
|
37
36
|
raw_value.id)
|
|
38
37
|
) {
|
|
39
|
-
const file = await
|
|
38
|
+
const file = await Sealious.File.fromID(
|
|
40
39
|
ctx.$app,
|
|
41
40
|
raw_value.id as string
|
|
42
41
|
);
|
|
@@ -59,7 +58,7 @@ export class File<Required extends boolean> extends FormField<
|
|
|
59
58
|
raw_value.old
|
|
60
59
|
) &&
|
|
61
60
|
raw_value.old.id
|
|
62
|
-
? await
|
|
61
|
+
? await Sealious.File.fromID(ctx.$app, raw_value.old.id)
|
|
63
62
|
: null;
|
|
64
63
|
const new_file =
|
|
65
64
|
hasFieldOfType(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { Context } from "koa";
|
|
3
|
-
import { FormDataValue } from "../form";
|
|
4
|
-
import { FieldParseResult, FormField } from "./field";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
5
5
|
|
|
6
6
|
export class NumberField<
|
|
7
7
|
DefaultValue extends number | null = number,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { Context } from "koa";
|
|
3
|
-
import { DropdownOption } from "../controls/dropdown";
|
|
4
|
-
import { FormFieldValidationResponse } from "./field";
|
|
5
|
-
import { SimpleFormField } from "./simple-form-field";
|
|
3
|
+
import type { DropdownOption } from "../controls/dropdown.js";
|
|
4
|
+
import { FormFieldValidationResponse } from "./field.js";
|
|
5
|
+
import { SimpleFormField } from "./simple-form-field.js";
|
|
6
6
|
|
|
7
7
|
export class PickFromListField<
|
|
8
8
|
Required extends boolean
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { Context } from "koa";
|
|
3
|
-
import { FormDataValue } from "../form";
|
|
4
|
-
import { FieldParseResult, FormField } from "./field";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
5
5
|
|
|
6
6
|
export class RegExpField<Required extends boolean> extends FormField<Required> {
|
|
7
7
|
constructor(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FormDataValue } from "../form";
|
|
1
|
+
import { FormDataValue } from "../form-types.js";
|
|
3
2
|
import { Context } from "koa";
|
|
4
3
|
import { predicates } from "@sealcode/ts-predicates";
|
|
4
|
+
import { FieldParseResult, FormField } from "./field.js";
|
|
5
5
|
|
|
6
6
|
export class SimpleFormField<Required extends boolean> extends FormField<
|
|
7
7
|
Required,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from "koa";
|
|
2
2
|
import { Field, FieldsetInput, FieldsetOutput, FieldTypes } from "sealious";
|
|
3
|
-
import { FormDataValue } from "../form";
|
|
4
|
-
import { FormField } from "./field";
|
|
3
|
+
import { FormDataValue } from "../form-types.js";
|
|
4
|
+
import { FormField } from "./field.js";
|
|
5
5
|
|
|
6
6
|
export class StructuredArrayField<
|
|
7
7
|
Fields extends Record<string, Field>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { File as SealiousFile } from "sealious";
|
|
2
|
+
import type { FlatTemplatable } from "tempstream";
|
|
3
|
+
import type { FormField } from "./fields/field.js";
|
|
4
|
+
|
|
5
|
+
export type FormDataPrimitive = string | string[] | number | undefined;
|
|
6
|
+
export type FormDataValue =
|
|
7
|
+
| FormDataPrimitive
|
|
8
|
+
| Record<string, FormDataPrimitive>
|
|
9
|
+
| SealiousFile;
|
|
10
|
+
|
|
11
|
+
export type FieldValueType<F extends FormField> = F extends FormField<infer R>
|
|
12
|
+
? R
|
|
13
|
+
: never;
|
|
14
|
+
|
|
15
|
+
export type FormFieldsToValues<
|
|
16
|
+
F extends Record<string, FormField<boolean, keyof F>>
|
|
17
|
+
> = {
|
|
18
|
+
[Property in keyof F]: FieldValueType<F[Property]>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type FormMessage = { type: "info" | "success" | "error"; text: string };
|
|
22
|
+
|
|
23
|
+
export type FormData<Fieldnames extends string = string> = {
|
|
24
|
+
raw_values: Record<Fieldnames, FormDataValue>;
|
|
25
|
+
messages: FormMessage[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type FormReaction =
|
|
29
|
+
| { action: "stay"; content: FlatTemplatable; messages?: FormMessage[] }
|
|
30
|
+
| { action: "redirect"; url: string; messages?: FormMessage[] };
|