@sealcode/sealgen 0.19.21 → 0.19.23

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.
@@ -1,7 +1,4 @@
1
1
  import regex_escape from "core-js-pure/features/regexp/escape.js";
2
- console.warn(regex_escape);
3
- const string = "jedna baba ;) drugiej babie ;)";
4
- console.warn(regex_escape(string), new RegExp(regex_escape(string)));
5
2
  const BooleanListFilter = {
6
3
  render: (value, field) => {
7
4
  return (
@@ -5,11 +5,9 @@ import { from_base64, to_base64 } from "../utils/base64.js";
5
5
  import { Mountable } from "./mountable.js";
6
6
  import { isPlainObject } from "is-what";
7
7
  class StatefulPage extends Mountable {
8
- async canAccess(_ctx) {
9
- return { canAccess: true, message: "" };
10
- }
11
- constructor() {
8
+ constructor(form_id) {
12
9
  super();
10
+ this.form_id = form_id;
13
11
  const original_render = this.render.bind(this);
14
12
  this.render = async (ctx, state, inputs) => {
15
13
  return this.wrapInLayout(
@@ -23,6 +21,9 @@ class StatefulPage extends Mountable {
23
21
  );
24
22
  };
25
23
  }
24
+ async canAccess(_ctx) {
25
+ return { canAccess: true, message: "" };
26
+ }
26
27
  async wrapInForm(context, state, content) {
27
28
  return tempstream`<form
28
29
  action="./"
@@ -69,6 +70,7 @@ class StatefulPage extends Mountable {
69
70
  type="submit"
70
71
  formaction="${this.makeActionURL(action_description, ...args)}"
71
72
  title="${label}"
73
+ ${this.form_id ? `form="${this.form_id}"` : ""}
72
74
  ${disabled ? "disabled" : ""}
73
75
  >
74
76
  ${content}
@@ -77,13 +79,13 @@ class StatefulPage extends Mountable {
77
79
  );
78
80
  }
79
81
  makeActionCallback(action_description, ...args) {
80
- return `(()=>{const form = this.closest('form'); form.action='${this.makeActionURL(
82
+ return `(()=>{const form = this.form; form.action='${this.makeActionURL(
81
83
  action_description,
82
84
  ...args
83
85
  )}'; form.requestSubmit()})()`;
84
86
  }
85
87
  rerender() {
86
- return "this.closest('form').requestSubmit()";
88
+ return "this.form.requestSubmit()";
87
89
  }
88
90
  async preprocessState(values) {
89
91
  return values;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.19.21",
3
+ "version": "0.19.23",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -69,7 +69,7 @@ export abstract class StatefulPage<
69
69
  return <const>{ canAccess: true, message: "" };
70
70
  }
71
71
 
72
- constructor() {
72
+ constructor(public form_id?: string) {
73
73
  super();
74
74
  const original_render = this.render.bind(this) as typeof this.render;
75
75
  this.render = async (
@@ -156,6 +156,7 @@ export abstract class StatefulPage<
156
156
  type="submit"
157
157
  formaction="${this.makeActionURL(action_description, ...args)}"
158
158
  title="${label}"
159
+ ${this.form_id ? `form="${this.form_id}"` : ""}
159
160
  ${disabled ? "disabled" : ""}
160
161
  >
161
162
  ${content}
@@ -172,14 +173,14 @@ export abstract class StatefulPage<
172
173
  | ActionName,
173
174
  ...args: ExtractStatefulPageActionArgs<Actions[ActionName]>
174
175
  ) {
175
- return `(()=>{const form = this.closest('form'); form.action='${this.makeActionURL(
176
+ return `(()=>{const form = this.form; form.action='${this.makeActionURL(
176
177
  action_description,
177
178
  ...args
178
179
  )}'; form.requestSubmit()})()`;
179
180
  }
180
181
 
181
182
  rerender() {
182
- return "this.closest('form').requestSubmit()";
183
+ return "this.form.requestSubmit()";
183
184
  }
184
185
 
185
186
  async preprocessState(values: State): Promise<State> {
@@ -231,9 +232,9 @@ export abstract class StatefulPage<
231
232
  const original_state_string = ctx.$body.state;
232
233
  const original_state = await this.deserializeState(
233
234
  ctx,
234
- typeof original_state_string == "string"
235
- ? from_base64(original_state_string)
236
- : "{}"
235
+ typeof original_state_string == "string" ?
236
+ from_base64(original_state_string)
237
+ : "{}"
237
238
  );
238
239
 
239
240
  const $body = ctx.$body;