y200subcontrols 0.0.325 → 0.0.327
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/LabeledDatePicker.svelte +104 -0
- package/dist/components/LabeledDatePicker.svelte.d.ts +35 -0
- package/dist/components/LabeledFormInput.svelte +16 -7
- package/dist/components/LabeledPasswordInput.svelte +5 -3
- package/dist/components/LabeledPasswordInput.svelte.d.ts +1 -0
- package/dist/components/LabeledTextArea.svelte +64 -0
- package/dist/components/LabeledTextArea.svelte.d.ts +30 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<script>import { onMount, createEventDispatcher } from "svelte";
|
|
2
|
+
import LabeledFormInput from "./LabeledFormInput.svelte";
|
|
3
|
+
export let labelText = void 0;
|
|
4
|
+
export let id = void 0;
|
|
5
|
+
export let readonly = false;
|
|
6
|
+
export let required = false;
|
|
7
|
+
export let value = void 0;
|
|
8
|
+
export let name = void 0;
|
|
9
|
+
export let placeholder = void 0;
|
|
10
|
+
export let validationText = void 0;
|
|
11
|
+
export let autocomplete = "off";
|
|
12
|
+
export let input = void 0;
|
|
13
|
+
export let customCss = "";
|
|
14
|
+
export let visible = true;
|
|
15
|
+
export let inputType = "datetime-local";
|
|
16
|
+
export let disabled = false;
|
|
17
|
+
let _value = "";
|
|
18
|
+
function padZero(num) {
|
|
19
|
+
return num > 9 ? `${num}` : `0${num}`;
|
|
20
|
+
}
|
|
21
|
+
$: {
|
|
22
|
+
if (value) {
|
|
23
|
+
if (typeof value === "string") {
|
|
24
|
+
value = new Date(value);
|
|
25
|
+
}
|
|
26
|
+
const year = value.getFullYear();
|
|
27
|
+
const month = value.getMonth() + 1;
|
|
28
|
+
const day = value.getDate();
|
|
29
|
+
const hour = padZero(value.getHours());
|
|
30
|
+
const minute = padZero(value.getMinutes());
|
|
31
|
+
const second = padZero(value.getSeconds());
|
|
32
|
+
_value = `${year}-${padZero(month)}-${padZero(day)}T${hour}:${minute}:${second}`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const dispatch = createEventDispatcher();
|
|
36
|
+
export let isValid = true;
|
|
37
|
+
let inputContainer;
|
|
38
|
+
function validateElement(event) {
|
|
39
|
+
if (input.dataset.validated !== "true") {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
isValid = input.checkValidity();
|
|
43
|
+
if (input.type === "number") {
|
|
44
|
+
console.clear();
|
|
45
|
+
console.log(value, isValid);
|
|
46
|
+
}
|
|
47
|
+
dispatch("validated", isValid);
|
|
48
|
+
}
|
|
49
|
+
function handleChange(event) {
|
|
50
|
+
const target = event.target;
|
|
51
|
+
_value = target.value;
|
|
52
|
+
if (_value === "" || _value === void 0) {
|
|
53
|
+
value = void 0;
|
|
54
|
+
dispatch("dateChanged", {
|
|
55
|
+
date: void 0
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const parts = _value.split("-");
|
|
60
|
+
const year = Number(parts[0]);
|
|
61
|
+
const month = Number(parts[1]);
|
|
62
|
+
const dayOfMonth = Number(parts[2]);
|
|
63
|
+
const _date = new Date(year, month - 1, dayOfMonth);
|
|
64
|
+
value = _date;
|
|
65
|
+
dispatch("dateChanged", {
|
|
66
|
+
date: _date
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
onMount(() => {
|
|
70
|
+
if (id === void 0) {
|
|
71
|
+
let r = (Math.random() + 1).toString(36).substring(2);
|
|
72
|
+
id = `input${r}`;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<LabeledFormInput
|
|
78
|
+
{labelText}
|
|
79
|
+
{id}
|
|
80
|
+
{validationText}
|
|
81
|
+
bind:isValid
|
|
82
|
+
{name}
|
|
83
|
+
{required}
|
|
84
|
+
{placeholder}
|
|
85
|
+
on:validated={validateElement}
|
|
86
|
+
{customCss}
|
|
87
|
+
{visible}
|
|
88
|
+
autoApplyCss={true}
|
|
89
|
+
>
|
|
90
|
+
<input
|
|
91
|
+
bind:this={input}
|
|
92
|
+
{disabled}
|
|
93
|
+
{id}
|
|
94
|
+
data-input="true"
|
|
95
|
+
type={inputType}
|
|
96
|
+
{required}
|
|
97
|
+
{autocomplete}
|
|
98
|
+
value={_value}
|
|
99
|
+
{placeholder}
|
|
100
|
+
{name}
|
|
101
|
+
on:change={handleChange}
|
|
102
|
+
{readonly}
|
|
103
|
+
/>
|
|
104
|
+
</LabeledFormInput>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
labelText?: string | undefined;
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
readonly?: boolean;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
value?: Date | undefined;
|
|
9
|
+
name?: string | undefined;
|
|
10
|
+
placeholder?: string | undefined;
|
|
11
|
+
validationText?: string | undefined;
|
|
12
|
+
autocomplete?: string | undefined;
|
|
13
|
+
input?: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | any | undefined;
|
|
14
|
+
customCss?: string;
|
|
15
|
+
visible?: boolean;
|
|
16
|
+
inputType?: "date" | "datetime-local";
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
isValid?: boolean;
|
|
19
|
+
};
|
|
20
|
+
events: {
|
|
21
|
+
validated: CustomEvent<any>;
|
|
22
|
+
dateChanged: CustomEvent<any>;
|
|
23
|
+
} & {
|
|
24
|
+
[evt: string]: CustomEvent<any>;
|
|
25
|
+
};
|
|
26
|
+
slots: {};
|
|
27
|
+
exports?: {} | undefined;
|
|
28
|
+
bindings?: string | undefined;
|
|
29
|
+
};
|
|
30
|
+
export type LabeledDatePickerProps = typeof __propDef.props;
|
|
31
|
+
export type LabeledDatePickerEvents = typeof __propDef.events;
|
|
32
|
+
export type LabeledDatePickerSlots = typeof __propDef.slots;
|
|
33
|
+
export default class LabeledDatePicker extends SvelteComponent<LabeledDatePickerProps, LabeledDatePickerEvents, LabeledDatePickerSlots> {
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -18,6 +18,18 @@ export let allowZero = false;
|
|
|
18
18
|
export let disabled = false;
|
|
19
19
|
const dispatch = createEventDispatcher();
|
|
20
20
|
export let isValid = true;
|
|
21
|
+
let inputCss = `
|
|
22
|
+
border peer block w-full rounded shadow-sm bg-white text-neutral-900
|
|
23
|
+
${size === "sm" ? "py-1 px-2 text-sm" : ""}
|
|
24
|
+
${size === "md" ? "py-1.5 px-2 text-base" : ""}
|
|
25
|
+
${size === "lg" ? "py-2 px-2 text-lg" : ""}
|
|
26
|
+
focus:outline-none focus:ring
|
|
27
|
+
read-only:bg-neutral-100
|
|
28
|
+
dark:read-only:bg-neutral-800
|
|
29
|
+
placeholder:text-sm placeholder:font-thin
|
|
30
|
+
dark:bg-slate-900 dark:text-neutral-100 {numeric ? 'hide-browser-appearance' : ''}
|
|
31
|
+
${!isValid ? "border-pink-600 dark:border-pink-500 focus:ring-pink-600/20 dark:focus:ring-pink-600/40" : "dark:border-slate-600 border-slate-300 focus:ring-teal-500/20 dark:focus:ring-teal-500/30"}
|
|
32
|
+
${customCss}`;
|
|
21
33
|
let inputContainer;
|
|
22
34
|
function validateElement(event) {
|
|
23
35
|
if (input.dataset.validated !== "true") {
|
|
@@ -36,7 +48,7 @@ onMount(() => {
|
|
|
36
48
|
let r = (Math.random() + 1).toString(36).substring(2);
|
|
37
49
|
id = `input${r}`;
|
|
38
50
|
}
|
|
39
|
-
let elem = inputContainer.querySelector(
|
|
51
|
+
let elem = inputContainer.querySelector('[data-input="true"]');
|
|
40
52
|
if (elem) {
|
|
41
53
|
elem.dataset.requiresValidation = "true";
|
|
42
54
|
input = elem;
|
|
@@ -51,11 +63,7 @@ onMount(() => {
|
|
|
51
63
|
_input.placeholder = placeholder ?? "";
|
|
52
64
|
}
|
|
53
65
|
if (autoApplyCss) {
|
|
54
|
-
elem.className =
|
|
55
|
-
focus:outline-none focus:ring read-only:bg-neutral-100
|
|
56
|
-
placeholder:text-sm placeholder:font-thin
|
|
57
|
-
dark:bg-slate-900 dark:text-neutral-100
|
|
58
|
-
${!isValid ? "border-pink-600 dark:border-pink-500 focus:ring-pink-600/20 dark:focus:ring-pink-600/40" : "dark:border-slate-600 border-slate-300 focus:ring-blue-500/20 dark:focus:ring-blue-500/30"} ${customCss}`;
|
|
66
|
+
elem.className = inputCss;
|
|
59
67
|
}
|
|
60
68
|
}
|
|
61
69
|
if (numeric && input) {
|
|
@@ -79,6 +87,7 @@ onMount(() => {
|
|
|
79
87
|
<div bind:this={inputContainer}>
|
|
80
88
|
<slot>
|
|
81
89
|
<input
|
|
90
|
+
data-input="true"
|
|
82
91
|
bind:this={input}
|
|
83
92
|
{disabled}
|
|
84
93
|
{id}
|
|
@@ -93,7 +102,7 @@ onMount(() => {
|
|
|
93
102
|
read-only:bg-neutral-100
|
|
94
103
|
dark:read-only:bg-neutral-800
|
|
95
104
|
placeholder:text-sm placeholder:font-thin
|
|
96
|
-
dark:bg-slate-900 dark:text-neutral-100 {numeric ? '
|
|
105
|
+
dark:bg-slate-900 dark:text-neutral-100 {numeric ? '' : ''}
|
|
97
106
|
{!isValid
|
|
98
107
|
? 'border-pink-600 dark:border-pink-500 focus:ring-pink-600/20 dark:focus:ring-pink-600/40'
|
|
99
108
|
: 'dark:border-slate-600 border-slate-300 focus:ring-teal-500/20 dark:focus:ring-teal-500/30'}
|
|
@@ -11,6 +11,7 @@ export let placeholder = void 0;
|
|
|
11
11
|
export let validationText = void 0;
|
|
12
12
|
export let customCss = "";
|
|
13
13
|
export let customValidation = void 0;
|
|
14
|
+
export let disabled = false;
|
|
14
15
|
let input;
|
|
15
16
|
let isValid = true;
|
|
16
17
|
let inputType = "password";
|
|
@@ -67,6 +68,7 @@ onMount(() => {
|
|
|
67
68
|
{name}
|
|
68
69
|
{readonly}
|
|
69
70
|
{required}
|
|
71
|
+
{disabled}
|
|
70
72
|
bind:value
|
|
71
73
|
on:change
|
|
72
74
|
/>
|
|
@@ -79,7 +81,7 @@ onMount(() => {
|
|
|
79
81
|
>
|
|
80
82
|
{#if inputType === 'password'}
|
|
81
83
|
<svg
|
|
82
|
-
class="w-5 h-5
|
|
84
|
+
class="w-5 h-5"
|
|
83
85
|
aria-hidden="true"
|
|
84
86
|
xmlns="http://www.w3.org/2000/svg"
|
|
85
87
|
width="24"
|
|
@@ -96,7 +98,7 @@ onMount(() => {
|
|
|
96
98
|
</svg>
|
|
97
99
|
{:else}
|
|
98
100
|
<svg
|
|
99
|
-
class="w-5 h-5
|
|
101
|
+
class="w-5 h-5"
|
|
100
102
|
aria-hidden="true"
|
|
101
103
|
xmlns="http://www.w3.org/2000/svg"
|
|
102
104
|
width="24"
|
|
@@ -112,7 +114,7 @@ onMount(() => {
|
|
|
112
114
|
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
115
|
/>
|
|
114
116
|
</svg>
|
|
115
|
-
{/if}
|
|
117
|
+
{/if}
|
|
116
118
|
</button>
|
|
117
119
|
</div>
|
|
118
120
|
</LabeledFormInput>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script>import { createEventDispatcher, onMount } from "svelte";
|
|
2
|
+
import LabeledInput from "./LabeledFormInput.svelte";
|
|
3
|
+
export let labelText = void 0;
|
|
4
|
+
export let id = void 0;
|
|
5
|
+
export let readonly = false;
|
|
6
|
+
export let required = false;
|
|
7
|
+
export let value = void 0;
|
|
8
|
+
export let name = void 0;
|
|
9
|
+
export let placeholder = void 0;
|
|
10
|
+
export let validationText = void 0;
|
|
11
|
+
export let customCss = "";
|
|
12
|
+
export let customValidation = void 0;
|
|
13
|
+
export let rows = 5;
|
|
14
|
+
const dispatch = createEventDispatcher();
|
|
15
|
+
let input;
|
|
16
|
+
let isValid = true;
|
|
17
|
+
function handleValidated(event) {
|
|
18
|
+
if (customValidation) {
|
|
19
|
+
isValid = event.detail && customValidation();
|
|
20
|
+
} else {
|
|
21
|
+
isValid = event.detail;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function validateElement() {
|
|
25
|
+
if (input.dataset.validated !== "true") {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
isValid = input.checkValidity();
|
|
29
|
+
dispatch("validated", isValid);
|
|
30
|
+
}
|
|
31
|
+
onMount(() => {
|
|
32
|
+
if (id === void 0) {
|
|
33
|
+
let r = (Math.random() + 1).toString(36).substring(2);
|
|
34
|
+
id = `input${r}`;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<LabeledInput
|
|
40
|
+
{labelText}
|
|
41
|
+
{id}
|
|
42
|
+
{validationText}
|
|
43
|
+
{isValid}
|
|
44
|
+
{name}
|
|
45
|
+
{required}
|
|
46
|
+
{placeholder}
|
|
47
|
+
{customCss}
|
|
48
|
+
autoApplyCss={true}
|
|
49
|
+
on:validated={handleValidated}
|
|
50
|
+
>
|
|
51
|
+
<textarea
|
|
52
|
+
data-input="true"
|
|
53
|
+
bind:this={input}
|
|
54
|
+
|
|
55
|
+
bind:value
|
|
56
|
+
{id}
|
|
57
|
+
{name}
|
|
58
|
+
{required}
|
|
59
|
+
{placeholder}
|
|
60
|
+
{readonly}
|
|
61
|
+
{rows}
|
|
62
|
+
data-requires-validation={required}
|
|
63
|
+
/>
|
|
64
|
+
</LabeledInput>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
labelText?: string | undefined;
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
readonly?: boolean;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
value?: string | number | undefined;
|
|
9
|
+
name?: string | undefined;
|
|
10
|
+
placeholder?: string | undefined;
|
|
11
|
+
validationText?: string | undefined;
|
|
12
|
+
customCss?: string;
|
|
13
|
+
customValidation?: (() => Boolean) | undefined;
|
|
14
|
+
rows?: number;
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
validated: CustomEvent<any>;
|
|
18
|
+
} & {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {};
|
|
22
|
+
exports?: {} | undefined;
|
|
23
|
+
bindings?: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
export type LabeledTextAreaProps = typeof __propDef.props;
|
|
26
|
+
export type LabeledTextAreaEvents = typeof __propDef.events;
|
|
27
|
+
export type LabeledTextAreaSlots = typeof __propDef.slots;
|
|
28
|
+
export default class LabeledTextArea extends SvelteComponent<LabeledTextAreaProps, LabeledTextAreaEvents, LabeledTextAreaSlots> {
|
|
29
|
+
}
|
|
30
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -16,4 +16,6 @@ import DataTable from "./components/DataTable.svelte";
|
|
|
16
16
|
import DataTableCell from "./components/DataTableCell.svelte";
|
|
17
17
|
import DataTableRow from "./components/DataTableRow.svelte";
|
|
18
18
|
import DataTableMenuButton from "./components/DataTableMenuButton.svelte";
|
|
19
|
-
|
|
19
|
+
import LabeledDatePicker from "./components/LabeledDatePicker.svelte";
|
|
20
|
+
import LabeledTextArea from "./components/LabeledTextArea.svelte";
|
|
21
|
+
export { Button, LoadingIndicator, Card, CardHeader, Form, ToggleButton, LabeledFormInput, LabeledPasswordInput, Alert, HyperLink, LabeledSelect, ModalDialog, BooleanPresenter, DataTable, DataTableCell, DataTableRow, DataTableMenuButton, DatePresenter, LabeledDatePicker, LabeledTextArea };
|
package/dist/index.js
CHANGED
|
@@ -17,4 +17,6 @@ import DataTable from "./components/DataTable.svelte";
|
|
|
17
17
|
import DataTableCell from "./components/DataTableCell.svelte";
|
|
18
18
|
import DataTableRow from "./components/DataTableRow.svelte";
|
|
19
19
|
import DataTableMenuButton from "./components/DataTableMenuButton.svelte";
|
|
20
|
-
|
|
20
|
+
import LabeledDatePicker from "./components/LabeledDatePicker.svelte";
|
|
21
|
+
import LabeledTextArea from "./components/LabeledTextArea.svelte";
|
|
22
|
+
export { Button, LoadingIndicator, Card, CardHeader, Form, ToggleButton, LabeledFormInput, LabeledPasswordInput, Alert, HyperLink, LabeledSelect, ModalDialog, BooleanPresenter, DataTable, DataTableCell, DataTableRow, DataTableMenuButton, DatePresenter, LabeledDatePicker, LabeledTextArea };
|