y200subcontrols 0.0.23 → 0.0.25
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.
|
@@ -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 {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script>export let checked = false;
|
|
2
|
+
export let label = "";
|
|
3
|
+
export let id = void 0;
|
|
4
|
+
export let name = void 0;
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<label class="flex cursor-pointer">
|
|
8
|
+
<input type="checkbox" bind:checked class="hidden peer" {id} {name} />
|
|
9
|
+
<div
|
|
10
|
+
class=" rounded-full h-5 w-10 flex my-auto bg-slate-300
|
|
11
|
+
peer-checked:bg-teal-600 transition-all duration-300"
|
|
12
|
+
>
|
|
13
|
+
<div
|
|
14
|
+
class="w-5 h-5 rounded-full my-auto border border-slate-400 {!checked
|
|
15
|
+
? 'bg-slate-400 translate-x-0'
|
|
16
|
+
: ' translate-x-5 bg-slate-100 '} transition-all ease-in-out duration-300
|
|
17
|
+
"
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<span class="text-slate-500 my-auto mx-2 text-lg font-thin">
|
|
22
|
+
{label}
|
|
23
|
+
</span>
|
|
24
|
+
</label>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
checked?: boolean;
|
|
5
|
+
label?: string;
|
|
6
|
+
id?: string | undefined;
|
|
7
|
+
name?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
exports?: {} | undefined;
|
|
14
|
+
bindings?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
export type ToggleButtonProps = typeof __propDef.props;
|
|
17
|
+
export type ToggleButtonEvents = typeof __propDef.events;
|
|
18
|
+
export type ToggleButtonSlots = typeof __propDef.slots;
|
|
19
|
+
export default class ToggleButton extends SvelteComponent<ToggleButtonProps, ToggleButtonEvents, ToggleButtonSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ 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
|
+
import ToggleButton from "./components/ToggleButton.svelte";
|
|
7
|
+
export { Button, LoadingIndicator, Card, CardHeader, Form, ToggleButton };
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,6 @@ 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
|
+
import ToggleButton from "./components/ToggleButton.svelte";
|
|
8
|
+
export { Button, LoadingIndicator, Card, CardHeader, Form, ToggleButton };
|