@functionalcms/svelte-components 4.10.37 → 4.10.40

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.
@@ -5,7 +5,6 @@
5
5
  import Select from './Select.svelte';
6
6
  import Switch from './Switch.svelte';
7
7
  import { Placement } from '../Styling.js';
8
- import { addTransactionSupport } from 'ioredis/built/transaction.js';
9
8
  import Button from './Button.svelte';
10
9
 
11
10
  interface FormButton {
@@ -24,7 +23,7 @@
24
23
 
25
24
  let {
26
25
  buttons = [],
27
- schema,
26
+ schema = [],
28
27
  action = '',
29
28
  buttonsContainer = '',
30
29
  buttonPosition = Placement.Bottom
@@ -39,7 +38,7 @@
39
38
  </div>
40
39
  {/snippet}
41
40
 
42
- <form method="POST" action={action}>
41
+ <form method="POST" {action}>
43
42
  <fieldset>
44
43
  {#if buttonPosition === Placement.Top}
45
44
  {@render renderButtons()}
@@ -5,7 +5,8 @@ export interface Field {
5
5
  meta: any;
6
6
  isRequired: boolean;
7
7
  }
8
- export declare function serialize(schema: any): Promise<import("sveltekit-superforms").SuperValidated<{}, any, {}>>;
8
+ export declare function serialize(schema: any): Promise<Field[]>;
9
+ export declare function createForm(schema: any): Promise<import("sveltekit-superforms").SuperValidated<{}, any, {}>>;
9
10
  export declare function mapEntiresToOptions(field: Field): {
10
11
  label: string;
11
12
  value: string;
@@ -1,20 +1,22 @@
1
1
  import { superValidate } from 'sveltekit-superforms';
2
2
  import { yup } from 'sveltekit-superforms/adapters';
3
3
  export async function serialize(schema) {
4
- // const keys = schema._nodes.reverse();
5
- // const fields: Array<Field> = keys.map((key: string) => {
6
- // const field = schema.fields[key];
7
- // const hasEntries = field._whitelist.size > 0;
8
- // const isOptional = field.spec.optional ?? true;
9
- // return {
10
- // name: key,
11
- // type: hasEntries ? "enum" : field.type,
12
- // entries: hasEntries ? [...field._whitelist] : [],
13
- // meta: field.spec.meta ?? {},
14
- // isRequired: !isOptional,
15
- // };
16
- // });
17
- // return fields;
4
+ const keys = schema._nodes.reverse();
5
+ const fields = keys.map((key) => {
6
+ const field = schema.fields[key];
7
+ const hasEntries = field._whitelist.size > 0;
8
+ const isOptional = field.spec.optional ?? true;
9
+ return {
10
+ name: key,
11
+ type: hasEntries ? "enum" : field.type,
12
+ entries: hasEntries ? [...field._whitelist] : [],
13
+ meta: field.spec.meta ?? {},
14
+ isRequired: !isOptional,
15
+ };
16
+ });
17
+ return fields;
18
+ }
19
+ export async function createForm(schema) {
18
20
  const form = await superValidate(yup(schema));
19
21
  return form;
20
22
  }
@@ -20,7 +20,7 @@
20
20
 
21
21
  let dynamicComponentRefs = $state([]); //https://svelte.dev/tutorial/component-this
22
22
  let tabButtonRefs: Array<HTMLButtonElement> = $state([]);
23
- let activePanel = $state(null);
23
+ let activePanel: Tab = $state(tabs[0]);
24
24
 
25
25
  const baseStyles = () => `tabs ${isVerticalOrientation ? 'tabs-vertical' : ''}`;
26
26
 
@@ -168,8 +168,8 @@
168
168
  {:else} -->
169
169
  <button
170
170
  bind:this={tabButtonRefs[i]}
171
- on:click={() => selectTab(i)}
172
- on:keydown={(e) => handleKeyDown(e, i)}
171
+ onclick={() => selectTab(i)}
172
+ onkeydown={(e) => handleKeyDown(e, i)}
173
173
  disabled={tab.isDisabled}
174
174
  class={tabButtonClasses(tab)}
175
175
  role="tab"
package/dist/index.d.ts CHANGED
@@ -34,7 +34,7 @@ export { default as AntiBot } from './components/form/AntiBot.svelte';
34
34
  export { default as Dropzone } from './components/form/Dropzone.svelte';
35
35
  export { default as Select } from './components/form/Select.svelte';
36
36
  export { default as Form } from './components/form/Form.svelte';
37
- export { type Field, serialize, mapEntiresToOptions } from './components/form/form.js';
37
+ export { type Field, serialize, createForm, mapEntiresToOptions } from './components/form/form.js';
38
38
  export { default as Markdown } from './components/content/Markdown.svelte';
39
39
  export { type BlogPost, listAllPosts, importPost } from './components/blog/blog.js';
40
40
  export { default as EasyTools } from './components/integrations/EasyTools.svelte';
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ export { default as AntiBot } from './components/form/AntiBot.svelte';
46
46
  export { default as Dropzone } from './components/form/Dropzone.svelte';
47
47
  export { default as Select } from './components/form/Select.svelte';
48
48
  export { default as Form } from './components/form/Form.svelte';
49
- export { serialize, mapEntiresToOptions } from './components/form/form.js';
49
+ export { serialize, createForm, mapEntiresToOptions } from './components/form/form.js';
50
50
  /*
51
51
  * Content
52
52
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "4.10.37",
3
+ "version": "4.10.40",
4
4
  "watch": {
5
5
  "build": {
6
6
  "patterns": [