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,38 @@
|
|
|
1
|
+
<script>export let value;
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
{#if value}
|
|
5
|
+
<svg
|
|
6
|
+
class="w-5 h-5 text-emerald-500"
|
|
7
|
+
aria-hidden="true"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
width="24"
|
|
10
|
+
height="24"
|
|
11
|
+
fill="currentColor"
|
|
12
|
+
viewBox="0 0 24 24"
|
|
13
|
+
>
|
|
14
|
+
<path
|
|
15
|
+
fill-rule="evenodd"
|
|
16
|
+
d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12Zm13.707-1.293a1 1 0 0 0-1.414-1.414L11 12.586l-1.793-1.793a1 1 0 0 0-1.414 1.414l2.5 2.5a1 1 0 0 0 1.414 0l4-4Z"
|
|
17
|
+
clip-rule="evenodd"
|
|
18
|
+
/>
|
|
19
|
+
</svg>
|
|
20
|
+
{:else}
|
|
21
|
+
<svg
|
|
22
|
+
class="w-5 h-5 text-red-500"
|
|
23
|
+
aria-hidden="true"
|
|
24
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
25
|
+
width="24"
|
|
26
|
+
height="24"
|
|
27
|
+
fill="none"
|
|
28
|
+
viewBox="0 0 24 24"
|
|
29
|
+
>
|
|
30
|
+
<path
|
|
31
|
+
stroke="currentColor"
|
|
32
|
+
stroke-linecap="round"
|
|
33
|
+
stroke-linejoin="round"
|
|
34
|
+
stroke-width="2"
|
|
35
|
+
d="m15 9-6 6m0-6 6 6m6-3a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
|
|
36
|
+
/>
|
|
37
|
+
</svg>
|
|
38
|
+
{/if}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
value: boolean | undefined;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
exports?: {} | undefined;
|
|
11
|
+
bindings?: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
export type BooleanPresenterProps = typeof __propDef.props;
|
|
14
|
+
export type BooleanPresenterEvents = typeof __propDef.events;
|
|
15
|
+
export type BooleanPresenterSlots = typeof __propDef.slots;
|
|
16
|
+
export default class BooleanPresenter extends SvelteComponent<BooleanPresenterProps, BooleanPresenterEvents, BooleanPresenterSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script>import HyperLink from "./HyperLink.svelte";
|
|
2
|
+
export let breadcrumbs = [];
|
|
3
|
+
export let currentPage;
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<div
|
|
7
|
+
class="px-2 py-1.5 border border-slate-300 dark:border-slate-600 rounded bg-white dark:bg-slate-950"
|
|
8
|
+
>
|
|
9
|
+
<HyperLink href="/">
|
|
10
|
+
<i class="bi bi-house-fill" title="Home"></i>
|
|
11
|
+
</HyperLink>
|
|
12
|
+
<i class="bi bi-chevron-compact-right text-slate-300 dark:text-slate-600"></i>
|
|
13
|
+
{#each breadcrumbs as crumb (crumb.href)}
|
|
14
|
+
<HyperLink href={crumb.href}>
|
|
15
|
+
{crumb.title}
|
|
16
|
+
</HyperLink>
|
|
17
|
+
<i class="bi bi-chevron-compact-right text-slate-300 dark:text-slate-600"></i>
|
|
18
|
+
{/each}
|
|
19
|
+
<span class="text-teal-600 dark:text-teal-400">
|
|
20
|
+
{currentPage}
|
|
21
|
+
</span>
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
breadcrumbs?: {
|
|
5
|
+
title: string;
|
|
6
|
+
href: string;
|
|
7
|
+
}[];
|
|
8
|
+
currentPage: string;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {};
|
|
14
|
+
exports?: {} | undefined;
|
|
15
|
+
bindings?: string | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type BreadcrumbProps = typeof __propDef.props;
|
|
18
|
+
export type BreadcrumbEvents = typeof __propDef.events;
|
|
19
|
+
export type BreadcrumbSlots = typeof __propDef.slots;
|
|
20
|
+
export default class Breadcrumb extends SvelteComponent<BreadcrumbProps, BreadcrumbEvents, BreadcrumbSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -23,6 +23,7 @@ export let isLoading = false;
|
|
|
23
23
|
{buttonStyle === 'dark' ? 'bg-slate-950 text-slate-50 ring-slate-800/20 ' : ''}
|
|
24
24
|
{buttonStyle === 'indigo' ? 'bg-indigo-500 text-indigo-50 ring-indigo-500/20' : ''}
|
|
25
25
|
{buttonStyle === 'teal' ? 'bg-teal-600 text-teal-50 ring-teal-600/20' : ''}
|
|
26
|
+
{buttonStyle === 'purple' ? 'bg-purple-600 text-purple-50 ring-purple-600/20' : ''}
|
|
26
27
|
|
|
27
28
|
data-[loading='false']:disabled:bg-slate-100 data-[loading='false']:disabled:text-slate-300 disabled:ring-0
|
|
28
29
|
data-[loading='false']:disabled:brightness-100
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { Size } from './types.js';
|
|
2
|
+
import type { ColorThemes, Size } from './types.js';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
type?: "submit" | "reset" | "button";
|
|
6
|
-
buttonStyle?:
|
|
6
|
+
buttonStyle?: ColorThemes;
|
|
7
7
|
buttonSize?: Size;
|
|
8
8
|
id?: string | undefined;
|
|
9
9
|
disabled?: boolean;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
<script>import
|
|
1
|
+
<script>import { onMount } from "svelte";
|
|
2
|
+
import Button from "./Button.svelte";
|
|
2
3
|
import ModalDialog from "./ModalDialog.svelte";
|
|
3
4
|
export let message = "Message goes here";
|
|
4
5
|
export let style = "warning";
|
|
5
6
|
export let okButtonContent = "<span>Ok</span>";
|
|
6
|
-
export let cancelButtonContent = "<span>
|
|
7
|
+
export let cancelButtonContent = "<span>Cancel</span>";
|
|
7
8
|
let dialog;
|
|
9
|
+
let dialogId = "";
|
|
10
|
+
let buttonsContainer;
|
|
8
11
|
export async function showDialog() {
|
|
9
|
-
const okButton = document.getElementById(
|
|
10
|
-
const cancelButton = document.getElementById(
|
|
12
|
+
const okButton = document.getElementById(`okButtonDialog-${dialogId}`);
|
|
13
|
+
const cancelButton = document.getElementById(`cancelButtonDialog-${dialogId}`);
|
|
11
14
|
const p = new Promise((resolve) => {
|
|
12
15
|
function closeDialog(result) {
|
|
13
16
|
okButton?.removeEventListener("click", acceptDialog);
|
|
@@ -27,10 +30,14 @@ export async function showDialog() {
|
|
|
27
30
|
});
|
|
28
31
|
return p;
|
|
29
32
|
}
|
|
33
|
+
onMount(() => {
|
|
34
|
+
let r = (Math.random() + 1).toString(36).substring(2);
|
|
35
|
+
dialogId = `dialog-${r}`;
|
|
36
|
+
});
|
|
30
37
|
</script>
|
|
31
38
|
|
|
32
39
|
<ModalDialog bind:this={dialog} showCloseButton={false} allowSubmit={false}>
|
|
33
|
-
<slot slot="title">Title goes here</slot>
|
|
40
|
+
<slot slot="title" name="title">Title goes here</slot>
|
|
34
41
|
<div
|
|
35
42
|
class="flex
|
|
36
43
|
{style === 'warning' ? 'text-amber-500' : ''}
|
|
@@ -98,11 +105,11 @@ export async function showDialog() {
|
|
|
98
105
|
{@html message}
|
|
99
106
|
</div>
|
|
100
107
|
</slot>
|
|
101
|
-
<div class="grid grid-cols-2 gap-2" slot="buttons">
|
|
102
|
-
<Button type="button" id="okButtonDialog">
|
|
108
|
+
<div class="grid grid-cols-2 gap-2" slot="buttons" bind:this={buttonsContainer}>
|
|
109
|
+
<Button type="button" id="okButtonDialog-{dialogId}">
|
|
103
110
|
{@html okButtonContent}
|
|
104
111
|
</Button>
|
|
105
|
-
<Button type="button" buttonStyle="dark" id="cancelButtonDialog">
|
|
112
|
+
<Button type="button" buttonStyle="dark" id="cancelButtonDialog-{dialogId}">
|
|
106
113
|
{@html cancelButtonContent}
|
|
107
114
|
</Button>
|
|
108
115
|
</div>
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
export let allowAdd = true;
|
|
3
|
+
export let allowSearch = true;
|
|
4
|
+
export let showSearch = true;
|
|
5
|
+
export let isBusy = false;
|
|
6
|
+
export let popupMenuItems = void 0;
|
|
7
|
+
export let hasAdvancedSearch = false;
|
|
8
|
+
export let searchHint = "Search";
|
|
9
|
+
let isMenuOpen = false;
|
|
10
|
+
let isAdvancedSearchOpen = false;
|
|
11
|
+
const dispatch = createEventDispatcher();
|
|
12
|
+
function handleSearchRequested(event) {
|
|
13
|
+
const target = event.target;
|
|
14
|
+
const value = target?.value;
|
|
15
|
+
if (event.key === "Enter" || !value || value === "") {
|
|
16
|
+
dispatch("search", {
|
|
17
|
+
value
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function toggleAdvancedSearch() {
|
|
22
|
+
if (isAdvancedSearchOpen === true) {
|
|
23
|
+
closeAdvancedSearch();
|
|
24
|
+
} else {
|
|
25
|
+
openAdvancedSearch();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function openAdvancedSearch() {
|
|
29
|
+
isAdvancedSearchOpen = true;
|
|
30
|
+
}
|
|
31
|
+
function closeAdvancedSearch() {
|
|
32
|
+
isAdvancedSearchOpen = false;
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<div
|
|
37
|
+
class="border border-slate-300 bg-white p-2 flex rounded mt-2 shadow {hasAdvancedSearch
|
|
38
|
+
? 'mb-0'
|
|
39
|
+
: 'mb-2'}
|
|
40
|
+
{isAdvancedSearchOpen ? 'rounded-b-none shadow-none' : ''}
|
|
41
|
+
"
|
|
42
|
+
>
|
|
43
|
+
<h1 class="text-2xl">
|
|
44
|
+
<slot name="title">Header goes here</slot>
|
|
45
|
+
</h1>
|
|
46
|
+
<div class="ml-auto my-auto flex">
|
|
47
|
+
{#if showSearch}
|
|
48
|
+
<div class="relative ">
|
|
49
|
+
<input
|
|
50
|
+
disabled={!allowSearch || isBusy}
|
|
51
|
+
type="text"
|
|
52
|
+
class="border border-slate-300 rounded-md pl-2 pr-8 py-1.5
|
|
53
|
+
focus:border-indigo-500 focus:ring ring-indigo-500/30 focus:outline-none
|
|
54
|
+
md:min-w-[250px] lg:min-w-[300px]
|
|
55
|
+
rounded-r-none disabled:bg-slate-200 disabled:text-slate-400 h-full
|
|
56
|
+
"
|
|
57
|
+
placeholder={searchHint}
|
|
58
|
+
on:keyup={handleSearchRequested}
|
|
59
|
+
/>
|
|
60
|
+
<div class="absolute right-0 inset-y-0 w-8 flex">
|
|
61
|
+
<svg
|
|
62
|
+
class="w-5 h-5 text-slate-400 my-auto"
|
|
63
|
+
aria-hidden="true"
|
|
64
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
65
|
+
width="24"
|
|
66
|
+
height="24"
|
|
67
|
+
fill="none"
|
|
68
|
+
viewBox="0 0 24 24"
|
|
69
|
+
>
|
|
70
|
+
<path
|
|
71
|
+
stroke="currentColor"
|
|
72
|
+
stroke-linecap="round"
|
|
73
|
+
stroke-width="2"
|
|
74
|
+
d="m21 21-3.5-3.5M17 10a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z"
|
|
75
|
+
/>
|
|
76
|
+
</svg>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
{/if}
|
|
80
|
+
<button
|
|
81
|
+
disabled={isBusy}
|
|
82
|
+
title="Reload data"
|
|
83
|
+
type="button"
|
|
84
|
+
class="px-3 py-1.5 bg-emerald-500 text-emerald-50 first:rounded-l-md
|
|
85
|
+
focus:outline-none focus:ring ring-emerald-500/20 active:z-[500]
|
|
86
|
+
hover:bg-emerald-600 disabled:bg-slate-100 disabled:text-slate-300
|
|
87
|
+
last-of-type:rounded-r-md"
|
|
88
|
+
on:click={() => dispatch('refresh')}
|
|
89
|
+
>
|
|
90
|
+
<svg
|
|
91
|
+
class="w-4 h-4"
|
|
92
|
+
aria-hidden="true"
|
|
93
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
94
|
+
width="24"
|
|
95
|
+
height="24"
|
|
96
|
+
fill="none"
|
|
97
|
+
viewBox="0 0 24 24"
|
|
98
|
+
>
|
|
99
|
+
<path
|
|
100
|
+
stroke="currentColor"
|
|
101
|
+
stroke-linecap="round"
|
|
102
|
+
stroke-linejoin="round"
|
|
103
|
+
stroke-width="2"
|
|
104
|
+
d="M17.651 7.65a7.131 7.131 0 0 0-12.68 3.15M18.001 4v4h-4m-7.652 8.35a7.13 7.13 0 0 0 12.68-3.15M6 20v-4h4"
|
|
105
|
+
/>
|
|
106
|
+
</svg>
|
|
107
|
+
</button>
|
|
108
|
+
{#if allowAdd}
|
|
109
|
+
<button
|
|
110
|
+
disabled={isBusy}
|
|
111
|
+
title="Add New Item"
|
|
112
|
+
type="button"
|
|
113
|
+
class="px-3 py-1.5 bg-blue-500 text-blue-50
|
|
114
|
+
focus:outline-none focus:ring ring-blue-500/20 active:z-[500]
|
|
115
|
+
hover:bg-blue-600 disabled:bg-slate-100 disabled:text-slate-300
|
|
116
|
+
last-of-type:rounded-r-md"
|
|
117
|
+
on:click={() => dispatch('addnew')}
|
|
118
|
+
>
|
|
119
|
+
<svg
|
|
120
|
+
class="w-4 h-4"
|
|
121
|
+
aria-hidden="true"
|
|
122
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
123
|
+
width="24"
|
|
124
|
+
height="24"
|
|
125
|
+
fill="none"
|
|
126
|
+
viewBox="0 0 24 24"
|
|
127
|
+
>
|
|
128
|
+
<path
|
|
129
|
+
stroke="currentColor"
|
|
130
|
+
stroke-linecap="round"
|
|
131
|
+
stroke-linejoin="round"
|
|
132
|
+
stroke-width="2"
|
|
133
|
+
d="M5 12h14m-7 7V5"
|
|
134
|
+
/>
|
|
135
|
+
</svg>
|
|
136
|
+
</button>
|
|
137
|
+
{/if}
|
|
138
|
+
{#if hasAdvancedSearch}
|
|
139
|
+
<div class="my-auto">
|
|
140
|
+
<button
|
|
141
|
+
disabled={isBusy}
|
|
142
|
+
on:click={toggleAdvancedSearch}
|
|
143
|
+
type="button"
|
|
144
|
+
class="mx-1 w-9 h-9 bg-white border border-slate-300
|
|
145
|
+
text-slate-500
|
|
146
|
+
hover:bg-slate-100 rounded-full my-auto
|
|
147
|
+
disabled:bg-slate-100 disabled:text-slate-300
|
|
148
|
+
transition-all ease-in-out duration-150 flex"
|
|
149
|
+
>
|
|
150
|
+
<svg
|
|
151
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
152
|
+
|
|
153
|
+
fill="currentColor"
|
|
154
|
+
class="w-3 h-3 pointer-events-none inline-block {isAdvancedSearchOpen
|
|
155
|
+
? 'rotate-0'
|
|
156
|
+
: 'rotate-180'} m-auto
|
|
157
|
+
transition-transform duration-150 ease-in-out"
|
|
158
|
+
viewBox="0 0 16 16"
|
|
159
|
+
>
|
|
160
|
+
<path
|
|
161
|
+
fill-rule="evenodd"
|
|
162
|
+
d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708"
|
|
163
|
+
/>
|
|
164
|
+
</svg>
|
|
165
|
+
</button>
|
|
166
|
+
</div>
|
|
167
|
+
{/if}
|
|
168
|
+
</div>
|
|
169
|
+
{#if popupMenuItems && popupMenuItems.length > 0}
|
|
170
|
+
<div class=" mx-2 relative my-auto">
|
|
171
|
+
<button
|
|
172
|
+
type="button"
|
|
173
|
+
class="px-3 py-1.5 text-blue-500 border border-blue-500 rounded
|
|
174
|
+
hover:bg-blue-50 active:bg-blue-500 active:text-blue-50 outline-blue-600 h-full
|
|
175
|
+
disabled:text-slate-300"
|
|
176
|
+
on:click={() => (isMenuOpen = true)}
|
|
177
|
+
>
|
|
178
|
+
<i class="bi bi-three-dots"></i>
|
|
179
|
+
</button>
|
|
180
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
181
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
182
|
+
<div
|
|
183
|
+
class="fixed inset-0 {isMenuOpen ? 'block' : 'hidden'} "
|
|
184
|
+
on:click={() => (isMenuOpen = false)}
|
|
185
|
+
/>
|
|
186
|
+
<div
|
|
187
|
+
class="absolute right-0 mt-1
|
|
188
|
+
bg-white border border-slate-300 shadow-lg rounded z-[1001]
|
|
189
|
+
transition-all ease-in-out duration-300 min-w-[220px]
|
|
190
|
+
grid
|
|
191
|
+
"
|
|
192
|
+
style="visibility: {isMenuOpen ? 'visible' : 'hidden'};grid-template-rows:{isMenuOpen
|
|
193
|
+
? '1fr'
|
|
194
|
+
: '0fr'};"
|
|
195
|
+
>
|
|
196
|
+
<div class="overflow-hidden">
|
|
197
|
+
<ul class="py-2 divide-y min-w-fit">
|
|
198
|
+
{#each popupMenuItems as menuItem (menuItem.id)}
|
|
199
|
+
<li class="flex">
|
|
200
|
+
<button
|
|
201
|
+
disabled={menuItem.disabled}
|
|
202
|
+
class="space-x-1 px-2 text-slate-600 hover:bg-slate-500/20
|
|
203
|
+
block flex-grow py-1 text-left active:text-slate-50 active:bg-slate-500
|
|
204
|
+
transition-all ease-in-out duration-300 focus:outline-none outline-none
|
|
205
|
+
disabled:text-slate-300 disabled:hover:bg-transparent whitespace-nowrap"
|
|
206
|
+
type="button"
|
|
207
|
+
on:click={() => {
|
|
208
|
+
menuItem.action();
|
|
209
|
+
isMenuOpen = false;
|
|
210
|
+
}}
|
|
211
|
+
>
|
|
212
|
+
{@html menuItem.content}
|
|
213
|
+
</button>
|
|
214
|
+
</li>
|
|
215
|
+
{/each}
|
|
216
|
+
</ul>
|
|
217
|
+
</div>
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
{/if}
|
|
221
|
+
</div>
|
|
222
|
+
<div
|
|
223
|
+
class="{hasAdvancedSearch ? 'grid' : 'hidden'} mb-2
|
|
224
|
+
{isAdvancedSearchOpen ? 'bg-slate-50 border border-slate-300 shadow' : ''}
|
|
225
|
+
transition-all duration-300 ease-linear
|
|
226
|
+
"
|
|
227
|
+
style={isAdvancedSearchOpen ? 'grid-template-rows:1fr;' : 'grid-template-rows:0fr;'}
|
|
228
|
+
>
|
|
229
|
+
<div class={isAdvancedSearchOpen ? '' : 'overflow-hidden'}>
|
|
230
|
+
<slot name="advancedsearch" />
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
|
|
234
|
+
<div class="bg-white border border-slate-300 shadow-md my-1">
|
|
235
|
+
<table class="w-full border-collapse">
|
|
236
|
+
<thead class="bg-gray-500 text-gray-50 border-b-2 border-b-gray-700">
|
|
237
|
+
<slot name="header" />
|
|
238
|
+
</thead>
|
|
239
|
+
<tbody>
|
|
240
|
+
<slot />
|
|
241
|
+
</tbody>
|
|
242
|
+
</table>
|
|
243
|
+
</div>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { PopupMenuItem } from './types.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
allowAdd?: boolean;
|
|
6
|
+
allowSearch?: boolean;
|
|
7
|
+
showSearch?: boolean;
|
|
8
|
+
isBusy?: boolean;
|
|
9
|
+
popupMenuItems?: PopupMenuItem[] | undefined;
|
|
10
|
+
hasAdvancedSearch?: boolean;
|
|
11
|
+
searchHint?: string;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
refresh: CustomEvent<any>;
|
|
15
|
+
addnew: CustomEvent<any>;
|
|
16
|
+
search: CustomEvent<any>;
|
|
17
|
+
} & {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
};
|
|
20
|
+
slots: {
|
|
21
|
+
title: {};
|
|
22
|
+
advancedsearch: {};
|
|
23
|
+
header: {};
|
|
24
|
+
default: {};
|
|
25
|
+
};
|
|
26
|
+
exports?: {} | undefined;
|
|
27
|
+
bindings?: string | undefined;
|
|
28
|
+
};
|
|
29
|
+
export type DataTableProps = typeof __propDef.props;
|
|
30
|
+
export type DataTableEvents = typeof __propDef.events;
|
|
31
|
+
export type DataTableSlots = typeof __propDef.slots;
|
|
32
|
+
export default class DataTable extends SvelteComponent<DataTableProps, DataTableEvents, DataTableSlots> {
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script>export let isHeader = false;
|
|
2
|
+
export let width = void 0;
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
{#if isHeader}
|
|
6
|
+
<th
|
|
7
|
+
class="px-2 py-1.5 border-r border-r-slate-300 last-of-type:border-r-0 text-left"
|
|
8
|
+
style={width === undefined ? '' : `width:${width}px`}
|
|
9
|
+
>
|
|
10
|
+
<slot />
|
|
11
|
+
</th>
|
|
12
|
+
{:else}
|
|
13
|
+
<td
|
|
14
|
+
class="px-2 py-1.5 border-r border-r-slate-300 last-of-type:border-r-0"
|
|
15
|
+
style={width === undefined ? '' : `width:${width}px`}
|
|
16
|
+
>
|
|
17
|
+
<slot />
|
|
18
|
+
</td>
|
|
19
|
+
{/if}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
isHeader?: boolean;
|
|
5
|
+
width?: number | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
exports?: {} | undefined;
|
|
14
|
+
bindings?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
export type DataTableCellProps = typeof __propDef.props;
|
|
17
|
+
export type DataTableCellEvents = typeof __propDef.events;
|
|
18
|
+
export type DataTableCellSlots = typeof __propDef.slots;
|
|
19
|
+
export default class DataTableCell extends SvelteComponent<DataTableCellProps, DataTableCellEvents, DataTableCellSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<script>import { createEventDispatcher, onMount } from "svelte";
|
|
2
|
+
import ConfirmModalDialog from "./ConfirmModalDialog.svelte";
|
|
3
|
+
export let allowDelete = true;
|
|
4
|
+
export let showEdit = true;
|
|
5
|
+
export let showDelete = true;
|
|
6
|
+
export let isDisabled = false;
|
|
7
|
+
let deleteDialog;
|
|
8
|
+
let menuOpen = false;
|
|
9
|
+
let menuItemContainer;
|
|
10
|
+
const dispatch = createEventDispatcher();
|
|
11
|
+
const menuButtonStyle = `space-x-1 px-2 text-slate-600 hover:bg-slate-500/20
|
|
12
|
+
block w-full py-1 text-left active:text-slate-50 active:bg-slate-500
|
|
13
|
+
transition-all ease-in-out duration-300 focus:outline-none outline-none
|
|
14
|
+
disabled:text-slate-300 disabled:hover:bg-transparent
|
|
15
|
+
`;
|
|
16
|
+
export let menuWidth = 200;
|
|
17
|
+
function openMenu() {
|
|
18
|
+
menuOpen = true;
|
|
19
|
+
}
|
|
20
|
+
function closeMenu() {
|
|
21
|
+
menuOpen = false;
|
|
22
|
+
}
|
|
23
|
+
function editMenuItemClicked(_) {
|
|
24
|
+
dispatch("edit");
|
|
25
|
+
}
|
|
26
|
+
async function deleteMenuItemClicked() {
|
|
27
|
+
const result = await deleteDialog.showDialog();
|
|
28
|
+
if (result === "accept") {
|
|
29
|
+
dispatch("delete");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
onMount(() => {
|
|
33
|
+
const buttons = menuItemContainer.querySelectorAll('[data-menu-item="true"]');
|
|
34
|
+
for (const button of buttons) {
|
|
35
|
+
button.addEventListener("click", () => closeMenu());
|
|
36
|
+
if (button.className === "") {
|
|
37
|
+
button.className = menuButtonStyle;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<div class="relative">
|
|
44
|
+
<button
|
|
45
|
+
type="button"
|
|
46
|
+
class="px-3 py-1 rounded bg-emerald-500 text-emerald-50
|
|
47
|
+
disabled:bg-slate-100 disabled:text-slate-300"
|
|
48
|
+
disabled={isDisabled}
|
|
49
|
+
on:click={openMenu}
|
|
50
|
+
>
|
|
51
|
+
<svg
|
|
52
|
+
class="w-6 h-6 text-white"
|
|
53
|
+
aria-hidden="true"
|
|
54
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
55
|
+
width="24"
|
|
56
|
+
height="24"
|
|
57
|
+
fill="none"
|
|
58
|
+
viewBox="0 0 24 24"
|
|
59
|
+
>
|
|
60
|
+
<path
|
|
61
|
+
stroke="currentColor"
|
|
62
|
+
stroke-linecap="round"
|
|
63
|
+
stroke-width="3"
|
|
64
|
+
d="M12 6h.01M12 12h.01M12 18h.01"
|
|
65
|
+
/>
|
|
66
|
+
</svg>
|
|
67
|
+
</button>
|
|
68
|
+
{#if true}
|
|
69
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
70
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
71
|
+
<div
|
|
72
|
+
class="fixed {menuOpen ? 'block' : 'hidden'} inset-0 bg-black/20 z-[1000]"
|
|
73
|
+
on:click={closeMenu}
|
|
74
|
+
/>
|
|
75
|
+
<div
|
|
76
|
+
class="absolute right-0
|
|
77
|
+
bg-white border border-slate-300 shadow-md rounded z-[1001]
|
|
78
|
+
transition-all ease-in-out duration-300
|
|
79
|
+
grid
|
|
80
|
+
"
|
|
81
|
+
style="visibility: {menuOpen ? 'visible' : 'hidden'};grid-template-rows:{menuOpen
|
|
82
|
+
? '1fr'
|
|
83
|
+
: '0fr'}; width:{menuWidth}px;"
|
|
84
|
+
>
|
|
85
|
+
<div class="overflow-hidden">
|
|
86
|
+
<ul class="py-2" bind:this={menuItemContainer}>
|
|
87
|
+
{#if showEdit}
|
|
88
|
+
<li>
|
|
89
|
+
<button
|
|
90
|
+
on:click={editMenuItemClicked}
|
|
91
|
+
data-menu-item="true"
|
|
92
|
+
type="button"
|
|
93
|
+
class={menuButtonStyle}
|
|
94
|
+
>
|
|
95
|
+
<i class="bi bi-pencil-square"></i>
|
|
96
|
+
<span>Edit</span>
|
|
97
|
+
</button>
|
|
98
|
+
</li>
|
|
99
|
+
{/if}
|
|
100
|
+
<slot />
|
|
101
|
+
{#if showDelete}
|
|
102
|
+
<li class="border-t border-t-slate-300">
|
|
103
|
+
<button
|
|
104
|
+
disabled={!allowDelete}
|
|
105
|
+
on:click={deleteMenuItemClicked}
|
|
106
|
+
data-menu-item="true"
|
|
107
|
+
type="button"
|
|
108
|
+
class="space-x-1 px-2 text-red-600 hover:bg-red-500/20
|
|
109
|
+
block w-full py-1 text-left active:text-red-50 active:bg-red-500
|
|
110
|
+
transition-all ease-in-out duration-300 focus:outline-none outline-none
|
|
111
|
+
disabled:text-slate-300 disabled:hover:bg-transparent
|
|
112
|
+
"
|
|
113
|
+
>
|
|
114
|
+
<i class="bi bi-trash"></i>
|
|
115
|
+
<span>Delete</span>
|
|
116
|
+
</button>
|
|
117
|
+
</li>
|
|
118
|
+
{/if}
|
|
119
|
+
</ul>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
{/if}
|
|
123
|
+
</div>
|
|
124
|
+
<ConfirmModalDialog
|
|
125
|
+
bind:this={deleteDialog}
|
|
126
|
+
style="danger"
|
|
127
|
+
okButtonContent="Yes, delete"
|
|
128
|
+
cancelButtonContent="Cancel"
|
|
129
|
+
>
|
|
130
|
+
<span slot="title"> Confirm Delete </span>
|
|
131
|
+
<div class="text-center my-2">
|
|
132
|
+
<span class="text-lg"> Are you sure you want to delete this record ?</span>
|
|
133
|
+
</div>
|
|
134
|
+
</ConfirmModalDialog>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
allowDelete?: boolean;
|
|
5
|
+
showEdit?: boolean;
|
|
6
|
+
showDelete?: boolean;
|
|
7
|
+
isDisabled?: boolean;
|
|
8
|
+
menuWidth?: number;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
edit: CustomEvent<any>;
|
|
12
|
+
delete: CustomEvent<any>;
|
|
13
|
+
} & {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {
|
|
17
|
+
default: {};
|
|
18
|
+
};
|
|
19
|
+
exports?: {} | undefined;
|
|
20
|
+
bindings?: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
export type DataTableMenuButtonProps = typeof __propDef.props;
|
|
23
|
+
export type DataTableMenuButtonEvents = typeof __propDef.events;
|
|
24
|
+
export type DataTableMenuButtonSlots = typeof __propDef.slots;
|
|
25
|
+
export default class DataTableMenuButton extends SvelteComponent<DataTableMenuButtonProps, DataTableMenuButtonEvents, DataTableMenuButtonSlots> {
|
|
26
|
+
}
|
|
27
|
+
export {};
|