y200subcontrols 0.0.26 → 0.0.28
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/Alert.svelte +56 -0
- package/dist/components/Alert.svelte.d.ts +22 -0
- package/dist/components/Form.svelte +3 -3
- package/dist/components/Form.svelte.d.ts +2 -0
- package/dist/components/HyperLink.svelte +46 -0
- package/dist/components/HyperLink.svelte.d.ts +24 -0
- package/dist/components/LabeledPasswordInput.svelte +37 -2
- package/dist/components/LabeledSelect.svelte +99 -0
- package/dist/components/LabeledSelect.svelte.d.ts +33 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script>import { createEventDispatcher, onMount } from "svelte";
|
|
2
|
+
export let alertType = "info";
|
|
3
|
+
export let dismissable = true;
|
|
4
|
+
export let alertText;
|
|
5
|
+
let alert;
|
|
6
|
+
const dispatch = createEventDispatcher();
|
|
7
|
+
function dismissAlert() {
|
|
8
|
+
alert.style.borderWidth = "0";
|
|
9
|
+
alert.style.gridTemplateRows = "0fr";
|
|
10
|
+
setTimeout(() => {
|
|
11
|
+
dispatch("dismissed");
|
|
12
|
+
}, 300);
|
|
13
|
+
}
|
|
14
|
+
onMount(() => {
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
alert.style.gridTemplateRows = "1fr";
|
|
17
|
+
}, 10);
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div
|
|
22
|
+
bind:this={alert}
|
|
23
|
+
class="grid border rounded transition-all ease-linear duration-300
|
|
24
|
+
{alertType === 'error' ? 'bg-red-100 text-red-700 border-red-600' : ''}
|
|
25
|
+
{alertType === 'info' ? 'bg-blue-100 text-blue-600 border-blue-600' : ''}
|
|
26
|
+
{alertType === 'warning' ? 'bg-orange-100 text-orange-700 border-orange-700' : ''}
|
|
27
|
+
{alertType === 'success' ? 'bg-green-100 text-green-700 border-green-700' : ''}
|
|
28
|
+
"
|
|
29
|
+
style="grid-template-rows: 0fr"
|
|
30
|
+
>
|
|
31
|
+
<div class="overflow-hidden">
|
|
32
|
+
<div class="p-2 flex space-x-1">
|
|
33
|
+
<div class="my-auto text-2xl">
|
|
34
|
+
{#if alertType === 'error' || alertType === 'warning'}
|
|
35
|
+
<i class="bi bi-exclamation-triangle"></i>
|
|
36
|
+
{:else if alertType === 'info'}
|
|
37
|
+
<i class="bi bi-info-circle"></i>
|
|
38
|
+
{:else if alertType === 'success'}
|
|
39
|
+
<i class="bi bi-check2-circle"></i>
|
|
40
|
+
{/if}
|
|
41
|
+
</div>
|
|
42
|
+
<div class="my-auto text-center flex-grow">
|
|
43
|
+
{alertText}
|
|
44
|
+
</div>
|
|
45
|
+
{#if dismissable}
|
|
46
|
+
<button
|
|
47
|
+
type="button"
|
|
48
|
+
class=" text-slate-500 hover:text-slate-800 mb-auto"
|
|
49
|
+
on:click={dismissAlert}
|
|
50
|
+
>
|
|
51
|
+
<i class="bi bi-x-lg"></i>
|
|
52
|
+
</button>
|
|
53
|
+
{/if}
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
alertType?: "error" | "warning" | "success" | "info";
|
|
5
|
+
dismissable?: boolean;
|
|
6
|
+
alertText: string;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
dismissed: CustomEvent<any>;
|
|
10
|
+
} & {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {};
|
|
14
|
+
exports?: {} | undefined;
|
|
15
|
+
bindings?: string | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type AlertProps = typeof __propDef.props;
|
|
18
|
+
export type AlertEvents = typeof __propDef.events;
|
|
19
|
+
export type AlertSlots = typeof __propDef.slots;
|
|
20
|
+
export default class Alert extends SvelteComponent<AlertProps, AlertEvents, AlertSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -8,7 +8,7 @@ export let defaultButtonContent = "Save changes";
|
|
|
8
8
|
export let extendedCss = "";
|
|
9
9
|
export let isCard = true;
|
|
10
10
|
export let id = void 0;
|
|
11
|
-
let
|
|
11
|
+
export let buttonSize = "md";
|
|
12
12
|
let dispatch = createEventDispatcher();
|
|
13
13
|
function handleSubmit(event) {
|
|
14
14
|
event.preventDefault();
|
|
@@ -27,7 +27,7 @@ function handleSubmit(event) {
|
|
|
27
27
|
}
|
|
28
28
|
</script>
|
|
29
29
|
|
|
30
|
-
<Card stylingDisabled={!isCard}
|
|
30
|
+
<Card stylingDisabled={!isCard} {extendedCss}>
|
|
31
31
|
<slot slot="title" name="title" />
|
|
32
32
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
33
33
|
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
|
@@ -37,7 +37,7 @@ function handleSubmit(event) {
|
|
|
37
37
|
</div>
|
|
38
38
|
<slot name="buttons">
|
|
39
39
|
<div class="my-2 grid">
|
|
40
|
-
<Button type="submit" {isLoading}>
|
|
40
|
+
<Button type="submit" {isLoading} {buttonSize}>
|
|
41
41
|
<span>{@html defaultButtonContent}</span>
|
|
42
42
|
</Button>
|
|
43
43
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Size } from './types.js';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
isLoading?: boolean;
|
|
@@ -7,6 +8,7 @@ declare const __propDef: {
|
|
|
7
8
|
extendedCss?: string;
|
|
8
9
|
isCard?: boolean;
|
|
9
10
|
id?: string | undefined;
|
|
11
|
+
buttonSize?: Size;
|
|
10
12
|
};
|
|
11
13
|
events: {
|
|
12
14
|
click: MouseEvent;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script>export let href;
|
|
2
|
+
export let linkStyle = "primary";
|
|
3
|
+
export let disabled = false;
|
|
4
|
+
export let isButton = false;
|
|
5
|
+
export let customCss = "";
|
|
6
|
+
let hrefInternal = href;
|
|
7
|
+
$: {
|
|
8
|
+
hrefInternal = disabled ? void 0 : href;
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#if !isButton}
|
|
13
|
+
<a
|
|
14
|
+
href={hrefInternal}
|
|
15
|
+
aria-disabled={disabled}
|
|
16
|
+
class="px-1 py-1 {customCss} text-slate-600 dark:text-slate-200
|
|
17
|
+
|
|
18
|
+
{linkStyle === 'primary' ? 'hover:text-blue-500 active:text-blue-600' : ''}
|
|
19
|
+
{linkStyle === 'danger' ? 'hover:text-red-500 active:text-red-600' : ''}
|
|
20
|
+
{linkStyle === 'success' ? 'hover:text-emerald-500 active:text-emerald-600' : ''}
|
|
21
|
+
{linkStyle === 'secondary' ? 'hover:text-slate-700 active:text-slate-700' : ''}
|
|
22
|
+
aria-disabled:text-slate-300 dark:aria-disabled:text-slate-500
|
|
23
|
+
space-x-1 transition-colors ease-in-out duration-150"
|
|
24
|
+
>
|
|
25
|
+
<slot />
|
|
26
|
+
</a>
|
|
27
|
+
{:else}
|
|
28
|
+
<a
|
|
29
|
+
href={hrefInternal}
|
|
30
|
+
aria-disabled={disabled}
|
|
31
|
+
class="px-1 py-1 {customCss} text-center
|
|
32
|
+
px-2 py-1.5 rounded-lg focus:outline-none focus:ring active:ring outline-none
|
|
33
|
+
{linkStyle === 'primary' ? 'bg-blue-500 text-blue-50 ring-blue-500/20 hover:bg-blue-600' : ''}
|
|
34
|
+
{linkStyle === 'secondary'
|
|
35
|
+
? 'bg-slate-400 text-slate-50 ring-slate-500/20 hover:bg-slate-600 '
|
|
36
|
+
: ''}
|
|
37
|
+
{linkStyle === 'danger' ? 'bg-red-500 text-red-50 ring-red-500/20 hover:bg-red-600' : ''}
|
|
38
|
+
{linkStyle === 'success'
|
|
39
|
+
? 'bg-emerald-950 text-emerald-50 ring-emerald-800/20 hover:bg-emerald-600 '
|
|
40
|
+
: ''}
|
|
41
|
+
aria-disabled:cursor-default aria-disabled:text-slate-300 aria-disabled:bg-slate-100
|
|
42
|
+
space-x-1 transition-colors ease-in-out duration-150"
|
|
43
|
+
>
|
|
44
|
+
<slot />
|
|
45
|
+
</a>
|
|
46
|
+
{/if}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
href: string;
|
|
5
|
+
linkStyle?: "primary" | "secondary" | "danger" | "success";
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
isButton?: boolean;
|
|
8
|
+
customCss?: string;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {
|
|
14
|
+
default: {};
|
|
15
|
+
};
|
|
16
|
+
exports?: {} | undefined;
|
|
17
|
+
bindings?: string | undefined;
|
|
18
|
+
};
|
|
19
|
+
export type HyperLinkProps = typeof __propDef.props;
|
|
20
|
+
export type HyperLinkEvents = typeof __propDef.events;
|
|
21
|
+
export type HyperLinkSlots = typeof __propDef.slots;
|
|
22
|
+
export default class HyperLink extends SvelteComponent<HyperLinkProps, HyperLinkEvents, HyperLinkSlots> {
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -49,7 +49,7 @@ onMount(() => {
|
|
|
49
49
|
<input
|
|
50
50
|
type="password"
|
|
51
51
|
bind:this={input}
|
|
52
|
-
class="border peer block w-full rounded shadow-sm bg-white text-neutral-900
|
|
52
|
+
class="border peer block w-full rounded shadow-sm bg-white text-neutral-900
|
|
53
53
|
{size === 'sm' ? 'py-1 px-2 text-sm' : ''}
|
|
54
54
|
{size === 'md' ? 'py-1.5 px-2 text-base' : ''}
|
|
55
55
|
{size === 'lg' ? 'py-2 px-2 text-lg' : ''}
|
|
@@ -77,7 +77,42 @@ onMount(() => {
|
|
|
77
77
|
text-slate-500 hover:text-teal-600 active:text-teal-700 focus:outline-none"
|
|
78
78
|
on:click={toggleInputType}
|
|
79
79
|
>
|
|
80
|
-
|
|
80
|
+
{#if inputType === 'password'}
|
|
81
|
+
<svg
|
|
82
|
+
class="w-5 h-5 "
|
|
83
|
+
aria-hidden="true"
|
|
84
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
85
|
+
width="24"
|
|
86
|
+
height="24"
|
|
87
|
+
fill="none"
|
|
88
|
+
viewBox="0 0 24 24"
|
|
89
|
+
>
|
|
90
|
+
<path
|
|
91
|
+
stroke="currentColor"
|
|
92
|
+
stroke-width="2"
|
|
93
|
+
d="M21 12c0 1.2-4.03 6-9 6s-9-4.8-9-6c0-1.2 4.03-6 9-6s9 4.8 9 6Z"
|
|
94
|
+
/>
|
|
95
|
+
<path stroke="currentColor" stroke-width="2" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
|
|
96
|
+
</svg>
|
|
97
|
+
{:else}
|
|
98
|
+
<svg
|
|
99
|
+
class="w-5 h-5 "
|
|
100
|
+
aria-hidden="true"
|
|
101
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
102
|
+
width="24"
|
|
103
|
+
height="24"
|
|
104
|
+
fill="none"
|
|
105
|
+
viewBox="0 0 24 24"
|
|
106
|
+
>
|
|
107
|
+
<path
|
|
108
|
+
stroke="currentColor"
|
|
109
|
+
stroke-linecap="round"
|
|
110
|
+
stroke-linejoin="round"
|
|
111
|
+
stroke-width="2"
|
|
112
|
+
d="M3.933 13.909A4.357 4.357 0 0 1 3 12c0-1 4-6 9-6m7.6 3.8A5.068 5.068 0 0 1 21 12c0 1-3 6-9 6-.314 0-.62-.014-.918-.04M5 19 19 5m-4 7a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"
|
|
113
|
+
/>
|
|
114
|
+
</svg>
|
|
115
|
+
{/if}
|
|
81
116
|
</button>
|
|
82
117
|
</div>
|
|
83
118
|
</LabeledFormInput>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<script>import { onMount, createEventDispatcher } from "svelte";
|
|
2
|
+
export let labelText = void 0;
|
|
3
|
+
export let id = void 0;
|
|
4
|
+
export let required = false;
|
|
5
|
+
export let value = void 0;
|
|
6
|
+
export let name = void 0;
|
|
7
|
+
export let placeholder = void 0;
|
|
8
|
+
export let validationText = void 0;
|
|
9
|
+
export let input = void 0;
|
|
10
|
+
export let visible = true;
|
|
11
|
+
export let disabled = false;
|
|
12
|
+
const dispatch = createEventDispatcher();
|
|
13
|
+
export let isValid = true;
|
|
14
|
+
let inputContainer;
|
|
15
|
+
let select;
|
|
16
|
+
function validateElement(event) {
|
|
17
|
+
if (input.dataset.validated !== "true") {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
isValid = input.checkValidity();
|
|
21
|
+
if (input.type === "number") {
|
|
22
|
+
console.clear();
|
|
23
|
+
console.log(value, isValid);
|
|
24
|
+
}
|
|
25
|
+
dispatch("validated", isValid);
|
|
26
|
+
}
|
|
27
|
+
onMount(() => {
|
|
28
|
+
if (id === void 0) {
|
|
29
|
+
let r = (Math.random() + 1).toString(36).substring(2);
|
|
30
|
+
id = `select${r}`;
|
|
31
|
+
}
|
|
32
|
+
let elem = inputContainer.querySelector("select");
|
|
33
|
+
if (elem) {
|
|
34
|
+
elem.dataset.requiresValidation = "true";
|
|
35
|
+
input = elem;
|
|
36
|
+
elem.addEventListener("change", validateElement);
|
|
37
|
+
elem.addEventListener("validate--custom", validateElement);
|
|
38
|
+
if (id) {
|
|
39
|
+
elem.id = id;
|
|
40
|
+
}
|
|
41
|
+
let _input = elem;
|
|
42
|
+
if (_input) {
|
|
43
|
+
_input.name = name ?? "";
|
|
44
|
+
_input.placeholder = placeholder ?? "";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<div class=" {visible ? '' : 'hidden'}">
|
|
51
|
+
{#if labelText}
|
|
52
|
+
<label
|
|
53
|
+
for={id}
|
|
54
|
+
class="mb-1 inline-block text-slate-600 dark:text-neutral-200"
|
|
55
|
+
bind:this={inputContainer}
|
|
56
|
+
>
|
|
57
|
+
{labelText}
|
|
58
|
+
{#if required}
|
|
59
|
+
*
|
|
60
|
+
{/if}
|
|
61
|
+
</label>
|
|
62
|
+
{/if}
|
|
63
|
+
<div class="relative">
|
|
64
|
+
<select
|
|
65
|
+
bind:this={select}
|
|
66
|
+
{disabled}
|
|
67
|
+
{id}
|
|
68
|
+
{required}
|
|
69
|
+
bind:value
|
|
70
|
+
{placeholder}
|
|
71
|
+
{name}
|
|
72
|
+
on:change
|
|
73
|
+
class="border peer block w-full py-1 px-2 rounded-md shadow-sm bg-white text-neutral-900
|
|
74
|
+
focus:outline-none focus:ring
|
|
75
|
+
placeholder:text-sm placeholder:font-thin
|
|
76
|
+
dark:bg-slate-900 dark:text-neutral-100 appearance-none
|
|
77
|
+
{!isValid
|
|
78
|
+
? 'border-pink-600 dark:border-pink-500 focus:ring-pink-600/20 dark:focus:ring-pink-600/40'
|
|
79
|
+
: 'dark:border-slate-600 border-slate-300 focus:ring-sky-500/20 dark:focus:ring-sky-500/30'}
|
|
80
|
+
"
|
|
81
|
+
>
|
|
82
|
+
<slot />
|
|
83
|
+
</select>
|
|
84
|
+
<span
|
|
85
|
+
|
|
86
|
+
class="absolute right-0 inset-y-0 w-10 flex text-slate-500 pointer-events-none
|
|
87
|
+
peer-hover:text-blue-500 peer-focus:text-blue-500"
|
|
88
|
+
>
|
|
89
|
+
<i class="bi bi-chevron-down m-auto"></i>
|
|
90
|
+
</span>
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
{#if validationText && !isValid}
|
|
95
|
+
<div class="text-sm text-pink-600 dark:text-pink-500 my-2">
|
|
96
|
+
{validationText}
|
|
97
|
+
</div>
|
|
98
|
+
{/if}
|
|
99
|
+
</div>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
labelText?: string | undefined;
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
value?: string | number | undefined;
|
|
8
|
+
name?: string | undefined;
|
|
9
|
+
placeholder?: string | undefined;
|
|
10
|
+
validationText?: string | undefined;
|
|
11
|
+
input?: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | any | undefined;
|
|
12
|
+
visible?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
isValid?: boolean;
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
change: Event;
|
|
18
|
+
validated: CustomEvent<any>;
|
|
19
|
+
} & {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
};
|
|
22
|
+
slots: {
|
|
23
|
+
default: {};
|
|
24
|
+
};
|
|
25
|
+
exports?: {} | undefined;
|
|
26
|
+
bindings?: string | undefined;
|
|
27
|
+
};
|
|
28
|
+
export type LabeledSelectProps = typeof __propDef.props;
|
|
29
|
+
export type LabeledSelectEvents = typeof __propDef.events;
|
|
30
|
+
export type LabeledSelectSlots = typeof __propDef.slots;
|
|
31
|
+
export default class LabeledSelect extends SvelteComponent<LabeledSelectProps, LabeledSelectEvents, LabeledSelectSlots> {
|
|
32
|
+
}
|
|
33
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,7 @@ import Form from "./components/Form.svelte";
|
|
|
6
6
|
import ToggleButton from "./components/ToggleButton.svelte";
|
|
7
7
|
import LabeledFormInput from "./components/LabeledFormInput.svelte";
|
|
8
8
|
import LabeledPasswordInput from "./components/LabeledPasswordInput.svelte";
|
|
9
|
-
|
|
9
|
+
import Alert from "./components/Alert.svelte";
|
|
10
|
+
import HyperLink from "./components/HyperLink.svelte";
|
|
11
|
+
import LabeledSelect from "./components/LabeledSelect.svelte";
|
|
12
|
+
export { Button, LoadingIndicator, Card, CardHeader, Form, ToggleButton, LabeledFormInput, LabeledPasswordInput, Alert, HyperLink, LabeledSelect };
|
package/dist/index.js
CHANGED
|
@@ -7,4 +7,7 @@ import Form from "./components/Form.svelte";
|
|
|
7
7
|
import ToggleButton from "./components/ToggleButton.svelte";
|
|
8
8
|
import LabeledFormInput from "./components/LabeledFormInput.svelte";
|
|
9
9
|
import LabeledPasswordInput from "./components/LabeledPasswordInput.svelte";
|
|
10
|
-
|
|
10
|
+
import Alert from "./components/Alert.svelte";
|
|
11
|
+
import HyperLink from "./components/HyperLink.svelte";
|
|
12
|
+
import LabeledSelect from "./components/LabeledSelect.svelte";
|
|
13
|
+
export { Button, LoadingIndicator, Card, CardHeader, Form, ToggleButton, LabeledFormInput, LabeledPasswordInput, Alert, HyperLink, LabeledSelect };
|