y200subcontrols 0.0.23 → 0.0.24
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/components/Form.svelte +46 -0
- package/dist/components/Form.svelte.d.ts +34 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script>import { createEventDispatcher, onMount } from "svelte";
|
|
2
|
+
import Card from "./Card.svelte";
|
|
3
|
+
import Button from "./Button.svelte";
|
|
4
|
+
let form;
|
|
5
|
+
export let isLoading = false;
|
|
6
|
+
export let allowSubmit = true;
|
|
7
|
+
export let defaultButtonContent = "Save changes";
|
|
8
|
+
export let extendedCss = "";
|
|
9
|
+
export let isCard = true;
|
|
10
|
+
export let id = void 0;
|
|
11
|
+
let card;
|
|
12
|
+
let dispatch = createEventDispatcher();
|
|
13
|
+
function handleSubmit(event) {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
if (!allowSubmit) return;
|
|
16
|
+
const inputs = document.querySelectorAll('[data-requires-validation="true"]');
|
|
17
|
+
for (const input of inputs) {
|
|
18
|
+
let i = input;
|
|
19
|
+
i.dataset.validated = "true";
|
|
20
|
+
i.dispatchEvent(new Event("validate--custom"));
|
|
21
|
+
}
|
|
22
|
+
if (!form.checkValidity()) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const formData = new FormData(form);
|
|
26
|
+
dispatch("submit", formData);
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<Card stylingDisabled={!isCard} bind:this={card} {extendedCss}>
|
|
31
|
+
<slot slot="title" name="title" />
|
|
32
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
33
|
+
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
|
34
|
+
<form {id} on:click on:mousedown on:mouseup bind:this={form} novalidate on:submit={handleSubmit}>
|
|
35
|
+
<div class="my-4">
|
|
36
|
+
<slot />
|
|
37
|
+
</div>
|
|
38
|
+
<slot name="buttons">
|
|
39
|
+
<div class="my-2 grid">
|
|
40
|
+
<Button type="submit" {isLoading}>
|
|
41
|
+
<span>{@html defaultButtonContent}</span>
|
|
42
|
+
</Button>
|
|
43
|
+
</div>
|
|
44
|
+
</slot>
|
|
45
|
+
</form>
|
|
46
|
+
</Card>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
isLoading?: boolean;
|
|
5
|
+
allowSubmit?: boolean;
|
|
6
|
+
defaultButtonContent?: string;
|
|
7
|
+
extendedCss?: string;
|
|
8
|
+
isCard?: boolean;
|
|
9
|
+
id?: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
click: MouseEvent;
|
|
13
|
+
mousedown: MouseEvent;
|
|
14
|
+
mouseup: MouseEvent;
|
|
15
|
+
submit: CustomEvent<any>;
|
|
16
|
+
} & {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
};
|
|
19
|
+
slots: {
|
|
20
|
+
title: {
|
|
21
|
+
slot: string;
|
|
22
|
+
};
|
|
23
|
+
default: {};
|
|
24
|
+
buttons: {};
|
|
25
|
+
};
|
|
26
|
+
exports?: {} | undefined;
|
|
27
|
+
bindings?: string | undefined;
|
|
28
|
+
};
|
|
29
|
+
export type FormProps = typeof __propDef.props;
|
|
30
|
+
export type FormEvents = typeof __propDef.events;
|
|
31
|
+
export type FormSlots = typeof __propDef.slots;
|
|
32
|
+
export default class Form extends SvelteComponent<FormProps, FormEvents, FormSlots> {
|
|
33
|
+
}
|
|
34
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import LoadingIndicator from "./components/LoadingIndicator.svelte";
|
|
|
2
2
|
import Button from "./components/Button.svelte";
|
|
3
3
|
import Card from "./components/Card.svelte";
|
|
4
4
|
import CardHeader from "./components/CardHeader.svelte";
|
|
5
|
-
|
|
5
|
+
import Form from "./components/Form.svelte";
|
|
6
|
+
export { Button, LoadingIndicator, Card, CardHeader, Form };
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,5 @@ import LoadingIndicator from "./components/LoadingIndicator.svelte";
|
|
|
3
3
|
import Button from "./components/Button.svelte";
|
|
4
4
|
import Card from "./components/Card.svelte";
|
|
5
5
|
import CardHeader from "./components/CardHeader.svelte";
|
|
6
|
-
|
|
6
|
+
import Form from "./components/Form.svelte";
|
|
7
|
+
export { Button, LoadingIndicator, Card, CardHeader, Form };
|