y200subcontrols 0.0.393 → 0.0.395
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/CodePresenter.svelte +147 -0
- package/dist/components/CodePresenter.svelte.d.ts +25 -0
- package/dist/components/LabeledDatePicker.svelte +2 -0
- package/dist/components/LabeledDatePicker.svelte.d.ts +2 -0
- package/dist/components/LoadingIndicator.svelte +1 -1
- package/dist/date-utils.d.ts +4 -0
- package/dist/date-utils.js +11 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,147 @@
|
|
|
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
|
+
<!-- {:else} -->
|
|
123
|
+
<!-- <button
|
|
124
|
+
disabled={isBusy}
|
|
125
|
+
type="button"
|
|
126
|
+
class="px-3 py-1 text-sm bg-slate-500 hover:bg-slate-600 rounded-tr-md
|
|
127
|
+
disabled:bg-slate-300
|
|
128
|
+
text-slate-50 space-x-2 transition-all ease-in-out duration-150 w-32"
|
|
129
|
+
on:click={refreshPayload}
|
|
130
|
+
>
|
|
131
|
+
<i class="bi bi-arrow-clockwise"></i>
|
|
132
|
+
|
|
133
|
+
<span> Refresh Json </span>
|
|
134
|
+
</button> -->
|
|
135
|
+
{/if}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
<div class=" grid">
|
|
139
|
+
<textarea
|
|
140
|
+
bind:value={code}
|
|
141
|
+
readonly={!readOnly}
|
|
142
|
+
{rows}
|
|
143
|
+
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"
|
|
144
|
+
/>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
};
|
|
16
|
+
exports?: {} | undefined;
|
|
17
|
+
bindings?: string | undefined;
|
|
18
|
+
};
|
|
19
|
+
export type CodePresenterProps = typeof __propDef.props;
|
|
20
|
+
export type CodePresenterEvents = typeof __propDef.events;
|
|
21
|
+
export type CodePresenterSlots = typeof __propDef.slots;
|
|
22
|
+
export default class CodePresenter extends SvelteComponent<CodePresenterProps, CodePresenterEvents, CodePresenterSlots> {
|
|
23
|
+
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 ";
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -14,6 +14,7 @@ export let customCss = "";
|
|
|
14
14
|
export let visible = true;
|
|
15
15
|
export let inputType = "datetime-local";
|
|
16
16
|
export let disabled = false;
|
|
17
|
+
export let size = "lg";
|
|
17
18
|
let _value = "";
|
|
18
19
|
function padZero(num) {
|
|
19
20
|
return num > 9 ? `${num}` : `0${num}`;
|
|
@@ -84,6 +85,7 @@ onMount(() => {
|
|
|
84
85
|
on:validated={validateElement}
|
|
85
86
|
{customCss}
|
|
86
87
|
{visible}
|
|
88
|
+
{size}
|
|
87
89
|
autoApplyCss={true}
|
|
88
90
|
>
|
|
89
91
|
<input
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Size } from './types.js';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
labelText?: string | undefined;
|
|
@@ -15,6 +16,7 @@ declare const __propDef: {
|
|
|
15
16
|
visible?: boolean;
|
|
16
17
|
inputType?: "date" | "datetime-local";
|
|
17
18
|
disabled?: boolean;
|
|
19
|
+
size?: Size;
|
|
18
20
|
isValid?: boolean;
|
|
19
21
|
};
|
|
20
22
|
events: {
|
|
@@ -8,7 +8,7 @@ export let textColor = "white";
|
|
|
8
8
|
{size === 'sm' ? 'h-5 w-5' : ''}
|
|
9
9
|
{size === 'md' ? 'h-8 w-8' : ''}
|
|
10
10
|
{size === 'lg' ? 'h-10 w-10' : ''}
|
|
11
|
-
{size === 'xl' ? 'h-
|
|
11
|
+
{size === 'xl' ? 'h-16 w-16' : ''}
|
|
12
12
|
{textColor === 'red' ? 'text-red-500' : ''}
|
|
13
13
|
{textColor === 'dark' ? 'text-slate-950' : ''}
|
|
14
14
|
{textColor === 'indigo' ? 'text-indigo-500' : ''}
|
package/dist/date-utils.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
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;
|
|
2
|
+
export declare function getMonthLimits(date: Date | undefined): {
|
|
3
|
+
dateStart: Date;
|
|
4
|
+
dateEnd: Date;
|
|
5
|
+
};
|
package/dist/date-utils.js
CHANGED
|
@@ -16,3 +16,14 @@ export function formatDateTime(dateTime, showTimeStamp = false, timeStyle = 'sho
|
|
|
16
16
|
}
|
|
17
17
|
return dateFormatted;
|
|
18
18
|
}
|
|
19
|
+
export function getMonthLimits(date) {
|
|
20
|
+
date ??= new Date();
|
|
21
|
+
const year = date.getFullYear();
|
|
22
|
+
const month = date.getMonth();
|
|
23
|
+
const dateStart = new Date(year, month, 1);
|
|
24
|
+
const dateEnd = new Date(year, month + 1, 0);
|
|
25
|
+
return {
|
|
26
|
+
dateStart,
|
|
27
|
+
dateEnd
|
|
28
|
+
};
|
|
29
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,9 +30,10 @@ import Pill from "./components/Pill.svelte";
|
|
|
30
30
|
import PillBoolean from "./components/PillBoolean.svelte";
|
|
31
31
|
import DropDownButton from "./components/DropDownButton.svelte";
|
|
32
32
|
import Table from "./components/Table.svelte";
|
|
33
|
-
import { formatDateTime } from "./date-utils.js";
|
|
33
|
+
import { formatDateTime, getMonthLimits } from "./date-utils.js";
|
|
34
34
|
import { formatNumber } from "./number-utils.js";
|
|
35
35
|
import ListBox from "./components/ListBox.svelte";
|
|
36
36
|
import HeadlessMenu from "./components/HeadlessMenu.svelte";
|
|
37
|
+
import CodePresenter from "./components/CodePresenter.svelte";
|
|
37
38
|
import Drawer from "./components/Drawer.svelte";
|
|
38
|
-
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, PillBoolean, DropDownButton, Table, ListBox, HeadlessMenu, Drawer, formatDateTime, formatNumber };
|
|
39
|
+
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, PillBoolean, DropDownButton, Table, ListBox, HeadlessMenu, Drawer, CodePresenter, formatDateTime, getMonthLimits, formatNumber, };
|
package/dist/index.js
CHANGED
|
@@ -31,9 +31,10 @@ import Pill from "./components/Pill.svelte";
|
|
|
31
31
|
import PillBoolean from "./components/PillBoolean.svelte";
|
|
32
32
|
import DropDownButton from "./components/DropDownButton.svelte";
|
|
33
33
|
import Table from "./components/Table.svelte";
|
|
34
|
-
import { formatDateTime } from "./date-utils.js";
|
|
34
|
+
import { formatDateTime, getMonthLimits } from "./date-utils.js";
|
|
35
35
|
import { formatNumber } from "./number-utils.js";
|
|
36
36
|
import ListBox from "./components/ListBox.svelte";
|
|
37
37
|
import HeadlessMenu from "./components/HeadlessMenu.svelte";
|
|
38
|
+
import CodePresenter from "./components/CodePresenter.svelte";
|
|
38
39
|
import Drawer from "./components/Drawer.svelte";
|
|
39
|
-
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, PillBoolean, DropDownButton, Table, ListBox, HeadlessMenu, Drawer, formatDateTime, formatNumber };
|
|
40
|
+
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, PillBoolean, DropDownButton, Table, ListBox, HeadlessMenu, Drawer, CodePresenter, formatDateTime, getMonthLimits, formatNumber, };
|