y200subcontrols 0.0.34 → 0.0.37
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/CardHeader.svelte +1 -1
- package/dist/components/DataTable.svelte +6 -6
- package/dist/components/DataTable.svelte.d.ts +1 -0
- package/dist/components/DataTableCell.svelte +11 -2
- package/dist/components/DataTableCell.svelte.d.ts +1 -0
- package/dist/components/DataTableMenuButton.svelte +3 -3
- package/dist/components/DatePresenter.svelte +3 -10
- 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/HyperlinkButton.svelte +4 -4
- package/dist/components/HyperlinkButton.svelte.d.ts +1 -0
- package/dist/components/LabeledFormInput.svelte +4 -1
- package/dist/components/LabeledPasswordInput.svelte +1 -1
- package/dist/components/LabeledSelect.svelte +10 -2
- package/dist/components/LabeledSelect.svelte.d.ts +2 -0
- package/dist/components/Pill.svelte +20 -0
- package/dist/components/Pill.svelte.d.ts +22 -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/ToggleButton.svelte +7 -4
- package/dist/components/ToggleButton.svelte.d.ts +3 -0
- package/dist/components/types.d.ts +1 -1
- package/dist/date-utils.d.ts +1 -0
- package/dist/date-utils.js +18 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- 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,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}
|
|
@@ -149,7 +149,6 @@ function closeAdvancedSearch() {
|
|
|
149
149
|
>
|
|
150
150
|
<svg
|
|
151
151
|
xmlns="http://www.w3.org/2000/svg"
|
|
152
|
-
|
|
153
152
|
fill="currentColor"
|
|
154
153
|
class="w-3 h-3 pointer-events-none inline-block {isAdvancedSearchOpen
|
|
155
154
|
? 'rotate-0'
|
|
@@ -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,17 +1,26 @@
|
|
|
1
1
|
<script>export let isHeader = false;
|
|
2
2
|
export let width = void 0;
|
|
3
|
+
export let breakpoint = void 0;
|
|
3
4
|
</script>
|
|
4
5
|
|
|
5
6
|
{#if isHeader}
|
|
6
7
|
<th
|
|
7
|
-
class="px-2 py-1.5 border-r border-r-slate-300 last-of-type:border-r-0 text-left
|
|
8
|
+
class="px-2 py-1.5 border-r border-r-slate-300 last-of-type:border-r-0 text-left table-cell
|
|
9
|
+
{breakpoint === 'sm' ? 'sm:hidden' : ''}
|
|
10
|
+
{breakpoint === 'md' ? 'md:hidden' : ''}
|
|
11
|
+
{breakpoint === 'lg' ? 'lg:hidden' : ''}
|
|
12
|
+
"
|
|
8
13
|
style={width === undefined ? '' : `width:${width}px`}
|
|
9
14
|
>
|
|
10
15
|
<slot />
|
|
11
16
|
</th>
|
|
12
17
|
{:else}
|
|
13
18
|
<td
|
|
14
|
-
class="px-2 py-1.5 border-r border-r-slate-300 last-of-type:border-r-0
|
|
19
|
+
class="px-2 py-1.5 border-r border-r-slate-300 last-of-type:border-r-0 table-cell
|
|
20
|
+
{breakpoint === 'sm' ? 'sm:hidden' : ''}
|
|
21
|
+
{breakpoint === 'md' ? 'md:hidden' : ''}
|
|
22
|
+
{breakpoint === 'lg' ? 'lg:hidden' : ''}
|
|
23
|
+
"
|
|
15
24
|
style={width === undefined ? '' : `width:${width}px`}
|
|
16
25
|
>
|
|
17
26
|
<slot />
|
|
@@ -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,19 +1,12 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script>import { formatDateTime } from "../date-utils.js";
|
|
2
|
+
export let date;
|
|
2
3
|
export let showTimeStamp = true;
|
|
3
4
|
let dateFormatted = "";
|
|
4
5
|
$: {
|
|
5
6
|
if (typeof date === "string") {
|
|
6
7
|
date = new Date(date);
|
|
7
8
|
}
|
|
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
|
-
}
|
|
9
|
+
dateFormatted = formatDateTime(date, showTimeStamp);
|
|
17
10
|
}
|
|
18
11
|
</script>
|
|
19
12
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script>import { onMount } from "svelte";
|
|
2
|
+
import Button from "./Button.svelte";
|
|
3
|
+
export let buttonStyle = "teal";
|
|
4
|
+
export let buttonSize = "md";
|
|
5
|
+
export let id = void 0;
|
|
6
|
+
export let disabled = false;
|
|
7
|
+
let isMenuOpen = false;
|
|
8
|
+
let menuItemContainer;
|
|
9
|
+
export const dataPrefix = 'data-menu-item="true"';
|
|
10
|
+
const menuButtonStyle = `space-x-1 px-2 text-slate-600 hover:bg-slate-500/20
|
|
11
|
+
block w-full py-1 text-left active:text-slate-50 active:bg-slate-500
|
|
12
|
+
transition-all ease-in-out duration-300 focus:outline-none outline-none
|
|
13
|
+
disabled:text-slate-300 disabled:hover:bg-transparent
|
|
14
|
+
`;
|
|
15
|
+
function openMenu() {
|
|
16
|
+
isMenuOpen = true;
|
|
17
|
+
}
|
|
18
|
+
function closeMenu() {
|
|
19
|
+
isMenuOpen = false;
|
|
20
|
+
}
|
|
21
|
+
onMount(() => {
|
|
22
|
+
const buttons = menuItemContainer.querySelectorAll('[data-menu-item="true"]');
|
|
23
|
+
for (const button of buttons) {
|
|
24
|
+
button.addEventListener("click", () => closeMenu());
|
|
25
|
+
if (button.className === "") {
|
|
26
|
+
button.className = menuButtonStyle;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<div class="relative grid">
|
|
33
|
+
<Button type="button" {disabled} {buttonStyle} {id} {buttonSize} on:click={openMenu}>
|
|
34
|
+
<div class="w-full flex">
|
|
35
|
+
<div class="flex-grow">
|
|
36
|
+
<slot />
|
|
37
|
+
</div>
|
|
38
|
+
<div class="w-5 flex-shrink-0 ml-auto my-auto">
|
|
39
|
+
<svg
|
|
40
|
+
class="w-5 h-5 block rotate-0 {isMenuOpen ? 'rotate-180' :''} transition-all duration-300"
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
43
|
+
width="24"
|
|
44
|
+
height="24"
|
|
45
|
+
fill="none"
|
|
46
|
+
viewBox="0 0 24 24"
|
|
47
|
+
>
|
|
48
|
+
<path
|
|
49
|
+
stroke="currentColor"
|
|
50
|
+
stroke-linecap="round"
|
|
51
|
+
stroke-linejoin="round"
|
|
52
|
+
stroke-width="2"
|
|
53
|
+
d="m19 9-7 7-7-7"
|
|
54
|
+
/>
|
|
55
|
+
</svg>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</Button>
|
|
59
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
60
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
61
|
+
<div
|
|
62
|
+
class="fixed {isMenuOpen ? 'block' : 'hidden'} inset-0 bg-black/10 z-[1000]"
|
|
63
|
+
on:click={closeMenu}
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
<div
|
|
67
|
+
class="absolute right-0 left-0 top-[100%]
|
|
68
|
+
bg-white border border-slate-300 shadow-md rounded z-[1001]
|
|
69
|
+
transition-all ease-linear duration-300
|
|
70
|
+
grid
|
|
71
|
+
"
|
|
72
|
+
style="visibility: {isMenuOpen ? 'visible' : 'hidden'};grid-template-rows:{isMenuOpen
|
|
73
|
+
? '1fr'
|
|
74
|
+
: '0fr'}; top:calc(100% + 5px)"
|
|
75
|
+
>
|
|
76
|
+
<div class="overflow-hidden">
|
|
77
|
+
<ul class="py-2" bind:this={menuItemContainer}>
|
|
78
|
+
<slot name="buttons" />
|
|
79
|
+
</ul>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ColorThemes, Size } from './types.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
buttonStyle?: ColorThemes;
|
|
6
|
+
buttonSize?: Size;
|
|
7
|
+
id?: string | undefined;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
dataPrefix?: "data-menu-item=\"true\"";
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {
|
|
15
|
+
default: {};
|
|
16
|
+
buttons: {};
|
|
17
|
+
};
|
|
18
|
+
exports?: {} | undefined;
|
|
19
|
+
bindings?: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
export type DropDownButtonProps = typeof __propDef.props;
|
|
22
|
+
export type DropDownButtonEvents = typeof __propDef.events;
|
|
23
|
+
export type DropDownButtonSlots = typeof __propDef.slots;
|
|
24
|
+
export default class DropDownButton extends SvelteComponent<DropDownButtonProps, DropDownButtonEvents, DropDownButtonSlots> {
|
|
25
|
+
get dataPrefix(): "data-menu-item=\"true\"";
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -10,6 +10,8 @@ export let isCard = true;
|
|
|
10
10
|
export let id = void 0;
|
|
11
11
|
export let buttonSize = "md";
|
|
12
12
|
export let method = "post";
|
|
13
|
+
export let showSubmit = true;
|
|
14
|
+
export let paddingVertical = "lg";
|
|
13
15
|
let dispatch = createEventDispatcher();
|
|
14
16
|
function handleSubmit(event) {
|
|
15
17
|
event.preventDefault();
|
|
@@ -26,6 +28,9 @@ function handleSubmit(event) {
|
|
|
26
28
|
const formData = new FormData(form);
|
|
27
29
|
dispatch("submit", formData);
|
|
28
30
|
}
|
|
31
|
+
export function submit() {
|
|
32
|
+
form.submit();
|
|
33
|
+
}
|
|
29
34
|
</script>
|
|
30
35
|
|
|
31
36
|
<Card stylingDisabled={!isCard} {extendedCss}>
|
|
@@ -42,11 +47,17 @@ function handleSubmit(event) {
|
|
|
42
47
|
on:submit={handleSubmit}
|
|
43
48
|
{method}
|
|
44
49
|
>
|
|
45
|
-
<div
|
|
50
|
+
<div
|
|
51
|
+
class="{paddingVertical === 'sm' ? 'py-1' : ''}
|
|
52
|
+
{paddingVertical === 'md' ? 'py-2' : ''}
|
|
53
|
+
{paddingVertical === 'lg' ? 'py-4' : ''}
|
|
54
|
+
|
|
55
|
+
"
|
|
56
|
+
>
|
|
46
57
|
<slot />
|
|
47
58
|
</div>
|
|
48
59
|
<slot name="buttons">
|
|
49
|
-
<div class="my-2 grid">
|
|
60
|
+
<div class="my-2 grid {showSubmit ? '' : 'hidden'}">
|
|
50
61
|
<Button type="submit" {isLoading} {buttonSize}>
|
|
51
62
|
<span>{@html defaultButtonContent}</span>
|
|
52
63
|
</Button>
|
|
@@ -10,6 +10,9 @@ declare const __propDef: {
|
|
|
10
10
|
id?: string | undefined;
|
|
11
11
|
buttonSize?: Size;
|
|
12
12
|
method?: "get" | "post" | "dialog";
|
|
13
|
+
showSubmit?: boolean;
|
|
14
|
+
paddingVertical?: Size;
|
|
15
|
+
submit?: () => void;
|
|
13
16
|
};
|
|
14
17
|
events: {
|
|
15
18
|
click: MouseEvent;
|
|
@@ -33,5 +36,6 @@ export type FormProps = typeof __propDef.props;
|
|
|
33
36
|
export type FormEvents = typeof __propDef.events;
|
|
34
37
|
export type FormSlots = typeof __propDef.slots;
|
|
35
38
|
export default class Form extends SvelteComponent<FormProps, FormEvents, FormSlots> {
|
|
39
|
+
get submit(): () => void;
|
|
36
40
|
}
|
|
37
41
|
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script>import { expoIn } from "svelte/easing";
|
|
2
|
+
export let linkStyle = "teal";
|
|
2
3
|
export let disabled = false;
|
|
3
4
|
export let id = void 0;
|
|
5
|
+
export let type = "button";
|
|
4
6
|
export let customCss = "";
|
|
5
7
|
</script>
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
9
|
<button
|
|
10
|
+
{type}
|
|
10
11
|
on:click
|
|
11
|
-
type="button"
|
|
12
12
|
{disabled}
|
|
13
13
|
class="px-1 py-1 {customCss} text-slate-600 dark:text-slate-200
|
|
14
14
|
{id}
|
|
@@ -26,9 +26,11 @@ let inputCss = `
|
|
|
26
26
|
focus:outline-none focus:ring
|
|
27
27
|
read-only:bg-neutral-100
|
|
28
28
|
dark:read-only:bg-neutral-800
|
|
29
|
+
disabled:text-slate-500
|
|
29
30
|
placeholder:text-sm placeholder:font-thin
|
|
30
31
|
dark:bg-slate-900 dark:text-neutral-100 {numeric ? 'hide-browser-appearance' : ''}
|
|
31
32
|
${!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"}
|
|
33
|
+
disabled:text-slate-400
|
|
32
34
|
${customCss}`;
|
|
33
35
|
let inputContainer;
|
|
34
36
|
function validateElement(event) {
|
|
@@ -94,7 +96,7 @@ onMount(() => {
|
|
|
94
96
|
type="text"
|
|
95
97
|
{required}
|
|
96
98
|
{autocomplete}
|
|
97
|
-
class="border peer block w-full rounded shadow-sm bg-white text-neutral-900
|
|
99
|
+
class="border peer block w-full rounded shadow-sm bg-white text-neutral-900
|
|
98
100
|
{size === 'sm' ? 'py-1 px-2 text-sm' : ''}
|
|
99
101
|
{size === 'md' ? 'py-1.5 px-2 text-base' : ''}
|
|
100
102
|
{size === 'lg' ? 'py-2 px-2 text-lg' : ''}
|
|
@@ -106,6 +108,7 @@ onMount(() => {
|
|
|
106
108
|
{!isValid
|
|
107
109
|
? 'border-pink-600 dark:border-pink-500 focus:ring-pink-600/20 dark:focus:ring-pink-600/40'
|
|
108
110
|
: 'dark:border-slate-600 border-slate-300 focus:ring-teal-500/20 dark:focus:ring-teal-500/30'}
|
|
111
|
+
disabled:text-slate-400
|
|
109
112
|
{customCss}"
|
|
110
113
|
bind:value
|
|
111
114
|
{placeholder}
|
|
@@ -62,7 +62,7 @@ onMount(() => {
|
|
|
62
62
|
{!isValid
|
|
63
63
|
? 'border-pink-600 dark:border-pink-500 focus:ring-pink-600/20 dark:focus:ring-pink-600/40'
|
|
64
64
|
: 'dark:border-slate-600 border-slate-300 focus:ring-teal-500/20 dark:focus:ring-teal-500/30'}
|
|
65
|
-
{customCss} pr-
|
|
65
|
+
{customCss} pr-8"
|
|
66
66
|
{placeholder}
|
|
67
67
|
{id}
|
|
68
68
|
{name}
|
|
@@ -7,6 +7,7 @@ export let name = void 0;
|
|
|
7
7
|
export let placeholder = void 0;
|
|
8
8
|
export let validationText = void 0;
|
|
9
9
|
export let theme = "teal";
|
|
10
|
+
export let size = "lg";
|
|
10
11
|
export let input = void 0;
|
|
11
12
|
export let visible = true;
|
|
12
13
|
export let disabled = false;
|
|
@@ -70,23 +71,30 @@ onMount(() => {
|
|
|
70
71
|
{placeholder}
|
|
71
72
|
{name}
|
|
72
73
|
on:change
|
|
73
|
-
class="border peer block w-full
|
|
74
|
+
class="border peer block w-full rounded-md shadow-sm bg-white text-neutral-900
|
|
75
|
+
|
|
74
76
|
focus:outline-none focus:ring
|
|
75
77
|
placeholder:text-sm placeholder:font-thin
|
|
76
78
|
dark:bg-slate-900 dark:text-neutral-100 appearance-none
|
|
77
|
-
|
|
79
|
+
{size === 'sm' ? 'py-1 px-2 text-sm' : ''}
|
|
80
|
+
{size === 'md' ? 'py-1.5 px-2 text-base' : ''}
|
|
81
|
+
{size === 'lg' ? 'py-2 px-2 text-lg' : ''}
|
|
82
|
+
pr-10
|
|
78
83
|
{!isValid
|
|
79
84
|
? 'border-pink-600 dark:border-pink-500 focus:ring-pink-600/20 dark:focus:ring-pink-600/40'
|
|
80
85
|
: 'dark:border-slate-600 border-slate-300'}
|
|
81
86
|
{isValid && theme === 'teal' ? ' focus:ring-teal-600/20 dark:focus:ring-teal-600/30' : ''}
|
|
87
|
+
disabled:bg-neutral-100 disabled:text-slate-500 dark:disabled:bg-neutral-800
|
|
82
88
|
"
|
|
83
89
|
>
|
|
90
|
+
|
|
84
91
|
<slot />
|
|
85
92
|
</select>
|
|
86
93
|
<span
|
|
87
94
|
class="absolute right-0 inset-y-0 w-8 flex text-slate-500 pointer-events-none
|
|
88
95
|
{theme === 'teal' ? 'peer-hover:text-teal-600 peer-focus:text-teal-600' : ''}
|
|
89
96
|
{theme === 'blue' ? 'peer-hover:text-blue-500 peer-focus:text-blue-500' : ''}
|
|
97
|
+
peer-disabled:text-slate-500
|
|
90
98
|
"
|
|
91
99
|
>
|
|
92
100
|
<svg
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
import type { ColorThemes } from './types.js';
|
|
3
|
+
import type { Size } from './types.js';
|
|
3
4
|
declare const __propDef: {
|
|
4
5
|
props: {
|
|
5
6
|
labelText?: string | undefined;
|
|
@@ -10,6 +11,7 @@ declare const __propDef: {
|
|
|
10
11
|
placeholder?: string | undefined;
|
|
11
12
|
validationText?: string | undefined;
|
|
12
13
|
theme?: ColorThemes;
|
|
14
|
+
size?: Size;
|
|
13
15
|
input?: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | any | undefined;
|
|
14
16
|
visible?: boolean;
|
|
15
17
|
disabled?: boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script>export let theme = "teal";
|
|
2
|
+
export let size = "md";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<span
|
|
6
|
+
class="inline-block text-center
|
|
7
|
+
{size === 'sm' ? 'text-sm rounded-3xl px-3 py-1.5' : ''}
|
|
8
|
+
{size === 'md' ? 'text-base rounded-3xl px-4 py-2' : ''}
|
|
9
|
+
{size === 'lg' ? 'text-lg rounded-3xl px-6 py-3' : ''}
|
|
10
|
+
{theme === 'teal' ? 'bg-teal-500 text-teal-50' : ''}
|
|
11
|
+
{theme === 'slate' ? 'bg-slate-400 text-slate-50' : ''}
|
|
12
|
+
{theme === 'blue' ? 'bg-blue-600 text-blue-50' : ''}
|
|
13
|
+
{theme === 'indigo' ? 'bg-indigo-600 text-indigo-50' : ''}
|
|
14
|
+
{theme === 'red' ? 'bg-red-600 text-red-50' : ''}
|
|
15
|
+
{theme === 'dark' ? 'bg-slate-950 text-slate-50' : ''}
|
|
16
|
+
{theme === 'purple' ? 'bg-purple-950 text-purple-50' : ''}
|
|
17
|
+
"
|
|
18
|
+
>
|
|
19
|
+
<slot />
|
|
20
|
+
</span>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ColorThemes, Size } from './types.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
theme?: ColorThemes;
|
|
6
|
+
size?: Size;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {
|
|
12
|
+
default: {};
|
|
13
|
+
};
|
|
14
|
+
exports?: {} | undefined;
|
|
15
|
+
bindings?: string | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type PillProps = typeof __propDef.props;
|
|
18
|
+
export type PillEvents = typeof __propDef.events;
|
|
19
|
+
export type PillSlots = typeof __propDef.slots;
|
|
20
|
+
export default class Pill extends SvelteComponent<PillProps, PillEvents, PillSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -16,7 +16,8 @@ function handleValueChanged(newValue) {
|
|
|
16
16
|
|
|
17
17
|
<div>
|
|
18
18
|
{#if labelText}
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
<span class="inline-block mb-1 text-slate-600 dark:text-neutral-200 font-thin text-lg">
|
|
20
21
|
{labelText}
|
|
21
22
|
</span>
|
|
22
23
|
{/if}
|
|
@@ -30,7 +31,14 @@ function handleValueChanged(newValue) {
|
|
|
30
31
|
data-selected={option.key === value ? 'true' : ''}
|
|
31
32
|
on:click={() => handleValueChanged(option.key)}
|
|
32
33
|
class="first:rounded-l-lg last-of-type:rounded-r-lg
|
|
33
|
-
border px-2 py-1 transition-all ease-in-out duration-150 enabled:active:ring
|
|
34
|
+
border px-2 py-1 transition-all ease-in-out duration-150 enabled:active:ring bg-white
|
|
35
|
+
{theme === 'teal'
|
|
36
|
+
? `border-teal-500 text-teal-500 dark:text-teal-100
|
|
37
|
+
enabled:hover:bg-teal-100 enabled:active:bg-teal-500 enabled:active:text-teal-50 ring-teal-500/40
|
|
38
|
+
data-[selected='true']:bg-teal-500 data-[selected='true']:text-teal-50
|
|
39
|
+
hover:data-[selected='true']:bg-teal-500 hover:data-[selected='true']:text-teal-50
|
|
40
|
+
enabled:dark:hover:bg-teal-100/20 enabled:dark:hover:data-[selected='true']:bg-teal-500`
|
|
41
|
+
: ''}
|
|
34
42
|
{theme === 'red'
|
|
35
43
|
? `border-red-500 text-red-500 dark:text-red-100
|
|
36
44
|
enabled:hover:bg-red-100 enabled:active:bg-red-500 enabled:active:text-red-50 ring-red-500/40
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script>import { onMount } from "svelte";
|
|
2
|
+
let tabsHolder;
|
|
3
|
+
let pagesHolder;
|
|
4
|
+
export let currentIndex = 0;
|
|
5
|
+
export let theme = "teal";
|
|
6
|
+
let tabHeaders = [];
|
|
7
|
+
function setIndex(index) {
|
|
8
|
+
currentIndex = index;
|
|
9
|
+
let tabPages = pagesHolder.querySelectorAll('[data-tab-page="true"]');
|
|
10
|
+
for (const tabPage of tabPages) {
|
|
11
|
+
let elem = tabPage;
|
|
12
|
+
const index2 = Number(elem.dataset.index);
|
|
13
|
+
if (index2 === currentIndex) {
|
|
14
|
+
elem.classList.remove("hidden");
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
elem.classList.add("opacity-100");
|
|
17
|
+
}, 5);
|
|
18
|
+
} else {
|
|
19
|
+
elem.classList.add("hidden");
|
|
20
|
+
elem.classList.remove("opacity-100");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
onMount(() => {
|
|
25
|
+
const headers = tabsHolder.querySelectorAll('[data-tab-header="true"]');
|
|
26
|
+
const pages = tabsHolder.querySelectorAll('[data-tab-page="true"]');
|
|
27
|
+
for (const header of headers) {
|
|
28
|
+
let elem = header;
|
|
29
|
+
const html = elem.innerHTML;
|
|
30
|
+
const index = Number(elem.dataset.index);
|
|
31
|
+
tabHeaders.push({
|
|
32
|
+
key: index,
|
|
33
|
+
value: html
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
tabHeaders = [...tabHeaders];
|
|
37
|
+
setIndex(currentIndex);
|
|
38
|
+
});
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<div bind:this={tabsHolder}>
|
|
42
|
+
<div class="border-b border-b-slate-300">
|
|
43
|
+
<ul class="flex flex-wrap -mb-px space-x-1">
|
|
44
|
+
{#each tabHeaders as tabHeader (tabHeader.key)}
|
|
45
|
+
<!-- svelte-ignore a11y-role-supports-aria-props -->
|
|
46
|
+
<button
|
|
47
|
+
on:click={() => setIndex(tabHeader.key)}
|
|
48
|
+
aria-checked={tabHeader.key === currentIndex ? 'true' : 'false'}
|
|
49
|
+
type="button"
|
|
50
|
+
class="p-3 md:px-4 lg:px-6 transition-all ease-in-out duration-150
|
|
51
|
+
text-slate-500 hover:text-slate-700
|
|
52
|
+
border-b-2 border-b-transparent hover:border-b-slate-400
|
|
53
|
+
{theme === 'teal'
|
|
54
|
+
? 'aria-checked:text-teal-500 aria-checked:border-b-teal-500'
|
|
55
|
+
: ''}
|
|
56
|
+
{theme === 'blue'
|
|
57
|
+
? 'aria-checked:text-blue-500 aria-checked:border-b-blue-500'
|
|
58
|
+
: ''}
|
|
59
|
+
{theme === 'purple'
|
|
60
|
+
? 'aria-checked:text-purple-500 aria-checked:border-b-purple-500'
|
|
61
|
+
: ''}
|
|
62
|
+
{theme === 'indigo'
|
|
63
|
+
? 'aria-checked:text-indigo-500 aria-checked:border-b-indigo-500'
|
|
64
|
+
: ''}
|
|
65
|
+
{theme === 'red'
|
|
66
|
+
? 'aria-checked:text-red-500 aria-checked:border-b-red-500'
|
|
67
|
+
: ''}
|
|
68
|
+
|
|
69
|
+
"
|
|
70
|
+
>
|
|
71
|
+
{@html tabHeader.value}
|
|
72
|
+
</button>
|
|
73
|
+
{/each}
|
|
74
|
+
</ul>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="my-2" bind:this={pagesHolder}>
|
|
77
|
+
<slot />
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ColorThemes } from './types.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
currentIndex?: number;
|
|
6
|
+
theme?: ColorThemes;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {
|
|
12
|
+
default: {};
|
|
13
|
+
};
|
|
14
|
+
exports?: {} | undefined;
|
|
15
|
+
bindings?: string | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type TabControlProps = typeof __propDef.props;
|
|
18
|
+
export type TabControlEvents = typeof __propDef.events;
|
|
19
|
+
export type TabControlSlots = typeof __propDef.slots;
|
|
20
|
+
export default class TabControl extends SvelteComponent<TabControlProps, TabControlEvents, TabControlSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script>export let index;
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<div data-tab-page data-index={index}>
|
|
5
|
+
<div data-tab-header="true" class="hidden" data-index={index}>
|
|
6
|
+
<slot name="header" />
|
|
7
|
+
</div>
|
|
8
|
+
<div data-tab-page="true" data-index={index} class="transition-all ease-in-out duration-500 opacity-0">
|
|
9
|
+
<slot />
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
index: number;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {
|
|
10
|
+
header: {};
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
exports?: {} | undefined;
|
|
14
|
+
bindings?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
export type TabItemProps = typeof __propDef.props;
|
|
17
|
+
export type TabItemEvents = typeof __propDef.events;
|
|
18
|
+
export type TabItemSlots = typeof __propDef.slots;
|
|
19
|
+
export default class TabItem extends SvelteComponent<TabItemProps, TabItemEvents, TabItemSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -3,15 +3,17 @@ export let label = "";
|
|
|
3
3
|
export let id = void 0;
|
|
4
4
|
export let name = void 0;
|
|
5
5
|
export let theme = "teal";
|
|
6
|
+
export let disabled = false;
|
|
6
7
|
</script>
|
|
7
8
|
|
|
8
9
|
<label class="flex cursor-pointer">
|
|
9
|
-
<input type="checkbox" bind:checked class="hidden peer" {id} {name} />
|
|
10
|
+
<input type="checkbox" bind:checked class="hidden peer" {id} {name} on:change {disabled} />
|
|
10
11
|
<div
|
|
11
12
|
class=" rounded-full h-5 w-10 flex my-auto bg-slate-300
|
|
12
|
-
{theme==='teal' ? 'peer-checked:bg-teal-600' : ''}
|
|
13
|
-
{theme==='indigo' ? 'peer-checked:bg-indigo-600' : ''}
|
|
14
|
-
{theme==='blue' ? 'peer-blue:bg-indigo-600' : ''}
|
|
13
|
+
{theme === 'teal' ? 'peer-checked:bg-teal-600' : ''}
|
|
14
|
+
{theme === 'indigo' ? 'peer-checked:bg-indigo-600' : ''}
|
|
15
|
+
{theme === 'blue' ? 'peer-blue:bg-indigo-600' : ''}
|
|
16
|
+
peer-disabled:bg-slate-100
|
|
15
17
|
|
|
16
18
|
transition-all duration-300"
|
|
17
19
|
>
|
|
@@ -19,6 +21,7 @@ export let theme = "teal";
|
|
|
19
21
|
class="w-5 h-5 rounded-full my-auto border border-slate-400 {!checked
|
|
20
22
|
? 'bg-slate-400 translate-x-0'
|
|
21
23
|
: ' translate-x-5 bg-slate-100 '} transition-all ease-in-out duration-300
|
|
24
|
+
|
|
22
25
|
"
|
|
23
26
|
/>
|
|
24
27
|
</div>
|
|
@@ -3,7 +3,7 @@ export type ColorThemes = 'red' | 'dark' | 'indigo' | 'teal' | 'blue' | 'purple'
|
|
|
3
3
|
export type PopupMenuItem = {
|
|
4
4
|
id: number;
|
|
5
5
|
content: string;
|
|
6
|
-
action: (param?: any | undefined) => {};
|
|
6
|
+
action: (param?: any | undefined) => {} | void;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
};
|
|
9
9
|
export type KeyValue<TKey, T> = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatDateTime(dateTime: Date | undefined | string, showTimeStamp?: boolean, timeStyle?: "full" | "long" | "medium" | "short" | undefined, dateStyle?: "full" | "long" | "medium" | "short" | undefined): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function formatDateTime(dateTime, showTimeStamp = false, timeStyle = 'short', dateStyle = 'short') {
|
|
2
|
+
if (!dateTime) {
|
|
3
|
+
return 'N/A';
|
|
4
|
+
}
|
|
5
|
+
if (typeof dateTime === 'string') {
|
|
6
|
+
dateTime = new Date(dateTime);
|
|
7
|
+
}
|
|
8
|
+
timeStyle ??= 'short';
|
|
9
|
+
let dateFormatted = 'N/A';
|
|
10
|
+
if (dateTime) {
|
|
11
|
+
const formatter = new Intl.DateTimeFormat(undefined, {
|
|
12
|
+
dateStyle: dateStyle,
|
|
13
|
+
timeStyle: showTimeStamp ? timeStyle : undefined
|
|
14
|
+
});
|
|
15
|
+
dateFormatted = formatter.format(dateTime);
|
|
16
|
+
}
|
|
17
|
+
return dateFormatted;
|
|
18
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -24,4 +24,9 @@ import HyperlinkButton from "./components/HyperlinkButton.svelte";
|
|
|
24
24
|
import SideNav from "./components/SideNav.svelte";
|
|
25
25
|
import SideNavItem from "./components/SideNavItem.svelte";
|
|
26
26
|
import DataTablePaginator from "./components/DataTablePaginator.svelte";
|
|
27
|
-
|
|
27
|
+
import TabControl from "./components/TabControl.svelte";
|
|
28
|
+
import TabItem from "./components/TabItem.svelte";
|
|
29
|
+
import Pill from "./components/Pill.svelte";
|
|
30
|
+
import DropDownButton from "./components/DropDownButton.svelte";
|
|
31
|
+
import { formatDateTime } from "./date-utils.js";
|
|
32
|
+
export { Button, LoadingIndicator, Card, CardHeader, Form, ToggleButton, LabeledFormInput, LabeledPasswordInput, Alert, HyperLink, LabeledSelect, ModalDialog, BooleanPresenter, DataTable, DataTableCell, DataTableRow, DataTableMenuButton, DatePresenter, LabeledDatePicker, LabeledTextArea, Breadcrumb, SegmentedControl, HyperlinkButton, SideNav, SideNavItem, DataTablePaginator, TabControl, TabItem, Pill, DropDownButton, formatDateTime };
|
package/dist/index.js
CHANGED
|
@@ -25,4 +25,9 @@ import HyperlinkButton from "./components/HyperlinkButton.svelte";
|
|
|
25
25
|
import SideNav from "./components/SideNav.svelte";
|
|
26
26
|
import SideNavItem from "./components/SideNavItem.svelte";
|
|
27
27
|
import DataTablePaginator from "./components/DataTablePaginator.svelte";
|
|
28
|
-
|
|
28
|
+
import TabControl from "./components/TabControl.svelte";
|
|
29
|
+
import TabItem from "./components/TabItem.svelte";
|
|
30
|
+
import Pill from "./components/Pill.svelte";
|
|
31
|
+
import DropDownButton from "./components/DropDownButton.svelte";
|
|
32
|
+
import { formatDateTime } from "./date-utils.js";
|
|
33
|
+
export { Button, LoadingIndicator, Card, CardHeader, Form, ToggleButton, LabeledFormInput, LabeledPasswordInput, Alert, HyperLink, LabeledSelect, ModalDialog, BooleanPresenter, DataTable, DataTableCell, DataTableRow, DataTableMenuButton, DatePresenter, LabeledDatePicker, LabeledTextArea, Breadcrumb, SegmentedControl, HyperlinkButton, SideNav, SideNavItem, DataTablePaginator, TabControl, TabItem, Pill, DropDownButton, formatDateTime };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "y200subcontrols",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite dev",
|
|
6
6
|
"build": "vite build && npm run package",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"type": "module",
|
|
55
55
|
"license": "MIT",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"bootstrap-icons": "^1.11.3"
|
|
57
|
+
"bootstrap-icons": "^1.11.3",
|
|
58
|
+
"y200subcontrols": "^0.0.355"
|
|
58
59
|
}
|
|
59
60
|
}
|