lutra 0.0.19 → 0.0.33
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/color.css +0 -0
- package/dist/display/Avatar.svelte +1 -1
- package/dist/display/Avatar.svelte.d.ts +18 -22
- package/dist/display/Badge.svelte +2 -4
- package/dist/display/Badge.svelte.d.ts +28 -32
- package/dist/display/Callout.svelte +8 -8
- package/dist/display/Callout.svelte.d.ts +27 -35
- package/dist/display/Close.svelte.d.ts +17 -20
- package/dist/display/Code.svelte +26 -31
- package/dist/display/Code.svelte.d.ts +31 -30
- package/dist/display/ContextTip.svelte +2 -5
- package/dist/display/ContextTip.svelte.d.ts +16 -20
- package/dist/display/DataList.svelte +16 -0
- package/dist/display/DataList.svelte.d.ts +21 -0
- package/dist/display/Details.svelte.d.ts +25 -30
- package/dist/display/Hero.svelte.d.ts +24 -28
- package/dist/display/Icon.svelte +3 -4
- package/dist/display/Icon.svelte.d.ts +18 -23
- package/dist/display/IconButton.svelte +12 -5
- package/dist/display/IconButton.svelte.d.ts +26 -29
- package/dist/display/Image.svelte.d.ts +25 -36
- package/dist/display/Indicator.svelte.d.ts +21 -22
- package/dist/display/Inset.svelte.d.ts +16 -20
- package/dist/display/LineChart.svelte +385 -0
- package/dist/display/LineChart.svelte.d.ts +24 -0
- package/dist/display/LoadingIndicator.svelte +33 -0
- package/dist/display/LoadingIndicator.svelte.d.ts +15 -0
- package/dist/display/Modal.svelte +116 -0
- package/dist/display/Modal.svelte.d.ts +27 -0
- package/dist/display/Notification.svelte.d.ts +22 -41
- package/dist/display/Panel.svelte +23 -0
- package/dist/display/Panel.svelte.d.ts +19 -0
- package/dist/display/Popup.svelte.d.ts +23 -28
- package/dist/{data → display}/Stat.svelte +9 -17
- package/dist/display/Stat.svelte.d.ts +30 -0
- package/dist/display/Table.svelte +14 -10
- package/dist/display/Table.svelte.d.ts +22 -32
- package/dist/display/TablePaginator.svelte +51 -0
- package/dist/display/TablePaginator.svelte.d.ts +21 -0
- package/dist/display/Tag.svelte.d.ts +29 -32
- package/dist/display/Tooltip.svelte +5 -4
- package/dist/display/Tooltip.svelte.d.ts +21 -26
- package/dist/display/chart.d.ts +78 -0
- package/dist/display/chart.js +212 -0
- package/dist/display/index.d.ts +11 -1
- package/dist/display/index.js +11 -1
- package/dist/display/notifications.svelte.d.ts +3 -3
- package/dist/display/notifications.svelte.js +2 -2
- package/dist/form/Button.svelte +7 -2
- package/dist/form/Button.svelte.d.ts +25 -35
- package/dist/form/FieldActions.svelte +25 -3
- package/dist/form/FieldActions.svelte.d.ts +18 -22
- package/dist/form/FieldContainer.svelte +1 -1
- package/dist/form/FieldContainer.svelte.d.ts +17 -22
- package/dist/form/FieldContent.svelte +52 -33
- package/dist/form/FieldContent.svelte.d.ts +28 -56
- package/dist/form/FieldError.svelte.d.ts +17 -20
- package/dist/form/FieldSection.svelte.d.ts +18 -32
- package/dist/form/Fieldset.svelte.d.ts +29 -40
- package/dist/form/Form.svelte +55 -16
- package/dist/form/Form.svelte.d.ts +36 -31
- package/dist/form/ImageUpload.svelte +259 -0
- package/dist/form/ImageUpload.svelte.d.ts +31 -0
- package/dist/form/Input.svelte +192 -153
- package/dist/form/Input.svelte.d.ts +115 -140
- package/dist/form/InputLength.svelte.d.ts +19 -20
- package/dist/form/Label.svelte +21 -4
- package/dist/form/Label.svelte.d.ts +24 -30
- package/dist/form/LogoUpload.svelte +100 -0
- package/dist/form/LogoUpload.svelte.d.ts +29 -0
- package/dist/form/Select.svelte +84 -36
- package/dist/form/Select.svelte.d.ts +69 -96
- package/dist/form/Textarea.svelte +163 -0
- package/dist/form/Textarea.svelte.d.ts +108 -0
- package/dist/form/Toggle.svelte +2 -0
- package/dist/form/Toggle.svelte.d.ts +15 -0
- package/dist/form/client.svelte.d.ts +8 -9
- package/dist/form/client.svelte.js +18 -10
- package/dist/form/form.d.ts +6 -4
- package/dist/form/form.js +23 -9
- package/dist/form/index.d.ts +6 -3
- package/dist/form/index.js +6 -3
- package/dist/form/types.d.ts +11 -1
- package/dist/icons/IconAlert.svelte.d.ts +23 -0
- package/dist/icons/{Copy.svelte → IconCopy.svelte} +1 -1
- package/dist/icons/IconCopy.svelte.d.ts +23 -0
- package/dist/icons/IconDone.svelte.d.ts +23 -0
- package/dist/icons/IconError.svelte.d.ts +23 -0
- package/dist/icons/IconHelp.svelte.d.ts +23 -0
- package/dist/icons/IconHide.svelte.d.ts +23 -0
- package/dist/icons/IconInfo.svelte.d.ts +23 -0
- package/dist/icons/IconLink.svelte.d.ts +23 -0
- package/dist/icons/IconMenuBurger.svelte.d.ts +23 -0
- package/dist/icons/IconMenuDots.svelte.d.ts +23 -0
- package/dist/icons/IconSearch.svelte +3 -0
- package/dist/icons/IconSearch.svelte.d.ts +23 -0
- package/dist/icons/IconShow.svelte.d.ts +23 -0
- package/dist/icons/IconSuccess.svelte.d.ts +23 -0
- package/dist/icons/IconWarning.svelte.d.ts +23 -0
- package/dist/icons/index.d.ts +14 -11
- package/dist/icons/index.js +14 -11
- package/dist/layout/Layout.svelte +7 -5
- package/dist/layout/Layout.svelte.d.ts +19 -22
- package/dist/layout/LayoutFooter.svelte.d.ts +17 -18
- package/dist/layout/LayoutGrid.svelte.d.ts +25 -36
- package/dist/layout/LayoutHeader.svelte +3 -0
- package/dist/layout/LayoutHeader.svelte.d.ts +33 -38
- package/dist/layout/LayoutSideMenu.svelte +18 -17
- package/dist/layout/LayoutSideMenu.svelte.d.ts +18 -22
- package/dist/layout/Overlay.svelte.d.ts +22 -32
- package/dist/layout/OverlayContainer.svelte.d.ts +14 -15
- package/dist/layout/OverlayLayer.svelte +6 -11
- package/dist/layout/OverlayLayer.svelte.d.ts +17 -20
- package/dist/layout/PageContent.svelte +9 -24
- package/dist/layout/PageContent.svelte.d.ts +23 -26
- package/dist/layout/Theme.svelte +19 -4
- package/dist/layout/Theme.svelte.d.ts +17 -22
- package/dist/layout/UIContent.svelte.d.ts +16 -20
- package/dist/layout/index.d.ts +5 -1
- package/dist/layout/index.js +5 -1
- package/dist/layout/overlays.svelte.d.ts +2 -2
- package/dist/nav/Breadcrumb.svelte +1 -1
- package/dist/nav/Breadcrumb.svelte.d.ts +26 -31
- package/dist/nav/Menu.svelte +6 -13
- package/dist/nav/Menu.svelte.d.ts +25 -31
- package/dist/nav/MenuItem.svelte +15 -8
- package/dist/nav/MenuItem.svelte.d.ts +20 -24
- package/dist/nav/MenuTypes.d.ts +7 -7
- package/dist/nav/NavMenu.svelte +7 -9
- package/dist/nav/NavMenu.svelte.d.ts +17 -18
- package/dist/nav/TabbedContent.svelte +1 -1
- package/dist/nav/TabbedContent.svelte.d.ts +21 -22
- package/dist/nav/Tabs.svelte +53 -13
- package/dist/nav/Tabs.svelte.d.ts +24 -25
- package/dist/nav/index.d.ts +2 -1
- package/dist/nav/index.js +2 -1
- package/dist/style.css +176 -79
- package/dist/typo/Clamp.svelte.d.ts +22 -26
- package/dist/typo/H.svelte.d.ts +26 -30
- package/dist/typo/H1.svelte.d.ts +24 -28
- package/dist/typo/H2.svelte.d.ts +24 -28
- package/dist/typo/H3.svelte.d.ts +24 -28
- package/dist/typo/H4.svelte.d.ts +24 -28
- package/dist/typo/H5.svelte.d.ts +24 -28
- package/dist/typo/H6.svelte.d.ts +24 -28
- package/dist/typo/P.svelte.d.ts +24 -28
- package/dist/utils/StringOrComponent.svelte +14 -0
- package/dist/utils/StringOrComponent.svelte.d.ts +19 -0
- package/dist/utils/StringOrSnippet.svelte +11 -0
- package/dist/utils/StringOrSnippet.svelte.d.ts +19 -0
- package/dist/utils/color.d.ts +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/isSnippet.d.ts +3 -5
- package/dist/utils/isSnippet.js +9 -4
- package/package.json +32 -25
- package/dist/data/Stat.svelte.d.ts +0 -39
- package/dist/data/index.d.ts +0 -1
- package/dist/data/index.js +0 -1
- package/dist/grid/Column.svelte +0 -11
- package/dist/grid/Column.svelte.d.ts +0 -22
- package/dist/grid/Grid.svelte +0 -19
- package/dist/grid/Grid.svelte.d.ts +0 -24
- package/dist/grid/Row.svelte +0 -44
- package/dist/grid/Row.svelte.d.ts +0 -24
- package/dist/icons/Alert.svelte.d.ts +0 -23
- package/dist/icons/Copy.svelte.d.ts +0 -23
- package/dist/icons/Done.svelte.d.ts +0 -23
- package/dist/icons/Error.svelte.d.ts +0 -23
- package/dist/icons/Help.svelte.d.ts +0 -23
- package/dist/icons/Hide.svelte.d.ts +0 -23
- package/dist/icons/Info.svelte.d.ts +0 -23
- package/dist/icons/Link.svelte.d.ts +0 -23
- package/dist/icons/MenuBurger.svelte.d.ts +0 -23
- package/dist/icons/MenuDots.svelte.d.ts +0 -23
- package/dist/icons/Show.svelte.d.ts +0 -23
- package/dist/icons/Success.svelte.d.ts +0 -23
- package/dist/icons/Warning.svelte.d.ts +0 -23
- package/dist/utils/StringOrComponentOrSnippet.svelte +0 -14
- package/dist/utils/StringOrComponentOrSnippet.svelte.d.ts +0 -24
- /package/dist/icons/{Alert.svelte → IconAlert.svelte} +0 -0
- /package/dist/icons/{Done.svelte → IconDone.svelte} +0 -0
- /package/dist/icons/{Error.svelte → IconError.svelte} +0 -0
- /package/dist/icons/{Help.svelte → IconHelp.svelte} +0 -0
- /package/dist/icons/{Hide.svelte → IconHide.svelte} +0 -0
- /package/dist/icons/{Info.svelte → IconInfo.svelte} +0 -0
- /package/dist/icons/{Link.svelte → IconLink.svelte} +0 -0
- /package/dist/icons/{MenuBurger.svelte → IconMenuBurger.svelte} +0 -0
- /package/dist/icons/{MenuDots.svelte → IconMenuDots.svelte} +0 -0
- /package/dist/icons/{Show.svelte → IconShow.svelte} +0 -0
- /package/dist/icons/{Success.svelte → IconSuccess.svelte} +0 -0
- /package/dist/icons/{Warning.svelte → IconWarning.svelte} +0 -0
package/dist/form/Select.svelte
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
<script lang="ts">import { getContext } from "svelte";
|
1
|
+
<script lang="ts">import { getContext, onMount } from "svelte";
|
2
2
|
import Label from "./Label.svelte";
|
3
3
|
import { createId } from "../utils/id.js";
|
4
|
-
import Copy from "../icons/
|
5
|
-
import Done from "../icons/
|
6
|
-
import Show from "../icons/
|
7
|
-
import Hide from "../icons/
|
4
|
+
import Copy from "../icons/IconCopy.svelte";
|
5
|
+
import Done from "../icons/IconDone.svelte";
|
6
|
+
import Show from "../icons/IconShow.svelte";
|
7
|
+
import Hide from "../icons/IconHide.svelte";
|
8
8
|
import Tooltip from "../display/Tooltip.svelte";
|
9
9
|
import IconButton from "../display/IconButton.svelte";
|
10
10
|
import { fieldChange, fieldKeydown, ignoreKeys } from "./client.svelte.js";
|
@@ -13,7 +13,7 @@ import { getFromObjWithStringPath } from "./form.js";
|
|
13
13
|
import { ZodType } from "zod";
|
14
14
|
import FieldContent from "./FieldContent.svelte";
|
15
15
|
let {
|
16
|
-
|
16
|
+
autofocus,
|
17
17
|
children,
|
18
18
|
disabled,
|
19
19
|
help,
|
@@ -43,46 +43,94 @@ const issue = $derived(form?.issues?.find((issue2) => issue2.name === name));
|
|
43
43
|
const validator = getContext("form.validators")?.[name];
|
44
44
|
const data = form?.data;
|
45
45
|
const originalData = form?.originalData;
|
46
|
+
if (!value) value = form ? getFromObjWithStringPath(Object.assign(originalData ?? {}, data ?? {}), name) || form?.fields?.[name]?.defaultValue : "";
|
47
|
+
onMount(() => {
|
48
|
+
if (value) fieldChange(form, name, () => el)({});
|
49
|
+
});
|
46
50
|
</script>
|
47
51
|
|
48
52
|
<FieldContent
|
49
53
|
{id}
|
50
54
|
{label}
|
51
55
|
{labelTip}
|
56
|
+
{help}
|
52
57
|
{field}
|
53
58
|
{issue}
|
59
|
+
{required}
|
60
|
+
contained
|
54
61
|
>
|
55
|
-
<
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
62
|
+
<div class="SelectContainer">
|
63
|
+
<select
|
64
|
+
bind:this={el}
|
65
|
+
{autofocus}
|
66
|
+
{disabled}
|
67
|
+
{id}
|
68
|
+
{name}
|
69
|
+
{onblur}
|
70
|
+
{onclick}
|
71
|
+
onchange={fieldChange(form, name, () => el, validator, onchange)}
|
72
|
+
{onfocus}
|
73
|
+
onkeydown={fieldKeydown(form, name, () => el, validator, onkeydown)}
|
74
|
+
{onkeyup}
|
75
|
+
{onkeypress}
|
76
|
+
{placeholder}
|
77
|
+
required={required || field?.required}
|
78
|
+
{results}
|
79
|
+
{tabindex}
|
80
|
+
bind:value={value}
|
81
|
+
>
|
82
|
+
{#if children}
|
83
|
+
{@render children()}
|
84
|
+
{:else if options}
|
85
|
+
{#each options as option}
|
86
|
+
{#if typeof option === 'string'}
|
87
|
+
<option value={option}>{option}</option>
|
88
|
+
{:else}
|
89
|
+
<option value={option.value}>{option.label}</option>
|
90
|
+
{/if}
|
91
|
+
{/each}
|
92
|
+
{/if}
|
93
|
+
</select>
|
94
|
+
<div class="Arrow">
|
95
|
+
<svg width="12px" height="8px" viewBox="0 0 12 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
96
|
+
<g transform="matrix(1,0,0,1,0,0.746639)">
|
97
|
+
<path d="M6,4.248L11.493,0L12,0.507L6,6.507L0,0.507L0.507,0L6,4.248Z" fill="currentColor" stroke="currentColor"/>
|
98
|
+
</g>
|
99
|
+
</svg>
|
100
|
+
</div>
|
101
|
+
</div>
|
85
102
|
</FieldContent>
|
86
103
|
|
87
104
|
<style>
|
105
|
+
.SelectContainer {
|
106
|
+
display: grid;
|
107
|
+
grid-template-columns: 1fr;
|
108
|
+
grid-template-areas: "select";
|
109
|
+
align-items: center;
|
110
|
+
width: 100%;
|
111
|
+
}
|
112
|
+
select {
|
113
|
+
padding-inline-end: calc(1.5em + 10px);
|
114
|
+
width: 100%;
|
115
|
+
appearance: none;
|
116
|
+
border: none !important;
|
117
|
+
border-radius: 0;
|
118
|
+
grid-area: select;
|
119
|
+
background: none;
|
120
|
+
}
|
121
|
+
.Arrow {
|
122
|
+
grid-area: select;
|
123
|
+
pointer-events: none;
|
124
|
+
display: flex;
|
125
|
+
align-items: center;
|
126
|
+
justify-content: end;
|
127
|
+
padding-inline-end: 0.75em;
|
128
|
+
}
|
129
|
+
svg {
|
130
|
+
display: block;
|
131
|
+
color: var(--field-text);
|
132
|
+
}
|
133
|
+
select:focus-visible {
|
134
|
+
outline: none;
|
135
|
+
}
|
88
136
|
</style>
|
@@ -1,97 +1,70 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
}) | undefined;
|
12
|
-
id?: import("svelte").Bindable<string | undefined>;
|
13
|
-
label?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
14
|
-
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
15
|
-
}) | undefined;
|
16
|
-
labelTip?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
17
|
-
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
18
|
-
}) | undefined;
|
19
|
-
name: string;
|
20
|
-
onblur?: ((e: FocusEvent) => void) | undefined;
|
21
|
-
onchange?: ((e: Event) => void) | undefined;
|
22
|
-
onclick?: ((e: MouseEvent) => void) | undefined;
|
23
|
-
onfocus?: ((e: FocusEvent) => void) | undefined;
|
24
|
-
onkeyup?: ((e: KeyboardEvent) => void) | undefined;
|
25
|
-
onkeydown?: ((e: KeyboardEvent) => void) | undefined;
|
26
|
-
onkeypress?: ((e: KeyboardEvent) => void) | undefined;
|
27
|
-
options?: string[] | {
|
28
|
-
value: string;
|
29
|
-
label: string;
|
30
|
-
}[] | undefined;
|
31
|
-
placeholder?: string | undefined;
|
32
|
-
suffix?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
33
|
-
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
34
|
-
}) | undefined;
|
35
|
-
prefix?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
36
|
-
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
37
|
-
}) | undefined;
|
38
|
-
required?: boolean | undefined;
|
39
|
-
results?: number | undefined;
|
40
|
-
shape?: "default" | "circle" | "rounded" | "pill" | undefined;
|
41
|
-
src?: string | undefined;
|
42
|
-
tabindex?: number | undefined;
|
43
|
-
value?: import("svelte").Bindable<string | undefined>;
|
44
|
-
};
|
45
|
-
events: {
|
46
|
-
[evt: string]: CustomEvent<any>;
|
47
|
-
};
|
48
|
-
slots: {};
|
49
|
-
};
|
50
|
-
export type SelectProps = typeof __propDef.props;
|
51
|
-
export type SelectEvents = typeof __propDef.events;
|
52
|
-
export type SelectSlots = typeof __propDef.slots;
|
53
|
-
export default class Select extends SvelteComponent<SelectProps, SelectEvents, SelectSlots> {
|
54
|
-
constructor(options?: import("svelte").ComponentConstructorOptions<{
|
55
|
-
attrs?: Record<string, string> | undefined;
|
56
|
-
children?: ((this: void) => typeof import("svelte").SnippetReturn & {
|
57
|
-
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
58
|
-
}) | undefined;
|
59
|
-
disabled?: boolean | undefined;
|
60
|
-
help?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
61
|
-
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
62
|
-
}) | undefined;
|
63
|
-
id?: import("svelte").Bindable<string | undefined>;
|
64
|
-
label?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
65
|
-
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
66
|
-
}) | undefined;
|
67
|
-
labelTip?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
68
|
-
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
69
|
-
}) | undefined;
|
70
|
-
name: string;
|
71
|
-
onblur?: ((e: FocusEvent) => void) | undefined;
|
72
|
-
onchange?: ((e: Event) => void) | undefined;
|
73
|
-
onclick?: ((e: MouseEvent) => void) | undefined;
|
74
|
-
onfocus?: ((e: FocusEvent) => void) | undefined;
|
75
|
-
onkeyup?: ((e: KeyboardEvent) => void) | undefined;
|
76
|
-
onkeydown?: ((e: KeyboardEvent) => void) | undefined;
|
77
|
-
onkeypress?: ((e: KeyboardEvent) => void) | undefined;
|
78
|
-
options?: string[] | {
|
79
|
-
value: string;
|
80
|
-
label: string;
|
81
|
-
}[] | undefined;
|
82
|
-
placeholder?: string | undefined;
|
83
|
-
suffix?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
84
|
-
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
85
|
-
}) | undefined;
|
86
|
-
prefix?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
87
|
-
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
88
|
-
}) | undefined;
|
89
|
-
required?: boolean | undefined;
|
90
|
-
results?: number | undefined;
|
91
|
-
shape?: "default" | "circle" | "rounded" | "pill" | undefined;
|
92
|
-
src?: string | undefined;
|
93
|
-
tabindex?: number | undefined;
|
94
|
-
value?: import("svelte").Bindable<string | undefined>;
|
95
|
-
}>);
|
1
|
+
import { type Snippet } from "svelte";
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
4
|
+
$$bindings?: Bindings;
|
5
|
+
} & Exports;
|
6
|
+
(internal: unknown, props: Props & {
|
7
|
+
$$events?: Events;
|
8
|
+
$$slots?: Slots;
|
9
|
+
}): Exports;
|
10
|
+
z_$$bindings?: Bindings;
|
96
11
|
}
|
97
|
-
|
12
|
+
declare const Select: $$__sveltets_2_IsomorphicComponent<{
|
13
|
+
/** Whether the input should be autofocused. */
|
14
|
+
autofocus?: boolean;
|
15
|
+
/** Options for the select element. */
|
16
|
+
children?: Snippet;
|
17
|
+
/** Whether the input should be disabled. */
|
18
|
+
disabled?: boolean;
|
19
|
+
/** Help text to display below the input. */
|
20
|
+
help?: string | Snippet;
|
21
|
+
/** A random id is generated if not provided. */
|
22
|
+
id?: string;
|
23
|
+
/** The label for the input */
|
24
|
+
label?: string | Snippet;
|
25
|
+
/** Context tooltip for a label. Renders with a questionmark using ContextTip. */
|
26
|
+
labelTip?: string | Snippet;
|
27
|
+
/** The name of the input element. */
|
28
|
+
name: string;
|
29
|
+
/** The onblur event handler */
|
30
|
+
onblur?: (e: FocusEvent) => void;
|
31
|
+
/** Onchange event handler */
|
32
|
+
onchange?: (e: Event) => void;
|
33
|
+
/** Onclick event handler */
|
34
|
+
onclick?: (e: MouseEvent) => void;
|
35
|
+
/** Onfocus event handler */
|
36
|
+
onfocus?: (e: FocusEvent) => void;
|
37
|
+
/** Keyup event handler */
|
38
|
+
onkeyup?: (e: KeyboardEvent) => void;
|
39
|
+
/** Keydown event handler */
|
40
|
+
onkeydown?: (e: KeyboardEvent) => void;
|
41
|
+
/** Keypress event handler */
|
42
|
+
onkeypress?: (e: KeyboardEvent) => void;
|
43
|
+
/** The options for the select element. */
|
44
|
+
options?: string[] | {
|
45
|
+
value: string;
|
46
|
+
label: string;
|
47
|
+
}[];
|
48
|
+
/** Placeholder text to display when the input is empty. */
|
49
|
+
placeholder?: string;
|
50
|
+
/** Suffix content, to display after the input. */
|
51
|
+
suffix?: string | Snippet;
|
52
|
+
/** Prefix content, to display before the input. */
|
53
|
+
prefix?: string | Snippet;
|
54
|
+
/** Whether the input should be required. */
|
55
|
+
required?: boolean;
|
56
|
+
/** The maximum number of items that should be displayed in the drop-down list of previous search queries. Safari only. */
|
57
|
+
results?: number;
|
58
|
+
/** The shape of the input element. */
|
59
|
+
shape?: "default" | "rounded" | "pill" | "circle";
|
60
|
+
/** Source URL for the image type. */
|
61
|
+
src?: string;
|
62
|
+
/** An integer attribute indicating if the element can take input focus (is focusable), if it should participate to sequential keyboard navigation. */
|
63
|
+
tabindex?: number;
|
64
|
+
/** The value of the input element. */
|
65
|
+
value?: string | number | boolean | null;
|
66
|
+
}, {
|
67
|
+
[evt: string]: CustomEvent<any>;
|
68
|
+
}, {}, {}, "value" | "id">;
|
69
|
+
type Select = InstanceType<typeof Select>;
|
70
|
+
export default Select;
|
@@ -0,0 +1,163 @@
|
|
1
|
+
<script lang="ts">import { getContext, onMount } from "svelte";
|
2
|
+
import { createId } from "../utils/id.js";
|
3
|
+
import { IconCopy, IconDone, IconShow } from "../icons/index.js";
|
4
|
+
import { Tooltip, IconButton } from "../display/index.js";
|
5
|
+
import { FieldContent, fieldChange, fieldKeydown, ignoreKeys, getFromObjWithStringPath } from "../form/index.js";
|
6
|
+
import { ZodType } from "zod";
|
7
|
+
let {
|
8
|
+
autofocus,
|
9
|
+
autocapitalize,
|
10
|
+
autocomplete,
|
11
|
+
autocorrect,
|
12
|
+
autoresize,
|
13
|
+
checked,
|
14
|
+
contained,
|
15
|
+
copyable,
|
16
|
+
defaultValue,
|
17
|
+
dirname,
|
18
|
+
disabled,
|
19
|
+
enterkeyhint,
|
20
|
+
help,
|
21
|
+
id = $bindable(createId()),
|
22
|
+
inputmode,
|
23
|
+
label,
|
24
|
+
labelTip,
|
25
|
+
list,
|
26
|
+
maxlength,
|
27
|
+
minlength,
|
28
|
+
name,
|
29
|
+
pattern,
|
30
|
+
placeholder,
|
31
|
+
suffix,
|
32
|
+
onblur,
|
33
|
+
onchange,
|
34
|
+
onclick,
|
35
|
+
onfocus,
|
36
|
+
onkeydown,
|
37
|
+
onkeyup,
|
38
|
+
onkeypress,
|
39
|
+
prefix,
|
40
|
+
readonly,
|
41
|
+
required,
|
42
|
+
resize = true,
|
43
|
+
shape = "rounded",
|
44
|
+
step,
|
45
|
+
style,
|
46
|
+
tabindex,
|
47
|
+
title,
|
48
|
+
value = $bindable(),
|
49
|
+
...rest
|
50
|
+
} = $props();
|
51
|
+
let el = $state();
|
52
|
+
let copyTitle = $state("Copy");
|
53
|
+
let viewTitle = $state("Show");
|
54
|
+
let copyTooltipOpen = $state(false);
|
55
|
+
let copyBtnIcon = $state(IconCopy);
|
56
|
+
let viewBtnIcon = $state(IconShow);
|
57
|
+
let resizeClass = $derived(resize === true ? "resize" : resize === false ? "" : resize);
|
58
|
+
const form = getContext("form");
|
59
|
+
const field = $derived(form?.fields[name]);
|
60
|
+
const issue = $derived(form?.issues?.find((issue2) => issue2.name === name));
|
61
|
+
const validator = getContext("form.validators")?.[name];
|
62
|
+
const data = form?.data;
|
63
|
+
const originalData = form?.originalData;
|
64
|
+
if (!value) value = form ? getFromObjWithStringPath(Object.assign(originalData ?? {}, data ?? {}), name) || form?.fields?.[name]?.defaultValue : "";
|
65
|
+
function copy(e) {
|
66
|
+
e.preventDefault();
|
67
|
+
if (!el) return;
|
68
|
+
if (navigator.clipboard) {
|
69
|
+
navigator.clipboard.writeText(value);
|
70
|
+
} else {
|
71
|
+
el.focus();
|
72
|
+
el.select();
|
73
|
+
document.execCommand("copy");
|
74
|
+
}
|
75
|
+
copyBtnIcon = IconDone;
|
76
|
+
copyTitle = "Copied!";
|
77
|
+
copyTooltipOpen = true;
|
78
|
+
setTimeout(() => {
|
79
|
+
copyBtnIcon = IconCopy;
|
80
|
+
copyTitle = "Copy";
|
81
|
+
copyTooltipOpen = false;
|
82
|
+
}, 1500);
|
83
|
+
el.focus();
|
84
|
+
}
|
85
|
+
function onresize() {
|
86
|
+
if (!autoresize || !el || !value) return;
|
87
|
+
setTimeout(() => {
|
88
|
+
el.style.height = "auto";
|
89
|
+
el.style.height = `${el.scrollHeight + 2}px`;
|
90
|
+
}, 0);
|
91
|
+
}
|
92
|
+
onMount(() => {
|
93
|
+
if (value) fieldChange(form, name, () => el)({});
|
94
|
+
setTimeout(() => {
|
95
|
+
onresize();
|
96
|
+
}, 5);
|
97
|
+
});
|
98
|
+
</script>
|
99
|
+
|
100
|
+
<svelte:window onresize={onresize} />
|
101
|
+
|
102
|
+
<FieldContent
|
103
|
+
{id}
|
104
|
+
{label}
|
105
|
+
{labelTip}
|
106
|
+
{field}
|
107
|
+
{issue}
|
108
|
+
{help}
|
109
|
+
{suffix}
|
110
|
+
{required}
|
111
|
+
>
|
112
|
+
<textarea
|
113
|
+
class="{resizeClass}"
|
114
|
+
bind:this={el}
|
115
|
+
{autofocus}
|
116
|
+
autocapitalize={typeof autocapitalize === 'string' ? autocapitalize : (typeof autocapitalize === 'boolean' ? (autocapitalize ? 'on' : 'off') : undefined)}
|
117
|
+
{autocomplete}
|
118
|
+
autocorrect={typeof autocorrect === 'boolean' ? (autocorrect ? 'on' : 'off') : undefined}
|
119
|
+
{dirname}
|
120
|
+
{disabled}
|
121
|
+
{enterkeyhint}
|
122
|
+
{id}
|
123
|
+
maxlength={maxlength ? maxlength : field?.maxlength}
|
124
|
+
minlength={minlength ? minlength : field?.minlength}
|
125
|
+
{name}
|
126
|
+
{onblur}
|
127
|
+
{onclick}
|
128
|
+
onchange={fieldChange(form, name, () => el, validator, onchange)}
|
129
|
+
{onfocus}
|
130
|
+
onkeydown={() => { onresize(); return fieldKeydown(form, name, () => el, validator, onkeydown) }}
|
131
|
+
{onkeyup}
|
132
|
+
{onkeypress}
|
133
|
+
{placeholder}
|
134
|
+
{readonly}
|
135
|
+
required={required || field?.required}
|
136
|
+
{tabindex}
|
137
|
+
{title}
|
138
|
+
bind:value={value}
|
139
|
+
{style}
|
140
|
+
{...rest}
|
141
|
+
></textarea>
|
142
|
+
|
143
|
+
{#if copyable}
|
144
|
+
<Tooltip tip={copyTitle} open={copyTooltipOpen}>
|
145
|
+
<IconButton icon={copyBtnIcon} onclick={copy} disabled={copyTooltipOpen} />
|
146
|
+
</Tooltip>
|
147
|
+
{/if}
|
148
|
+
</FieldContent>
|
149
|
+
|
150
|
+
<style>
|
151
|
+
textarea {
|
152
|
+
resize: none;
|
153
|
+
}
|
154
|
+
textarea.resize {
|
155
|
+
resize: both;
|
156
|
+
}
|
157
|
+
textarea.resize.horizontal {
|
158
|
+
resize: horizontal;
|
159
|
+
}
|
160
|
+
textarea.resize.vertical {
|
161
|
+
resize: vertical;
|
162
|
+
}
|
163
|
+
</style>
|
@@ -0,0 +1,108 @@
|
|
1
|
+
import { type Snippet } from "svelte";
|
2
|
+
import type { Autocomplete } from "../form/types.js";
|
3
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
4
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
5
|
+
$$bindings?: Bindings;
|
6
|
+
} & Exports;
|
7
|
+
(internal: unknown, props: Props & {
|
8
|
+
$$events?: Events;
|
9
|
+
$$slots?: Slots;
|
10
|
+
}): Exports;
|
11
|
+
z_$$bindings?: Bindings;
|
12
|
+
}
|
13
|
+
declare const Textarea: $$__sveltets_2_IsomorphicComponent<{
|
14
|
+
/** Whether the input should be autofocused. */
|
15
|
+
autofocus?: boolean;
|
16
|
+
/** Whether the input should be autocapitalized. */
|
17
|
+
autocapitalize?: boolean | "off" | "none" | "on" | "sentences" | "words" | "characters";
|
18
|
+
/** Specifies whether autocomplete is enabled for the input. */
|
19
|
+
autocomplete?: Autocomplete;
|
20
|
+
/** Whether the input should be autocorrected. (Safari only) */
|
21
|
+
autocorrect?: boolean;
|
22
|
+
/** Whether the input should resize automatically. */
|
23
|
+
autoresize?: boolean;
|
24
|
+
/** A hint to the browser for which capture method to use. */
|
25
|
+
capture?: "user" | "environment";
|
26
|
+
/** Whether the input should be checked. */
|
27
|
+
checked?: boolean;
|
28
|
+
/** Whether the input should be contained. */
|
29
|
+
contained?: boolean;
|
30
|
+
/** Whether the input should be copyable. */
|
31
|
+
copyable?: boolean;
|
32
|
+
/** The default value of the input element. */
|
33
|
+
defaultValue?: string;
|
34
|
+
/** Form field name for the directionality of the element's text content during form submission */
|
35
|
+
dirname?: string;
|
36
|
+
/** Whether the input should be disabled. */
|
37
|
+
disabled?: boolean;
|
38
|
+
/** A hint to the browser for which enter key to display for the input. */
|
39
|
+
enterkeyhint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send";
|
40
|
+
/** The height of the input element. Valid for image inputs. */
|
41
|
+
height?: number;
|
42
|
+
/** Help text to display below the input. */
|
43
|
+
help?: string | Snippet;
|
44
|
+
/** A random id is generated if not provided. */
|
45
|
+
id?: string;
|
46
|
+
/** Whether the input should be indeterminate. */
|
47
|
+
indeterminate?: boolean;
|
48
|
+
/** A hint to the browser for which keyboard to display. This is only used for type="text" inputs. Strongly consider using type="email" or type="url" etc. instead */
|
49
|
+
inputmode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search";
|
50
|
+
/** The label for the input */
|
51
|
+
label?: string | Snippet;
|
52
|
+
/** Context tooltip for a label. Renders with a questionmark using ContextTip. */
|
53
|
+
labelTip?: string | Snippet;
|
54
|
+
/** The id of a datalist element that contains pre-defined options for the input element. */
|
55
|
+
list?: string;
|
56
|
+
/** The maximum number of characters (as UTF-16 code units) the user can enter into the input. Valid for text, search, url, tel, email, and password. */
|
57
|
+
maxlength?: number;
|
58
|
+
/** The minimum number of characters (as UTF-16 code units) the user can enter into the input. Valid for text, search, url, tel, email, and password. */
|
59
|
+
minlength?: number;
|
60
|
+
/** The name of the input element. */
|
61
|
+
name: string;
|
62
|
+
/** The onblur event handler */
|
63
|
+
onblur?: (e: FocusEvent) => void;
|
64
|
+
/** Onchange event handler */
|
65
|
+
onchange?: (e: Event) => void;
|
66
|
+
/** Onclick event handler */
|
67
|
+
onclick?: (e: MouseEvent) => void;
|
68
|
+
/** Onfocus event handler */
|
69
|
+
onfocus?: (e: FocusEvent) => void;
|
70
|
+
/** Keyup event handler */
|
71
|
+
onkeyup?: (e: KeyboardEvent) => void;
|
72
|
+
/** Keydown event handler */
|
73
|
+
onkeydown?: (e: KeyboardEvent) => void;
|
74
|
+
/** Keypress event handler */
|
75
|
+
onkeypress?: (e: KeyboardEvent) => void;
|
76
|
+
/** A regular expression that the input's value is checked against. Valid for text, search, url, tel, email, and password. */
|
77
|
+
pattern?: string;
|
78
|
+
/** Placeholder text to display when the input is empty. */
|
79
|
+
placeholder?: string;
|
80
|
+
/** Suffix content, to display after the input. */
|
81
|
+
suffix?: string | Snippet;
|
82
|
+
/** Prefix content, to display before the input. */
|
83
|
+
prefix?: string | Snippet;
|
84
|
+
/** Whether the input should be read-only. */
|
85
|
+
readonly?: boolean;
|
86
|
+
/** Whether the input should be required. */
|
87
|
+
required?: boolean;
|
88
|
+
/** Whether the textarea is resizable. */
|
89
|
+
resize?: boolean | "both" | "horizontal" | "vertical" | "none";
|
90
|
+
/** The shape of the input element. */
|
91
|
+
shape?: "default" | "rounded" | "pill" | "circle";
|
92
|
+
/** Spellcheck the input. */
|
93
|
+
spellcheck?: boolean;
|
94
|
+
/** A number that specifies the granularity that the value must adhere to. Valid for date, month, week, time, datetime-local, number, and range. */
|
95
|
+
step?: number;
|
96
|
+
/** Inline styles to apply to the input element. */
|
97
|
+
style?: string;
|
98
|
+
/** An integer attribute indicating if the element can take input focus (is focusable), if it should participate to sequential keyboard navigation. */
|
99
|
+
tabindex?: number;
|
100
|
+
/** A string that defines the title of the input element. */
|
101
|
+
title?: string;
|
102
|
+
/** The value of the input element. */
|
103
|
+
value?: string | null;
|
104
|
+
}, {
|
105
|
+
[evt: string]: CustomEvent<any>;
|
106
|
+
}, {}, {}, "value" | "id">;
|
107
|
+
type Textarea = InstanceType<typeof Textarea>;
|
108
|
+
export default Textarea;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
3
|
+
$$bindings?: Bindings;
|
4
|
+
} & Exports;
|
5
|
+
(internal: unknown, props: {
|
6
|
+
$$events?: Events;
|
7
|
+
$$slots?: Slots;
|
8
|
+
}): Exports;
|
9
|
+
z_$$bindings?: Bindings;
|
10
|
+
}
|
11
|
+
declare const Toggle: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
12
|
+
[evt: string]: CustomEvent<any>;
|
13
|
+
}, {}, {}, string>;
|
14
|
+
type Toggle = InstanceType<typeof Toggle>;
|
15
|
+
export default Toggle;
|
@@ -1,15 +1,14 @@
|
|
1
1
|
import type { ZodType } from "zod";
|
2
|
-
import type {
|
2
|
+
import type { LutraForm } from "./types.js";
|
3
3
|
/**
|
4
4
|
* Use a form in a Svelte component.
|
5
5
|
* @param {Form} form - The form to use.
|
6
6
|
* @returns
|
7
7
|
*/
|
8
|
-
export declare function useForm(form:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
} & Form<any>;
|
8
|
+
export declare function useForm(form: LutraForm<any>): LutraForm<any> & {
|
9
|
+
originalData: any;
|
10
|
+
data: any;
|
11
|
+
state: string;
|
13
12
|
};
|
14
13
|
/**
|
15
14
|
* Validate a single field.
|
@@ -18,7 +17,7 @@ export declare function useForm(form: Form<any>): {
|
|
18
17
|
* @param {HTMLInputElement | HTMLSelectElement} el - The element to validate.
|
19
18
|
* @param {ZodType} validator - The validator to use.
|
20
19
|
*/
|
21
|
-
export declare function fieldValidate(form:
|
20
|
+
export declare function fieldValidate(form: LutraForm<any>, name: string, el?: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement, validator?: ZodType<any, any>): void;
|
22
21
|
/**
|
23
22
|
* Keydown event handler for a field.
|
24
23
|
* @param {KeyboardEvent} e - The event.
|
@@ -28,7 +27,7 @@ export declare function fieldValidate(form: Form<any>, name: string, el?: HTMLIn
|
|
28
27
|
* @param {ZodType} validator - The validator to use.
|
29
28
|
* @param {(e: KeyboardEvent) => void} onkeydown - The onkeydown event handler.
|
30
29
|
*/
|
31
|
-
export declare function fieldKeydown(form:
|
30
|
+
export declare function fieldKeydown(form: LutraForm<any>, name: string, el: () => HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | undefined, validator?: ZodType<any, any>, onkeydown?: (e: KeyboardEvent) => void): (e: KeyboardEvent) => Promise<void>;
|
32
31
|
/**
|
33
32
|
* Change event handler for a field.
|
34
33
|
* @param {Event} e - The event.
|
@@ -38,7 +37,7 @@ export declare function fieldKeydown(form: Form<any>, name: string, el: () => HT
|
|
38
37
|
* @param {ZodType} validator - The validator to use.
|
39
38
|
* @param {(e: Event) => void} onchange - The onchange event handler.
|
40
39
|
*/
|
41
|
-
export declare function fieldChange(form:
|
40
|
+
export declare function fieldChange(form: LutraForm<any>, name: string, el: () => HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | undefined, validator?: ZodType<any, any>, onchange?: (e: Event) => void): (e: Event) => Promise<void>;
|
42
41
|
/**
|
43
42
|
* Keys that should be ignored when marking a field as tainted.
|
44
43
|
*/
|