y200subcontrols 0.0.33 → 0.0.34
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/BooleanPresenter.svelte +38 -0
- package/dist/components/BooleanPresenter.svelte.d.ts +18 -0
- package/dist/components/Breadcrumb.svelte +22 -0
- package/dist/components/Breadcrumb.svelte.d.ts +22 -0
- package/dist/components/Button.svelte +1 -0
- package/dist/components/Button.svelte.d.ts +2 -2
- package/dist/components/ConfirmModalDialog.svelte +15 -8
- package/dist/components/ConfirmModalDialog.svelte.d.ts +3 -0
- package/dist/components/DataTable.svelte +243 -0
- package/dist/components/DataTable.svelte.d.ts +34 -0
- package/dist/components/DataTableCell.svelte +19 -0
- package/dist/components/DataTableCell.svelte.d.ts +21 -0
- package/dist/components/DataTableMenuButton.svelte +134 -0
- package/dist/components/DataTableMenuButton.svelte.d.ts +27 -0
- package/dist/components/DataTablePaginator.svelte +118 -0
- package/dist/components/DataTablePaginator.svelte.d.ts +23 -0
- package/dist/components/DataTableRow.svelte +5 -0
- package/dist/components/DataTableRow.svelte.d.ts +18 -0
- package/dist/components/DatePresenter.svelte +22 -0
- package/dist/components/DatePresenter.svelte.d.ts +19 -0
- package/dist/components/HyperLink.svelte +15 -11
- package/dist/components/HyperLink.svelte.d.ts +2 -1
- package/dist/components/HyperlinkButton.svelte +25 -0
- package/dist/components/HyperlinkButton.svelte.d.ts +26 -0
- package/dist/components/LabeledDatePicker.svelte +103 -0
- package/dist/components/LabeledDatePicker.svelte.d.ts +35 -0
- package/dist/components/LabeledFormInput.svelte +17 -8
- package/dist/components/LabeledPasswordInput.svelte +6 -4
- package/dist/components/LabeledPasswordInput.svelte.d.ts +1 -0
- package/dist/components/LabeledSelect.svelte +24 -10
- package/dist/components/LabeledSelect.svelte.d.ts +2 -0
- package/dist/components/LabeledTextArea.svelte +64 -0
- package/dist/components/LabeledTextArea.svelte.d.ts +30 -0
- package/dist/components/SegmentedControl.svelte +75 -0
- package/dist/components/SegmentedControl.svelte.d.ts +26 -0
- package/dist/components/SideNav.svelte +12 -0
- package/dist/components/SideNav.svelte.d.ts +20 -0
- package/dist/components/SideNavItem.svelte +64 -0
- package/dist/components/SideNavItem.svelte.d.ts +24 -0
- package/dist/components/ToggleButton.svelte +6 -1
- package/dist/components/ToggleButton.svelte.d.ts +2 -0
- package/dist/components/types.d.ts +11 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +15 -1
- package/package.json +1 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import LabeledFormInput from "./LabeledFormInput.svelte";
|
|
3
|
+
import LabeledSelect from "./LabeledSelect.svelte";
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
|
+
export let recordsPerPageArray = [10, 25, 50, 100];
|
|
6
|
+
export let recordsPerPage = 10;
|
|
7
|
+
export let currentPage;
|
|
8
|
+
export let totalRecords;
|
|
9
|
+
let pagesCount = 0;
|
|
10
|
+
let _currentPage = 0;
|
|
11
|
+
$: {
|
|
12
|
+
pagesCount = Math.ceil(totalRecords / recordsPerPage);
|
|
13
|
+
_currentPage = currentPage + 1;
|
|
14
|
+
}
|
|
15
|
+
function handlePageIndexChanged(factor) {
|
|
16
|
+
currentPage += factor;
|
|
17
|
+
handlePageChanged();
|
|
18
|
+
}
|
|
19
|
+
function handleCurrentPageChanged(event) {
|
|
20
|
+
currentPage = _currentPage - 1;
|
|
21
|
+
handlePageChanged();
|
|
22
|
+
}
|
|
23
|
+
function handleRecordsPerPageChanged(event) {
|
|
24
|
+
const target = event.target;
|
|
25
|
+
if (!target) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const value = Number(target.value);
|
|
29
|
+
recordsPerPage = value;
|
|
30
|
+
handlePageChanged();
|
|
31
|
+
}
|
|
32
|
+
function handlePageChanged() {
|
|
33
|
+
if (currentPage < 0) {
|
|
34
|
+
currentPage = 0;
|
|
35
|
+
}
|
|
36
|
+
if (currentPage > pagesCount - 1) {
|
|
37
|
+
currentPage = pagesCount - 1;
|
|
38
|
+
}
|
|
39
|
+
dispatch("pagechanged", {
|
|
40
|
+
currentPage,
|
|
41
|
+
recordsPerPage
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<div class="border border-slate-300 rounded flex p-2">
|
|
47
|
+
<div class="my-auto flex space-x-2">
|
|
48
|
+
<label for="recordsPerPageSelect" class="text-sm my-auto text-slate-600">
|
|
49
|
+
Records per page
|
|
50
|
+
</label>
|
|
51
|
+
<LabeledSelect
|
|
52
|
+
value={recordsPerPage}
|
|
53
|
+
id="recordsPerPageSelect"
|
|
54
|
+
on:change={handleRecordsPerPageChanged}
|
|
55
|
+
>
|
|
56
|
+
{#each recordsPerPageArray as recperPage (recperPage)}
|
|
57
|
+
<option value={recperPage}>{recperPage}</option>
|
|
58
|
+
{/each}
|
|
59
|
+
</LabeledSelect>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div class="ml-auto flex space-x-3">
|
|
63
|
+
<span class="inline-block my-auto text-sm text-slate-500"> Page </span>
|
|
64
|
+
<div class="w-14">
|
|
65
|
+
<LabeledFormInput
|
|
66
|
+
numeric={true}
|
|
67
|
+
bind:value={_currentPage}
|
|
68
|
+
on:change={handleCurrentPageChanged}
|
|
69
|
+
size="md"
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
<span class="inline-block my-auto text-sm text-slate-500 mr-10">
|
|
73
|
+
of {pagesCount} ( {totalRecords} records )
|
|
74
|
+
</span>
|
|
75
|
+
|
|
76
|
+
<button
|
|
77
|
+
on:click={() => handlePageIndexChanged(-1)}
|
|
78
|
+
type="button"
|
|
79
|
+
class="px-3 py-2 border border-teal-600 rounded text-teal-600 hover:bg-teal-600/10 active:bg-teal-600 active:text-teal-50
|
|
80
|
+
outline-none focus:outline-none
|
|
81
|
+
transition-all ease-in-out duration-300"
|
|
82
|
+
>
|
|
83
|
+
<svg
|
|
84
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
85
|
+
width="16"
|
|
86
|
+
height="16"
|
|
87
|
+
fill="currentColor"
|
|
88
|
+
viewBox="0 0 16 16"
|
|
89
|
+
>
|
|
90
|
+
<path
|
|
91
|
+
fill-rule="evenodd"
|
|
92
|
+
d="M9.224 1.553a.5.5 0 0 1 .223.67L6.56 8l2.888 5.776a.5.5 0 1 1-.894.448l-3-6a.5.5 0 0 1 0-.448l3-6a.5.5 0 0 1 .67-.223"
|
|
93
|
+
/>
|
|
94
|
+
</svg>
|
|
95
|
+
</button>
|
|
96
|
+
|
|
97
|
+
<button
|
|
98
|
+
on:click={() => handlePageIndexChanged(1)}
|
|
99
|
+
type="button"
|
|
100
|
+
class="px-3 py-2 border border-teal-600 rounded text-teal-600 hover:bg-teal-600/10 active:bg-teal-600 active:text-teal-50
|
|
101
|
+
outline-none focus:outline-none
|
|
102
|
+
transition-all ease-in-out duration-300"
|
|
103
|
+
>
|
|
104
|
+
<svg
|
|
105
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
106
|
+
width="16"
|
|
107
|
+
height="16"
|
|
108
|
+
fill="currentColor"
|
|
109
|
+
viewBox="0 0 16 16"
|
|
110
|
+
>
|
|
111
|
+
<path
|
|
112
|
+
fill-rule="evenodd"
|
|
113
|
+
d="M6.776 1.553a.5.5 0 0 1 .671.223l3 6a.5.5 0 0 1 0 .448l-3 6a.5.5 0 1 1-.894-.448L9.44 8 6.553 2.224a.5.5 0 0 1 .223-.671"
|
|
114
|
+
/>
|
|
115
|
+
</svg>
|
|
116
|
+
</button>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
recordsPerPageArray?: number[];
|
|
5
|
+
recordsPerPage?: number;
|
|
6
|
+
currentPage: number;
|
|
7
|
+
totalRecords: number;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
pagechanged: CustomEvent<any>;
|
|
11
|
+
} & {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {};
|
|
15
|
+
exports?: {} | undefined;
|
|
16
|
+
bindings?: string | undefined;
|
|
17
|
+
};
|
|
18
|
+
export type DataTablePaginatorProps = typeof __propDef.props;
|
|
19
|
+
export type DataTablePaginatorEvents = typeof __propDef.events;
|
|
20
|
+
export type DataTablePaginatorSlots = typeof __propDef.slots;
|
|
21
|
+
export default class DataTablePaginator extends SvelteComponent<DataTablePaginatorProps, DataTablePaginatorEvents, DataTablePaginatorSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {
|
|
8
|
+
default: {};
|
|
9
|
+
};
|
|
10
|
+
exports?: {} | undefined;
|
|
11
|
+
bindings?: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
export type DataTableRowProps = typeof __propDef.props;
|
|
14
|
+
export type DataTableRowEvents = typeof __propDef.events;
|
|
15
|
+
export type DataTableRowSlots = typeof __propDef.slots;
|
|
16
|
+
export default class DataTableRow extends SvelteComponent<DataTableRowProps, DataTableRowEvents, DataTableRowSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script>export let date;
|
|
2
|
+
export let showTimeStamp = true;
|
|
3
|
+
let dateFormatted = "";
|
|
4
|
+
$: {
|
|
5
|
+
if (typeof date === "string") {
|
|
6
|
+
date = new Date(date);
|
|
7
|
+
}
|
|
8
|
+
if (date) {
|
|
9
|
+
const formatter = new Intl.DateTimeFormat(void 0, {
|
|
10
|
+
dateStyle: "short",
|
|
11
|
+
timeStyle: showTimeStamp ? "short" : void 0
|
|
12
|
+
});
|
|
13
|
+
dateFormatted = formatter.format(date);
|
|
14
|
+
} else {
|
|
15
|
+
dateFormatted = "N/A";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<span>
|
|
21
|
+
{dateFormatted}
|
|
22
|
+
</span>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
date: Date | string;
|
|
5
|
+
showTimeStamp?: boolean;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
exports?: {} | undefined;
|
|
12
|
+
bindings?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type DatePresenterProps = typeof __propDef.props;
|
|
15
|
+
export type DatePresenterEvents = typeof __propDef.events;
|
|
16
|
+
export type DatePresenterSlots = typeof __propDef.slots;
|
|
17
|
+
export default class DatePresenter extends SvelteComponent<DatePresenterProps, DatePresenterEvents, DatePresenterSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>export let href;
|
|
2
|
-
export let linkStyle = "
|
|
2
|
+
export let linkStyle = "teal";
|
|
3
3
|
export let disabled = false;
|
|
4
4
|
export let id = void 0;
|
|
5
5
|
export let isButton = false;
|
|
@@ -16,10 +16,13 @@ $: {
|
|
|
16
16
|
aria-disabled={disabled}
|
|
17
17
|
class="px-1 py-1 {customCss} text-slate-600 dark:text-slate-200
|
|
18
18
|
{id}
|
|
19
|
-
{linkStyle === '
|
|
20
|
-
{linkStyle === '
|
|
21
|
-
{linkStyle === '
|
|
22
|
-
{linkStyle === '
|
|
19
|
+
{linkStyle === 'blue' ? 'hover:text-blue-500 active:text-blue-600' : ''}
|
|
20
|
+
{linkStyle === 'red' ? 'hover:text-red-500 active:text-red-600' : ''}
|
|
21
|
+
{linkStyle === 'teal' ? 'hover:text-teal-500 active:text-teal-600' : ''}
|
|
22
|
+
{linkStyle === 'indigo' ? 'hover:text-indigo-500 active:text-indigo-600' : ''}
|
|
23
|
+
{linkStyle === 'purple' ? 'hover:text-purple-500 active:text-purple-600' : ''}
|
|
24
|
+
|
|
25
|
+
|
|
23
26
|
aria-disabled:text-slate-300 dark:aria-disabled:text-slate-500
|
|
24
27
|
space-x-1 transition-colors ease-in-out duration-150"
|
|
25
28
|
>
|
|
@@ -32,14 +35,15 @@ $: {
|
|
|
32
35
|
aria-disabled={disabled}
|
|
33
36
|
class="px-1 py-1 {customCss} text-center
|
|
34
37
|
px-2 py-1.5 rounded-lg focus:outline-none focus:ring active:ring outline-none
|
|
35
|
-
{linkStyle === '
|
|
36
|
-
{linkStyle === '
|
|
38
|
+
{linkStyle === 'blue' ? 'bg-blue-500 text-blue-50 ring-blue-500/20 hover:bg-blue-600' : ''}
|
|
39
|
+
{linkStyle === 'slate'
|
|
37
40
|
? 'bg-slate-400 text-slate-50 ring-slate-500/20 hover:bg-slate-600 '
|
|
38
41
|
: ''}
|
|
39
|
-
{linkStyle === '
|
|
40
|
-
{linkStyle === '
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
{linkStyle === 'red' ? 'bg-red-500 text-red-50 ring-red-500/20 hover:bg-red-600' : ''}
|
|
43
|
+
{linkStyle === 'teal' ? 'bg-teal-500 text-teal-50 ring-teal-800/20 hover:bg-teal-600 ' : ''}
|
|
44
|
+
{linkStyle === 'indigo' ? 'bg-indigo-500 text-indigo-50 ring-indigo-800/20 hover:bg-indigo-600 ' : ''}
|
|
45
|
+
{linkStyle === 'purple' ? 'bg-purple-500 text-purple-50 ring-purple-800/20 hover:bg-purple-600 ' : ''}
|
|
46
|
+
{linkStyle === 'dark' ? 'bg-slate-950 text-slate-50 ring-slate-800/20 hover:bg-slate-800 ' : ''}
|
|
43
47
|
aria-disabled:cursor-default aria-disabled:text-slate-300 aria-disabled:bg-slate-100
|
|
44
48
|
space-x-1 transition-colors ease-in-out duration-150"
|
|
45
49
|
>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ColorThemes } from './types.js';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
href: string;
|
|
5
|
-
linkStyle?:
|
|
6
|
+
linkStyle?: ColorThemes;
|
|
6
7
|
disabled?: boolean;
|
|
7
8
|
id?: string | undefined;
|
|
8
9
|
isButton?: boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script>export let linkStyle = "teal";
|
|
2
|
+
export let disabled = false;
|
|
3
|
+
export let id = void 0;
|
|
4
|
+
export let customCss = "";
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
<button
|
|
10
|
+
on:click
|
|
11
|
+
type="button"
|
|
12
|
+
{disabled}
|
|
13
|
+
class="px-1 py-1 {customCss} text-slate-600 dark:text-slate-200
|
|
14
|
+
{id}
|
|
15
|
+
{linkStyle === 'blue' ? 'hover:text-blue-500 active:text-blue-600' : ''}
|
|
16
|
+
{linkStyle === 'red' ? 'hover:text-red-500 active:text-red-600' : ''}
|
|
17
|
+
{linkStyle === 'teal' ? 'hover:text-teal-500 active:text-teal-600' : ''}
|
|
18
|
+
{linkStyle === 'indigo' ? 'hover:text-indigo-500 active:text-indigo-600' : ''}
|
|
19
|
+
{linkStyle === 'purple' ? 'hover:text-purple-500 active:text-purple-600' : ''}
|
|
20
|
+
hover:underline underline-offset-4
|
|
21
|
+
disabled:text-slate-300 dark:disabled:text-slate-500
|
|
22
|
+
space-x-1 transition-colors ease-in-out duration-150"
|
|
23
|
+
>
|
|
24
|
+
<slot />
|
|
25
|
+
</button>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ColorThemes } from './types.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
linkStyle?: ColorThemes;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
id?: string | undefined;
|
|
8
|
+
customCss?: string;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
click: MouseEvent;
|
|
12
|
+
} & {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {
|
|
16
|
+
default: {};
|
|
17
|
+
};
|
|
18
|
+
exports?: {} | undefined;
|
|
19
|
+
bindings?: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
export type HyperlinkButtonProps = typeof __propDef.props;
|
|
22
|
+
export type HyperlinkButtonEvents = typeof __propDef.events;
|
|
23
|
+
export type HyperlinkButtonSlots = typeof __propDef.slots;
|
|
24
|
+
export default class HyperlinkButton extends SvelteComponent<HyperlinkButtonProps, HyperlinkButtonEvents, HyperlinkButtonSlots> {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
function setValueInternal(value2) {
|
|
22
|
+
if (value2) {
|
|
23
|
+
if (typeof value2 === "string") {
|
|
24
|
+
value2 = new Date(value2);
|
|
25
|
+
}
|
|
26
|
+
const year = value2.getFullYear();
|
|
27
|
+
const month = value2.getMonth() + 1;
|
|
28
|
+
const day = value2.getDate();
|
|
29
|
+
const hour = padZero(value2.getHours());
|
|
30
|
+
const minute = padZero(value2.getMinutes());
|
|
31
|
+
_value = `${year}-${padZero(month)}-${padZero(day)}T${hour}:${minute}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const dispatch = createEventDispatcher();
|
|
35
|
+
export let isValid = true;
|
|
36
|
+
function validateElement(event) {
|
|
37
|
+
if (input.dataset.validated !== "true") {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
isValid = input.checkValidity();
|
|
41
|
+
dispatch("validated", isValid);
|
|
42
|
+
}
|
|
43
|
+
function handleChange(event) {
|
|
44
|
+
const target = event.target;
|
|
45
|
+
let _value2 = target.value;
|
|
46
|
+
if (_value2 === "" || _value2 === void 0) {
|
|
47
|
+
value = void 0;
|
|
48
|
+
dispatch("dateChanged", {
|
|
49
|
+
date: void 0
|
|
50
|
+
});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const parts = _value2.split("T");
|
|
54
|
+
const datePart = parts[0].split("-");
|
|
55
|
+
const year = Number(datePart[0]);
|
|
56
|
+
const month = Number(datePart[1]);
|
|
57
|
+
const dayOfMonth = Number(datePart[2]);
|
|
58
|
+
const timeParts = parts[1].split(":");
|
|
59
|
+
const hours = Number(timeParts[0]);
|
|
60
|
+
const minutes = Number(timeParts[1]);
|
|
61
|
+
const _date = new Date(year, month - 1, dayOfMonth, hours, minutes);
|
|
62
|
+
value = _date;
|
|
63
|
+
dispatch("dateChanged", {
|
|
64
|
+
date: _date
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
onMount(() => {
|
|
68
|
+
if (id === void 0) {
|
|
69
|
+
let r = (Math.random() + 1).toString(36).substring(2);
|
|
70
|
+
id = `input${r}`;
|
|
71
|
+
}
|
|
72
|
+
setValueInternal(value);
|
|
73
|
+
});
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<LabeledFormInput
|
|
77
|
+
{labelText}
|
|
78
|
+
{id}
|
|
79
|
+
{validationText}
|
|
80
|
+
bind:isValid
|
|
81
|
+
{name}
|
|
82
|
+
{required}
|
|
83
|
+
{placeholder}
|
|
84
|
+
on:validated={validateElement}
|
|
85
|
+
{customCss}
|
|
86
|
+
{visible}
|
|
87
|
+
autoApplyCss={true}
|
|
88
|
+
>
|
|
89
|
+
<input
|
|
90
|
+
bind:this={input}
|
|
91
|
+
{disabled}
|
|
92
|
+
{id}
|
|
93
|
+
data-input="true"
|
|
94
|
+
type={inputType}
|
|
95
|
+
{required}
|
|
96
|
+
{autocomplete}
|
|
97
|
+
{placeholder}
|
|
98
|
+
{name}
|
|
99
|
+
on:change={handleChange}
|
|
100
|
+
{readonly}
|
|
101
|
+
value={_value}
|
|
102
|
+
/>
|
|
103
|
+
</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,9 +48,9 @@ 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
|
-
elem.dataset.requiresValidation = "true";
|
|
53
|
+
elem.dataset.requiresValidation = required ? "true" : "false";
|
|
42
54
|
input = elem;
|
|
43
55
|
elem.addEventListener("change", validateElement);
|
|
44
56
|
elem.addEventListener("validate--custom", validateElement);
|
|
@@ -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";
|
|
@@ -61,12 +62,13 @@ onMount(() => {
|
|
|
61
62
|
{!isValid
|
|
62
63
|
? 'border-pink-600 dark:border-pink-500 focus:ring-pink-600/20 dark:focus:ring-pink-600/40'
|
|
63
64
|
: 'dark:border-slate-600 border-slate-300 focus:ring-teal-500/20 dark:focus:ring-teal-500/30'}
|
|
64
|
-
{customCss}"
|
|
65
|
+
{customCss} pr-5"
|
|
65
66
|
{placeholder}
|
|
66
67
|
{id}
|
|
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>
|
|
@@ -6,6 +6,7 @@ export let value = void 0;
|
|
|
6
6
|
export let name = void 0;
|
|
7
7
|
export let placeholder = void 0;
|
|
8
8
|
export let validationText = void 0;
|
|
9
|
+
export let theme = "teal";
|
|
9
10
|
export let input = void 0;
|
|
10
11
|
export let visible = true;
|
|
11
12
|
export let disabled = false;
|
|
@@ -51,8 +52,7 @@ onMount(() => {
|
|
|
51
52
|
{#if labelText}
|
|
52
53
|
<label
|
|
53
54
|
for={id}
|
|
54
|
-
class="mb-1
|
|
55
|
-
bind:this={inputContainer}
|
|
55
|
+
class="inline-block mb-1 text-slate-600 dark:text-neutral-200 font-thin text-lg"
|
|
56
56
|
>
|
|
57
57
|
{labelText}
|
|
58
58
|
{#if required}
|
|
@@ -60,7 +60,7 @@ onMount(() => {
|
|
|
60
60
|
{/if}
|
|
61
61
|
</label>
|
|
62
62
|
{/if}
|
|
63
|
-
<div class="relative">
|
|
63
|
+
<div class="relative" bind:this={inputContainer}>
|
|
64
64
|
<select
|
|
65
65
|
bind:this={select}
|
|
66
66
|
{disabled}
|
|
@@ -70,26 +70,40 @@ onMount(() => {
|
|
|
70
70
|
{placeholder}
|
|
71
71
|
{name}
|
|
72
72
|
on:change
|
|
73
|
-
class="border peer block w-full py-1
|
|
73
|
+
class="border peer block w-full py-1 pl-2 pr-10 rounded-md shadow-sm bg-white text-neutral-900
|
|
74
74
|
focus:outline-none focus:ring
|
|
75
75
|
placeholder:text-sm placeholder:font-thin
|
|
76
76
|
dark:bg-slate-900 dark:text-neutral-100 appearance-none
|
|
77
|
+
|
|
77
78
|
{!isValid
|
|
78
79
|
? '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
|
|
80
|
+
: 'dark:border-slate-600 border-slate-300'}
|
|
81
|
+
{isValid && theme === 'teal' ? ' focus:ring-teal-600/20 dark:focus:ring-teal-600/30' : ''}
|
|
80
82
|
"
|
|
81
83
|
>
|
|
82
84
|
<slot />
|
|
83
85
|
</select>
|
|
84
86
|
<span
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
class="absolute right-0 inset-y-0 w-8 flex text-slate-500 pointer-events-none
|
|
88
|
+
{theme === 'teal' ? 'peer-hover:text-teal-600 peer-focus:text-teal-600' : ''}
|
|
89
|
+
{theme === 'blue' ? 'peer-hover:text-blue-500 peer-focus:text-blue-500' : ''}
|
|
90
|
+
"
|
|
88
91
|
>
|
|
89
|
-
<
|
|
92
|
+
<svg
|
|
93
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
94
|
+
width="16"
|
|
95
|
+
height="16"
|
|
96
|
+
fill="currentColor"
|
|
97
|
+
class="w-4 h-4 block m-auto"
|
|
98
|
+
viewBox="0 0 16 16"
|
|
99
|
+
>
|
|
100
|
+
<path
|
|
101
|
+
fill-rule="evenodd"
|
|
102
|
+
d="M1.553 6.776a.5.5 0 0 1 .67-.223L8 9.44l5.776-2.888a.5.5 0 1 1 .448.894l-6 3a.5.5 0 0 1-.448 0l-6-3a.5.5 0 0 1-.223-.67"
|
|
103
|
+
/>
|
|
104
|
+
</svg>
|
|
90
105
|
</span>
|
|
91
106
|
</div>
|
|
92
|
-
|
|
93
107
|
|
|
94
108
|
{#if validationText && !isValid}
|
|
95
109
|
<div class="text-sm text-pink-600 dark:text-pink-500 my-2">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ColorThemes } from './types.js';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
labelText?: string | undefined;
|
|
@@ -8,6 +9,7 @@ declare const __propDef: {
|
|
|
8
9
|
name?: string | undefined;
|
|
9
10
|
placeholder?: string | undefined;
|
|
10
11
|
validationText?: string | undefined;
|
|
12
|
+
theme?: ColorThemes;
|
|
11
13
|
input?: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | any | undefined;
|
|
12
14
|
visible?: boolean;
|
|
13
15
|
disabled?: boolean;
|