y200subcontrols 0.0.27 → 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.
|
@@ -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 {};
|
|
@@ -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
|
@@ -7,4 +7,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
|
-
|
|
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
|
@@ -8,4 +8,6 @@ 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
|
-
|
|
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 };
|