y200subcontrols 0.0.338 → 0.0.340
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/README.md +2 -0
- package/dist/components/Breadcrumb.svelte +17 -12
- package/dist/components/Breadcrumb.svelte.d.ts +3 -1
- package/dist/components/Button.svelte +11 -3
- package/dist/components/Button.svelte.d.ts +1 -0
- package/dist/components/CardHeader.svelte +1 -1
- package/dist/components/CodePresenter.svelte +135 -0
- package/dist/components/CodePresenter.svelte.d.ts +26 -0
- package/dist/components/DataTable.svelte +10 -10
- package/dist/components/DataTable.svelte.d.ts +1 -0
- package/dist/components/DataTableCell.svelte +15 -2
- package/dist/components/DataTableCell.svelte.d.ts +3 -0
- package/dist/components/DataTableMenuButton.svelte +3 -3
- package/dist/components/DataTablePaginator.svelte +35 -11
- package/dist/components/DataTablePaginator.svelte.d.ts +2 -1
- package/dist/components/DatePresenter.svelte +5 -10
- package/dist/components/DatePresenter.svelte.d.ts +2 -0
- package/dist/components/Divider.svelte +8 -0
- package/dist/components/Divider.svelte.d.ts +18 -0
- package/dist/components/Drawer.svelte +87 -0
- package/dist/components/Drawer.svelte.d.ts +23 -0
- package/dist/components/DropDownButton.svelte +82 -0
- package/dist/components/DropDownButton.svelte.d.ts +27 -0
- package/dist/components/Form.svelte +13 -2
- package/dist/components/Form.svelte.d.ts +4 -0
- package/dist/components/HeadlessMenu.svelte +60 -0
- package/dist/components/HeadlessMenu.svelte.d.ts +25 -0
- package/dist/components/HyperLink.svelte +8 -2
- package/dist/components/HyperLink.svelte.d.ts +2 -0
- package/dist/components/HyperlinkButton.svelte +4 -4
- package/dist/components/HyperlinkButton.svelte.d.ts +1 -0
- package/dist/components/LabeledDatePicker.svelte +2 -0
- package/dist/components/LabeledDatePicker.svelte.d.ts +2 -0
- package/dist/components/LabeledFormInput.svelte +4 -1
- package/dist/components/LabeledPasswordInput.svelte +4 -2
- package/dist/components/LabeledPasswordInput.svelte.d.ts +1 -0
- package/dist/components/LabeledSelect.svelte +32 -10
- package/dist/components/LabeledSelect.svelte.d.ts +4 -0
- package/dist/components/ListBox.svelte +135 -0
- package/dist/components/ListBox.svelte.d.ts +24 -0
- package/dist/components/LoadingIndicator.svelte +14 -0
- package/dist/components/LoadingIndicator.svelte.d.ts +3 -2
- package/dist/components/ModalDialog.svelte +22 -5
- package/dist/components/Pill.svelte +42 -0
- package/dist/components/Pill.svelte.d.ts +23 -0
- package/dist/components/PillBoolean.svelte +60 -0
- package/dist/components/PillBoolean.svelte.d.ts +24 -0
- package/dist/components/SegmentedControl.svelte +10 -2
- package/dist/components/TabControl.svelte +79 -0
- package/dist/components/TabControl.svelte.d.ts +22 -0
- package/dist/components/TabItem.svelte +11 -0
- package/dist/components/TabItem.svelte.d.ts +21 -0
- package/dist/components/Table.svelte +18 -0
- package/dist/components/Table.svelte.d.ts +22 -0
- package/dist/components/ToggleButton.svelte +7 -4
- package/dist/components/ToggleButton.svelte.d.ts +3 -0
- package/dist/components/types.d.ts +2 -2
- package/dist/date-utils.d.ts +5 -0
- package/dist/date-utils.js +29 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +15 -1
- package/dist/number-utils.d.ts +1 -0
- package/dist/number-utils.js +10 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -4,19 +4,24 @@ export let currentPage;
|
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
6
|
<div
|
|
7
|
-
class="px-2 py-1.5 border border-slate-300 dark:border-slate-600 rounded bg-white dark:bg-slate-950"
|
|
7
|
+
class="px-2 py-1.5 border border-slate-300 dark:border-slate-600 rounded bg-white dark:bg-slate-950 flex flex-row"
|
|
8
8
|
>
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
|
|
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}
|
|
9
|
+
<div class="my-auto">
|
|
10
|
+
<HyperLink href="/">
|
|
11
|
+
<i class="bi bi-house-fill" title="Home"></i>
|
|
16
12
|
</HyperLink>
|
|
17
13
|
<i class="bi bi-chevron-compact-right text-slate-300 dark:text-slate-600"></i>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
{#each breadcrumbs as crumb (crumb.href)}
|
|
15
|
+
<HyperLink href={crumb.href}>
|
|
16
|
+
{crumb.title}
|
|
17
|
+
</HyperLink>
|
|
18
|
+
<i class="bi bi-chevron-compact-right text-slate-300 dark:text-slate-600"></i>
|
|
19
|
+
{/each}
|
|
20
|
+
<span class="text-teal-600 dark:text-teal-400">
|
|
21
|
+
{currentPage}
|
|
22
|
+
</span>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="ml-auto my-auto">
|
|
25
|
+
<slot />
|
|
26
|
+
</div>
|
|
22
27
|
</div>
|
|
@@ -6,24 +6,32 @@ export let id = void 0;
|
|
|
6
6
|
export let disabled = false;
|
|
7
7
|
export let customCss = "";
|
|
8
8
|
export let isLoading = false;
|
|
9
|
+
export let title = "";
|
|
9
10
|
</script>
|
|
10
11
|
|
|
11
12
|
<button
|
|
13
|
+
{title}
|
|
12
14
|
disabled={disabled || isLoading}
|
|
13
15
|
data-loading={isLoading ? 'true' : 'false'}
|
|
14
16
|
{id}
|
|
15
17
|
{type}
|
|
16
18
|
class=" rounded hover:brightness-95 focus:outline-none focus:ring active:ring
|
|
17
19
|
space-x-1
|
|
18
|
-
{buttonSize === 'sm' ? 'px-
|
|
19
|
-
{buttonSize === 'md' ? 'px-2 py-1.5' : ''}
|
|
20
|
-
{buttonSize === 'lg' ? 'font-bold px-
|
|
20
|
+
{buttonSize === 'sm' ? 'px-2 py-1 text-sm' : ''}
|
|
21
|
+
{buttonSize === 'md' ? 'px-2.5 py-1.5' : ''}
|
|
22
|
+
{buttonSize === 'lg' ? 'font-bold px-3 py-3' : ''}
|
|
21
23
|
{buttonStyle === 'blue' ? 'bg-blue-500 text-blue-50 ring-blue-500/20 ' : ''}
|
|
22
24
|
{buttonStyle === 'red' ? 'bg-red-500 text-red-50 ring-red-500/20' : ''}
|
|
23
25
|
{buttonStyle === 'dark' ? 'bg-slate-950 text-slate-50 ring-slate-800/20 ' : ''}
|
|
24
26
|
{buttonStyle === 'indigo' ? 'bg-indigo-500 text-indigo-50 ring-indigo-500/20' : ''}
|
|
25
27
|
{buttonStyle === 'teal' ? 'bg-teal-600 text-teal-50 ring-teal-600/20' : ''}
|
|
26
28
|
{buttonStyle === 'purple' ? 'bg-purple-600 text-purple-50 ring-purple-600/20' : ''}
|
|
29
|
+
{buttonStyle === 'orange' ? 'bg-orange-600 text-orange-50 ring-orange-600/20' : ''}
|
|
30
|
+
{buttonStyle === 'amber' ? 'bg-amber-600 text-amber-50 ring-amber-600/20' : ''}
|
|
31
|
+
{buttonStyle === 'cyan' ? 'bg-cyan-600 text-cyan-50 ring-cyan-600/20' : ''}
|
|
32
|
+
{buttonStyle === 'sky' ? 'bg-sky-600 text-sky-50 ring-sky-600/20' : ''}
|
|
33
|
+
{buttonStyle === 'white' ? 'bg-white text-slate-950 ring-white/20' : ''}
|
|
34
|
+
|
|
27
35
|
|
|
28
36
|
data-[loading='false']:disabled:bg-slate-100 data-[loading='false']:disabled:text-slate-300 disabled:ring-0
|
|
29
37
|
data-[loading='false']:disabled:brightness-100
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<script>export let code;
|
|
2
|
+
export let readonly = false;
|
|
3
|
+
export let formatCode = void 0;
|
|
4
|
+
export const buttonStyle = `px-3 py-1 text-sm bg-slate-500 hover:bg-slate-600
|
|
5
|
+
first-of-type:rounded-bl-md
|
|
6
|
+
text-slate-50 space-x-1 transition-all ease-in-out duration-150 w-32
|
|
7
|
+
border-r border-r-slate-600 last-of-type:border-r-0 last-of-type:rounded-br-md
|
|
8
|
+
flex items-center justify-center space-x-1
|
|
9
|
+
`;
|
|
10
|
+
export let minRows = 10;
|
|
11
|
+
let rows = 10;
|
|
12
|
+
$: {
|
|
13
|
+
rows = code.split("\n").length;
|
|
14
|
+
if (rows < minRows) {
|
|
15
|
+
rows = minRows;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function copyCode(event) {
|
|
19
|
+
let target = event.target;
|
|
20
|
+
if (code) {
|
|
21
|
+
navigator.clipboard.writeText(code);
|
|
22
|
+
let icon = target.querySelector("#cgen-icon-copy-primary");
|
|
23
|
+
let iconSecondary = target.querySelector("#cgen-icon-copy-secondary");
|
|
24
|
+
let span = target.querySelector("span");
|
|
25
|
+
if (icon !== void 0 && span !== void 0) {
|
|
26
|
+
span.innerHTML = "Copied";
|
|
27
|
+
icon.classList.remove("inline");
|
|
28
|
+
icon.classList.add("hidden");
|
|
29
|
+
iconSecondary.classList.remove("hidden");
|
|
30
|
+
iconSecondary.classList.add("inline");
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
span.innerHTML = "Copy";
|
|
33
|
+
icon.classList.remove("hidden");
|
|
34
|
+
icon.classList.add("inline");
|
|
35
|
+
iconSecondary.classList.remove("inline");
|
|
36
|
+
iconSecondary.classList.add("hidden");
|
|
37
|
+
}, 500);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function pasteCode(event) {
|
|
42
|
+
const clipboardData = await navigator.clipboard.readText();
|
|
43
|
+
code = clipboardData;
|
|
44
|
+
if (formatCode) {
|
|
45
|
+
formatCode();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<div>
|
|
51
|
+
<h3 class="text-slate-700 px-2 text-xl">
|
|
52
|
+
<span>
|
|
53
|
+
<slot name="title">Code Presenter</slot>
|
|
54
|
+
</span>
|
|
55
|
+
</h3>
|
|
56
|
+
|
|
57
|
+
<div class="relative">
|
|
58
|
+
<div class="absolute right-0 top-0 left-0 h-8 flex">
|
|
59
|
+
<div class="ml-auto flex">
|
|
60
|
+
<button type="button" class={buttonStyle} on:click={copyCode}>
|
|
61
|
+
<svg
|
|
62
|
+
id="cgen-icon-copy-primary"
|
|
63
|
+
class="w-5 h-5 pointer-events-none inline"
|
|
64
|
+
aria-hidden="true"
|
|
65
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
66
|
+
width="24"
|
|
67
|
+
height="24"
|
|
68
|
+
fill="none"
|
|
69
|
+
viewBox="0 0 24 24"
|
|
70
|
+
>
|
|
71
|
+
<path
|
|
72
|
+
stroke="currentColor"
|
|
73
|
+
stroke-linejoin="round"
|
|
74
|
+
stroke-width="2"
|
|
75
|
+
d="M9 8v3a1 1 0 0 1-1 1H5m11 4h2a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1h-7a1 1 0 0 0-1 1v1m4 3v10a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-7.13a1 1 0 0 1 .24-.65L7.7 8.35A1 1 0 0 1 8.46 8H13a1 1 0 0 1 1 1Z"
|
|
76
|
+
/>
|
|
77
|
+
</svg>
|
|
78
|
+
|
|
79
|
+
<svg
|
|
80
|
+
class="w-5 h-5 pointer-events-none hidden"
|
|
81
|
+
id="cgen-icon-copy-secondary"
|
|
82
|
+
aria-hidden="true"
|
|
83
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
84
|
+
width="24"
|
|
85
|
+
height="24"
|
|
86
|
+
fill="none"
|
|
87
|
+
viewBox="0 0 24 24"
|
|
88
|
+
>
|
|
89
|
+
<path
|
|
90
|
+
stroke="currentColor"
|
|
91
|
+
stroke-linecap="round"
|
|
92
|
+
stroke-linejoin="round"
|
|
93
|
+
stroke-width="2"
|
|
94
|
+
d="M5 11.917 9.724 16.5 19 7.5"
|
|
95
|
+
/>
|
|
96
|
+
</svg>
|
|
97
|
+
|
|
98
|
+
<span class="pointer-events-none"> Copy </span>
|
|
99
|
+
</button>
|
|
100
|
+
{#if !readonly}
|
|
101
|
+
<button type="button" class={buttonStyle} on:click={pasteCode}>
|
|
102
|
+
<svg
|
|
103
|
+
class="w-5 h-5 pointer-events-none inline-block"
|
|
104
|
+
aria-hidden="true"
|
|
105
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
106
|
+
width="24"
|
|
107
|
+
height="24"
|
|
108
|
+
fill="none"
|
|
109
|
+
viewBox="0 0 24 24"
|
|
110
|
+
>
|
|
111
|
+
<path
|
|
112
|
+
stroke="currentColor"
|
|
113
|
+
stroke-linecap="round"
|
|
114
|
+
stroke-linejoin="round"
|
|
115
|
+
stroke-width="2"
|
|
116
|
+
d="M15 4h3a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3m0 3h6m-5-4v4h4V3h-4Z"
|
|
117
|
+
/>
|
|
118
|
+
</svg>
|
|
119
|
+
|
|
120
|
+
<span> Paste </span>
|
|
121
|
+
</button>
|
|
122
|
+
{/if}
|
|
123
|
+
<slot name="buttons"></slot>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
<div class=" grid">
|
|
127
|
+
<textarea
|
|
128
|
+
bind:value={code}
|
|
129
|
+
{readonly}
|
|
130
|
+
{rows}
|
|
131
|
+
class=" p-2 py-4 md:px-4 pt-10 border border-slate-500 focus:ring focus:ring-blue-500/60 bg-stone-700 rounded-md text-yellow-100"
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
code: string;
|
|
5
|
+
readonly?: boolean;
|
|
6
|
+
formatCode?: (() => void) | undefined;
|
|
7
|
+
buttonStyle?: "px-3 py-1 text-sm bg-slate-500 hover:bg-slate-600\n first-of-type:rounded-bl-md \n text-slate-50 space-x-1 transition-all ease-in-out duration-150 w-32 \n border-r border-r-slate-600 last-of-type:border-r-0 last-of-type:rounded-br-md\n flex items-center justify-center space-x-1\n ";
|
|
8
|
+
minRows?: number;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {
|
|
14
|
+
title: {};
|
|
15
|
+
buttons: {};
|
|
16
|
+
};
|
|
17
|
+
exports?: {} | undefined;
|
|
18
|
+
bindings?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
export type CodePresenterProps = typeof __propDef.props;
|
|
21
|
+
export type CodePresenterEvents = typeof __propDef.events;
|
|
22
|
+
export type CodePresenterSlots = typeof __propDef.slots;
|
|
23
|
+
export default class CodePresenter extends SvelteComponent<CodePresenterProps, CodePresenterEvents, CodePresenterSlots> {
|
|
24
|
+
get buttonStyle(): "px-3 py-1 text-sm bg-slate-500 hover:bg-slate-600\n first-of-type:rounded-bl-md \n text-slate-50 space-x-1 transition-all ease-in-out duration-150 w-32 \n border-r border-r-slate-600 last-of-type:border-r-0 last-of-type:rounded-br-md\n flex items-center justify-center space-x-1\n ";
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -6,8 +6,8 @@ export let isBusy = false;
|
|
|
6
6
|
export let popupMenuItems = void 0;
|
|
7
7
|
export let hasAdvancedSearch = false;
|
|
8
8
|
export let searchHint = "Search";
|
|
9
|
+
export let isAdvancedSearchOpen = false;
|
|
9
10
|
let isMenuOpen = false;
|
|
10
|
-
let isAdvancedSearchOpen = false;
|
|
11
11
|
const dispatch = createEventDispatcher();
|
|
12
12
|
function handleSearchRequested(event) {
|
|
13
13
|
const target = event.target;
|
|
@@ -45,14 +45,14 @@ function closeAdvancedSearch() {
|
|
|
45
45
|
</h1>
|
|
46
46
|
<div class="ml-auto my-auto flex">
|
|
47
47
|
{#if showSearch}
|
|
48
|
-
<div class="relative
|
|
48
|
+
<div class="relative">
|
|
49
49
|
<input
|
|
50
50
|
disabled={!allowSearch || isBusy}
|
|
51
51
|
type="text"
|
|
52
52
|
class="border border-slate-300 rounded-md pl-2 pr-8 py-1.5
|
|
53
53
|
focus:border-indigo-500 focus:ring ring-indigo-500/30 focus:outline-none
|
|
54
54
|
md:min-w-[250px] lg:min-w-[300px]
|
|
55
|
-
rounded-r-none disabled:bg-slate-200 disabled:text-slate-400
|
|
55
|
+
rounded-r-none disabled:bg-slate-200 disabled:text-slate-400 h-full
|
|
56
56
|
"
|
|
57
57
|
placeholder={searchHint}
|
|
58
58
|
on:keyup={handleSearchRequested}
|
|
@@ -141,19 +141,18 @@ function closeAdvancedSearch() {
|
|
|
141
141
|
disabled={isBusy}
|
|
142
142
|
on:click={toggleAdvancedSearch}
|
|
143
143
|
type="button"
|
|
144
|
-
class="mx-1 w-
|
|
144
|
+
class="mx-1 w-9 h-9 bg-white border border-slate-300
|
|
145
145
|
text-slate-500
|
|
146
146
|
hover:bg-slate-100 rounded-full my-auto
|
|
147
147
|
disabled:bg-slate-100 disabled:text-slate-300
|
|
148
|
-
transition-all ease-in-out duration-150"
|
|
148
|
+
transition-all ease-in-out duration-150 flex"
|
|
149
149
|
>
|
|
150
150
|
<svg
|
|
151
151
|
xmlns="http://www.w3.org/2000/svg"
|
|
152
|
-
|
|
153
152
|
fill="currentColor"
|
|
154
|
-
class="w-
|
|
153
|
+
class="w-3 h-3 pointer-events-none inline-block {isAdvancedSearchOpen
|
|
155
154
|
? 'rotate-0'
|
|
156
|
-
: 'rotate-180'}
|
|
155
|
+
: 'rotate-180'} m-auto
|
|
157
156
|
transition-transform duration-150 ease-in-out"
|
|
158
157
|
viewBox="0 0 16 16"
|
|
159
158
|
>
|
|
@@ -171,9 +170,10 @@ function closeAdvancedSearch() {
|
|
|
171
170
|
<button
|
|
172
171
|
type="button"
|
|
173
172
|
class="px-3 py-1.5 text-blue-500 border border-blue-500 rounded
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
hover:bg-blue-50 active:bg-blue-500 active:text-blue-50 outline-blue-600 h-full
|
|
174
|
+
disabled:text-slate-300 disabled:bg-slate-100 disabled:border-slate-400 disabled:outline-none"
|
|
176
175
|
on:click={() => (isMenuOpen = true)}
|
|
176
|
+
disabled={isBusy}
|
|
177
177
|
>
|
|
178
178
|
<i class="bi bi-three-dots"></i>
|
|
179
179
|
</button>
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
<script>export let isHeader = false;
|
|
2
2
|
export let width = void 0;
|
|
3
|
+
export let breakpoint = void 0;
|
|
4
|
+
export let extendedCss = "";
|
|
5
|
+
export let colspan = 0;
|
|
3
6
|
</script>
|
|
4
7
|
|
|
5
8
|
{#if isHeader}
|
|
6
9
|
<th
|
|
7
|
-
class="px-2 py-1.5 border-r border-r-slate-300 last-of-type:border-r-0 text-left
|
|
10
|
+
class="px-2 py-1.5 border-r border-r-slate-300 last-of-type:border-r-0 text-left table-cell
|
|
11
|
+
{breakpoint === 'sm' ? 'sm:hidden' : ''}
|
|
12
|
+
{breakpoint === 'md' ? 'md:hidden' : ''}
|
|
13
|
+
{breakpoint === 'lg' ? 'lg:hidden' : ''} {extendedCss}
|
|
14
|
+
"
|
|
8
15
|
style={width === undefined ? '' : `width:${width}px`}
|
|
16
|
+
{colspan}
|
|
9
17
|
>
|
|
10
18
|
<slot />
|
|
11
19
|
</th>
|
|
12
20
|
{:else}
|
|
13
21
|
<td
|
|
14
|
-
class="px-2 py-1.5 border-r border-r-slate-300 last-of-type:border-r-0
|
|
22
|
+
class="px-2 py-1.5 border-r border-r-slate-300 last-of-type:border-r-0 table-cell
|
|
23
|
+
{breakpoint === 'sm' ? 'sm:hidden' : ''}
|
|
24
|
+
{breakpoint === 'md' ? 'md:hidden' : ''}
|
|
25
|
+
{breakpoint === 'lg' ? 'lg:hidden' : ''} {extendedCss}
|
|
26
|
+
"
|
|
15
27
|
style={width === undefined ? '' : `width:${width}px`}
|
|
28
|
+
{colspan}
|
|
16
29
|
>
|
|
17
30
|
<slot />
|
|
18
31
|
</td>
|
|
@@ -14,7 +14,7 @@ const menuButtonStyle = `space-x-1 px-2 text-slate-600 hover:bg-slate-500/20
|
|
|
14
14
|
disabled:text-slate-300 disabled:hover:bg-transparent
|
|
15
15
|
`;
|
|
16
16
|
export let menuWidth = 200;
|
|
17
|
-
function openMenu() {
|
|
17
|
+
function openMenu(event) {
|
|
18
18
|
menuOpen = true;
|
|
19
19
|
}
|
|
20
20
|
function closeMenu() {
|
|
@@ -43,13 +43,13 @@ onMount(() => {
|
|
|
43
43
|
<div class="relative">
|
|
44
44
|
<button
|
|
45
45
|
type="button"
|
|
46
|
-
class="px-3 py-1 rounded bg-emerald-500 text-emerald-50
|
|
46
|
+
class="px-3 py-1 rounded bg-emerald-500 text-emerald-50
|
|
47
47
|
disabled:bg-slate-100 disabled:text-slate-300"
|
|
48
48
|
disabled={isDisabled}
|
|
49
49
|
on:click={openMenu}
|
|
50
50
|
>
|
|
51
51
|
<svg
|
|
52
|
-
class="w-6 h-6 text-white"
|
|
52
|
+
class="w-6 h-6 text-white pointer-events-none"
|
|
53
53
|
aria-hidden="true"
|
|
54
54
|
xmlns="http://www.w3.org/2000/svg"
|
|
55
55
|
width="24"
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
<script>import { createEventDispatcher } from "svelte";
|
|
2
2
|
import LabeledFormInput from "./LabeledFormInput.svelte";
|
|
3
|
+
import LabeledSelect from "./LabeledSelect.svelte";
|
|
3
4
|
const dispatch = createEventDispatcher();
|
|
4
|
-
export let
|
|
5
|
+
export let recordsPerPageArray = [10, 25, 50, 100];
|
|
6
|
+
export let recordsPerPage = 10;
|
|
5
7
|
export let currentPage;
|
|
6
8
|
export let totalRecords;
|
|
7
9
|
let pagesCount = 0;
|
|
8
10
|
let _currentPage = 0;
|
|
9
11
|
$: {
|
|
10
|
-
pagesCount = totalRecords / recordsPerPage;
|
|
12
|
+
pagesCount = Math.ceil(totalRecords / recordsPerPage);
|
|
11
13
|
_currentPage = currentPage + 1;
|
|
12
14
|
}
|
|
13
15
|
function handlePageIndexChanged(factor) {
|
|
@@ -18,6 +20,15 @@ function handleCurrentPageChanged(event) {
|
|
|
18
20
|
currentPage = _currentPage - 1;
|
|
19
21
|
handlePageChanged();
|
|
20
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
|
+
}
|
|
21
32
|
function handlePageChanged() {
|
|
22
33
|
if (currentPage < 0) {
|
|
23
34
|
currentPage = 0;
|
|
@@ -25,18 +36,32 @@ function handlePageChanged() {
|
|
|
25
36
|
if (currentPage > pagesCount - 1) {
|
|
26
37
|
currentPage = pagesCount - 1;
|
|
27
38
|
}
|
|
28
|
-
dispatch("pagechanged",
|
|
39
|
+
dispatch("pagechanged", {
|
|
40
|
+
currentPage,
|
|
41
|
+
recordsPerPage
|
|
42
|
+
});
|
|
29
43
|
}
|
|
30
44
|
</script>
|
|
31
45
|
|
|
32
46
|
<div class="border border-slate-300 rounded flex p-2">
|
|
33
|
-
<div
|
|
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>
|
|
34
61
|
|
|
35
62
|
<div class="ml-auto flex space-x-3">
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</span>
|
|
39
|
-
<div class="w-14">
|
|
63
|
+
<span class="inline-block my-auto text-sm text-slate-500"> Page </span>
|
|
64
|
+
<div class="w-24">
|
|
40
65
|
<LabeledFormInput
|
|
41
66
|
numeric={true}
|
|
42
67
|
bind:value={_currentPage}
|
|
@@ -52,8 +77,8 @@ function handlePageChanged() {
|
|
|
52
77
|
on:click={() => handlePageIndexChanged(-1)}
|
|
53
78
|
type="button"
|
|
54
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
|
|
55
|
-
|
|
56
|
-
|
|
80
|
+
outline-none focus:outline-none
|
|
81
|
+
transition-all ease-in-out duration-300"
|
|
57
82
|
>
|
|
58
83
|
<svg
|
|
59
84
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -68,7 +93,6 @@ function handlePageChanged() {
|
|
|
68
93
|
/>
|
|
69
94
|
</svg>
|
|
70
95
|
</button>
|
|
71
|
-
|
|
72
96
|
<button
|
|
73
97
|
on:click={() => handlePageIndexChanged(1)}
|
|
74
98
|
type="button"
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script>import { formatDateTime } from "../date-utils.js";
|
|
2
|
+
export let date;
|
|
2
3
|
export let showTimeStamp = true;
|
|
4
|
+
export let timeStyle = "short";
|
|
5
|
+
export let dateStyle = "short";
|
|
3
6
|
let dateFormatted = "";
|
|
4
7
|
$: {
|
|
5
8
|
if (typeof date === "string") {
|
|
6
9
|
date = new Date(date);
|
|
7
10
|
}
|
|
8
|
-
|
|
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
|
-
}
|
|
11
|
+
dateFormatted = formatDateTime(date, showTimeStamp, timeStyle, dateStyle);
|
|
17
12
|
}
|
|
18
13
|
</script>
|
|
19
14
|
|
|
@@ -3,6 +3,8 @@ declare const __propDef: {
|
|
|
3
3
|
props: {
|
|
4
4
|
date: Date | string;
|
|
5
5
|
showTimeStamp?: boolean;
|
|
6
|
+
timeStyle?: "full" | "long" | "medium" | "short" | undefined;
|
|
7
|
+
dateStyle?: "full" | "long" | "medium" | "short" | undefined;
|
|
6
8
|
};
|
|
7
9
|
events: {
|
|
8
10
|
[evt: string]: CustomEvent<any>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
direction?: "horizontal" | "vertical";
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
exports?: {} | undefined;
|
|
11
|
+
bindings?: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
export type DividerProps = typeof __propDef.props;
|
|
14
|
+
export type DividerEvents = typeof __propDef.events;
|
|
15
|
+
export type DividerSlots = typeof __propDef.slots;
|
|
16
|
+
export default class Divider extends SvelteComponent<DividerProps, DividerEvents, DividerSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script>import { onMount } from "svelte";
|
|
2
|
+
export let theme = "teal";
|
|
3
|
+
export let direction = "ltr";
|
|
4
|
+
export let sliderWidth = 384;
|
|
5
|
+
let isTransitionning = false;
|
|
6
|
+
let isMenuOpen = false;
|
|
7
|
+
let menu;
|
|
8
|
+
function openMenu() {
|
|
9
|
+
isTransitionning = true;
|
|
10
|
+
isMenuOpen = true;
|
|
11
|
+
menu.style.width = `${sliderWidth}px`;
|
|
12
|
+
setTimeout(() => {
|
|
13
|
+
isTransitionning = false;
|
|
14
|
+
}, 301);
|
|
15
|
+
}
|
|
16
|
+
function closeMenu() {
|
|
17
|
+
isTransitionning = true;
|
|
18
|
+
menu.style.width = "0px";
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
isMenuOpen = false;
|
|
21
|
+
isTransitionning = false;
|
|
22
|
+
}, 301);
|
|
23
|
+
}
|
|
24
|
+
onMount(() => {
|
|
25
|
+
const buttons = menu.querySelectorAll('[data-close-menu="true"]');
|
|
26
|
+
for (const button of buttons) {
|
|
27
|
+
button.addEventListener("click", (event) => {
|
|
28
|
+
closeMenu();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<button
|
|
35
|
+
type="button"
|
|
36
|
+
on:click={openMenu}
|
|
37
|
+
class="text-2xl py-2 px-3 my-aut
|
|
38
|
+
bg-white rounded-md transition-all ease-in-out duration-300
|
|
39
|
+
{theme === 'blue' ? 'text-blue-500 hover:bg-blue-500 hover:text-blue-50 ' : ''}
|
|
40
|
+
{theme === 'red' ? 'text-red-500 hover:bg-red-500 hover:text-red-50' : ''}
|
|
41
|
+
{theme === 'dark' ? 'text-slate-950 hover:bg-slate-950 hover:text-slate-50' : ''}
|
|
42
|
+
{theme === 'indigo' ? 'text-indigo-500 hover:bg-indigo-500 hover:text-indigo-50 ' : ''}
|
|
43
|
+
{theme === 'teal' ? 'text-teal-600 hover:bg-teal-500 hover:text-teal-50 ' : ''}
|
|
44
|
+
{theme === 'purple' ? 'text-purple-600 hover:bg-purple-500 hover:text-purple-50 ' : ''}
|
|
45
|
+
{theme === 'orange' ? 'text-orange-600 hover:bg-orange-500 hover:text-orange-50 ' : ''}
|
|
46
|
+
{theme === 'amber' ? 'text-amber-600 hover:bg-amber-500 hover:text-amber-50 ' : ''}
|
|
47
|
+
{theme === 'cyan' ? 'text-cyan-600 hover:bg-cyan-500 hover:text-cyan-50 ' : ''}
|
|
48
|
+
{theme === 'sky' ? 'text-sky-600 hover:bg-sky-500 hover:text-sky-50 ' : ''}"
|
|
49
|
+
>
|
|
50
|
+
<svg
|
|
51
|
+
class="w-6 h-6"
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
54
|
+
width="24"
|
|
55
|
+
height="24"
|
|
56
|
+
fill="none"
|
|
57
|
+
viewBox="0 0 24 24"
|
|
58
|
+
>
|
|
59
|
+
<path
|
|
60
|
+
stroke="currentColor"
|
|
61
|
+
stroke-linecap="round"
|
|
62
|
+
stroke-width="2"
|
|
63
|
+
d="M5 7h14M5 12h14M5 17h14"
|
|
64
|
+
/>
|
|
65
|
+
</svg>
|
|
66
|
+
</button>
|
|
67
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
68
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
69
|
+
<div
|
|
70
|
+
class="fixed inset-0 bg-black/20 z-[1000] {isMenuOpen ? 'block' : 'hidden'}"
|
|
71
|
+
on:click={closeMenu}
|
|
72
|
+
/>
|
|
73
|
+
<div
|
|
74
|
+
bind:this={menu}
|
|
75
|
+
style="width: 0px;"
|
|
76
|
+
class="fixed
|
|
77
|
+
{direction === 'ltr' ? 'left-0 border-r border-r-neutral-400' : ''}
|
|
78
|
+
{direction === 'rtl' ? 'right-0 border-l border-l-neutral-400' : ''}
|
|
79
|
+
inset-y-0 bg-neutral-100
|
|
80
|
+
shadow-lg
|
|
81
|
+
{isMenuOpen ? 'visible z-[1001] ' : 'invisible'}
|
|
82
|
+
transition-all ease-in-out duration-300"
|
|
83
|
+
>
|
|
84
|
+
<div class="{isTransitionning || !isMenuOpen ? 'hidden' : 'block'} ">
|
|
85
|
+
<slot />
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|