@sealcode/sealgen 0.12.0 → 0.12.3
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/dist/notifier.js +1 -1
- package/package.json +2 -2
- package/src/notifier.ts +1 -1
- package/.madgerc +0 -7
- package/coverage/.tmp/coverage-15.json +0 -1
- package/coverage/.tmp/coverage-16.json +0 -1
- package/coverage/.tmp/coverage-17.json +0 -1
- package/coverage/.tmp/coverage-18.json +0 -1
- package/coverage/.tmp/coverage-19.json +0 -1
- package/coverage/.tmp/coverage-20.json +0 -1
- package/coverage/.tmp/coverage-21.json +0 -1
- package/coverage/.tmp/coverage-22.json +0 -1
- package/coverage/.tmp/coverage-23.json +0 -1
- package/coverage/.tmp/coverage-24.json +0 -1
- package/coverage/.tmp/coverage-25.json +0 -1
- package/coverage/.tmp/coverage-26.json +0 -1
- package/lib/add-collection.js +0 -24
- package/lib/add-jdd-component.js +0 -27
- package/lib/add-route.js +0 -65
- package/lib/add-route.test.js +0 -60
- package/lib/build.js +0 -187
- package/lib/cli.js +0 -35
- package/lib/components/components.js +0 -3
- package/lib/components/tabs.js +0 -88
- package/lib/components/toggle-modal.js +0 -46
- package/lib/example.test.js +0 -5
- package/lib/find-css-includes.js +0 -23
- package/lib/forms/controls/array.js +0 -140
- package/lib/forms/controls/autocomplete.js +0 -23
- package/lib/forms/controls/big-radio-group.js +0 -34
- package/lib/forms/controls/checkbox-group.js +0 -29
- package/lib/forms/controls/checkbox.js +0 -24
- package/lib/forms/controls/checkboxed-list-input.js +0 -35
- package/lib/forms/controls/collapsible-checkbox-group.js +0 -13
- package/lib/forms/controls/collapsible-field-group.js +0 -78
- package/lib/forms/controls/controls.js +0 -31
- package/lib/forms/controls/derived-frame.js +0 -52
- package/lib/forms/controls/derived.js +0 -77
- package/lib/forms/controls/dropdown.js +0 -55
- package/lib/forms/controls/editable-collection-subset.js +0 -68
- package/lib/forms/controls/field-group.js +0 -53
- package/lib/forms/controls/file.js +0 -35
- package/lib/forms/controls/form-control.js +0 -14
- package/lib/forms/controls/form-field-control.js +0 -9
- package/lib/forms/controls/form-header.js +0 -14
- package/lib/forms/controls/form-paragraph.js +0 -12
- package/lib/forms/controls/frame.js +0 -25
- package/lib/forms/controls/hidden-input.js +0 -14
- package/lib/forms/controls/html.js +0 -23
- package/lib/forms/controls/multiple-files.js +0 -160
- package/lib/forms/controls/multiple-photos.js +0 -33
- package/lib/forms/controls/number.js +0 -25
- package/lib/forms/controls/photo.js +0 -57
- package/lib/forms/controls/radio.js +0 -25
- package/lib/forms/controls/reverse-single-reference.js +0 -47
- package/lib/forms/controls/simple-input.js +0 -78
- package/lib/forms/controls/textarea.js +0 -33
- package/lib/forms/controls/tickable.js +0 -75
- package/lib/forms/fields/boolean.js +0 -51
- package/lib/forms/fields/boolean.test.js +0 -32
- package/lib/forms/fields/checkboxed-list.js +0 -40
- package/lib/forms/fields/collection-field.js +0 -29
- package/lib/forms/fields/email.js +0 -11
- package/lib/forms/fields/email.test.js +0 -20
- 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 -39
- package/lib/forms/fields/enum.test.js +0 -21
- package/lib/forms/fields/existing-sealious-value.js +0 -16
- package/lib/forms/fields/field.js +0 -81
- package/lib/forms/fields/file.js +0 -53
- package/lib/forms/fields/multiple-files.js +0 -15
- package/lib/forms/fields/number.js +0 -45
- package/lib/forms/fields/number.test.js +0 -30
- package/lib/forms/fields/pick-from-list.js +0 -31
- package/lib/forms/fields/pick-from-list.test.js +0 -17
- package/lib/forms/fields/proxy-field.js +0 -20
- package/lib/forms/fields/regexp.js +0 -40
- package/lib/forms/fields/regexp.test.js +0 -21
- package/lib/forms/fields/reverse-single-reference.js +0 -14
- package/lib/forms/fields/simple-form-field.js +0 -20
- package/lib/forms/fields/structured-array.js +0 -18
- package/lib/forms/form.js +0 -176
- package/lib/forms/form.test.js +0 -1
- package/lib/forms/multiform.js +0 -174
- package/lib/forms/multiform.test.js +0 -426
- package/lib/generate-collections.js +0 -52
- package/lib/generate-components.js +0 -33
- package/lib/generate-routes.js +0 -75
- package/lib/index.js +0 -17
- package/lib/make-env.js +0 -14
- package/lib/make-hidden-inputs.js +0 -14
- package/lib/mount.js +0 -70
- package/lib/notifier.js +0 -19
- package/lib/page/access-control.js +0 -16
- package/lib/page/default-list-filters.js +0 -40
- package/lib/page/list.js +0 -183
- package/lib/page/mountable-with-fields.js +0 -85
- package/lib/page/mountable.js +0 -5
- package/lib/page/page.js +0 -26
- package/lib/page/props-parser.js +0 -23
- package/lib/page/sealious-list.js +0 -59
- package/lib/page/stateful-page.js +0 -97
- package/lib/remove-named-imports.js +0 -47
- package/lib/run.js +0 -2
- package/lib/sanitize.js +0 -10
- package/lib/src/add-collection.js +0 -24
- package/lib/src/add-jdd-component.js +0 -27
- package/lib/src/add-route.js +0 -65
- package/lib/src/add-route.test.js +0 -72
- package/lib/src/build.js +0 -142
- package/lib/src/cli.js +0 -37
- package/lib/src/components/components.js +0 -3
- package/lib/src/components/tabs.js +0 -88
- package/lib/src/components/toggle-modal.js +0 -46
- package/lib/src/example.test.js +0 -5
- package/lib/src/find-css-includes.js +0 -23
- package/lib/src/forms/controls/array.js +0 -141
- package/lib/src/forms/controls/autocomplete.js +0 -23
- package/lib/src/forms/controls/big-radio-group.js +0 -34
- package/lib/src/forms/controls/checkbox-group.js +0 -30
- package/lib/src/forms/controls/checkbox.js +0 -24
- package/lib/src/forms/controls/checkboxed-list-input.js +0 -35
- package/lib/src/forms/controls/collapsible-checkbox-group.js +0 -13
- package/lib/src/forms/controls/collapsible-field-group.js +0 -78
- package/lib/src/forms/controls/controls.js +0 -31
- package/lib/src/forms/controls/derived-frame.js +0 -52
- package/lib/src/forms/controls/derived.js +0 -77
- package/lib/src/forms/controls/dropdown.js +0 -55
- package/lib/src/forms/controls/editable-collection-subset.js +0 -68
- package/lib/src/forms/controls/field-group.js +0 -53
- package/lib/src/forms/controls/file.js +0 -35
- package/lib/src/forms/controls/form-control.js +0 -14
- package/lib/src/forms/controls/form-field-control.js +0 -9
- package/lib/src/forms/controls/form-header.js +0 -14
- package/lib/src/forms/controls/form-paragraph.js +0 -12
- package/lib/src/forms/controls/frame.js +0 -25
- package/lib/src/forms/controls/hidden-input.js +0 -14
- package/lib/src/forms/controls/html.js +0 -23
- package/lib/src/forms/controls/multiple-files.js +0 -160
- package/lib/src/forms/controls/multiple-photos.js +0 -33
- package/lib/src/forms/controls/number.js +0 -25
- package/lib/src/forms/controls/photo.js +0 -57
- package/lib/src/forms/controls/radio.js +0 -25
- package/lib/src/forms/controls/reverse-single-reference.js +0 -47
- package/lib/src/forms/controls/simple-input.js +0 -78
- package/lib/src/forms/controls/textarea.js +0 -33
- package/lib/src/forms/controls/tickable.js +0 -75
- package/lib/src/forms/fields/boolean.js +0 -51
- package/lib/src/forms/fields/boolean.test.js +0 -33
- package/lib/src/forms/fields/checkboxed-list.js +0 -40
- package/lib/src/forms/fields/collection-field.js +0 -29
- package/lib/src/forms/fields/email.js +0 -11
- package/lib/src/forms/fields/email.test.js +0 -20
- package/lib/src/forms/fields/enum-multiple.js +0 -47
- package/lib/src/forms/fields/enum-multiple.test.js +0 -27
- package/lib/src/forms/fields/enum.js +0 -39
- package/lib/src/forms/fields/enum.test.js +0 -21
- package/lib/src/forms/fields/existing-sealious-value.js +0 -16
- package/lib/src/forms/fields/field.js +0 -66
- package/lib/src/forms/fields/fields.js +0 -16
- package/lib/src/forms/fields/file.js +0 -53
- package/lib/src/forms/fields/multiple-files.js +0 -15
- package/lib/src/forms/fields/number.js +0 -45
- package/lib/src/forms/fields/number.test.js +0 -31
- package/lib/src/forms/fields/pick-from-list.js +0 -31
- package/lib/src/forms/fields/pick-from-list.test.js +0 -17
- package/lib/src/forms/fields/proxy-field.js +0 -20
- package/lib/src/forms/fields/regexp.js +0 -40
- package/lib/src/forms/fields/regexp.test.js +0 -21
- package/lib/src/forms/fields/reverse-single-reference.js +0 -14
- package/lib/src/forms/fields/simple-form-field.js +0 -19
- package/lib/src/forms/fields/structured-array.js +0 -18
- package/lib/src/forms/form-types.js +0 -2
- package/lib/src/forms/form.js +0 -176
- package/lib/src/forms/form.test.js +0 -271
- package/lib/src/forms/multiform.js +0 -174
- package/lib/src/forms/multiform.test.js +0 -430
- package/lib/src/generate-collections.js +0 -52
- package/lib/src/generate-components.js +0 -33
- package/lib/src/generate-routes.js +0 -75
- package/lib/src/hehe.test.js +0 -7
- package/lib/src/index.js +0 -19
- package/lib/src/make-env.js +0 -14
- package/lib/src/make-hidden-inputs.js +0 -14
- package/lib/src/mount.js +0 -70
- package/lib/src/notifier.js +0 -19
- package/lib/src/page/access-control.js +0 -16
- package/lib/src/page/default-list-filters.js +0 -40
- package/lib/src/page/list.js +0 -184
- package/lib/src/page/mountable-with-fields.js +0 -85
- package/lib/src/page/mountable.js +0 -5
- package/lib/src/page/page.js +0 -26
- package/lib/src/page/props-parser.js +0 -23
- package/lib/src/page/sealious-list.js +0 -59
- package/lib/src/page/stateful-page.js +0 -97
- package/lib/src/run.js +0 -2
- package/lib/src/sample-index.js +0 -3
- package/lib/src/sample-lib.js +0 -6
- package/lib/src/sanitize.js +0 -10
- package/lib/src/templates/collection.js +0 -12
- package/lib/src/templates/form.js +0 -57
- package/lib/src/templates/jdd-component.js +0 -39
- package/lib/src/templates/list.js +0 -139
- package/lib/src/templates/long-running-process.js +0 -60
- package/lib/src/templates/multiform.js +0 -55
- package/lib/src/templates/page.js +0 -23
- package/lib/src/templates/post.js +0 -22
- package/lib/src/templates/redirect.js +0 -23
- package/lib/src/templates/route-test.js +0 -54
- package/lib/src/templates/stateful-page.js +0 -66
- package/lib/src/templates/templates.js +0 -21
- package/lib/src/test_utils/locator_is_visible.js +0 -11
- package/lib/src/utils/assert-throws.js +0 -17
- package/lib/src/utils/base64.js +0 -7
- package/lib/src/utils/browser-creator.js +0 -10
- package/lib/src/utils/escape-url-params.js +0 -14
- package/lib/src/utils/exec.js +0 -22
- package/lib/src/utils/extract-fields-from-collection.js +0 -26
- package/lib/src/utils/format-external-url.js +0 -11
- package/lib/src/utils/import-path.js +0 -16
- package/lib/src/utils/input-wrapper.js +0 -15
- package/lib/src/utils/list-collections.js +0 -13
- package/lib/src/utils/make-slug.js +0 -6
- package/lib/src/utils/natural-numbers.js +0 -6
- package/lib/src/utils/prettier.js +0 -10
- package/lib/src/utils/question.js +0 -19
- package/lib/src/utils/render-attributes.js +0 -19
- package/lib/src/utils/sleep.js +0 -4
- package/lib/src/utils/translate.js +0 -6
- package/lib/src/utils/url-with-new-params.js +0 -5
- package/lib/src/utils/utils.js +0 -16
- package/lib/src/utils/walk.js +0 -23
- package/lib/src/vitest.config.js +0 -20
- package/lib/templates/collection.js +0 -12
- package/lib/templates/form.js +0 -57
- package/lib/templates/jdd-component.js +0 -39
- package/lib/templates/list.js +0 -139
- package/lib/templates/long-running-process.js +0 -60
- package/lib/templates/multiform.js +0 -55
- package/lib/templates/page.js +0 -23
- package/lib/templates/post.js +0 -22
- package/lib/templates/redirect.js +0 -23
- package/lib/templates/route-test.js +0 -54
- package/lib/templates/stateful-page.js +0 -66
- package/lib/templates/templates.js +0 -21
- package/lib/test_utils/locator_is_visible.js +0 -11
- package/lib/utils/assert-throws.js +0 -17
- package/lib/utils/base64.js +0 -7
- package/lib/utils/browser-creator.js +0 -10
- package/lib/utils/escape-url-params.js +0 -14
- package/lib/utils/exec.js +0 -22
- package/lib/utils/extract-fields-from-collection.js +0 -26
- package/lib/utils/format-external-url.js +0 -11
- package/lib/utils/import-path.js +0 -16
- package/lib/utils/input-wrapper.js +0 -15
- package/lib/utils/list-collections.js +0 -13
- package/lib/utils/make-slug.js +0 -6
- package/lib/utils/natural-numbers.js +0 -6
- package/lib/utils/prettier.js +0 -10
- package/lib/utils/question.js +0 -19
- package/lib/utils/render-attributes.js +0 -19
- package/lib/utils/sleep.js +0 -4
- package/lib/utils/translate.js +0 -6
- package/lib/utils/url-with-new-params.js +0 -5
- package/lib/utils/utils.js +0 -16
- package/lib/utils/walk.js +0 -23
- package/lib/vitest.config.js +0 -22
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CheckboxGroup } from "./checkbox-group.js";
|
|
2
|
-
import { CollapsibleFieldGroup } from "./collapsible-field-group.js";
|
|
3
|
-
export class CollapsibleCheckboxGroup extends CheckboxGroup {
|
|
4
|
-
wrapGroup(fctx, checkboxes) {
|
|
5
|
-
return new CollapsibleFieldGroup(checkboxes, {
|
|
6
|
-
label: this.options.label,
|
|
7
|
-
textWhenOpen: this.options.textWhenOpen,
|
|
8
|
-
textWhenClosed: this.options.textWhenClosed,
|
|
9
|
-
groupID: this.options.groupID,
|
|
10
|
-
}).render(fctx);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=collapsible-checkbox-group.js.map
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { FieldGroup } from "./field-group.js";
|
|
2
|
-
import { randomUUID } from "crypto";
|
|
3
|
-
export class CollapsibleFieldGroup extends FieldGroup {
|
|
4
|
-
constructor(controls, options = {}) {
|
|
5
|
-
super([]);
|
|
6
|
-
this.controls = controls;
|
|
7
|
-
this.options = options;
|
|
8
|
-
if (this.options.groupID == undefined) {
|
|
9
|
-
this.options.groupID = "A" + randomUUID(); // "A" is needed as ids always have to start with a letter
|
|
10
|
-
}
|
|
11
|
-
this.collapseID = this.options.groupID + "collapse";
|
|
12
|
-
}
|
|
13
|
-
getGroupLabelProps() {
|
|
14
|
-
return super.getGroupLabelProps() + ` for="${this.collapseID}"`;
|
|
15
|
-
}
|
|
16
|
-
preLabelContainer() {
|
|
17
|
-
return /* HTML */ `<style>
|
|
18
|
-
input#${this.collapseID} {
|
|
19
|
-
display: none;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
input#${this.collapseID} ~ .field-group__fields {
|
|
23
|
-
display: none;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
input#${this.collapseID}:checked ~ .field-group__fields {
|
|
27
|
-
display: block;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
input#${this.collapseID}
|
|
31
|
-
~ .field-group__label-container
|
|
32
|
-
.field-group__collapse-label-text--open {
|
|
33
|
-
display: none;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
input#${this.collapseID}:checked
|
|
37
|
-
~ .field-group__label-container
|
|
38
|
-
.field-group__collapse-label-text--open {
|
|
39
|
-
display: inline-block;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
input#${this.collapseID}
|
|
43
|
-
~ .field-group__label-container
|
|
44
|
-
.field-group__collapse-label-text--closed {
|
|
45
|
-
display: inline-block;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
input#${this.collapseID}:checked
|
|
49
|
-
~ .field-group__label-container
|
|
50
|
-
.field-group__collapse-label-text--closed {
|
|
51
|
-
display: none;
|
|
52
|
-
}
|
|
53
|
-
</style>
|
|
54
|
-
<input
|
|
55
|
-
type="checkbox"
|
|
56
|
-
id="${this.collapseID}"
|
|
57
|
-
${this.options.openOnStart ? "checked" : ""}
|
|
58
|
-
/>`;
|
|
59
|
-
}
|
|
60
|
-
postLabel() {
|
|
61
|
-
return /* HTML */ `<label
|
|
62
|
-
class="field-group__collapse-label"
|
|
63
|
-
for="${this.collapseID}"
|
|
64
|
-
>
|
|
65
|
-
<span
|
|
66
|
-
class="field-group__collapse-label-text field-group__collapse-label-text--open"
|
|
67
|
-
>
|
|
68
|
-
${this.options.textWhenOpen || "close"}
|
|
69
|
-
</span>
|
|
70
|
-
<span
|
|
71
|
-
class="field-group__collapse-label-text field-group__collapse-label-text--closed"
|
|
72
|
-
>
|
|
73
|
-
${this.options.textWhenClosed || "open"}
|
|
74
|
-
</span>
|
|
75
|
-
</label>`;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=collapsible-field-group.js.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export { FormControl } from "./form-control.js";
|
|
2
|
-
export { FormFieldControl } from "./form-field-control.js";
|
|
3
|
-
export { EditableCollectionSubset } from "./editable-collection-subset.js";
|
|
4
|
-
export { Frame } from "./frame.js";
|
|
5
|
-
export { CheckboxedListInput } from "./checkboxed-list-input.js";
|
|
6
|
-
export * from "./dropdown.js";
|
|
7
|
-
export { SimpleInput } from "./simple-input.js";
|
|
8
|
-
export { FormHeader } from "./form-header.js";
|
|
9
|
-
export { FormParagraph } from "./form-paragraph.js";
|
|
10
|
-
export { HTML } from "./html.js";
|
|
11
|
-
export { HiddenInput } from "./hidden-input.js";
|
|
12
|
-
export { Textarea } from "./textarea.js";
|
|
13
|
-
export { FieldGroup } from "./field-group.js";
|
|
14
|
-
export * from "./derived.js";
|
|
15
|
-
export * from "./derived-frame.js";
|
|
16
|
-
export * from "./tickable.js";
|
|
17
|
-
export * from "./checkbox.js";
|
|
18
|
-
export * from "./radio.js";
|
|
19
|
-
export * from "./big-radio-group.js";
|
|
20
|
-
export * from "./checkbox-group.js";
|
|
21
|
-
export * from "./collapsible-field-group.js";
|
|
22
|
-
export * from "./collapsible-checkbox-group.js";
|
|
23
|
-
export * from "./autocomplete.js";
|
|
24
|
-
export * from "./file.js";
|
|
25
|
-
export * from "./photo.js";
|
|
26
|
-
export * from "./multiple-files.js";
|
|
27
|
-
export * from "./number.js";
|
|
28
|
-
export * from "./multiple-photos.js";
|
|
29
|
-
// export * from "./reverse-single-reference";
|
|
30
|
-
export * from "./array.js";
|
|
31
|
-
//# sourceMappingURL=controls.js.map
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { hasShape, predicates } from "@sealcode/ts-predicates";
|
|
2
|
-
import { tempstream } from "tempstream";
|
|
3
|
-
import { makeSlug } from "../../utils/make-slug.js";
|
|
4
|
-
import { Derived } from "./derived.js";
|
|
5
|
-
import { FormControlContext } from "./form-control.js";
|
|
6
|
-
export class DerivedFrame extends Derived {
|
|
7
|
-
constructor(frame_name, fields, generateFrameContent,
|
|
8
|
-
// "a" is to make it a valid DOM id
|
|
9
|
-
frame_id = "a" + makeSlug(frame_name)) {
|
|
10
|
-
super(fields, async (values, consts) => /* HTML */ `<turbo-frame
|
|
11
|
-
id="${consts.frame_id}"
|
|
12
|
-
src="./${consts.frame_id}?${Object.entries({
|
|
13
|
-
...consts,
|
|
14
|
-
...(values || {}),
|
|
15
|
-
})
|
|
16
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
17
|
-
.join("&")}"
|
|
18
|
-
></turbo-frame>`, async (fctx) => ({
|
|
19
|
-
form_id: fctx.form_id,
|
|
20
|
-
field_name_prefix: fctx.field_name_prefix,
|
|
21
|
-
frame_id,
|
|
22
|
-
validate: fctx.validate,
|
|
23
|
-
}));
|
|
24
|
-
this.frame_name = frame_name;
|
|
25
|
-
this.generateFrameContent = generateFrameContent;
|
|
26
|
-
this.frame_id = frame_id;
|
|
27
|
-
}
|
|
28
|
-
renderBackendResponseFrame(_ctx, content) {
|
|
29
|
-
return tempstream /* HTML */ `<turbo-frame
|
|
30
|
-
id="${this.frame_id}"
|
|
31
|
-
target="_top"
|
|
32
|
-
>
|
|
33
|
-
${content || ""}
|
|
34
|
-
</turbo-frame>`;
|
|
35
|
-
}
|
|
36
|
-
mount(router) {
|
|
37
|
-
router.get(this.frame_id, async (ctx) => {
|
|
38
|
-
const query = ctx.query;
|
|
39
|
-
if (!hasShape({
|
|
40
|
-
field_name_prefix: predicates.string,
|
|
41
|
-
form_id: predicates.string,
|
|
42
|
-
validate: predicates.string,
|
|
43
|
-
}, query)) {
|
|
44
|
-
ctx.body = this.renderBackendResponseFrame(ctx, "Missing query params");
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
ctx.body = this.renderBackendResponseFrame(ctx, await this.generateFrameContent(new FormControlContext(ctx, ctx.query, [], query.field_name_prefix, query.form_id, query.validate === "true" ? true : false), ctx.query));
|
|
48
|
-
});
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=derived-frame.js.map
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "crypto";
|
|
2
|
-
import { tempstream } from "tempstream";
|
|
3
|
-
import { FormControl } from "./form-control.js";
|
|
4
|
-
export class Derived extends FormControl {
|
|
5
|
-
constructor(fields, _render, getConsts = async () => ({})) {
|
|
6
|
-
super();
|
|
7
|
-
this.fields = fields;
|
|
8
|
-
this._render = _render;
|
|
9
|
-
this.getConsts = getConsts;
|
|
10
|
-
this.role = "decoration";
|
|
11
|
-
}
|
|
12
|
-
async getBackendValues(fctx) {
|
|
13
|
-
const fieldnames = this.fields.map((f) => f.name);
|
|
14
|
-
const result = Object.fromEntries(Object.entries(fctx.data).filter(([key]) => fieldnames.includes(key)));
|
|
15
|
-
return result;
|
|
16
|
-
}
|
|
17
|
-
async render(fctx) {
|
|
18
|
-
// the A makes it always a valid id, as it cannot start with a number
|
|
19
|
-
const id = "A" + randomUUID();
|
|
20
|
-
const consts = this.getConsts(fctx);
|
|
21
|
-
const frontend_side_refresh_code = (values_code = "getValues()") => `render(${values_code}, consts)
|
|
22
|
-
.then(result=>document.querySelector("#${id}").innerHTML=result)`;
|
|
23
|
-
return tempstream /* HTML */ `<div>
|
|
24
|
-
<script>
|
|
25
|
-
(function () {
|
|
26
|
-
const consts = ${"{" +
|
|
27
|
-
Object.entries((await consts) || {})
|
|
28
|
-
.map(([key, value]) => {
|
|
29
|
-
return `"${key}": ${typeof value === "object"
|
|
30
|
-
? JSON.stringify(value)
|
|
31
|
-
: typeof value == "string"
|
|
32
|
-
? '"' + value.toString() + '"'
|
|
33
|
-
: value.toString()}`;
|
|
34
|
-
})
|
|
35
|
-
.join(",") +
|
|
36
|
-
"}"};
|
|
37
|
-
const form_container =
|
|
38
|
-
document.currentScript.closest(".form-container");
|
|
39
|
-
const render = ${this._render.toString()};
|
|
40
|
-
function getValues() {
|
|
41
|
-
return Object.fromEntries(
|
|
42
|
-
${JSON.stringify(this.fields.map((field) => field.name))}.map((field_name) => {
|
|
43
|
-
let input = form_container.querySelector(
|
|
44
|
-
\`input[name="\${field_name}"]\`
|
|
45
|
-
);
|
|
46
|
-
if (!input) {
|
|
47
|
-
return [field_name, ""];
|
|
48
|
-
}
|
|
49
|
-
if (input.type === "radio") {
|
|
50
|
-
input = form_container.querySelector(
|
|
51
|
-
\`input[name="\${field_name}"]:checked\`
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
return [field_name, input.value];
|
|
55
|
-
})
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
function setupWatcher(field_name) {
|
|
59
|
-
form_container
|
|
60
|
-
.querySelectorAll(\`input[name="\${field_name}"]\`)
|
|
61
|
-
.forEach((input) => {
|
|
62
|
-
input.addEventListener("change", () => {
|
|
63
|
-
${frontend_side_refresh_code()};
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
${JSON.stringify(this.fields.map((field) => field.name))}.forEach(setupWatcher);
|
|
68
|
-
setTimeout(() => {
|
|
69
|
-
${frontend_side_refresh_code(JSON.stringify(await this.getBackendValues(fctx)))};
|
|
70
|
-
}, 0);
|
|
71
|
-
})();
|
|
72
|
-
</script>
|
|
73
|
-
<div id="${id}">${this._render({}, await consts)}</div>
|
|
74
|
-
</div>`;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=derived.js.map
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { tempstream } from "tempstream";
|
|
2
|
-
import { attribute } from "../../sanitize.js";
|
|
3
|
-
import { SimpleInput } from "./simple-input.js";
|
|
4
|
-
export class FreeformDropdown extends SimpleInput {
|
|
5
|
-
constructor(field, _generateOptions, options = {
|
|
6
|
-
label: field.name,
|
|
7
|
-
autosubmit: false,
|
|
8
|
-
autocomplete: true,
|
|
9
|
-
}) {
|
|
10
|
-
super(field, options);
|
|
11
|
-
this.field = field;
|
|
12
|
-
this._generateOptions = _generateOptions;
|
|
13
|
-
this.options = options;
|
|
14
|
-
}
|
|
15
|
-
async generateOptions(ctx) {
|
|
16
|
-
return this._generateOptions(ctx);
|
|
17
|
-
}
|
|
18
|
-
async getInputAttributes(fctx) {
|
|
19
|
-
const original = await super.getInputAttributes(fctx);
|
|
20
|
-
return {
|
|
21
|
-
...original,
|
|
22
|
-
...Object.fromEntries([
|
|
23
|
-
...(this.options.autosubmit
|
|
24
|
-
? [
|
|
25
|
-
[
|
|
26
|
-
"onchange",
|
|
27
|
-
(original.onchange || "") +
|
|
28
|
-
";this.form.submit();",
|
|
29
|
-
],
|
|
30
|
-
]
|
|
31
|
-
: []),
|
|
32
|
-
]),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
async renderInput(ctx, attributes_str, data) {
|
|
36
|
-
const { parsed: picked_value } = await this.field.getValue(ctx, data);
|
|
37
|
-
return /* HTML */ tempstream `<select ${attributes_str}>
|
|
38
|
-
${
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
40
|
-
Promise.resolve(this.generateOptions(ctx)).then((options) => options.map(({ value, label }) => `<option value="${attribute(value)}" ${(value || "") == picked_value ? "selected" : ""}>${label}</option>`))}
|
|
41
|
-
</select>`;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
export class Dropdown extends FreeformDropdown {
|
|
45
|
-
constructor(field, options = {
|
|
46
|
-
label: field.name,
|
|
47
|
-
autosubmit: false,
|
|
48
|
-
autocomplete: true,
|
|
49
|
-
}) {
|
|
50
|
-
super(field, (ctx) => field.generateOptions(ctx), options);
|
|
51
|
-
this.field = field;
|
|
52
|
-
this.options = options;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=dropdown.js.map
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { tempstream } from "tempstream";
|
|
2
|
-
import { attribute } from "../../sanitize.js";
|
|
3
|
-
import { FormFieldControl } from "./controls.js";
|
|
4
|
-
/**
|
|
5
|
-
* This control has own forms in it so if you want to use it you
|
|
6
|
-
* probably shouldn't use `await super.render(ctx, data, path)` in
|
|
7
|
-
* render method of you from implementation and you should write
|
|
8
|
-
* your own implementation of this method. See forms that uses
|
|
9
|
-
* this control for reference.
|
|
10
|
-
*/
|
|
11
|
-
export class EditableCollectionSubset extends FormFieldControl {
|
|
12
|
-
constructor(field, actionname, listLabel, selectLabel) {
|
|
13
|
-
super([field]);
|
|
14
|
-
this.field = field;
|
|
15
|
-
this.actionname = actionname;
|
|
16
|
-
this.listLabel = listLabel;
|
|
17
|
-
this.selectLabel = selectLabel;
|
|
18
|
-
this.role = "input";
|
|
19
|
-
}
|
|
20
|
-
async render(fctx) {
|
|
21
|
-
const { parsed: values } = await this.field.getValue(fctx.ctx, fctx.data);
|
|
22
|
-
return tempstream /* HTML */ `<div>
|
|
23
|
-
<ul>
|
|
24
|
-
${Promise.resolve(this.field.generateOptions(fctx.ctx)).then((options) => Object.entries(options)
|
|
25
|
-
.filter(([value]) => (values || []).includes(value))
|
|
26
|
-
.map(([value, text]) => /* HTML */ `
|
|
27
|
-
<li>
|
|
28
|
-
<form
|
|
29
|
-
method="POST"
|
|
30
|
-
action="${fctx.ctx.path}"
|
|
31
|
-
>
|
|
32
|
-
<span>${text}</span>
|
|
33
|
-
<input
|
|
34
|
-
type="hidden"
|
|
35
|
-
name="${this.field.name}"
|
|
36
|
-
value="${attribute(value)}"
|
|
37
|
-
/>
|
|
38
|
-
<input
|
|
39
|
-
type="hidden"
|
|
40
|
-
name="${this.actionname}"
|
|
41
|
-
value="list"
|
|
42
|
-
/>
|
|
43
|
-
<input
|
|
44
|
-
type="submit"
|
|
45
|
-
${this.listLabel
|
|
46
|
-
? `value="${this.listLabel}"`
|
|
47
|
-
: ""}
|
|
48
|
-
/>
|
|
49
|
-
</form>
|
|
50
|
-
</li>
|
|
51
|
-
`))}
|
|
52
|
-
</ul>
|
|
53
|
-
<form method="POST" action="${fctx.ctx.path}">
|
|
54
|
-
<select name="${this.field.name}">
|
|
55
|
-
${Promise.resolve(this.field.generateOptions(fctx.ctx)).then((options) => Object.entries(options)
|
|
56
|
-
.filter(([value]) => !(values || []).includes(value))
|
|
57
|
-
.map(([value, text]) => `<option value="${attribute(value)}">${text}</option>`))}
|
|
58
|
-
</select>
|
|
59
|
-
<input type="hidden" name="${this.actionname}" value="select" />
|
|
60
|
-
<input
|
|
61
|
-
type="submit"
|
|
62
|
-
${this.selectLabel ? `value="${this.selectLabel}"` : ""}
|
|
63
|
-
/>
|
|
64
|
-
</form>
|
|
65
|
-
</div>`;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=editable-collection-subset.js.map
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { tempstream } from "tempstream";
|
|
2
|
-
import { FormFieldControl } from "./form-field-control.js";
|
|
3
|
-
export class FieldGroup extends FormFieldControl {
|
|
4
|
-
constructor(controls, options = {}) {
|
|
5
|
-
super([]);
|
|
6
|
-
this.controls = controls;
|
|
7
|
-
this.options = options;
|
|
8
|
-
}
|
|
9
|
-
preLabel() {
|
|
10
|
-
return "";
|
|
11
|
-
}
|
|
12
|
-
preLabelContainer() {
|
|
13
|
-
return "";
|
|
14
|
-
}
|
|
15
|
-
postLabel() {
|
|
16
|
-
return "";
|
|
17
|
-
}
|
|
18
|
-
preFields() {
|
|
19
|
-
return "";
|
|
20
|
-
}
|
|
21
|
-
postFields() {
|
|
22
|
-
return "";
|
|
23
|
-
}
|
|
24
|
-
getGroupLabelProps() {
|
|
25
|
-
return `class="field-group__label"`;
|
|
26
|
-
}
|
|
27
|
-
async render(fctx) {
|
|
28
|
-
const { label, classes } = this.options;
|
|
29
|
-
return tempstream /* HTML */ `
|
|
30
|
-
<div
|
|
31
|
-
class="field-group ${(classes || []).join(" ")}"
|
|
32
|
-
${this.options.containerID
|
|
33
|
-
? `id="${this.options.containerID}"`
|
|
34
|
-
: ""}
|
|
35
|
-
>
|
|
36
|
-
${this.preLabelContainer()}
|
|
37
|
-
<div class="field-group__label-container">
|
|
38
|
-
${this.preLabel()}
|
|
39
|
-
${label
|
|
40
|
-
? `<label ${this.getGroupLabelProps()}>${label}</label>`
|
|
41
|
-
: ""}
|
|
42
|
-
${this.postLabel()}
|
|
43
|
-
</div>
|
|
44
|
-
${this.preFields()}
|
|
45
|
-
<div class="field-group__fields">
|
|
46
|
-
${this.controls.map((control) => control.render(fctx))}
|
|
47
|
-
</div>
|
|
48
|
-
${this.postFields()}
|
|
49
|
-
</div>
|
|
50
|
-
`;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=field-group.js.map
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { tempstream } from "tempstream";
|
|
2
|
-
import { SimpleInput } from "./simple-input.js";
|
|
3
|
-
export class File extends SimpleInput {
|
|
4
|
-
getType() {
|
|
5
|
-
return "file";
|
|
6
|
-
}
|
|
7
|
-
async renderFilePreview(_ctx, file_data) {
|
|
8
|
-
return file_data?.filename || "";
|
|
9
|
-
}
|
|
10
|
-
async preInput(ctx, data) {
|
|
11
|
-
const { parsed } = await this.field.getValue(ctx, data);
|
|
12
|
-
return tempstream /* HTML */ `${this.renderFilePreview(ctx, parsed.old)}
|
|
13
|
-
<input
|
|
14
|
-
type="hidden"
|
|
15
|
-
name="${this.field.name}[old][id]"
|
|
16
|
-
value="${parsed.old?.id || ""}"
|
|
17
|
-
/>
|
|
18
|
-
<input
|
|
19
|
-
type="hidden"
|
|
20
|
-
name="${this.field.name}[old][filename]"
|
|
21
|
-
value="${parsed.old?.filename || ""}"
|
|
22
|
-
/>`;
|
|
23
|
-
}
|
|
24
|
-
async getInputAttributes(fctx) {
|
|
25
|
-
const original = await super.getInputAttributes(fctx);
|
|
26
|
-
const { parsed } = await this.field.getValue(fctx.ctx, fctx.data);
|
|
27
|
-
return {
|
|
28
|
-
...original,
|
|
29
|
-
name: this.field.name + "[new]",
|
|
30
|
-
required: original.required && !parsed.old,
|
|
31
|
-
value: false,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=file.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export class FormControlContext {
|
|
2
|
-
constructor(ctx, data, messages, field_name_prefix, form_id, validate) {
|
|
3
|
-
this.ctx = ctx;
|
|
4
|
-
this.data = data;
|
|
5
|
-
this.messages = messages;
|
|
6
|
-
this.field_name_prefix = field_name_prefix;
|
|
7
|
-
this.form_id = form_id;
|
|
8
|
-
this.validate = validate;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export class FormControl {
|
|
12
|
-
mount(router) { }
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=form-control.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FormControl } from "./controls.js";
|
|
2
|
-
export class FormHeader extends FormControl {
|
|
3
|
-
constructor(text, isVisible = async () => true) {
|
|
4
|
-
super();
|
|
5
|
-
this.text = text;
|
|
6
|
-
this.isVisible = isVisible;
|
|
7
|
-
this.role = "decoration";
|
|
8
|
-
}
|
|
9
|
-
async render(fctx) {
|
|
10
|
-
const isVsbl = await this.isVisible(fctx);
|
|
11
|
-
return isVsbl ? `<h2>${this.text}</h2>` : "";
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=form-header.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FormControl } from "./controls.js";
|
|
2
|
-
export class FormParagraph extends FormControl {
|
|
3
|
-
constructor(text) {
|
|
4
|
-
super();
|
|
5
|
-
this.text = text;
|
|
6
|
-
this.role = "decoration";
|
|
7
|
-
}
|
|
8
|
-
render() {
|
|
9
|
-
return `<p>${this.text}</p>`;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=form-paragraph.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { FormControl } from "./controls.js";
|
|
2
|
-
/**
|
|
3
|
-
* This class will render `turbo-frame` tag so that u can
|
|
4
|
-
* embed other route inside your form. This will require
|
|
5
|
-
* to add value to `data: FormData` (inside your master form
|
|
6
|
-
* render function) with key `Frame.FRAME_PATH_KEY`. Value
|
|
7
|
-
* needs to be url to route that you want to embed. If you
|
|
8
|
-
* this value wont be provided frame will redner empty string.
|
|
9
|
-
* See `src/back/routes/profile/[id].form.ts` for an example.
|
|
10
|
-
*/
|
|
11
|
-
export class Frame extends FormControl {
|
|
12
|
-
constructor(src) {
|
|
13
|
-
super();
|
|
14
|
-
this.src = src;
|
|
15
|
-
this.role = "decoration";
|
|
16
|
-
}
|
|
17
|
-
render() {
|
|
18
|
-
return /* HTML */ `<turbo-frame
|
|
19
|
-
id="contrahents"
|
|
20
|
-
loading="lazy"
|
|
21
|
-
src="${this.src}"
|
|
22
|
-
></turbo-frame>`;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=frame.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { tempstream } from "tempstream";
|
|
2
|
-
import { attribute } from "../../sanitize.js";
|
|
3
|
-
import { FormFieldControl } from "./form-field-control.js";
|
|
4
|
-
export class HiddenInput extends FormFieldControl {
|
|
5
|
-
constructor(field) {
|
|
6
|
-
super([field]);
|
|
7
|
-
this.field = field;
|
|
8
|
-
}
|
|
9
|
-
async render(fctx) {
|
|
10
|
-
const { raw } = await this.field.getValue(fctx.ctx, fctx.data);
|
|
11
|
-
return tempstream `<input type="hidden" name="${this.field.name}" value="${attribute((raw || "").toString())}" form="${fctx.form_id}">`;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=hidden-input.js.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { FormControl } from "./controls.js";
|
|
2
|
-
export class HTML extends FormControl {
|
|
3
|
-
constructor(role_or_renderer, renderer_or_undefined) {
|
|
4
|
-
super();
|
|
5
|
-
this.role = "decoration";
|
|
6
|
-
if (arguments.length == 2) {
|
|
7
|
-
this.role = role_or_renderer;
|
|
8
|
-
this.renderer = renderer_or_undefined;
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
this.renderer = role_or_renderer;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
async render(fctx) {
|
|
15
|
-
if (typeof this.renderer === "string") {
|
|
16
|
-
return this.renderer;
|
|
17
|
-
}
|
|
18
|
-
return typeof this.renderer == "function"
|
|
19
|
-
? this.renderer(fctx)
|
|
20
|
-
: this.renderer;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=html.js.map
|